Wednesday, March 04, 2015

LTspice Behavioural AND Gate

For that day when you're finally fed up with the one they've provided that's causing you to pull your hair out..

How : save the first file as mdl_and.asc. Save the second as mdl_and.asy in your working directory - that is, wherever you have the testbench you're going to simulate - so you can use this..

NOTE - if you're familiar with LTspice files, you should know that stuff displayed below maybe wrapped - that is lines that should all be on one "line" are displayed using 2.. Generally, all lines begin with a directive that's ALL CAPs.



---------------------------------------- first file (don't copy this line)
Version 4
SHEET 1 1392 680
WIRE 864 0 752 0
WIRE 752 16 752 0
WIRE 480 32 368 32
WIRE 624 32 560 32
WIRE 704 32 624 32
WIRE 368 96 368 32
WIRE 608 128 592 128
WIRE 624 128 624 96
WIRE 624 128 608 128
WIRE 704 128 704 80
WIRE 704 128 624 128
WIRE 752 128 752 96
WIRE 752 128 704 128
WIRE 160 160 112 160
WIRE 160 224 112 224
WIRE 992 224 864 224
WIRE 624 240 496 240
WIRE 736 240 704 240
WIRE 816 240 736 240
WIRE 864 240 864 224
WIRE 816 256 816 240
WIRE 496 272 496 240
WIRE 160 288 112 288
WIRE 736 320 736 304
WIRE 816 320 816 304
WIRE 816 320 736 320
WIRE 864 320 816 320
WIRE 720 336 704 336
WIRE 736 336 736 320
WIRE 736 336 720 336
WIRE 368 416 368 176
WIRE 368 416 112 416
WIRE 496 416 496 352
WIRE 496 416 368 416
FLAG 112 160 a
IOPIN 112 160 In
FLAG 112 224 b
IOPIN 112 224 In
FLAG 112 288 c
IOPIN 112 288 In
FLAG 112 416 g
IOPIN 112 416 In
FLAG 864 0 Q
IOPIN 864 0 Out
FLAG 992 224 Qb
IOPIN 992 224 Out
FLAG 608 128 g
FLAG 720 336 g
SYMBOL bv 368 80 R0
SYMATTR InstName B1
SYMATTR Value V=if( (V(a,g) > Vth) & (V(b,g) > Vth) & (V(c,g) > Vth) , Vhigh, Vlow )
SYMBOL bv 496 256 R0
SYMATTR InstName B2
SYMATTR Value V=if( !((V(a,g) > Vth) & (V(b,g) > Vth) & (V(c,g) > Vth)) , Vhigh, Vlow )
SYMBOL res 576 16 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R1
SYMATTR Value 1000
SYMBOL res 720 224 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 1000
SYMBOL cap 608 32 R0
SYMATTR InstName C1
SYMATTR Value 1p
SYMBOL cap 720 240 R0
SYMATTR InstName C2
SYMATTR Value 1p
SYMBOL e 864 224 R0
SYMATTR InstName E1
SYMATTR Value 1
SYMBOL e 752 0 R0
SYMATTR InstName E2
SYMATTR Value 1
TEXT 952 0 Left 2 ;params : \nVth : input transition threshold\nVhigh : output high level\nVlow : output low level
---------------------------------------- end first file (don't copy this line)
Version 4
SymbolType BLOCK
LINE Normal -32 32 -12 32
LINE Normal -32 96 -12 96
LINE Normal -32 96 -32 32
LINE Normal 16 48 32 48
CIRCLE Normal 32 88 16 72
ARC Normal -44 96 20 32 -12 96 -12 32
WINDOW 0 16 24 Left 2
WINDOW 3 16 112 Left 2
SYMATTR Description Custom behavioural AND gate
SYMATTR SpiceLine Vth=1.5 Vhigh=3.0 Vlow=0
PIN -32 48 NONE 0
PINATTR PinName a
PINATTR SpiceOrder 1
PIN -32 64 NONE 0
PINATTR PinName b
PINATTR SpiceOrder 2
PIN -32 80 NONE 0
PINATTR PinName c
PINATTR SpiceOrder 3
PIN 32 80 NONE 0
PINATTR PinName Qb
PINATTR SpiceOrder 4
PIN 32 48 NONE 0
PINATTR PinName Q
PINATTR SpiceOrder 5
PIN -16 96 NONE 0
PINATTR PinName g
PINATTR SpiceOrder 6
---------------------------------------- end second file (don't copy this line)

No comments: