Skip to content

Commit

Permalink
[topgen] Make toplevel SV and chiplevel templates top-sepcific
Browse files Browse the repository at this point in the history
This PR makes the toplevel verilog and chiplevel template top-specific
to better scale with multiple tops. This avoids adding multiple cases
to the template dealing with top-specic funcitonality.

Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
  • Loading branch information
Razer6 authored and rswarbrick committed Oct 9, 2024
1 parent d0f3500 commit 7e76fe2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions hw/top_englishbreakfast/templates/chiplevel.sv.tpl
1 change: 1 addition & 0 deletions hw/top_englishbreakfast/templates/toplevel.sv.tpl
9 changes: 6 additions & 3 deletions util/topgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from io import StringIO
from itertools import chain
from pathlib import Path
from typing import Dict, List, Optional, Tuple
from typing import Dict, List

import hjson
import tlgen
Expand Down Expand Up @@ -1214,16 +1214,19 @@ def render_template(template_path: str, rendered_path: Path,
// {seed}
""".format(top_name=top_name, seed=completecfg["rnd_cnst_seed"])

# Top and chiplevel templates are top-specific
top_template_path = SRCTREE_TOP / "hw" / top_name / "templates"

# SystemVerilog Top:
# "toplevel.sv.tpl" -> "rtl/autogen/{top_name}.sv"
render_template(TOPGEN_TEMPLATE_PATH / "toplevel.sv.tpl",
render_template(top_template_path / "toplevel.sv.tpl",
out_path / "rtl" / "autogen" / f"{top_name}.sv",
gencmd=gencmd)

# Multiple chip-levels (ASIC, FPGA, Verilator, etc)
for target in topcfg["targets"]:
target_name = target["name"]
render_template(TOPGEN_TEMPLATE_PATH / "chiplevel.sv.tpl",
render_template(top_template_path / "chiplevel.sv.tpl",
out_path /
f"rtl/autogen/chip_{topname}_{target_name}.sv",
gencmd=gencmd,
Expand Down

0 comments on commit 7e76fe2

Please sign in to comment.