Topic 3: VHDL José Nelson Amaral Paul Berube Paras Mehta

Slides:



Advertisements
Similar presentations
INTRO TO VHDL Appendix A: page page VHDL is an IEEE and ANSI standard. VHDL stands for Very High Speed IC hardware description language.
Advertisements

Verilog Intro: Part 1.
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 VHDL Tutorial R. E. Haskell and D. M. Hanna T1: Combinational Logic Circuits.
Mini-MIPS From Weste/Harris CMOS VLSI Design. CS/EE 3710 Based on MIPS  In fact, it’s based on the multi-cycle MIPS from Patterson and Hennessy Your.
02/02/20091 Logic devices can be classified into two broad categories Fixed Programmable Programmable Logic Device Introduction Lecture Notes – Lab 2.
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.
CMPUT Computer Organization and Architecture II1 CMPUT329 - Fall 2003 TopicI: Building a Multicycle Data Path and a Control Path for a Microprocessor.
Sistemas Digitais I LESI - 2º ano Lesson 5 - VHDL U NIVERSIDADE DO M INHO E SCOLA DE E NGENHARIA Prof. João Miguel Fernandes Dept.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
CMPUT Computer Organization and Architecture II1 CMPUT229 - Fall 2003 TopicE: Building a Data Path and a Control Path for a Microprocessor José Nelson.
1/31/20081 Logic devices can be classified into two broad categories Fixed Programmable Programmable Logic Device Introduction Lecture Notes – Lab 2.
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.
CMPUT Computer Organization and Architecture II1 CMPUT329 - Fall 2003 TopicH: Building a Data Path and a Control Path for a Microprocessor José Nelson.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Fall 08, Oct 29ELEC Lecture 7 (updated) 1 Lecture 7: VHDL - Introduction ELEC 2200: Digital Logic Circuits Nitin Yogi
CMPUT Computer Organization and Architecture II 1 CMPUT329 - Fall 2003 Topic 6: Testbenches Paras Mehta and José Nelson Amaral.
1 H ardware D escription L anguages Basic Language Concepts.
ECE 2372 Modern Digital System Design
Digital Arithmetic and Arithmetic Circuits
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.
LECTURE 8: VHDL PROCESSES
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.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
VHDL IE- CSE. What do you understand by VHDL??  VHDL stands for VHSIC (Very High Speed Integrated Circuits) Hardware Description Language.
A full die photograph of the MIPS R2000 RISC Microprocessor is shown above. The 1986 MIPS R2000 with five pipeline stages and 450,000 transistors was the.
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.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
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.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
VHDL Basics. VHDL BASICS 2 OUTLINE –Component model –Code model –Entity –Architecture –Identifiers and objects –Operations for relations VHDL ET062G &
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
Another Example: MIPS From the Harris/Weste book Based on the MIPS-like processor from the Hennessy/Patterson book.
1 MIPS VHDL Overview Reference: VHDL Tutorial on CDROM, or Accolade Reference Guide Notes: / / pdf / MIPS_vhdl_notes.pdf.
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)
5-1 Logic System Design I VHDL Design Principles ECGR2181 Reading: Chapter 5.0, 5.1, 5.3 port ( I: in STD_LOGIC_VECTOR (1 to 9); EVEN, ODD: out STD_LOGIC.
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 Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Slide 1 3.VHDL/Verilog Description Elements. Slide 2 To create a digital component, we start with…? The component’s interface signals Defined in MODULE.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 2.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
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.
Multi-Cycle Datapath and Control
Basic Language Concepts
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Multi-Cycle CPU.
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
VHDL VHSIC Hardware Description Language VHSIC
VHDL Hardware Description Language
Vishwani D. Agrawal James J. Danaher Professor
Data Flow Description of Combinational-Circuit Building Blocks
Processor: Multi-Cycle Datapath & Control
Data Flow Description of Combinational-Circuit Building Blocks
Single Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
The Processor: Datapath & Control.
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

Topic 3: VHDL José Nelson Amaral Paul Berube Paras Mehta CMPUT329 - Fall 2003 Topic 3: VHDL José Nelson Amaral Paul Berube Paras Mehta

Reading Assigment Chapter 4: Sections 4.7.0 to 4.7.4

PCSource TargetWrite 1 2 M u x Target 32 4 32 26 PcWrite MemRead 1 2 M u x Target 32 4 Conc/ Shift left 2 32 26 PcWrite MemRead RegDst MemWrite ALUSelA IorD IRWrite MemtoReg RegWrite PC M u x 1 M u x 1 I[25-21] Read address Read register 1 Instruction [31-26] I[20-16] Read data 1 Read register 2 Zero Memory Write address M u x 1 ALUSelB ALU result Instruction [25-0] Write register Read data 2 MemData M u x 1 2 3 ALU Write data Instruction register Write data 4 ALU control ALUOp [15-11] 1 M u x Registers 32 I[15-0] Sign ext. Shift left 2 16

Motivating Example: Arithmetic Logic Unit Important part of datapath in CPU architecture Like all hardware, can be designed in VHDL Useful example because it can be easily decomposed operand1 alu_result ALU operand2 ALU operation opcode

Motivating Example: Arithmetic Logic Unit Set of operations: operand1 alu_result ALU Logic AND OR XOR NOT operand2 ALU operation opcode Arithmetic add subtract multiply negate

ALU Structure Arithmetic Module Logic arithmetic operation MUX logic 2 arith_result logic_result operand1 operand2 alu_result 1 opcode selection

ALU Structure ALU Arithmetic Module Logic MUX 2 1 selection arith_result logic_result operand1 operand2 alu_result 2 opcode 1 selection

VHSIC Hardware Description Language Very High Speed Integrated Circuit VHDL VHSIC Hardware Description Language Very High Speed Integrated Circuit Development sponsored by the IEEE and the US DoD in mid-1980s Based on ADA (somehow similar to Pascal)

VHDL Features Designs organized hierarchically Each design element has: A well-defined interface A precise behavioral specification using either: algorithmic description hardware structural description Models concurrency, timing, and clocking: Handles asynchronous and synchronous circuits Designs can be simulated

VHDL Hierarchical Program Structure architecture A entity A entity is a “wrapper” with “hooks” for an architecture A higher level architecture instantiates lower level entities. architecture B entity B architecture C entity C architecture D entity D architecture E entity E architecture F entity F

ALU Structural Picture alu_arch alu arithmetic_module logic_module mux_arch mux Multiplexor arithmetic_module_arch logic_module_arch Arithmetic Functionality Logic Functionality

VHDL Program File Structure text file (e.g., mydesign.vhd) entity declaration architecture definition

Entity Declaration Syntax: out inout buffer Modes: in Final signal has entity entity-name is port ( signal-name: mode signal-type; ... signal-name: mode signal-type); end entity-name; Syntax: Final signal has no semi-colon Built-in or user-defined

Example – ALU Syntax: ALU entity entity-name is port ( operand1 signal-name: mode signal-type; ... signal-name: mode signal-type); end entity-name; Syntax: operand1 alu_result ALU operand2 opcode entity alu is port( operand1: in std_logic_vector(7 downto 0); operand2: in std_logic_vector(7 downto 0); opcode: in std_logic_vector(2 downto 0); alu_result: out std_logic_vector(7 downto 0)); end alu;

ALU Structure How do we describe this structure? 2 MUX Arithmetic Module Logic arith_result logic_result operand1 operand2 First we need to describe these components! alu_result 1 opcode

Structural VHDL – Component Declaration A component must be declared before it can be used declaration before architecture 'begin' statement component component-name port( signal-name: signal-type; . . . ); end component; Syntax:

Arithmetic Module Logic Module MUX operation operandA result inputA operandB output Logic Module operation result inputB operandA selection operandB component arithmetic_module port( operation: in std_logic_vector (1 downto 0); operandA: in std_logic_vector (7 downto 0); operandB: in std_logic_vector (7 downto 0); result: out std_logic_vector (7 downto 0); ); end component;

Arithmetic Module Logic Module MUX operation operandA result inputA operandB output Logic Module operation result inputB operandA selection operandB component logic_module port( operation: in std_logic_vector (1 downto 0); operandA: in std_logic_vector (7 downto 0); operandB: in std_logic_vector (7 downto 0); result: out std_logic_vector (7 downto 0); ); end component;

Arithmetic Module Logic Module MUX operation operandA result inputA operandB output Logic Module operation result inputB operandA selection operandB component mux port( selection: in std_logic; inputA: in std_logic_vector (7 downto 0); inputB: in std_logic_vector (7 downto 0); output: out std_logic_vector (7 downto 0); ); end component;

Signals In VHDL, signals: represent wires in hardware are assigned to and read from (like variables in traditional programming languages) signal signal-name : signal-type; signal signal-name : signal-type := initial-value; Declarations: signal-name <= constant-value; signal-name <= signal-name; signal-name <= expression; Assignments:

signal arith_result : std_logic_vector(7 downto 0); Arithmetic Module MUX operation arith_result operandA result inputA operandB alu_result output Logic Module operation logic_result result inputB operandA selection operandB signal arith_result : std_logic_vector(7 downto 0); signal logic_result : std_logic_vector(7 downto 0);

Arithmetic Module Logic Module MUX arith_result alu_result operation arith_result operandA result inputA operandB alu_result output Logic Module operation logic_result result inputB architecture alu_arch of alu is • • • begin Inst_alu_arith: arithmetic_module Port Map ( result => arith_result ); Inst_alu_mux: mux inputA => arith_result, inputB => logic_result, output => alu_result end alu_arch operandA selection operandB

ALU Structure How do we connect the inputs and output of the ALU to the modules? 2 MUX Arithmetic Module Logic arith_result logic_result operand1 operand2 alu_result 1 opcode Though the Port Maps in the component instantiations.

Arithmetic Module Logic Module MUX opcode(1-0) operand1 arith_result operation operand1 arith_result operandA result inputA operand2 operandB alu_result output Logic Module opcode(1-0) operation logic_result result inputB operand1 operandA selection operand2 operandB opcode(2) architecture alu_struct_arch of alu is • • • begin Inst_alu_arith: arithmetic_module Port Map ( operation => opcode(1 downto 0) operandA => operand1 operandB => operand2 result => arith_result ); • • • Inst_logic_arith: logic_module Port Map ( operation => opcode(1 downto 0) operandA => operand1 operandB => operand2 result => arith_result );

Arithmetic Module Logic Module MUX opcode(1-0) operand1 arith_result operation operand1 arith_result operandA result inputA operand2 operandB alu_result output Logic Module opcode(1-0) operation logic_result result inputB operand1 operandA selection operand2 operandB opcode(2) • • • Inst_alu_mux: mux Port Map ( selection => opcode(2); inputA => arith_result, inputB => logic_result, output => alu_result ); end alu_struct_arch

If-Then-Else Statements Used for conditional behaviour if condition then statements elsif condition then ... else end if; Syntax: if signal_1 = '1' then signal_2 <= signal_3; else signal_2 <= signal_4; end if; Example:

Processes Processes are used in VHDL to separate behaviours within an architecture sensitivity list indicates signals the process should respond to if-then-else structure only used within process Process-Name: process (sensitivity-list) begin statements end process; Syntax:

Process example: Defining the function of the MUX Functionally, the multiplexor outputs either inputA or inputB, depending on the value of the selection. Therefore the mux is sensitive to all its inputs. architecture mux_arch of mux is begin SelectionProcess: process (inputA,inputB,selection) if selection = ’0' then output <= inputA; else output <= inputB; end if; end process; end mux_arch;

MUX entity Although MUX is defined as a component in the ALU, it must be also defined as an independent entity so that it can be reused in other designs. entity mux is Port( selection: in std_logic; inputA: in std_logic_vector (7 downto 0); inputB: in std_logic_vector (7 downto 0); output: out std_logic_vector (7 downto 0); ); end mux;

Constants Provide constant values for settings, etc. used as in other programming languages constant constant-name : constant-type := value Example: constant ADDR_MAX: integer := 16; constant INCLUDE_BUF: boolean := true;

Constant Example: Operations in arith. mod. architecture arithmetic_module_arch of arithmetic_module is architecture alu_arith_arch of alu_arith is -- declare math opcode constants constant ADD : std_logic_vector(1 downto 0) := "00"; constant SUB : std_logic_vector(1 downto 0) := "01"; constant MUL : std_logic_vector(1 downto 0) := "10"; constant NEG : std_logic_vector(1 downto 0) := "11"; begin • • • end arithmetic_module_arch; constant constant-name : constant-type := value

Modifying Existing Code So far we coded the ALU to operate with 8 bit operands and result. If now we want an ALU to operate with 16 bit operands and results, we will have to change the code in many places. VHDL provide Generics and Generic Statements that can be used to build much more flexible designs.

Generic Generics are used in entity declaration define constants in the architecture Syntax: entity entity-name generic( generic-name: type := default-value; . . . ); port( end entity; Undefined generics (in structural designs) take this value

Complete Arithmetic Module Entity Definition entity arithmetic_module is Generic ( OPERAND_WIDTH : integer := 8 ); port( operation: in std_logic_vector (OPERAND_WIDTH-1 downto 0); operandA: in std_logic_vector (OPERAND_WIDTH-1 downto 0); operandB: in std_logic_vector (OPERAND_WIDTH-1 downto 0); result: out std_logic_vector (OPERAND_WIDTH-1 downto 0); end arithmetic_module;

Case Statements Used to enumerate cases of expression Example: Syntax: case signal_1 is when “00” => signal_2 <= '1'; signal_3 <= '0'; when “10” => signal_2 <= '0'; signal_3 <= '1'; when others => end case; Example: case condition is when value => statements . . . when others => end case Syntax:

Case Statement Example: Function of Arithmetic Mod. architecture arithmetic_module_arch of arithmetic_module is -- multiplication returns a result with length = sum of lengths of operands signal ext_result : std_logic_vector(OPERAND_WIDTH*2-1 downto 0); begin EVAL_ARITH: process(operandA, operandB, operation) case operation is when ADD => ext_result(OPERAND_WIDTH-1 downto 0) <= operand1 + operand2; when SUB => ext_result(OPERAND_WIDTH-1 downto 0) <= operand1 - operand2; when MUL => ext_result <= operand1 * operand2; when NEG => ext_result(OPERAND_WIDTH-1 downto 0) <= ZERO - operand1; -- cover all cases not explicitly stated in case statement when others => ext_result <= (others => '0'); end case; end process EVAL_ARITH; end arithmetic_module_arch;

Makes all values 256 bits wide Generalizing Code architecture alu_struct_arch of alu_struct is component alu_mux generic ( DATA_WIDTH: integer; ); port ( . . . ); end component; . . . begin inst_alu_mux : alu_mux generic map( DATA_WIDTH => 256 ) port map ( . . . ); end architecture; Example: Makes all values 256 bits wide

Generate one piece of code for each element in range Generalizing Code Generate Statements used to conditionally write code in architectures: can generate parallel code or decide whether or not to generate code Generate one piece of code for each element in range Syntax: generate-name: for identifier in range generate statements . . . end generate; generate name: if condition generate Generate code only if condition holds

Generalizing Code Example: 16 x n RAM existing component for 16 entry x 1 bit RAM want to build multi-bit RAM 1 . 14 15 1 . 14 15 n-1 n-2 . . . One entry n bits wide One-bit wide

Generalizing Code Example: 16 x n RAM Corresponds to n signal write_data : std_logic_vector(DATA_WIDTH-1 downto 0); signal read_data : std_logic_vector(DATA_WIDTH-1 downto 0); signal addr_sig: std_logic_vector(ADDRESS_WIDTH-1 downto 0); RamGen: for i in 0 to DATA_WIDTH-1 generate RamInst: Ram16x1 port map( web => web_sig, clk => clk, data_in => write_data(i), data_out => read_data(i), addr => addr_sig ); end generate; 16 entries => 4 bits each bit in separate RAM

VHDL Types IEEE Defined Types: std_logic used to define signals in hardware std_logic_vector used to define buses (collection of multiple signals) std_logic std_logic_vector signal signal-name: std_logic; signal bus-name: std_logic_vector (start to end); signal bus-name: std_logic_vector (start downto end);

VHDL Types Useful Built-in Types integer: defined as in other languages, though its width is inferred boolean: as in other languages signal signal-name: boolean := true; signal int-name: integer range start to end;