George Mason University ECE 448 – FPGA and ASIC Design with VHDL ECE 448 Lecture 12 Sorting Example.

Slides:



Advertisements
Similar presentations
Lecture 16 PicoBlaze Instruction Set & Assembler Directives
Advertisements

IN2305-II Embedded Programming Lecture 2: Digital Logic.
Survey of Reconfigurable Logic Technologies
George Mason University Timing Analysis ECE 545 Lecture 8a.
Sequential-Circuit Building Blocks
Algorithmic State Machine (ASM) Charts
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts,
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448.
Simple Testbenches Behavioral Modeling of Combinational Logic
ECE 448 – FPGA and ASIC Design with VHDL Lecture 15 External SRAM.
ECE 545 Lecture 7 Behavioral Modeling of Sequential-Circuit Building Blocks Mixing Design Styles Modeling of Circuits with a Regular Structure.
CS/EE 3700 : Fundamentals of Digital System Design
Data Flow Modeling of Combinational Logic Simple Testbenches
CoE3DJ4 Digital Systems Design Register transfers, sequencing and control (from chapters 7 and 8 of Mano and Kime)
Lecture 9 RTL Design Methodology Sorting Example.
ECE 449: Computer Design Lab Coordinator: Kris Gaj TAs: Tuesday session: Pawel Chodowiec Thursday session: Nghi Nguyen.
1/8/ L20 Project Step 8 - Data Path Copyright Joanne DeGroat, ECE, OSU1 State Machine Design with an HDL A methodology that works for documenting.
George Mason University Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts ECE 545 Lecture 14.
1 ECE 545—Digital System Design with VHDL Lecture 6 Behavioral VHDL Coding (for Synthesis): Finite State Machines and ASMs 9/30/08.
George Mason University ECE 449 – Computer Design Lab Welcome to the ECE 449 Computer Design Lab Spring 2005.
George Mason University ECE 449 – Computer Design Lab Welcome to the ECE 449 Computer Design Lab Spring 2004.
George Mason University Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code ECE 448 Lecture 6.
Mixed Style RTL Modeling
Lecture 9 RTL Design Methodology. Structure of a Typical Digital System Datapath (Execution Unit) Controller (Control Unit) Data Inputs Data Outputs Control.
Figure ASM chart for the bit counter.. Figure Verilog code for the bit-counting circuit (Part a). module bitcount (Clock, Resetn, LA, s,
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 6 Mixing Design Styles.
George Mason University Controllers for Keccak_F and AES ECE 545 Lecture 11 Addendum.
Algorithmic State Machines Sorting Signed & Unsigned Data Types
1 ECE 545 – Introduction to VHDL Algorithmic State Machines Sorting Example ECE 656 Lecture 8.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
George Mason University Design of Controllers using Algorithmic State Machine (ASM) Charts ECE 545 Lecture 12.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
George Mason University Finite State Machines Refresher ECE 545 Lecture 11.
Supplement on Verilog for Algorithm State Machine Chart
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
RTL Design Methodology
RTL Design Methodology
Sequential-Circuit Building Blocks
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Lecture 18 PicoBlaze I/O Interface
RTL Design Methodology
Finite State Machines Experiment 4 Introduction
Chapter 2: Digital Image Fundamentals
Lecture 18 SORTING in Hardware.
Chapter 2: Digital Image Fundamentals
ECE 448 Lecture 13 Multipliers Timing Parameters
ECE 545 Lecture 12 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
ECE 545 Lecture 10 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
ECE 545 Lecture 9 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
ECE 545 Lecture 11 Design of Controllers Finite State Machines and Algorithmic State Machine (ASM) Charts.
Implementing Combinational
RTL Design Methodology Transition from Pseudocode & Interface
Sequntial-Circuit Building Blocks
Chapter 2: Getting Started
Modeling of Circuits with a Regular Structure
RTL Design Methodology
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code.
RTL Design Methodology
RTL Design Methodology
RTL Design Methodology
RTL Design Methodology Transition from Pseudocode & Interface
RTL Design Methodology
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
RTL Design Methodology
RTL Design Methodology
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Sequntial-Circuit Building Blocks
RTL Design Methodology
Presentation transcript:

George Mason University ECE 448 – FPGA and ASIC Design with VHDL ECE 448 Lecture 12 Sorting Example

2ECE 448 – FPGA and ASIC Design with VHDL Required reading S. Brown and Z. Vranesic, Fundamentals of Digital Logic with VHDL Design Chapter 8.10, Algorithmic State Machine (ASM) Charts Chapter Sort Operation

3ECE 448 – FPGA and ASIC Design with VHDL Sorting

4ECE 448 – FPGA and ASIC Design with VHDL Pseudocode for the sort operation for i=0 to k2 do A=R i ; for j=i+1 to k1 do B=R j ; if B<A then R i =B ; R j =A ; A=R i ; end if; end for; – –

5ECE 448 – FPGA and ASIC Design with VHDL Structure of a Typical Digital System Execution Unit (Datapath) Control Unit (Control) Data Inputs Data Outputs Control Inputs Control Outputs Control Signals

6ECE 448 – FPGA and ASIC Design with VHDL Hardware Design with RTL VHDL Pseudocode Execution UnitControl Unit Block diagram Block diagram ASM VHDL code

7ECE 448 – FPGA and ASIC Design with VHDL VHDL code (1) – Entity declaration LIBRARY ieee; USE ieee.std_logic_1164.all; USE work.components.all ; ENTITY sort IS GENERIC ( N : INTEGER := 4 ) ; PORT (Clock, Resetn: IN STD_LOGIC ; s, WrInit, Rd: IN STD_LOGIC ; DataIn : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; RAdd : IN INTEGER RANGE 0 TO 3 ; DataOut : BUFFER STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; Done : BUFFER STD_LOGIC ) ; END sort ;

8ECE 448 – FPGA and ASIC Design with VHDL Package components (1) LIBRARY ieee ; USE ieee.std_logic_1164.all ; PACKAGE components IS -- n-bit register with enable COMPONENT regne GENERIC ( N : INTEGER := 4 ) ; PORT (R : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; Resetn : IN STD_LOGIC ; E : IN STD_LOGIC ; Clock : IN STD_LOGIC ; Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ; END COMPONENT ;

9ECE 448 – FPGA and ASIC Design with VHDL Package components (2) -- up-counter that counts from 0 to modulus-1 COMPONENT upcount GENERIC ( modulus : INTEGER := 8 ) ; PORT ( Resetn : IN STD_LOGIC ; Clock: IN STD_LOGIC ; E: IN STD_LOGIC ; L: IN STD_LOGIC ; R : IN INTEGER RANGE 0 TO modulus-1 ; Q : BUFFER INTEGER RANGE 0 TO modulus-1 ) ; END COMPONENT ; END components ;

10ECE 448 – FPGA and ASIC Design with VHDL VHDL code (2) – Datapath signal declarations ARCHITECTURE Dataflow OF sort IS -- datapath data buses TYPE RegArray IS ARRAY(3 DOWNTO 0) OF STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; SIGNAL R : RegArray; SIGNAL RData : STD_LOGIC_VECTOR(N-1 DOWNTO 0); SIGNAL ABData : STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; SIGNAL A, B : STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; SIGNAL ABMux : STD_LOGIC_VECTOR(N-1 DOWNTO 0); -- datapath control signals SIGNAL Rin : STD_LOGIC_VECTOR(3 DOWNTO 0) ; SIGNAL IMux : INTEGER RANGE 0 TO 3 ; SIGNAL Ain, Bin : STD_LOGIC ; SIGNAL Aout, Bout : STD_LOGIC ; SIGNAL BltA : STD_LOGIC ;

11ECE 448 – FPGA and ASIC Design with VHDL -- control unit Part 1 SIGNAL Zero : INTEGER RANGE 3 DOWNTO 0 ; SIGNAL Ci, Cj: INTEGER RANGE 0 TO 3 ; SIGNAL CMux : INTEGER RANGE 0 TO 3 ; SIGNAL LI, LJ: STD_LOGIC ; SIGNAL EI, EJ: STD_LOGIC ; SIGNAL zi, zj : STD_LOGIC ; SIGNAL Csel : STD_LOGIC ; SIGNAL Int: STD_LOGIC ; SIGNAL Wr: STD_LOGIC ; -- control unit Part 2 TYPE State_type IS ( S1, S2, S3, S4, S5, S6, S7, S8, S9 ); SIGNAL y : State_type; VHDL code (3) – Control unit signal declarations

12ECE 448 – FPGA and ASIC Design with VHDL VHDL code (4) - Datapath BEGIN RData <= ABMux WHEN WrInit = '0' ELSE DataIn ; GenReg: FOR i IN 0 TO 3 GENERATE Reg: regne GENERIC MAP ( N => N ) PORT MAP ( R => RData, Resetn => Resetn, E => Rin(i), Clock => Clock, Q => R(i) ) ; END GENERATE ; WITH IMux Select ABData <= R(0) WHEN 0, R(1) WHEN 1, R(2) WHEN 2, R(3) WHEN OTHERS ;

13ECE 448 – FPGA and ASIC Design with VHDL VHDL code (5) - Datapath RegA: regne GENERIC MAP ( N => N ) PORT MAP ( R => ABData, Resetn => Resetn, E => Ain, Clock => Clock, Q => A ) ; RegB: regne GENERIC MAP ( N => N ) PORT MAP ( R => ABData, Resetn => Resetn, E => Bin, Clock => Clock, Q => B ) ; BltA <= '1' WHEN B < A ELSE '0' ; ABMux <= A WHEN Bout = '0' ELSE B ; DataOut 'Z') WHEN Rd = '0' ELSE ABData ;

14ECE 448 – FPGA and ASIC Design with VHDL VHDL code (6) – Control Unit Part 1 Zero <= 0 ; OuterLoop: upcount GENERIC MAP ( modulus => 4 ) PORT MAP ( Resetn => Resetn, Clock => Clock, E => EI, L => LI, R => Zero, Q => Ci ) ; InnerLoop: upcount GENERIC MAP ( modulus => 4 ) PORT MAP ( Resetn => Resetn, Clock => Clock, E => EJ, L => LJ, R => Ci, Q => Cj ) ;

15ECE 448 – FPGA and ASIC Design with VHDL VHDL code (7) – Control Unit Part 1 CMux <= Ci WHEN Csel = '0' ELSE Cj ; IMux <= Cmux WHEN Int = '1' ELSE Radd ; RinDec: PROCESS ( WrInit, Wr, IMux ) BEGIN IF (WrInit OR Wr) = '1' THEN CASE IMux IS WHEN 0 =>Rin <= "0001" ; WHEN 1 =>Rin <= "0010" ; WHEN 2 =>Rin <= "0100" ; WHEN OTHERS=>Rin <= "1000" ; END CASE ; ELSE Rin <= "0000" ; END IF ; END PROCESS ; Zi <= '1' WHEN Ci = 2 ELSE '0' ; Zj <= '1' WHEN Cj = 3 ELSE '0' ;

16ECE 448 – FPGA and ASIC Design with VHDL VHDL code (8) – Control Unit Part 2 FSM_transitions: PROCESS ( Resetn, Clock ) BEGIN IF Resetn = '0' THEN y <= S1 ; ELSIF (Clock'EVENT AND Clock = '1') THEN CASE y IS WHEN S1 => IF S = '0' THEN y <= S1 ; ELSE y <= S2 ; END IF ; WHEN S2 => y <= S3 ; WHEN S3 => y <= S4 ; WHEN S4 => y <= S5 ; WHEN S5 => IF BltA = '1' THEN y <= S6 ; ELSE y <= S8 ; END IF ; WHEN S6 => y <= S7 ; WHEN S7 => y <= S8 ; WHEN S8 => IF zj = '0' THEN y <= S4 ; ELSIF zi = '0' THEN y <= S2 ; ELSE y <= S9 ; END IF ; WHEN OTHERS => IF s = '1' THEN y <= S9 ; ELSE y <= S1 ; END IF ; END CASE ; END IF ; END PROCESS ;

17ECE 448 – FPGA and ASIC Design with VHDL VHDL code (9) – Control Unit Part 2 -- define the outputs generated by the FSM Int <= '0' WHEN y = S1 ELSE '1' ; Done <= '1' WHEN y = S9 ELSE '0' ; FSM_outputs: PROCESS ( y, zi, zj ) BEGIN LI <= '0' ; LJ <= '0' ; EI <= '0' ; EJ <= '0' ; Csel <= '0' ; Wr <= '0'; Ain <= '0' ; Bin <= '0' ; Aout <= '0' ; Bout <= '0' ; CASE y IS WHEN S1 => LI <= '1' ; EI <= '1' ; WHEN S2 => Ain <= '1' ; LJ <= '1' ; EJ <= '1' ; WHEN S3 => EJ <= '1' ; WHEN S4 => Bin <= '1' ; Csel <= '1' ; WHEN S5 => -- no outputs asserted in this state WHEN S6 => Csel <= '1' ; Wr <= '1' ; Aout <= '1' ; WHEN S7 => Wr <= '1' ; Bout <= '1' ;

18ECE 448 – FPGA and ASIC Design with VHDL VHDL code (10) – Control Unit Part 2 WHEN S8 => Ain <= '1' ; IF zj = '0' THEN EJ <= '1' ; ELSE EJ <= '0' ; IF zi = '0' THEN EI <= '1' ; ELSE EI <= '0' ; END IF; WHEN OTHERS => -- Done is assigned 1 by conditional signal assignment END CASE ; END PROCESS ; END Dataflow ;

19ECE 448 – FPGA and ASIC Design with VHDL Simulation results for the sort operation (1) Loading the registers and starting sorting

20ECE 448 – FPGA and ASIC Design with VHDL Simulation results for the sort operation (2) Completing sorting and reading out registers