CprE 583 Reconfigurable Computing

Similar documents
ECE 545 Lecture 12. Datapath vs. Controller. Structure of a Typical Digital System Data Inputs. Required reading. Design of Controllers

CprE 583 Reconfigurable Computing

[VARIABLE declaration] BEGIN. sequential statements

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Lecture 7. Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits. Hardware Description Language)

3 Designing Digital Systems with Algorithmic State Machine Charts

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 6 Combinational and sequential circuits

The University of Alabama in Huntsville ECE Department CPE Midterm Exam February 26, 2003

FSM Components. FSM Description. HDL Coding Methods. Chapter 7: HDL Coding Techniques

Hardware Description Language VHDL (1) Introduction

Sequential Logic - Module 5

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

ELCT 501: Digital System Design

Timing in synchronous systems

Lecture 08 Finite State Machine Design Using VHDL

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

Control and Datapath 8

Summary of FPGA & VHDL

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

EL 310 Hardware Description Languages Midterm

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

VHDL: A Crash Course

Lattice VHDL Training

Digital Systems Design

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

Outline. CPE/EE 422/522 Advanced Logic Design L05. Review: General Model of Moore Sequential Machine. Review: Mealy Sequential Networks.

Synthesis from VHDL. Krzysztof Kuchcinski Department of Computer Science Lund Institute of Technology Sweden

Lecture 12 VHDL Synthesis

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

Using ModelSim to Simulate Logic Circuits in VHDL Designs. 1 Introduction. For Quartus II 13.0

EEL 4783: Hardware/Software Co-design with FPGAs

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. Behavioral Design Style: Registers & Counters.

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

Luleå University of Technology Kurskod SMD152 Datum Skrivtid

VHDL for Synthesis. Course Description. Course Duration. Goals

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

ECEU530. Homework 4 due Wednesday Oct 25. ECE U530 Digital Hardware Synthesis. VHDL for Synthesis with Xilinx. Schedule

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

CCE 3202 Advanced Digital System Design

Concurrent & Sequential Stmts. (Review)

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1. Your name 2/13/2014

Introduction to VHDL #3

Computer-Aided Digital System Design VHDL

VHDL Modeling Behavior from Synthesis Perspective -Part B - EL 310 Erkay Savaş Sabancı University

EITF35: Introduction to Structured VLSI Design

Counters and Simple Design Example

Programable Logic Devices

Digital Design with SystemVerilog

ECE 551: Digital System *

VHDL simulation and synthesis

A bird s eye view on VHDL!

FPGA for Software Engineers

CSC / EE Digital Systems Design. Summer Sample Project Proposal 01

ELE432. ADVANCED DIGITAL DESIGN HACETTEPE UNIVERSITY Designing with VHDL

The University of Alabama in Huntsville ECE Department CPE Final Exam Solution Spring 2004

VHDL. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

Sign here to give permission for your test to be returned in class, where others might see your score:

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

ECE 545 Lecture 5. Data Flow Modeling in VHDL. George Mason University

JUNE, JULY 2013 Fundamentals of HDL (10EC45) PART A

VHDL Examples Mohamed Zaky

HDL Design Cube. Synthesis and VHDL

RTL Design (Using ASM/SM Chart)

VHDL in 1h. Martin Schöberl

CCE 3202 Advanced Digital System Design

Finite State Machines

Contents. Chapter 9 Datapaths Page 1 of 28

Outline. Finite State Machine. 2. Representation of FSM. 1. Overview on FSM

Problem Set 10 Solutions

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

Introduction to VHDL. Yvonne Avilés Colaboration: Irvin Ortiz Flores Rapid System Prototyping Laboratory (RASP) University of Puerto Rico at Mayaguez

The block diagram representation is given below: The output equation of a 2x1 multiplexer is given below:

Today. Comments about assignment Max 1/T (skew = 0) Max clock skew? Comments about assignment 3 ASICs and Programmable logic Others courses

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

Chapter 6 Combinational-Circuit Building Blocks

Creating Safe State Machines

Using Library Modules in VHDL Designs

Experiment 8 Introduction to VHDL

FPGA BASED SYSTEM DESIGN. Dr. Tayab Din Memon Lecture 9 & 10 : Combinational and Sequential Logic

State Machine Descriptions

COE 405 Design Methodology Based on VHDL

Using Library Modules in VHDL Designs. 1 Introduction. For Quartus II 12.1

VHDL: RTL Synthesis Basics. 1 of 59

