Skip to content

Commit 06bcaf0

Browse files
Razer6a-will
authored andcommitted
[topgen] Add tool support for ipgen'ed GPIO
Signed-off-by: Robert Schilling <[email protected]>
1 parent 7fbcd5a commit 06bcaf0

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

hw/top_darjeeling/data/top_darjeeling.hjson

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@
295295
},
296296
{ name: "gpio",
297297
type: "gpio",
298+
template_type: "gpio",
298299
clock_srcs: {clk_i: "io_div4"},
299300
clock_group: "peri",
300301
reset_connections: {rst_ni: "lc_io_div4"},
@@ -304,7 +305,8 @@
304305
param_decl: {
305306
GpioAsHwStrapsEn: "1",
306307
GpioAsyncOn: "1"
307-
}
308+
},
309+
attr: "ipgen"
308310
},
309311
{ name: "spi_device",
310312
type: "spi_device",

hw/top_earlgrey/data/top_earlgrey.hjson

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@
349349
},
350350
{ name: "gpio",
351351
type: "gpio",
352+
template_type: "gpio",
352353
clock_srcs: {clk_i: "io_div4"},
353354
clock_group: "peri",
354355
reset_connections: {rst_ni: "lc_io_div4"},
@@ -358,7 +359,8 @@
358359
param_decl: {
359360
GpioAsHwStrapsEn: "0",
360361
GpioAsyncOn: "1"
361-
}
362+
},
363+
attr: "ipgen"
362364
},
363365
{ name: "spi_device",
364366
type: "spi_device",

hw/top_englishbreakfast/data/top_englishbreakfast.hjson

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@
291291
},
292292
{ name: "gpio",
293293
type: "gpio",
294+
template_type: "gpio",
294295
clock_srcs: {clk_i: "io_div4"},
295296
clock_group: "peri",
296297
reset_connections: {rst_ni: "sys_io_div4"},
@@ -299,7 +300,8 @@
299300
},
300301
param_decl: {
301302
GpioAsyncOn: "1"
302-
}
303+
},
304+
attr: "ipgen"
303305
}
304306
{ name: "spi_device",
305307
type: "spi_device",

util/topgen.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,23 @@ def generate_racl(top: ConfigT, module: ConfigT, out_path: Path) -> None:
756756
generate_ipgen(top, module, params, out_path)
757757

758758

759+
def _get_gpio_params(top: ConfigT) -> ParamsT:
760+
"""Extracts parameters for GPIO ipgen."""
761+
762+
gpio = lib.find_module(top["module"], "gpio")
763+
params = {
764+
"module_instance_name": gpio["type"]
765+
}
766+
return params
767+
768+
769+
def generate_gpio(top: ConfigT, module: ConfigT,
770+
out_path: Path) -> None:
771+
log.info('Generating GPIO with ipgen')
772+
params = _get_gpio_params(top)
773+
generate_ipgen(top, module, params, out_path)
774+
775+
759776
def generate_top_only(top_only_dict: List[str], out_path: Path, top_name: str,
760777
alt_hjson_path: str) -> None:
761778
"""Generate the regfile for top_only IPs."""
@@ -1063,6 +1080,9 @@ def insert_ip_attrs(module: ConfigT, params: ParamsT):
10631080
raise SystemExit("There are ipgen modules with multiple instances: "
10641081
f"{multi_instance_ipgens}")
10651082

1083+
if "gpio" in ipgen_instances:
1084+
instance = ipgen_instances["gpio"][0]
1085+
insert_ip_attrs(instance, _get_gpio_params(topcfg))
10661086
if "racl_config" in topcfg:
10671087
amend_racl(topcfg, name_to_block, allow_missing_blocks=True)
10681088
assert "racl_ctrl" in ipgen_instances
@@ -1234,6 +1254,9 @@ def generate_modules(template_type: str,
12341254
# Generate rstmgr if there is an instance
12351255
generate_modules("rstmgr", generate_rstmgr, single_instance=True)
12361256

1257+
# Generate gpio if there is an instance
1258+
generate_modules("gpio", generate_gpio, single_instance=True)
1259+
12371260
# Generate ac_range_check
12381261
generate_modules("ac_range_check",
12391262
generate_ac_range_check,

0 commit comments

Comments
 (0)