EE3A1 Computer Hardware and Digital Design Lecture 2 Introduction to 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

Quad 2-to-1 and Quad 4-to-1 Multiplexers Discussion D2.4 Example 7.
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Introduction to VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T1: Combinational Logic Circuits.
1 Comparators Discussion D A 1-Bit Comparator The variable Gout is 1 if x > y or if x = y and Gin = 1. The variable Eout is 1 if x = y and Gin =
Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
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.
VHDL And Synthesis Review. VHDL In Detail Things that we will look at: –Port and Types –Arithmetic Operators –Design styles for Synthesis.
Programming in VHDL Using Processes. How Processes Run A process is either in suspend mode or is running. For a process to run, there has to be a change.
Introduction to VHDL Multiplexers Discussion D1.1.
1 Comparators: Procedures Discussion D9.2 Example 22.
Lecture #6 Page 1 Lecture #6 Agenda 1.VHDL - Architecture 2.VHDL - Packages Announcements 1.HW #3 assigned ECE 4110– Sequential Logic Design.
AND Gate: A Logic circuit whose output is logic ‘1’ if and only if all of its inputs are logic ‘1’.
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.
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.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
L26 – Datapath ALU implementation
RTL Hardware Design by P. Chu Chapter Basic VHDL program 2. Lexical elements and program format 3. Objects 4. Data type and operators RTL Hardware.
Basic Overview of VHDL Matthew Murach Slides Available at:
EE3A1 Computer Hardware and Digital Design Lecture 5 Testbenches and Memories in VHDL.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
HARDWARE DESCRIPTION LANGUAGE (HDL). What is HDL? A type of programming language for sampling and modeling of electronic & logic circuit designs It can.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
2’s Complement 4-Bit Saturator Discussion D2.8 Lab 2.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
Digital System Projects
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
CS/EE 3700 : Fundamentals of Digital System Design
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
BASIC VHDL LANGUAGE ELEMENTS Digital Design for Instrumentation with VHDL 1.
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Number Representation and Arithmetic Circuits
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
ECE 332 Digital Electronics and Logic Design Lab Lab 3 Introduction to Starter Kit ECE 332 George Mason University.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Fundamentals of Digital Signal Processing יהודה אפק, נתן אינטרטור אוניברסיטת תל אביב.
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
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.
1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.
Combinational logic circuit
Basic Language Concepts
Describing Combinational Logic Using Processes
Dataflow Style Combinational Design with VHDL
Comparators Discussion DS-3.1.
ECE 4110–5110 Digital System Design
ECE 4110–5110 Digital System Design
IAS 0600 Digital Systems Design
VHDL 1. ver.7a VHDL1 INTRODUCTION TO VHDL (VERY-HIGH-SPEED-INTEGRATED-CIRCUITS HARDWARE DESCRIPTION LANGUAGE) KH WONG (w2 begins) (Some pictures are.
VHDL (VHSIC Hardware Description Language)
VHDL Discussion Subprograms
VHDL Structural Architecture
Chapter 5 – Number Representation and Arithmetic Circuits
VHDL Discussion Subprograms
ECE 331 – Digital System Design
Data Flow Description of Combinational-Circuit Building Blocks
UNIT 6: Mixed-Type Description
Data Flow Description of Combinational-Circuit Building Blocks
ECE 545 Lecture 5 Simple Testbenches.
4-Input Gates VHDL for Loops
Digital Logic with VHDL
Presentation transcript:

EE3A1 Computer Hardware and Digital Design Lecture 2 Introduction to VHDL

Introduction  We’ll look at some simple design in VHDL  These will be the examples used in lab 1

A simple example  NAND gate  1 st thing to do:  Say what it looks like to the rest of the system  List of inputs and outputs  Port map

Port map: inputs and outputs  Uppercase is a VHDL keyword  Lower case is name I have chosen  Mode can be IN or OUT ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC ); END;

Port map: inputs and outputs  Type STD_LOGIC can be ‘0’, ‘1’, ‘X’ or ‘U’.  ‘X’ means unknown  ‘U’ means uninitialized ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC ); END;

Architecture ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC ); END;  Now we know how many inputs and outputs  Next we say how outputs derive values from inputs:  Architecture

Architecture ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC ); END; ARCHITECTURE simple OF nandgate IS BEGIN c <= a NAND b; END;

