Skip to content

Commit f4a1d19

Browse files
[racl,raclgen,topgen] raclgen: Add support for ranges and non-* mappings
Signed-off-by: David Schrammel <[email protected]>
1 parent d4f3d73 commit f4a1d19

File tree

12 files changed

+204
-35
lines changed

12 files changed

+204
-35
lines changed

hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7622,6 +7622,7 @@
76227622
WDATA: 0
76237623
RDATA: 0
76247624
}
7625+
range_mapping: []
76257626
}
76267627
}
76277628
clock_connections:
@@ -7824,6 +7825,7 @@
78247825
WDATA: 0
78257826
RDATA: 0
78267827
}
7828+
range_mapping: []
78277829
}
78287830
}
78297831
clock_connections:
@@ -8026,6 +8028,7 @@
80268028
WDATA: 0
80278029
RDATA: 0
80288030
}
8031+
range_mapping: []
80298032
}
80308033
}
80318034
clock_connections:
@@ -8404,6 +8407,7 @@
84048407
WDATA: 0
84058408
RDATA: 0
84068409
}
8410+
range_mapping: []
84078411
}
84088412
}
84098413
clock_connections:
@@ -8606,6 +8610,7 @@
86068610
WDATA: 0
86078611
RDATA: 0
86088612
}
8613+
range_mapping: []
86098614
}
86108615
}
86118616
clock_connections:
@@ -8984,6 +8989,7 @@
89848989
WDATA: 0
89858990
RDATA: 0
89868991
}
8992+
range_mapping: []
89878993
}
89888994
}
89898995
clock_connections:
@@ -9186,6 +9192,7 @@
91869192
WDATA: 2
91879193
RDATA: 2
91889194
}
9195+
range_mapping: []
91899196
}
91909197
}
91919198
clock_connections:
@@ -9388,6 +9395,7 @@
93889395
WDATA: 2
93899396
RDATA: 2
93909397
}
9398+
range_mapping: []
93919399
}
93929400
}
93939401
clock_connections:

hw/top_darjeeling/data/racl/all_rd_wr_mapping.hjson

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
{
66
Null: {
7-
"*": "ALL_RD_WR"
7+
registers: {
8+
"*": "ALL_RD_WR"
9+
}
10+
windows: {
11+
"*": "ALL_RD_WR"
12+
}
813
}
914
}

hw/top_darjeeling/data/racl/soc_rot_mapping.hjson

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
{
66
Null: {
7-
"*": "SOC_ROT"
7+
registers: {
8+
"*": "SOC_ROT"
9+
}
10+
windows: {
11+
"*": "SOC_ROT"
12+
}
813
}
914
}

hw/top_darjeeling/rtl/autogen/top_racl_pkg.sv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ package top_racl_pkg;
4848
// Default policy vector for unconnected RACL IPs
4949
parameter racl_policy_vec_t RACL_POLICY_VEC_DEFAULT = '0;
5050

51+
typedef struct packed {
52+
logic [top_pkg::TL_AW-1:0] base;
53+
logic [top_pkg::TL_AW-1:0] mask;
54+
racl_policy_sel_t policy_sel;
55+
} racl_range_t;
56+
5157
// Default ROT Private read policy value
5258
parameter racl_role_vec_t RACL_POLICY_ROT_PRIVATE_RD = 16'h1;
5359

