Algorithmic State Machines Sorting Signed & Unsigned Data Types

Slides:



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

Sequential-Circuit Building Blocks
CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 3 Khurram Kazi Some of the slides were taken from K Gaj ’ s lecture slides from GMU ’ s VHDL.
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi Some of the slides were taken from K Gaj’s lecture slides from GMU’s.
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.
CS/EE 3700 : Fundamentals of Digital System Design
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 8: Synchronous Sequential Circuits Chapter 8.
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)
Figure A flip-flop with an enable input. D Q Q Q R Clock E 0 1.
Lecture 9 RTL Design Methodology Sorting Example.
CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #17 – Introduction.
1 Sequential Logic Lecture #7. 모바일컴퓨팅특강 2 강의순서 Latch FlipFlop Shift Register Counter.
George Mason University ECE 545 – Introduction to VHDL ECE 545 Lecture 5 Finite State Machines.
CprE / ComS 583 Reconfigurable Computing
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
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.
1 ECE 545 – Introduction to VHDL ECE 545 Lecture 4 Behavioral & Structural Design Styles.
1 ECE 545 – Introduction to VHDL Dataflow Modeling of Combinational Logic Simple Testbenches ECE 656. Lecture 2.
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
ECE 332 Digital Electronics and Logic Design Lab Lab 6 Concurrent Statements & Adders.
Figure ASM chart for the bit counter.. Figure Verilog code for the bit-counting circuit (Part a). module bitcount (Clock, Resetn, LA, s,
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
Digital System Design using VHDL
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VHDL Coding for Synthesis ECE 448 Lecture 12.
Hao Zheng Comp Sci & Eng USF CDA 4253 FPGA System Design Chapter 5 Finite State Machines.
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.
ECE DIGITAL LOGIC LECTURE 21: FINITE STATE MACHINE Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/24/2015.
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.
Fundamentals of Digital System Design Pradondet Nilagupta Lecture 7: Flip-flops, Registers, Counters Chapter 7.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code.
Figure 7.1 Control of an alarm system
Hao Zheng Comp Sci & Eng USF
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
RTL Design Methodology
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
Sequential-Circuit Building Blocks
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Lecture 18 SORTING in Hardware.
VHDL (VHSIC Hardware Description Language)
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.
RTL Design Methodology Transition from Pseudocode & Interface
Behavioral Modeling of Sequential-Circuit Building Blocks
Sequntial-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
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
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.
CprE / ComS 583 Reconfigurable Computing
Sequntial-Circuit Building Blocks
RTL Design Methodology
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
(Sequential-Circuit Building Blocks)
Presentation transcript:

Algorithmic State Machines Sorting Signed & Unsigned Data Types ECE 545 Lecture 10 Algorithmic State Machines Sorting Signed & Unsigned Data Types ECE 545 – Introduction to VHDL

Sources & Required Reading Stephen Brown and Zvonko Vranesic, Fundamentals of Digital Logic with VHDL Design Chapter 8.10 Algorithmic State Machine (ASM) Charts Chapter 10.2.6 Sort Operation Sundar Rajan, Essential VHDL, Chapter 5 Counters and Simple Arithmetic Functions ECE 545 – Introduction to VHDL

Algorithmic State Machine (ASM) Charts ECE 545 – Introduction to VHDL

Algorithmic State Machine representation of a Finite State Machine suitable for FSMs with a larger number of inputs and outputs compared to FSMs expressed using state diagrams and state tables. ECE 545 – Introduction to VHDL

Elements used in ASM charts (1) State name Output signals 0 (False) 1 (True) Condition or actions expression (Moore type) (a) State box (b) Decision box Conditional outputs or actions (Mealy type) (c) Conditional output box ECE 545 – Introduction to VHDL

Elements used in ASM charts (2) State box – represents a state. Equivalent to a node in a state diagram or a row in a state table. Moore type outputs are listed inside of the box. It is customary to write only the name of the signal that has to be asserted in the given state, e.g., z instead of z=1. Also, it might be useful to write an action to be taken, e.g., Count = Count + 1, and only later translate it to asserting a control signal that causes a given action to take place. ECE 545 – Introduction to VHDL

Elements used in ASM charts (3) Decision box – indicates that a given condition is to be tested and the exit path is to be chosen accordingly The condition expression consists of one or more inputs to the FSM. Conditional output box – denotes output signals that are of the Mealy type. The condition that determines whether such outputs are generated is specified in the decision box. ECE 545 – Introduction to VHDL

Moore FSM – Example 1: State diagram C z 1 = ¤ Reset B A w ECE 545 – Introduction to VHDL

ASM Chart for Moore FSM – Example 1 ECE 545 – Introduction to VHDL

Mealy FSM – Example 2: State diagram w = z ¤ 1 B Reset ECE 545 – Introduction to VHDL

ASM Chart for Mealy FSM – Example 2 ECE 545 – Introduction to VHDL

Control Unit - Example 3 ECE 545 – Introduction to VHDL

ASM Chart for Control Unit - Example 3 ECE 545 – Introduction to VHDL

Sorting ECE 545 – Introduction to VHDL

Pseudocode for the sort operation = to k 2 do A R ; j + 1 B if < then end if end for; – ECE 545 – Introduction to VHDL

ASM chart for the sort operation ECE 545 – Introduction to VHDL

Datapath Circuit for the sort operation ECE 545 – Introduction to VHDL

Control Circuit – Part 1 ECE 545 – Introduction to VHDL

ASM chart for the Control Circuit – Part 2 ECE 545 – Introduction to 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 ; ECE 545 – Introduction to 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 ; ECE 545 – Introduction to 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 ; ECE 545 – Introduction to VHDL

Datapath Circuit for the sort operation ECE 545 – Introduction to 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 ; ECE 545 – Introduction to VHDL

Control Circuit – Part 1 ECE 545 – Introduction to VHDL

VHDL code (3) – Control unit signal declarations -- 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; ECE 545 – Introduction to VHDL

Datapath Circuit for the sort operation ECE 545 – Introduction to 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 ; ECE 545 – Introduction to 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 ) E => Bin, Q => B ) ; BltA <= '1' WHEN B < A ELSE '0' ; ABMux <= A WHEN Bout = '0' ELSE B ; DataOut <= (OTHERS => 'Z') WHEN Rd = '0' ELSE ABData ; ECE 545 – Introduction to VHDL

