2-3. Learning Outcomes 2-3.2 Spiral 2 3 Negative Logic One hot State Assignment System Design Examples I understand the active low signal convention and how to interface circuits that use both active high and active low signals I can take any state diagram and create a corresponding state machine using one hot implementation by using one FF per state and creating the D input circuit by converting each incoming transition arrow to a state into a logic gate and ORing them together I understand how to decompose an algorithm into states for each step and appropriate datapath units for each operator Mark Redekopp 2-3.3 DeMorgan Equivalents 2-3.4 = = NEGATIVE (ACTIVE LO) LOGIC = =
2-3.5 2-3.6 Negative Logic Why Active low Recall it is up to us humans to to the two voltage levels Thus, far we ve used (unknowingly) the logic convention where means true and means false In logic means true and means false Some digital circuits are better at (draining/sucking) electric current than (producing) current volts =true/on (Value/Meaning) volts =false/off (Value/Meaning) Active-hi output Active-low output =false/off Logic Convention time =true/on time Logic Convention LED is on when gate outputs '' LED is on when gate outputs '' 2-3.7 2-3.8 Negative Logic AND Function Negative Logic OR Function Traditional P.L. AND N.L. AND function N.L. AND = P.L. OR Traditional P.L. OR N.L. OR function N.L. OR = P.L. AND P.L. X Y P.L. AND P.L. Z N.L. X Y P.L. AND N.L. AND N.L. Z N.L. X Y N.L. AND N.L. Z P.L. X Y P.L. OR P.L. Z N.L. X Y P.L. OR N.L. OR N.L. Z X Y Z X Y Z X Y Z X Y Z X Y Z X Y Z Traditional AND gate functionality assumes positive logic convention Given negative logic signals, we can invert to positive logic, perform the AND operation, then convert back to negative logic However, we then see that an OR gate implements the negative logic AND function Traditional OR gate functionality assumes positive logic convention Given negative logic signals, we can invert to positive logic, perform the OR operation, then convert back to negative logic However, we then see that an AND gate implements the negative logic OR function
2-3.9 2-3. Negative Logic Active hi vs. Active low A negative logic OR function is equivalent to an AND gate = A negative logic AND function is equivalent to an OR gate = These are the preferred way of showing the N.L. functions because the inversion bubbles explicitly show where N.L. is being converted to P.L. and the basic gate schematics retain their meaning (when we see an AND gate we know we re doing some king of AND function with the bubbles indicating N.L.) Active hi convention = on/true/active = off/false/inactive Active low convention = on/true/active = off/false/inactive To convert between conventions 2-3. 2-3.2 Enables Decoder w/ Active Low Enable and Outputs When E=, inputs is ignored Since E=, all outputs = A /D /D When E=, inputs will cause the appropriate output to go active Since E=, outputs will function normally B Enable /E /D2 /D3 Bubbles and signals starting with a slash '/' indicate an active-low input or output not an inverter the inverters are actually in the logic diagram on the next pages
Active Lo Outputs 2-3.3 Active Lo Enable 2-3.4 When E=inactive (inactive means ), Outputs turn off (off means ) When E=active (active means ), Selected outputs turn on (on means ) When E=inactive (inactive means ), Outputs turn off (off means ) When E=active (active means ), Selected outputs turn on (on means ) Active Lo Enable 2-3.5 Decoder w/ Multiple Enables 2-3.6 When a decoder has multiple enables, all enables for the decoder to be enabled When E=inactive (inactive means ), Outputs turn off (off means ) When E=active (active means ), Selected outputs turn on (on means ) 3 Enables /G must equal /G2 must equal and E must equal
2-3.7 2-3.8 Active Low CLR and PRESET Active Low CLR and PRESET The reset signal might also be active low ( = Reset, = Normal operations) FFs can be made with active low /CLR & /PRE Need to be able to initialize Q to a known value ( or ) /RESET /RESET Logic PRE D CLK CLR Q _ When /RESET =, /CLR is activated and Q is forced to Logic PRE D CLK CLR Q Q* = _ When /RESET =, /CLR is inactive and Q looks at D at each clock edge /RESET _ /RESET _ 2-3.9 Digital System Representation 2-3.2 Turn Sensor S State Diagram Turn Sensor S2 Overall sensor output S = S + S2 ONE HOT STATE ASSIGNMENT Main Street Raw inputs S S2 Input Function Logic (IFL) Conditioned inputs S Next State Logic (NSL) FF inputs State Memory (SM) FF outputs Output Function Logic (OFL) Outputs
Encoded State Assignment Review State Diagrams. States 2. Transition Conditions 3. Outputs State Machines require sequential logic to remember the current state (w/ just combo logic we could only look at the current value of X, but now we can take 4 separate actions when X=) On Reset (power on) X= Sinit F= X= X= X= X= S S F= F= X= X= X= State Diagram for Sequence Detector State Machine. State Memory => FF s n FF s => 2 n states 2. Next State Logic (NSL) + Input Function Logic (IFL) combinational logic for FF inputs 3. Output Function Logic (OFL) MOORE: f(state) MEALY: f(state + inputs) (Input) (Next State) (Current State) X D Q D Q OFL S F= NSL D D SM Q Q Q Q 2-3.2 (Output) F State Assignment Design of the traffic light controller with main turn arrow Represent states with some binary code, but what kind? Encoded: 3 States => : =SSG, =MSG, =MTG One hot: Separate FF per state: =SSG, =MSG, =MTG Turn Sensor S2 Main Street Turn Sensor S Overall sensor output S = S + S2 2-3.22 State Diagram CLK 2-3.23 2-3.24 NSL Implementation in Hot Method NSL Implementation in Hot Method In one hot assignment, NSL is designed by simple observation For each state, examine each transition Each incoming arrow will be one case in our logic We can just each condition together Describe each transition as a combination of what state it originates from & any associated conditions Ex. Two arrows converge on MS: Q MS should be on the next clock when Current state is...or Current state is AND Q SS Q MT Q MS SS MT MS One-hot State Assignment Two arrows converge on MS: Q MS should be on the next clock when Current state is MT...OR Current stat is SS AND S= Q* MS = D MS = Q MT + Q SS S Q* MT = D MT = Q* SS = D SS = What about initial state? Preset the appropriate flop. Q SS Q MT Q MS SS MT MS One-hot State Assignment
2-3.25 Multiplication Techniques 2-3.26 Array Multiplier (Combinational) Add and Shift Method (Sequential) MULTIPLICATION TECHNIQUES A multiplier unit can be Purely Combinational: Each partial product is produced in and fed into an of adders to generate the product Sequential and Combinational: Produce and add partial product at a time ( ) Combinational Multiplier Analysis 2-3.27 Add and Shift Method 2-3.28 Large Area due to bit adders n because the first adder adds the first two partial products and then each adder afterwards adds one more partial product Propagation delay is in two dimensions proportional to Sequential algorithm n bit * n bit multiply Adds partial product per clock Shift running sum bit right each clock Three n bit Registers, Adder At start: M = Multiplicand Q = Multiplier A = Answer => initialized to After completion A and Q concatenate to form 2n bit answer
C A Q Cout Add and Shift Hardware = M * = Q 2-3.29 Add and Shift Algorithm C=, A= Repeat the following If Q[] =, A = Else if Q[] =, A= Shift bit ( ) 2-3.3 Cin M * 2-3.3 Add and Shift Multiplication = M * = Q = Ans C A Q 2-3.32 Cout M = C A Q Cin M
Add and Shift Multiplication C A Q Cout Cin M = M * = Q = Ans Final Product Finished M = C A Q * + + - + -- + --- Add Shift Add Shift No Add Shift Add Shift = 2-3.33 * Example C A Q Cout Cin M C= M= A= Q= Description A=A+M Shift Right C,A,Q A=A+ Shift Right C,A,Q A=A+M Shift Right C,A,Q A=A+ Shift Right C,A,Q 2-3.34 2-3.35 2-3.36 Sequential Multiplier Analysis Digital System Design Pros: Cons: Control and Datapath Unit paradigm Separate logic into datapath elements that operate on data and control elements that generate control signals for datapath elements Datapath: Adders, muxes, comparators, counters, registers (w/ enables) Control Unit: State machines/sequencers clk reset Control Control Signals Condition Signals Data Inputs Datapath Data Outputs
2-3.37 2-3.38 Let's Practice our Design Skills Break design into control and datapath This is the datapath Adder 2 to mux 2 shift registers (A/Q) normal reg (M) FF w/ Enable (C) C A Q Cout Cin State Machine Control From our high level datapath we can arrive at a high level state diagram M 2-3.39 2-3.4 Refining our Design Sample Shift Register But now we need to refine our design to actual components, specific control bits, etc. Shift registers come in many flavors, we'll just look at one example 4 bit Bi directional Shift Register RST: synchronous reset S[:]: Hold, Right Shift, Left Shift, or Load DSL and DSR Data to shift in from left or right CLK ACLR S S Q*[3:] (case), X X X Q[3:] X X Reset Q[3:] Hold D SR,Q[3:] Right Q[2:],D SL Left D[:3] Load
2-3.4 2-3.42 Shift Registers Complete the DataPath Assume you build the state machine below and produce 4-signals that tell us which state we are in: Qwait Qadd Qsh Qdone 2-3.43 2-3.44 Encoders Another common datapath component Opposite function of decoders Takes in 2 n inputs and produces an n bit number I SIMPLE & PRIORITY ENCODERS Assume One active input I I2 I3 I4 I5 I6 Binary Encoder Y Y Y2 That number input gets encoded in binary I7 4
2-3.45 2-3.46 Encoders Encoders What s inside an encoder? What s inside an encoder? I I I 2 I 3 I 4 I 5 I 6 I 7 Y 2 Y Y I I I2 I3 I4 I5 I6 I7 Binary Encoder Y Y Y2 I I I 2 I 3 I 4 I 5 I 6 I 7 Y 2 Y Y I I I2 I3 I4 I5 I6 I7 Binary Encoder Y Y Y2 Deriving equations for Y, Y, Y 2 is made simpler because of the assumption that only input can be active at a time. Y 2 = Y = Y = 2-3.47 2-3.48 Encoders Problems A simple binary encoder can be made with just gates There is a problem Our assumption is that only input can be active at a time What happens if 2 or more inputs are active or if inputs are active
2-3.49 2-3.5 2 or More Active Inputs Active Inputs What if I5 and I2 are active at the same time? Substitute values into equation Output will be = 7 Output is neither 2 nor 5, it s something different, 7 I I I2 I3 I4 I5 I6 I7 Binary Encoder Y Y Y2 Y 2 = I4 + I5 + I6 + I7 Y = I2 + I3 + I6 + I7 Y = I + I3 + I5 + I7 What if no inputs are active? Substitute values into equation Output will be Problem: means that input was active Can t between when means input was active or no inputs was active I I I2 I3 I4 I5 I6 I7 Binary Encoder Y Y Y2 I I I2 I3 I4 I5 I6 I7 Binary Encoder Y Y Y2 2-3.5 2-3.52 Priority Encoders Priority Encoders Fix the 2 problems seen above Problem of more than 2 active inputs Assign priority to inputs and only encode the highest priority active input Problem of zero active inputs Create an extra output to indicate if any inputs are active We will call this output the Valid output (/V) Fix the 2 problems seen above Problem of more than 2 active inputs Assign priority to inputs and only encode the highest priority active input Problem of zero active inputs Create an extra output to indicate if any inputs are active If multiple inputs are active only the highest priority active input (I5) is encoded Lowest priority Highest priority / V = Valid (a.k.a /EO=Enabled Output) is active if ANY inputs are active No inputs are active Output is still but /V tells us that this is not because I was active / V = Valid (a.k.a /EO=Enabled Output) is inactive if no inputs are active
2-3.53 2-3.54 Encoder Application: Interrupts Encoder Application: Interrupts I/O Devices in a computer need to request attention from the CPU they need to interrupt the processor CPU cannot have a dedicated line to each I/O device (too many inputs and outputs) plus it can only service one device at a time Solution: Priority Encoder /INT input of CPU indicates SOME device is requesting attention INT_ID inputs identify who is requesting attention Sound Network Card USB Ctrl. Processor (CPU) Sound Network Card USB Ctrl. Keyboard Keyboard I I I2 Y I3 I4 Priority Encoder Y I5 I6 Y2 I7 /V Processor (CPU) INT_ID /INT 2-3.55 2-3.56 Encoder Application: Interrupts Example: Sound and Network request interrupt at the same time Network is highest priority and is encoded After network is handled, sound will cause interrupt Sound Network Card USB Ctrl. Keyboard I I I2 Y I3 I4 Priority Encoder Y I5 I6 Y2 I7 /V 3 = Processor (CPU) INT_ID /INT VENDING MACHINE
2-3.57 2-3.58 Vending Machine Controller Digital System Design Consider a vending machine that sells Coke, Diet Coke, Sprite and Dr. Pepper Drinks cost Sensors indicate (for clock cycle) when a user has entered a nickel, dime, quarter, or dollar bill Max. input amount is (beyond that the machine is not responsible for counting) Individual buttons for each drink allow the user to select their drink and if at least $ has been entered, a release signal for each drink should be asserted Making change will be considered in a future lab Control and Datapath Unit paradigm Separate logic into datapath elements that operate on data and control elements that generate control signals for datapath elements Datapath: Adders, muxes, comparators, counters, registers (w/ enables) Control Unit: State machines/sequencers clk reset Data Inputs Control Signals Control Datapath Condition Signals Data Outputs 2-3.59 2-3.6 Money Collection & Release FSM Money Collection Datapath Consider the state machine and datapth only for money collection and release signal generation Pseudocode for collection algorithm:
Sample Operation Waveform 2-3.6 CLK /RESET SNSR25 BTN_DP LD M M >= State REL_EN REL_DP