Professional Documents
Culture Documents
2011 by D. G. Meyer
ECE 270
2011 by D. G. Meyer
hardware description language o an HDL is a logic programming language (caution: not sequential in nature like a computer programming language, but rather a means of describing hardware design) o we will use the Advanced Boolean Expression Language (ABEL) as an introductory hardware description language o we will compile our ABEL programs using ispLever (software tool available from Lattice Semiconductor go to website to download trial version) ABEL o program contents documentation (e.g., comments) declarations of pins, inputs, outputs statements that specify logic functions (optionally) test vectors o program structure identifiers Module statement comments pin declarations, istype keyword Equations statement equations written like assignments, terminated by a semicolon Truth_Table statement Test_Vectors statement End statement o basic symbols used in formulating ABEL equations & AND # OR ! NOT $ XOR !$ XNOR = assignment
MODULE abel_ex
TITLE 'ABEL Combinational Example for GAL16V8' DECLARATIONS " Input pins A pin 2; B pin 3; C pin 4; D pin 5; " Output pins X pin 12 istype 'com'; Y pin 13 istype 'com'; Z pin 14 istype 'com'; EQUATIONS X = A&B # !C&D; Y = !B&D # !A&B&D; Z = A & !B&C&!D; END
ECE 270
2011 by D. G. Meyer
E
0 4
E
12 8
B
1
A A A C
A
13
B B
T T
D D C R
A A C
15
11
F
10
14
C R
1/4 - 7402
2/3 - 7404
ECE 270
2011 by D. G. Meyer
o n-bit binary input code most common o 1-out-of-m output code most common (note: output code bits are mutually exclusive) o binary decoder: n to 2n (n-bit binary input code, 1-out-of-2n output code) example: generic 3-to-8 decoder (74x138)
key observation #1: each output of an n to 2n binary decoder represents a minterm of an n-variable Boolean function; therefore, any arbitrary Boolen function of n-variables can be implemented with an n-input binary decoder by simply OR-ing the needed outputs key observation #2: if the decoder outputs are active low (e.g., 74x138 example above), a NAND gate can be used to OR the minterms of the function (representing its ON set) key observation #3: if the decoder outputs are active low (e.g., 74x138 example above), an AND gate can be used to OR the minterms of the complement function (representing its OFF set) key observation #4: a NAND gate (or AND gate) with at most 2n-1 inputs is needed to implement an arbitrary n-variable function using an n to 2n binary decoder (that has active low outputs, e.g., a 74x138) 4
ECE 270
2011 by D. G. Meyer
general circuit for implementing an arbitrary n-variable function using a decoder, for case where ON set has 2n-1 members
VCC
Z Y X
1 2 3 6 4 5
A B C G1 G2AN G2BN
Y 0N Y 1N Y 2N Y 3N Y 4N Y 5N Y 6N Y 7N
15 14 13 12 11 10 9 7
F(X,Y,Z)
question: how does circuit change if ON set has < 2n-1 members question: how does circuit change if ON set has > 2n-1 members? 16V8 realization of 74x138
MODULE dec138 TITLE '74x138 decoder implemented using 16V8' DECLARATIONS " Enable input pins G1 pin 1; !G2A pin 2; !G2B pin 3; " Select input pins C, B, A pin 4, 5, 6; " Output pins !Y0, !Y1, !Y2, !Y3, !Y4, !Y5, !Y6, !Y7 pin 19..12 istype 'com'; " Intermediate equation EN = G1 & G2A & G2B; EQUATIONS Y0 = EN & Y1 = EN & Y2 = EN & Y3 = EN & Y4 = EN & Y5 = EN & Y6 = EN & Y7 = EN & END
!C !C !C !C C C C C
!B !B B B !B !B B B
ECE 270
2011 by D. G. Meyer
GS pin istype 'com'; "strobe output (asserted if any input asserted) " Short-hand for don't care X = .X.; TRUTH_TABLE ([I7,I6,I5,I4,I3,I2,I1,I0]->[E2,E1,E0,GS]) [ 0, 0, 0, 0, 0, 0, 0, 0]->[ 0, 0, 0, 0]; [ 0, 0, 0, 0, 0, 0, 0, 1]->[ 0, 0, 0, 1]; [ 0, 0, 0, 0, 0, 0, 1, X]->[ 0, 0, 1, 1]; [ 0, 0, 0, 0, 0, 1, X, X]->[ 0, 1, 0, 1]; [ 0, 0, 0, 0, 1, X, X, X]->[ 0, 1, 1, 1]; [ 0, 0, 0, 1, X, X, X, X]->[ 1, 0, 0, 1]; [ 0, 0, 1, X, X, X, X, X]->[ 1, 0, 1, 1]; [ 0, 1, X, X, X, X, X, X]->[ 1, 1, 0, 1]; [ 1, X, X, X, X, X, X, X]->[ 1, 1, 1, 1]; END
none active input 0 wins input 1 wins input 2 wins input 3 wins input 4 wins input 5 wins input 6 wins input 7 wins
ABEL-isms to note in this example: the dont care symbol ( .X. ), and how to define a substitute symbol (here, X); also note use of ranges to define the input and output pins. 6
ECE 270
2011 by D. G. Meyer
Title: 8-to-3 Priority Encoder Using 16V8 P-Terms --------4/4 4/3 4/1 8/1 ========= 20/9 Fan-in -----7 6 4 8 Fan-out ------1 1 1 1 Type ---Pin Pin Pin Pin Name (attributes) ----------------E0 E1 E2 GS 9 12 0 2
Equations: E0 = (!I6 & !I4 & !I2 & I1 # !I6 & !I4 & I3 # !I6 & I5 # I7); E1 = (!I5 & !I4 & I2 # !I5 & !I4 & I3 # I6 # I7); E2 = (I4 # I5 # I6 # I7); GS = (I1 # I0 # I2 # I3 # I4 # I5 # I6 # I7); Reverse-Polarity Equations: !E0 = (!I7 & !I5 & !I3 & !I1 # !I7 & !I5 & !I3 & I2 # !I7 & !I5 & I4 # !I7 & I6); !E1 = (!I7 & !I6 & !I3 & !I2 # !I7 & !I6 & I4 # !I7 & !I6 & I5); !E2 = (!I7 & !I6 & !I5 & !I4); !GS = (!I7 & !I6 & !I5 & !I4 & !I3 & !I2 & !I1 & !I0);
example MSI encoder chip: 74x148 o similar to generic example (above), except all inputs and outputs are active low has EI input and EO output to facilitate daisy chaining multiple 148 chips 10-key pushbutton pad encoder (10:4) straight-forward extension of generic 8:3 encoder consider a different (4:2) priority encoder (CQ #2)
MODULE diff_pri TITLE 'Different Priority Encoder' DECLARATIONS A,B,C,D pin; E0..E1 pin istype 'com'; GS pin istype 'com'; X = .X.; TRUTH_TABLE ([ A, B, C, D]->[E1,E0,GS]) [ 0, 0, 0, 0]->[ 0, 0, 0]; [ 0, 0, 0, 1]->[ 1, 1, 1]; [ 0, 0, 1, X]->[ 1, 0, 1]; [ 0, 1, X, X]->[ 0, 1, 1]; [ 1, X, X, X]->[ 0, 0, 1]; END
ECE 270
2011 by D. G. Meyer
o party line example note need for dead time to ensure that no bus fights occur
ECE 270
2011 by D. G. Meyer
bus o defn collection of signals with a common purpose shared among multiple entities example: address or data bus in a computer can be uni-directional or bi-directional o a bus transceiver contains pairs of buffers connected in opposite directions o examples: address bus and data bus in a computer
tri-state buffers in ABEL o attribute suffix .OE is used to denote the enable input for a tri-state buffer that outputs the named signal (signal.OE) o example 4:2 priority encoder with tri-state output control
MODULE TITLE prienc42 '4-to-2 Priority Encoder with Tri-State Enable'
DECLARATIONS " Input pins I0..I3 pin; " Input 0 - lowest priority, Input 3 - highest " Output pins E0..E1 pin istype 'com'; " E1 E0 - encoded output GS pin istype 'com'; " strobe output (asserted if any input asserted) EN pin; " tri-state enable control input " Short-hand for don't care X = .X.; TRUTH_TABLE ([I3,I2,I1,I0]->[E1,E0,GS]) [ 0, 0, 0, 0]->[ 0, 0, 0]; [ 0, 0, 0, 1]->[ 0, 0, 1]; [ 0, 0, 1, X]->[ 0, 1, 1]; [ 0, 1, X, X]->[ 1, 0, 1]; [ 1, X, X, X]->[ 1, 1, 1]; EQUATIONS [E0..E1].OE = EN; END
no inputs active input 0 wins input 1 wins input 2 wins input 3 wins
ECE 270
2011 by D. G. Meyer
X Y F(X,Y) 0 0 0 1 1 0 1 1 a0 a1 a2 a3 D0 D1 D2 D3
F(X,Y)
i1 i0
Functional values assigned to each combination
X Y
MODULE mux811 TITLE '8-to-1 Mux (74x151) DECLARATIONS " Data inputs D0..D7 pin 1..8; " Enable EN pin 9; " Select lines S0..S2 pin 11..13; " Outputs Y pin 14 istype com; Y_L pin 15 istype com; EQUATIONS Y = EN & (!S2&!S1&!S0&D0 # !S2&!S1& S0&D1 # !S2& S1&!S0&D2 # !S2& S1& S0&D3 # S2&!S1&!S0&D4 # S2&!S1& S0&D5 # S2& S1&!S0&D6 # S2& S1& S0&D7); Y_L = !Y; END
10
ECE 270
2011 by D. G. Meyer
F(C,B,A)
4 3 2 1 15 14 13 12 11 10 9 7 D0 D1 D2 D3 D4 D5 D6 D7 A B C G W Y 6 5
Determine the switches that should be closed to implement the function F(C,B,A) = CA + C(AB)
de-multiplexer: an inverse multiplexer (essentially the same as a decoder with an enable) multiplexer functionality expressed in ABEL (8-bit wide 4:1 mux example)
MODULE mux418a TITLE '4-to-1 X 8-bit Multiplexer' DECLARATIONS EN pin; " output enable control line S0..S1 pin; " select inputs " 8-bit input buses A0..A7, B0..B7, C0..C7, D0..D7 pin; " 8-bit output bus Y0..Y7 pin istype com; " A B C D Y Sets = [A0..A7]; = [B0..B7]; = [C0..C7]; = [D0..D7]; = [Y0..Y7]; MODULE mux418b TITLE '4-to-1 X 8-bit Multiplexer' DECLARATIONS EN pin; " output enable control line S0..S1 pin; " select inputs " 8-bit input buses A0..A7, B0..B7, C0..C7, D0..D7 pin; " 8-bit output bus Y0..Y7 pin istype com; " Sets SEL = {S1..S0]; A = [A0..A7]; B = [B0..B7]; C = [C0..C7]; D = [D0..D7]; Y = [Y0..Y7]; EQUATIONS Y.OE = EN; WHEN (SEL == 0) THEN ELSE WHEN (SEL == 1) ELSE WHEN (SEL == 2) ELSE WHEN (SEL == 3) END
11
ECE 270
2011 by D. G. Meyer
example: treexor o ability to fit in a small PLD like a 16V8 ___ o product terms required for each expression (macrocell) ___ o impact on propagation delay ___
MODULE treexor TITLE 'Tree XOR' DECLARATIONS A,B,C,D,E,F,G,H,I,J,K,L pin; T1..T3 pin istype 'com'; XOUT pin istype 'com'; EQUATIONS T1 = A $ B $ C $ D; T2 = E $ F $ G $ H; T3 = I $ J $ K $ L; XOUT = T1 $ T2 $ T3; END
12