VHDLPrimeri Poglavlje5.doc

Similar documents
VHDLPrimeri Poglavlje3.doc. end process seq; Slika 3.1: Anatomija osnovne definicije test bench-a

VHDL And Synthesis Review

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

Računarske osnove Interneta (SI3ROI, IR4ROI)

Lecture 5: State Machines, Arrays, Loops. EE 3610 Digital Systems

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

Lecture 38 VHDL Description: Addition of Two [5 5] Matrices

VHDL in 1h. Martin Schöberl

Concurrent Signal Assignment Statements (CSAs)

Sequential Statement

Tutorial 4 HDL. Outline VHDL PROCESS. Modeling Combinational Logic. Structural Description Instantiation and Interconnection Hierarchy

Sequential Logic - Module 5

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

cla library ieee; use ieee.std_logic_1164.all;

CMPT 250: Computer Architecture. Using LogicWorks 5. Tutorial Part 1. Somsubhra Sharangi

VHDL: Code Structure. 1

Review. LIBRARY list of library names; USE library.package.object; ENTITY entity_name IS generic declarations PORT ( signal_name(s): mode signal_type;

Uvod u programiranje - vežbe. Kontrola toka izvršavanja programa

Lattice VHDL Training

VHDL Examples Mohamed Zaky

Programiranje III razred

Basic Language Concepts

VHDL Simulation. Testbench Design

b) program deljiv3; uses wincrt; var i:integer; begin i:=3; while i<100 do begin write(i:5); i:=i+3; end; end.

1. DESCRIPCION EN VHDL DE UN BIESTABLE D SINCRONO POR FLANCO ASCENDENTE CON RESET SINCRONO

Digital Systems Design

Accelerate FPGA Prototyping with

COVER SHEET: Total: Regrade Info: 5 (5 points) 2 (8 points) 6 (10 points) 7b (13 points) 7c (13 points) 7d (13 points)

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

In our case Dr. Johnson is setting the best practices

CCE 3202 Advanced Digital System Design

Osnove programskog jezika C# Čas 5. Delegati, događaji i interfejsi

Sintaksa VHDL jezika - podsjetnik -

Mašinska vizija. Dr Nenad Jovičić tnt.etf.rs/~mv

Mid-Term Exam Solutions

COVER SHEET: Total: Regrade Info: 5 (14 points) 7 (15 points) Midterm 1 Spring 2012 VERSION 1 UFID:

The University of Alabama in Huntsville Electrical and Computer Engineering CPE/EE 422/522 Spring 2005 Homework #6 Solution

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

Σχεδιασμός Κυκλώματος Προσαύξησης στη VHDL

SEQUENTIAL STATEMENTS

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

EITF35: Introduction to Structured VLSI Design

ELCT 501: Digital System Design

EE261: Intro to Digital Design

ECE 545 Lecture 9. Modeling of Circuits with a Regular Structure. Aliases, Attributes, Packages. George Mason University

Polusabirač. design.vhd. testbench.vhd. library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;

Hardware Description Language VHDL (1) Introduction

Constructing VHDL Models with CSA

Mridula Allani Fall Fall

VRIJEDNOSTI ATRIBUTA

Lecture 4. VHDL Fundamentals. George Mason University

File: /home/young/mywork/5.cordic_vhdl/a.beh/print.cordic_beh Page 1 of 10

VHDL Testbench Design. Textbook chapters 2.19, , 9.5

Very High Speed Integrated Circuit Har dware Description Language

[VARIABLE declaration] BEGIN. sequential statements

ECE 545 Lecture 5. Data Flow Modeling in VHDL. George Mason University

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

VHDL. Official Definition: VHSIC Hardware Description Language VHISC Very High Speed Integrated Circuit

The block diagram representation is given below: The output equation of a 2x1 multiplexer is given below:

Deo 3: Sekvencijalni blokovi

VHDL. Chapter 7. Behavioral Modeling. Outline. Behavioral Modeling. Process Statement

1. Defining and capturing the design of a system. 2. Cost Limitations (low profit margin must sell millions)

Izrada VI laboratorijske vježbe

Tutorial on VHDL Compilation, Simulation, and Synthesis