Simulate it  Check our design by giving it inputs  Simulator says what the output would do Output is 0 when both inputs are 1: It works

Multiple architectures  We can give more than 1 architecture  Distinguish them by different names ARCHITECTURE simple OF nandgate IS BEGIN c <= a NAND b; END; ARCHITECTURE complicated OF nandgate IS BEGIN c <= NOT ( a AND b ); END;

BEGIN and END statements C: Block defined by { and } for (i=1; i<=n; i++) { a[i]=i; b[i]=a[i]*a[i]; }  A block is a group of statements that should be treated as one

BEGIN and END statements VHDL: Block defined by BEGIN and END FOR i IN ( 1 TO N ) LOOP BEGIN a(i) = i; b(i) = a(i) * a(i); END LOOP;  A block is a group of statements that should be treated as one

Semicolons C: for (i=1; i<=n; i++); /* WRONG semicolon */ {; /* ALSO WRONG semicolon */ a[i]=i; b[i]=a[i]*a[i]; }  ; indicates end of statement.  Statements that "open up" a block don't take semicolons:

Semicolons VHDL: FOR i IN ( 1 TO N ) LOOP; --WRONG semicolon BEGIN; --ALSO WRONG semicolon a(i) = i; b(i) = a(i) * a(i); END LOOP;  ; indicates end of statement.  Statements that "open up" a block don't take semicolons:

ENTITY doesn’t need a BEGIN ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC ); END; ARCHITECTURE simple OF nandgate IS BEGIN c <= a NAND b; END;

Style issues  VHDL is not case sensitive.  In (black and white) books, VHDL keywords are normally in one particular case  In editors, VHDL keywords are normally in one particular colour

Style issues  These are the same: ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END; entity NANDGATE is port ( A, B: in std_logic; C: out std_logic); end; entity nandgate is port ( a, b: in std_logic; c: out std_logic); end;

Spaces, indents and line breaks  Have no effect on code meaning  Used to enhance clarity  These are the same: ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END; ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END;

Annotating END statements ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END; ARCHITECTURE simple OF nandgate IS BEGIN c <= a NAND b; END;  It’s good style to say what you are ENDing

Annotating END statements  Often helps avoid bugs or confusion  Usually optional ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END; ARCHITECTURE simple OF nandgate IS BEGIN c <= a NAND b; END ARCHITECTURE simple;  It’s good style to say what you are ENDing

Comments  Comments are introduced by two dashes -- This is a comment

Libraries void main () { printf(“My first C program”); }  ERROR: printf not found

Libraries #include void main () { printf(“My first C program”); }  Works OK

The IEEE library ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END ENTITY nandgate; ARCHITECTURE simple OF nandgate IS BEGIN c <= a NAND b; END ARCHITECTURE simple; u Error message “Cannot recognise type STD_LOGIC”.

Opening libraries  Definition of STD_LOGIC is held in library  Must open library in order to get at definitions  Main library is called IEEE LIBRARY IEEE; USE IEEE.XXXX.YYYY  XXXX is sub-library (package)  YYYY is feature that you want to use.

Opening libraries  Definition of STD_LOGIC is held in library  Must open library in order to get at definitions  Main library is called IEEE LIBRARY IEEE; USE IEEE.XXXX.ALL  If you want to open all features of the package

Using STD_LOGIC LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC ); END ENTITY nandgate; ARCHITECTURE simple OF nandgate IS BEGIN c <= a NAND b; END ARCHITECTURE simple;

Questions What is the block diagram for this entity declaration? ENTITY question1 IS PORT ( a: IN STD_LOGIC; b: OUT STD_LOGIC; c: IN STD_LOGIC; d: OUT STD_LOGIC ); END ENTITY question1; What is wrong with this architecture (2 problems)? ARCHITECTURE simple OF question1 IS BEGIN b <= a NAND c; END ARCHITECTURE complicated;

What is the block diagram for this entity declaration? ENTITY question1 IS PORT ( a: IN STD_LOGIC; b: OUT STD_LOGIC; c: IN STD_LOGIC; d: OUT STD_LOGIC ); END ENTITY question1;

Questions  What is wrong with this architecture? ARCHITECTURE simple OF question1 IS BEGIN b <= a NAND c; END ARCHITECTURE complicated; Output d is never assigned a value Mismatch in architecture names

Example 2  Arithmetic Logic Unit  Heart of a microprocessor  1 st part of the assignment  To build ALU we need u Conditionals u Signals that are many bits wide u Arithmetic on signals

