ECE - 1551 DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015.

Slides:



Advertisements
Similar presentations
CSE 205: Digital Logic Design
Advertisements

Registers and Counters
28/10/2007DSD,USIT,GGSIPU1 Latch & Register Inference.
L18 – VHDL for other counters and controllers. Other counters  More examples Gray Code counter Controlled counters  Up down counter  Ref: text Unit.
Contemporary Logic Design Sequential Case Studies © R.H. Katz Transparency No Chapter #7: Sequential Logic Case Studies 7.1, 7.2 Counters.
Registers and Counters
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.
CS370 Counters. Overview °Counter: A register that goes through a prescribed series of states °Counters are important components in computers. °Counters.
ECE C03 Lecture 91 Lecture 9 Registers, Counters and Shifters Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
ENGIN112 L26: Shift Registers November 3, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 26 Shift Registers.
A.Abhari CPS2131 Registers A register is a group of n flip-flops each of them capable of storing one bit of information There are two types of registers:
Chapter 1_4 Part II Counters
1 Sequential Circuits Registers and Counters. 2 Master Slave Flip Flops.
Registers and Counters
Registers and Counters
EE24C Digital Electronics Projects
Registers & Counters M. Önder Efe
1 Registers and Counters A register consists of a group of flip-flops and gates that affect their transition. An n-bit register consists of n-bit flip-flops.
Rabie A. Ramadan Lecture 3
Chapter 10 State Machine Design. 2 State Machine Definitions State Machine: A synchronous sequential circuit consisting of a sequential logic section.
1 Sequential Logic Lecture #7. 모바일컴퓨팅특강 2 강의순서 Latch FlipFlop Shift Register Counter.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
SEQUENTIAL CIRCUITS Component Design and Use. Register with Parallel Load  Register: Group of Flip-Flops  Ex: D Flip-Flops  Holds a Word of Data 
RTL Hardware Design by P. Chu Chapter Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing asynchronous circuit 4.
2017/4/24 CHAPTER 6 Counters Chapter 5 (Sections )
1 CSE370, Lecture 15 Lecture 15 u Logistics n HW5 due this Friday n HW6 out today, due Friday Feb 20 n I will be away Friday, so no office hour n Bruce.
ENG241 Digital Design Week #8 Registers and Counters.
Registers and Counters Chapter 6. Digital Circuits 2 Clocked sequential circuits a group of flip-flops and combinational gates connected to form a feedback.
Chap 5. Registers and Counters. Chap Definition of Register and Counter l a clocked sequential circuit o consist of a group of flip-flops & combinational.
Registers Page 1. Page 2 What is a Register?  A Register is a collection of flip-flops with some common function or characteristic  Control signals.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
1 Part III: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
CDA 4253 FPGA System Design Sequential Circuit Building Blocks Hao Zheng Dept of Comp Sci & Eng USF.
ENG241 Digital Design Week #7 Sequential Circuits (Part B)
ECE DIGITAL LOGIC LECTURE 21: FINITE STATE MACHINE Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/24/2015.
Chap 5. Registers and Counters
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Logic Design (CE1111 ) Lecture 6 (Chapter 6) Registers &Counters Prepared by Dr. Lamiaa Elshenawy 1.
1 Registers A register is a group of n flip-flops each of them capable of storing one bit of information There are two types of registers: parallel and.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Sequential statements (1) process
Combinational logic circuit
LAB #6 Sequential Logic Design (Flip Flops, Shift Registers)
Week #7 Sequential Circuits (Part B)
Registers and Counters
Figure 7.1 Control of an alarm system
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Assistant Prof. Fareena Saqib Florida Institute of Technology
ECE Digital logic Lecture 16: Synchronous Sequential Logic
Registers and Counters Register : A Group of Flip-Flops. N-Bit Register has N flip-flops. Each flip-flop stores 1-Bit Information. So N-Bit Register Stores.
Sequential-Circuit Building Blocks
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN
VHDL (VHSIC Hardware Description Language)
ECE 545 Lecture 6 Behavioral Modeling of Sequential-Circuit Building Blocks Mixing Design Styles Modeling of Circuits with a Regular Structure.
Computer Architecture and Organization: L02: Logic design Review
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Behavioral Modeling of Sequential-Circuit Building Blocks
Sequntial-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
Digital Logic Department of CNET Chapter-6
Digital Logic Department of CNET Chapter-6
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Sequntial-Circuit Building Blocks
(Sequential-Circuit Building Blocks)
Presentation transcript:

ECE DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015

Recap  Analysis of sequential circuits  State reduction and Assignment  Design Procedure  With DFF  With JK FF  With T FF

Agenda  Design Shift Register and Counters

D Flip Flop 4 Clk d q

D-FF  You should use the following ’templates’ to create latches and FFs, so that the predesigned library cells are inferred by the synthesis tools. 5 library ieee; use ieee.std_logic_1164.all; entity dFF is port( c: in std_logic; d: in std_logic; q: out std_logic ); end dFF; architecture arch of dFF is begin -- observe the sensitivity list. process(clk) begin if (rising_edge(clk)) then q <= d; end if; end process; end arch;

Register  A clocked sequential circuit consists of a group of flip-flops and combinational gates.  All Flip Flops share a common clock  An n bit register consists of n flip flops.  In addition to flip flops, a register might consist of combinational gates that perform certain data processing tasks.  A counter is essentially a register that goes through a predetermined sequence of binary states  The gates in a counter are connected in a way as to produce the prescribed sequence of states.  Various registers are available, the simplest register is one that consists of flip-flops.  Figure shows a Register constructed with a 4 DFFs.

Register  Multiple D FFs with same clock and reset 7 library ieee; use ieee.std_logic_1164.all; entity reg4 is port( clk, reset: in std_logic; d: in std_logic_vector(3 downto 0); q: out std_logic_vector(3 downto 0) ); end reg4; architecture arch of reg4 is begin process(clk, reset) begin if (reset=’1’) then q ’0’); elsif (clk’event and clk=’1’) then q <= d; end if; end process; end arch;

2 segment Style 8 Follow the block diagram: Build the register Code the next-state and output logic (combinational circuits) Output logic (combinational circuit)

D FF with sync enable  Note that the en is controlled by clock  Note the sensitivity list 9

D FF with sync enable (2 segment style) 10 library ieee; use ieee.std_logic_1164.all; entity dff_en is port( clk: in std_logic; reset: in std_logic; en: in std_logic; d: in std_logic; q: out std_logic ); end dff_en; architecture two_seg_arch of dff_en is signal q_reg: std_logic; signal q_next: std_logic; begin -- D FF process(clk, reset) begin if (reset=’1’) then q_reg <= ’0’; elsif (clk’event and clk=’1’) then q_reg <= q_next; end if; end process; -- next-state logic q_next <= d when en =’1’ else q_reg; -- output logic q <= q_reg; end two_seg_arch;

Toggle Flip Flop 11

Toggle Flip Flop 12 library ieee; use ieee.std_logic_1164.all; entity tff is port( clk: in std_logic; reset: in std_logic; t: in std_logic; q: out std_logic ); end tff; architecture two_seg_arch of tff is signal q_reg: std_logic; signal q_next: std_logic; begin -- D FF process(clk, reset) begin if (reset=’1’) then q_reg <= ’0’; elsif (clk’event and clk=’1’) then q_reg <= q_next; end if; end process; -- next-state logic q_next <= q_reg when t=’0’ else not(q_reg); -- output logic q <= q_reg; end two_seg_arch;

Register with Parallel Load  Registers with parallel load are a fundamental building block in digital system.  The transfer of new information into a register is referred as loading or updating the register.  If all the bits of the register are loaded simultaneously with a common clock pulse, we say that the loading is done in parallel.

