Registers and Counters. Register Register is built with gates, but has memory. The only type of flip-flop required in this class – the D flip-flop – Has.

Slides:



Advertisements
Similar presentations
Tutorial 2 Sequential Logic. Registers A register is basically a D Flip-Flop A D Flip Flop has 3 basic ports. D, Q, and Clock.
Advertisements

//HDL Example 8-2 // //RTL description of design example (Fig.8-9) module Example_RTL (S,CLK,Clr,E,F,A);
Counters Discussion D8.3.
Synchronous Counters with SSI Gates
Lecture #24 Page 1 EE 367 – Logic Design Lecture #24 Agenda 1.State Machines Review Announcements 1.n/a.
CDA 3100 Recitation Week 11.
Lecture 23: Registers and Counters (2)
Synchronous Sequential Logic
State Machine Design Procedure
Changes in input values are reflected immediately (subject to the speed of light and electrical delays) on the outputs Each gate has an associated “electrical.
Digital Logic Design Brief introduction to Sequential Circuits and Latches.
CS 300 – Lecture 3 Intro to Computer Architecture / Assembly Language Sequential Circuits.
ENGIN112 L26: Shift Registers November 3, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 26 Shift Registers.
CS 140L Lecture 4 Professor CK Cheng 10/22/02. 1)F-F 2)Shift register 3)Counter (Asynchronous) 4)Counter (Synchronous)
Flip Flops. Clock Signal Sequential logic circuits have memory Output is a function of input and present state Sequential circuits are synchronized by.
Registers and Counters
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 17 Dr. Shi Dept. of Electrical and Computer Engineering.
Flip Flops 3.1 Latches and Flip-Flops 3 ©Paul Godin Created September 2007 Last Edit Aug 2013.
Asynch 1.1 Asynchronous Counters 1 ©Paul Godin Last Edit Sept 2009.
ECA1212 Introduction to Electrical & Electronics Engineering Chapter 9: Digital Electronics – Sequential Logic by Muhazam Mustapha, November 2011.
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Latches & Flip-Flops.
Abdullah Said Alkalbani University of Buraimi
SEQUENTIAL LOGIC By Tom Fitch. Types of Circuits Combinational: Gates Combinational: Gates Sequential: Flip-Flops Sequential: Flip-Flops.
Counters Prepared by: Careene McCallum-Rodney. Introduction Counters uses a Toggle Flip Flops to count either UP or DOWN in binary. A toggle flip flop.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Dr. Shi Dept. of Electrical and Computer Engineering.
Counters and registers Eng.Maha Alqubali. Registers Registers are groups of flip-flops, where each flip- flop is capable of storing one bit of information.
7. Latches and Flip-Flops Digital Computer Logic.
Shift Register Counters
Computer Science 210 Computer Organization
Computer Architecture & Operations I
Class Exercise 1B.
Summary Latch & Flip-Flop
SR Flip-Flop Negative Edge Triggered Flip-Flops The SR Flip-Flop
Computer Architecture & Operations I
Asynchronous Counters with SSI Gates
Who Wants to be an Electronics Millionaire?
Sequential Logic Counters and Registers
Flip Flops.
FIGURE 5.1 Block diagram of sequential circuit
INTRODUCTION Overview of Shift Registers
12-bit counter and 2GHz oscillator
Latches, Flip-Flops and Registers
Flip Flop.
Computer Science 210 Computer Organization
D Flip-Flop.
Introduction to Sequential Logic Design
Latches and Flip-flops
Registers and Counters
EEC 180B Lecture 14 Bevan M. Baas Tuesday, May 22, 2018
Computer Science 210 Computer Organization
Asynchronous Counters with SSI Gates
Excitation Vectors Input Combinational Logic Memory Output States.
COE 202: Digital Logic Design Sequential Circuits Part 4
4-Bit Counter Spencer Canavan.
Verilog.
Registers and Counters
FIGURE 10.1 Rectangular‐shape graphic symbols for gates
Excitation Vectors Input Combinational Logic Memory Output States.
FIGURE 1: SERIAL ADDER BLOCK DIAGRAM
Digital Systems II EEC 180 Bevan M. Baas.
1) Latched, initial state Q =1
FLIP-FLOPS.
Switching Theory and Logic Design Chapter 5:
Flip Flops Unit-4.
14 Digital Systems.
Registers and Counters
Outline Registers Counters 5/11/2019.
Registers and Counters
Registers and Counters
FLIP-FLOP. The basic memory circuit is known as Flip-flop. OR It is a bistable sequential circuit which has two stable state (set & reset) and can be.
Presentation transcript:

