L18 – VHDL for other counters and controllers. Other counters  More examples Gray Code counter Controlled counters  Up down counter  Ref: text Unit.

Slides:



Advertisements
Similar presentations
L15 – Specification of State Machines
Advertisements

1/8/ VerilogCopyright Joanne DeGroat, ECE, OSU1 Verilog Overview An overview of the Verilog HDL.
L23 – Adder Architectures. Adders  Carry Lookahead adder  Carry select adder (staged)  Carry Multiplexed Adder  Ref: text Unit 15 9/2/2012 – ECE 3561.
L9 – State Assignment and gate implementation. States Assignment  Rules for State Assignment  Application of rule  Gate Implementation  Ref: text.
VHDL Lecture 1 Megan Peck EECS 443 Spring 08.
L7 – Derivation of State Graphs and Tables – Moore Machines.
28/10/2007DSD,USIT,GGSIPU1 Latch & Register Inference.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 3 Microcomputer Systems Design (Embedded Systems)
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.
ECE C03 Lecture 141 Lecture 14 VHDL Modeling of Sequential Machines Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
9/15/09 - L22 Sequential Circuit Design Copyright Joanne DeGroat, ECE, OSU1 Sequential Circuit Design Creating a sequential circuit to address a.
9/15/09 - L25 Registers & Load Enable Copyright Joanne DeGroat, ECE, OSU1 Registers & Load Enable.
L23 – Arithmetic Logic Units. Arithmetic Logic Units (ALU)  Modern ALU design  ALU is heart of datapath  Ref: text Unit 15 9/2/2012 – ECE 3561 Lect.
Introduction to VHDL (part 2)
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
L5 – Sequential Circuit Design
L16 – Testbenches for state machines. VHDL Language Elements  More examples HDL coding of class examples Testbench for example  Testing of examples.
Chapter 10 State Machine Design. 2 State Machine Definitions State Machine: A synchronous sequential circuit consisting of a sequential logic section.
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.
1/8/ L20 Project Step 8 - Data Path Copyright Joanne DeGroat, ECE, OSU1 State Machine Design with an HDL A methodology that works for documenting.
L26 – Datapath ALU implementation
1/8/ L23 Project Step 9 - Sequential Machine Copyright Joanne DeGroat, ECE, OSU1 Project Step 9 Beyond the ALU and Datapath. Sequential Machine.
L16 – VHDL for State Machines with binary encoding.
ENG241 Digital Design Week #8 Registers and Counters.
Sequential Design Basics. Lecture 2 topics  A review of devices that hold state A review of Latches A review of Flip-Flops 8/22/2012 – ECE 3561 Lect.
1/8/ L7 Project Step 3Copyright Joanne DeGroat, ECE, OSU1 Project Step 3 Structural Modeling and the Generate Statement.
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,
9/15/09 - L21 Sequential Circuit Analaysis Copyright Joanne DeGroat, ECE, OSU1 Sequential Circuit Analysis.
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.
1/8/ L2 VHDL Introcution© Copyright Joanne DeGroat, ECE, OSU1 Introduction to VHDL.
L19 – Resolved Signals. Resolved Signals  What are resolved signals In systems In VHDL Resolution – Isn’t that for resolving conflicts?  Ref: text Unit.
Assignment write a short notes on 1.Manufacturing Testing. 2.Functional Testing. 3.Files and Text I/O. 4.Differentiate the cpld and fpga architecture.
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)
L20 – Register Set. The 430 Register Set  Not exactly a dual ported register set, but a dual drive register set.  Ref: text Unit 10, 17, 20 9/2/2012.
EE694v-Verification-Lect6-1- Lecture 6 - Writing Tests A difference if treating the design as a black box or if you have access to internal signals EE762.
ENG241 Digital Design Week #7 Sequential Circuits (Part B)
1/8/ L11 Project Step 5Copyright Joanne DeGroat, ECE, OSU1 Project Step 7 Behavioral modeling of a dual ported register set.
ECE DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015.
Project 1.  Two parts Implement a 3 bit Gray Code Counter Implement a 4-to-1 muxtiplexer  Can be done on Altera (Quartis) or Xilinx 8/22/2012 – ECE.
Common Elements in Sequential Design. Lecture 3 topics  Registers and Register Transfer  Shift Registers  Counters Basic Counter Partial sequence counters.
State Machine Design with an HDL
Sequential statements (1) process
Week #7 Sequential Circuits (Part B)
L5 – Sequential Circuit Design
Registers and Counters
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Some VHDL Details 10/8/08 ECE Lecture 8.
ECE 4110–5110 Digital System Design
Using CAD Tools to implement Digital Circuits
VHDL Hierarchy in XILINX
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
L19 – Register Set.
VHDL (VHSIC Hardware Description Language)
L21 – Register Set.
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
L25 – Datapath ALU.
Copyright Joanne DeGroat, ECE, OSU
State Machine Design with an HDL
L22 – Register Set Debugging
Figure 8.1. The general form of a sequential circuit.
Beyond the ALU and Datapath. Sequential Machine Modeling exercise.
An overview of the Verilog HDL.
L25 – Final Review AU 15 Final Exam – Classroom – Journalism 300
Sequntial-Circuit Building Blocks
Beyond the ALU and Datapath. Sequential Machine Modeling exercise.
System Controller Approach
Presentation transcript:

