FriendFX
FriendFX

Reputation: 3079

Can we have variables in a Yosys script?

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

Upvotes: 6

Views: 1282

Answers (1)

CliffordVienna
CliffordVienna

Reputation: 8245

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.

Upvotes: 9

Related Questions