ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.

Slides:



Advertisements
Similar presentations
1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
Advertisements

Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
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
George Mason University Modeling of Arithmetic Circuits ECE 545 Lecture 7.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
Data Flow Modeling of Combinational Logic Simple Testbenches
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
A.7 Concurrent Assignment Statements Used to assign a value to a signal in an architecture body. Four types of concurrent assignment statements –Simple.
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #17 – Introduction.
ENG241 Digital Design Week #4 Combinational Logic Design.
VHDL for Combinational Circuits. VHDL We Know Simple assignment statements –f
1 ECE 545 – Introduction to VHDL Dataflow Modeling of Combinational Logic Simple Testbenches ECE 656. Lecture 2.
ECE 332 Digital Electronics and Logic Design Lab Lab 6 Concurrent Statements & Adders.
George Mason University Data Flow Modeling in VHDL ECE 545 Lecture 7.
9/9/2006DSD,USIT,GGSIPU1 Concurrent vs Sequential Combinational vs Sequential logic –Combinational logic is that in which the output of the circuit depends.
CS/EE 3700 : Fundamentals of Digital System Design
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches Concurrent Statements & Adders.
ECOM 4311—Digital System Design with VHDL
Data Flow Modeling in VHDL
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VHDL Coding for Synthesis ECE 448 Lecture 12.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
CDA 4253 FPGA System Design Behavioral modeling of Combinational Circuits Hao Zheng Dept of Comp Sci & Eng USF.
ECE 448 – FPGA and ASIC Design with VHDL George Mason University ECE 448 Lab 1 Implementing Combinational Logic in VHDL.
VHDL 표현방식.
George Mason University Data Flow Modeling of Combinational Logic ECE 545 Lecture 5.
Data Flow and Behavioral Modeling in VHDL 1 MS EMBEDDED SYSTEMS.
George Mason University ECE 545 – Introduction to VHDL Data Flow & Structural Modeling of Combinational Logic ECE 545 Lecture 2.
Combinational logic circuit
Basic Language Concepts
Describing Combinational Logic Using Processes
ENG2410 Digital Design “Combinational Logic Design”
Dataflow Style Combinational Design with VHDL
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
IAS 0600 Digital Systems Design
Sequential-Circuit Building Blocks
CHAPTER 10 Introduction to VHDL
VHDL VHSIC Hardware Description Language VHSIC
Review of Aldec Active HDL Implementing Combinational
VHDL Hardware Description Language
ECE 448 Lecture 6 Modeling of Circuits with a Regular Structure Aliases, Constants, Packages Mixing Design Styles ECE 448 – FPGA and ASIC Design with.
ECE 448 Lab 1 Developing Effective Testbenches
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
Data Flow Modeling of Combinational Logic
VHDL (VHSIC Hardware Description Language)
VHDL Structural Architecture
Concurrent vs Sequential
Chapter 5 – Number Representation and Arithmetic Circuits
Behavioral Modeling of Sequential-Circuit Building Blocks
ECE 448 Lab 1 Developing Effective Testbenches
Sequntial-Circuit Building Blocks
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
ECE 331 – Digital System Design
Data Flow Description of Combinational-Circuit Building Blocks
ECE 448 Lab 1 Developing Effective Testbenches
Modeling of Circuits with a Regular Structure
Data Flow Description of Combinational-Circuit Building Blocks
ECE 448 Lecture 4 Modeling of Circuits with a Regular Structure Constants, Aliases, Packages ECE 448 – FPGA and ASIC Design with VHDL.
Modeling of Circuits with a Regular Structure
ECE 545 Lecture 5 Simple Testbenches.
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.
Modeling of Circuits with Regular Structure
CprE / ComS 583 Reconfigurable Computing
Sequntial-Circuit Building Blocks
Digital Logic with VHDL
(Carry Lookahead Adder)
(Simple Testbenches & Arithmetic Operations)
Presentation transcript:

ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL

Reading P. Chu, FPGA Prototyping by VHDL Examples Required P. Chu, FPGA Prototyping by VHDL Examples Chapter 3, RT-level combinational circuit Sections 3.1, 3.2, 3.3, 3.6, 3.7.1, 3.7.3. Recommended S. Brown and Z. Vranesic, Fundamentals of Digital Logic with VHDL Design Chapter 6, Combinational-Circuit Building Blocks Chapter 5.5, Design of Arithmetic Circuits Using CAD Tools ECE 448 – FPGA and ASIC Design with VHDL

Types of VHDL Description (Modeling Styles) ECE 448 – FPGA and ASIC Design with VHDL

Types of VHDL Description VHDL Descriptions Testbenches dataflow structural behavioral Concurrent statements Components and interconnects Sequential statements Registers State machines Instruction decoders Subset most suitable for synthesis ECE 448 – FPGA and ASIC Design with VHDL

Synthesizable VHDL VHDL code synthesizable Dataflow VHDL VHDL code ECE 448 – FPGA and ASIC Design with VHDL

Concurrent Statements Data-Flow VHDL Concurrent Statements concurrent signal assignment () conditional concurrent signal assignment (when-else) selected concurrent signal assignment (with-select-when) ECE 448 – FPGA and ASIC Design with VHDL

Concurrent signal assignment <= target_signal <= expression; ECE 448 – FPGA and ASIC Design with VHDL

Conditional concurrent signal assignment When - Else target_signal <= value1 when condition1 else value2 when condition2 else . . . valueN-1 when conditionN-1 else valueN; ECE 448 – FPGA and ASIC Design with VHDL

Selected concurrent signal assignment With –Select-When with choice_expression select target_signal <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N; ECE 448 – FPGA and ASIC Design with VHDL

Modeling Wires and Buses ECE 448 – FPGA and ASIC Design with VHDL

Signals a b SIGNAL a : STD_LOGIC; SIGNAL b : STD_LOGIC_VECTOR(7 DOWNTO 0); a 1 wire b bus 8 ECE 448 – FPGA and ASIC Design with VHDL

Merging wires and buses 4 10 b 5 d = a || b || c c SIGNAL a: STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL b: STD_LOGIC_VECTOR(4 DOWNTO 0); SIGNAL c: STD_LOGIC; SIGNAL d: STD_LOGIC_VECTOR(9 DOWNTO 0); d <= a & b & c; ECE 448 – FPGA and ASIC Design with VHDL

Splitting buses a = d9..6 d b = d5..1 c = d0 4 10 d b = d5..1 5 c = d0 SIGNAL a: STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL b: STD_LOGIC_VECTOR(4 DOWNTO 0); SIGNAL c: STD_LOGIC; SIGNAL d: STD_LOGIC_VECTOR(9 DOWNTO 0); a <= d(9 downto 6); b <= d(5 downto 1); c <= d(0); ECE 448 – FPGA and ASIC Design with VHDL

Combinational-Circuit Building Blocks ECE 448 – FPGA and ASIC Design with VHDL

Fixed Shifters & Rotators ECE 448 – FPGA and ASIC Design with VHDL

Fixed Logical Shift Right in VHDL SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0); A(3) A(2) A(1) A(0) 4 A A >>1 C L Internal signals are from DUT. Main process may be split into main process. I.e. one to drive clk, rst and other for test vectors. Many architectures can be tested by inserting more for DUT:TestComp use entity work.TestComp(archName) statmetns “work” is the name of the library that “TestComp” is being compiled to. The “DUT” tag is required. C 4 ‘0’ A(3) A(2) A(1) C = '0' & A(3 downto 1); ECE 448 – FPGA and ASIC Design with VHDL

Fixed Arithmetic Shift Right in VHDL SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0); A(3) A(2) A(1) A(0) 4 A A >>1 C A Internal signals are from DUT. Main process may be split into main process. I.e. one to drive clk, rst and other for test vectors. Many architectures can be tested by inserting more for DUT:TestComp use entity work.TestComp(archName) statmetns “work” is the name of the library that “TestComp” is being compiled to. The “DUT” tag is required. C 4 A(3) A(3) A(2) A(1) C = A(3) & A(3 downto 1); ECE 448 – FPGA and ASIC Design with VHDL

