VHDL Hardware Description Language

Slides:



Advertisements
Similar presentations
The Verilog Hardware Description Language
Advertisements

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.
History TTL-logic PAL (Programmable Array Logic)
Mridula Allani Fall 2010 (Refer to the comments if required) ELEC Fall 2010, Nov 21(Adopted from Profs. Nelson and Stroud)
Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
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.
CSET 4650 Field Programmable Logic Devices Dan Solarek VHDL Behavioral & Structural.
AND Gate: A Logic circuit whose output is logic ‘1’ if and only if all of its inputs are logic ‘1’.
1 H ardware D escription L anguages Basic Language Concepts.
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.
VHDL TUTORIAL Preetha Thulasiraman ECE 223 Winter 2007.
CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #17 – Introduction.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
1 Part I: SYSTEM DESIGN. 2 Packages and Components Functions and Procedures Problem (Design & Implementation) Additional System Designs.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
陳慶瀚 機器智慧與自動化技術 (MIAT) 實驗室 國立中央大學資工系 2009 年 10 月 8 日 ESD-04 VHDL 硬體描述語言概論 VHDL Hardware Description Language.
L12 – VHDL Overview. VHDL Overview  HDL history and background  HDL CAD systems  HDL view of design  Low level HDL examples  Ref: text Unit 10, 17,
1 ECE 545 – Introduction to VHDL Dataflow Modeling of Combinational Logic Simple Testbenches ECE 656. Lecture 2.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
HARDWARE DESCRIPTION LANGUAGE (HDL). What is HDL? A type of programming language for sampling and modeling of electronic & logic circuit designs It can.
1 component OR_3 port (A,B,C: in bit; Z: out bit); end component ; Reserved Words  Declarations of Components and Entities are similar  Components are.
ECE 332 Digital Electronics and Logic Design Lab Lab 6 Concurrent Statements & Adders.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
CEC 220 Digital Circuit Design Introduction to VHDL Wed, February 25 CEC 220 Digital Circuit Design Slide 1 of 19.
George Mason University Data Flow Modeling in VHDL ECE 545 Lecture 7.
VHDL Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches Concurrent Statements & Adders.
Data Flow Modeling in VHDL
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VHDL Coding for Synthesis ECE 448 Lecture 12.
CEC 220 Digital Circuit Design Introduction to VHDL Friday, February 21 CEC 220 Digital Circuit Design Slide 1 of 10.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, Oct 14 CEC 220 Digital Circuit Design Slide 1 of 19.
George Mason University Data Flow Modeling of Combinational Logic ECE 545 Lecture 5.
An Introduction to V.H.D.L.. Need of a Compiler… main( ) { int x=10,y=20,z; z = x + y ; printf ( “ %d “, z ); getch( ) ; } What’s That ? Give me only.
Sequential statements (1) process
Combinational logic circuit
Basic Language Concepts
VHDL Basics.
Dataflow Style Combinational Design with VHDL
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
UNIT 2: Data Flow description
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
CHAPTER 10 Introduction to VHDL
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
VHDL VHSIC Hardware Description Language VHSIC
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
ELEC 5200/6200 Computer Architecture and Design Review of VHDL
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
Concurrent vs Sequential
Behavioral Modeling of Sequential-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.
Data Flow Description of Combinational-Circuit Building Blocks
The Verilog Hardware Description Language
Data Flow Description of Combinational-Circuit Building Blocks
The Verilog Hardware Description Language
ECE 545 Lecture 5 Simple Testbenches.
© Copyright Joanne DeGroat, ECE, OSU
CprE / ComS 583 Reconfigurable Computing
Sequntial-Circuit Building Blocks
4-Input Gates VHDL for Loops
Digital Logic with VHDL
EEL4712 Digital Design (VHDL Tutorial).
(Simple Testbenches & Arithmetic Operations)
Presentation transcript:

VHDL Hardware Description Language

GUIDELINES How to write HDL code:

GUIDELINES How NOT to write HDL code:

Think Hardware NOT Software Poorly written VHDL code will either be: Unsynthesizable Functionally incorrect Lead to poor performance/area/power results

VHDL code basic structure Entity (I/O and generic declaration) Architecture structural (structure description) rtl (register transfer level description) behavioral (high-level description)

Entity declaration ENTITY entity_name IS PORT (port_name_1 : port_type_1; port_name_2: port _type_2; . . . port_name_n: port_type_n); END entity_name;

Port types PORT DIRECTION SIGNAL TYPE - IN -OUT -INOUT BIT BIT_VECTOR(WIDTH -1 DOWNTO 0) STD_LOGIC STD_LOGIC_VECTOR(WIDTH -1 DOWNTO 0)

Entity declaration example (1/2) ENTITY and_gate IS PORT (i1: IN BIT; i2: IN BIT; O: OUT BIT); END and_gate;

