Skip to content

Commit

Permalink
Merge pull request #347 from hdl/liberty_cell
Browse files Browse the repository at this point in the history
Adds ability to use standard cells in user provided RTL
  • Loading branch information
QuantamHD authored Aug 23, 2024
2 parents 30d7f3d + 1411c99 commit 805f6fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 10 additions & 1 deletion synthesis/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ def _synthesize_design_impl(ctx):
for dont_use_pattern in or_config.do_not_use_cell_list:
dont_use_args += " -dont_use {} ".format(dont_use_pattern)

if ctx.attr.verilog_defines:
for define in ctx.attr.verilog_defines:
args.add(define)

standard_cell_black_box = ctx.actions.declare_file("{}_stdcells_blackbox.v".format(ctx.attr.name))
script_env_files = {
"ABC_SCRIPT": abc_script,
"ADDITIONAL_LIBERTIES": additional_liberty_files,
Expand All @@ -145,6 +150,7 @@ def _synthesize_design_impl(ctx):
"FLIST": verilog_flist,
"LIBERTY": default_liberty_file,
"OUTPUT": output_file,
"STANDARD_CELL_BLACK_BOX": standard_cell_black_box,
"TOP": ctx.attr.top_module,
"UHDM_FLIST": uhdm_flist,
}
Expand Down Expand Up @@ -178,7 +184,7 @@ def _synthesize_design_impl(ctx):
env[k] = v

ctx.actions.run(
outputs = [output_file, log_file],
outputs = [output_file, log_file, standard_cell_black_box],
inputs = inputs,
arguments = [args],
executable = ctx.executable.yosys_tool,
Expand Down Expand Up @@ -343,6 +349,9 @@ synthesize_rtl = rule(
"top_module": attr.string(
default = "top",
),
"verilog_defines": attr.string_list(
doc = "Verilog defines to pass to the synthesis tool.",
),
"yosys_tool": attr.label(
default = Label("@at_clifford_yosys//:yosys"),
executable = True,
Expand Down
11 changes: 11 additions & 0 deletions synthesis/synth.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@

yosys -import

set all_liberties [split $::env(ADDITIONAL_LIBERTIES) ","]
lappend all_liberties $::env(LIBERTY)

# create liberty blackbox so cells can be manually created.
foreach lib $all_liberties {
read_liberty -lib -overwrite $lib
}

write_verilog -blackboxes $::env(STANDARD_CELL_BLACK_BOX)

# read design
set srcs_flist_path $::env(FLIST)
set srcs_flist_file [open $srcs_flist_path "r"]
set srcs_flist_data [read $srcs_flist_file]
set srcs [split $srcs_flist_data "\n"]
set srcs [linsert $srcs 0 $::env(STANDARD_CELL_BLACK_BOX)]
puts $srcs
foreach src $srcs {
# Skip empty lines, including the implict one after the last \n delimiter
Expand Down

0 comments on commit 805f6fa

Please sign in to comment.