Chapter 4: One-Shots, Counters, and Clocks

Similar documents
Timing Pulses. Important element of laboratory electronics. Pulses can control logical sequences with precise timing.

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

Chapter 5 Flip-Flops and Related Devices

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING DIGITAL DESIGN

Digital Fundamentals: A Systems Approach

Digital Circuits I and II Nov. 17, 1999

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

Lecture 8: Sequential Logic

Flip-Flops and Related Devices. Wen-Hung Liao, Ph.D. 4/11/2001

FLIP-FLOPS AND RELATED DEVICES

MUHAMMAD NAEEM LATIF MCS 3 RD SEMESTER KHANEWAL

CHAPTER 4: Logic Circuits

Logic Gates, Timers, Flip-Flops & Counters. Subhasish Chandra Assistant Professor Department of Physics Institute of Forensic Science, Nagpur

CSCB58 - Lab 4. Prelab /3 Part I (in-lab) /1 Part II (in-lab) /1 Part III (in-lab) /2 TOTAL /8

Asynchronous (Ripple) Counters

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Sequential Logic and Clocked Circuits

SEQUENTIAL LOGIC. Satish Chandra Assistant Professor Department of Physics P P N College, Kanpur

LATCHES & FLIP-FLOP. Chapter 7

ASYNCHRONOUS COUNTER CIRCUITS

RS flip-flop using NOR gate

Digital Systems Laboratory 3 Counters & Registers Time 4 hours

Counter dan Register

RS flip-flop using NOR gate

Combinational vs Sequential

EKT 121/4 ELEKTRONIK DIGIT 1

Logic Design. Flip Flops, Registers and Counters

CHAPTER 4: Logic Circuits

Laboratory 1 - Introduction to Digital Electronics and Lab Equipment (Logic Analyzers, Digital Oscilloscope, and FPGA-based Labkit)

PESIT Bangalore South Campus

Unit-5 Sequential Circuits - 1

IT T35 Digital system desigm y - ii /s - iii

Counters

Chapter 4. Logic Design

Digital Circuits 4: Sequential Circuits

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

Sequential Digital Design. Laboratory Manual. Experiment #7. Counters

PRE J. Figure 25.1a J-K flip-flop with Asynchronous Preset and Clear inputs

Digital Fundamentals: A Systems Approach

Sequential logic. Circuits with feedback. How to control feedback? Sequential circuits. Timing methodologies. Basic registers

COMP sequential logic 1 Jan. 25, 2016

PGT104 Digital Electronics. PGT104 Digital Electronics

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) COUNTERS

Figure 30.1a Timing diagram of the divide by 60 minutes/seconds counter

Notes on Digital Circuits

Experiment 8 Introduction to Latches and Flip-Flops and registers

EKT 121/4 ELEKTRONIK DIGIT 1

Name Of The Experiment: Sequential circuit design Latch, Flip-flop and Registers

Registers and Counters

Asynchronous counters

Report on 4-bit Counter design Report- 1, 2. Report on D- Flipflop. Course project for ECE533

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

5: Sequential Logic Latches & Flip-flops

Registers and Counters

ELCT201: DIGITAL LOGIC DESIGN

Chapter 7 Counters and Registers

Rangkaian Sekuensial. Flip-flop

The University of Texas at Dallas Department of Computer Science CS 4141: Digital Systems Lab

Sequential Logic Basics

EE 367 Lab Part 1: Sequential Logic

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

MODULE 3. Combinational & Sequential logic

Experiment # 9. Clock generator circuits & Counters. Digital Design LAB

Sri Vidya College of Engineering And Technology. Virudhunagar Department of Electrical and Electronics Engineering

Digital Fundamentals 11/2/2017. Summary. Summary. Floyd. Chapter 7. Latches

Sequential Circuits. Sequential Logic. Circuits with Feedback. Simplest Circuits with Feedback. Memory with Cross-coupled Gates.

Laboratory 4. Figure 1: Serdes Transceiver

Sequential circuits. Same input can produce different output. Logic circuit. William Sandqvist

The NOR latch is similar to the NAND latch

Notes on Digital Circuits

UNIT-3: SEQUENTIAL LOGIC CIRCUITS

ECE 2274 Pre-Lab for Experiment Timer Chip

CHAPTER 1 LATCHES & FLIP-FLOPS

Fig1-1 2-bit asynchronous counter

Contents Circuits... 1

Scanned by CamScanner

Name: Date: Suggested Reading Chapter 7, Digital Systems, Principals and Applications; Tocci

2.6 Reset Design Strategy

ECB DIGITAL ELECTRONICS PROJECT BASED LEARNING PROJECT REPORT ON 7 SEGMENT DIGITAL STOP WATCH USING DECODER

