課程名稱 : 數位邏輯設計 P-1/55 2012/6/11 Textbook: Digital Design, 4 th. Edition M. Morris Mano and Michael D. Ciletti Prentice-Hall, Inc. 教師 : 蘇慶龍 INSTRUCTOR : CHING-LUNG SU E-mail: kevinsu@yuntech.edu.tw
Chapter 8 P-2/55 2012/6/11 Chapter 8 Design at the Register Transfer Level
Outline of Chapter 8 P-3/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.1 Introduction P-4/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.1 Introduction P-5/55 2012/6/11 A digital system is a sequential logic system constructed with flip-flops and gates. 1. To specify a large digital system with a state table is very difficult. 2. Modular subsystems 3. Registers, decoders, multiplexers, arithmetic elements and control logic 4. They are interconnected with datapaths and control signals.
8.2 Register Transfer Level Notation P-6/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.8 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.2 Register Transfer Level Notation P-7/55 2012/6/11 RTL 1. Register Transfer Level (RTL): The information flow and processing perform on the data stored in the registers is referred to as register transfer operations. 2. A large digital system is presented at the register transfer level when it is specified by the following three components: 1: The set of registers in the system 2: The operations that are performed on the data stored in the registers 3: The control that supervises the sequence of operations in the system
Register MUX Register Register Register 8.2 Register Transfer Level Notation P-8/55 2012/6/11 Controller RTL (Continued) RTL 1 IF Combination Logic Gates Combination Logic Gates Combination Logic Gates Combination Logic Gates RTL 2 RTL 3
8.2 Register Transfer Level Notation P-9/55 2012/6/11 R2 RTL Notations R1 : Contents of R1 transfer into R2 IF (T1=1) then (R2 R1) Concurrently IF (T3=1) then (R2 R1, R1 R2) : Exchange R1, R2 R1 R3 R4 R1+R2 : Add Content of R2 to R1 R3+1 : Increase R3 by 1 (Count up) shr R4 : Shift right R4 R5 0 : Clear R5 to 0
8.2 Register Transfer Level Notation P-10/55 2012/6/11 Four Types of Operations in a Digital System 1. Transfer operations that transfer data from one register to another. 2. Arithmetic operations that perform arithmetic on data in registers. 3. Logic operations that perform bits manipulation of non-numeric data in registers. 4. Shift operations that shift data in registers
8.3 Register Transfer Level in HDL P-11/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.3 Register Transfer Level in HDL P-12/55 2012/6/11 HDL Programming referred to TA
8.3 Register Transfer Level in HDL P-13/55 2012/6/11 Process of HDL Simulation and Synthesis HDL Description of Design Valid Design Synthesis Tools Synthesis Gate-level Netlist Simulation RTL Design Test Bench Simulation Gate-level Design Needs Corerection Results OK! OK! Results Needs Corerection No Match Comparison Match! Fabricate IC
8.4 Arithmetic State Machines (ASMs) P-14/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.4 Arithmetic State Machines (ASMs) P-15/55 2012/6/11 Control and Datapath Interaction Status Conditions Inputs Control Logic (Controller) Commands (Control Signals) Inputs Datapath (Data Compuating) Outputs Adders Decoder Multiplexer Counter Shift Register
8.4 Arithmetic State Machines (ASMs) P-16/55 2012/6/11 Algorithmic State Machine (ASM) 1. Algorithmic State Machine (ASM): A special flow chart that has been developed specifically to define digital hardware algorithm. 2. State Machine: A term for a sequential circuit. 3. ASM Chart: The ASM chart describes the sequence of events as well as the timing relation ship between the states of sequential controller and the events that occur while going from one state to the next.
8.4 Arithmetic State Machines (ASMs) P-17/55 2012/6/11 ASM Chart: State Box + Decision Box + Conditional Box State Box: Name Binary Code T 3 011 Register Operation or Output R 0 START (a) General Description (b) Specific Example Decision Box: 0 1 Condition Exit Path Exit Path
8.4 Arithmetic State Machines (ASMs) P-18/55 2012/6/11 Conditional Box and a Example Example with Conditional Box: T 1 001 General Description: START From exit path of decision box Register Operation or Output 0 E 1 R 0 T 2 010 F E
8.4 Arithmetic State Machines (ASMs) P-19/55 2012/6/11 ASM Block : 1 Clock Period (RTL) T 1 001 ASM Block A A+1 0 E 1 State Diagram Equivalent to ASM Chart 001 EF=00 E=1 0 1 F R 0 010 EF=01 100 T 2 010 T 3 011 T 4 100 011
8.4 Arithmetic State Machines (ASMs) P-20/55 2012/6/11 Timing Considerations Clock Present State (T 1 ) Next State (T 2 or T 3 or T 4 ) 1. Register A is increased 2. If E=1, then register R is cleared 3. Control transfer to the next state as specified in previous slice.
8.5 Design Example P-21/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.5 Design Example P-22/55 2012/6/11 Design Descriptions 1. System with 2 FFs (E and F), a 4-bit binary counter A (A 4 A 3 A 2 A 1 ) 2. A 4 : Most Signification Bit (MSB) 3. In initiation signal S clear A and F 4. Counter is increased by clock pulse 5. If A 3 =0, E is cleared to 0 and the counter continues 6. If A 3 =1, E is set to 1; then if A 4 =0, the count continues, but if A 4 =1, F is set to 1 on next clock pulse and the system stops counting 7. Then if S=0, the system remains in the initial state, but if S=1, the operation cycle repeats.
8.5 Design Example P-23/55 2012/6/11 T 0 00 Initial State 0 S T 0 ASM Block ASM Chart for Design Example T 1 1 A 0 F 0 A A+1 T 1 A 3 =0 G 1 G 0 =01 A 3 A 4 =10 T 2 0 1 A 3 E 0 E 1 A 4 0 T 2 1 A 3 A 4 =11 11 F 1
Delay 1 Cycle 8.5 Design Example P-24/55 2012/6/11 Timing Sequence: Response Delay 1 Cycle Operation Sequence Counter Flip-Flop A 4 A 3 A 2 A 1 E F Condition State Delay 1 Cycle 0 0 0 0 1 0 0 0 0 1 0 0 A 3 =0, A 4 =0 T 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 1 0 A 3 =1, A 4 =0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 1 0 0 1 0 0 A 3 =0, A 4 =1 1 0 1 0 0 0 1 0 1 1 0 0 1 1 0 0 0 0 A 3 =1, A 4 =1 1 1 0 1 1 0 T 2 1 1 0 1 1 1 T 0 Delay 1 Cycle
8.5 Design Example P-25/55 2012/6/11 Datapath Design Start S T 0 T 0 =1,S=1 A 4 Controller T 1 T 1 =1,E=A 3 A 3 Clock T 2 J C K E T 2 =1 J C K F A 4 A 3 A 2 A 1 4-Bit Counter with Synchronous Clear Count Clear T 0 =1,S=1 Clock
8.5 Design Example P-26/55 2012/6/11 Register Transfer Representation S=0 A 3 =0 Register Transfer Operations T 0 : if (S=1) then A 0, F 0 T 0 S=1 T 1 T A 2 3 A 4 =11 T 1 : A A+1 if (A 3 =1) then E 1 if (A 3 =0) then E 0 A 3 A 4 =10 T 2 : F 1 State Diagram
8.5 Design Example P-27/55 2012/6/11 State Table State Table for Controller Present Next Present-State State Inputs State Outputs Symbol G 1 G 0 S A 3 A 4 G 1 G 0 T 0 T 1 T 2 T 0 0 0 0 X X 0 0 1 0 0 T 0 0 0 1 X X 0 1 1 0 0 T 1 0 1 X 0 X 0 1 0 1 0 T 1 0 1 X 1 0 0 1 0 1 0 T 1 0 1 X 1 1 1 1 0 1 0 T 2 1 1 X X X 0 0 0 0 1 T 0 =G 0 T 2 =G 1
8.5 Design Example P-28/55 2012/6/11 Control Logic (Controller) Design S D G 0 D G1 = T 1 A 3 A 4 D G0 = T 0 S+T 1 T 0 = G 0 T 1 = G 1 G 0 T 2 = G 1 A 3 A 4 C D G 1 Clear T 0 T 2 C T 1 Clock Clear
8.6 HDL Description of Design Example P-29/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.6 HDL Description of Design Example P-30/55 2012/6/11 Referred to TA
8.7 Sequential Binary Multiplier P-31/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.7 Sequential Binary Multiplier P-32/55 2012/6/11 Example for Binary Multiplications 23 10111 Multiplicand (n-bit) 19 10011 Multiplier (m-bit) 10111 10111 00000 00000 10111 437 110110101 Product (n+m Bits)
8.7 Sequential Binary Multiplier P-33/55 2012/6/11 Register Configuration Check for Zero Z=1 if P=0 Z Control Logic P Counter (Down Counter) S (Start) Register B Multiplicand Initial Value = n (Bit Number of Multiplier) CAQ C out Parallel Adder Sum Initial Value = 0 C Register A Initial Value=0 Register Q Multiplier Q 0 Product
8.7 Sequential Binary Multiplier P-34/55 2012/6/11 T 0 Initial State T 1 0 S 1 A 0 C 0 P n ASM Chart T 2 P P-1 0 1 Q 0 A A+B, C C out Shift CAQ, C 0 A shr A, A n-1 C, Q shr Q, Q n-1 A 0, C 0 T 3 Shift Right CAQ, C 0 0 1 Z
8.7 Sequential Binary Multiplier P-35/55 2012/6/11 Numerical Example for Binary Multiplier Multiplicand B=10111 C A Q P Multiplier in Q 0 00000 10011 101 Q 0 =1; add B 10111 First partial product 0 10111 100 Shift right CAQ 0 01011 11001 Q 0 =1; add B 10111 Second partial product 1 00010 011 Shift right CAQ 0 10001 01100 Q 0 =0; shift right CAQ 0 01000 10110 010 Q 0 =0; shift right CAQ 0 00100 01011 001 Q 0 =1; add B 10111 Fifth partial product 0 11011 Shift right CAQ 0 01101 10101 000 Final Product in CAQ = 0110110101
8.8 Control Logic P-36/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.8 Control Logic P-37/55 2012/6/11 Control Specifications for Binary Multiplier Register Transfer Operations T 0 : Initial State T 1 : A 0, C 0, P n T 2 : P P-1 if (Q 0 )=1 then (A A+B, C C out ) T 3 : Shift Right CAQ, C 0 State Diagram S=0 Z=1 T 0 T 1 T 2 T 3 S=1 Z=0
8.8 Control Logic P-38/55 2012/6/11 Control Block Diagram and State Assignment Control Block Diagram Z S Q 0 Control Logic T 0 T 1 T 2 T 3 L=Q 0 T 2 Addition State Assignment for Control State Binary Gray Code One-Hot T 0 00 00 0001 T 1 01 01 0010 T 2 10 11 0100 T 3 11 10 1000
8.8 Control Logic P-39/55 2012/6/11 Sequence Register and Decoder State Table for Control Circuit Present Next State Input State Outputs G 1 G 0 S Z G 1 G 0 T 0 T 1 T 2 T 3 0 0 0 X 0 0 1 0 0 0 0 0 1 X 0 1 1 0 0 0 0 1 X X 1 0 0 1 0 0 1 0 X X 1 1 0 0 1 0 1 1 X 0 1 0 0 0 0 1 1 1 X 1 0 0 0 0 0 1 T 3 Z Next State: D G1 = T 1 + T 2 + T 3 Z D G0 = T 0 S + T 2
8.8 Control Logic P-40/55 2012/6/11 Control Logic Diagram of a Binary Multiplier S D C G 0 0 1 2X4 Decoder 0 1 2 3 T 0 T 1 T 2 T 3 Z D G 1 C Q 0 L=T 2 Q 0 Clock
8.8 Control Logic P-41/55 2012/6/11 One Flip-Flop per State (One-Hot) without Decoder State Table for One-Hot Controller T 0 S T 3 Z Present Next State Input State Outputs S Z T 0 T 1 T 2 T 3 T 0 0 X T 0 1 0 0 0 T 0 1 X T 1 1 0 0 0 T 1 X X T 2 0 1 0 0 T 2 X X T 3 0 0 1 0 T 3 X 0 T 2 0 0 0 1 T 3 X 1 T 0 0 0 0 1 Next State: D T0 = T 0 S + T 3 Z D T1 = T 0 S D T2 = T 1 + T 3 Z D T3 = T 2
8.8 Control Logic P-42/55 2012/6/11 S Z T 0 S +T 3 Z D C T 0 One Flip-Flop per State (One-Hot) Controller D C D C T 1 T 2 D T 3 C Clock
8.9 HDL Description of Binary Multiplier P-43/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.9 HDL Description of Binary Multiplier P-44/55 2012/6/11 Referred to TA
8.10 Design With Multiplexers P-45/55 2012/6/11 8.1 Introduction 8.2 Register Transfer Level (RTL) Notation 8.3 Register Transfer Level in HDL 8.4 Algorithmic State Machines (ASMs) 8.5 Design Example 8.6 HDL Description of Design Example 8.7 Sequential Binary Multiplier 8.8 Control Logic 8.9 HDL Description of Binary Multiplier 8.10 Design With Multiplexers
8.10 Design With Multiplexers P-46/55 2012/6/11 3-Level Controller Implementations with Multiplexers 1 st. Level: Multiplexers determines the next state of the register. 2 nd. Level: Registers hold the present binary state. 3 rd. Level: Decoders provide a separate output for each control state.
8.10 Design With Multiplexers P-47/55 2012/6/11 T 0 00 w 0w 1w T 1 01 Design Example x 0 x 1 x T 3 11 T 2 10 0 z 0 y 1 1 y 0 yz 1 1 z 0 yz y
8.10 Design With Multiplexers P-48/55 2012/6/11 Control Implementation with Multiplexers y z y z 0 1 y w x y 0 1 2 3 0 1 2 3 MUX 1 S 1 S 0 S 1 S 0 MUX 2 D C D C G 1 G 0 2X4 Decoder T 0 T 1 T 2 T 3 Clock
8.10 Design With Multiplexers P-49/55 2012/6/11 Multiplexer Input Conditions Multiplexer Input Conditions Present Next State State Input Inputs G 1 G 0 G 1 G 0 Conditions MUX1 MUX2 0 0 0 0 w 0 0 0 1 w 0 w 0 1 1 0 x 0 1 1 1 x 1 x 1 0 0 0 y 1 0 1 0 yz yz +yz=y yz 1 0 1 1 yz 1 1 0 1 y z 1 1 1 0 y y+y z =y+z y z+y z =y 1 1 1 1 y z
8.10 Design With Multiplexers P-50/55 2012/6/11 Design Example: Count the Number of Ones in a Register 1. The system to be designed consists of two registers, R1 and R2, and a flip-flop E. 2. The system counts the number of 1 s in the number loaded into R1 and sets register R2 to that number. Example: R1 = 10111001 R2 = 101 Solution: 1. Shift each bit from R1 one at a time into flip-flop E 2. If E=1, then R2 is increased by 1 3. If R1=0, then Z=1
Complete 8.10 Design With Multiplexers P-51/55 2012/6/11 T 0 00 Initial State 0 R1 R2 S 1 Input All 1's ASM Chart for Countof-Ones Circuit T 1 01 R2 R2+1 Z 1 0 T 2 10 Shift R1 to E T 3 11 E 1 0
8.10 Design With Multiplexers P-52/55 2012/6/11 Start S E Z Control T 0 T 1 T 2 T 3 Z=1 if R1=0 Block Diagram for Count-of-Ones E D Check for Zero Parallel Output Shift Register R1 Serial Input=0 Shift Left Load Input C Input Data Clock Output Count Counter R2 Count Load Input Input = All 1's
8.10 Design With Multiplexers P-53/55 2012/6/11 Multiplexer Input Conditions for Design Example Present Next Multiplexer State State Input Inputs G 1 G 0 G 1 G 0 Conditions MUX1 MUX2 0 0 0 0 S 0 0 0 1 S 0 S 0 1 0 0 Z 0 1 1 0 Z Z 0 1 0 1 1 None 1 1 1 1 1 0 E 1 1 0 1 E E E
8.10 Design With Multiplexers P-54/55 2012/6/11 0 Z 1 E S 0 1 E Control Implementation for Count-of-One Circuit 0 1 2 3 0 1 2 3 MUX 1 S 1 S 0 S 1 S 0 MUX 2 Clock D C D C G 1 G 0 2X4 Decoder T 0 T 1 T 2 T 3
P-55/55 2012/6/11 Have a nice summer vacation!