问题
I'd like to make my Yosys scripts more DRY by factoring out common parameters, such as in the following example:
read_liberty -lib /long/path/to/lib/file
...
dfflibmap -liberty /long/path/to/lib/file
...
abc -liberty /long/path/to/lib/file
I haven't found a way to declare or de-reference variables, is there any way like in TCL (set lib_file /long/path/to/lib/file
) or Bash (export lib_file=/long/path/to/lib/file
)?
回答1:
You can use TCL. See yosys -h tcl
for details. Run TCL scripts with yosys -c <script_file>
(instead of yosys -s <script_file>
for native Yosys scripts.)
I've now added front-end detection for .tcl files in commit b8d7f57. So starting with b8d7f57 you can also use yosys <script_file>
to run a TCL script, if <script_file>
ends with .tcl
.
来源:https://stackoverflow.com/questions/43062516/can-we-have-variables-in-a-yosys-script