Decoders
• n-to-2n decoder: logic network with n inputs and 2n outputs.
• One output is active for each of the 2n input combinations each minterm
• Decoder minterm generator• Most common use:
– Memory selection
Decoders
• Parallel is expensive• Problem extending for larger n• 2n decoders require n-input ANDs: fan-in
• Alternative: (c) alternate structure
• Tree decoders – constant fan-in: 2-input gates throughout
• Compare the number of gates required for (a) and (b)
• Dual tree decoders– n inputs divided into 2 groups j and k;
• n = j+k
– j-input decoder 2j outputs– k-input decoder 2k outputs– Array of 2j * 2k = 2n 2-input ANDs
Decoders
Logic functions using Decoders
• Active-high decoder with OR gate (a)• Active-low decoder with NAND gate (b)
Logic functions using Decoders
• Active-high decoder with NOR gate (c)• Active-low decoder with AND gate (d)
Encoders
• Opposite of decoder: one output code (binary) for each input; assumes one input active at a time
• n inputs; s outputs• n ≤ 2s
• s ≥ log2n; usually s = log2n
• 4:2 encoder with
exclusive inputs:
functional diagram
Encoders
• Functional diagram and Truth table of the 4:3 encoder
• Outputs Zero unless exactly
one line is active high
Encoders
• 4:2 priority encoder• No input active EO = 1• At least one input active GS = 1• If more than one input active output the one
with highest priority• 3 > 2 > 1 > 0• Useful in resource
managementrequest /acknowledgecircuits incomputers
Adders
• Often realized as “bit slice”s– Bit slice: module that handles one bit position– Can be replicated (arrayed)– Array handles n bits (the whole number)
• Bit slice: Half Adder– Given two input bits, produces sum and carry
Adders
• Expanding the carry expressions yields
or, generalized:
ii
iiiiii
iiii
pppgpppg
ppgpgg
cpgc
210321
121
1
Adders
• When there is carry-in, it becomes c0, and renumbering the terms yields:
• Can form groups of 4:
iii
iiiiii
iiii
pppcpppgpppg
ppgpgg
cpgc
100210321
121
1
*0
*0
3210032103213234
21002102123
1001012
0001
PG
ppppcpppgppgpggc
pppcppgpggc
ppcpggc
cpgc
Adders
• Using the group carries:
• Generate and propagate are from one bit so far
• Can extend the idea to groups of bit positions
*2
*1
*00
*2
*1
*0
*2
*1
*212
*1
*00
*1
*0
*18
*00
*04
PPPcPPGPGGc
PPcPGGc
PcGc
iiii cpgc 1
• The group carry, generate and propagate are:
• The groups can be adjoining or overlappinge.g.
Adders
21211:
1:
::1
iiiiiiiiiji
jiiji
jijjii
gppgppgpgG
pppP
PCGC
4:744:78
0:300:34
PCGC
PCGC
• Subtraction is addition– Two-s complement
– Bitwise invert B and set the carry-in c0=1
Adders
BABA~