wrap long lines in source code, set default direction of pins to "B"(idirectional) if not specified in spice netlist (no *.PININFO information)

This commit is contained in:
Stefan Frederik 2020-11-22 00:51:24 +01:00
parent 427bce91e7
commit d93826f61c
15 changed files with 150 additions and 114 deletions

View File

@ -1212,7 +1212,8 @@ void descend_schematic(int instnumber)
inst_number = instnumber;
}
if(inst_number < 0 ) inst_number += inst_mult+1;
if(inst_number <1 || inst_number > inst_mult) inst_number = 1; /* any invalid number->descend to leftmost inst */
/* any invalid number->descend to leftmost inst */
if(inst_number <1 || inst_number > inst_mult) inst_number = 1;
}
dbg(1,"descend_schematic(): inst_number=%d\n", inst_number);
my_strcat(15, &xctx->sch_path[xctx->currsch+1], find_nth(str, ',', inst_number));
@ -1615,50 +1616,75 @@ void zoom_box(int what)
}
}
#define STORE
void draw_stuff(void)
{
double x1,y1,w,h, x2, y2;
int i;
int n = 200000;
clear_drawing();
view_unzoom(40);
for(i=0;i<=210000;i++)
{
w=(float)(areaw*xctx->zoom/800) * rand() / (RAND_MAX+1.0);
h=(float)(areah*xctx->zoom/80) * rand() / (RAND_MAX+1.0);
x1=(float)(areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin;
y1=(float)(areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin;
x2=x1+w;
y2=y1+h;
ORDER(x1,y1,x2,y2);
rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1,y1,x2,y2, xRECT,rectcolor, 0, NULL);
}
for(i=0;i<=210000;i++)
{
w=(float)(areaw*xctx->zoom/80) * rand() / (RAND_MAX+1.0);
h=(float)(areah*xctx->zoom/800) * rand() / (RAND_MAX+1.0);
x1=(float)(areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin;
y1=(float)(areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin;
x2=x1+w;
y2=y1+h;
ORDER(x1,y1,x2,y2);
rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1,y1,x2,y2,xRECT,rectcolor, 0, NULL);
}
for(i=0;i<=210000;i++)
{
w=(float)xctx->zoom * rand() / (RAND_MAX+1.0);
h=w;
x1=(float)(areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin;
y1=(float)(areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin;
x2=x1+w;
y2=y1+h;
rectcolor = (int) (10.0*rand()/(RAND_MAX+1.0))+4;
RECTORDER(x1,y1,x2,y2);
storeobject(-1, x1,y1,x2,y2,xRECT,rectcolor, 0, NULL);
#ifndef STORE
n /= (cadlayers - 4);
for(rectcolor = 4; rectcolor < cadlayers; rectcolor++) {
#else
#endif
for(i = 0; i < n; i++)
{
w=(float)(areaw*xctx->zoom/800) * rand() / (RAND_MAX+1.0);
h=(float)(areah*xctx->zoom/80) * rand() / (RAND_MAX+1.0);
x1=(float)(areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin;
y1=(float)(areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin;
x2=x1+w;
y2=y1+h;
ORDER(x1,y1,x2,y2);
#ifdef STORE
rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1, y1, x2, y2, xRECT,rectcolor, 0, NULL);
#else
drawtemprect(gc[rectcolor], ADD, x1, y1, x2, y2);
#endif
}
for(i = 0; i < n; i++)
{
w=(float)(areaw*xctx->zoom/80) * rand() / (RAND_MAX+1.0);
h=(float)(areah*xctx->zoom/800) * rand() / (RAND_MAX+1.0);
x1=(float)(areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin;
y1=(float)(areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin;
x2=x1+w;
y2=y1+h;
ORDER(x1,y1,x2,y2);
#ifdef STORE
rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1, y1, x2, y2,xRECT,rectcolor, 0, NULL);
#else
drawtemprect(gc[rectcolor], ADD, x1, y1, x2, y2);
#endif
}
for(i = 0; i < n; i++)
{
w=(float)xctx->zoom * rand() / (RAND_MAX+1.0);
h=w;
x1=(float)(areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin;
y1=(float)(areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin;
x2=x1+w;
y2=y1+h;
RECTORDER(x1,y1,x2,y2);
#ifdef STORE
rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1, y1, x2, y2,xRECT,rectcolor, 0, NULL);
#else
drawtemprect(gc[rectcolor], ADD, x1, y1, x2, y2);
#endif
}
#ifndef STORE
drawtemprect(gc[rectcolor], END, 0.0, 0.0, 0.0, 0.0);
}
#else
draw();
#endif
}
void restore_selection(double x1, double y1, double x2, double y2)

View File

@ -126,7 +126,8 @@ int callback(int event, int mx, int my, KeySym key,
if(semaphore)
{
if(debug_var>=2)
if(event != MotionNotify) fprintf(errfp, "callback(): reentrant call of callback(), semaphore=%d\n", semaphore);
if(event != MotionNotify)
fprintf(errfp, "callback(): reentrant call of callback(), semaphore=%d\n", semaphore);
/* if(event==Expose) {
* XCopyArea(display, save_pixmap, window, gctiled, mx,my,button,aux,mx,my);
*
@ -251,8 +252,9 @@ int callback(int event, int mx, int my, KeySym key,
if(vertical_move) mousex_snap = mx_double_save;
new_polygon(RUBBER);
}
if(!(ui_state & STARTPOLYGON) && (state&Button1Mask) && !(ui_state & STARTWIRE) && !(ui_state & STARTPAN2) &&
!(state & Mod1Mask) && !(state & ShiftMask) && !(ui_state & PLACE_SYMBOL)) /* start of a mouse area select */
/* start of a mouse area select */
if(!(ui_state & STARTPOLYGON) && (state&Button1Mask) && !(ui_state & STARTWIRE) &&
!(ui_state & STARTPAN2) && !(state & Mod1Mask) && !(state & ShiftMask) && !(ui_state & PLACE_SYMBOL))
{
static int onetime=0;
if(mx != mx_save || my != my_save) {
@ -1318,7 +1320,6 @@ int callback(int event, int mx, int my, KeySym key,
if( 0 && (key==';') && (state & ControlMask) ) /* testmode: for performance testing */
{
draw_stuff();
draw();
break;
}
if(0 && key=='~' && (state & ControlMask)) { /* testmode */

View File

@ -1650,7 +1650,7 @@ void draw(void)
for(i=0;i<xctx->instances;i++) {
if(xctx->inst[i].ptr == -1) continue;
symptr = (xctx->inst[i].ptr+ xctx->sym);
if( c==0 || /*20150408 draw_symbol call is needed on layer 0 to avoid redundant work (outside check) */
if( c==0 || /*draw_symbol call is needed on layer 0 to avoid redundant work (outside check) */
symptr->lines[c] ||
symptr->arcs[c] ||
symptr->rects[c] ||

View File

@ -493,7 +493,7 @@ void edit_line_property(void)
} else {
y1 = xctx->line[c][n].y1+INT_BUS_WIDTH(xctx->lw); y2 = xctx->line[c][n].y2-INT_BUS_WIDTH(xctx->lw);
}
bbox(ADD, xctx->line[c][n].x1-INT_BUS_WIDTH(xctx->lw), y1 , xctx->line[c][n].x2+INT_BUS_WIDTH(xctx->lw) , y2 );
bbox(ADD, xctx->line[c][n].x1-INT_BUS_WIDTH(xctx->lw), y1, xctx->line[c][n].x2+INT_BUS_WIDTH(xctx->lw), y2);
}
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();

View File

@ -331,6 +331,7 @@ function compact_pinlist(inst,inst_sub , prevgroup, group,i,ii,
else net_ret[ii] = compact_label(inst,net_ar,curr_n,i-1)
}
dir_ret[ii] = pin_ar[inst_sub,"dir",pin_ar[inst_sub,i-1] ]
if(dir_ret[ii] == "") dir_ret[ii] = "B"
ii++
curr=base;curr_n=i
prevgroup=group
@ -345,6 +346,7 @@ function compact_pinlist(inst,inst_sub , prevgroup, group,i,ii,
}
dir_ret[ii] = pin_ar[inst_sub,"dir",pin_ar[inst_sub,np] ]
if(dir_ret[ii] == "") dir_ret[ii] = "B"
pin_ret["n"] = dir_ret["n"] = ii
if(inst) net_ret["n"] = ii
}

View File

@ -96,12 +96,14 @@ const char *expandlabel(const char *s, int *m)
l = strlen(s)+120;
cmd = my_malloc(526, l);
fprintf(errfp, "syntax error in %s\n", s);
my_snprintf(cmd, l, "tk_messageBox -icon error -type ok -message {Syntax error in identifier expansion: %s}", s);
my_snprintf(cmd, l,
"tk_messageBox -icon error -type ok -message {Syntax error in identifier expansion: %s}", s);
if(has_x) tcleval(cmd);
my_free(543, &cmd);
}
if(dbg_var >= 3) fprintf(errfp, "expandlabel(): returning %s from %s mult=%d\n",dest_string.str, s, dest_string.m);
if(dbg_var >= 3)
fprintf(errfp, "expandlabel(): returning %s from %s mult=%d\n",dest_string.str, s, dest_string.m);
if(dest_string.str)
*m = dest_string.m;
else

View File

@ -1371,7 +1371,8 @@ void align_sch_pins_with_sym(const char *name, int pos)
dbg(1, "align_sch_pins_with_sym(): i=%d, pin name=%s entry->value=%d\n", i, pinname, entry->value);
}
if(!fail) {
for(i=0; i < xctx->sym[pos].rects[PINLAYER]; i++) { /* copy box[] ordererd array to LCC schematic instance */
/* copy box[] ordererd array to LCC schematic instance */
for(i=0; i < xctx->sym[pos].rects[PINLAYER]; i++) {
xctx->sym[pos].rect[PINLAYER][i] = box[i];
}
}

View File

@ -442,7 +442,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
prepared_netlist_structs=0;
prepared_hilight_structs=0;
if(has_x) {
tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\""); /* 20150417 set window and icon title */
tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\""); /* set window and icon title */
tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]\"");
}
}
@ -943,7 +943,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
} else if(!strcmp(argv[1],"save")) {
dbg(1, "scheduler(): saving: current schematic\n");
if(!strcmp(xctx->sch[xctx->currsch],"")) { /* 20170622 check if unnamed schematic, use saveas in this case... */
if(!strcmp(xctx->sch[xctx->currsch],"")) { /* check if unnamed schematic, use saveas in this case... */
saveas(NULL, SCHEMATIC);
} else {
save(0);

View File

@ -655,7 +655,8 @@ void select_element(int i,unsigned short select_mode, int fast, int override_loc
my_strncpy(s,xctx->inst[i].prop_ptr!=NULL?xctx->inst[i].prop_ptr:"<NULL>",S(s));
if(event_reporting) {
char n[PATH_MAX];
printf("xschem search exact %d name %s\n", select_mode? 1:-1, escape_chars(n, xctx->inst[i].instname, PATH_MAX));
printf("xschem search exact %d name %s\n",
select_mode? 1:-1, escape_chars(n, xctx->inst[i].instname, PATH_MAX));
fflush(stdout);
}
if( !fast )

View File

@ -58,7 +58,8 @@ void global_spice_netlist(int global) /* netlister driver */
bus_replacement_char[1] = str_tmp[1];
}
netlist_count=0;
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d", netlist_dir, skip_dir(xctx->sch[xctx->currsch]), getpid());
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d",
netlist_dir, skip_dir(xctx->sch[xctx->currsch]), getpid());
dbg(1, "global_spice_netlist(): opening %s for writing\n",netl_filename);
fd=fopen(netl_filename, "w");
@ -340,6 +341,9 @@ void spice_block_netlist(FILE *fd, int i)
my_strncpy(filename, abs_sym_path(str_tmp, ""), S(filename));
load_schematic(1,filename, 0);
} else {
dbg(1, "spice_block_netlist(): loading: %s -> %s\n",
xctx->sym[i].name, add_ext(abs_sym_path(xctx->sym[i].name, ""), ".sch"));
dbg(1, "spice_block_netlist(): current_dirname=%s\n", tclgetvar("current_dirname"));
load_schematic(1, add_ext(abs_sym_path(xctx->sym[i].name, ""), ".sch") ,0);
}
spice_netlist(fd, spice_stop); /* 20111113 added spice_stop */

View File

@ -185,7 +185,8 @@ void store_arc(int pos, double x, double y, double r, double a, double b,
set_modify(1);
}
void store_poly(int pos, double *x, double *y, int points, unsigned int rectcolor, unsigned short sel, char *prop_ptr)
void store_poly(int pos, double *x, double *y, int points, unsigned int rectcolor,
unsigned short sel, char *prop_ptr)
{
int n, j;
const char *dash;

View File

@ -1484,7 +1484,7 @@ void print_spice_element(FILE *fd, int inst)
( (!space && c != '$' && c != '@') && escape )
)
) {
dbg(1, "print_spice_element(): c=%c, space=%d, escape=%d roken_pos=%d\n", c, space, escape, token_pos);
dbg(1, "print_spice_element(): c=%c, space=%d, escape=%d token_pos=%d\n", c, space, escape, token_pos);
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);

View File

@ -49,7 +49,8 @@ void global_verilog_netlist(int global) /* netlister driver */
/* top sch properties used for library use declarations and type definitions */
/* to be printed before any entity declarations */
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d", netlist_dir, skip_dir(xctx->sch[xctx->currsch]),getpid());
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d",
netlist_dir, skip_dir(xctx->sch[xctx->currsch]),getpid());
fd=fopen(netl_filename, "w");
if(user_top_netl_name[0]) {

View File

@ -49,7 +49,8 @@ void global_vhdl_netlist(int global) /* netlister driver */
}
netlist_count=0;
free_hash(subckt_table);
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d", netlist_dir, skip_dir(xctx->sch[xctx->currsch]), getpid());
my_snprintf(netl_filename, S(netl_filename), "%s/.%s_%d",
netlist_dir, skip_dir(xctx->sch[xctx->currsch]), getpid());
fd=fopen(netl_filename, "w");
@ -509,69 +510,63 @@ void vhdl_block_netlist(FILE *fd, int i)
if(!vhdl_stop)
for(j=0;j<xctx->symbols;j++)
{
if( strcmp(get_tok_value(xctx->sym[j].prop_ptr,"vhdl_primitive",0),"true")==0 ) continue;
if(!xctx->sym[j].type || (strcmp(xctx->sym[j].type,"primitive")!=0 && strcmp(xctx->sym[j].type,"subcircuit")!=0))
continue;
if((
strcmp(xctx->sym[j].type,"subcircuit")==0 ||
strcmp(xctx->sym[j].type,"primitive")==0
) && check_lib(xctx->sym[j].name)
)
{
/* only print component declaration if used in current subcircuit */
found=0;
for(l=0;l<xctx->instances;l++)
{
if( strcmp(get_tok_value(xctx->inst[l].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(xctx->inst[l].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[l].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
if(!strcmp(xctx->sym[j].name,xctx->inst[l].name))
{
found=1; break;
}
}
if(!found) continue;
/* component generics */
print_generic(fd, "component",j);
/* component ports */
tmp=0;
for(k=0;k<xctx->sym[j].rects[PINLAYER];k++)
{
if(strcmp(get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"vhdl_ignore",0), "true")) {
my_strdup(597, &sig_type,get_tok_value(
xctx->sym[j].rect[PINLAYER][k].prop_ptr,"sig_type",0));
my_strdup(598, &port_value, get_tok_value(
xctx->sym[j].rect[PINLAYER][k].prop_ptr,"value",2) );
if(!sig_type || sig_type[0]=='\0') my_strdup(599, &sig_type,"std_logic");
my_strdup(600, &dir_tmp, get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"dir",0) );
str_tmp = get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"name",0);
if(!tmp) fprintf(fd, "port (\n");
if(tmp) fprintf(fd, " ;\n");
fprintf(fd," %s : %s %s",str_tmp ? str_tmp : "<NULL>",
dir_tmp ? dir_tmp : "<NULL>", sig_type);
my_free(1093, &dir_tmp);
if(port_value &&port_value[0])
fprintf(fd," := %s", port_value);
tmp=1;
if( strcmp(get_tok_value(xctx->sym[j].prop_ptr,"vhdl_primitive",0),"true")==0 ) continue;
if(!xctx->sym[j].type || (strcmp(xctx->sym[j].type,"primitive")!=0 &&
strcmp(xctx->sym[j].type,"subcircuit")!=0))
continue;
if(( strcmp(xctx->sym[j].type,"subcircuit")==0 || strcmp(xctx->sym[j].type,"primitive")==0) &&
check_lib(xctx->sym[j].name)
) {
/* only print component declaration if used in current subcircuit */
found=0;
for(l=0;l<xctx->instances;l++)
{
if( strcmp(get_tok_value(xctx->inst[l].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(xctx->inst[l].ptr<0) continue;
if(!strcmp(get_tok_value( (xctx->inst[l].ptr+ xctx->sym)->prop_ptr, "vhdl_ignore",0 ), "true") ) {
continue;
}
if(!strcmp(xctx->sym[j].name,xctx->inst[l].name))
{
found=1; break;
}
}
if(!found) continue;
/* component generics */
print_generic(fd, "component",j);
/* component ports */
tmp=0;
for(k=0;k<xctx->sym[j].rects[PINLAYER];k++)
{
if(strcmp(get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"vhdl_ignore",0), "true")) {
my_strdup(597, &sig_type,get_tok_value(
xctx->sym[j].rect[PINLAYER][k].prop_ptr,"sig_type",0));
my_strdup(598, &port_value, get_tok_value(
xctx->sym[j].rect[PINLAYER][k].prop_ptr,"value",2) );
if(!sig_type || sig_type[0]=='\0') my_strdup(599, &sig_type,"std_logic");
my_strdup(600, &dir_tmp, get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"dir",0) );
str_tmp = get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"name",0);
if(!tmp) fprintf(fd, "port (\n");
if(tmp) fprintf(fd, " ;\n");
fprintf(fd," %s : %s %s",str_tmp ? str_tmp : "<NULL>",
dir_tmp ? dir_tmp : "<NULL>", sig_type);
my_free(1093, &dir_tmp);
if(port_value &&port_value[0])
fprintf(fd," := %s", port_value);
tmp=1;
}
}
if(tmp) fprintf(fd, "\n);\n");
fprintf(fd, "end component ;\n\n");
}
if(tmp) fprintf(fd, "\n);\n");
fprintf(fd, "end component ;\n\n");
}
}
dbg(1, "vhdl_block_netlist(): netlisting %s\n",
skip_dir( xctx->sch[xctx->currsch]));
dbg(1, "vhdl_block_netlist(): netlisting %s\n", skip_dir( xctx->sch[xctx->currsch]));
vhdl_netlist(fd, vhdl_stop);
fprintf(fd,"//// begin user architecture code\n");
for(l=0;l<xctx->instances;l++) {
if( strcmp(get_tok_value(xctx->inst[l].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(xctx->inst[l].ptr<0) continue;

View File

@ -81,7 +81,8 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/
Atom prop1 = 0;
Atom prop2 = 0;
char *p1, *p2;
const char *argerr = "expects a list of comma separated parameters: \"(remove|add|toggle),<PROP1>[,<PROP2>]\"\n";
const char *argerr = "expects a list of comma separated parameters: "
"\"(remove|add|toggle),<PROP1>[,<PROP2>]\"\n";
my_strdup(604, &arg_copy, arg);
@ -1013,7 +1014,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
my_strcat(416, &win_xschem_library_path, "\;");
my_strcat(431, &win_xschem_library_path, tmp);
}
my_snprintf(tmp, S(tmp), "set tmp2 \"%s\"; while {[regsub {([^/]*\\.*[^./]+[^/]*)/\\.\\./?} $tmp2 {} tmp2]} {}; ", win_xschem_library_path);
my_snprintf(tmp, S(tmp), "set tmp2 \"%s\"; "
"while {[regsub {([^/]*\\.*[^./]+[^/]*)/\\.\\./?} $tmp2 {} tmp2]} {}; ", win_xschem_library_path);
const char *result2 = tcleval(tmp);
const char *win_xschem_library_path_clean = tclgetvar("tmp2");
tclsetvar("XSCHEM_LIBRARY_PATH", win_xschem_library_path_clean);