-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtb_fifo_controller.vhd
162 lines (125 loc) · 3.75 KB
/
tb_fifo_controller.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_unsigned.all;
entity tb_fifo_controller is
-- Port ( );
end tb_fifo_controller;
architecture Behavioral of tb_fifo_controller is
component fifo_controller is
port (
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
din : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
wr_en : IN STD_LOGIC;
rd_en : IN STD_LOGIC;
dout : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
full : OUT STD_LOGIC;
wr_ack : OUT STD_LOGIC;
empty : OUT STD_LOGIC;
valid : OUT STD_LOGIC;
data_count : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
sbiterr : OUT STD_LOGIC;
dbiterr : OUT STD_LOGIC;
wr_rst_busy : OUT STD_LOGIC;
rd_rst_busy : OUT STD_LOGIC
);
end component;
signal clk : STD_LOGIC;
signal rst : STD_LOGIC;
signal din : STD_LOGIC_VECTOR(7 DOWNTO 0);
signal wr_en : STD_LOGIC;
signal rd_en : STD_LOGIC;
signal dout : STD_LOGIC_VECTOR(7 DOWNTO 0);
signal full : STD_LOGIC;
signal wr_ack : STD_LOGIC;
signal empty : STD_LOGIC;
signal valid : STD_LOGIC;
signal data_count : STD_LOGIC_VECTOR(7 DOWNTO 0);
signal sbiterr : STD_LOGIC;
signal dbiterr : STD_LOGIC;
signal wr_rst_busy : STD_LOGIC;
signal rd_rst_busy : STD_LOGIC ;
constant clock_period : time := 20 ns;
begin
clock_process: process
begin
clk <= '0' ;
wait for clock_period/2 ;
clk <= '1' ;
wait for clock_period/2 ;
end process;
--
fifo_ip : fifo_controller port map
(
clk => clk ,
rst => rst ,
din => din ,
wr_en => wr_en ,
rd_en => rd_en ,
dout => dout ,
full => full ,
wr_ack => wr_ack ,
empty => empty ,
valid => valid ,
data_count => data_count ,
sbiterr => sbiterr ,
dbiterr => dbiterr ,
wr_rst_busy => wr_rst_busy,
rd_rst_busy => rd_rst_busy
);
stim_proc : process
begin
rst <= '1'; -- reset durumundan baslamali test bench
wait for 210 ns;
rst <= '0';
wait for clock_period;
wait for 300 ns; -- dokumanda bu kadar sure beklemek gerektigi belirtilmis
--1
wr_en <= '1'; -- artik yazabiliriz
din <= x"0a";
wait for clock_period; -- bir clock sonra yazma tamamlanmis olur
--2
din <= x"0b";
wait for clock_period;
--3
din <= x"0c";
wait for clock_period;
--4
din <= x"0d";
wait for clock_period;
--5
din <= x"0e";
wait for clock_period;
--6
din <= x"0f";
wait for clock_period;
--7
din <= x"aa";
wait for clock_period;
--8
din <= x"ab";
wait for clock_period;
--9
din <= x"ac";
wait for clock_period;
--10
din <= x"ad";
wait for clock_period;
--11
din <= x"ae";
wait for clock_period;
--12
din <= x"af";
wait for clock_period;
--13
din <= x"ff";
wait for clock_period;
wr_en <= '0'; -- yazma islemi bitti
wait for clock_period;
rd_en <= '1'; -- okuma islemi basladi
wait for clock_period*44; -- 30 tane okuma yapalim istedik
rd_en <= '0';
wait;
end process;
end Behavioral;