Fixed Logical Shift Left in VHDL SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0); A(3) A(2) A(1) A(0) 4 A A <<1 C L Internal signals are from DUT. Main process may be split into main process. I.e. one to drive clk, rst and other for test vectors. Many architectures can be tested by inserting more for DUT:TestComp use entity work.TestComp(archName) statmetns “work” is the name of the library that “TestComp” is being compiled to. The “DUT” tag is required. C 4 A(2) A(1) A(0) ‘0’ C = A(2 downto 0) & '0'; ECE 448 – FPGA and ASIC Design with VHDL

Fixed Rotation Left in VHDL SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0); A(3) A(2) A(1) A(0) 4 A A <<< 1 C Internal signals are from DUT. Main process may be split into main process. I.e. one to drive clk, rst and other for test vectors. Many architectures can be tested by inserting more for DUT:TestComp use entity work.TestComp(archName) statmetns “work” is the name of the library that “TestComp” is being compiled to. The “DUT” tag is required. C 4 A(2) A(1) A(0) A(3) C = A(2 downto 0) & A(3); ECE 448 – FPGA and ASIC Design with VHDL

Variable Rotators ECE 448 – FPGA and ASIC Design with VHDL

8-bit Variable Rotator Left 3 A <<< B B C 8 To be covered during one of the future classes ECE 448 – FPGA and ASIC Design with VHDL

Gates ECE 448 – FPGA and ASIC Design with VHDL

Basic Gates – AND, OR, NOT × ¼ (a) AND gates x + (b) OR gates 1 2 n ¼ + × (a) AND gates (b) OR gates (c) NOT gate ECE 448 – FPGA and ASIC Design with VHDL

Basic Gates – NAND, NOR … … ECE 448 – FPGA and ASIC Design with VHDL

DeMorgan’s Theorem and other symbols for NAND, NOR x 1 2 + = (a) (b) ECE 448 – FPGA and ASIC Design with VHDL

Basic Gates – XOR (b) Graphical symbol (a) Truth table 1 x f Å = 1 x 2 f Å = (c) Sum-of-products implementation ECE 448 – FPGA and ASIC Design with VHDL

Basic Gates – XNOR x x f = x Å x 1 1 x 1 . f = x Å x = x x x 1 1 1 2 1 2 1 1 x 1 1 . f = x Å x = x x x 1 2 1 2 1 1 1 2 (a) Truth table (b) Graphical symbol x 1 x 2 f = x Å x 1 2 (c) Sum-of-products implementation ECE 448 – FPGA and ASIC Design with VHDL

Data-flow VHDL: Example y s cin cout ECE 448 – FPGA and ASIC Design with VHDL

Data-flow VHDL: Example (1) LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY fulladd IS PORT ( x : IN STD_LOGIC ; y : IN STD_LOGIC ; cin : IN STD_LOGIC ; s : OUT STD_LOGIC ; cout : OUT STD_LOGIC ) ; END fulladd ; ECE 448 – FPGA and ASIC Design with VHDL

Data-flow VHDL: Example (2) ARCHITECTURE dataflow OF fulladd IS BEGIN s <= x XOR y XOR cin ; cout <= (x AND y) OR (cin AND x) OR (cin AND y) ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Logic Operators Logic operators Logic operators precedence and or nand nor xor not xnor only in VHDL-93 Highest No order precedents not and or nand nor xor xnor Lowest ECE 448 – FPGA and ASIC Design with VHDL

No Implied Precedence Wanted: y = ab + cd Incorrect y <= a and b or c and d ; equivalent to y <= ((a and b) or c) and d ; y = (ab + c)d Correct y <= (a and b) or (c and d) ; No order precedents ECE 448 – FPGA and ASIC Design with VHDL

Multiplexers ECE 448 – FPGA and ASIC Design with VHDL

f <= w1 WHEN s = ‘1' ELSE w0 ; 2-to-1 Multiplexer f s w 1 s f w 1 w 1 (a) Graphical symbol (b) Truth table VHDL: f <= w0 WHEN s = '0' ELSE w1 ; or f <= w1 WHEN s = ‘1' ELSE w0 ; ECE 448 – FPGA and ASIC Design with VHDL

