(1) D Flip-Flop with Asynchronous Reset. (2) 4:1 Multiplexor. CS/EE120A VHDL Lab Programming Reference



Similar documents
Digital Design with VHDL

ECE 3401 Lecture 7. Concurrent Statements & Sequential Statements (Process)

12. A B C A B C A B C 1 A B C A B C A B C JK-FF NETr

More Verilog. 8-bit Register with Synchronous Reset. Shift Register Example. N-bit Register with Asynchronous Reset.

if-then else : 2-1 mux mux: process (A, B, Select) begin if (select= 1 ) then Z <= A; else Z <= B; end if; end process;

Lenguaje VHDL. Diseño de sistemas digitales secuenciales

VGA video signal generation

An Example VHDL Application for the TM-4

Using Xilinx ISE for VHDL Based Design

VHDL GUIDELINES FOR SYNTHESIS

ECE232: Hardware Organization and Design. Part 3: Verilog Tutorial. Basic Verilog

State Machines in VHDL

CNC FOR EDM MACHINE TOOL HARDWARE STRUCTURE. Ioan Lemeni

VHDL programmering H2

A CPLD VHDL Introduction

Finite State Machine Design and VHDL Coding Techniques

Sprites in Block ROM

ECE 451 Verilog Exercises. Sept 14, James Barnes

Modeling Registers and Counters

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

Asynchronous & Synchronous Reset Design Techniques - Part Deux

FINITE STATE MACHINE: PRINCIPLE AND PRACTICE

In this example the length of the vector is determined by D length and used for the index variable.

Memory Elements. Combinational logic cannot remember

Digital Design with Synthesizable VHDL

Introduction to Programmable Logic Devices. John Coughlan RAL Technology Department Detector & Electronics Division

Step : Create Dependency Graph for Data Path Step b: 8-way Addition? So, the data operations are: 8 multiplications one 8-way addition Balanced binary

CPE 462 VHDL: Simulation and Synthesis

Registers & Counters

Combinational-Circuit Building Blocks

Digital Systems Design. VGA Video Display Generation

Computer organization

Hardware Implementation of the Stone Metamorphic Cipher

! " # # $ '"() * #! +, # / $0123$

Implementation of Web-Server Using Altera DE2-70 FPGA Development Kit

Designing Digital Circuits a modern approach. Jonathan Turner

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Lab 7: VHDL 16-Bit Shifter

LAB #3 VHDL RECOGNITION AND GAL IC PROGRAMMING USING ALL-11 UNIVERSAL PROGRAMMER

To design digital counter circuits using JK-Flip-Flop. To implement counter using 74LS193 IC.

AES (Rijndael) IP-Cores

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY

Register File, Finite State Machines & Hardware Control Language

From UML to HDL: a Model Driven Architectural Approach to Hardware-Software Co-Design

VHDL Test Bench Tutorial

Modeling Latches and Flip-flops

Memory unit. 2 k words. n bits per word

Layout of Multiple Cells

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

Fractional Burst Clock Data Recovery for XG-PON Applications Author: Paolo Novellini and Massimo Chirico

From VHDL to FPGA

Digital Design and Synthesis INTRODUCTION

Introduction to the Altera Qsys System Integration Tool. 1 Introduction. For Quartus II 12.0

5 A structured VHDL design method

Lecture 10 Sequential Circuit Design Zhuo Feng. Z. Feng MTU EE4800 CMOS Digital IC Design & Analysis 2010

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

ECE380 Digital Logic

Asynchronous Counters. Asynchronous Counters

Combining the ADS1202 with an FPGA Digital Filter for Current Measurement in Motor Control Applications

Lecture 11: Sequential Circuit Design

Lecture 10: Sequential Circuits

Manchester Encoder-Decoder for Xilinx CPLDs

Digital Logic Design Sequential circuits

Sequential Circuits. Combinational Circuits Outputs depend on the current inputs

Cascaded Counters. Page 1 BYU

Design Example: Counters. Design Example: Counters. 3-Bit Binary Counter. 3-Bit Binary Counter. Other useful counters:

Sistemas Digitais I LESI - 2º ano

Floating point package user s guide By David Bishop (dbishop@vhdl.org)

Rotary Encoder Interface for Spartan-3E Starter Kit

16-bit ALU, Register File and Memory Write Interface

Using SystemVerilog Assertions for Creating Property-Based Checkers

Lecture-3 MEMORY: Development of Memory:

SystemVerilog Is Getting Even Better!

The Boundary Scan Test (BST) technology

CHAPTER 11 LATCHES AND FLIP-FLOPS

ModelSim-Altera Software Simulation User Guide

Combinational Logic Design Process

Hardware Implementations of RSA Using Fast Montgomery Multiplications. ECE 645 Prof. Gaj Mike Koontz and Ryon Sumner

Chapter 5 :: Memory and Logic Arrays

ASYNCHRONOUS COUNTERS

VENDING MACHINE. ECE261 Project Proposal Presentaion. Members: ZHANG,Yulin CHEN, Zhe ZHANG,Yanni ZHANG,Yayuan

Introduction. Jim Duckworth ECE Department, WPI. VHDL Short Course - Module 1

MICROPROCESSOR AND MICROCOMPUTER BASICS

Timing Methodologies (cont d) Registers. Typical timing specifications. Synchronous System Model. Short Paths. System Clock Frequency

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

Serial port interface for microcontroller embedded into integrated power meter

VHDL Reference Manual

Lecture 8: Synchronous Digital Systems

PROTOTYPE DEVELOPMENT OF FPGA BASED PS/2 MOUSE CONTROLLED PCB DRILL MACHINE

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Transcription:

