aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/issue1069/tb_ram5.vhdl
blob: 828d6491397a3d50a1f6f6d580a3263b21d392ec (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
entity tb_ram5 is
end tb_ram5;

library ieee;
use ieee.std_logic_1164.all;

architecture behav of tb_ram5 is
  constant WIDTH : natural := 8;
  constant ADDRWIDTH : natural := 12;
  
  signal clk_a        : std_logic;
  signal read_a       : std_logic;
  signal write_a      : std_logic;
  signal addr_a       : std_logic_vector(ADDRWIDTH - 1 downto 0);
  signal data_read_a  : std_logic_vector(WIDTH - 1 downto 0);
  signal data_write_a : std_logic_vector(WIDTH - 1 downto 0);
  signal clk_b        : std_logic;
  signal read_b       : std_logic;
  signal write_b      : std_logic;
  signal addr_b       : std_logic_vector(ADDRWIDTH - 1 downto 0);
  signal data_read_b  : std_logic_vector(WIDTH - 1 downto 0);
  signal data_write_b : std_logic_vector(WIDTH - 1 downto 0);
begin
  tdp_ram_1: entity work.ram5
    generic map (
      ADDRWIDTH => ADDRWIDTH,
      WIDTH     => WIDTH)
    port map (
      clk_a        => clk_a,
      read_a       => read_a,
      write_a      => write_a,
      addr_a       => addr_a,
      data_read_a  => data_read_a,
      data_write_a => data_write_a,
      clk_b        => clk_b,
      read_b       => read_b,
      write_b      => write_b,
      addr_b       => addr_b,
      data_read_b  => data_read_b,
      data_write_b => data_write_b);

  process
    procedure pulsea is
    begin
      clk_a <= '0';
      wait for 1 ns;
      clk_a <= '1';
      wait for 1 ns;
    end pulsea;
    
    procedure pulseb is
    begin
      clk_b <= '0';
      wait for 1 ns;
      clk_b <= '1';
      wait for 1 ns;
    end pulseb;
  begin
    clk_a <= '0';
    clk_b <= '0';

    write_a <= '1';
    read_a <= '0';
    addr_a <= x"000";
    data_write_a <= x"a0";
    pulsea;

    write_b <= '1';
    read_b <= '0';
    addr_b <= x"001";
    data_write_b <= x"b1";
    pulseb;

    write_a <= '0';
    read_a <= '1';
    addr_a <= x"001";
    pulsea;
    assert data_read_a = x"b1" severity failure;

    write_b <= '0';
    read_b <= '1';
    addr_b <= x"000";
    pulseb;
    assert data_read_b = x"a0" severity failure;

    wait;
  end process;
end behav;