delon
Junior Member level 2
Hello, I am a beginner in VHDL. I wrote a code for gated SR latch which is mentioned bellow:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY hw IS
PORT ( ck, s, r : IN std_logic;
q, qnot : BUFFER std_logic);
END hw;
ARCHITECTURE sr OF hw IS
BEGIN
PROCESS (ck,s,r) BEGIN
IF ( ck ='1' AND r='1' AND s='0') THEN
q <='0';
qnot<= NOT q;
ELSIF ( ck ='1' AND r='0' and s='1') THEN
q <='1';
qnot<= NOT q;
ELSIF ( ck ='1' AND r='1' and s='1') THEN
q <='X';
qnot<= 'X';
END IF;
END PROCESS;
END sr;
I run this code as a functional simulation in Altera Quartus II. In the simulation result, I am not getting 'X' for s=r=1 input combination. Here is a screenshot:
For s=1, r=1, I am getting '0' in q. Does it mean that, the PROCESS is not evaluating the condition when s or r changes it's value? What might be the reason for that. Please help.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY hw IS
PORT ( ck, s, r : IN std_logic;
q, qnot : BUFFER std_logic);
END hw;
ARCHITECTURE sr OF hw IS
BEGIN
PROCESS (ck,s,r) BEGIN
IF ( ck ='1' AND r='1' AND s='0') THEN
q <='0';
qnot<= NOT q;
ELSIF ( ck ='1' AND r='0' and s='1') THEN
q <='1';
qnot<= NOT q;
ELSIF ( ck ='1' AND r='1' and s='1') THEN
q <='X';
qnot<= 'X';
END IF;
END PROCESS;
END sr;
I run this code as a functional simulation in Altera Quartus II. In the simulation result, I am not getting 'X' for s=r=1 input combination. Here is a screenshot:
For s=1, r=1, I am getting '0' in q. Does it mean that, the PROCESS is not evaluating the condition when s or r changes it's value? What might be the reason for that. Please help.