No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

registers_test.vhd 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.numeric_std.ALL;
  4. ENTITY registers_test IS
  5. END registers_test;
  6. ARCHITECTURE behavior OF registers_test IS
  7. -- Component Declaration for the Unit Under Test (UUT)
  8. COMPONENT registers
  9. PORT(
  10. addr_A : IN std_logic_vector(0 to 3);
  11. addr_B : IN std_logic_vector(0 to 3);
  12. addr_W : IN std_logic_vector(0 to 3);
  13. W : IN std_logic;
  14. DATA : IN std_logic_vector(0 to 7);
  15. RST : IN std_logic;
  16. CLK : IN std_logic;
  17. QA : OUT std_logic_vector(0 to 7);
  18. QB : OUT std_logic_vector(0 to 7)
  19. );
  20. END COMPONENT;
  21. --Inputs
  22. signal addr_A : std_logic_vector(0 to 3) := (others => '0');
  23. signal addr_B : std_logic_vector(0 to 3) := (others => '0');
  24. signal addr_W : std_logic_vector(0 to 3) := (others => '0');
  25. signal W : std_logic := '0';
  26. signal DATA : std_logic_vector(0 to 7) := (others => '0');
  27. signal RST : std_logic := '0';
  28. signal CLK : std_logic := '0';
  29. --Outputs
  30. signal QA : std_logic_vector(0 to 7);
  31. signal QB : std_logic_vector(0 to 7);
  32. -- Clock period definitions
  33. constant CLK_period : time := 10 ns;
  34. BEGIN
  35. -- Instantiate the Unit Under Test (UUT)
  36. uut: registers PORT MAP (
  37. addr_A => addr_A,
  38. addr_B => addr_B,
  39. addr_W => addr_W,
  40. W => W,
  41. DATA => DATA,
  42. RST => RST,
  43. CLK => CLK,
  44. QA => QA,
  45. QB => QB
  46. );
  47. -- Clock process definitions
  48. CLK_process :process
  49. begin
  50. CLK <= '0';
  51. wait for CLK_period/2;
  52. CLK <= '1';
  53. wait for CLK_period/2;
  54. end process;
  55. -- Stimulus process
  56. stim_proc: process
  57. begin
  58. -- hold reset state for 100 ns.
  59. wait for 100 ns;
  60. addr_A <=
  61. "0000",
  62. "0010" after 1*CLK_period,
  63. "0110" after 2*CLK_period,
  64. "1000" after 3*CLK_period,
  65. "1100" after 4*CLK_period,
  66. "0000" after 5*CLK_period,
  67. "0001" after 6*CLK_period,
  68. "0010" after 8*CLK_period,
  69. "1000" after 9*CLK_period,
  70. "1111" after 11*CLK_period;
  71. addr_B <=
  72. "0000",
  73. "0001" after 1*CLK_period,
  74. "0111" after 2*CLK_period,
  75. "1000" after 3*CLK_period,
  76. "1111" after 4*CLK_period,
  77. "0001" after 5*CLK_period,
  78. "1111" after 9*CLK_period,
  79. "0001" after 11*CLK_period;
  80. addr_W <=
  81. "0000",
  82. "0001" after 6*CLK_period,
  83. "0010" after 7*CLK_period,
  84. "1000" after 8*CLK_period,
  85. "1111" after 9*CLK_period;
  86. DATA <=
  87. "01010101",
  88. "10101010" after 6*CLK_period,
  89. "00000000" after 7*CLK_period,
  90. "11111111" after 8*CLK_period,
  91. "00001111" after 10*CLK_period;
  92. W <=
  93. '0',
  94. '1' after 5*CLK_period,
  95. '0' after 9*CLK_period,
  96. '1' after 10*CLK_period;
  97. RST <= '1', '0' after 12*CLK_period;
  98. wait;
  99. end process;
  100. END;