Using Library Modules in VHDL Designs

קורס VHDL for High Performance. VHDL

Multi-valued Logic. Standard Logic IEEE 1164 Type std_ulogic is ( U, uninitialized

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4)

Overview. Ram vs Register. Register File. Introduction to Structured VLSI Design. Recap Operator Sharing FSMD Counters.

Field Programmable Gate Array

Inthis lecture we will cover the following material:

Modeling Complex Behavior

2/14/2016. Hardware Synthesis. Midia Reshadi. CE Department. Entities, Architectures, and Coding.

EEL 4712 Digital Design Test 1 Spring Semester 2008

Transcription:

Recap 4:1 Multiplexer CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #18 VHDL for Synthesis I LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux4to1 IS PORT ( w0, w1, w2, w3 : IN STD_LOGIC ; s : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ; f : OUT STD_LOGIC ) ; END mux4to1 ; ARCHITECTURE dataflow OF mux4to1 IS WITH s SELECT f <= w0 WHEN "00", w1 WHEN "01", w2 WHEN "10", w3 WHEN OTHERS ; END dataflow ; Lect-18.2 Recap N-bit Register with Reset ENTITY regn IS GENERIC ( N : INTEGER := 16 ) ; PORT ( D : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; Resetn, Clock : IN STD_LOGIC ; Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ; END regn ; ARCHITECTURE Behavior OF regn IS PROCESS ( Resetn, Clock ) IF Resetn = '0' THEN Q <= (OTHERS => '0') ; ELSIF Clock'EVENT AND Clock = '1' THEN Q <= D ; END PROCESS ; END Behavior ; N Resetn N D Q Clock regn Recap 4-bit Up-Counter with Reset ARCHITECTURE Behavior OF upcount IS SIGNAL Count : STD_LOGIC_VECTOR (3 DOWNTO 0) ; PROCESS ( Clock, Resetn ) IF Resetn = '0' THEN Count <= "0000" ; ELSIF (Clock'EVENT AND Clock = '1') THEN IF Enable = '1' THEN Count <= Count + 1 ; Enable END PROCESS ; Q Q <= Count ; Clock END Behavior ; Resetn 4 upcount Lect-18.3 Lect-18.4 Design Exercise Design a simple 32-bit CPU Requirements Three instruction types: load/store, register ALU, branch-if-equal 8 32-bit registers ALU operations: ADD, SUB, OR, XOR, AND, CMP Memory operations: load word, store word Components Instruction memory / decode Register file ALU Data memory Other control Outline Recap Finite State Machines Moore Machines Mealy Machines FSMs in VHDL State Encoding Example Systems Serial Adder Arbiter Circuit Lect-18.5 Lect-18.6 1

Structure of a Typical Digital System Execution Unit (Datapath) Data Inputs Execution Unit (Datapath) Control Signals Control Inputs Control Unit (Control) Provides all necessary resources and interconnects among them to perform specified task Examples of resources Adders, multipliers, registers, memories, etc. Data Outputs Control Outputs Lect-18.7 Lect-18.8 Control Unit (Control) Controls data movements in operational circuit by switching multiplexers and enabling or disabling resources Follows some program or schedule Often implemented as Finite State Machine or collection of Finite State Machines Finite State Machines (FSMs) Any circuit with memory is a Finite State Machine Even computers can be viewed as huge FSMs Design of FSMs involves Defining states Defining transitions between states Optimization / minimization Above approach is practical for small FSMs only Lect-18.9 Lect-18.10 Moore FSM Output is a function of present state only Inputs clock Next State Next State function Present State Register Present State Mealy FSM Output is a function of a present state and inputs Inputs clock Next State Next State function Present State Register Present State Output function Outputs Output function Outputs Lect-18.11 Lect-18.12 2

Moore Machine Mealy Machine transition condition 1 transition condition 1 / output 1 state 1 / output 1 transition condition 2 state 2 / output 2 state 1 state 2 transition condition 2 / output 2 Lect-18.13 Lect-18.14 Moore vs. Mealy FSM Moore and Mealy FSMs can be functionally equivalent Equivalent Mealy FSM can be derived from Moore FSM and vice versa Mealy FSM has richer description and usually requires smaller number of states Smaller circuit area Moore vs. Mealy FSM (cont.) Mealy FSM computes outputs as soon as inputs change Mealy FSM responds one clock cycle sooner than equivalent Moore FSM Moore FSM has no combinational path between inputs and outputs Moore FSM is more likely to have a shorter critical path Lect-18.15 Lect-18.16 Moore FSM Example Moore FSM that recognizes sequence 10 Mealy FSM Example Mealy FSM that recognizes sequence 10 0 1 0 1 S0 / 0 S1 / 0 1 S2 / 1 0 / 0 1 / 0 1 / 0 S0 S1 Meaning of states: S0: No elements of the sequence 0 S1: 1 S2: 10 Meaning of states: S0: No elements of the sequence 0 / 1 S1: 1 Lect-18.17 Lect-18.18 3

