Modeling Digital Systems with Verilog

Similar documents
Sequencing and Control

Register Transfer Level in Verilog: Part II

CS 110 Computer Architecture. Finite State Machines, Functional Units. Instructor: Sören Schwertfeger.

Chapter 2. Digital Circuits

Logic Devices for Interfacing, The 8085 MPU Lecture 4

Sequential logic. Circuits with feedback. How to control feedback? Sequential circuits. Timing methodologies. Basic registers

ELEN Electronique numérique

Logic Design II (17.342) Spring Lecture Outline

Synchronous Sequential Logic

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

BUSES IN COMPUTER ARCHITECTURE

Switching Circuits & Logic Design, Fall Final Examination (1/13/2012, 3:30pm~5:20pm)

Registers and Counters

1. Convert the decimal number to binary, octal, and hexadecimal.

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Tajana Simunic Rosing. Source: Vahid, Katz

CHAPTER 4: Logic Circuits

Counter dan Register

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

CS3350B Computer Architecture Winter 2015

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

CHAPTER 4: Logic Circuits

Microprocessor Design

Counters

ECSE-323 Digital System Design. Datapath/Controller Lecture #1

IT T35 Digital system desigm y - ii /s - iii

6.3 Sequential Circuits (plus a few Combinational)

CSE 352 Laboratory Assignment 3

Registers and Counters

MODULE 3. Combinational & Sequential logic

The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

Control Unit. Arturo Díaz-Pérez Departamento de Computación Laboratorio de Tecnologías de Información CINVESTAV-IPN

CS61C : Machine Structures

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING DIGITAL DESIGN

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

Chapter 3. Boolean Algebra and Digital Logic

CS/ECE 250: Computer Architecture. Basics of Logic Design: ALU, Storage, Tristate. Benjamin Lee

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

PESIT Bangalore South Campus

First Name Last Name November 10, 2009 CS-343 Exam 2

CHAPTER 4 RESULTS & DISCUSSION

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science SOLUTIONS

Administrative issues. Sequential logic

More Digital Circuits

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

Chapter 7 Counters and Registers

Logic Design. Flip Flops, Registers and Counters

Sequential Logic. Sequential Circuits. ! Timing Methodologies " Cascading flip-flops for proper operation " Clock skew

Lab #12: 4-Bit Arithmetic Logic Unit (ALU)

Chapter 4: One-Shots, Counters, and Clocks

Chapter 5 Flip-Flops and Related Devices

CS 152 Midterm 2 May 2, 2002 Bob Brodersen

Computer Organization & Architecture Lecture #5

Lab #10 Hexadecimal-to-Seven-Segment Decoder, 4-bit Adder-Subtractor and Shift Register. Fall 2017

Flip Flop. S-R Flip Flop. Sequential Circuits. Block diagram. Prepared by:- Anwar Bari

Unit-5 Sequential Circuits - 1

CHAPTER1: Digital Logic Circuits

EE178 Lecture Module 4. Eric Crabill SJSU / Xilinx Fall 2005

Altera s Max+plus II Tutorial

Universal Asynchronous Receiver- Transmitter (UART)

ASYNCHRONOUS COUNTER CIRCUITS

Digital Fundamentals: A Systems Approach

P U Q Q*

Contents Slide Set 6. Introduction to Chapter 7 of the textbook. Outline of Slide Set 6. An outline of the first part of Chapter 7

Figure 1 shows a simple implementation of a clock switch, using an AND-OR type multiplexer logic.

ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design ALU and Storage Elements

Chapter 3 Unit Combinational

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Experiment 8 Introduction to Latches and Flip-Flops and registers

Solution to Digital Logic )What is the magnitude comparator? Design a logic circuit for 4 bit magnitude comparator and explain it,

Midterm Exam 15 points total. March 28, 2011

Low Power VLSI Circuits and Systems Prof. Ajit Pal Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Efficient Architecture for Flexible Prescaler Using Multimodulo Prescaler

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District DEPARTMENT OF INFORMATION TECHNOLOGY CS 2202 DIGITAL PRINCIPLES AND SYSTEM DESIGN

Long and Fast Up/Down Counters Pushpinder Kaur CHOUHAN 6 th Jan, 2003

Note that none of the above MAY be a VALID ANSWER.

Chapter Contents. Appendix A: Digital Logic. Some Definitions

EECS150 - Digital Design Lecture 9 - CPU Microarchitecture. CMOS Devices

Report on 4-bit Counter design Report- 1, 2. Report on D- Flipflop. Course project for ECE533

EE178 Spring 2018 Lecture Module 5. Eric Crabill

Asynchronous (Ripple) Counters

Sequencing. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Fall,

University of Pennsylvania Department of Electrical and Systems Engineering. Digital Design Laboratory. Lab8 Calculator

Digital Electronics II 2016 Imperial College London Page 1 of 8

Registers and Counters

Chapter 5. Introduction

Registers & Counters. BME208 Logic Circuits Yalçın İŞLER

Module -5 Sequential Logic Design

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

