6

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)?

FriendFX
  • 2,929
  • 1
  • 34
  • 63

1 Answers1

8

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.

CliffordVienna
  • 7,995
  • 1
  • 37
  • 57
  • 2
    Thanks a lot, this simplifies a few things. For the benefit of others: apart from running Yosys with the `-c` option, you'll also need to add the line `yosys -import` at the top of the script to make all Yosys commands available to the TCL interpreter and rename `proc` calls to `procs` as `proc` is a TCL reserved word. – FriendFX Mar 28 '17 at 23:41