Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bd97109

Browse files
committedFeb 20, 2024·
wip: Virtual drivers
1 parent ce04715 commit bd97109

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed
 

‎Bender.yml

+2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ sources:
4848
files:
4949
# Level 0
5050
- hw/test/floo_test_pkg.sv
51+
- hw/test/floo_intf.sv
5152
# Level 1
53+
- hw/test/floo_test.sv
5254
- hw/test/floo_axi_test_node.sv
5355
- hw/test/floo_axi_rand_slave.sv
5456
- hw/test/floo_dma_test_node.sv

‎hw/test/floo_intf.sv

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2024 ETH Zurich and University of Bologna.
2+
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
3+
// SPDX-License-Identifier: SHL-0.51
4+
//
5+
// Author: Tim Fischer <fischeti@iis.ee.ethz.ch>
6+
7+
/// A Floo AXI interface used for testing.
8+
interface FLOO_LINK_DV
9+
(
10+
input logic clk_i
11+
);
12+
13+
import floo_axi_pkg::*;
14+
15+
floo_req_t floo_req_mgr;
16+
floo_rsp_t floo_rsp_mgr;
17+
floo_req_t floo_req_sbr;
18+
floo_rsp_t floo_rsp_sbr;
19+
20+
endinterface
21+
22+
/// A Floo narrow-wide interface used for testing.
23+
interface FLOO_NW_LINK_DV
24+
(
25+
input logic clk_i
26+
);
27+
28+
import floo_narrow_wide_pkg::*;
29+
30+
floo_req_t floo_req_mgr;
31+
floo_rsp_t floo_rsp_mgr;
32+
floo_wide_t floo_wide_mgr;
33+
floo_req_t floo_req_sbr;
34+
floo_rsp_t floo_rsp_sbr;
35+
floo_wide_t floo_wide_sbr;
36+
37+
endinterface

‎hw/test/floo_test.sv

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// Copyright 2024 ETH Zurich and University of Bologna.
2+
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
3+
// SPDX-License-Identifier: SHL-0.51
4+
//
5+
// Author: Tim Fischer <fischeti@iis.ee.ethz.ch>
6+
7+
/// A set of testbench utilities for the FlooNoC interface.
8+
package floo_test;
9+
10+
import floo_pkg::*;
11+
import floo_axi_pkg::*;
12+
13+
class floo_driver #(
14+
parameter time TA = 0ns,
15+
parameter time TT = 0ns
16+
);
17+
virtual FLOO_LINK_DV intf;
18+
19+
function new(virtual FLOO_LINK_DV intf);
20+
this.intf = intf;
21+
endfunction
22+
23+
function void reset_mgr();
24+
intf.floo_req_mgr <= '0;
25+
intf.floo_rsp_mgr <= '0;
26+
endfunction
27+
28+
function void reset_sbr();
29+
intf.floo_req_sbr <= '0;
30+
intf.floo_rsp_sbr <= '0;
31+
endfunction
32+
33+
task cycle_start();
34+
#TT;
35+
endtask
36+
37+
task cycle_end();
38+
@(posedge intf.clk_i);
39+
endtask
40+
41+
task send_req (
42+
input floo_req_generic_flit_t req
43+
);
44+
intf.floo_req_mgr.req <= #TA req;
45+
intf.floo_req_mgr.valid <= #TA 1'b1;
46+
cycle_start();
47+
while (intf.floo_req_sbr.ready != 1'b1) begin cycle_end(); cycle_start(); end
48+
cycle_end();
49+
intf.floo_req_mgr.req <= #TA '0;
50+
intf.floo_req_mgr.valid <= #TA 1'b0;
51+
endtask
52+
53+
task send_rsp (
54+
input floo_rsp_generic_flit_t rsp
55+
);
56+
intf.floo_rsp_sbr.rsp <= #TA rsp;
57+
intf.floo_rsp_sbr.valid <= #TA 1'b1;
58+
cycle_start();
59+
while (intf.floo_rsp_mgr.ready != 1'b1) begin cycle_end(); cycle_start(); end
60+
cycle_end();
61+
intf.floo_rsp_sbr.rsp <= #TA '0;
62+
intf.floo_rsp_sbr.valid <= #TA 1'b0;
63+
endtask
64+
65+
task recv_req (
66+
output floo_req_generic_flit_t req
67+
);
68+
intf.floo_req_sbr.ready <= #TA 1'b1;
69+
cycle_start();
70+
while (intf.floo_req_mgr.valid != 1'b1) begin cycle_end(); cycle_start(); end
71+
// TODO: create new req? i.e. do we need to define it as a class?
72+
req = intf.floo_req_mgr.req;
73+
cycle_end();
74+
intf.floo_req_mgr.ready <= #TA 1'b0;
75+
endtask
76+
77+
task recv_rsp (
78+
output floo_rsp_generic_flit_t rsp
79+
);
80+
intf.floo_rsp_mgr.ready <= #TA 1'b1;
81+
cycle_start();
82+
while (intf.floo_rsp_sbr.valid != 1'b1) begin cycle_end(); cycle_start(); end
83+
rsp = intf.floo_rsp_sbr.rsp;
84+
cycle_end();
85+
intf.floo_rsp_sbr.ready <= #TA 1'b0;
86+
endtask
87+
88+
endclass
89+
90+
class floo_node #(
91+
parameter time TA = 0ns,
92+
parameter time TT = 0ns,
93+
parameter id_t SrcId = '0,
94+
parameter route_algo_e RouteAlgo = XYRouting,
95+
parameter int MaxId = 0
96+
);
97+
floo_driver #(
98+
.TA(TA),
99+
.TT(TT)
100+
) drv;
101+
102+
function new(virtual FLOO_LINK_DV intf);
103+
drv = new(intf);
104+
drv.reset_mgr();
105+
drv.reset_sbr();
106+
endfunction
107+
108+
function floo_req_generic_flit_t new_rand_req();
109+
automatic logic rand_success;
110+
automatic hdr_t hdr;
111+
automatic floo_req_generic_flit_t req;
112+
automatic id_t dst_id;
113+
114+
dst_id = id_t'($urandom_range(0, MaxId));
115+
endfunction
116+
117+
endclass
118+
119+
120+
endpackage

0 commit comments

Comments
 (0)
Please sign in to comment.