-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
library ieee; | ||
use ieee.std_logic_1164.all; | ||
|
||
entity sr_latch is | ||
port( | ||
s_in, r_in : in std_logic; | ||
q_out, q_not_out : inout std_logic | ||
); | ||
end entity; | ||
|
||
architecture behaviour of sr_latch is | ||
begin | ||
DUT : process(s_in, r_in, q_out, q_not_out) | ||
begin | ||
q_out <= q_not_out nor r_in; | ||
q_not_out <= q_out nor s_in; | ||
end process; | ||
end architecture; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
library ieee; | ||
use ieee.std_logic_1164.all; | ||
|
||
entity tb_sr_latch is | ||
end entity; | ||
|
||
architecture bench of tb_sr_latch is | ||
component sr_latch is | ||
port( | ||
s_in, r_in : in std_logic; | ||
q_out, q_not_out : inout std_logic | ||
); | ||
end component; | ||
|
||
signal s_tb_in, r_tb_in, q_tb_out, q_not_tb_out : std_logic; | ||
|
||
begin | ||
DUT : sr_latch port map( | ||
s_in => s_tb_in, r_in => r_tb_in, q_out => q_tb_out, q_not_out => q_not_tb_out | ||
); | ||
process | ||
begin | ||
s_tb_in <= '0'; | ||
r_tb_in <= '1'; | ||
wait for 50 ns; | ||
assert (q_tb_out = '0') report "Error in q" severity failure; | ||
|
||
s_tb_in <= '0'; | ||
r_tb_in <= '0'; | ||
wait for 50 ns; | ||
assert (q_tb_out = '0') report "Error in q" severity failure; | ||
|
||
s_tb_in <= '1'; | ||
r_tb_in <= '0'; | ||
wait for 50 ns; | ||
assert (q_tb_out = '1') report "Error in q" severity failure; | ||
|
||
s_tb_in <= '0'; | ||
r_tb_in <= '0'; | ||
wait for 50 ns; | ||
assert (q_tb_out = '1') report "Error in q" severity failure; | ||
|
||
s_tb_in <= '0'; | ||
r_tb_in <= '1'; | ||
wait for 50 ns; | ||
assert (q_tb_out = '0') report "Error in q" severity failure; | ||
|
||
wait; | ||
end process; | ||
end architecture; |