Conditionals LIBRARY ieee; USE ieee.std_logic_1164.ALL;

Conditionals LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY equals IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END ENTITY equals;

Conditionals LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY equals IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC); END ENTITY equals; ARCHITECTURE number1 OF equals IS BEGIN c <= '1' WHEN a=b ELSE '0'; END ARCHITECTURE number1;

Signals that are more than 1 bit  STD_LOGIC_VECTOR(0 TO 3)  Four members a(0), a(1), a(2) and a(3).  Each is of type STD_LOGIC.

Example of 4-bit device LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY orgate IS PORT ( a, b: IN STD_LOGIC_VECTOR(0 TO 3); c: OUT STD_LOGIC_VECTOR(0 TO 3)); END ENTITY orgate;

Example of 4-bit device ARCHITECTURE number1 OF orgate IS BEGIN C(0) <= a(0) OR b(0); C(1) <= a(1) OR b(1); C(2) <= a(2) OR b(2); C(3) <= a(3) OR b(3); END ARCHITECTURE number1;

Example of 4-bit device ARCHITECTURE number2 OF orgate IS BEGIN c <= a OR b; END ARCHITECTURE number2;  The compiler can figure out that a,b,c are 4 bits wide

Example of 4-bit device ARCHITECTURE number3 OF orgate IS BEGIN C(0 TO 3) <= a(0 TO 3) OR b(0 TO 3); END ARCHITECTURE number3;  Making the loop explicit

STD_LOGIC_VECTOR values  Single bit STD_LOGIC assignment:  a <= ‘1’;--single quotes  4-bit STD_LOGIC_VECTOR assignment:  a <= “1110”;-- double quotes.

Direction of numbering  Can number upwards or downwards  Both represent the same decimal number u 14 if it’s signed; -2 if it’s unsigned

Direction of numbering  In digital logic design bit 0 is usually lsb  So in VHDL index usually counts downwards

Arithmetic on STD_LOGIC_VECTOR s  Comparator  g b ELSE ‘0’;  Signed or unsigned? u 1111 is +15 or –1? u 1110 is +14 or –2?

Arithmetic on STD_LOGIC_VECTOR s  VHDL has two different versions of +,-,>,< etc. u STD_LOGIC_SIGNED u STD_LOGIC_UNSIGNED  Import one or the other

Arithmetic on STD_LOGIC_VECTOR s LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.std_logic_signed.ALL; ENTITY comp IS PORT ( a, b: IN STD_LOGIC_VECTOR(3 DOWNTO 0); g: OUT STD_LOGIC); END ENTITY comp; ARCHITECTURE simple OF comp IS BEGIN g b ELSE ‘0’; END ARCHITECTURE simple; 1111 will be interpreted as -1

Arithmetic on STD_LOGIC_VECTOR s LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.std_logic_unsigned.ALL; ENTITY comp IS PORT ( a, b: IN STD_LOGIC_VECTOR(3 DOWNTO 0); g: OUT STD_LOGIC); END ENTITY comp; ARCHITECTURE simple OF comp IS BEGIN g b ELSE ‘0’; END ARCHITECTURE simple; 1111 will be interpreted as 15

ALU example OpcodeOperation 00a + b 01a – b 10a and b 11a or b  16 bit ALU  Operation is selected by opcode

ALU example LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.std_logic_signed.ALL; ENTITY alu IS PORT ( a, b: IN STD_LOGIC_VECTOR(15 DOWNTO 0); opcode: IN STD_LOGIC_VECTOR(1 DOWNTO 0); c: OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ); END ENTITY alu;

ALU example ARCHITECTURE simple OF alu IS BEGIN c <= a + b WHEN opcode=”00” ELSE a - b WHEN opcode=”01” ELSE a OR b WHEN opcode=”10” ELSE a AND b WHEN opcode=”11”; END ARCHITECTURE simple;

Simulate the ALU  a = “ ”, 0077H.  b = “ ”, 0001H.  As opcode changes “00”,”01”,”10”,”11”, (0,1,2,3)  output gets a+b, then a-b, then a OR b then a AND c.

Synthesise the example  It works as expected  Synthesise to gate level description  Much quicker and easier than doing it the old fashioned way  More flexible too

Summary  Intro to VHDL  Basic examples for use in lab 1