Registers & Counters M. Önder Efe

Slides:



Advertisements
Similar presentations
CSE 205: Digital Logic Design
Advertisements

Synchronous Sequential Logic
Registers and Counters
CENG 241 Digital Design 1 Lecture 11
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
Registers and Counters
11/16/2004EE 42 fall 2004 lecture 331 Lecture #33: Some example circuits Last lecture: –Edge triggers –Registers This lecture: –Example circuits –shift.
Logic and Computer Design Fundamentals Registers and Counters
11/15/2004EE 42 fall 2004 lecture 321 Lecture #32 Registers, counters etc. Last lecture: –Digital circuits with feedback –Clocks –Flip-Flops This Lecture:
CS370 Counters. Overview °Counter: A register that goes through a prescribed series of states °Counters are important components in computers. °Counters.
COE 202: Digital Logic Design Sequential Circuits Part 4 KFUPM Courtesy of Dr. Ahmad Almulhem.
ENGIN112 L26: Shift Registers November 3, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 26 Shift Registers.
Sequential Circuit Introduction to Counter
C HAPTER S IX R EGISTERS AND C OUNTERS 1. A clocked sequential circuit consists of a group of flip-flops and combinational gates connected to form a feedback.
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:
Mantıksal Tasarım – BBM231 M. Önder Efe
1 Digital Design: Sequential Logic Blocks Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals.
Registers and Counters
Counters  A counter is a device which stores (and sometimes displays) the number of times a particular event or process has occurred, often in relationship.
Counters.
A State Element “Zoo”.
Registers and Counters
Chapter 1_4 Part II Counters
1 Sequential Circuits Registers and Counters. 2 Master Slave Flip Flops.
EE345: Introduction to Microcontrollers Register and Counters Prof. Ahmad Abu-El-Haija.
Registers and Counters
Shift Register Section Register A register is a group of flip-flops, each one of which is capable of storing one bit of information. Issues of.
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.
Registers and Counters
Rabie A. Ramadan Lecture 3
Chapter 6 Registers and Counter
SEQUENTIAL CIRCUITS Component Design and Use. Register with Parallel Load  Register: Group of Flip-Flops  Ex: D Flip-Flops  Holds a Word of Data 
2017/4/24 CHAPTER 6 Counters Chapter 5 (Sections )
Princess Sumaya Univ. Computer Engineering Dept. Chapter 6:
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 17 Dr. Shi Dept. of Electrical and Computer Engineering.
Digital Design Lectures 11 & 12 Shift Registers and Counters.
7-6 단일 레지스터에서 Microoperation Multiplexer-Based Transfer  Register 가 서로 다른 시간에 둘 이상의 source 에서 data 를 받을 경우 If (K1=1) then (R0 ←R1) else if (K2=1) then.
1 Registers & Counters Logic and Digital System Design - CS 303 Erkay Savaş Sabancı University.
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.
REGISTER A register is a group of flip-flops. Each flip- flop is capable of storing one bit of informa­ tion. An n-bit register consists of a group of.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
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.
Abdullah Said Alkalbani University of Buraimi
4-Bit Universal Shift Register Behavioral Vs. Structural Description Behavioral Description – Behavior model of a shift register Describe the operation.
CHAPTER 6 Sequential Circuits’ Analysis CHAPTER 6 Sequential Circuits’ Analysis Sichuan University Software College.
C HAPTER S IX R EGISTERS AND C OUNTERS 1. A clocked sequential circuit consists of a group of flip-flops and combinational gates connected to form a feedback.
Digital Electronics.
ECE/CS 352 Digital System Fundamentals© T. Kaminski & C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Fall 2000 Chapter 5 – Part 2 Tom Kaminski & Charles.
SYEN 3330 Digital SystemsJung H. Kim 1 SYEN 3330 Digital Systems Chapter 7 – Part 2.
Chap 5. Registers and Counters
DIGITAL COMPONENTS. MULTIPLEXERS A multiplexer is a combinational circuit that receives binary information from one of 2 n input data lines and directs.
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.
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.
Dr. Clincy Professor of CS
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.
CS Fall 2005 – Lec. #5 – Sequential Logic - 1
COE 202: Digital Logic Design Sequential Circuits Part 4
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN
Computer Architecture and Organization: L02: Logic design Review
CSE 370 – Winter Sequential Logic-2 - 1
6. Registers and Counters
Switching Theory and Logic Design Chapter 5:
Digital Logic Department of CNET Chapter-6
Digital Logic Department of CNET Chapter-6
Outline Registers Counters 5/11/2019.
Digital Electronics and Logic Design
Presentation transcript:

Registers & Counters M. Önder Efe

