CSE 4 Lecture Standard Combinational Modules CK Cheng and Diba Mirza CSE Dept. UC San Diego
Part III - Standard Combinational Modules (Harris: 2.8, 5) Signal Transport Decoder: Decode address Encoder: Encode address Multiplexer (Mux): Select data by address Demultiplexier (DeMux): Direct data by address Shifter: Shift bit location Data Operator Adder: Add two binary numbers Multiplier: Multiply two binary numbers 2
. Decoder Definition Logic Diagram Application (Universal Set) Tree of Decoders 3
iclicker: Decoder Definition A. A device that decodes B. An electronic device that converts signals from one form to another C. A machine that converts a coded text into ordinary language D. A device or program that translates encoded data into its original format E. All of the above 4
Decoder Definition: A digital module that converts a binary address to the assertion of the addressed device E (enable) I I I 2 2 n inputs n= 3 2 3 4 5 6 7 y y.. y 7 2 n outputs 2 3 = 8 n to 2 n decoder function: y i = if E= & (I 2, I, I ) = i y i = otherwise 5
Interconnect: Decoder, Encoder, Mux, DeMux Processors P Data Mux Arbiter Memory Bank Address Data P2 Address 2 Address k Pk Demux Mux Data k Address n n-m m 2 m Decoder Decoder: Decode the address to assert the addressed device Mux: Select the inputs according to the index addressed by the control signals 6
. Decoder: Definition PI Q: What is the output Y 3: of the 2:4 decoder for (A, A ) = (,)? A. (,,, ) B. (,,, ) C. (,,, ) D. (,,, ) A A 2:4 Decoder Y 3 Y 2 Y Y A A Y 3 Y 2 Y Y 7
. Decoder: Definition N inputs, 2 N outputs One-hot outputs: only one output HIGH at once A A E= E 2:4 Decoder Y 3 Y 2 Y Y A A Y 3 Y 2 Y Y 8
Decoder: Logic Diagram E Output Expression: y i = E m i I I I 2 I I I 2 y y y = if E= & (I 2, I, I )=(,,).. I I I 2 y 7 y 7 = if E= & (I 2, I, I )=(,,) 9
Decoder Application: universal set {Decoder, OR} Example: Implement the following functions with a 3-input decoder and OR gates. i) f (a,b,c) = Σm(,2,4) ii) f 2 (a,b,c) = Σm(2,3), iii) f 3 (a,b,c) = Σm(,5,6)
Decoder Application: universal set {Decoder, OR} Example: Implement functions i) f (a,b,c) = Σm(,2,4) ii) f 2 (a,b,c) = Σm(2,3), iii) f 3 (a,b,c) = Σm(,5,6) with a 3-input decoder and OR gates. E= y y 2 y 4 f c b a y I y 2 I 3. 4. 5 I 2 6 7 y 7 y 2 y 3 f 2 y y 5 y 6 f 3
Decoders OR minterms A B E= 2:4 Decoder Minterm AB AB AB AB Y = AB + AB = A B Y 2
Tree of Decoders Implement a 4-2 4 decoder with 3-2 3 decoders. d c b y I y 2 I 3 4 5 I 2 6 7 y 7 a y 8 I y 9 2 I 3 4 5 I 2 6 7 y 5 3
Tree of Decoders Implement a 6-2 6 decoder with 3-2 3 decoders. E E y I 2, I, I D y 7 I 5, I 4, I 3 I 2, I, I D y 8 y 5 y 56 I 2, I, I D7 y 63 4
PI Q: A four variable switching function f(a,b,c,d) can be implemented using which of the following? A. :2 decoders and OR gates B. 2:4 decoders and OR gates C. 3:8 decoders and OR gates D. None of the above E. All of the above 5
2. Encoder Definition (What is it?) Logic Diagram (How is it realized?) Priority Encoder (Special type of encoder) 6
iclicker: Definition of Encoder A. Any program, circuit or algorithm which encodes B. In digital audio technology, an encoder is a program that converts an audio WAV file into an MP3 file C. A device that convert a message from plain text into code D. A circuit that is used to convert between digital video and analog video E. All of the above 7
2. Encoder: Definition En 8 inputs 3 outputs I I 7 2 3 4 5 6 7 A 2 y y y 2 At most one I i =. (y n-,.., y ) = i if I i = & En = (y n-,.., y ) = otherwise. A = if En = and one i s.t. I i = A = otherwise. 8
Encoder Definition: A digital module that converts the assertion of a device to the binary address of the device. E I 2 n - I y n- y I I 7 2 3 4 5 6 7 E y y y 2 A 8 inputs A 3 outputs 2 Encoder Description: At most one I i =. (y n-,.., y ) = i if I i = & E = (y n-,.., y ) = otherwise. A = if E = and one i s.t. I i = A = otherwise. 9
Encoder: Logic Diagram En En y y I I 3 I 5 I 7 En I 2 I 3 I 6 I 7 En y 2 I 4 I 5 I 6 I 7 I I. I 6 I 7 A 2
Priority Encoder: E I y 2 I 3 3 y Eo Gs 2
Priority Encoder: Definition Description: Input (I 2 n -,, I ), Output (y n-,,, y ) E (y n-,,, y ) = i if I i = & E = & I k = for all k > i (high bit priority) or for all k< i (low bit priority). I 2 3 4 5 6 7 2 y y y 2 E o = if E = & I i = for all i, G s = if E = & i s.t. I i =. (G s is like A, and E o tells us if enable is true or not). E I 7 Eo Gs 22
Priority Encoder: Implement a 32-input priority encoder w/ 8 input priority encoders (high bit priority). E I 3-24 y 32, y 3, y 3 Eo Gs I 25-6 y 22, y 2, y 2 Eo Gs I 5-8 y 2, y, y Eo Gs I 7- y 2, y, y Eo Gs 23
Multiplexer Definition Logic Diagram Application 24
3. Mux (Multiplexer) Definition: A digital module that selects one of data inputs according to the binary address of the selector. D 2 n - -D (Data input) E y Description If E = y = D i where i = (S n-,.., S ) Else y = S n-, (Selector) 25
iclicker: Multiplexer Definition A. A device that interleaves two or more activities B. A communications device that combines several signals for transmission over a single medium C. A logic circuit that sends one of several inputs out over a single output channel. D. The circuit that uses a common communications channel for sending two or more messages or signals. E. All of the above 26
Multiplexer (Mux): Definition Selects between one of N inputs to connect to the output. log 2 N-bit select input control input Example: S 2: Mux D D Y S D D Y S Y D D 27
PI Q: What is the output of the following MUX? A. B. C. Can t say E = y S= 28
Multiplexer Definition: Example En D D D 2 D 3 2 3 y S S y S S 29
Multiplexer: Logic Diagram Logic gates Sum-of-products form Y D D S Y = D S + D S Tristates For an N-input mux, use N tristates Turn on exactly one to select the appropriate input S D D Y S D D Y 3
Multiplexer Application Mux for a Boolean function with truth table as input A B Y Y = AB A B Y 3
Multiplexer: Application Y = AB A B Y A Y A B B Y 32
Multiplexer Application: universal set {Mux} Example : Given f (a,b,c) = Σm (,,7) + Σd(2), implement with an 8-input Mux. Id a b c f 2-3 4 5 6 7 33
Multiplexer Application: universal set {Mux} Example : Given f (a,b,c) = Σm (,,7) + Σd(2), implement with an 8-input Mux. Id a b c f 2-3 4 5 6 7 2 3 4 5 6 7 En S 2 S S a b c y 34
Example 2: Given f (a,b,c) = Σm (,,7) + Σd(2), implement with 4-input Muxes. E a b c = c = D (c) D (c) = D (c) = D 2 (c) = D 3 (c) = 2 3 y S S a b 35
Example 2: Given f (a,b,c) = Σm (,,7) + Σd(2), implement with 4-input Muxes. E a b c = - c = D (c) D (c) = D (c) = D 2 (c) = D 3 (c) =c c 2 3 S S y a b 36
Example 3: Given f (a,b,c) = Σm (,,7) + Σd(2), implement with 2- input Muxes. a D (b,c) - D (b,c) D (b,c) E y a 37
Example 3: Given f (a,b,c) = Σm (,,7) + Σd(2), implement with 2- input Muxes. a D (b,c) - D (b,c) D (b,c) E D (b,c) = b - D (b,c) = bc b D (b,c) y c b c b a 38
Example 3: Given f (a,b,c) = Σm (,,7) + Σd(2), implement with 2- input Muxes. D (b,c) b c = c = l () = l (c) = c E b y a 39
Example 3: Given f (a,b,c) = Σm (,,7) + Σd(2), implement with 2- input Muxes. D (b,c) b c = c = E l () = l (c) = c E b y c a b 4
4. Demultiplexers E x Control Input 4
4. Demultiplexers E y i = x if i = (S n-,.., S ) & E= y i = otherwise x y 2 n- -y S(n-,) Control Input 42
Shifters Logical shifter: shifts value to left or right and fills empty spaces with s Ex: >> 2 = Ex: << 2 = Arithmetic shifter: same as logical shifter, but on right shift, fills empty spaces with the old most significant bit (msb). Ex: >>> 2 = Ex: <<< 2 = Rotator: rotates bits in a circle, such that bits shifted off one end are shifted into the other end Ex: ROR 2 = Ex: ROL 2 = 43
Shifter x n x n- x x - s d s d E y i = x i- if E =, s =, and d = L = x i+ if E =, s =, and d = R = x i if E =, s = = if E = yn- y x i+ x i x i- Can be implemented with a mux s d 3 2 E yi
Shifter Design A 3 A 2 A A shamt : 2 S : Y 3 shamt : 2 S : Y 2 4 4 A 3: >> Y 3: S : Y S : Y 45
Barrel Shifter shift x s O or shift s O or 2 shift s 2 O or 4 shift y
Shifters as Multipliers and Dividers A left shift by N bits multiplies a number by 2 N Ex: << 2 = ( 2 2 = 4) Ex: << 2 = (-3 2 2 = -2) The arithmetic right shift by N divides a number by 2 N Ex: >>> 2 = (8 2 2 = 2) Ex: >>> 2 = (-6 2 2 = -4) 47