File tree Expand file tree Collapse file tree 6 files changed +65
-0
lines changed Expand file tree Collapse file tree 6 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,23 @@ def top_node(self) -> AddrmapNode:
49
49
return self .exp .ds .top_node
50
50
51
51
52
+ def get_extra_package_params (self ) -> str :
53
+ lines = []
54
+
55
+ for param in self .top_node .inst .parameters :
56
+ value = param .get_value ()
57
+ if isinstance (value , int ):
58
+ lines .append (
59
+ f"localparam { param .name } = { SVInt (value )} ;"
60
+ )
61
+ elif isinstance (value , str ):
62
+ lines .append (
63
+ f"localparam { param .name } = { value } ;"
64
+ )
65
+
66
+ return "\n " .join (lines )
67
+
68
+
52
69
def get_package_contents (self ) -> str :
53
70
"""
54
71
If this hwif requires a package, generate the string
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ package {{ds.package_name}};
7
7
localparam {{ ds.module_name.upper ()}} _MIN_ADDR_WIDTH = {{ ds.addr_width}} ;
8
8
localparam {{ ds.module_name.upper ()}} _SIZE = {{ SVInt (ds.top_node.size)}} ;
9
9
10
+ {{ hwif.get_extra_package_params ()| indent}}
11
+
10
12
{{ hwif.get_package_contents ()| indent}}
11
13
endpackage
12
14
{ # (eof newline anchor) # }
Original file line number Diff line number Diff line change
1
+ addrmap top #(
2
+ longint N_REGS = 1,
3
+ longint REGWIDTH = 32,
4
+ string NAME = "abcd"
5
+ ) {
6
+ reg reg_t {
7
+ regwidth = REGWIDTH;
8
+ field {sw=rw; hw=na;} f[REGWIDTH] = 1;
9
+ };
10
+ reg_t regs[N_REGS];
11
+ };
Original file line number Diff line number Diff line change
1
+ { % extends " lib/tb_base.sv" % }
2
+
3
+ { % block seq % }
4
+ { % sv_line_anchor % }
5
+ assert (regblock_pkg :: N_REGS == {{ testcase.n_regs}} );
6
+ assert (regblock_pkg :: REGWIDTH == {{ testcase.regwidth}} );
7
+ assert (regblock_pkg :: NAME == " {{testcase.name}}" );
8
+ { % endblock % }
Original file line number Diff line number Diff line change
1
+ from parameterized import parameterized_class
2
+
3
+ from ..lib .sim_testcase import SimTestCase
4
+ from ..lib .test_params import get_permutations
5
+
6
+ PARAMS = get_permutations ({
7
+ "n_regs" : [1 , 2 ],
8
+ "regwidth" : [8 , 16 ],
9
+ "name" : ["hello" , "world" ],
10
+ })
11
+ @parameterized_class (PARAMS )
12
+ class TestRetimedFanin (SimTestCase ):
13
+ n_regs = 20
14
+ regwidth = 32
15
+ name = "xyz"
16
+
17
+ @classmethod
18
+ def setUpClass (cls ):
19
+ cls .rdl_elab_params = {
20
+ "N_REGS" : cls .n_regs ,
21
+ "REGWIDTH" : cls .regwidth ,
22
+ "NAME" : f'"{ cls .name } "' ,
23
+ }
24
+ super ().setUpClass ()
25
+
26
+ def test_dut (self ):
27
+ self .run_test ()
You can’t perform that action at this time.
0 commit comments