Registers Registers are clocked sequential circuits A register is a group of flip-flops – Each flip-flop capable of storing one bit of information – An n-bit register consists of n flip-flops capable of storing n bits of information – besides flip-flops, a register usually contains combinational logic to perform some simple tasks – In summary flip-flops to hold information combinational logic to control the state transition

Counters A counter is essentially a register that goes through a predetermined sequence of states “Counting sequence” RegisterFF 0 FF 1 FF n-1 Combinational logic

Uses of Registers and Counters Registers are useful for storing and manipulating information – internal registers in microprocessors to manipulate data Counters are extensively used in control logic – PC (program counter) in microprocessors

4-bit Register (Parallel) REG Q3Q3 Q2Q2 Q1Q1 Q0Q0 D3D3 D2D2 D1D1 D0D0 clear D Q clock C R D Q C R D Q C R D Q C R clear D0D0 D1D1 D2D2 D3D3 Q0Q0 Q1Q1 Q2Q2 Q3Q3

4-bit Register (Parallel) module parallel_reg(Q3,Q2,Q1,Q0,D3,D2,D1,D0,clock,clear); output Q3,Q2,Q1,Q0; input D3,D2,D1,D0,clock,clear; reg Q3,Q2,Q1,Q0; clock or negedge clear) if(~clear) {Q3,Q2,Q1,Q0}<=4'b0000; else begin Q3 <= D3; Q2 <= D2; Q1 <= D1; Q0 <= D0; end endmodule

Register with Parallel Load Load D Q C R Q0Q0 D Q C R Q1Q1 D Q C R Q2Q2 D Q C R Q3Q3 clock clear D1D1 D2D2 D3D3 D0D0

4-bit Parallel Register with Load module parallel_reg(Q3,Q2,Q1,Q0,D3,D2,D1,D0,clock,clear,Load); output Q3,Q2,Q1,Q0; input D3,D2,D1,D0,clock,clear,Load; reg Q3,Q2,Q1,Q0; clock or negedge clear) if(~clear) {Q3,Q2,Q1,Q0}<=4'b0000; else if(Load) begin Q3 <= D3; Q2 <= D2; Q1 <= D1; Q0 <= D0; end endmodule

Shift Registers A register capable of shifting its content in one or both directions – Flip-flops in cascade serial input serial output D Q C SI D Q C D Q C D Q C SO clock The current of n-bit shift register state can be transferred in n clock cycles

Shift Left Register module shift_reg(serial_output,serial_input,clock); output serial_output; input serial_input,clock; reg out3,out2,out1,out0; assign serial_output=out3; clock) begin out3 <= out2; out2 <= out1; out1 <= out0; out0 <= serial_input; end endmodule

Universal Shift Register Capabilities: 1.A “clear” control to set the register to 0. 2.A “clock” input 3.A “shift-right” control 4.A “shift-left” control 5.n input lines & a “parallel-load” control 6.n parallel output lines

Universal Shift Register Mode Control Register operation s1s1 s0s0 00No change 01Shift right 10Shift left 11Parallel load

4-Bit Universal Shift Register D Q C D Q C D Q C D Q C A0A0 A1A1 A2A2 A3A3 parallel outputs clear clk 4  1 MUX  1 MUX  1 MUX  1 MUX s1s1 s0s0 serial input for shift-right serial input for shift-left parallel inputs

Verilog Code – v1 // Behavioral description of a 4-bit universal shift register module Shift_Register_4_beh ( // V2001, 2005 output reg [3: 0] O_par, // Register output input [3: 0] I_par, // Parallel input input s1, s0, // Select inputs MSB_in, LSB_in, // Serial inputs CLK, // Clock Clear); // Clear ( posedge CLK, negedge Clear) // V2001, 2005 if (Clear== 0) O_par <= 4'b0000; else case ({s1, s0}) 2'b00: O_par <= O_par; // No change 2'b01: O_par <= {MSB_in, O_par[3: 1]}; // Shift right 2'b10: O_par <= {O_par[2: 0], LSB_in}; // Shift left 2'b11: O_par <= I_par; // Parallel load of input endcase endmodule

Verilog Code – v2 // Behavioral description of a 4-bit universal shift register module Shift_Register_4_beh ( // V2001, 2005 output reg [3: 0] O_par, // Register output input [3: 0] I_par, // Parallel input input s1, s0, // Select inputs MSB_in, LSB_in, // Serial inputs CLK, // Clock Clear); // Clear ( posedge CLK, negedge Clear) // V2001, 2005 if (Clear== 0) O_par <= 4'b0000; else case ({s1, s0}) // 2'b00: O_par <= O_par; // No change 2'b01: O_par <= {MSB_in, O_par[3: 1]}; // Shift right 2'b10: O_par <= {O_par[2: 0], LSB_in}; // Shift left 2'b11: O_par <= I_par; // Parallel load of input endcase endmodule

