HDL Programming Fundamentals

Slides:



Advertisements
Similar presentations
HDL Programming Fundamentals
Advertisements

HDL Programming Fundamentals
Verilog.
LECTURE 4: The VHDL N-bit Adder
Mridula Allani Fall 2010 (Refer to the comments if required) ELEC Fall 2010, Nov 21(Adopted from Profs. Nelson and Stroud)
VHDL ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
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 Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #12) The slides included herein were taken from the materials.
ECE 331 – Digital System Design
Binary-to-BCD Converter
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’.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
Binary-to-BCD Converter
DSD,USIT,GGSIPU1 Entity declaration –describes the input/output ports of a module entity reg4 is port ( d0, d1, d2, d3, en, clk : in std_logic; q0, q1,
VHDL TUTORIAL Preetha Thulasiraman ECE 223 Winter 2007.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
ENG6090 RCS1 ENG6090 Reconfigurable Computing Systems Hardware Description Languages Part 5: Modeling Structure.
Carry look ahead adder P (I) = a(I) xor b(I); G(I) = a(I) and b(I); S(I) = p(I) xor c(I); Carry(I+1) = c(I)p(I) + g(I)
CWRU EECS 317 EECS 317 Computer Design LECTURE 1: The VHDL Adder Instructor: Francis G. Wolff Case Western Reserve University.
Basic Overview of VHDL Matthew Murach Slides Available at:
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 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 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials.
1/8/ L2 VHDL Introcution© Copyright Joanne DeGroat, ECE, OSU1 Introduction to VHDL.
CEC 220 Digital Circuit Design More VHDL Fri, February 27 CEC 220 Digital Circuit Design Slide 1 of 15.
Digital System Projects
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
Verilog hdl – II.
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-1 Chapter 6: Hierarchical.
Unit 4 Structural Descriptions SYLLABUS Highlights of Structural descriptions Organization of the Structural descriptions Binding State Machines Generate(HDL),Generic(VHDL),
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
Unit 7 Mixed Language Descriptions SYLLABUS Highlights of Mixed-Language Description, How to invoke One language from the Other Mixed-language Description.
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.
Hardware Description Languages: Verilog
Combinational logic circuit
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
Behavioral Style Combinational Design with VHDL
UNIT 8: Synthesis Basics
Dataflow Style Combinational Design with VHDL
Lecture 2 Supplement Verilog-01
HDL Programming Fundamentals
Behavioral Style Combinational Design with VHDL
Hardware Description Languages: Verilog
ENG6530 Reconfigurable Computing Systems
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
UNIT 3: Behavioral Descriptions
UNIT 2: Data Flow description
ECE 331 – Digital System Design
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
VHDL VHSIC Hardware Description Language VHSIC
IAS 0600 Digital Systems Design
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
VHDL (VHSIC Hardware Description Language)
Hardware Descriptive Languages these notes are taken from Mano’s book
Chapter 5 – Number Representation and Arithmetic Circuits
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
Step 2 in behavioral modeling. Use of procedures.
Figure 8.1. The general form of a sequential circuit.
UNIT 6: Mixed-Type Description
Supplement on Verilog adder examples
An overview of the Verilog HDL.
EEE2243 Digital System Design Chapter 1: Verilog HDL (Combinational) by Muhazam Mustapha, February 2012.
© Copyright Joanne DeGroat, ECE, OSU
Four Bit Adder Sum A Cin B Cout 10/9/2007 DSD,USIT,GGSIPU.
4-Input Gates VHDL for Loops
COE 202 Introduction to Verilog
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