L18 – VHDL for other counters and controllers

Other counters  More examples Gray Code counter Controlled counters  Up down counter  Ref: text Unit 10, 17, 20 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU2

Gray code counter  What is Gray Code – it is a binary encoding that has only one bit transition from 0 to 1 or 1 to 0 in any successive count. 3 bit sequence – 3 bit Gray code count 000 – 001 – 011 – 010 – 110 – 111 – 101 – 100 – 000  How to generate? Actually quite easy and controlled 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU3

Gray Code generation  Start with the one bit  For 2 bit, put 1-bit code as lsb Precede by a 0 on 1 bit code Precede by a 1 on reflected 1 bit code Results in 2-bit count sequence  For n bit Gray Code Precede by a 0 on n-1 Gray bit code Precede by a 1 on reflected n-1 Gray bit code Results in n-bit count sequence 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU4

The HDL code for a 3 bit counter  The counter is a SED counter What is SED – Single Error Detecting SED will detect any single error that occurs in the architecture of the counter. This was for a specific purpose. Can easily be modified to be non SED. Only gives an indication (output signal) that error occurred.  The ENTITY ENTITY cnt3 IS PORT (clk : IN bit; cnt : OUT bit_vector(2 downto 0); dcnt : OUT bit_vector(2 downto 0); err : OUT bit); END cnt3; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU5

The declarative region ARCHITECTURE one OF cnt3 IS SIGNAL state,next_state : bit_vector(2 downto 0) := "000"; SIGNAL dstate,dnext_state : bit_vector(2 downto 0) := "111"; BEGIN  A binary encoded state machines  Two state machines are being specified  Each has state encoding of 3 bits 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU6

The F/F process  Note that both state machine Flip Flops are specified within the same process. This is acceptable. -- Latching logic specification PROCESS BEGIN WAIT UNTIL clk='1' AND clk'event; state <= next_state; dstate <= dnext_state; END PROCESS; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU7

Next state processes(2 of them)  --Next state logic for true logic  PROCESS (state)  BEGIN  CASE state IS  WHEN ("000") =>  next_state <= "001";  WHEN ("001") =>  next_state <= "011";  WHEN ("011") =>  next_state <= "010";  WHEN ("010") =>  next_state <= "110";  WHEN ("110") =>  next_state <= "111";  WHEN ("111") =>  next_state <= "101";  WHEN ("101") =>  next_state <= "100";  WHEN ("100") =>  next_state <= "000";  END CASE;  END PROCESS;  --Next state logic for dual logic  PROCESS (dstate)  BEGIN  CASE dstate IS  WHEN ("111") =>  dnext_state <= "110";  WHEN ("110") =>  dnext_state <= "100";  WHEN ("100") =>  dnext_state <= "101";  WHEN ("101") =>  dnext_state <= "001";  WHEN ("001") =>  dnext_state <= "000";  WHEN ("000") =>  dnext_state <= "010";  WHEN ("010") =>  dnext_state <= "011";  WHEN ("011") =>  dnext_state <= "111";  END CASE;  END PROCESS; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU8

The output process  Again quite simple --Assign outputs cnt <= state; dcnt <= dstate; err <= (state(0) XNOR dstate(0)) OR (state(1) XNOR dstate(1)) OR (state(2) XNOR dstate(2)); END one;  Note: As binary encoded output, output process can be a simple concurrent signal assignment. Also, generate the error signal output which is a direct Boolean function of the state encoding bits. 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU9

Description of Quartis results  What would be expected? CLASS INPUT  Run through Quartis successfully 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU10

Quartis schematic result  The schematic  6 F/F (2 3-bit counters)  6 combinational elements with register  2 combinational elements with no register ?? Error signal generation 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU11