Control Circuit – Part 1 ECE 545 – Introduction to 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 ) E => EJ, L => LJ, R => Ci, Q => Cj ) ; ECE 545 – Introduction to 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' ; ECE 545 – Introduction to VHDL

ASM chart for the Control Circuit – Part 2 ECE 545 – Introduction to 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 S9 => IF s = '1' THEN y <= S9 ; ELSE y <= S1 ; END IF ; END CASE ; END PROCESS ; ECE 545 – Introduction to 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' ; ECE 545 – Introduction to 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' ; EI <= '0' ; END IF; END IF ; WHEN S9 => -- Done is assigned 1 by conditional signal assignment END CASE ; END PROCESS ; END Dataflow ; ECE 545 – Introduction to VHDL

Simulation results for the sort operation (1) Loading the registers and starting sorting ECE 545 – Introduction to VHDL

Simulation results for the sort operation (2) Completing sorting and reading out registers ECE 545 – Introduction to VHDL

Alternative datapath based on tri-state buffers ECE 545 – Introduction to VHDL

Arithmetic mean ECE 545 – Introduction to VHDL

Pseudocode for the mean of k numbers Sum = 0 for i = k - 1 downto 0 do Sum = Sum + Ri end for M = Sum / k ECE 545 – Introduction to VHDL

ASM chart for the mean of k numbers ECE 545 – Introduction to VHDL

Datapath & Control Circuit ECE 545 – Introduction to VHDL