VHDL code for a 2-to-1 Multiplexer Entity LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux2to1 IS PORT ( w0, w1, s : IN STD_LOGIC ; f : OUT STD_LOGIC ) ; END mux2to1 ; ARCHITECTURE dataflow OF mux2to1 IS BEGIN f <= w0 WHEN s = '0' ELSE w1 ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Cascade of two multiplexers 3 w 1 y 2 w 1 1 s2 s1 VHDL: f <= w1 WHEN s1 = ‘1' ELSE w2 WHEN s2 = ‘1’ ELSE w3 ; ECE 448 – FPGA and ASIC Design with VHDL

VHDL design entity implementing a cascade of two multiplexers LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux_cascade IS PORT ( w1, w2, w3: IN STD_LOGIC ; s1, s2 : IN STD_LOGIC ; f : OUT STD_LOGIC ) ; END mux_cascade ; ARCHITECTURE dataflow OF mux2to1 IS BEGIN f <= w1 WHEN s1 = ‘1' ELSE w2 WHEN s2 = ‘1’ ELSE w3 ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Operators Relational operators Logic and relational operators precedence = /= < <= > >= Highest not = /= < <= > >= and or nand nor xor xnor No order precedents Lowest ECE 448 – FPGA and ASIC Design with VHDL

Priority of logic and relational operators compare a = bc Incorrect … when a = b and c else … equivalent to … when (a = b) and c else … Correct … when a = (b and c) else … No order precedents ECE 448 – FPGA and ASIC Design with VHDL

4-to-1 Multiplexer s WITH s SELECT f <= w0 WHEN "00", w1 WHEN "01", (a) Graphic symbol (b) Truth table f s 1 w 00 01 2 3 10 11 s w 1 f s 2 3 WITH s SELECT f <= w0 WHEN "00", w1 WHEN "01", w2 WHEN "10", w3 WHEN OTHERS ; ECE 448 – FPGA and ASIC Design with VHDL

VHDL code for a 4-to-1 Multiplexer entity 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 BEGIN WITH s SELECT f <= w0 WHEN "00", w1 WHEN "01", w2 WHEN "10", w3 WHEN OTHERS ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Decoders ECE 448 – FPGA and ASIC Design with VHDL

2-to-4 Decoder w y Enw <= En & w ; WITH Enw SELECT (b) Graphical symbol (a) Truth table w y w 1 3 w y 1 y 3 w x En 2 2 y y 1 y En Enw <= En & w ; WITH Enw SELECT y <= "0001" WHEN "100", "0010" WHEN "101", "0100" WHEN "110", "1000" WHEN "111", "0000" WHEN OTHERS ; ECE 448 – FPGA and ASIC Design with VHDL

VHDL code for a 2-to-4 Decoder entity LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY dec2to4 IS PORT ( w : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ; En : IN STD_LOGIC ; y : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) ) ; END dec2to4 ; ARCHITECTURE dataflow OF dec2to4 IS SIGNAL Enw : STD_LOGIC_VECTOR(2 DOWNTO 0) ; BEGIN Enw <= En & w ; WITH Enw SELECT y <= "0001" WHEN "100", "0010" WHEN "101", "0100" WHEN "110", "1000" WHEN "111", "0000" WHEN OTHERS ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Encoders ECE 448 – FPGA and ASIC Design with VHDL

Priority Encoder y w y <= "11" WHEN w(3) = '1' ELSE y y w w 1 y 1 w y <= "11" WHEN w(3) = '1' ELSE "10" WHEN w(2) = '1' ELSE "01" WHEN w(1) = '1' ELSE "00" ; z <= '0' WHEN w = "0000" ELSE '1' ; 2 z w 3 d 1 w y z - 2 3 ECE 448 – FPGA and ASIC Design with VHDL

VHDL code for a Priority Encoder entity LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY priority IS PORT ( w : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ; y : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ; z : OUT STD_LOGIC ) ; END priority ; ARCHITECTURE dataflow OF priority IS BEGIN y <= "11" WHEN w(3) = '1' ELSE "10" WHEN w(2) = '1' ELSE "01" WHEN w(1) = '1' ELSE "00" ; z <= '0' WHEN w = "0000" ELSE '1' ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Adders ECE 448 – FPGA and ASIC Design with VHDL