MC9211 Computer Organization

Laboratory Exercise 7

DIGITAL ELECTRONICS MCQs

CHW 261: Logic Design

EE292: Fundamentals of ECE

CPS311 Lecture: Sequential Circuits

EL302 DIGITAL INTEGRATED CIRCUITS LAB #3 CMOS EDGE TRIGGERED D FLIP-FLOP. Due İLKER KALYONCU, 10043

Registers and Counters

D Latch (Transparent Latch)

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) LATCHES and FLIP-FLOPS

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

Review of digital electronics. Storage units Sequential circuits Counters Shifters

Review of Flip-Flop. Divya Aggarwal. Student, Department of Physics and Astro-Physics, University of Delhi, New Delhi. their state.

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Registers

! Two inverters form a static memory cell " Will hold value as long as it has power applied

Digital Fundamentals. Lab 5 Latches & Flip-Flops CETT Name: Date:

Sequential Logic. Sequential Circuits. ! Timing Methodologies " Cascading flip-flops for proper operation " Clock skew

The outputs are formed by a combinational logic function of the inputs to the circuit or the values stored in the flip-flops (or both).

Synchronous Sequential Logic

Chapter 6. sequential logic design. This is the beginning of the second part of this course, sequential logic.

Multiplexor (aka MUX) An example, yet VERY useful circuit!

Transcription:

Chapter 4: One-Shots, Counters, and Clocks I. The Monostable Multivibrator (One-Shot) The timing pulse is one of the most common elements of laboratory electronics. Pulses can control logical sequences with precise timing. For example, if your detector sees a charged particle or a photon, you might want to signal a clock to store the time that the event occurred. In that case, you will use the event to generate a standard pulse so that your clock always responds in the same way. Alternatively, you might need to reset your electronics after the event. Clearly you want the reset pulse to arrive as soon as possible after the data has been processed. This requires a precision time delay generator. A simple type of delay generator is a D type flip-flop that charges up a capacitor after receiving a clock edge. The charged capacitor also serves as the clear input to the D flipflop, so that after a fixed time (roughly RC) the flip-flop resets back to its initial state. The net result is a single pulse that has a duration (or pulse width) determined by the combination of the resistor and capacitor. The exact relationship between the time constant and the pulse width is specified in the datasheet for each chip type. If the falling edge of this pulse triggers other electronics, then you can introduce whatever delay you wish by choosing an appropriate pulse width. This device is called a monostable multivibrator, but the common name is the descriptive one-shot. Many one-shots have two clock inputs so that they can be triggered by either a rising edge or a falling edge. The typical one-shot will also have two outputs (Q and Q ) and an reset or clear input, which instantly sets the output to a standard condition regardless of the current state or clock level. You will find one-shots in all electronic circuits that use pulses and pulse sequences. They are not, however, the best sources of timed pulses. Two effects limit their reliability: (1) a one-shot s pulse length varies with temperature; (2) a one-shot s pulse length varies with duty cycle. It they stay high too long they do not reset as fast as they would for short pulses. Thus, one-shots are generally a bad choice for generating square waves. However, they can be very handy in getting signal timings just right in an asynchronous digital circuit. II. Counters Last week, you used a D-type flip flop to transfer the data from the D input to the Q output on the falling edge of a clock. With one more level of feedback, we can convert this into a device that changes state every time the clock edge falls.

If you connect the inverted output to the input then every time the clock edge fall the flip-flop will reverse its output (i.e. Q n 1 = Q n ). This is shown in Figure 5-1. With a square-wave clock input, the output will change on each falling clock edge generating a square wave at half the frequency. This is called a divide-by two circuit. You can cascade these flip-flops one after another to continue dividing the output frequency. You simply drive the clock of another flip-flop with the output of an earlier flip-flop. We can call the state of the first gate b 1 and the state of the second gate b 2 and create a state table of the sequence of the states of the two gates for successive clock pulses. From Figure 5-2, you can see that the two bits are actually count in binary. By making a cascade of divide by two circuits you have created a counter. This counter is conceptually simple but it takes time for the clock pulse to propagate down the line of flip-flops. If you imagine many flip-flops connected together in a ripple counter, then each will trigger only after a propagation delay. One triggers the next just like a series of falling dominos. This type of counter is dubbed ripple counter to describe this propagating trigger edge. In synchronous counters, however, all stages make their transitions simultaneously. This is usually a much better choice if you have lots of stages (binary digits) in your counter. Of course, the logic is more difficult because you only want a stage to flip states if all the previous stages were set to 1. We will play with synchronous counters next week. Figure 5-1: D type flip-flop as a divide by two counter. Figure 5-2: State table for bits b1 of synchronous counter. Shift Registers You can also construct a shift register by cascading D-type flip-flop without feedback. To make this device connect all of flip-flops use the same clock. The output of one flip-flop is the input of the next flip-flop. If data is presented to the first, it works its way down the line of gates at each clock tick. These are great devices to convert between serial data (one bit follows the next in time) and parallel data (several lines holding simultaneous information). It is an example of queuing circuit known as first in/first out or FIFO buffer. It will store the data in time order and present at it at its output as requested by the clock.