ASM chart for the control circuit ECE 545 – Introduction to VHDL

Schematic with an SRAM block ECE 545 – Introduction to VHDL

Simulation results for the mean circuit ECE 545 – Introduction to VHDL

Clock skew and metastability ECE 545 – Introduction to VHDL

Flip-flop enable – incorrect approach D Q Data Clock E ECE 545 – Introduction to VHDL

Flip-flop enable – correct approach D Q R Clock E 1 ECE 545 – Introduction to VHDL

An H tree clock distribution network ff ECE 545 – Introduction to VHDL

Arithmetic and Relational in Predefined Packages Operators in Predefined Packages ECE 545 – Introduction to VHDL

std_logic_unsigned / std_logic_signed Operand 1 Operand Operand 2 Result +  * std_logic_vector std_logic integer std_logic_vector std_logic integer std_logic_vector ECE 545 – Introduction to VHDL

Different declarations for the same operator - Example Declarations in the package ieee.std_logic.unsigned: function “+” ( L: std_logic_vector; R:std_logic_vector) return std_logic_vector; function “+” ( L: std_logic_vector; R: integer) return std_logic_vector; function “+” ( L: std_logic_vector; R:std_logic) return std_logic_vector; ECE 545 – Introduction to VHDL

Different declarations for the same operator - Example signal count: std_logic_vector(7 downto 0); You can use: count <= count + “0000_0001”; or count <= count + 1; count <= count + ‘1’; ECE 545 – Introduction to VHDL

Signed and unsigned data types signed, unsigned - represent an array of std_logic values (the same as std_logic_vector) - allow a user to indicate which representation unsigned or signed 2’s complement is being used ECE 545 – Introduction to VHDL

std_logic_arith Operand 1 Operand Operand 2 Result +  * signed unsigned integer std_logic +  * signed unsigned integer std_logic signed unsigned std_logic_vector ECE 545 – Introduction to VHDL

std_logic_arith Operand 1 Operand Operand 2 Result > < = >= <= /= signed unsigned integer signed unsigned integer boolean ECE 545 – Introduction to VHDL

numeric_std Operand 1 Operand Operand 2 Result +  * ** / mod signed unsigned integer natural signed unsigned integer natural signed unsigned Not synthesizable unless constant operands or division by a power of 2 ECE 545 – Introduction to VHDL

numeric_std Operand 1 Operand Operand 2 Result > < = >= <= /= signed unsigned integer natural signed unsigned integer natural boolean ECE 545 – Introduction to VHDL

Modulo-11 down-counter (1) library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity downCounter is port ( clk: in std_logic; reset: in std_logic; count: out std_logic_vector(3 downto 0) ); end downCounter; ECE 545 – Introduction to VHDL

Modulo-11 down-counter (2) architecture simple of downCounter is signal countL: unsigned(3 downto 0); signal termCnt: std_logic; begin decrement: process (clk, reset) begin if (reset = '1') then countL <= "1011"; -- Reset to 11 termCnt <= '1'; elsif(clk'event and clk = '1') then if (termCnt = '1') then countL <= "1011"; -- Count rolls over to 11 else countL <= countL - 1; end if; ECE 545 – Introduction to VHDL

Modulo-11 down-counter (3) if (countL = "0001") then -- Terminal count decoded 1 cycle earlier termCnt <= '1'; else termCnt <= '0'; end if; end process; count <= std_logic_vector(countL); end simple; ECE 545 – Introduction to VHDL

Modulo-11 down-counter with to_unsigned architecture simple of downCounter is signal countL: unsigned(3 downto 0); signal termCnt: std_logic; begin decrement: process (clk, reset) begin if (reset = '1') then countL <= to_unsigned(11, 4); -- Reset to 11 termCnt <= '1'; elsif(clk'event and clk = '1') then if (termCnt = '1') then countL <= "1011"; -- Count rolls over to 11 else countL <= countL - 1; end if; ECE 545 – Introduction to VHDL