Registers, Register Transfers and Counters Dr. Fethullah Karabiber

ELCT201: DIGITAL LOGIC DESIGN

Dr. Shahram Shirani COE2DI4 Midterm Test #2 Nov 19, 2008

Combinational / Sequential Logic

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

Fall 2000 Chapter 5 Part 1

Sequential Circuits. Sequential Logic. Circuits with Feedback. Simplest Circuits with Feedback. Memory with Cross-coupled Gates.

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

6.S084 Tutorial Problems L05 Sequential Circuits

CSE140L: Components and Design Techniques for Digital Systems Lab. CPU design and PLDs. Tajana Simunic Rosing. Source: Vahid, Katz

Transcription:

Modeling Digital Systems with Verilog Prof. Chien-Nan Liu TEL: 03-4227151 ext:34534 Email: jimmy@ee.ncu.edu.tw 6-1 Composition of Digital Systems Most digital systems can be partitioned into two types of modules: Datapath: perform data-processing operations between registers Controller: determine the sequence of those operations 6-2 1

Register Transfer Operations The movement of the data stored in registers and the processing performed on the data are referred to as register transfer operations Ex: If (K1 = 1) then (R2 R1) 6-3 Multiplexer-Based Transfer When a register receives data from two or more different sources at different times, a multiplexer can be used Ex: If (K1 = 1) then (R0 R1) else if (K2 = 1) then (R0 R2) 6-4 2

Bus-Based Transfer Each register has its own multiplexers May be too complex for large systems Use shared transfer path instead Often called a bus Can have only one source but multiple destinations at a time More hardware-efficient 6-5 Three-State Bus A bus can be constructed with the three-state buffers Many three-state buffer outputs can be connected together Avoid the high-fanin OR in multiplexers Delay time and logic complexity can be reduced The signals can travel in two directions on a three-state bus EN=1: output, EN=0: input Simplify the interconnections three-state register with bidirectional data line 6-6 3