Entity declaration example (2/2) Library ieee; Use ieee.std_logic_1164.all; ENTITY adder IS PORT (i1: IN STD_LOGIC_VECTOR(3 DOWNTO 0); i2: IN STD_LOGIC_VECTOR(3 DOWNTO 0); sum: OUT STD_LOGIC_VECTOR(3 DOWNTO 0); carry: OUT STD_LOGIC); END adder;

Example

Architecture declaration ARCHITECTURE architecture_name OF entity_name IS component declaration; signal declaration; BEGIN component instantiation sequential statements (processes) concurrent statements END [architecture_name];

Component declaration COMPONENT component_name PORT (port_name_1 : port_type_1; port_name_2: port _type_2; . . . port_name_n: port_type_n); END COMPONENT;

Component declaration example COMPONENT and_gate PORT (i1: IN BIT; i2: IN BIT; O: OUT BIT); END COMPONENT;

Signal declaration SIGNAL signal_name : signal_type; Examples SIGNAL data_bus: std_logic_vector(7 downto 0); SIGNAL clock: std_logic; SIGNAL count : bit_vector(5 downto 0);

Component instantiation (nominal) Label: component_name PORT MAP( port_name1 => signal_name1, port_name2 => signal_name2, … port_nameN => signal_nameN);

Example U_adder: adder PORT MAP(i1 => add1, i2 => add2, sum => s, carry => c);

Component instantiation (positional) Label: component_name PORT MAP( signal_name1, signal_name2, … signal_nameN);

Example U_adder: adder PORT MAP(add1, add2, s, c);