+ 16-bit Unsigned Adder X Y Cout Cin S 16 16 16 ECE 448 – FPGA and ASIC Design with VHDL

Operations on Unsigned Numbers For operations on unsigned numbers USE ieee.std_logic_unsigned.all and signals of the type STD_LOGIC_VECTOR OR USE ieee.numeric_std.all UNSIGNED and conversion functions: std_logic_vector(), unsigned() ECE 448 – FPGA and ASIC Design with VHDL

VHDL code for a 16-bit Unsigned Adder LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_unsigned.all ; ENTITY adder16 IS PORT ( Cin : IN STD_LOGIC ; X : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; Y : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; S : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ; Cout : OUT STD_LOGIC ) ; END adder16 ; ARCHITECTURE dataflow OF adder16 IS SIGNAL Sum : STD_LOGIC_VECTOR(16 DOWNTO 0) ; BEGIN Sum <= ('0' & X) + Y + Cin ; S <= Sum(15 DOWNTO 0) ; Cout <= Sum(16) ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Addition of Unsigned Numbers (1) LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.numeric_std.all ; ENTITY adder16 IS PORT ( Cin : IN STD_LOGIC ; X : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; Y : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; S : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ; Cout : OUT STD_LOGIC ) ; END adder16 ; ECE 448 – FPGA and ASIC Design with VHDL

Addition of Unsigned Numbers (2) ARCHITECTURE dataflow OF adder16 IS SIGNAL Xu : UNSIGNED(15 DOWNTO 0); SIGNAL Yu: UNSIGNED(15 DOWNTO 0); SIGNAL Su : UNSIGNED(16 DOWNTO 0) ; BEGIN Xu <= unsigned(X); Yu <= unsigned(Y); Su <= ('0' & Xu) + Yu + unsigned('0' & Cin) ; S <= std_logic_vector(Su(15 DOWNTO 0)) ; Cout <= Su(16) ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Addition of Unsigned Numbers (3) ARCHITECTURE dataflow OF adder16 IS signal Sum: STD_LOGIC_VECTOR(16 DOWNTO 0) ; BEGIN Sum <= std_logic_vector( unsigned('0' & X) + unsigned(Y) + unsigned('0' & Cin) ) ; S <= Sum(15 downto 0); Cout <= Sum(16) ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Operations on Signed Numbers For operations on signed numbers USE ieee.numeric_std.all, signals of the type SIGNED, and conversion functions: std_logic_vector(), signed() OR USE ieee.std_logic_signed.all and signals of the type STD_LOGIC_VECTOR ECE 448 – FPGA and ASIC Design with VHDL

Signed and Unsigned Types Behave exactly like STD_LOGIC_VECTOR plus, they determine whether a given vector should be treated as a signed or unsigned number. Require USE ieee.numeric_std.all; ECE 448 – FPGA and ASIC Design with VHDL

Multipliers ECE 448 – FPGA and ASIC Design with VHDL

Unsigned vs. Signed Multiplication 1111 15 1111 -1 x x x x 11100001 225 00000001 1 ECE 448 – FPGA and ASIC Design with VHDL

8x8-bit Unsigned Multiplier a b * c U 16 ECE 448 – FPGA and ASIC Design with VHDL

Multiplication of unsigned numbers LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all ; entity multiply is port( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); c : out STD_LOGIC_VECTOR(15 downto 0) ); end multiply; architecture dataflow of multiply is begin c <= a * b; end dataflow; ECE 448 – FPGA and ASIC Design with VHDL

8x8-bit Signed Multiplier a b * c S 16 ECE 448 – FPGA and ASIC Design with VHDL

Multiplication of signed numbers LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_signed.all ; entity multiply is port( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); c : out STD_LOGIC_VECTOR(15 downto 0) ); end multiply; architecture dataflow of multiply is begin c <= a * b; end dataflow; ECE 448 – FPGA and ASIC Design with VHDL

8x8-bit Unsigned and Signed Multiplier * cu cs 16 16 ECE 448 – FPGA and ASIC Design with VHDL