VHDL is an abbreviation for Very High Speed Integrated Circuit Hardware Description Language, and is used for modeling digital systems. VHDL coding includes behavior modeling, structure modeling and dataflow modeling, After studying the following simple examples, you will quickly become familiar with its syntax and reserved words (in bold). Please note that these codes are only for your reference, NOT the exact solution for EE/CS120A s Hwk/Lab/Project. However, if you spend some time to understand all of them, it could be very helpful, even for the future class EE/CS120B. Have fun! (1) D Flip-Flop with Asynchronous Reset entity dff_async_rst is port( data, clk, reset: in std_logic; q: out std_logic); end dff_async_rst; architecture behav of dff_async_rst is process(clk,reset) if (reset= 0 ) then q<= 0 ; elsif (clk event and clk= 1 ) then q<=data; end behav; (2) 4:1 Multiplexor entity mux is port( c,d,e,f: in std_logic; s: in std_logic_vector(1 downto 0); muxout: out std_logic); end mux; architecture my_mux of mux is mux1: process(s,c,d,e,f) case s is when 00 => muxout <= c; when 01 => muxout <= d; when 10 => muxout <= e; when others => muxout <= f; end process mux1; end my_mux; Page 1 of 5

(3) Shift Register entity shift is port( d_in,clk,resetn: in std_logic; d_out: out std_logic ); end shift; architecture shift_reg of shift is process(clk,d_in,d_out) variable REG: std_logic_vector(2 downto 0):=( 0, 0, 0 ); if resetn= 0 then REG (2 downto 0):=( 0, 0, 0 ); elsif clk event and clk= 1 then REG:= d_in & REG(2 downto 1); d_out<=reg(0); end shift_reg; (4) 4-bit Up Counter with Enable and Asynchronous Reset use IEEE.std_logic_unsigned.all; use IEEE.std_logic_arith.all; entity counter4 is port( clk,en,rst: in std_logic; count: out std_logic_vector(7 downto 0)); end counter4; architecture behav of counter4 is signal cnt: std_logic_vector (3 downto 0); process(clk,en,cnt,rst) if (rst= 0 ) then cnt <= (others => 0 ); elsif (clk event and clk= 1 ) then if (en= 1 ) then cnt <= cnt+ 1 ; count <= cnt; end behav; Page 2 of 5

(5) 2-4 Decoder entity decode is port( Ain: in std_logic_vector(1 downto 0); En: in std_logic; Yout: out std_logic(3 downto 0)); end decode; architecture decode_arch of decode is process(ain) if (En= 0 ) then Yout <= (others=> 0 ); else case Ain is when 00 => Yout<= 0001 ; when 01 => Yout<= 0010 ; when 10 => Yout<= 0100 ; when 11 => Yout<= 1000 ; end decode_arch; (6) 8-bit Comparator/Comparator Cell entity cmp_cell is port( a,b: in std_logic; Cin: in std_logic_vector(1 downto 0); Cout: out std_logic_vector(1 downto 0)); end decode; architecture cmp_cell of cmp_cell is process(cin,a,b) if Cin= 10 then Cout<= 10 ; elsif Cin= 01 then Cout<= 01 ; elsif Cin= 00 and a=b then Cout<= 00 ; elsif Cin= 00 and a>b then Cout<= 01 ; elsif Cin= 00 and a<b then Cout<= 10 ; end cmp_cell; Page 3 of 5

entity comparator_8 is port( A,B: in std_logic_vector(7 downto 0); CMPIN: in std_logic_vector(1 downto 0); CMPOUT: out std_logic_vector(1 downto 0)); end comparator_8; architecture cmp_8 of comparator_8 is component cmp_cell port( a,b: in std_logic; Cin: in std_logic_vector(1 downto 0); Cout: out std_logic_vector(1 downto 0)); end component; signal OUT0,OUT1,OUT2,OUT3,OUT4,OUT5,OUT6:std_logic_vector(1 downto 0); cell0:cmp_cell port map(a(0),b(0),cmpin,out0); cell1:cmp_cell port map(a(1),b(1),out0,out1); cell2:cmp_cell port map(a(2),b(2),out1,out2); cell3:cmp_cell port map(a(3),b(3),out2,out3); cell4:cmp_cell port map(a(4),b(4),out3,out4); cell5:cmp_cell port map(a(5),b(5),out4,out5); cell6:cmp_cell port map(a(6),b(6),out5,out6); cell7:cmp_cell port map(a(7),b(7),out6,cmpout); end cmp_8; (7) Finite State Machine entity sequence is port( clk,resetn,data_in: in std_logic; data_out: out std_logic)); end sequence; architecture state_machine of SEQUENCE is type StateType is (ST0,ST1,ST2,ST3,ST4,ST5,ST6,ST7); signal Current_State:StateType; state_comb: process(clk,resetn, Current_State) variable REG: std_logic_vector(2 downto 0); if clk event and clk= 1 and resetn= 1 then case Current_State is when ST0 => when ST1 => if data_in= 0 then Current_State<=ST2; else Current_State<=ST3; when ST2 => if data_in= 0 then Current_State<=ST4; else Current_State<=ST5; Page 4 of 5

when ST3 => if data_in= 0 then Current_State<=ST6; else Current_State<=ST7; when ST4 => when ST5 => when ST6 => if data_in= 0 then Current_State<=ST4; else Current_State<=ST5; when ST7 => if data_in= 0 then Current_State<=ST6; else Current_State<=ST7; REG:=data_in&REG(2 downto 1); elsif resetn= 0 then Current_State<=ST0; REG(2 downto 0):=( 0, 0, 0 ); data_out<=reg(0); end process state_comb; end architecture state_machine; Page 5 of 5