Parallel Laod Register 14 library ieee; use ieee.std_logic_1164.all; entity shift_right_register is port( clk, reset: in std_logic; load : in std_logic; d: in std_logic_vector(3 downto 0); q: out std_logic_vector(3 downto 0) ); end shift_right_register; architecture two_seg_arch of shift_right_register is signal r_reg: std_logic_vector(3 downto 0); signal r_next: std_logic_vector(3 downto 0); begin -- register process(clk, reset) begin if (reset=’1’) then r_reg ’0’); elsif (clk’event and clk=’1’) then if (load <= ‘1’) then r_reg <= d; else r_reg <= r_next; end if; end process; -- output q <= r_reg; end two_seg_arch;

Free Running Shift Register  A register capable to shifting the binary information held in each cell to its neighboring cell, in a selected direction is called shift register  Can be used to carry out parallel-to-serial conversion. 15

Free Running Shift Register  Conceptually, we can re-arrange the FFs into a column and treat them as a single memory block (see below) 16

Free Running Shift Register 17

Free Running Shift Register 18 library ieee; use ieee.std_logic_1164.all; entity shift_right_register is port( clk, reset: in std_logic; d: in std_logic; q: out std_logic ); end shift_right_register; architecture two_seg_arch of shift_right_register is signal r_reg: std_logic_vector(3 downto 0); signal r_next: std_logic_vector(3 downto 0); begin -- register process(clk, reset) begin if (reset=’1’) then r_reg ’0’); elsif (clk’event and clk=’1’) then r_reg <= r_next; end if; end process; -- next-state logic (shift right 1 bit) r_next <= d & r_reg(3 downto 1); -- output q <= r_reg(0); end two_seg_arch;

Serial Addition

Free Running Shift Register 20 library ieee; use ieee.std_logic_1164.all; entity shift_right_register is port( clk, reset: in std_logic; d: in std_logic; q: out std_logic ); end shift_right_register; architecture two_seg_arch of shift_right_register is signal a_reg, b_reg: std_logic_vector(3 downto 0); signal a_next, b_next:std_logic_vector(3 downto 0); begin -- register process(clk, reset) begin if (reset=’1’) then a_reg ’0’); b_reg ’0’); elsif (clk’event and clk=’1’) then a_reg <= a_next; b_reg <= b_next; end if; end process; -- next-state logic (shift right 1 bit) b_next <= SerialInput & b_reg(3 downto 1); -- output q <= r_reg(0); end two_seg_arch;

Universal Shift Register  Designed to implement 4 ops: parallel load, shift right, shift left, pause 21 library ieee; use ieee.std_logic_1164.all; entity shift_register is port( clk, reset: in std_logic; ctrl: in std_logic_vector(1 downto 0); d: in std_logic_vector(3 downto 0); q: out std_logic_vector(3 downto 0) ); end shift_register;

Universal Shift Register 22 architecture two_seg_arch of shift_register is signal r_reg: std_logic_vector(3 downto 0); signal r_next: std_logic_vector(3 downto 0); begin -- register process(clk, reset) begin if (reset=’1’) then r_reg ’0’); elsif (clk’event and clk=’1’) then r_reg <= r_next; end if; end process; -- next-state logic with ctrl select r_next <= r_reg when "00", -- no op r_reg(2 downto 0) & d(0) when "01", -- sft left d(3) & r_reg(3 downto 1) when "10", -- sft rght d when others; -- parallel -- output q <= r_reg; end two_seg_arch;

Counter  A counter is a register that goes through a prescribed sequence of states upon the application of input pulses.  Binary Ripple Counter  Positive edge triggered  Negative edge triggered  ALREADY Discussed the timing waveform in previous classes

Counter – D Flip Flop  ALREADY Discussed the timing waveform in previous classes.