III. Timing with FPGAs and Verilog FPGAs work best when they are used for synchronous circuits. In fact FPGAs do not include capacitors so you cannot use a one-shot in an FPGA circuit. While, this may seem like a problem, it does not pose any real difficulties since a high-frequency synchronous circuit can easily mimic a one-shot. Synchronous circuits in Verilog Synchronous FPGA circuits are implemented in Verilog with the always block. All the code, or circuitry, inside an always block executes on trigger indicated at the ning of the always block. Here is generic Verilog code for an always block: module always_block_example (inputs, outputs ); input input1, input2, ; output output1, output2, ; module output reg [N:0] output_register; reg [M:0] variable_register; always@ (trigger) [put your always block code here] The trigger can be an edge trigger such as always@ (posedge input1) or always@ (negedge input1). The trigger can also be a level trigger such as always@ (input2), which means the always block will execute whenever there is a level change in the input2 value. You can even use an always block without a trigger (though this is a little dangerous, since you will then have an infinite loop, and the timing is not well defined): always The variables that are manipulated and changed inside an always block must be declared as type reg (i.e. a memory register of flip-flops). The always block can include the following statements: Blocking assignment: a = b The blocking assignment is executed and then the code moves on to the next instruction (line of code).

Non-blocking assignment: a <= b The non-blocking assignment is executed at the same time as any other sequential block of non-blocking assigments (i.e. all the non-blocking assignments are executed in parallel). Conditional statement: if (a == b) [the code here will execute if the "if" condition is satified] Conditional statements can be included inside an always block and are a powerful way of manipulating registers or variables. As a general rule, if you are making a circuit in which timing must be included or in which it could be an issue, then you should use an always block. An always block guarantees that you will be constructing a synchronous circuit. In other words, always use always. Some important coding structures to avoid when using an always block: 1. Nested always blocks. 2. Registers or variables which are manipulated in several different always blocks. This means that several output wires are connected and trying to assign a voltage to the "D" input of a register flip-flop (remember last week's warning: "never tie outputs together"). Register initialization in Verilog Variables and registers can be initialized in Verilog with an initial block. The initial block is placed at the ning of a module and is only executed once. Here is an example of how to code an initial block: module always_block_example (inputs, outputs ); input input1, input2, ; output output1, output2, ; output reg [N:0] output_register; reg [M:0] variable_register; initial output_register = N'b10111100011; variable_register = M'b11111001101;

[the rest of your code goes here] module A Verilog counter A counter is easy to implement in Verilog. You use an always block and increment a register variable by one at each trigger, as in the following 4-bit counter example: module counter_verilog(input_clock, counter_register); input input_clock; // declares the input output reg [3:0] counter_register; // declares the output to be a 4-bit // register initial // initial block to set the counter to zero // The next line sets counter register to zero counter_register = 4'b0000; always@ (posedge input_clock) // the following line increments the register by // 1 at each clock trigger counter_register <= counter_register + 4'b0001; module Clocks for FPGAs A synchronous circuit must be triggered by a clock which has a period longer than any of the timing delays in the circuit. A crystal oscillator is frequently used to provide a periodic square wave. The DE2 board is provided with two crystal oscillators, one at 50 MHz and the other at 27 MHz, which are connected to the FPGA at pins PIN_N2 and PIN_D13, repectively. A connection for an external clock is also provided via pin PIN_P26 (see p. 32-33 of DE2 development board manual). Alternatively, the TTL square wave of the function generator can be used as a clock signal. If actual timekeeping is not important, the frequency of the clock does not have to be very stable, but must only have a period longer than the longest internal timing delay in the circuit. Design Exercises: Design Exercise 4-1: Using information from the datasheet for an 74LS123 pick resistors and capacitors to make a pulse of roughly 1 ms and 30 μs. Design Exercise 4-2: Layout a circuit that uses two one-shots to generate a 30 µs pulse that starts 1 ms after a trigger.

Design Exercise 4-3: Use a single always block to construct a Quartus II FPGA project which will generate a 4 clock cycle output pulse that starts 23 clock cycles after an external input trigger goes from low to high. You can assume that the triggering pulse is longer than a single clock cycle. Design Exercise 4-4: Construct a Quartus II FPGA project for a divide-by-8 circuit which will convert a 1 MHz square wave to a 125 khz rectangular wave.