Mealy FSM Example (cont.) FSMs in VHDL clock input Moore Mealy 0 1 0 0 0 S0 S1 S2 S0 S0 S0 S1 S0 S0 S0 Finite State Machines can be easily described with processes Synthesis tools understand FSM description if certain rules are followed State transitions should be described in a process sensitive to clock and asynchronous signals only Outputs described as concurrent statements outside the process Lect-18.19 Lect-18.20 Moore FSM Example VHDL TYPE state IS (S0, S1, S2); SIGNAL Moore_state: state; U_Moore: PROCESS (clock, ) IF( = 1 ) THEN Moore_state <= S0; ELSIF (clock = 1 AND clock event) THEN CASE Moore_state IS WHEN S0 => IF input = 1 THEN Moore_state <= S1; Moore_state <= S0; Moore FSM Example VHDL (cont.) WHEN S1 => IF input = 0 THEN Moore_state <= S2; Moore_state <= S1; WHEN S2 => IF input = 0 THEN Moore_state <= S0; Moore_state <= S1; END CASE; END PROCESS; Output <= 1 WHEN Moore_state = S2 0 ; Lect-18.21 Lect-18.22 Mealy FSM Example VHDL TYPE state IS (S0, S1); SIGNAL Mealy_state: state; U_Mealy: PROCESS(clock, ) IF( = 1 ) THEN Mealy_state <= S0; ELSIF (clock = 1 AND clock event) THEN CASE Mealy_state IS WHEN S0 => IF input = 1 THEN Mealy_state <= S1; Mealy_state <= S0; Mealy FSM Example VHDL (cont.) WHEN S1 => IF input = 0 THEN Mealy_state <= S0; Mealy_state <= S1; END CASE; END PROCESS; Output <= 1 WHEN (Mealy_state = S1 AND input = 0 ) 0 ; Lect-18.23 Lect-18.24 4

State Encoding Problem State encoding can have a big influence on optimality of the FSM implementation No methods other than checking all possible encodings are known to produce optimal circuit Feasible for small circuits only Using enumerated types for states in VHDL leaves encoding problem for synthesis tool Types of State Encodings Binary (Sequential) States encoded as consecutive binary numbers Small number of used flip-flops Potentially complex transition functions leading to slow implementations One-Hot only one bit is active Number of used flip-flops as big as number of states Simple and fast transition functions Preferable coding technique in FPGAs Lect-18.25 Lect-18.26 Types of State Encodings (cont.) Manual State Assignment State S0 S1 S2 S3 S4 S5 S6 S7 Binary Code 000 001 010 011 100 101 110 111 One-Hot Code 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 (ENTITY declaration not shown) ARCHITECTURE Behavior OF simple IS TYPE State_type IS (A, B, C) ; ATTRIBUTE ENUM_ENCODING : STRING ; ATTRIBUTE ENUM_ENCODING OF State_type : TYPE IS "00 01 11" ; SIGNAL y_present, y_next : State_type ; cont... Lect-18.27 Lect-18.28 Manual State Assignment (cont.) Serial Adder Block Diagram ARCHITECTURE Behavior OF simple IS SUBTYPE ABC_STATE is STD_LOGIC_VECTOR(1 DOWNTO 0); CONSTANT A : ABC_STATE := "00" ; CONSTANT B : ABC_STATE := "01" ; CONSTANT C : ABC_STATE := "11" ; SIGNAL y_present, y_next : ABC_STATE; PROCESS ( w, y_present ) CASE y_present IS WHEN A => IF w = '0' THEN y_next <= A ; y_next <= B ; cont Clock A Shift register Shift register B a b Adder FSM s Shift register Sum = A + B Lect-18.29 Lect-18.30 5

