Guest User

Untitled

a guest
Jan 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4. use ieee.numeric_std.all;
  5.  
  6. type MyRecordType is record
  7. x : std_logic_vector(2 downto 0);
  8. y : std_logic_vector(2 downto 0);
  9. end record;
  10.  
  11. entity Test is
  12. port(
  13. clk : in std_logic;
  14. input : in MyRecordType;
  15. output : out std_logic
  16. );
  17. end entity;
  18.  
  19. architecture RTL of Test is
  20.  
  21. begin
  22. process (clk) is
  23. begin
  24. if rising_edge(clk) then
  25. if (input.x = input.y) then
  26. output <= '1';
  27. else
  28. output <= '0';
  29. end if;
  30. end if;
  31. end process;
  32. end;
  33.  
  34. library ieee;
  35. use ieee.std_logic_1164.all;
  36. use ieee.std_logic_unsigned.all;
  37. use ieee.numeric_std.all;
  38.  
  39. entity TOP is
  40. end entity;
  41.  
  42. architecture SIM of TOP is
  43.  
  44. type MyRecordType is record
  45. x : std_logic_vector(2 downto 0);
  46. y : std_logic_vector(2 downto 0);
  47. end record;
  48.  
  49. component Test is
  50. port(
  51. clk : in std_logic;
  52. input : in MyRecordType;
  53. output : out std_logic
  54. );
  55. end component;
  56.  
  57. constant period : time := 20 ns;
  58. signal clk : std_logic;
  59. signal result : std_logic;
  60. signal myRecord : MyRecordType;
  61.  
  62. begin
  63. dut : Test port map(clk => clk, input => myRecord, output => result);
  64.  
  65. clk <= not clk after period / 2;
  66.  
  67. process is
  68. begin
  69. myRecord.x <= "000";
  70. myRecord.y <= "000";
  71.  
  72. wait for 20 ns;
  73.  
  74. if result = 0 then
  75. report "TEST 1 - FAILED.";
  76. else
  77. report "TEST 1 - PASSED.";
  78. end if;
  79.  
  80. myRecord.x <= "000";
  81. myRecord.y <= "010";
  82.  
  83. wait for 20 ns;
  84.  
  85. if result = 1 then
  86. report "TEST 2 - FAILED.";
  87. else
  88. report "TEST 2 - PASSED.";
  89. end if;
  90.  
  91. wait;
  92.  
  93. end process;
  94.  
  95. end architecture;
Add Comment
Please, Sign In to add comment