diff --git a/src/actions.c b/src/actions.c index 0845c460..061b85b1 100644 --- a/src/actions.c +++ b/src/actions.c @@ -877,8 +877,6 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot xctx->instances++; /* must be updated before calling symbol_bbox() */ - if(xctx->prep_hash_inst) hash_inst(XINSERT, n); /* no need to rehash, add item */ - /* xctx->prep_hash_inst=0; */ /* force these vars to 0 to trigger a prepare_netlist_structs(0) needed by symbol_bbox->translate @@ -887,6 +885,8 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot xctx->prep_hi_structs=0; symbol_bbox(n, &xctx->inst[n].x1, &xctx->inst[n].y1, &xctx->inst[n].x2, &xctx->inst[n].y2); + if(xctx->prep_hash_inst) hash_inst(XINSERT, n); /* no need to rehash, add item */ + /* xctx->prep_hash_inst=0; */ if(draw_sym & 3) bbox(ADD, xctx->inst[n].x1, xctx->inst[n].y1, xctx->inst[n].x2, xctx->inst[n].y2); set_modify(1); if(draw_sym&1) { diff --git a/src/hilight.c b/src/hilight.c index a02e7d05..3af9731d 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -898,31 +898,32 @@ void print_stack(int *stack, int sp) int eval_logic_expr(int inst, int output) { int stack[STACKMAX]; - int i, sp = 0; - char *saveptr = NULL; - char *ptr1; - char *ptr2; - char *arg; + int pos = 0, i, sp = 0; + char *str; int res = 0; - my_strdup(827, &saveptr, xctx->simdata.inst[inst].pin[output].function); - dbg(1, "eval_logic_expr(): inst=%d pin=%d function=%s\n", inst, output, saveptr ? saveptr : "NULL"); - if(!saveptr) return 2; /* no logic function defined, return LOGIC_X */ - ptr2 = saveptr; - while( (arg = my_strtok_r(ptr2, " ", &ptr1)) ) { - ptr2 = NULL; - if(arg[0] == 'd') { /* duplicate top element*/ + str = xctx->simdata.inst[inst].pin[output].function; + dbg(1, "eval_logic_expr(): inst=%d pin=%d function=%s\n", inst, output, str ? str : "NULL"); + if(!str) return 2; /* no logic function defined, return LOGIC_X */ + while(str[pos]) { + if(str[pos] == 'd') { /* duplicate top element*/ if(sp > 0 && sp < STACKMAX) { stack[sp] = stack[sp - 1]; sp++; } - } else if(arg[0] == '~') { /* negation operator */ + } else if(str[pos] == 'x') { /* exchange top 2 operands */ + if(sp > 1) { + int tmp = stack[sp - 2]; + stack[sp - 2] = stack[sp - 1]; + stack[sp - 1] = tmp; + } + } else if(str[pos] == '~') { /* negation operator */ if(sp > 0) { sp--; if(stack[sp] != 2) stack[sp] = !stack[sp]; ++sp; } - } else if(arg[0] == '|') { /* or operator */ + } else if(str[pos] == '|') { /* or operator */ if(sp > 1) { res = 0; for(i = sp - 2; i < sp; i++) { @@ -936,7 +937,7 @@ int eval_logic_expr(int inst, int output) stack[sp - 2] = res; sp--; } - } else if(arg[0] == '&') { /* and operator */ + } else if(str[pos] == '&') { /* and operator */ if(sp > 1) { res = 1; for(i = sp - 2; i < sp; i++) { @@ -950,7 +951,7 @@ int eval_logic_expr(int inst, int output) stack[sp - 2] = res; sp--; } - } else if(arg[0] == '^') { /* xor operator */ + } else if(str[pos] == '^') { /* xor operator */ if(sp > 1) { res = 0; for(i = sp - 2; i < sp; i++) { @@ -965,22 +966,25 @@ int eval_logic_expr(int inst, int output) stack[sp - 2] = res; sp--; } - } else if(arg[0] == 'L') { /* logic low (0) */ + } else if(str[pos] == 'L') { /* logic low (0) */ if(sp < STACKMAX) { stack[sp++] = 0; } - } else if(arg[0] == 'H') { /* logic high (1) */ + } else if(str[pos] == 'H') { /* logic high (1) */ if(sp < STACKMAX) { stack[sp++] = 1; } - } else if(isdigit(arg[0])) { + } else if(isdigit(str[pos])) { if(sp < STACKMAX) { - stack[sp++] = get_logic_value(inst, atoi(arg)); + char *num = str + pos; + while(isdigit(str[++pos])) ; + pos--; /* push back last non digit character */ + stack[sp++] = get_logic_value(inst, atoi(num)); } else dbg(0, "eval_logic_expr(): stack overflow!\n"); } + pos++; } - my_free(1218, &saveptr); dbg(1, "eval_logic_expr(): inst %d output %d, returning %d\n", inst, output, stack[0]); return stack[0]; } diff --git a/xschem_library/rom8k/lvnand2.sym b/xschem_library/rom8k/lvnand2.sym index 59bf231c..819869d1 100644 --- a/xschem_library/rom8k/lvnand2.sym +++ b/xschem_library/rom8k/lvnand2.sym @@ -1,5 +1,7 @@ -v {xschem version=2.9.5_RC6 file_version=1.1} -G {type=subcircuit +v {xschem version=2.9.9 file_version=1.2 } +G {} +K {type=subcircuit +function0="1 2 & ~" vhdl_stop=true verilog_stop=true format="@name @pinlist @VCCPIN @VSSPIN @symname wna=@wna lna=@lna wpa=@wpa lpa=@lpa wnb=@wnb lnb=@lnb wpb=@wpb lpb=@lpb m=@m" @@ -38,8 +40,8 @@ L 4 22.5 -22.5 30 -15 {} L 4 30 -15 33.75 -7.5 {} L 4 33.75 -7.5 35 0 {} B 5 57.5 -2.5 62.5 2.5 {name=y dir=out verilog_type=wire} -B 5 -42.5 -22.5 -37.5 -17.5 {name=a dir=in} -B 5 -42.5 17.5 -37.5 22.5 {name=b dir=in} +B 5 -42.5 -22.5 -37.5 -17.5 {name=a dir=in goto=0} +B 5 -42.5 17.5 -37.5 22.5 {name=b dir=in goto=0} T {na:@wna\\/@lna nb:@wnb\\/@lnb} -35 65 2 1 0.2 0.2 {} T {pa:@wpa\\/@lpa diff --git a/xschem_library/rom8k/lvnot.sym b/xschem_library/rom8k/lvnot.sym index 9f394630..bd5c6ff7 100644 --- a/xschem_library/rom8k/lvnot.sym +++ b/xschem_library/rom8k/lvnot.sym @@ -1,5 +1,7 @@ -v {xschem version=2.9.7 file_version=1.2} -G {type=subcircuit +v {xschem version=2.9.9 file_version=1.2 } +G {} +K {type=subcircuit +function0="1 ~" vhdl_stop=true verilog_stop=true format="@name @pinlist @VCCPIN @VSSPIN @symname wn=@wn lln=@lln wp=@wp lp=@lp m=@m" @@ -26,7 +28,7 @@ L 4 18.75 5 23.75 5 {} L 4 16.25 2.5 18.75 5 {} L 4 26.25 0 40 0 {} B 5 37.5 -2.5 42.5 2.5 {name=y dir=out verilog_type=wire} -B 5 -42.5 -2.5 -37.5 2.5 {name=a dir=in} +B 5 -42.5 -2.5 -37.5 2.5 {name=a dir=in goto=0} T {n:@wn\\/@lln} -35 35 2 1 0.2 0.2 {} T {p:@wp\\/@lp} -35 -22.5 2 1 0.2 0.2 {} T {@name} -26.25 -5 0 0 0.2 0.2 {}