hw/top_darjeeling/templates/toplevel.sv.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ max_intrwidth = (max(len(x.name) for x in block.interrupts)
501501
<%
502502
register_mapping = m['racl_mappings'][if_name]['register_mapping']
503503
window_mapping = m['racl_mappings'][if_name]['window_mapping']
504+
range_mapping = m['racl_mappings'][if_name]['range_mapping']
504505
racl_group = m['racl_mappings'][if_name]['racl_group']
505506
group_suffix = f"_{racl_group.upper()}" if racl_group and racl_group != "Null" else ""
506507
if_suffix = f"_{if_name.upper()}" if if_name else ""
@@ -513,6 +514,10 @@ max_intrwidth = (max(len(x.name) for x in block.interrupts)
513514
% for window_name, policy_idx in window_mapping.items():
514515
.RaclPolicySelWin${if_suffix2}${window_name.replace("_","").title()}(top_racl_pkg::${policy_sel_name}_WIN_${window_name.upper()}),
515516
% endfor
517+
% if len(range_mapping) > 0:
518+
.RaclPolicySelRanges${if_suffix2}Num(top_racl_pkg::${policy_sel_name}_NUM_RANGES),
519+
.RaclPolicySelRanges${if_suffix2}(top_racl_pkg::${policy_sel_name}_RANGES),
520+
% endif
516521
% endfor
517522
% endif
518523
% if m.get('template_type') == 'racl_ctrl':

hw/top_earlgrey/rtl/autogen/top_racl_pkg.sv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ package top_racl_pkg;
4848
// Default policy vector for unconnected RACL IPs
4949
parameter racl_policy_vec_t RACL_POLICY_VEC_DEFAULT = '0;
5050

51+
typedef struct packed {
52+
logic [top_pkg::TL_AW-1:0] base;
53+
logic [top_pkg::TL_AW-1:0] mask;
54+
racl_policy_sel_t policy_sel;
55+
} racl_range_t;
56+
5157
// Default ROT Private read policy value
5258
parameter racl_role_vec_t RACL_POLICY_ROT_PRIVATE_RD = 2'h0;
5359

hw/top_earlgrey/templates/toplevel.sv.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ max_intrwidth = (max(len(x.name) for x in block.interrupts)
518518
<%
519519
register_mapping = m['racl_mappings'][if_name]['register_mapping']
520520
window_mapping = m['racl_mappings'][if_name]['window_mapping']
521+
range_mapping = m['racl_mappings'][if_name]['range_mapping']
521522
racl_group = m['racl_mappings'][if_name]['racl_group']
522523
group_suffix = f"_{racl_group.upper()}" if racl_group and racl_group != "Null" else ""
523524
if_suffix = f"_{if_name.upper()}" if if_name else ""
@@ -530,6 +531,10 @@ max_intrwidth = (max(len(x.name) for x in block.interrupts)
530531
% for window_name, policy_idx in window_mapping.items():
531532
.RaclPolicySelWin${if_suffix2}${window_name.replace("_","").title()}(top_racl_pkg::${policy_sel_name}_WIN_${window_name.upper()}),
532533
% endfor
534+
% if len(range_mapping) > 0:
535+
.RaclPolicySelRanges${if_suffix2}Num(top_racl_pkg::${policy_sel_name}_NUM_RANGES),
536+
.RaclPolicySelRanges${if_suffix2}(top_racl_pkg::${policy_sel_name}_RANGES),
537+
% endif
533538
% endfor
534539
% endif
535540
% if m.get('template_type') == 'racl_ctrl':

hw/top_englishbreakfast/rtl/autogen/top_racl_pkg.sv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ package top_racl_pkg;
4848
// Default policy vector for unconnected RACL IPs
4949
parameter racl_policy_vec_t RACL_POLICY_VEC_DEFAULT = '0;
5050

51+
typedef struct packed {
52+
logic [top_pkg::TL_AW-1:0] base;
53+
logic [top_pkg::TL_AW-1:0] mask;
54+
racl_policy_sel_t policy_sel;
55+
} racl_range_t;
56+
5157
// Default ROT Private read policy value
5258
parameter racl_role_vec_t RACL_POLICY_ROT_PRIVATE_RD = 2'h0;
5359

util/raclgen.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def main():
5050
raise SystemExit(
5151
f'Failed to parse RACL config "{args.racl_config}". Error: {err}')
5252

53-
parsed_register_mapping, parsed_window_mapping, racl_group, policy_names = parse_racl_mapping(
54-
parsed_racl_config, args.mapping, args.if_name, ip_block)
53+
register_mapping, window_mapping, range_mapping, racl_group, policy_names\
54+
= parse_racl_mapping(parsed_racl_config, args.mapping, args.if_name, ip_block)
5555

5656
template = """\
5757
<%doc>
@@ -63,12 +63,14 @@ def main():
6363
hw/top_earlgrey/templates/toplevel.sv.tpl
6464
hw/top_englishbreakfast/templates/toplevel.sv.tpl
6565
</%doc>\
66+
<% import raclgen.lib as raclgen %>\
6667
<% import math %>\
6768
<% policy_idx_len = math.ceil(math.log10(max(1,len(policy_names)+1))) %>\
6869
<% group_suffix = f"_{racl_group.upper()}" if racl_group and racl_group != "Null" else "" %>\
6970
<% if_suffix = f"_{if_name.upper()}" if if_name else "" %>\
7071
<% reg_name_len = max( (len(name) for name in register_mapping.keys()), default=0 ) %>\
7172
<% window_name_len = max( (len(name) for name in window_mapping.keys()), default=0 ) %>\
73+
<% policy_sel_name = f"RACL_POLICY_SEL_{module_name.upper()}{group_suffix}{if_suffix}" %>\
7274
/**
7375
* Policy selection vector for ${module_name}
7476
* TLUL interface name: ${if_name}
@@ -87,20 +89,34 @@ def main():
8789
(Idx ${f"{policy_idx}".rjust(policy_idx_len)})
8890
% endfor
8991
% endif
92+
% if len(range_mapping) > 0:
93+
* Range to policy mapping:
94+
% for range in range_mapping:
95+
* ${f"0x{range['base']:08x}"} -- ${f"0x{(range['base']+range['size']):08x}"} \
96+
policy: ${policy_names[range['policy']]} (Idx ${f"{range['policy']}".rjust(policy_idx_len)})
97+
% endfor
98+
% endif
9099
*/
91-
<% policy_sel_name = f"RACL_POLICY_SEL_{module_name.upper()}{group_suffix}{if_suffix}" %>\
100+
% if len(register_mapping) > 0:
92101
<% policy_sel_value = "'{" + ", ".join(map(str, reversed(register_mapping.values()))) + "};" %>\
93102
parameter racl_policy_sel_t ${policy_sel_name} [${len(register_mapping)}] = ${policy_sel_value}
103+
% endif
94104
% for window_name, policy_idx in window_mapping.items():
95105
parameter racl_policy_sel_t ${policy_sel_name}_WIN_${window_name.upper()} = ${policy_idx};
96106
% endfor
107+
% if len(range_mapping) > 0:
108+
<% value = raclgen.format_parameter_ranges_value(range_mapping) %>\
109+
parameter racl_range_t ${policy_sel_name}_RANGES [${len(range_mapping)}] = ${value};
110+
% endif
111+
97112
"""
98113

99114
print(
100115
Template(template).render(m=ip_block,
101116
if_name=args.if_name,
102-
register_mapping=parsed_register_mapping,
103-
window_mapping=parsed_window_mapping,
117+
register_mapping=register_mapping,
118+
window_mapping=window_mapping,
119+
range_mapping=range_mapping,
104120
policy_names=policy_names,
105121
module_name=ip_block.name,
106122
racl_group=racl_group).rstrip())

0 commit comments

Comments
 (0)