Question: When I use a user_io as a clk input, how...
# caravel
h
Question: When I use a user_io as a clk input, how should I put it into
config.tcl
? I am using e.g.
io_in[34]
as clk in the user area. set ::env(CLOCK_PORT) “????” set ::env(CLOCK_NET) “????”
t
@User: Can you please answer this question?
h
@User Did you use a GPIO as clock input for one of your macros?
m
@User You can specify the clock port to be
io_in[34]
, but you might need to escape the square brackets
Copy code
set ::env(CLOCK_PORT) "io_in\[34\]"
👍 1
m
Try using
set ::env(CLOCK_PORT) {io_in[34]}
I believe this is how variables are quoted in the recent changes to
config.tcl
(see the automatically generated
<design>/runs/tag/config.tcl
)
h
Thanks for the hints, I tried them, unfortunately not successful. As soon as there are the square brackets, even escaped, with or without curly braces, crash of the script, saying “invalid command name “34" while executing”
I found a working solution, one more iteration I missed earlier:
Copy code
set ::env(CLOCK_PORT) {io_in\[34\]}
this works 🙂
Correction: Almost works. It crashed in step 41 (CVC) when collecting the results?!? Same error as before:
invalid command name "34"
Here the complete trace, maybe helps to debug:
Copy code
invalid command name "34"
    while executing
"34"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 ${cmd}"
    (procedure "set_log" line 3)
    invoked from within
"set_log ::env($index) $escaped_env_var $::env(GLB_CFG_FILE) 1"
    (procedure "save_state" line 9)
    invoked from within
"save_state"
    (procedure "run_non_interactive_mode" line 68)
    invoked from within
"run_non_interactive_mode {*}$argv"
    invoked from within