Serial Adder FSM Serial Adder FSM State Table Reset ( ab s ) 11 0 00 0 01 1 10 1 G 00 1 H 01 0 10 0 11 1 Present Next state Output s state ab =00 01 10 11 00 01 10 11 G G G G H 0 1 1 0 H G H H H 1 0 0 1 G: H: carry-in = 0 carry-in = 1 Lect-18.31 Lect-18.32 Serial Adder Entity Declaration Serial Adder Architecture (2) 10 ARCHITECTURE Behavior OF serial IS 1 LIBRARY ieee ; 2 USE ieee.std_logic_1164.all ; 3 ENTITY serial IS 4 GENERIC ( length : INTEGER := 8 ) ; 5 PORT ( Clock : IN STD_LOGIC ; 6 Reset : IN STD_LOGIC ; 7 A, B : IN STD_LOGIC_VECTOR(length-1 DOWNTO 0) ; 8 Sum : BUFFER STD_LOGIC_VECTOR(length-1 DOWNTO 0)); 9 END serial ; 11 COMPONENT shiftrne 12 GENERIC ( N : INTEGER := 4 ) ; 13 PORT ( R : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; 14 L, E, w : IN STD_LOGIC ; 15 Clock : IN STD_LOGIC ; 16 Q : BUFFER STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ; 17 END COMPONENT ; 18 SIGNAL QA, QB, Null_in : STD_LOGIC_VECTOR(length-1 DOWNTO 0) ; 19 SIGNAL s, Low, High, Run : STD_LOGIC ; 20 SIGNAL Count : INTEGER RANGE 0 TO length ; 21 TYPE State_type IS (G, H) ; 22 SIGNAL y : State_type ; Lect-18.33 Lect-18.34 Serial Adder Architecture (3) Serial Adder Architecture (4) 23 24 Low <= '0' ; High <= '1' ; 25 ShiftA: shiftrne GENERIC MAP (N => length) 26 PORT MAP ( A, Reset, High, Low, Clock, QA ) ; 27 ShiftB: shiftrne GENERIC MAP (N => length) 28 PORT MAP ( B, Reset, High, Low, Clock, QB ) ; 29 AdderFSM: PROCESS ( Reset, Clock ) 30 31 IF Reset = '1' THEN 32 y <= G ; 33 ELSIF Clock'EVENT AND Clock = '1' THEN 34 CASE y IS 35 WHEN G => 36 IF QA(0) = '1' AND QB(0) = '1' THEN y <= H ; 37 y <= G ; 38 39 WHEN H => 40 IF QA(0) = '0' AND QB(0) = '0' THEN y <= G ; 41 y <= H ; 42 43 END CASE ; 44 45 END PROCESS AdderFSM ; Lect-18.35 Lect-18.36 6

Serial Adder Architecture (5) Serial Adder Architecture (5) 46 WITH y SELECT 47 s <= QA(0) XOR QB(0) WHEN G, 48 NOT ( QA(0) XOR QB(0) ) WHEN H ; 49 Null_in <= (OTHERS => '0') ; 50 ShiftSum: shiftrne GENERIC MAP ( N => length ) 51 PORT MAP ( Null_in, Reset, Run, s, Clock, Sum ) ; 52 Stop: PROCESS 53 54 WAIT UNTIL (Clock'EVENT AND Clock = '1') ; 55 IF Reset = '1' THEN 56 Count <= length ; 57 ELSIF Run = '1' THEN 58 Count <= Count -1 ; 59 60 END PROCESS ; 61 Run <= '0' WHEN Count = 0 '1' ; -- stops counter and ShiftSum 62 END Behavior ; Lect-18.37 Lect-18.38 Serial Adder - Mealy FSM Circuit Arbiter Circuit a b Full adder Y D carry-out Q y s r1 g1 Clock Q r2 Arbiter g2 Reset r3 g3 clock Lect-18.39 Lect-18.40 Arbiter Moore State Diagram Grant Signals VHDL Code xx0 x0x Reset 0xx Idle 000 1xx gnt1 g 1 = 1 1xx gnt2 g 2 = 1 x1x gnt3 g 3 = 1 xx1 01x 001... PROCESS( y ) g(1) <= '0' ; g(2) <= '0' ; g(3) <= '0' ; IF y = gnt1 THEN g(1) <= '1' ; ELSIF y = gnt2 THEN g(2) <= '1' ; ELSIF y = gnt3 THEN g(3) <= '1' ; END PROCESS ; END Behavior ; Lect-18.41 Lect-18.42 7

Arbiter Simulation Results Lect-18.43 8