Structural description example (1/2) ENTITY gates IS PORT (i0,i1,i2,i3: std_logic; o: out std_logic); END gates; ARCHITECTURE str of gates IS COMPONENT and_gate PORT (i1,i2: in std_logic; END COMPONENT; SIGNAL s1,s2: std_logic; BEGIN

Structural description example (2/2) U_and1: and_gate PORT MAP(i1 => i0, i2 => i1, o => s1); U_and2: and_gate PORT MAP(i1 => i2, i2 => i3, o => s2); U_and3: and_gate PORT MAP(i1 => s1, i2 => s2, o => o); END;

VHDL operators Arithmetic Logical Relational +, - , *, Synthesizable /, abs, rem, mod, ** Non-synthesizable Logical AND, OR, NOT, NAND, NOR, XOR, XNOR Relational =, /=, <, >, <=, >=

Signal assignment signal_name <= signal_value; Examples signal a: std_logic; signal b: std_logic_vector(6 downto 0); signal c: std_logic_vector(3 downto 0); signal d: std_logic_vector(2 downto 0); Correct Incorrect a <= ‘1’; a <= “01”; b <= “0101001”; b <= ‘0’; b(1) <= ‘0’; c <= (others => ‘0’); c <= ‘0000’; d <= (1 => ‘0’, others => ’1’); d <= b & c; b <= c & d; b(3 downto 1) <= d(1 downto 0); b(5 downto 3) <= d;

The “after” clause Used to assign signals with delay, modeling circuit behaviour a <= d after 5 ns; -- 5 ns wire delay b <= a and c after 20 ns; -- 20 ns gate delay Not synthesizable, is ignored by synthesis tools Useful in testbenches for creating input signal waveforms clk <= not clk after 20 ns; -- 40 ns clock period rst_n <= ‘0’, ‘1’ after 210 ns;

Concurrent statements –delta time b <= not a; (a = ‘1’, b = ‘1’, c= ‘0’) c <= a xor b; Time a b c 0 1 1 0 δ 1 0 0 2δ 1 0 1 b <= not a; (a = ‘1’, b = ‘1’, c =‘0’) c <= a xor b; Time a b c 0 1 1 0 δ 1 0 0 b <= not a; (a = ‘1’, b = ‘1’, c= ‘0’) c <= a xor b; Time a b c 0 1 1 0

Concurrent statements Multiple driver error c <= a AND b; …. c <= d OR e;

Combinational circuit description ENTITY gates is port (a: in std_logic; d: out std_logic); end gates; Architecture rtl of gates is signal b: std_logic; begin b <= not a; d <= c xor b; --d<=c xor (not a); end rtl;

GENERATE STATEMENTS (concurrent only) Used to generate multiple instances of a component in homogeneous architectures Z_Gen: For i in 0 to 7 generate z(i) <= x(i) AND y(i+8); end generate;

Generate example (1/2) ENTITY cell_array IS PORT (i: in std_logic_vector(63 downto 0); o: out std_logic_vector(63 downto 0) ); END ENTITY cell_array; ARCHITECTURE str OF cell_array IS COMPONENT cell (i_north: in std_logic; i_west: in std_logic; i_east: in std_logic; o_east: out std_logic; o_west: out std_logic; o_south: out std_logic end component; signal west: std_logic_vector(62 downto 0); signal east: std_logic_vector(62 downto 0); BEGIN

Generate example (2/2) U_cell_0: cell PORT MAP (i_north => i(0), i_west => '0', i_east => west(0), o_east => east(0), o_west => open, o_south => o(0) ); U_cell_63: cell (i_north => i(63), i_west => east(62), i_east => '0', o_east => open, o_west => west(62), o_south => o(63) U_top_gen: for i in 1 to 62 generate U_cell_i: cell (i_north => i(i), i_west => east(i-1), i_east => west(i), o_east => east(i), o_west => west(i-1), o_south => o(i) end generate; end;

Generate example 2 (1/5) ENTITY cell_array IS PORT (i: in std_logic_vector(3 downto 0); o: out std_logic_vector(3 downto 0) ); END ENTITY cell_array; -- ARCHITECTURE str OF cell_array IS COMPONENT cell (i_north: in std_logic; i_west: in std_logic; i_east: in std_logic; o_east: out std_logic; o_west: out std_logic; o_south: out std_logic end component; type sig_array is array (3 downto 0) of std_logic_vector(3 downto 0); type sig_array2 is array (2 downto 0) of std_logic_vector(3 downto 0); signal south: sig_array2; signal west: sig_array; signal east: sig_array;

Generate example 2 (2/5) BEGIN U_cell_0_0: cell PORT MAP (i_north => i(0), i_west => '0', i_east => west(0)(0), o_east => east(0)(0), o_west => open, o_south => south(0)(0) ); U_cell_0_3: cell (i_north => i(3), i_west => west(0)(3), i_east => '0', o_east => east(0)(3), o_west => west(0)(3), o_south => south(0)(3) U_cell_3_0: cell (i_north => north(2)(0), i_east => west(3)(0), o_east => east(3)(0), o_south => o(0) Generate example 2 (2/5)

Generate example 2 (3/5) U_cell_3_3: cell PORT MAP (i_north => north(2)(3), i_west => west(3)(3), i_east => '0', o_east => open, o_west => west(3)(3), o_south => o(3) ); U_top_gen: for i in 1 to 2 generate U_cell_i_0: cell (i_north => i(i), i_west => east(i-1)(0), i_east => west(i)(0), o_east => east(i)(0), o_west => west(i-1)(0), o_south => south(i)(0) end generate; U_bottom_gen: for i in 1 to 2 generate U_cell_i_3: cell (i_north => south(i)(2), i_west => east(i-1)(3), i_east => west(i)(3), o_east => east(i)(3), o_west => west(i-1)(3), o_south => o(i) Generate example 2 (3/5)

Generate example 2 (4/5) U_left_gen: for i in 1 to 2 generate U_cell_0_i: cell PORT MAP (i_north => south(0)(i), i_west => '0', i_east => west(0)(i), o_east => east(0)(i), o_west => open, o_south => south(0)(i) ); end generate; U_right_gen: for i in 1 to 2 generate U_cell_3_i: cell (i_north => south(2)(i), i_west => east(3)(i-1), i_east => '0', o_east => east(3)(i), o_west => west(3)(i-1), o_south => south(3)(i)

Generate example 2 (5/5) U_inner_gen_x: for i in 1 to 2 generate U_inner_gen_y: for j in 1 to 2 generate U_cell_i_j: cell PORT MAP (i_north => south(i-1)(j), i_west => east(i)(j-1), i_east => west(i)(j), o_east => east(i)(j), o_west => west(i)(j-1), o_south => south(i)(j) ); end generate; END ARCHITECTURE str;

Arithmetic unit description Library ieee; Use ieee.std_logic_1164.all; Use ieee.std_logic_unsigned.all; ENTITY add1 is port (a, b: in std_logic; cin: in std_logic; sum: out std_logic; cout: out std_logic); end add1; ARCHITECTURE rtl of add1 is Signal s: std_logic_vector(1 downto 0); begin s <= (‘0’ & a) + b + cin; sum <= s(0); cout <= s(1); end;

Example Describe a 5-bit multiplier in VHDL.

When statement (concurrent)– describing MUXs Port/signal <= value1 WHEN condition1 [ELSE value2 when condition2 …] ELSE valueN; ENTITY mux IS PORT (i0: in std_logic; i1: in std_logic; s: in std_logic; o: out std_logic); END mux; ARCHITECTURE rtl OF mux IS BEGIN o <= i0 when s = ‘0’ else i1; END RTL;

with statement (concurrent)– describing MUXs WITH signal SELECT port/signal <= expression1 WHEN value1, expression2 WHEN value2, … expressionN WHEN OTHERS; ENTITY mux IS PORT (i0: in std_logic; i1: in std_logic; s: in std_logic; o: out std_logic); END mux; ARCHITECTURE rtl OF mux IS BEGIN WITH s SELECT o <= i0 WHEN ‘0’, i1 WHEN OTHERS; END rtl;