JUNE, JULY 2013 Fundamentals of HDL (10EC45) PART A

Altera s Avalon Communication Fabric

ELE432. ADVANCED DIGITAL DESIGN HACETTEPE UNIVERSITY Designing with VHDL

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit

Hardware Modeling. VHDL Basics. ECS Group, TU Wien

ECE 545 Lecture 7. Modeling of Circuits with a Regular Structure. Aliases, Attributes, Packages. Mixing Design Styles. George Mason University

COE Design Process Tutorial

COVER SHEET: Total: Regrade Info: 1 (8 points) 2 ( 8 points) 3 (16 points) 4 (16 points) 5 (16 points) 6 (16 points) 7 (16 points) 8 (8 points)

Vežbe - XII nedelja PHP Doc

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution Spring 2016

Uvod u relacione baze podataka

VHDL. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

2. Linijska algoritamska struktura

Summary of FPGA & VHDL

VHDL VS VERILOG.

Basic Language Constructs of VHDL

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

Solutions - Homework 2 (Due date: October 9:30 am) Presentation and clarity are very important!

ECE 545: Lecture 11. Programmable Logic Memories

pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

ECE 545: Lecture 11. Programmable Logic Memories. Recommended reading. Memory Types. Memory Types. Memory Types specific to Xilinx FPGAs

MATLAB AND MODELSIM LINKING

EITF35: Introduction to Structured VLSI Design

-- Fill in values for each generic. -- Fill in values for each signal. SIGNAL load_start : std_ulogic := '1'; SIGNAL clock : std_ulogic := '0';

Design a 4 bit-adder. Then design a 4-7 decoder to show the outputs. Output Sum(4 bits) Adder. Output carry(1 bit)

5. 0 VHDL OPERATORS. The above classes are arranged in increasing priority when parentheses are not used.

Codec. WM8731 Audio Codec

CPE 626 Advanced VLSI Design Lecture 6: VHDL Synthesis. Register File: An Example. Register File: An Example (cont d) Aleksandar Milenkovic

CCE 3202 Advanced Digital System Design

Hardware Description Languages. Modeling Complex Systems

VHDL par Ahcène Bounceur VHDL

Lab # 5. Subprograms. Introduction

Transcription:

5. VHDL opis kola koja obavljaju osnovne aritmetičke funkcije Sabirači Jednobitni potpuni sabirač definisan je tablicom istinitosti iz Tabele 5.1. Tabela 5.1. cin a b sum cout 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 VHDL opis dat je na primeru 5.1, dok je šema hardverske realizacije prikazana na Slici 5.1.a, a blok šema sabirača na slici 5.1.b. Primer 5.1 File: c:\peca\my designs\potpunisabirac1\src\potpunisabirac1.vhd created by Design Wizard: 12/22/01 20:22:00 {{ Section below this comment is automatically maintained and may be overwritten {entity {PotpuniSabirac1} architecture {PotpuniSabirac1}} use IEEE.std_logic_1164.all; entity PotpuniSabirac1 is port ( a: in STD_LOGIC; b: in STD_LOGIC; cin: in STD_LOGIC; sum: out STD_LOGIC; cout: out STD_LOGIC end PotpuniSabirac1; }} End of automatically maintained section architecture PotpuniSabirac1 of PotpuniSabirac1 is <<enter your statements here>> sum <= ((a XOR b) XOR cin cout <= (a AND b) OR (a AND cin) OR (b AND cin end PotpuniSabirac1;

b cin cout_1 a un2_cout cout cout un4_cout sum Slika 5.1: Jednobitni potpuni sabirač a) Realizacija (Primer 5.1 b) blok šema sum

Višebitni sabirač može da se opiše kao n-to bitni na način koji pokazuje Primer 5.2 u kome je opisan n=4. Primer 5.2 File: c:/peca/my designs/potpunisabiracnđsrcđpotpunisabiracn.vhd created by Design Wizard: 12/22/01 20:59:56 {{ Section below this comment is automatically maintained and may be overwritten {entity {PotpuniSabiracN} architecture {PotpuniSabiracN}} use IEEE.std_logic_1164.all; entity PotpuniSabiracN is generic ( n: integer := 4 port ( a: in STD_LOGIC_VECTOR (n-1 downto 0 b: in STD_LOGIC_VECTOR (n-1 downto 0 cin: in STD_LOGIC; sum: out STD_LOGIC_VECTOR (n-1 downto 0 cout: out STD_LOGIC end PotpuniSabiracN; }} End of automatically maintained section architecture PotpuniSabiracN of PotpuniSabiracN is <<enter your statements here>> Zbir: process (a, b, cin) variable Prenos: STD_LOGIC_VECTOR (n downto 0 variable LokalniZbir: STD_LOGIC_VECTOR (n-1 downto 0 Prenos (0) := cin; for i in 0 to n - 1 loop LokalniZbir(i) := (a(i) XOR b(i)) XOR Prenos(i Prenos (i+1) := (a(i) AND b(i)) OR (Prenos(i) AND (a(i) OR b(i)) end loop; sum <= LokalniZbir; cout <= Prenos(n end process Zbir; end PotpuniSabiracN;

Paket numeric_std obuhvata i signed i unsigned std_logic tipove. Uvodjenje operatora nad vektorima std_logic značajno pojednostavljuje opis hardvera. Primer 5.3: Title : Sabirac4 Design : SabiracN Author : Predrag Petkovic Company : LEDA laboratorija, EF - Nis File : Sabirac4.vhd Generated : Sun Mar 13 22:44:43 2005 From : interface description file By : Itf2Vhdl ver. 1.20 Description : {{ Section below this comment is automatically maintained and may be overwritten {entity {Sabirac4} architecture {Sabirac4}} use IEEE.STD_LOGIC_1164.all; use IEEE.numeric_std.all; entity Sabirac4 is generic ( n: integer :=4 port( a : in unsigned(3 downto 0 b : in unsigned(3 downto 0 sum : out unsigned(3 downto 0) end Sabirac4; }} End of automatically maintained section architecture Sabirac4 of Sabirac4 is enter your statements here sum <= a + b; end Sabirac4; a b + sum_1[1:4] [1:4] [1:4] sum Slika 5.3: Grafička interpretacija sabirača iz Primera 5.3

Primena unsigned tipa i + operatora u opisu potpunog n-bitnog sabirača koji bi odgovarao onom iz primera 5.2 data je u primeru 5.4. Primer 5.4: File: c:\peca\my designs\potpunisabiracun\src\potpunisabiracun.vhd created by Design Wizard: 12/23/01 11:05:44 {{ Section below this comment is automatically maintained and may be overwritten {entity {PotpuniSabiracUN} architecture {PotpuniSabiracUN}} use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity PotpuniSabiracUN is generic (n: integer :=4 port ( a: in STD_LOGIC_VECTOR (n-1 downto 0 b: in STD_LOGIC_VECTOR (n-1 downto 0 cin: in STD_LOGIC_VECTOR (0 downto 0 sum: out STD_LOGIC_VECTOR (n-1 downto 0 cout: out STD_LOGIC end PotpuniSabiracUN; }} End of automatically maintained section architecture PotpuniSabiracUN of PotpuniSabiracUN is <<enter your statements here>> Zbir: process (a, b, cin) variable LokalSum: unsigned (n downto 0 variable LokalCin : unsigned (0 downto 0 LokalCin := unsigned(cin LokalSum := unsigned('0' & a) + unsigned('0' & b LokalSum := LokalSum + LokalCin; sum <= std_logic_vector( LokalSum(n-1 downto 0) cout <= std_logic(lokalsum(n) end process Zbir; end PotpuniSabiracUN;

Akumulatori Opis akumulatora n-bitnog signala (sa n=4) koji uvećava vrednost pri svakoj prednjoj ivici kloka i asinhronim resetom dat je na primeru 5.5, a odgovarajuća hardverska realizacija na slici 5.4. Primer 5.5: File: c:\peca\my designs\akumulatorn\src\akumulatorn.vhd created by Design Wizard: 12/23/01 13:01:42 {{ Section below this comment is automatically maintained and may be overwritten {entity {AkumulatorN} architecture {AkumulatorN}} use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity AkumulatorN is generic (n: integer :=4 port ( a: in STD_LOGIC_VECTOR (n-1 downto 0 clk: in STD_LOGIC; rst: in STD_LOGIC; acc: out STD_LOGIC_VECTOR (n-1 downto 0) end AkumulatorN; }} End of automatically maintained section architecture AkumulatorN of AkumulatorN is signal LokalAcc: unsigned (n-1 downto 0 <<enter your statements here>> Akumuliraj: process (clk, rst) if (rst = '1') then LokalAcc <= (others =>'0' elsif (clk'event and clk = '1') then LokalAcc <= LokalAcc + unsigned(a end if; end process Akumuliraj; acc <= std_logic_vector(lokalacc end AkumulatorN;

clk a + [1:4] un2_lokalacc[1:4] [1:4] D Q R acc rst lokalacc Slika 5.4: Grafička interpretacija akumulatora iz Primera 5.5

Brojači Primer 5.6 use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity Up_counter is port ( clk: in STD_LOGIC; izlaz: out STD_LOGIC_VECTOR (3 downto 0) end Up_counter; }} End of automatically maintained section architecture Up_counter of Up_counter is <<enter your statements here>> signal LokalniBrojac: unsigned (3 downto 0):="0000"; Dodaj_1: process (clk) if (clk'event and clk ='1') then LokalniBrojac <= LokalniBrojac + 1; end if; end process Dodaj_1; izlaz <= std_logic_vector(lokalnibrojac end Up_counter; Napomena: Signal LokalniBrojac koristi se iz dva razloga: - Operacija + odnosi se na tip std_logic, a ne na std_logic_vector; + postoji samo za tipove unsigned i signed koji su, takodje, vektori čiji su elementi tipa std_logic; - izlaz je moda out, tako da ne može da se nadje sa desne strane iskaza (ne može da se definiše izlaz = izlaz + 1). Treba uočiti da if...then struktura nije kompletirana. Ovo u realizaciji izaziva povratnu vezu sa izalaza na ulaz, kao što pokazuje slika 5.5. clk 1 + [1:4] [1:4] D Q un2_lokalnibrojac[1:4] lokalnibrojac Slika 5.5 Realizacija jednostavnog brojača unapred (Primer 5.6) izlaz

Primer 5.7 ilustrje opis brojača unazad, kod koga se posle svake ivice kloka, stanje brojača smanjuje za 3. Brojač ima asinhroni reset signal kojim se izlaz postavlja u stanje koje je definisano četvorobitnim signalom start (u našem primeru to je stanje 1111 ). Primer 5.7 Title : Down_Counter3 Design : Down_counter3 Author : Predrag Petkovic Company : LEDA Laboratorija, EF - Nis File : Down_Counter3.vhd Generated : Mon Mar 14 20:01:07 2005 From : interface description file By : Itf2Vhdl ver. 1.20 Description : {{ Section below this comment is automatically maintained and may be overwritten {entity {Down_Counter3} architecture {Down_Counter3}} use IEEE.STD_LOGIC_1164.all; use IEEE.numeric_std.all; entity Down_Counter3 is port( clk : in STD_LOGIC; start : in STD_LOGIC_VECTOR(3 downto 0 rst : in STD_LOGIC; izlaz : out STD_LOGIC_VECTOR(3 downto 0) end Down_Counter3; }} End of automatically maintained section architecture Down_Counter3 of Down_Counter3 is signal LokalniBrojac: unsigned (3 downto 0):=unsigned(start enter your statements here Oduzmi_3: process (clk, rst, start) if rst ='1' then LokalniBrojac <= unsigned(start elsif (clk'event and clk ='1') then LokalniBrojac <= LokalniBrojac - "11"; end if; end process Oduzmi_3; izlaz <= std_logic_vector(lokalnibrojac end Down_Counter3;

Ovaj primer ilustruje primenu asinhronog reseta, konverziju std_logic_vector u unsigned vektor funkcijom unsigned() i definisanje dekrementa kao unsigned vektora dužine kraće od LokalniBrojac range. Slika 5.6 Odziv brojača unazad (Primer 5.7)