HDL Programming Fundamentals

Slides:



Advertisements
Similar presentations
Digital System Design-II (CSEB312)
Advertisements

UNIT 2: Data Flow description
HDL Programming Fundamentals
UNIT 8: Synthesis Basics
What are FPGA Power Management HDL Coding Techniques Xilinx Training.
Basic Logic Gates Discussion D5.1 Section Sections 13-3, 13-4.
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
ENEL111 Digital Electronics
Traffic light contoller using FSM
1 COMP541 More on State Machines and Video Scanout Montek Singh Feb 13, 2007.
COMP541 State Machines – II: Verilog Descriptions
Sequential Circuits Storage elements
CDA 3100 Recitation Week 11.
HDL Programming Fundamentals
The Verilog Hardware Description Language
VHDL Refresher ECE 437 April 13, 2015 Motivation ECE 337 is a prerequisite But… –You may have taken 337 a few semesters previous –Breaks causes memory.
Sequential Logic in Verilog
Supplement on Verilog adder examples
Synchronous Sequential Logic
Combinational Logic.
Hardware Description Language (HDL)
LCSL Logic Circuit Simulation Language Bogdan Caprita Julian Maller Sachin Nene Chaue Shen.
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
VHDL Structural Architecture ENG241 Week #5 1. Fall 2012ENG241/Digital Design2 VHDL Design Styles Components and interconnects structural VHDL Design.
Combinational Logic Discussion D2.5. Combinational Logic Combinational Logic inputsoutputs Outputs depend only on the current inputs.
Verilog HDL (Behavioral Modeling) Bilal Saqib. Behavioral Modeling.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI System Design Lecture 4 - Advanced Verilog.
Guest Lecture by Ben Magstadt CprE 281: Digital Logic.
Module : TASKS, Functions and UDPs in Verilog. Functions Functions are declared with the keywords function and endfunction. Functions are used if all.
StateCAD FPGA Design Workshop. For Academic Use Only Presentation Name 2 Objectives After completing this module, you will be able to:  Describe how.
1 VERILOG Fundamentals Workshop סמסטר א ' תשע " ה מרצה : משה דורון הפקולטה להנדסה Workshop Objectives: Gain basic understanding of the essential concepts.
Department of Communication Engineering, NCTU
Lecture 4 – State Machine Design 9/26/20081ECE Lecture 4.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Use of HDLs in Teaching of Computer Hardware Courses Zvonko Vranesic and Stephen Brown University of Toronto.
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
Introduction to ASIC flow and Verilog HDL
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
MIPS Pipeline and Branch Prediction Implementation Shuai Chang.
Introduction to VHDL Coding Wenchao Cao, Teaching Assistant Department of EECS University of Tennessee.
AND Gate Inputs Output Input A (Switch) Input B (Switch) Output Y (Lamp) 0 (Open) 0 (OFF) A B Lamp.
Chapter1: Introduction Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 1-1 Chapter 1: Introduction Prof. Ming-Bo.
VHDL From Ch. 5 Hardware Description Languages. History 1980’s Schematics 1990’s Hardware Description Languages –Increased due to the use of Programming.
State Machine Design Shiva choudhary En No.: Electronics and comm. Dept K.I.T.,Jamnagar 1.
Combinational Design, Part 2: Procedure. 2 Topics Positive vs. negative logic Design procedure.
1 Lecture 1: Verilog HDL Introduction. 2 What is Verilog HDL? Verilog Hardware Description Language(HDL)? –A high-level computer language can model, represent.
State Machine Design with an HDL
1 A hardware description language is a computer language that is used to describe hardware. Two HDLs are widely used Verilog HDL VHDL (Very High Speed.
Unit 7 Mixed Language Descriptions SYLLABUS Highlights of Mixed-Language Description, How to invoke One language from the Other Mixed-language Description.
Adapted from Krste Asanovic
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
Figure 1.1 The Altera UP 1 CPLD development board.
UNIT 8: Synthesis Basics
Topics Modeling with hardware description languages (HDLs).
Lab02 :Logic Gate Fundamentals:
Discussion D5.1 Section Sections 13-3, 13-4
HDL Programming Fundamentals
Using CAD Tools to implement Digital Circuits
Topics Modeling with hardware description languages (HDLs).
HDL Programming Fundamentals
CS341 Digital Logic and Computer Organization F2003
Computer Architecture
HDL Hardware Description Language
State Machine Design with an HDL
Discussion D5.1 Section Sections 13-3, 13-4
UNIT 6: Mixed-Type Description
Basic Logic Gates.
Introduction to Verilog – Part-2 Procedural Statements
Arithmatic Logic Unit (ALU). ALU Input Data :  A0-A3  B0-B3 Output Data :  F0 – F3.
Presentation transcript:

HDL Programming Fundamentals UNIT 5 Procedures, Tasks, and Functions 6.1 Highlights of Procedures, Tasks, and Functions Facts Procedures, Tasks, and Functions are HDL tools to optimize the style of writing the HDL code. They are implemented to refer to a segment or a construct of code. Procedures and Tasks can have more than one input and more than one output. Functions have single output but can have more than one input. Procedures and Functions in VHDL can be called only from within process. Tasks and Functions in Verilog can be called only from within always or initial. HDL Programming Fundamentals

HDL Programming Fundamentals 6.2 Procedures (VHDL) and Tasks (Verilog) procedure exmple (signal a : in std_logic ; signal y: out std_logic) is variable x: std_logic; begin x:= a; case x is ....... end case; y <= x; end exmple; Calling the procedure is a sequential statement process (d,clk) ...... exmple (d,z); ......... End process exmple is the name (identifier) of the procedure HDL Programming Fundamentals

HDL Programming Fundamentals task addr; output cc, dd; input aa, bb; begin cc = aa ^ bb; ............. end endtask addr is the name (identifier) of the task ............ always @ (a,b) begin addr( c,d,a,b); end HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.1 HDL Behavioral Description of Full Adder using Procedure and Task HDL Programming Fundamentals

HDL Programming Fundamentals library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity full_add is port (x,y, cin: in std_logic; sum, cout: out std_logic); end full_add; architecture two_halfs of full_add is -- The full adder is built from two half adders procedure Haddr(sh, ch: out std_logic; ah, bh : in std_logic) is --This procedure describes a half adder begin sh := ah xor bh; ch := ah and bh; end Haddr; addfull: process (x,y,cin) variable sum1, c1, c2, tem1, tem2: std_logic; Haddr (sum1, c1, y, cin); Haddr( tem1, c2, sum1,x); --The above two statements are calls to the procedure Haddr tem2:= c1 or c2; sum <= tem1; cout <= tem2; end process; end two_halfs; HDL Programming Fundamentals

HDL Programming Fundamentals Verilog module Full_add(x,y,cin,sum, cout); //The full adder is built from two half adders input x,y, cin; output sum, cout; reg sum,sum1,c1,c2, cout; always @ (x,y, cin) begin Haddr( sum1,c1,y,cin ); Haddr( sum, c2, sum1,x); //The above two statements are calls to the task Haddr. cout = c1 | c2; end task Haddr; //This task describes half adder output sh, ch; input ah, bh; sh = ah ^ bh; ch = ah & bh; endtask endmodule HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.2 HDL Description of N-bit Ripple-Carry Adder using Procedure and Task Listing 6.2 HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.3 Unsigned Binary Vector to Integer Conversion using Procedure and Task library ieee; use ieee.std_logic_1164.all; Use ieee.numeric_std.all; entity Bin_Int is generic (N : natural :=3); port (X_bin: unsigned (N downto 0); Y_int: out natural; Z: out std_logic); --Y is always positive end Bin_Int; architecture convert of Bin_Int is procedure bti (bin : in unsigned ; int: out natural; signal Z: out std_logic) is -- the procedure bti is to change binary to integer --We chose flag Z to be a signal rather than a variable -- Since the binary vector is always positive we use natural variable result:natural; begin result := 0; for i in bin'Range loop --bin’Range represents the range of the unsigned vector bin --Range is a predefined attribute HDL Programming Fundamentals

HDL Programming Fundamentals Verilog module Bin_Int(X_bin, Y_int, Z); parameter N =3; input [N:0] X_bin; output integer Y_int; output Z; reg Z; always @ (X_bin) begin bti(Y_int,Z, N, X_bin); end task bti; parameter P = N; output integer int; output Z; input N; input [P:0] bin; integer i, result; begin int =0; //change binary to integer for (i=0; i<=P; i=i+1) if (bin[i] == 1) int = int + 2**i; end if (int == 0) Z = 1'b1; else Z = 1'b0; endtask endmodule HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.4 Fraction Binary to Real Conversion using Procedure and Task Listing 6.4 HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.5 Unsigned Integer to Binary Conversion using Procedure and Task Listing 6.5 HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.6 Signed Binary to Integer Conversion using Procedure and Task Listing 6.6 HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.7 Integer to Signed Binary Conversion using procedure Listing 6.7 HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.8 Signed Vector Multiplication Using Procedure and Task Listing 6.8 HDL Programming Fundamentals

HDL Programming Fundamentals Example Enzyme-Substrate Activity Using procedure and task Listing 6.9 HDL Programming Fundamentals

exp is the name (identifier) 6.3 Functions VHDL architecture Behavioral of Func_exm is function exp (a, b: in std_logic) return std_logic is variable d: std_logic; begin d := a xor b; return d; end function exp; exp is the name (identifier) of the function Verilog function exp ; input a,b; begin exp = a ^ b; end endfunction HDL Programming Fundamentals

HDL Programming Fundamentals Example 6.10 Function to Find the Greater of two signed numbers library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.numeric_std.all; entity greater_2 is port (x,y : in signed (3 downto 0) ; z: out signed (3 downto 0)); end greater_2; architecture greater_2 of greater_2 is function grt(a,b : signed (3 downto 0)) return signed is --The above statement declares a function by the name of grt. -- The inputs are 4-bit signed numbers variable temp : signed (3 downto 0); begin if (a >= b) then temp := a; else temp := b; end if; return temp; end grt; process (x,y) z <= grt (x,y); --This is a function call. end process; VHDL HDL Programming Fundamentals

HDL Programming Fundamentals module greater_2(x,y, z); input signed [3:0] x; input signed [3:0] y; output signed [3:0] z; reg signed [3:0] z; always @ (x,y) begin z = grt (x,y);//This is a function call. end function [3:0] grt; /*The above statement declares a function by the name grt; grt is also the output of the function*/ input signed [3:0] a, b; /*The above statement declares two input to the function; both are 4-bit signed numbers.*/ if (a >= b) grt = a; else grt = b; endfunction endmodule Verilog HDL Programming Fundamentals

HDL Programming Fundamentals Example Function to Find the floating sum y = , 0 < x < 1 Listing 6.13 HDL Programming Fundamentals

HDL Programming Fundamentals 6.4 Summary VHDL Commands or Components Verilog Counterpart procedure task function function HDL Programming Fundamentals