Is there a tcl command to autoscale, manual scale,...
# xschem
d
Is there a tcl command to autoscale, manual scale, set lin log axis etc on the built in graphing? I would like to share graphs between say AC and DC sims and have the launcher change scales etc when loading that data set. Or is there a better way to did this? Thanks
s
yes this can be done, xschem graphs are just rectangles on layer 2 (grey) with some attributes. These attributes can be changed using the following command:
xschem setprop rect 2 0 x1 1e-8
the first number is the rectangle layer and for graphs should be always 2 the second number is the graph number (0, 1, 2, ...) the first created graph is 0, the next is 1 and so on. to get the graph number position the mouse pointer close to the inner left border, click and see the n = in the status bottom line (1st picture). To get all defined attributes select the graph as expained before and press 'q' (2nd picture) Examples: • set end value of graph '1' x axis to 12e-12:
xschem setprop rect 2 1 x2 12p
• set initial value of x axis to 2p:
xschem setprop rect 2 1 x1 2p
• switch to log scale x:
xschem setprop rect 2 1 logx 1
(you need to set the x1 and x2 in log units afterwards). • Change trace colors (assuming there are 2 traces):
xschem setprop rect 2 1 color {6 9}
Currently there is no autoscale command equivalent to the 'f' key, will add that.
🌍 1
👍 1
Another way to do this is to place multiple graphs , some fit for AC analysis and some fit for tran analysis: see video. the AC launcher has this command:
xschem raw_read $netlist_dir/test_ac.raw ac
the TRAN launcher does:
xschem raw_read $netlist_dir/test_ac.raw tran
d
Thanks, the tcl works a treat.
excuse my inability to use a search engine... 🙂 but what is the best reference for these commands?
s
@Daniel For generic tcl commands there are tons of on line resources. For xschem tcl commands I am writing documentation, i am not done yet. I hope to add the xschem-specific tcl commands (xschem ... tcl commands) very soon here. There are 154 commands (some are mostly for debugging) however it's quite a lot of stuff.
d
great thanks; yes I meant xchem specific.
s
The xschem specific commands are just a new tcl command (xschem) with lot of sub commands. And these commands behave like true tcl commands so they can be chained. For example the following command lists the attributes of a sky130 MOS transistor M20:
xschem list_tokens [xschem getprop instance M20] 0
name L W ad pd as ps nrd nrs sa sb sd nf mult model spiceprefix
the inner command gets the whole attribute string of M20 (name=M20 W=.. L=.. model=... ....) the outer command extracts the attributes. All the xschem specific tcl commands are defined in file scheduler.c, if you look at lines looking like this:
else if(!strcmp(argv[1], "list_tokens"))
{
...
}
Of course it is difficult to get the meaning looking into an obscure C file. I will add the documentation asap.
@Daniel if you update your xschem installation i have added commands to full zoom on x and y axes a graph.(see below example procedure) attached procedure (you can load it at the xschem prompt with
source create_graph.tcl
) allows you to create a graph in xschem and full zoom in both directions, using xschem like a waveform viewer.
Copy code
proc create_graph {rawfile node {analysis tran} {color {4 5 6 7 8 9 10 11 12 13 14}}} {
  # clear window if not already empty
  xschem clear force
  # clear loaded raw file if any
  xschem raw_clear
  # set current layer to graph layer (grey, layer 2)
  xschem set rectcolor 2
  # create a 300x400 rectangle
  xschem rect 0 -300 400 0
  # make it a graph
  xschem setprop rect 2 0 flags graph
  # read a simulation raw file
  xschem raw_read $rawfile $analysis
  # add nodes to display
  xschem setprop rect 2 0 node $node
  # set node colors
  xschem setprop rect 2 0 color $color
  # make xschem display full the graph rectangle
  xschem zoom_full
  # full zoom graph data on x axis
  xschem setprop rect 2 0 fullxzoom
  # full zoom graph data on y axis
  xschem setprop rect 2 0 fullyzoom
}
After sourcing the file you call this procedure at the xschem prompt in the following way:
create_graph  .xschem/simulations/solar_panel.raw {led panel}
see attached short video.
d
Thanks for the quick work. Y seems good. X does odd things when I have two graphs. I think gr is pointing to the wrong graph and getting the fact another graph is set to log or lin scale that is different to the one I'm actually trying to autoscale. ie changing 1882 in draw.c to use get_tok_value instead of what gr->logx is does the right thing in my mind. Only briefly looked at the code so can't submit a proper fix though, sorry.
s
Thank you, yes it was a bug. If you have a chance to update xschem and redo the test it would be great if you let me know if it works as expected now. As you noticed the gr structure was not correctly set (setup_graph_data() function call missing in below code, taken from scheduler.c, "`fullxzoom`" command).
if(argc > 5 && c == 2 && !strcmp(argv[5], "fullxzoom")) {
xRect *r = &xctx->rect[c][n];
Graph_ctx *gr = &xctx->graph_struct;
int dataset;
`/ following line was missing, scheduler.c line 2786 /`
setup_graph_data(n, 0, gr);
if(gr->dataset >= 0 && gr->dataset < xctx->graph_datasets) dataset = gr->dataset;
else dataset = -1;
graph_fullxzoom(r, gr, dataset);
}
❤️ 1
d
yes, with the schematic I was testing it is good now thanks.