forked from pulp-platform/axi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tb_axi_dw_upsizer.sv
181 lines (154 loc) · 5.1 KB
/
tb_axi_dw_upsizer.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Copyright 2020 ETH Zurich and University of Bologna.
// Copyright and related rights are licensed under the Solderpad Hardware
// License, Version 0.51 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
// or agreed to in writing, software, hardware and materials distributed under
// this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
//
// Authors:
// - Matheus Cavalcante <[email protected]>
`include "axi/assign.svh"
module tb_axi_dw_upsizer #(
// AXI Parameters
parameter int unsigned TbAxiAddrWidth = 64 ,
parameter int unsigned TbAxiIdWidth = 4 ,
parameter int unsigned TbAxiSlvPortDataWidth = 32 ,
parameter int unsigned TbAxiMstPortDataWidth = 64 ,
parameter int unsigned TbAxiUserWidth = 8 ,
// TB Parameters
parameter time TbCyclTime = 10ns,
parameter time TbApplTime = 2ns ,
parameter time TbTestTime = 8ns
);
/*********************
* CLOCK GENERATOR *
*********************/
logic clk;
logic rst_n;
logic eos;
clk_rst_gen #(
.ClkPeriod (TbCyclTime),
.RstClkCycles (5 )
) i_clk_rst_gen (
.clk_o (clk ),
.rst_no(rst_n)
);
/*********
* AXI *
*********/
// Master port
AXI_BUS_DV #(
.AXI_ADDR_WIDTH(TbAxiAddrWidth ),
.AXI_DATA_WIDTH(TbAxiSlvPortDataWidth),
.AXI_ID_WIDTH (TbAxiIdWidth ),
.AXI_USER_WIDTH(TbAxiUserWidth )
) master_dv (
.clk_i(clk)
);
AXI_BUS #(
.AXI_ADDR_WIDTH(TbAxiAddrWidth ),
.AXI_DATA_WIDTH(TbAxiSlvPortDataWidth),
.AXI_ID_WIDTH (TbAxiIdWidth ),
.AXI_USER_WIDTH(TbAxiUserWidth )
) master ();
`AXI_ASSIGN(master, master_dv)
axi_test::axi_rand_master #(
.AW (TbAxiAddrWidth ),
.DW (TbAxiSlvPortDataWidth),
.IW (TbAxiIdWidth ),
.UW (TbAxiUserWidth ),
.TA (TbApplTime ),
.TT (TbTestTime ),
.MAX_READ_TXNS (8 ),
.MAX_WRITE_TXNS(8 ),
.AXI_ATOPS (1'b1 )
) master_drv = new (master_dv);
// Slave port
AXI_BUS_DV #(
.AXI_ADDR_WIDTH(TbAxiAddrWidth ),
.AXI_DATA_WIDTH(TbAxiMstPortDataWidth),
.AXI_ID_WIDTH (TbAxiIdWidth ),
.AXI_USER_WIDTH(TbAxiUserWidth )
) slave_dv (
.clk_i(clk)
);
AXI_BUS #(
.AXI_ADDR_WIDTH(TbAxiAddrWidth ),
.AXI_DATA_WIDTH(TbAxiMstPortDataWidth),
.AXI_ID_WIDTH (TbAxiIdWidth ),
.AXI_USER_WIDTH(TbAxiUserWidth )
) slave ();
axi_test::axi_rand_slave #(
.AW(TbAxiAddrWidth ),
.DW(TbAxiMstPortDataWidth),
.IW(TbAxiIdWidth ),
.UW(TbAxiUserWidth ),
.TA(TbApplTime ),
.TT(TbTestTime )
) slave_drv = new (slave_dv);
`AXI_ASSIGN(slave_dv, slave)
/*********
* DUT *
*********/
axi_dw_converter_intf #(
.AXI_MAX_READS (4 ),
.AXI_ADDR_WIDTH (TbAxiAddrWidth ),
.AXI_ID_WIDTH (TbAxiIdWidth ),
.AXI_SLV_PORT_DATA_WIDTH(TbAxiSlvPortDataWidth),
.AXI_MST_PORT_DATA_WIDTH(TbAxiMstPortDataWidth),
.AXI_USER_WIDTH (TbAxiUserWidth )
) i_dw_converter (
.clk_i (clk ),
.rst_ni(rst_n ),
.slv (master),
.mst (slave )
);
/*************
* DRIVERS *
*************/
initial begin
eos = 1'b0;
// Configuration
slave_drv.reset() ;
master_drv.reset() ;
master_drv.add_memory_region({TbAxiAddrWidth{1'b0}}, {TbAxiAddrWidth{1'b1}}, axi_pkg::WTHRU_NOALLOCATE);
// Wait for the reset before sending requests
@(posedge rst_n);
fork
// Act as a sink
slave_drv.run() ;
master_drv.run(200, 200);
join_any
// Done
repeat (10) @(posedge clk);
eos = 1'b1;
end
/*************
* MONITOR *
*************/
initial begin : proc_monitor
static tb_axi_dw_pkg::axi_dw_upsizer_monitor #(
.AxiAddrWidth (TbAxiAddrWidth ),
.AxiMstPortDataWidth(TbAxiMstPortDataWidth),
.AxiSlvPortDataWidth(TbAxiSlvPortDataWidth),
.AxiIdWidth (TbAxiIdWidth ),
.AxiUserWidth (TbAxiUserWidth ),
.TimeTest (TbTestTime )
) monitor = new (master_dv, slave_dv);
fork
monitor.run();
forever begin
#TbTestTime;
if(eos) begin
monitor.print_result();
$stop() ;
end
@(posedge clk);
end
join
end
// vsim -voptargs=+acc work.tb_axi_dw_upsizer
endmodule : tb_axi_dw_upsizer