Disadv. of Three-State Bus Bus connection problems? May reduce reliability One and only one active bus driver at a time Limited driving strength Bus floating problems Floating nets with ambiguous logic values Solution: bus keeper or pull up/down resistances ATPG problem FPGA prototyping problem 6-7 Modeling Three-State Registers To declare a bidirectional data port, inout type is used instead of input or output Ex: module TriReg(CLK, Rst, EN, Load, Data); input CLK, Rst, EN, Load; inout Data; reg int_data, Data; separated to ensure correct circuits always @(posedge CLK) begin register if (Rst) int_data = 0; else if (Load) int_data = Data; end always @(int_data or EN) begin if (EN) Data = int_data; else Data = 1`bz; end three-state control endmodule 6-8 4

HDL Modeling for Buses To model the behavior of a three-state bus, tri type is used instead of wire tri: has the same properties of wire but indicates more than one drivers may connect to it Ex: module TriBus(CLK, Rst, E2, E1, E0, L2, L1, L0); input CLK, Rst, E2, E1, E0, L2, L1, L0; tri databus; TriReg R0(CLK, Rst, E0, L0, databus); TriReg R1(CLK, Rst, E1, L1, databus); TriReg R2(CLK, Rst, E2, L2, databus); endmodule all connected together 6-9 Datapaths A typical datapath often consists of: Register file Arithmetic/logic unit (ALU) Shifter (may be implemented in ALU) Status signals that feedback to controller status bits 6-10 5

Arithmetic/Logic Unit ALU = Arithmetic Circuit + Logic Circuit 6-11 Arithmetic Circuit Eight arithmetic functions can be performed by setting the three control signals: S1, S0, Cin. 6-12 6

Logic Circuit 6-13 The Shifter A bidirectional shift register can meet the basic requirement for the shift operations Shift left and shift right One shift operation per clock cycle for shift registers A faster method is often required Combinational shifter can be used instead S=00 : keep unchanged S=01 : shift right S=10 : shift left S=11 : undefined 6-14 7

Barrel Shifter In some datapaths, the data must be shifted more than one bit position in a single clock cycle Barrel shifter is used A barrel shifter with 2 n input and output lines requires 2 n multiplexers and n selection inputs 6-15 Modeling the Barrel Shifter Describe one by one case (select) 2`b00: Y = D; 2`b01: Y = {D[2:0], D[3]}; 2`b10: Y = {D[1:0], D[3:2]}; 2`b10: Y = {D[0], D[3:1]}; endcase Incorrect description case (select) 2`b00: Y = D; 2`b01: Y = D << 1; endcase D3 D2 D1 D0 D2 D1 D0 0 the vacated bits are filled with 0, not really rotate 6-16 8

The Control Unit Two primary types of control units: Programmable Determine the performed operations according to the pre-stored instructions and associated operands Non-programmable Determine the performed operations and their sequence by only its inputs and the status bits 6-17 Design of Control Unit Design of control unit: the most challenging and creative part of digital design Formulate hardware algorithms for achieving required objectives A special flowchart, algorithmic state machine (ASM), is often used to define hardware algorithms Convenient to specify the procedural steps and decision paths with timing relationship Easier to understand Lead directly to hardware realization 6-18 9

Basic Elements of ASM Chart (1/2) The ASM chart contains three basic elements: State box (rectangle shape) Decision box (diamond shape) Conditional output box (oval shape) State box: containing register transfer operations or activated output signals 6-19 Basic Elements of ASM Chart (2/2) Conditional output box: similar to state box but describe the operations after a condition is satisfied Decision box: describe the effect of inputs on the control Two exit paths (true & false) 6-20 10

An Example of ASM Block 6-21 ASM Block ASM chart is constructed from ASM blocks Contains exactly one state box One entrance path n exit paths Every valid input combination defines one exit path No internal feedback 6-22 11

ASM Block with Feedback 6-23 STG to ASM Chart original state transition graph equivalent ASM chart 6-24 12

Timing Considerations Assume positive-edge triggering of all flip-flops in Fig. 8-6 The ASM chart considers the entire block as one unit All operations in the block must occur in the same clock cycle The following operations occur simultaneously after T1 Register A is incremented If E=1, register R is cleared Control transfer to the next state as specified in Fig. 8-7 Figure 8-7 6-25 Binary Multiplication 6-26 13

Serial Binary Multiplier ex: 3 bits for 8 counts datapath controller 6-27 ASM Chart for Multiplier Multiplicand has been in B and multiplier has been in Q Z: detect whether the count P is zero C A Q : A composition register made up of other registers 6-28 14

ASM Chart to Control Circuits Two design approaches are introduced for the control unit: Hardwired control: dedicated circuits for generating the control signals Sequence register and decoder approach One flip-flop per state approach Microprogrammed control: store its binary control values as words in memory Execute the pre-stored microprogram according to the current control address 6-29 Hardwired Control Two primary parts: Generate the control signals Determine what happens next Analyze the required control signals: 6-30 15

The Execution Sequence Determine the execution sequence by removing The information of microoperations All conditional output boxes The decision boxes not affecting the next state This simplified ASM chart is similar to the traditional state diagram 6-31 Sequence Register and Decoder A sequence register to determine the next states Designed from the simplified ASM chart A decoder to generate required control signals for each state 6-32 16

The Final Circuits 6-33 Design with Multiplexers The sequence register and decoder control consists of three components: Flip-flops: hold the binary value Decoder: generates the control outputs Some gates: determine the next state and the values of output signals Can be replaced by multiplexers!! Using multiplexers results in a regular pattern of three levels of components MUXs flip-flops decoder 6-34 17

ASM Chart for the Example Inputs = (Next State) & (Input Conditions) used as MUX selection required conditions to enable this transition 6-35 Implementation with MUXs level 1 level 2 level 3 6-36 18

One Flip-Flop per State Each state is assigned a different flip-flop Flip-flop is 1: currently in its corresponding state Only one flip-flop contains a 1 at any time The single 1 propagates from one flip-flop to another under the control of decision logic Maximum number of flip-flops are used n vs. log 2 n Simplify the decision logic and design procedure Can be directly transformed from the ASM chart 6-37 Transformation Rules (1/2) State box Entry = 1: going into the state Exit = 1: currently in the state Decision box X = 0: send signal to the exit 0 X = 1: send signal to the exit 1 6-38 19

Transformation Rules (2/2) Junction Wired-OR in nature OR all input signals Conditional output box Replaced by a connection only Attached a control line to trigger the output actions 6-39 The Final Circuit should be 1 at initialization 1 2 3 4 : state box : decision box : junction : conditional output Solutions: 1. Use flip-flop with PRESET 2. Add inverters at both its input and output 6-40 20

Verilog Modeling (1/2) 6-41 Verilog Modeling (2/2) 6-42 21

Microprogrammed Control Determine the output actions by only state information (Moore type) 6-43 Modify the ASM Chart No conditional output boxes are allowed!! (replaced by a state box) 6-44 22

Control Signal Analysis 6-45 Microinstruction Format total: 12 bits the four control signals next address for FALSE next address for TRUE 5 possible states require 3 bits for an address 6-46 23

The Final Circuit 6-47 Microprogram Design 6-48 24

Why Pipelined System? Conventional: Max delay = 12ns Clock rate = 83.3 MHz Required 1 clock cycle to finish a operation Pipelined: Max delay = 5ns Clock rate = 200 MHz Required 3 clock cycles (15ns) for a operation Longer latency but higher throughput 6-49 Analogy to Pipelined Operations Can process next operation when current operation is sent to another stage Every worker only finish a part of the product in the assembly line Can have almost n times improvements on total speed if multiple operations are processed 6-50 25

Pipelined Datapath Design the number of stages can be decided by designers registers are inserted between different stages to store the partial results (extra delay will be incurred for storing values in registers) 6-51 Execution in Pipelined Datapath Controller design for piplelined datapath will be more complex!! 6-52 26

store the fetched instruction Pipelined Control store the control signals registers are inserted between each stage in both controller and datapath 6-53 27