Arbitrary sequence counter  Architecture ??? 25 library ieee; use ieee.std_logic_1164.all; entity arbi_seq_counter4 is port( clk, reset: in std_logic; q: out std_logic_vector(2 downto 0) ); end arbi_seq_counter4; A sequential counter circulates a predefined sequence of states. The next state logic determines the patterns in the sequence. For example counter needs to circulates through the following sequence

Arbitrary sequence counter 26 architecture two_seg_arch of arbi_seq_counter4 is signal r_reg: std_logic_vector(2 downto 0); signal r_next: std_logic_vector(2 downto 0); begin -- register process(clk, reset) begin if (reset=’1’) then r_reg ’0’); elsif (clk’event and clk=’1’) then r_reg <= r_next; end if; end process; -- next-state logic r_next <= "011" when r_reg="000" else "110" when r_reg="011" else "101" when r_reg="110" else "111" when r_reg="101" else "000"; -- r_reg="111" -- output logic q <= r_reg; end two_seg_arch; -- next-state logic with r_reg select r_next <= "011" when "000" else "110" when "011" else "101" when "110" else "111" when "101" else "000"; -- r_reg="111" -- output logic q <= r_reg; end two_seg_arch; Conditional signal Statement Selected Signal Statement

Free-Running Binary Counter  RTL schematic of free running binary counter  A binary counter circulates through a sequence that resembles the unsigned binary number  In the following example, signal max_pulse is another output, asserted when counter is all ’1’s 27

Free-Running Binary Counter 28 library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity binary_counter4_pulse is port( clk, reset: in std_logic; max_pulse: out std_logic; q: out std_logic_vector(3 downto 0) ); end binary_counter4_pulse; architecture two_seg_arch of binary_counter4_pulse is signal r_reg: unsigned(3 downto 0); signal r_next: unsigned(3 downto 0); begin

Free-Running Binary Counter register process(clk, reset) begin if (reset=’1’) then r_reg ’0’); elsif (clk’event and clk=’1’) then r_reg <= r_next; end if; end process; -- next-state logic r_next <= r_reg + 1; -- output logic q <= std_logic_vector(r_reg); max_pulse <= ’1’ when (r_reg="1111") else ’0’; end two_seg_arch;

Coding Styles  Two-segment code  Separate memory segment from the rest  Can be little cumbersome  Has a clear mapping to hardware component  One-segment code  Mix memory segment and next-state logic / output logic  Can sometimes be more compact  No clear hardware mapping  Error prone 30

Test Bench  Test bench consists of component instantiation statement.  1 segment to generate a stimulus for clock Constant T:= time := 10 ns; -- clk period for 100MHz clock Process begin clk <= ‘0’; wait for T/2; clk <= ‘1’; wait for T/2; end process  1 segment for regular inputs. reset <= ‘1’, ‘0’ after T/2; 31

Test Bench  For a synchronous system with positive edge-triggered FFs, an input signal must be stable around the rising edge of the clock signal to satisfy the setup and hold time constraints.  One easy way to achieve this is to change an input signal’s value during the ’1’-to-’0’ transition of the clk signal.  The falling_edge function of the std_logic_1164 package checks this condition, and we can use it in a wait statement: wait until falling-edge (clk) ;  Note that each statement represents a new falling edge, which corresponds to the advancement of one clock cycle.  For multiple clock cycles, we can use a loop statement: for i in 1 to 10 loop -- count 10 clocks wait until falling-edge (clk) ; end loop; or wait for 10*T; 32

State Table – Sequential Circuit Design  Create a state transition table  This is basically a truth table that records the information of the finite state machine.  Decide how many flip flops you need, and what kind  This is usually simple, because you have to encode each state of the finite state machine using ceil( lg( k ) ) bits. Or even better, someone's already given you an FSM with that information encoded.  Choosing the kind of flip flop you want is usually an academic exercise. You'll often be told to use a certain flip flop, so you need to be able to handle the kind give.  Use the flip flop excitation table, to fill out the rest of the chart.  We'll talk about the excitation table momentarily.  Implement the circuit using Flip Flops and Combinational Logic.