aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/synth109/tb_ram2.vhdl
blob: 16a2d0af46d3ae0987a510299eedae6e5bb7d837 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
entity tb_ram2 is
end tb_ram2;

library ieee;
use ieee.std_logic_1164.all;

architecture behav of tb_ram2 is
  signal clkA : std_logic;
  signal enA : std_logic;
  signal weA : std_logic;
  signal addrA : std_logic_vector(5 downto 0);
  signal rdatA : std_logic_vector(31 downto 0);
  signal wdatA : std_logic_vector(31 downto 0);
  
  signal clkB : std_logic;
  signal enB : std_logic;
  signal weB : std_logic;
  signal addrB : std_logic_vector(5 downto 0);
  signal rdatB : std_logic_vector(31 downto 0);
  signal wdatB : std_logic_vector(31 downto 0);
begin
  dut: entity work.ram2
    port map (clkA => clkA, clkB => clkB,
              enA => enA, enB => enB,
              weA => weA, weB => weB,
              addrA => addrA, addrB => addrB,
              diA => wdatA, diB => wdatB,
              doA => rdatA, doB => rdatB);

  process
    procedure pulseB is
    begin
      clkB <= '0';
      wait for 1 ns;
      clkB <= '1';
      wait for 1 ns;
    end pulseB;
    procedure pulseA is
    begin
      clkA <= '0';
      wait for 1 ns;
      clkA <= '1';
      wait for 1 ns;
    end pulseA;
  begin
    clkA <= '0';
    enA <= '0';

    enB <= '1';
    weB <= '1';
    addrB <= b"00_0000";
    wdatB <= x"11_22_33_f0";
    pulseB;
    assert rdatB = x"11_22_33_f0" severity failure;

    addrB <= b"00_0001";
    wdatB <= x"11_22_33_f1";
    pulseB;
    assert rdatB = x"11_22_33_f1" severity failure;

    --  Read.
    weB <= '0';
    addrB <= b"00_0000";
    wdatB <= x"ff_22_33_f1";
    pulseB;
    assert rdatB = x"11_22_33_f0" severity failure;

    addrB <= b"00_0001";
    wdatB <= x"ff_22_33_f1";
    pulseB;
    assert rdatB = x"11_22_33_f1" severity failure;

    --  Disable.
    enB <= '0';
    weB <= '1';
    addrB <= b"00_0000";
    wdatB <= x"11_22_33_f0";
    pulseB;
    assert rdatB = x"11_22_33_f1" severity failure;

    --  Read from A.
    enA <= '1';
    weA <= '0';
    addrA <= b"00_0001";
    wdatA <= x"88_22_33_f1";
    pulseA;
    assert rdatA = x"11_22_33_f1" severity failure;
    
    wait;
  end process;
end behav;