Multiplication of signed and unsigned numbers LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all ; entity multiply is port( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); cu : out STD_LOGIC_VECTOR(15 downto 0); cs : out STD_LOGIC_VECTOR(15 downto 0) ); end multiply; architecture dataflow of multiply is begin -- signed multiplication cs <= STD_LOGIC_VECTOR(SIGNED(a)*SIGNED(b)); -- unsigned multiplication cu <= STD_LOGIC_VECTOR(UNSIGNED(a)*UNSIGNED(b)); end dataflow; ECE 448 – FPGA and ASIC Design with VHDL

Comparators ECE 448 – FPGA and ASIC Design with VHDL

4-bit Number Comparator A > B AgtB 4 B AgtB <= '1' WHEN A > B ELSE '0' ; ECE 448 – FPGA and ASIC Design with VHDL

VHDL code for a 4-bit Unsigned Number Comparator entity LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_unsigned.all ; ENTITY compare IS PORT ( A, B : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ; AgtB : OUT STD_LOGIC ) ; END compare ; ARCHITECTURE dataflow OF compare IS BEGIN AgtB <= '1' WHEN A > B ELSE '0' ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

VHDL code for a 4-bit Signed Number Comparator entity LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_signed.all ; ENTITY compare IS PORT ( A, B : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ; AgtB : OUT STD_LOGIC ) ; END compare ; ARCHITECTURE dataflow OF compare IS BEGIN AgtB <= '1' WHEN A > B ELSE '0' ; END dataflow ; ECE 448 – FPGA and ASIC Design with VHDL

Buffers ECE 448 – FPGA and ASIC Design with VHDL

Tri-state Buffer (a) A tri-state buffer (b) Equivalent circuit x f e = 0 (a) A tri-state buffer x f e x f e = 1 x f Z 1 Z 1 (b) Equivalent circuit 1 1 1 (c) Truth table ECE 448 – FPGA and ASIC Design with VHDL

Four types of Tri-state Buffers f <= x WHEN (e = '1') ELSE 'Z'; f <= not x WHEN (e = '1') ELSE 'Z'; f <= x WHEN (e = '0') ELSE 'Z'; f <= not x WHEN (e = '0') ELSE 'Z'; ECE 448 – FPGA and ASIC Design with VHDL

Tri-state Buffer entity (1) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY tri_state IS PORT ( e: IN STD_LOGIC; x: IN STD_LOGIC; f: OUT STD_LOGIC ); END tri_state; ECE 448 – FPGA and ASIC Design with VHDL

Tri-state Buffer entity (2) ARCHITECTURE dataflow OF tri_state IS BEGIN f <= x WHEN (e = ‘1’) ELSE ‘Z’; END dataflow; ECE 448 – FPGA and ASIC Design with VHDL

ROM ECE 448 – FPGA and ASIC Design with VHDL

ROM 8x16 example (1) 8x16 ROM Addr Dout C 3 16 ECE 448 – FPGA and ASIC Design with VHDL

ROM 8x16 example (2) LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all; ENTITY rom IS PORT ( Addr : IN STD_LOGIC_VECTOR(2 DOWNTO 0); Dout : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ); END rom;

