Skip to content

Commit c3b3a75

Browse files
committed
Merge remote-tracking branch 'pinata/synth-canonicalize' into synth-names-and-canonicalize
Signed-off-by: Matt Liberty <[email protected]>
2 parents 33f8c77 + 725fad6 commit c3b3a75

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

docs/tutorials/FlowTutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ constraints. We will use default configuration variables for this tutorial.
160160
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------|
161161
| `PLATFORM` | Specifies Process design kit. |
162162
| `DESIGN_NAME` | The name of the top-level module of the design |
163-
| `VERILOG_FILES` | The path to the design Verilog files |
163+
| `VERILOG_FILES` | The path to the design Verilog files or JSON files providing a description of modules (check `yosys -h write_json` for more details). |
164164
| `SDC_FILE` | The path to design `.sdc` file |
165165
| `CORE_UTILIZATION` | The core utilization percentage. |
166166
| `PLACE_DENSITY` | The desired placement density of cells. It reflects how spread the cells would be on the core area. 1 = closely dense. 0 = widely spread |

docs/user/FlowVariables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ file for each design located in the OpenROAD-flow-scripts directory of
222222
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
223223
| `PLATFORM` | Specifies process design kit or technology node to be used. |
224224
| `DESIGN_NAME` | The name of the top-level module of the design. |
225-
| `VERILOG_FILES` | The path to the design Verilog files. |
225+
| `VERILOG_FILES` | The path to the design Verilog files or JSON files providing a description of modules (check `yosys -h write_json` for more details). |
226226
| `SDC_FILE` | The path to design constraint (SDC) file. |
227227

228228

flow/Makefile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ export SYNTH_MEMORY_MAX_BITS ?= 4096
483483

484484
$(SYNTH_STOP_MODULE_SCRIPT):
485485
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR)
486-
($(TIME_CMD) $(YOSYS_CMD) $(YOSYS_FLAGS) -c $(HIER_REPORT_SCRIPT)) 2>&1 | tee $(LOG_DIR)/1_1_yosys_hier_report.log
486+
(export VERILOG_FILES=$(RESULTS_DIR)/1_synth.rtlil; \
487+
$(TIME_CMD) $(YOSYS_CMD) $(YOSYS_FLAGS) -c $(HIER_REPORT_SCRIPT)) 2>&1 | tee $(LOG_DIR)/1_1_yosys_hier_report.log
487488

488489
ifeq ($(SYNTH_HIERARCHICAL), 1)
489490
do-yosys: $(SYNTH_STOP_MODULE_SCRIPT)
@@ -499,11 +500,20 @@ $(SDC_FILE_CLOCK_PERIOD): $(SDC_FILE)
499500
yosys-dependencies: $(DONT_USE_LIBS) $(WRAPPED_LIBS) $(DONT_USE_SC_LIB) $(DFF_LIB_FILE) $(VERILOG_FILES) $(CACHED_NETLIST) $(LATCH_MAP_FILE) $(ADDER_MAP_FILE)
500501

501502
.PHONY: do-yosys
502-
do-yosys: yosys-dependencies
503+
do-yosys:
503504
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
504-
($(TIME_CMD) $(YOSYS_CMD) $(YOSYS_FLAGS) -c $(SYNTH_SCRIPT)) 2>&1 | tee $(LOG_DIR)/1_1_yosys.log
505+
(export VERILOG_FILES=$(RESULTS_DIR)/1_synth.rtlil; \
506+
$(TIME_CMD) $(YOSYS_CMD) $(YOSYS_FLAGS) -c $(SYNTH_SCRIPT)) 2>&1 | tee -a $(LOG_DIR)/1_1_yosys.log
505507

506-
$(RESULTS_DIR)/1_1_yosys.v: $(SDC_FILE_CLOCK_PERIOD)
508+
.PHONY: do-yosys-canonicalize
509+
do-yosys-canonicalize: yosys-dependencies
510+
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
511+
($(TIME_CMD) $(YOSYS_CMD) $(YOSYS_FLAGS) -c $(SCRIPTS_DIR)/synth_canonicalize.tcl) 2>&1 | tee $(LOG_DIR)/1_1_yosys.log
512+
513+
$(RESULTS_DIR)/1_synth.rtlil: $(RESULTS_DIR)/1_1_yosys.v $(SDC_FILE_CLOCK_PERIOD)
514+
$(UNSET_AND_MAKE) do-yosys-canonicalize
515+
516+
$(RESULTS_DIR)/1_1_yosys.v: $(RESULTS_DIR)/1_synth.rtlil $(SDC_FILE_CLOCK_PERIOD)
507517
$(UNSET_AND_MAKE) do-yosys
508518

509519
$(RESULTS_DIR)/1_synth.sdc: $(SDC_FILE)
@@ -520,7 +530,7 @@ $(RESULTS_DIR)/1_synth.v: $(RESULTS_DIR)/1_1_yosys.v
520530

521531
.PHONY: clean_synth
522532
clean_synth:
523-
rm -f $(RESULTS_DIR)/1_*.v $(RESULTS_DIR)/1_synth.sdc $(RESULTS_DIR)/mem.json
533+
rm -f $(RESULTS_DIR)/1_* $(RESULTS_DIR)/mem.json
524534
rm -f $(REPORTS_DIR)/synth_*
525535
rm -f $(LOG_DIR)/1_*
526536
rm -f $(SYNTH_STOP_MODULE_SCRIPT)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
2+
hierarchy -check -top $::env(DESIGN_NAME)
3+
# Get rid of unused modules
4+
opt_clean -purge
5+
# The hash of this file will not change if files not part of synthesis do not change
6+
write_rtlil $::env(RESULTS_DIR)/1_synth.rtlil

flow/scripts/synth_preamble.tcl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ if {[info exist ::env(VERILOG_INCLUDE_DIRS)]} {
2222

2323
# Read verilog files
2424
foreach file $::env(VERILOG_FILES) {
25-
read_verilog -defer -sv {*}$vIdirsArgs $file
25+
if {[file extension $file] == ".rtlil"} {
26+
read_rtlil $file
27+
} elseif {[file extension $file] == ".json"} {
28+
read_json $file
29+
} else {
30+
read_verilog -defer -sv {*}$vIdirsArgs $file
31+
}
2632
}
2733

2834

@@ -102,8 +108,6 @@ close $constr
102108
proc synthesize_check {synth_args} {
103109
# Generic synthesis
104110
log_cmd synth -top $::env(DESIGN_NAME) -run :fine {*}$synth_args
105-
# Get rid of unused modules
106-
clean
107111
json -o $::env(RESULTS_DIR)/mem.json
108112
# Run report and check here so as to fail early if this synthesis run is doomed
109113
exec -- python3 $::env(SCRIPTS_DIR)/mem_dump.py --max-bits $::env(SYNTH_MEMORY_MAX_BITS) $::env(RESULTS_DIR)/mem.json

0 commit comments

Comments
 (0)