forked from JoseIuri/axi4lite2uart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testbench_buffer.sv
74 lines (64 loc) · 1.82 KB
/
testbench_buffer.sv
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
`timescale 1ns/100ps
module testbench_buffer ();
// Testbench uses 25 MHz clock
// Want to interface to 115200 baud UART
// 25000000 / 115200 = 217 Clocks Per Bit.
parameter c_CLOCK_PERIOD_NS = 40;
parameter c_CLKS_PER_BIT = 217;
parameter c_BIT_PERIOD = 8600;
logic r_Clock;
logic r_rst;
logic empty;
logic full;
logic [31:0] data_inTx;
logic [31:0] data_outRx;
logic [7:0] data_tr;
logic rd_en;
logic wr_en;
logic rxValid;
logic txValid;
logic rxReady;
logic txReady;
logic outReady;
logic outValid;
bufferRx bufferRx (.clk(r_Clock), .rst(r_rst), .rxValid(rxValid), .empty(empty),
.rxReady(rxReady), .outReady(outReady), .outValid(outValid), .data_out(data_outRx), .data_in(data_tr));
bufferTx bufferTx (.clk(r_Clock), .rst(r_rst), .txValid(txValid), .full(full), .outReady(outReady),
.txReady(txReady), .outValid(outValid), .data_out(data_tr),
.data_in(data_inTx));
always
begin
// #(c_CLOCK_PERIOD_NS/2) r_Clock <= !r_Clock;
r_Clock <= 1'b0;
#(c_CLOCK_PERIOD_NS/2);
r_Clock <= 1'b1;
#(c_CLOCK_PERIOD_NS/2);
end
initial
begin
// #1 r_Clock <= 1'b1;
full <= 0;
empty <= 0;
#5 r_rst <= 1'b1;
#5 r_rst <= 1'b0;
#5 r_rst <= 1'b1;
@(posedge r_Clock);
@(posedge r_Clock);
data_inTx <= 32'h0000f0f0;
txValid <= 1'b1;
rxReady <= 1'b1;
@(posedge r_Clock);
@(posedge r_Clock);
@(posedge r_Clock);
@(posedge r_Clock);
@(posedge r_Clock);
@(posedge r_Clock);
@(posedge r_Clock);
@(posedge r_Clock);
if (data_outRx == 32'hf0f0)
$display("Test Passed - Correct Word Received");
else
$display("Test Failed - Incorrect Word Received");
$finish;
end
endmodule