Up/Down Counter  An Up/Down counter is a controlled counter  Specification: Design a 3-bit counter that has an input c which indicates that the counter should be counting, an input r that resets the counter to 0 when asserted, and an input ud which says to count up when ud=1 and count down when ud=0. 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU12

The HDL interface  THE ENTITY ENTITY cnt3ud IS PORT(clk,c,r,ud : IN BIT; cnt : OUT bit_vector(2 downto 0)); END cnt3ud;  This time there are several control signals in ENTITY 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU13

The declarative region  Start the ARCHITECTURE and state element process ARCHITECTURE one OF cnt3ud IS -- will use a binary encoded state SIGNAL state,next_state : bit_vector(2 downto 0) := "000"; BEGIN --state elements PROCESS BEGIN WAIT UNTIL clk='1' AND clk'event; state <= next_state; END PROCESS; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU14

Next state  This is where the input control affects the behavior of the machine. --next state process PROCESS (state,c,r,ud) BEGIN CASE state IS WHEN "000"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "000"; ELSIF (ud='1') THEN next_state <= "001"; ELSE next_state <= "111"; END IF; WHEN "001"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "001"; ELSIF (ud='1') THEN next_state <= "010"; ELSE next_state <= "000"; END IF; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU15

Next state continued WHEN "010"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "010"; ELSIF (ud='1') THEN next_state <= "011"; ELSE next_state <= "001"; END IF; WHEN "011"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "011"; ELSIF (ud='1') THEN next_state <= "100"; ELSE next_state <= "010"; END IF; WHEN "100"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "100"; ELSIF (ud='1') THEN next_state <= "101"; ELSE next_state <= "011"; END IF; WHEN "101"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "101"; ELSIF (ud='1') THEN next_state <= "110"; ELSE next_state <= "100"; END IF; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU16

The end of the next state process WHEN "110"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "110"; ELSIF (ud='1') THEN next_state <= "111"; ELSE next_state <= "101"; END IF; WHEN "111"=> IF (r='1') THEN next_state <= "000"; ELSIF (c='0') THEN next_state <= "111"; ELSIF (ud='1') THEN next_state <= "000"; ELSE next_state <= "110"; END IF; END CASE; END PROCESS; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU17

The output process  Again quite simple --output process cnt <= state; END one;  Before going off to synthesis the description needs to be simulated. 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU18

The testbench  The start ENTITY testcnt3ud IS END testcnt3ud; ARCHITECTURE one OF testcnt3ud IS COMPONENT cnt3ud IS PORT(clk,c,r,ud : IN BIT; cnt : OUT bit_vector(2 downto 0)); END COMPONENT; FOR all : cnt3ud USE ENTITY work.cnt3ud(one); --declare hookup signals SIGNAL clk,c,r,ud : bit; SIGNAL cnt : bit_vector (2 downto 0); BEGIN 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU19

The common setup of clk  And wire in the component --set up clock - 50% duty cycle - 10 ns period clk <= NOT clk AFTER 5 ns; --instantiate component u1 : cnt3ud PORT MAP (clk,c,r,ud,cnt); 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU20

Now generate the controls --generate control signal stimulus PROCESS BEGIN --time 0 -- set up controls c <= '1'; -- count r <= '0'; -- don't reset ud <= '1'; -- count up WAIT for 100 ns; -- allow the system to count --reset the counter r <= '1'; WAIT for 10 ns; r <= '0'; -- start counting again WAIT for 50 ns; --start counting down ud <= '0'; WAIT for 100 ns; --flip back to counting up ud <= '1'; WAIT for 50 ns; --now hold count c <= '0'; WAIT for 50 ns; --now resume c <= '1'; WAIT for 50 ns; --should be done! WAIT; END PROCESS; 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU21

The waveform  The first 120 ns – count then reset 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU22

The waveform  From 120 to 270 ns – counting down 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU23

The waveform  After 270 ns – suspend count 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU24

Enter into Quartis  And synthesize – this is a somewhat more complex design  3 registers  7 I/O pins  5 LUTs 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU25

Time for live demo  Demo of code in Modelsim  Demo of setup in Quartis  Probably want to take note of steps and editing shortcuts. 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU26

Lecture summary  HDL for more complex counter HDL code Testbench  HDL for controlled counter Testbench needing control signal wave forms Simulation results Quartis results  Coming – TYPE std_logic 9/2/2012 – ECE 3561 Lect 9 Copyright Joanne DeGroat, ECE, OSU27