Skip to content

Commit d2f436d

Browse files
committed
Added preview FIFO testbench
1 parent d07d0ad commit d2f436d

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

preview_fifo_tb.sv

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
//------------------------------------------------------------------------------
2+
// preview_fifo_tb.sv
3+
// Konstantin Pavlov, [email protected]
4+
//------------------------------------------------------------------------------
5+
6+
// INFO ------------------------------------------------------------------------
7+
// testbench for preview_fifo_tb.sv module
8+
9+
`timescale 1ns / 1ps
10+
11+
module preview_fifo_tb();
12+
13+
logic clk200;
14+
initial begin
15+
#0 clk200 = 1'b0;
16+
forever
17+
#2.5 clk200 = ~clk200;
18+
end
19+
20+
logic clk400;
21+
initial begin
22+
#0 clk400 = 1'b0;
23+
forever
24+
#1.25 clk400 = ~clk400;
25+
end
26+
27+
logic clk33;
28+
initial begin
29+
#0 clk33 = 1'b0;
30+
forever
31+
#15.151 clk33 = ~clk33;
32+
end
33+
34+
logic rst;
35+
initial begin
36+
#0 rst = 1'b0;
37+
#10.2 rst = 1'b1;
38+
#5 rst = 1'b0;
39+
end
40+
41+
logic nrst;
42+
assign nrst = ~rst;
43+
44+
logic rst_once;
45+
initial begin
46+
#0 rst_once = 1'b0;
47+
#10.2 rst_once = 1'b1;
48+
#5 rst_once = 1'b0;
49+
end
50+
51+
logic nrst_once;
52+
assign nrst_once = ~rst_once;
53+
54+
logic [31:0] DerivedClocks;
55+
clk_divider #(
56+
.WIDTH( 32 )
57+
) cd1 (
58+
.clk( clk200 ),
59+
.nrst( nrst_once ),
60+
.ena( 1'b1 ),
61+
.out( DerivedClocks[31:0] )
62+
);
63+
64+
logic [31:0] E_DerivedClocks;
65+
edge_detect ed1[31:0] (
66+
.clk( {32{clk200}} ),
67+
.nrst( {32{nrst_once}} ),
68+
.in( DerivedClocks[31:0] ),
69+
.rising( E_DerivedClocks[31:0] ),
70+
.falling( ),
71+
.both( )
72+
);
73+
74+
logic [31:0] RandomNumber1;
75+
c_rand rng1 (
76+
.clk( clk200 ),
77+
.rst( 1'b0 ),
78+
.reseed( rst_once ),
79+
.seed_val( DerivedClocks[31:0] ^ (DerivedClocks[31:0] << 1) ),
80+
.out( RandomNumber1[15:0] )
81+
);
82+
83+
c_rand rng2 (
84+
.clk( clk200 ),
85+
.rst( 1'b0 ),
86+
.reseed( rst_once ),
87+
.seed_val( DerivedClocks[31:0] ^ (DerivedClocks[31:0] << 2) ),
88+
.out( RandomNumber1[31:16] )
89+
);
90+
91+
// Module under test ==========================================================
92+
93+
logic wrreg;
94+
logic valid;
95+
96+
preview_fifo #(
97+
.WIDTH( 16 ),
98+
.DEPTH( 16 )
99+
) pf (
100+
.clk( clk200 ),
101+
.nrst( nrst_once ),
102+
103+
// input port
104+
.wrreq( wrreg ),
105+
.ena( (wrreg && |RandomNumber1[1:0]) ),
106+
.id0( RandomNumber1[15:0] ),
107+
.id1( RandomNumber1[31:16] ),
108+
109+
// output port
110+
.valid( valid ),
111+
.shift_req_oh( {3{valid}} &
112+
3'b010 ),
113+
//RandomNumber1[15:13] ),
114+
.od0( ),
115+
.od1( )
116+
);
117+
118+
119+
endmodule

0 commit comments

Comments
 (0)