DQDQDQDQ IN OUT1OUT2OUT3OUT4 CLK OUT Pattern Recognizer Combinational function of input samples – In this case, recognizing the pattern 1001 on the single input signal

Counters Registers that go through a prescribed sequence of states upon the application of input pulses – input pulses are usually clock pulses Example: n-bit binary counter – count in binary from 0 to 2 n -1 Classification 1.Synchronous counters flip-flops receive the same common clock as the pulse 2.Ripple counters (Asynchronous) flip-flop output transition serves as the pulse to trigger other flip-flops

Binary Ripple Counter bit binary ripple counter Idea: – to connect the output of one flip-flop to the C input of the next high-order flip- flop We need “complementing” flip-flops – We can use T flip-flops to obtain complementing flip-flops or – JK flip-flops with its inputs are tied together or – D flip-flops with complement output connected to the D input.

4-bit Binary Ripple Counter T Q C R A0A0 T Q C R A1A1 T Q C R A2A2 T Q C R A3A3 clear count logic-1 D Q C R A0A0 D Q C R A1A1 D Q C R A2A2 D Q C R A3A3 clear count Discouraged Know it exists Don’t use it

4-bit Binary Ripple Counter T Q C R A0A0 T Q C R A1A1 T Q C R A2A2 T Q C R A3A3 clear count logic-1

4-bit Binary Synchronous Counter Logic between registers (not just multiplexer) – XOR decides when bit should be toggled – Always for low-order bit, only when first bit is true for second bit, and so on

Binary Counter Verilog module binary_counter(out4, out3, out2, out1, clk); output out4, out3, out2, out1; input clk; reg out4, out3, out2, out1; clk) begin out4 <= (out1 & out2 & out3) ^ out4; out3 <= (out1 & out2) ^ out3; out2 <= out1 ^ out2; out1 <= out1 ^ 1b'1;//out1 <= ~out1; end endmodule

Binary Counter Verilog module binary_counter(out, clk); output [3:0] out; input clk; reg [3:0] out; clk) out <= out + 1; endmodule

Synchronous Counters There is a common clock – that triggers all flip-flops simultaneously – If T = 0 or J = K = 0 the flip-flop does not change state. – If T = 1 or J = K = 1 the flip-flop does change state. Design procedure is so simple – no need for going through sequential logic design process – A 0 is always complemented – A 1 is complemented when A 0 = 1 – A 2 is complemented when A 0 = 1 and A 1 = 1 – so on

4-bit Binary Synchronous Counter J Q C A0A0 J Q C A1A1 J Q C A2A2 J Q C A3A3 K K K K clock Count_enable to next stage

Other Counters Ring Counter – A ring counter is a circular shift register with only one flip-flop being set at any particular time, all others are cleared. shift right Q3Q3 Q2Q2 Q1Q1 QoQo initial value 1000 Usage –Timing signals control the sequence of operations in a digital system In this case, 1000, 0100, 0010, 0001 If one of the patterns is its initial state (by loading or set/reset)

Ring Counter Sequence of timing signals clock Q3Q3 Q2Q2 Q1Q1 Q0Q0

Ring Counter To generate 2 n timing signals, – we need a shift register with ? flip-flops or, we can construct the ring counter with a binary counter and a decoder 2x4 decoder Q3Q3 Q2Q2 Q1Q1 Q0Q0 2-bit counter count Cost: 2 flip-flops 2-to-4 line decoder Cost in general case: n flip-flops n-to-2 n line decoder 2 n n-input AND gates n NOT gates

Ring Counter Verilog module ring_counter(Q,Clock,Resetn); input Clock,Resetn; output [3:0] Q; reg [3:0] Q; Clock or negedge Resetn) if(!Resetn) Q <= 4'b1000; else Q <= {Q[0],Q[3:1]}; //Q[3]<=Q[0]; //Q[2]<=Q[3]; //Q[1]<=Q[2]; //Q[0]<=Q[1]; endmodule

Johnson Counter A k-bit ring counter can generate k distinguishable states The number of states can be doubled if the shift register is connected as a switch-tail ring counter clock D Q C D Q C D Q C D Q C X X’ Y Y’ Z Z’ T T’ In this case, 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001

Johnson Counter Verilog module johnson_counter(X,Y,Z,T,clock,Resetn); input clock,Resetn; output X,Y,Z,T; reg X,Y,Z,T; clock or negedge Resetn) if(!Resetn) {X,Y,Z,T} <= 4'b0000; else X <= ~T; Y <= X; Z <= Y; T <= Z; endmodule

Rising Edge Detector ("0" to "1" transition) Verilog Kodu?

Falling Edge Detector ("1" to "0" transition) Verilog Kodu?

Edge Detector (Rising or Falling Edge Detector) ("1" to "0" or "0" to "1" transition) ?