-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsingle_port_ram_tb.vhd
114 lines (71 loc) · 1.98 KB
/
single_port_ram_tb.vhd
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity single_port_ram_tb is
end entity single_port_ram_tb;
architecture rtl of single_port_ram_tb is
--50 MHz = 20 ns period
constant c_CLOCK_PERIOD : time := 20 ns;
signal r_CLKIN : std_logic := '0';
signal r_WE : std_logic := '1';
signal r_OE : std_logic := '1';
signal r_ADDR : std_logic_vector(3 downto 0) := (others => '0');
signal r_DATA_BUS_IN : std_logic_vector(7 downto 0) := (others => '0');
signal r_DATA_BUS_OUT : std_logic_vector(7 downto 0) := (others => '0');
signal r_RAM_DBG_LED : std_logic_vector(7 downto 0) := (others => '0');
component single_port_ram is
port(
i_clkin : in std_logic;
i_we : in std_logic; --Active LOW
i_oe : in std_logic; --Active LOW
i_addr : in std_logic_vector(3 downto 0);
i_data_bus_in : in std_logic_vector(7 downto 0);
o_data_bus_out : out std_logic_vector(7 downto 0);
o_ram_dbg_led : out std_logic_vector(7 downto 0)
);
end component single_port_ram;
begin
UUT : single_port_ram
port map(
i_clkin => r_CLKIN,
i_we => r_WE,
i_oe => r_OE,
i_addr => r_ADDR,
i_data_bus_in => r_DATA_BUS_IN,
o_data_bus_out => r_DATA_BUS_OUT,
o_ram_dbg_led => r_RAM_DBG_LED
);
p_clk_gen : process is
begin
wait for c_CLOCK_PERIOD/2;
r_CLKIN <= not r_CLKIN;
end process p_clk_gen;
process
begin
r_ADDR <= "0001";
r_DATA_BUS_IN <= "10011001";
wait for 7.5 ns;
r_WE <= '0';
wait for 5 ns;
r_WE <= '1';
r_ADDR <= "1010";
r_DATA_BUS_IN <= "10111101";
wait for 15 ns;
r_WE <= '0';
wait for 5 ns;
r_WE <= '1';
r_ADDR <= "0001";
r_DATA_BUS_IN <= "11111111"; --Just to ckeck if data gets in the ram
wait for 15 ns;
r_OE <= '0';
wait for 5 ns;
r_OE <= '1';
r_ADDR <= "1010";
r_DATA_BUS_IN <= "11111111";
wait for 15 ns;
r_OE <= '0';
wait for 5 ns;
r_OE <= '1';
wait for 1 sec;
end process;
end architecture rtl;