Registers and Counters

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

Counters Discussion D8.3.
CDA 3100 Recitation Week 11.
Synchronous Sequential Logic
Review for Exam 2 Using MUXs to implement logic
Table 7.1 Verilog Operators.
Control path Recall that the control path is the physical entity in a processor which: fetches instructions, fetches operands, decodes instructions, schedules.
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.
CS 300 – Lecture 3 Intro to Computer Architecture / Assembly Language Sequential Circuits.
Sequential Circuit Introduction to Counter
Registers & Counters M. Önder Efe
Rabie A. Ramadan Lecture 3
IT253: Computer Organization Lecture 10: Making a Processor: Control Signals Tonga Institute of Higher Education.
Introduction Verilog is a HARDWARE DESCRIPTION LANGUAGE (HDL) A hardware description language is a language or means used to describe or model a digital.
© BYU 13 COUNTERS Page 1 ECEn 224 COUNTERS Counters Transition Tables Moore Outputs Counter Timing.
SEQUENTIAL LOGIC By Tom Fitch. Types of Circuits Combinational: Gates Combinational: Gates Sequential: Flip-Flops Sequential: Flip-Flops.
IT253: Computer Organization Lecture 9: Making a Processor: Single-Cycle Processor Design Tonga Institute of Higher Education.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
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.
Introduction to FPGAs Getting Started with Xilinx.
Appendix C Basics of Logic Design. Appendix C — Logic Basic — 2 Logic Design Basics §4.2 Logic Design Conventions Objective: To understand how to build.
Exam-like questions.
Overview Logistics Last lecture Today HW5 due today
Supplement on Verilog FF circuit examples
CS161 – Design and Architecture of Computer Systems
Memories.
Homework Reading Machine Projects Labs Tokheim Chapter 9.1 – 9.6
Flip Flops Lecture 10 CAP
Clocks A clock is a free-running signal with a cycle time.
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
EKT 221 : Digital 2 COUNTERS.
Sequential Logic Counters and Registers
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
Quad D Flip Flop Index Circuit Error Judgment Scenario
Morgan Kaufmann Publishers
MIPS Processor.
Processor (I).
Latches and Flip-flops
Registers and Counters
MIPS processor continued
Lesson Objectives Aims
CS Fall 2005 – Lec. #5 – Sequential Logic - 1
Single-Cycle CPU DataPath.
How does the CPU work? CPU’s program counter (PC) register has address i of the first instruction Control circuits “fetch” the contents of the location.
CSE 140L Discussion Finite State Machines.
4-Bit Counter Spencer Canavan.
SYNTHESIS OF SEQUENTIAL LOGIC
Computer Architecture and Design Lecture 6
MIPS Processor.
Verilog.
Levels in Processor Design
332:437 Lecture 8 Verilog and Finite State Machines
The Processor Lecture 3.1: Introduction & Logic Design Conventions
Lecture 9. MIPS Processor Design – Decoding and Execution
6. Registers and Counters
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
Levels in Processor Design
Overview Part 1 - Registers, Microoperations and Implementations
Levels in Processor Design
Sequential Logic.
Counters.
MIPS processor continued
Registers and Counters
Levels in Processor Design
Outline Registers Counters 5/11/2019.
Registers and Counters
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
332:437 Lecture 8 Verilog and Finite State Machines
Registers and Counters
MIPS Processor.
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; always @(posedge 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 always @(posedge clk) begin #1 Q = D; Qbar = ~Q; endmodule

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

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. Q2 Q1 Q0 D2 D1 D0 1

D Q2 Q1 Q0 D2 D1 D0 1

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 00 01 11 10 1 1

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

D2 Based on the truth table. Q2Q1 Q0 00 01 11 10 1 1

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 How to implement a “counter”, which will count as 0,2,3,1,4,5,7,6,0,2,3,…… Q2 Q1 Q0 D2 D1 D0 1

The next state table How to implement a counter, which will count as 0,2,3,1,4,5,7,6,0,2,3,…… Q2 Q1 Q0 D2 D1 D0 1

D0 D0 = Q2Q1 Q0 00 01 11 10 1 1

D1 D1 = Q2Q1 Q0 00 01 11 10 1 1

D2 D2 = Q2Q1 Q0 00 01 11 10 1 1