From b0e9874de8d8fb77f3b225435f9400ac1bc7c913 Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Tue, 8 Nov 2022 12:09:13 -0800 Subject: [PATCH] Add more vectors to behavioral 283 circuit. Add tristate buffer circuit which shows glitches until inertial delays are implemented. --- examples/p-to-n-examples/behav-283-1.cir | 91 +++++++++++++++++++ examples/p-to-n-examples/behav-283-1.stim | 39 ++++++++ .../p-to-n-examples/behav-tristate-pulse.cir | 82 +++++++++++++++++ .../p-to-n-examples/behav-tristate-pulse.stim | 30 ++++++ src/frontend/logicexp.c | 10 +- 5 files changed, 248 insertions(+), 4 deletions(-) create mode 100644 examples/p-to-n-examples/behav-283-1.cir create mode 100644 examples/p-to-n-examples/behav-283-1.stim create mode 100644 examples/p-to-n-examples/behav-tristate-pulse.cir create mode 100644 examples/p-to-n-examples/behav-tristate-pulse.stim diff --git a/examples/p-to-n-examples/behav-283-1.cir b/examples/p-to-n-examples/behav-283-1.cir new file mode 100644 index 000000000..7618f70bd --- /dev/null +++ b/examples/p-to-n-examples/behav-283-1.cir @@ -0,0 +1,91 @@ +Behavioral CMOS 283 : 4-bit adder with behav-283-1.stim + +*-------------------------------------------------------------74AC283----- +* +* The 74AC283 4-Bit Binary Full Adder with Fast Carry +* (4 Page Fax) Harris Advanced CMOS Logic, File Number 1912 +* and Philips Semiconductors High-speed CMOS Logic Data Handbook +* for the logic diagram, 1994, page 564 +* jat 7/26/95 + +.SUBCKT 74AC283 ++ A0 A1 A2 A3 B0 B1 B2 B3 CIN COUT S0 S1 S2 S3 ++ OPTIONAL: DPWR=$G_DPWR DGND=$G_DGND ++ PARAMS: MNTYMXDLY=0 IO_LEVEL=0 + +U1 LOGICEXP(9,5) DPWR DGND ++ A0 A1 A2 A3 B0 B1 B2 B3 CIN ++ S_0 S_1 S_2 S_3 C_OUT ++ D0_GATE IO_AC ++ MNTYMXDLY={MNTYMXDLY} IO_LEVEL={IO_LEVEL} ++ LOGIC: ++ S_0 = {A0 ^ B0 ^ CIN} ++ NOR1 = {(A0 | B0) & (CIN | (A0 & B0))} ++ S_1 = {NOR1 ^ A1 ^ B1} ++ NOR2 = {~((~(A1 | B1)) | ((~(A0 | B0)) & (~(A1 & B1))) | ++ ((~(A1 & B1)) & (~(A0 & B0)) & (~CIN)))} ++ S_2 = {NOR2 ^ A2 ^ B2} ++ AND31 = {(~(A2 & B2)) & (~(A1 & B1)) & (~(A0 & B0)) & (~CIN)} ++ AND32 = {(~(A0 | B0)) & (~(A2 & B2)) & (~(A1 & B1))} ++ AND33 = {(~(A1 | B1)) & (~(A2 & B2))} ++ NOR3 = {~(AND31 | AND32 | AND33 | (~(A2 | B2)))} ++ S_3 = {NOR3 ^ A3 ^ B3} ++ ANDC1 = {(~(A3 & B3)) & (~(A2 & B2)) & (~(A1 & B1)) & ++ (~(A0 & B0)) & (~CIN)} ++ ANDC2 = {(~(A0 | B0)) & (~(A3 & B3)) & (~(A2 & B2)) & (~(A1 & B1))} ++ ANDC3 = {(~(A1 | B1)) & (~(A3 & B3)) & (~(A2 & B2))} ++ ANDC4 = {(~(A2 | B2)) & (~(A3 & B3))} ++ C_OUT = {~(ANDC1 | ANDC2 | ANDC3 | ANDC4 | (~(A3 | B3)))} + +U2 PINDLY(5,0,9) DPWR DGND ++ S_0 S_1 S_2 S_3 C_OUT ++ A0 A1 A2 A3 B0 B1 B2 B3 CIN ++ S0 S1 S2 S3 COUT ++ IO_AC ++ MNTYMXDLY={MNTYMXDLY} IO_LEVEL={IO_LEVEL} ++ BOOLEAN: ++ CARRYIN = {CHANGED(CIN,0)} ++ NUMBER = {CHANGED(A0,0) | CHANGED(A1,0) | CHANGED(A2,0) | ++ CHANGED(A3,0) | CHANGED(B0,0) | CHANGED(B1,0) | ++ CHANGED(B2,0) | CHANGED(B3,0)} ++ PINDLY: ++ S0 S1 S2 S3 = { ++ CASE( ++ NUMBER & (TRN_LH | TRN_HL), DELAY(4.7NS,-1,16.5NS), ++ CARRYIN & (TRN_LH | TRN_HL), DELAY(4.5NS,-1,16NS), ++ DELAY(5.7NS,-1,17.5NS))} ++ COUT = { ++ CASE( ++ NUMBER & (TRN_LH | TRN_HL), DELAY(4.5NS,-1,16NS), ++ CARRYIN & (TRN_LH | TRN_HL), DELAY(4.5NS,-1,16NS), ++ DELAY(5.7NS,-1,17.5NS))} + +.ENDS 74AC283 + +X1 a0 a1 a2 a3 b0 b1 b2 b3 cin cout s0 s1 s2 s3 74ac283 +a_1 [ a3 a2 a1 a0 b3 b2 b1 b0 cin ] input_vec1 +.model input_vec1 d_source(input_file = "behav-283-1.stim") + +.tran 0.01ns 4us +.control +run +listing +edisplay +eprint a3 a2 a1 a0 b3 b2 b1 b0 cin +eprint s3 s2 s1 s0 cout +* save data to input directory +cd $inputdir +eprvcd a3 a2 a1 a0 b3 b2 b1 b0 cin s3 s2 s1 s0 cout > behav-283-1.vcd +* plotting the vcd file with GTKWave +if $oscompiled = 1 | $oscompiled = 8 ; MS Windows + shell start gtkwave behav-283-1.vcd --script nggtk.tcl +else + if $oscompiled = 7 ; macOS, manual tweaking required (mark, insert, Zoom Fit) + shell open -a gtkwave behav-283-1.vcd + else ; Linux and others + shell gtkwave behav-283-1.vcd --script nggtk.tcl & + end +end +quit +.endc +.end diff --git a/examples/p-to-n-examples/behav-283-1.stim b/examples/p-to-n-examples/behav-283-1.stim new file mode 100644 index 000000000..2ab1bdea6 --- /dev/null +++ b/examples/p-to-n-examples/behav-283-1.stim @@ -0,0 +1,39 @@ +* T a a a a b b b b c +* i 0 1 2 3 0 1 2 3 i +* m n +* e + +0ns 0s 0s 0s 0s 0s 0s 0s 0s 0s +100ns 0s 0s 0s 1s 0s 0s 0s 1s 0s +200ns 0s 0s 1s 0s 0s 0s 1s 0s 0s +300ns 0s 0s 1s 1s 0s 0s 1s 1s 0s +400ns 0s 1s 0s 0s 0s 1s 0s 0s 0s +500ns 0s 1s 0s 1s 0s 1s 0s 1s 0s +600ns 0s 1s 1s 0s 0s 1s 1s 0s 0s +700ns 0s 1s 1s 1s 0s 1s 1s 1s 0s +800ns 1s 0s 0s 0s 1s 0s 0s 0s 0s +900ns 1s 0s 0s 1s 1s 0s 0s 1s 0s +1.0us 1s 0s 1s 0s 1s 0s 1s 0s 0s +1.1us 1s 0s 1s 1s 1s 0s 1s 1s 0s +1.2us 1s 1s 0s 0s 1s 1s 0s 0s 0s +1.3us 1s 1s 0s 1s 1s 1s 0s 1s 0s +1.4us 1s 1s 1s 0s 1s 1s 1s 0s 0s +1.5us 1s 1s 1s 1s 1s 1s 1s 1s 0s +1.6us 0s 0s 0s 0s 0s 0s 0s 0s 0s +1.7us 0s 0s 0s 0s 0s 0s 0s 0s 1s +1.8us 0s 0s 0s 1s 0s 0s 0s 1s 1s +1.9us 0s 0s 1s 0s 0s 0s 1s 0s 1s +2.0us 0s 0s 1s 1s 0s 0s 1s 1s 1s +2.1us 0s 1s 0s 0s 0s 1s 0s 0s 1s +2.2us 0s 1s 0s 1s 0s 1s 0s 1s 1s +2.3us 0s 1s 1s 0s 0s 1s 1s 0s 1s +2.4us 0s 1s 1s 1s 0s 1s 1s 1s 1s +2.5us 1s 0s 0s 0s 1s 0s 0s 0s 1s +2.6us 1s 0s 0s 1s 1s 0s 0s 1s 1s +2.7us 1s 0s 1s 0s 1s 0s 1s 0s 1s +2.8us 1s 0s 1s 1s 1s 0s 1s 1s 1s +2.9us 1s 1s 0s 0s 1s 1s 0s 0s 1s +3.0us 1s 1s 0s 1s 1s 1s 0s 1s 1s +3.1us 1s 1s 1s 0s 1s 1s 1s 0s 1s +3.2us 1s 1s 1s 1s 1s 1s 1s 1s 1s +3.3us 0s 0s 0s 0s 0s 0s 0s 0s 1s diff --git a/examples/p-to-n-examples/behav-tristate-pulse.cir b/examples/p-to-n-examples/behav-tristate-pulse.cir new file mode 100644 index 000000000..3d08f6fd7 --- /dev/null +++ b/examples/p-to-n-examples/behav-tristate-pulse.cir @@ -0,0 +1,82 @@ +Test behav-tristate.cir + +* -----------------------------------------------------------74HCT125------ +*** This is not quad +* Quad Buffer/Line Driver; Tri-State +* Philips High Speed CMOS Logic Family, 1994, pages 243 to 247 +* jat 9/4/96 + +.SUBCKT 74HCT125 1A 1Y 1OEBAR ++ OPTIONAL: DPWR=$G_DPWR DGND=$G_DGND ++ PARAMS: MNTYMXDLY=0 IO_LEVEL=0 + +U1 PINDLY(1,1,0) DPWR DGND ++ 1A ++ 1OEBAR ++ 1Y ++ IO_HCT MNTYMXDLY={MNTYMXDLY} IO_LEVEL={IO_LEVEL} ++ TRISTATE: ++ ENABLE LO = 1OEBAR ++ 1Y = { ++ CASE( ++ TRN_Z$,DELAY(-1,15NS,28NS), ++ TRN_$Z, DELAY(-1,15NS,25NS), ++ (TRN_LH | TRN_HL), DELAY(-1,15NS,25NS), ++ DELAY(-1,16NS,29NS))} + +.ENDS 74HCT125 +* -----------------------------------------------------------74HC126A------ +*** This is not quad +* Quad Tri-State Noninverting Buffers +* Motorola High-Speed CMOS Data, 1993, pages 5-106 to 5-109 +* jat 9/4/96 + +.SUBCKT 74HC126A A1 Y1 OE1 ++ OPTIONAL: DPWR=$G_DPWR DGND=$G_DGND ++ PARAMS: MNTYMXDLY=0 IO_LEVEL=0 + +U1 PINDLY(1,1,0) DPWR DGND ++ A1 ++ OE1 ++ Y1 ++ IO_HC MNTYMXDLY={MNTYMXDLY} IO_LEVEL={IO_LEVEL} ++ TRISTATE: ++ ENABLE HI = OE1 ++ Y1 = { ++ CASE( ++ TRN_Z$,DELAY(-1,-1,18NS), ++ TRN_$Z, DELAY(-1,-1,24NS), ++ (TRN_LH | TRN_HL), DELAY(-1,-1,18NS), ++ DELAY(-1,-1,25NS))} + +.ENDS 74HC126A + +* .SUBCKT 74HCT125 1A 1Y 1OEBAR +x1 1a 1y oebar 74hct125 +* .SUBCKT 74HC126A A1 Y1 OE1 +x2 a1 y1 oe 74hc126a +a_1 [ 1a oebar a1 oe ] input_vec1 +.model input_vec1 d_source(input_file = "behav-tristate-pulse.stim") + +.tran 0.01ns 1us +.control +run +listing +edisplay +eprint 1a oebar 1y a1 oe y1 +* save data to input directory +cd $inputdir +eprvcd 1a 1y oebar a1 y1 oe > behav-tristate-pulse.vcd +* plotting the vcd file with GTKWave +if $oscompiled = 1 | $oscompiled = 8 ; MS Windows + shell start gtkwave behav-tristate-pulse.vcd --script nggtk.tcl +else + if $oscompiled = 7 ; macOS, manual tweaking required (mark, insert, Zoom Fit) + shell open -a gtkwave behav-tristate-pulse.vcd + else ; Linux and others + shell gtkwave behav-tristate-pulse.vcd --script nggtk.tcl & + end +end +quit +.endc +.end diff --git a/examples/p-to-n-examples/behav-tristate-pulse.stim b/examples/p-to-n-examples/behav-tristate-pulse.stim new file mode 100644 index 000000000..87ef9aa84 --- /dev/null +++ b/examples/p-to-n-examples/behav-tristate-pulse.stim @@ -0,0 +1,30 @@ +* T 1 o a o +* i a e 1 e +* m b +* e a +* r + +0ns 1s 1s 1s 0s +100ns 1s 0s 1s 1s +152ns 0s 0s 0s 1s +154ns 1s 0s 1s 1s +156ns 0s 0s 0s 1s +158ns 1s 0s 1s 1s +160ns 0s 0s 0s 1s +200ns 0s 0s 0s 1s +300ns 0s 1s 0s 0s +400ns 1s 1s 1s 0s +500ns 1s 0s 1s 1s +600ns 0s 0s 0s 1s +650ns 1s 0s 1s 1s +652ns 0s 0s 0s 1s +654ns 1s 0s 1s 1s +656ns 0s 0s 0s 1s +658ns 1s 0s 1s 1s +660ns 0s 0s 0s 1s +700ns 1s 0s 1s 1s +750ns 0s 0s 0s 1s +752ns 1s 0s 1s 1s +754ns 0s 0s 0s 1s +758ns 1s 0s 1s 1s +850ns 0s 0s 0s 1s diff --git a/src/frontend/logicexp.c b/src/frontend/logicexp.c index 770ca0945..4c142b1f6 100644 --- a/src/frontend/logicexp.c +++ b/src/frontend/logicexp.c @@ -553,13 +553,15 @@ static TLINE tab_find(PTABLE pt, char *str, BOOL start_of_line) return NULL; } -#ifdef TABLE_PRINT -static void table_print(TLINE first) +//#define PTABLE_PRINT +#ifdef PTABLE_PRINT +static void ptable_print(PTABLE pt) { TLINE t; - if (!first) + if (!pt) return; - t = first; + t = pt->first; + printf("num_entries %u\n", pt->num_entries); while (t) { printf("%s\n", t->line); t = t->next;