Skip to content

Commit

Permalink
Document Error in JSON Config Files (The-OpenROAD-Project#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
donn authored Nov 21, 2022
1 parent cb59d1f commit ff85171
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions designs/spm/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"DESIGN_NAME": "spm",
"VERILOG_FILES": "dir::src/*.v",
"CLOCK_PERIOD": 10,
"TEST_FLOAT_REF": "expr::$CLOCK_PERIOD",
"CLOCK_PORT": "clk",
"CLOCK_NET": "ref::$CLOCK_PORT",
"FP_PDN_VOFFSET": 7,
Expand Down
12 changes: 11 additions & 1 deletion docs/source/reference/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Note that ***the order of declarations matter here***: as seen in the following
#### Variable Reference

If a string's value starts with `ref::`, you can interpolate exactly one variable at the beginning of your string.
If a string's value starts with `ref::`, you can interpolate exactly one **string** variable at the beginning of your string.

Like conditional execution, the order of declarations matter: i.e., you cannot reference a variable that is declared after the current expression.

Expand Down Expand Up @@ -172,6 +172,16 @@ It is important to note that, like variable referencing and conditional executio
```
> In this example, the first configuration is invalid, as B is used in a mathematical expression before declaration, but the latter is OK, evaluating to 8.
You can also simply reference another number using this prefix:

```json
{
"A": 10,
"B": "expr::$A"
}
```
> In this example, B will simply hold the value of A.
## Tcl
These configuration files are simple Tcl scripts with environment variables that are sourced by the OpenLane flow. Again, Tcl config files are not recommended for newer designs, but is still maintained and supported at the moment.

Expand Down
9 changes: 9 additions & 0 deletions scripts/config/tcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ def process_string(value: str, state: State) -> str:
reference_variable = match[1]
try:
found = state.vars[reference_variable]
if type(found) != str:
if type(found) in [int, float]:
raise InvalidConfig(
f"Referenced variable {reference_variable} is a number and not a string: use expr::{match[0]} if you want to reference this number."
)
else:
raise InvalidConfig(
f"Referenced variable {reference_variable} is not a string."
)
value = reference.replace(match[0], found)
full_abspath = os.path.abspath(value)

Expand Down

0 comments on commit ff85171

Please sign in to comment.