ROM 8x16 example (3) ARCHITECTURE dataflow OF rom IS SIGNAL temp: INTEGER RANGE 0 TO 7; TYPE vector_array IS ARRAY (0 to 7) OF STD_LOGIC_VECTOR(15 DOWNTO 0); CONSTANT memory : vector_array := ( X”800A", X"D459", X"A870", X"7853", X"650D", X"642F", X"F742", X"F548"); BEGIN temp <= to_integer(unsigned(Addr)); Dout <= memory(temp); END dataflow;

Describing Combinational Logic Using Dataflow Design Style ECE 448 – FPGA and ASIC Design with VHDL

MLU Example ECE 448 – FPGA and ASIC Design with VHDL

MLU Block Diagram A MUX_4_1 NEG_A Y NEG_Y B L1 L0 NEG_B MUX_0 A1 Y1 1 A1 A MUX_4_1 IN0 Y1 MUX_1 1 NEG_A IN1 MUX_2 Y IN2 OUTPUT IN3 SEL0 SEL1 NEG_Y 1 B1 B L1 L0 MUX_3 NEG_B

MLU: Entity Declaration LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY mlu IS PORT( NEG_A : IN STD_LOGIC; NEG_B : IN STD_LOGIC; NEG_Y : IN STD_LOGIC; A : IN STD_LOGIC; B : IN STD_LOGIC; L1 : IN STD_LOGIC; L0 : IN STD_LOGIC; Y : OUT STD_LOGIC ); END mlu; ECE 448 – FPGA and ASIC Design with VHDL

MLU: Architecture Declarative Section ARCHITECTURE mlu_dataflow OF mlu IS SIGNAL A1 : STD_LOGIC; SIGNAL B1 : STD_LOGIC; SIGNAL Y1 : STD_LOGIC; SIGNAL MUX_0 : STD_LOGIC; SIGNAL MUX_1 : STD_LOGIC; SIGNAL MUX_2 : STD_LOGIC; SIGNAL MUX_3 : STD_LOGIC; SIGNAL L: STD_LOGIC_VECTOR(1 DOWNTO 0); ECE 448 – FPGA and ASIC Design with VHDL

MLU - Architecture Body BEGIN A1<= NOT A WHEN (NEG_A='1') ELSE A; B1<= NOT B WHEN (NEG_B='1') ELSE B; Y <= NOT Y1 WHEN (NEG_Y='1') ELSE Y1; MUX_0 <= A1 AND B1; MUX_1 <= A1 OR B1; MUX_2 <= A1 XOR B1; MUX_3 <= A1 XNOR B1; L <= L1 & L0; with (L) select Y1 <= MUX_0 WHEN "00", MUX_1 WHEN "01", MUX_2 WHEN "10", MUX_3 WHEN OTHERS; END mlu_dataflow; ECE 448 – FPGA and ASIC Design with VHDL

Logic Implied Most Often by Conditional and Selected Concurrent Signal Assignments ECE 448 – FPGA and ASIC Design with VHDL

Concurrent statements Data-flow VHDL Major instructions Concurrent statements concurrent signal assignment () conditional concurrent signal assignment (when-else) selected concurrent signal assignment (with-select-when) ECE 448 – FPGA and ASIC Design with VHDL

Conditional concurrent signal assignment When - Else target_signal <= value1 when condition1 else value2 when condition2 else . . . valueN-1 when conditionN-1 else valueN; ECE 448 – FPGA and ASIC Design with VHDL

Most often implied structure When - Else target_signal <= value1 when condition1 else value2 when condition2 else . . . valueN-1 when conditionN-1 else valueN; Value N Value N-1 Condition N-1 Condition 2 Condition 1 Value 2 Value 1 Target Signal … 1 .… 1 1 ECE 448 – FPGA and ASIC Design with VHDL

Concurrent statements Data-flow VHDL Major instructions Concurrent statements concurrent signal assignment () conditional concurrent signal assignment (when-else) selected concurrent signal assignment (with-select-when) ECE 448 – FPGA and ASIC Design with VHDL

Selected concurrent signal assignment With –Select-When with choice_expression select target_signal <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N; ECE 448 – FPGA and ASIC Design with VHDL

Most Often Implied Structure With –Select-When with choice_expression select target_signal <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N; expression1 choices_1 expression2 choices_2 target_signal expressionN choices_N choice expression ECE 448 – FPGA and ASIC Design with VHDL

Allowed formats of choices_k WHEN value WHEN value_1 | value_2 | .... | value N WHEN OTHERS ECE 448 – FPGA and ASIC Design with VHDL

Allowed formats of choice_k - example WITH sel SELECT y <= a WHEN "000", c WHEN "001" | "111", d WHEN OTHERS; ECE 448 – FPGA and ASIC Design with VHDL

when-else vs. with-select-when (1) "when-else" should be used when: 1) there is only one condition (and thus, only one else), as in the 2-to-1 MUX 2) conditions are independent of each other (e.g., they test values of different signals) 3) conditions reflect priority (as in priority encoder); one with the highest priority need to be tested first. ECE 448 – FPGA and ASIC Design with VHDL

when-else vs. with-select-when (2) "with-select-when" should be used when there is 1) more than one condition 2) conditions are closely related to each other (e.g., represent different ranges of values of the same signal) 3) all conditions have the same priority (as in the 4-to-1 MUX). ECE 448 – FPGA and ASIC Design with VHDL