Registers and Counters

Register Register is built with gates, but has memory. The only type of flip-flop required in this class – the D flip-flop – Has at least two inputs (both 1-bit): D and clk – Has at least one output (1-bit): Q – At the rising edge of clk (when clk is changing from 0 to 1), Q <= D. – Q does not change value at ANY OTHER TIME except at the rising edge of clk

D flip-flop module Dff (D, clk, Q); input D, clk; output reg Q; clk) begin Q = D; end endmodule

D flip-flop can hold value Note that the output of the D flip-flop (Q) does not follow the change of the input (D). It holds the value until the next time it is allowed to change – the rising edge of the clock. This is why you can write to a register and expect that the next time you want to use it the value is still there. Your MIPS code won’t work if the values in the registers can change at random time. Now you know another piece of MIPS processor – MIPS has 32 registers, each register is 32 bits, so basically you have 1024 D-flip-flops.

Delay Real circuits have delays caused by charging and discharging. So, once the input to a gate changes, the output will change after a delay, usually in the order of nano seconds. An and gate: A B output

Delay A more realistic D flip-flop: module Dff1 (D, clk, Q, Qbar); input D, clk; output reg Q, Qbar; initial begin Q = 0; Qbar = 1; end clk) begin #1 Q = D; #1 Qbar = ~Q; end endmodule

What happens if… What happens if I connect a Dff like this? wire Q2, Qbar2; Dff1 D2 (Qbar2, clk, Q2, Qbar2);

What happens if … We connect three D-flip-flops in a chain?

Implementing a 3-bit counter A 3-bit counter changes value at every rising edge of the clock, and counts from 0 to 7 and then back to 0. We are going to implement it with D flip-flops and some combinatorial logic.

Any suggestions? How many D flip-flips do we need? How to control the D flip-flops to realize this function?

The last bit The output bit can be dealt with one by one Let’s work with something simple first. How to implement the last bit?

How about the other two bits? The only thing we can control of the D flip-flop is the D signal, because the clk should always be connected to the ``true clk.’’ – In hardware, special cares are given to the clk signal to make sure that they don’t have glitches and other stuff

States The counter has 8 ``states,’’ from 0 to 7. It moves from the current state to the next state at the clk. State is represented by the current value of Q. What the next state is is totally determined by the current state.

D To go from the current state to the next state, we tell the D flip-flop what the next Q should be by setting D to appropriate values, that is, D=next Q. Q2Q1Q0D2D1D

D Q2Q1Q0D2D1D

D Q2Q1Q0D2D1D

D The key part is: D is determined by the current state. That is, D2, D1, D0 are all functions of Q2, Q1, and Q0. We know that – D0 = ~Q0. How to get the functions for D2 and D1?

D1 Based on the truth table Q2Q1 Q0

D1 So, D1 = (~Q1&Q0)|(Q1&~Q0) = Q1^Q0.

D2 Based on the truth table Q2Q1 Q0

D2 So, D2 = (Q2&~Q1)|(Q2&~Q0)|(~Q2&Q1&Q0)

Load Sometimes, we wish to load a certain value to the counter. The counter will have a ``load’’ input and a ``L’’ input. When load is 1, at the next clock, Q=L. How to make this happen? Use a 2-1 selector in front of each D input. Use load as the select signal. One of the input is the D signal from the counter, the other is L.

Program Counter (PC) So we have basically implemented the program counter for mips. Remember that the PC will – Increment by 4 if there no jump or branch – Or be loaded with the address of the instruction to be jumped to if there is a jump or a branch

The next state table Q2Q1Q0D2D1D How to implement a “counter”, which will count as 0,2,3,1,4,5,7,6,0,2,3,……

The next state table How to implement a counter, which will count as 0,2,3,1,4,5,7,6,0,2,3,…… Q2Q1Q0D2D1D

D0 = Q2Q1 Q0

D1 D1 = Q2Q1 Q0

D2 D2 = Q2Q1 Q0