"if { [info exists flags_map(-interactive)] || [info exists flags_map(-it)] } {
	puts_info "Running interactively"
	if { [info exists arg_values(-file)..."
    (file "/openlane/flow.tcl" line 356)
make: *** [Makefile:43: user_proj_dac] Error 1
@User any idea why it crashes, or another solution instead of
set ::env(CLOCK_PORT) {io_in\[34\]}
t
Somewhere along the line the escapes got removed from the name. This is deep within the openlane flow and I don't know which tool to accuse. Likely you will need to work with the Openlane developers to figure this out. Using a clock applied externally from a GPIO is a normal use case, so it ought to be working out-of-the-box.
m
@User I'm the CVC developer, but it may have more to do with the openlane flow. Using bus signals as clocks was a problem a couple months ago, but I thought it was fixed. What version of openlane are you on?
More specifically, how is
CLOCK_PORT
stored in
<design_name>/runs/<tag>/config.tcl
? It may be stored twice in that file, check both if it is.
h
@User here’s the version of OpenLane I am using, it is quite a few weeks/months old, but is the only stable environment for Caravel that I found. If someone could make a recent config that works I would be glad to switch.
Copy code
OPENLANE_TAG=mpw-3a OPENLANE_IMAGE_NAME=efabless/openlane:mpw-3a
from `…/config.tcl`:
Copy code
set ::env(CLOCK_PORT) "io_in\[34\]"
it is only stored once.
m
@User There are 2 "versions" of the
config.tcl
file. The original is located just below the design directory and contains only the variables that the designer has set. The second is located under the runs/<tag> directory and stores all the variables from the first config file plus all the internal variable (including the current state) from running flow.tcl. What is the value of
CLOCK_PORT
in the second file? I don't believe mpw-3a has the changes required to use a bus signal as a clock. IIRC, the the following changes to openlane's
scripts/utils/utils.tcl
is all you need.
Copy code
# puts a variable in a log file
 proc set_log {var val filepath log_flag} {
-        set cmd "set ${var} \"${val}\""
-        uplevel #0 ${cmd}
-        set global_cfg_file [open $filepath a+]
-               if { $log_flag } {
-                       puts $global_cfg_file $cmd
-               }
-        close $global_cfg_file
+       set cmd "set ${var} \{${val}\}"
+       uplevel #0 ${cmd}
+       set global_cfg_file [open $filepath a+]
+       if { $log_flag } {
+               puts $global_cfg_file $cmd
+       }
+       close $global_cfg_file
 }
The
set cmd
line change is the only relevant line. The other changes are just spaces.
However, I remember a problem with one of the reporting programs after that in version mpw-3a. A python program tries to parse the config file and can't recognize the "{ }" quotes. That may need to be patched also.
h
@User I applied the patch to
scripts/utils/utils.tcl
you proposed, still crash. Here a bit more from the crash site, seems to be after CVC:
Copy code
CVC: Log output to /project/openlane/user_proj_dac/runs/user_proj_dac/results/cvc/cvc_user_proj_dac.log
CVC: End: Fri Jan 21 15:57:33 2022

[INFO]: Saving Magic Views in /project
[INFO]: Calculating Runtime From the Start...
[INFO]: flow completed for user_proj_dac/2022.01.21_15.52.00 in 0h5m33s
[INFO]: Saving Runtime Environment
invalid command name "34"
    while executing
"34"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 ${cmd}"
    (procedure "set_log" line 3)
    invoked from within
"set_log ::env($index) $escaped_env_var $::env(GLB_CFG_FILE) 1"
    (procedure "save_state" line 9)
    invoked from within
"save_state"
    (procedure "run_non_interactive_mode" line 68)
    invoked from within
"run_non_interactive_mode {*}$argv"
    invoked from within
"if { [info exists flags_map(-interactive)] || [info exists flags_map(-it)] } {
	puts_info "Running interactively"
	if { [info exists arg_values(-file)..."
    (file "/openlane/flow.tcl" line 356)
make: *** [Makefile:43: user_proj_dac] Error 1
m
Can you
grep CLOCK_ /project/openlane/user_proj_dac/runs/user_proj_dac/config.tcl
?
h
good catch, I think here’s the problem. the {} get replaced by “”:
Copy code
set ::env(CLOCK_BUFFER_FANOUT) "16"
set ::env(CLOCK_PERIOD) "10"
set ::env(CLOCK_PORT) "io_in\[34\]"
set ::env(CLOCK_TREE_SYNTH) "1"
set ::env(CLOCK_WIRE_RC_LAYER) "met5"
set ::env(SYNTH_CLOCK_TRANSITION) "0.15"
set ::env(SYNTH_CLOCK_UNCERTAINITY) "0.25"
set ::env(CLOCK_BUFFER_FANOUT) "16"
m
The changes to
util.tcl
should change that (but not totally fix the problem). If you're using
make <cell>
in the
/project/openlane/user_proj_dac
directory, it may not be using the openlane directory that you expect. Also, some values in the
<design>/runs/<tag>/config.tcl
do not get overwritten. Sometimes deleting this file before rerunning fixes some problems.
The latest version of openlane uses {} instead of "" in the config.tcl files.
Copy code
set ::env(CLOCK_BUFFER_FANOUT) {16}
set ::env(CLOCK_PERIOD) {10.0}
set ::env(CLOCK_TREE_SYNTH) {1}
set ::env(CLOCK_WIRE_RC_LAYER) {met5}
So I guess the reporting programs have been modified also. Another thing you might try is backing out the last change I suggested and using this instead.
Copy code
+++ b/scripts/tcl_commands/all.tcl
@@ -24,6 +24,8 @@ proc save_state {args} {
         if { $index != "INIT_ENV_VAR_ARRAY" && $index != "PS1" } {
             set escaped_env_var [string map {\" \\\"} $::env($index)]
             set escaped_env_var [string map {\$ \\\$} $escaped_env_var]
+            set escaped_env_var [string map {\[ \\\[} $escaped_env_var]
+            set escaped_env_var [string map {\] \\\]} $escaped_env_var]
             set_log ::env($index) $escaped_env_var $::env(GLB_CFG_FILE) 1
         }
     }
This adds an extra escape before calling
set_log
which is where your flow is failing.
h
I’ll try that later. For now I resorted to using the
user_clock2
🙂
👍 1
m
Yes, I ran into this same issue on MPW2/3 with the openram test chip. I had to hack the scripts like @User mentined above.