-
Notifications
You must be signed in to change notification settings - Fork 23
/
floo_axi_test_node.sv
122 lines (106 loc) · 3.61 KB
/
floo_axi_test_node.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
// Copyright 2022 ETH Zurich and University of Bologna.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51
//
// Michael Rogenmoser <[email protected]>
`include "axi/assign.svh"
/// A AXI4 Bus Master-Slave Node for generating random AXI transactions
module floo_axi_test_node #(
parameter floo_pkg::axi_cfg_t AxiCfg = '{default:0},
parameter type mst_req_t = logic,
parameter type mst_rsp_t = logic,
parameter type slv_req_t = logic,
parameter type slv_rsp_t = logic,
// TB Parameters
parameter time ApplTime = 2ns,
parameter time TestTime = 8ns,
parameter bit Atops = 1'b0,
parameter int unsigned AxiMaxBurstLen = 128,
parameter int unsigned NumAddrRegions = 0,
parameter type rule_t = logic,
parameter rule_t [NumAddrRegions-1:0] AddrRegions = '0,
parameter int unsigned NumReads = 0,
parameter int unsigned NumWrites = 0
) (
input logic clk_i,
input logic rst_ni,
output mst_req_t mst_port_req_o,
input mst_rsp_t mst_port_rsp_i,
input slv_req_t slv_port_req_i,
output slv_rsp_t slv_port_rsp_o,
output logic end_of_sim
);
AXI_BUS_DV #(
.AXI_ADDR_WIDTH ( AxiCfg.AddrWidth ),
.AXI_DATA_WIDTH ( AxiCfg.DataWidth ),
.AXI_ID_WIDTH ( AxiCfg.OutIdWidth ),
.AXI_USER_WIDTH ( AxiCfg.UserWidth )
) master_dv (clk_i);
`AXI_ASSIGN_TO_REQ(mst_port_req_o, master_dv)
`AXI_ASSIGN_FROM_RESP(master_dv, mst_port_rsp_i)
typedef axi_test::axi_rand_master #(
// AXI interface parameters
.AW ( AxiCfg.AddrWidth ),
.DW ( AxiCfg.DataWidth ),
.IW ( AxiCfg.OutIdWidth ),
.UW ( AxiCfg.UserWidth ),
// Stimuli application and test time
.TA ( ApplTime ),
.TT ( TestTime ),
// Maximum number of read and write transactions in flight
.MAX_READ_TXNS ( 20 ),
.MAX_WRITE_TXNS ( 20 ),
.AXI_EXCLS ( 1'b0 ),
.AXI_ATOPS ( Atops ),
.UNIQUE_IDS ( 1'b0 ),
// Delay of master port
.AXI_MAX_BURST_LEN ( AxiMaxBurstLen ),
.AX_MIN_WAIT_CYCLES ( 0 ),
.AX_MAX_WAIT_CYCLES ( 2 ),
.W_MIN_WAIT_CYCLES ( 0 ),
.W_MAX_WAIT_CYCLES ( 2 ),
.RESP_MIN_WAIT_CYCLES ( 0 ),
.RESP_MAX_WAIT_CYCLES ( 2 )
) axi_rand_master_t;
AXI_BUS_DV #(
.AXI_ADDR_WIDTH ( AxiCfg.AddrWidth ),
.AXI_DATA_WIDTH ( AxiCfg.DataWidth ),
.AXI_ID_WIDTH ( AxiCfg.OutIdWidth ),
.AXI_USER_WIDTH ( AxiCfg.UserWidth )
) slave_dv (clk_i);
`AXI_ASSIGN_FROM_REQ(slave_dv, slv_port_req_i)
`AXI_ASSIGN_TO_RESP(slv_port_rsp_o, slave_dv)
typedef axi_test::axi_rand_slave #(
// AXI interface parameters
.AW ( AxiCfg.AddrWidth ),
.DW ( AxiCfg.DataWidth ),
.IW ( AxiCfg.OutIdWidth ),
.UW ( AxiCfg.UserWidth ),
// Stimuli application and test time
.TA ( ApplTime ),
.TT ( TestTime )
) axi_rand_slave_t;
// traffic generator master
axi_rand_master_t axi_rand_master;
initial begin
axi_rand_master = new( master_dv);
end_of_sim = 1'b0;
for (int i = 0; i < NumAddrRegions; i++) begin
axi_rand_master.add_memory_region(AddrRegions[i].start_addr,
AddrRegions[i].end_addr,
axi_pkg::DEVICE_NONBUFFERABLE);
end
axi_rand_master.reset();
@(posedge rst_ni)
axi_rand_master.run(NumReads, NumWrites);
end_of_sim = 1'b1;
end
// axi slave
axi_rand_slave_t axi_rand_slave;
initial begin
axi_rand_slave = new( slave_dv );
axi_rand_slave.reset();
@(posedge rst_ni)
axi_rand_slave.run();
end
endmodule