Skip to content

Commit

Permalink
synth: Make synthesize_rtl emit a VerilogInfo provider
Browse files Browse the repository at this point in the history
Lets you do gate level sims easier if this rule can be passed
as if it were a verilog_library

Signed-off-by: Ethan Mahintorabi <[email protected]>
  • Loading branch information
QuantamHD committed Nov 1, 2024
1 parent 8657ee9 commit 2b372e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 11 additions & 1 deletion synthesis/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Rules for synthesizing (System)Verilog code."""

load("@rules_hdl//pdk:build_defs.bzl", "StandardCellInfo")
load("//verilog:defs.bzl", "VerilogInfo")
load("//verilog:defs.bzl", "VerilogInfo", "make_dag_entry", "make_verilog_info")

# There are no rules to generate this provider, but it does provide the mechansim to build
# rules based on surelog in the open source world.
Expand Down Expand Up @@ -213,6 +213,16 @@ def _synthesize_design_impl(ctx):
verilog_files = verilog_files,
uhdm_files = uhdm_files,
),
make_verilog_info(
new_entries = [make_dag_entry(
label = ctx.label,
srcs = [output_file],
hdrs = [],
data = [],
deps = [],
tags = [],
)]
),
]

def _benchmark_synth(ctx, synth_log_file):
Expand Down
4 changes: 4 additions & 0 deletions verilog/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ load(
":providers.bzl",
_VerilogInfo = "VerilogInfo",
_verilog_library = "verilog_library",
_make_dag_entry = "make_dag_entry",
_make_verilog_info = "make_verilog_info",
)

VerilogInfo = _VerilogInfo
verilog_library = _verilog_library
make_dag_entry = _make_dag_entry
make_verilog_info = _make_verilog_info
5 changes: 4 additions & 1 deletion verilog/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ VerilogInfo = provider(
},
)

def make_dag_entry(srcs, hdrs, data, deps, label):
def make_dag_entry(srcs, hdrs, data, deps, label, tags):
"""Create a new DAG entry for use in VerilogInfo.
As VerilogInfo should be created via 'merge_verilog_info' (rather than directly),
Expand All @@ -42,6 +42,7 @@ def make_dag_entry(srcs, hdrs, data, deps, label):
data: A list of File that are `data`.
deps: A list of Label that are deps of this entry.
label: A Label to use as the name for this entry.
tags: A list of str. (Ideally) just the entry tags for later filelist filtering.
Returns:
struct with all these fields properly stored.
"""
Expand All @@ -50,6 +51,7 @@ def make_dag_entry(srcs, hdrs, data, deps, label):
hdrs = tuple(hdrs),
data = tuple(data),
deps = tuple(deps),
tags = tuple(tags),
label = label,
)

Expand Down Expand Up @@ -97,6 +99,7 @@ def _verilog_library_impl(ctx):
hdrs = ctx.files.hdrs,
deps = ctx.attr.deps,
label = ctx.label,
tags = [],
)],
old_infos = [dep[VerilogInfo] for dep in ctx.attr.deps],
)
Expand Down

0 comments on commit 2b372e7

Please sign in to comment.