diff --git a/examples/p-to-n-examples/counter.cir b/examples/p-to-n-examples/counter.cir new file mode 100644 index 000000000..936a7973b --- /dev/null +++ b/examples/p-to-n-examples/counter.cir @@ -0,0 +1,57 @@ +counter.cir + +.subckt counter high clear clk qa qb qc qd 5 7 9 11 +U1 JKFF(1) $G_DPWR $G_DGND HIGH CLEAR CLK HIGH HIGH QA 5 ++ D0_EFF IO_STD IO_LEVEL=0 MNTYMXDLY=2 +U2 JKFF(1) $G_DPWR $G_DGND HIGH CLEAR QA HIGH HIGH QB 7 ++ D0_EFF IO_STD IO_LEVEL=0 MNTYMXDLY=2 +U3 JKFF(1) $G_DPWR $G_DGND HIGH CLEAR QB HIGH HIGH QC 9 ++ D0_EFF IO_STD IO_LEVEL=0 MNTYMXDLY=2 +U4 JKFF(1) $G_DPWR $G_DGND HIGH CLEAR QC HIGH HIGH QD 11 ++ D0_EFF IO_STD IO_LEVEL=0 MNTYMXDLY=2 +.MODEL D0_EFF UEFF () +.ends counter + +*** input sources *** +vclk 100 0 pulse( 0.0 1.0 50ns 0ns 0ns 50ns 100ns ) +vreset 200 0 pulse( 1.0 0.0 10ns 0ns 0ns 50ns ) +vhigh 300 0 DC 1.0 + +*** adc_bridge blocks *** +aconverter [100 200 300] [clock clr hi] adc_bridge1 +.model adc_bridge1 adc_bridge (in_low=0.1 in_high=0.9 ++ rise_delay=1.0e-12 fall_delay=1.0e-12) + +*** resistors to ground *** +r1 100 0 1k +r2 200 0 1k +r3 300 0 1k + +x1 hi clr clock q1 q2 q3 q4 q1b q2b q3b q4b counter + +*.TRAN 1e-008 4u 0 +.save all + +.control +TRAN 1e-008 4u 0 +run +listing +display +edisplay +*eprint hi clr clock q1 q2 q3 q4 +* save data to input directory +cd $inputdir +eprvcd hi clr clock q1 q2 q3 q4 > counter.vcd +* plotting the vcd file with GTKWave +if $oscompiled = 1 | $oscompiled = 8 ; MS Windows + shell start gtkwave counter.vcd --script nggtk.tcl +else + if $oscompiled = 7 ; macOS, manual tweaking required (mark, insert, Zoom Fit) + shell open -a gtkwave counter.vcd + else ; Linux and others + shell gtkwave counter.vcd --script nggtk.tcl & + end +end +quit +.endc +.END diff --git a/examples/p-to-n-examples/nggtk.tcl b/examples/p-to-n-examples/nggtk.tcl new file mode 100644 index 000000000..a8669f6f8 --- /dev/null +++ b/examples/p-to-n-examples/nggtk.tcl @@ -0,0 +1,10 @@ +# tcl script for gtkwave: show vcd file data created by ngspice +set nfacs [ gtkwave::getNumFacs ] + +for {set i 0} {$i < $nfacs } {incr i} { + set facname [ gtkwave::getFacName $i ] + set num_added [ gtkwave::addSignalsFromList $facname ] +} + +gtkwave::/Edit/UnHighlight_All +gtkwave::/Time/Zoom/Zoom_Full diff --git a/src/frontend/udevices.c b/src/frontend/udevices.c index ada02dd47..7d178649e 100644 --- a/src/frontend/udevices.c +++ b/src/frontend/udevices.c @@ -1455,9 +1455,19 @@ static Xlatorp gen_dff_instance(struct dff_instance *ip) darr = ip->d_in; qarr = ip->q_out; qbarr = ip->qb_out; - xxp = create_xlator(); - preb = ip->prebar; + clrb = ip->clrbar; + for (i = 0; i < num_gates; i++) { + if (strncmp(darr[i], "$d_", 3) == 0) { return NULL; } + } + if (strcmp(preb, "$d_lo") == 0 || strcmp(preb, "$d_nc") == 0) { + return NULL; + } + if (strcmp(clrb, "$d_lo") == 0 || strcmp(clrb, "$d_nc") == 0) { + return NULL; + } + + xxp = create_xlator(); add_input_pin(preb); if (strcmp(preb, "$d_hi") == 0) { preb = "NULL"; @@ -1466,7 +1476,6 @@ static Xlatorp gen_dff_instance(struct dff_instance *ip) preb = new_inverter(iname, preb, xxp); } - clrb = ip->clrbar; add_input_pin(clrb); if (strcmp(clrb, "$d_hi") == 0) { clrb = "NULL"; @@ -1512,7 +1521,6 @@ static Xlatorp gen_dff_instance(struct dff_instance *ip) tfree(modelnm); return xxp; - return NULL; } static Xlatorp gen_jkff_instance(struct jkff_instance *ip) @@ -1533,9 +1541,20 @@ static Xlatorp gen_jkff_instance(struct jkff_instance *ip) karr = ip->k_in; qarr = ip->q_out; qbarr = ip->qb_out; - xxp = create_xlator(); - preb = ip->prebar; + clrb = ip->clrbar; + for (i = 0; i < num_gates; i++) { + if (strncmp(jarr[i], "$d_", 3) == 0) { return NULL; } + if (strncmp(karr[i], "$d_", 3) == 0) { return NULL; } + } + if (strcmp(preb, "$d_lo") == 0 || strcmp(preb, "$d_nc") == 0) { + return NULL; + } + if (strcmp(clrb, "$d_lo") == 0 || strcmp(clrb, "$d_nc") == 0) { + return NULL; + } + + xxp = create_xlator(); add_input_pin(preb); if (strcmp(preb, "$d_hi") == 0) { preb = "NULL"; @@ -1544,7 +1563,6 @@ static Xlatorp gen_jkff_instance(struct jkff_instance *ip) preb = new_inverter(iname, preb, xxp); } - clrb = ip->clrbar; add_input_pin(clrb); if (strcmp(clrb, "$d_hi") == 0) { clrb = "NULL"; @@ -1612,8 +1630,19 @@ static Xlatorp gen_dltch_instance(struct dltch_instance *ip) darr = ip->d_in; qarr = ip->q_out; qbarr = ip->qb_out; - xxp = create_xlator(); preb = ip->prebar; + clrb = ip->clrbar; + for (i = 0; i < num_gates; i++) { + if (strncmp(darr[i], "$d_", 3) == 0) { return NULL; } + } + if (strcmp(preb, "$d_lo") == 0 || strcmp(preb, "$d_nc") == 0) { + return NULL; + } + if (strcmp(clrb, "$d_lo") == 0 || strcmp(clrb, "$d_nc") == 0) { + return NULL; + } + + xxp = create_xlator(); add_input_pin(preb); if (strcmp(preb, "$d_hi") == 0) { preb = "NULL"; @@ -1622,7 +1651,6 @@ static Xlatorp gen_dltch_instance(struct dltch_instance *ip) preb = new_inverter(iname, preb, xxp); } - clrb = ip->clrbar; add_input_pin(clrb); if (strcmp(clrb, "$d_hi") == 0) { clrb = "NULL"; @@ -3048,7 +3076,6 @@ BOOL u_process_instance(char *nline) char *p1, *itype, *xspice; struct instance_hdr *hdr = create_instance_header(nline); Xlatorp xp = NULL; - BOOL retval = TRUE; itype = hdr->instance_type; xspice = find_xspice_for_delay(itype); @@ -3072,7 +3099,7 @@ BOOL u_process_instance(char *nline) xp = translate_pull(hdr, p1); } else { delete_instance_hdr(hdr); - retval = FALSE; + return FALSE; } if (xp) { append_xlator(translated_p, xp); @@ -3080,8 +3107,10 @@ BOOL u_process_instance(char *nline) interpret_xlator(xp, TRUE); #endif delete_xlator(xp); + return TRUE; + } else { + return FALSE; } - return retval; } BOOL u_process_model_line(char *line)