CARLETON UNIVERSITY. The Tug-of-War Game. Player 1 RESET

Similar documents
Keeping The Clock Pure. Making The Impurities Digestible

Asynchronous (Ripple) Counters

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Unit 11. Latches and Flip-Flops

Chapter 9 Counters. Clock Edge Output Q 2 Q 1 Q

ASYNCHRONOUS SEQUENTIAL CIRCUIT CONCEPTS

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

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).

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

DIGITAL CIRCUIT LOGIC UNIT 11: SEQUENTIAL CIRCUITS (LATCHES AND FLIP-FLOPS)

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

CARLETON UNIVERSITY. Facts without theory is trivia. Theory without facts is bull 2607-LRB

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

A clock is a free-running signal with a cycle time. A clock may be either high or low, and alternates between the two states.


Unit 9 Latches and Flip-Flops. Dept. of Electrical and Computer Eng., NCTU 1

COMP sequential logic 1 Jan. 25, 2016

Logic Design II (17.342) Spring Lecture Outline

Lecture 8: Sequential Logic

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

Outline. CPE/EE 422/522 Advanced Logic Design L03. Review: Clocked D Flip-Flop with Rising-edge Trigger. Sequential Networks

Logic Design. Flip Flops, Registers and Counters

Advanced Digital Logic Design EECS 303

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

CPS311 Lecture: Sequential Circuits

CHAPTER 1 LATCHES & FLIP-FLOPS

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

Sequential Digital Design. Laboratory Manual. Experiment #3. Flip Flop Storage Elements

`COEN 312 DIGITAL SYSTEMS DESIGN - LECTURE NOTES Concordia University

INTRODUCTION TO SEQUENTIAL CIRCUITS

EECS150 - Digital Design Lecture 15 Finite State Machines. Announcements

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

Clocks. Sequential Logic. A clock is a free-running signal with a cycle time.

Switching Circuits & Logic Design

CSE 352 Laboratory Assignment 3

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

RS flip-flop using NOR gate

Counter dan Register

Chapter 5: Synchronous Sequential Logic

Digital Fundamentals: A Systems Approach

Digital Design, Kyung Hee Univ. Chapter 5. Synchronous Sequential Logic

Combinational vs Sequential

Digital Fundamentals: A Systems Approach

2.6 Reset Design Strategy

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

EECS 373 Design of Microprocessor-Based Systems

Chapter 5 Sequential Circuits

Experiment 8 Introduction to Latches and Flip-Flops and registers

Other Flip-Flops. Lecture 27 1

Momentary Changes in Outputs. State Machine Signaling. Oscillatory Behavior. Hazards/Glitches. Types of Hazards. Static Hazards

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

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED 220. Experiment 4 - Latches and Flip-Flops

1. What does the signal for a static-zero hazard look like?

Chapter 5 Flip-Flops and Related Devices

EE292: Fundamentals of ECE

RS flip-flop using NOR gate

CHAPTER 4: Logic Circuits

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Learning Outcomes. Unit 13. Sequential Logic BISTABLES, LATCHES, AND FLIP- FLOPS. I understand the difference between levelsensitive

Chapter 5 Synchronous Sequential Logic

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

UNIT IV. Sequential circuit

cascading flip-flops for proper operation clock skew Hardware description languages and sequential logic

Sequential Circuits: Latches & Flip-Flops

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

Digital Integrated Circuits EECS 312

1. Convert the decimal number to binary, octal, and hexadecimal.

Laboratory 4 A MIDI Interface

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING DIGITAL DESIGN

CHAPTER 4: Logic Circuits

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

Problems with D-Latch

EET2411 DIGITAL ELECTRONICS

Supplement 3 Asynchronous Sequential Circuit Concepts

Logic. Andrew Mark Allen March 4, 2012

FLIP-FLOPS AND RELATED DEVICES

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

Laboratory 4 A MIDI Interface

CHAPTER 6 COUNTERS & REGISTERS

(Refer Slide Time: 2:00)

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

LATCHES & FLIP-FLOP. Chapter 7

SEQUENTIAL CIRCUITS SEQUENTIAL CIRCUITS

Sequential Logic. E&CE 223 Digital Circuits and Systems (A. Kennings) Page 1

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

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

Final Exam review: chapter 4 and 5. Supplement 3 and 4

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District DEPARTMENT OF INFORMATION TECHNOLOGY CS 2202 DIGITAL PRINCIPLES AND SYSTEM DESIGN

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

Chapter 5 Sequential Circuits

Physics 120 Lab 10 (2018): Flip-flops and Registers

Review of digital electronics. Storage units Sequential circuits Counters Shifters

Chapter 3 Unit Combinational

Solar Power for Small Hall

CHAPTER 11 LATCHES AND FLIP-FLOPS

Figure 1 shows a simple implementation of a clock switch, using an AND-OR type multiplexer logic.

Previous Lecture Sequential Circuits. Slide Summary of contents covered in this lecture. (Refer Slide Time: 01:55)

Transcription:

ARLETON UNIVERSITY Deparment of Electronics ELE 3500 Digital Electronics October 17, 2006. The Tug-of-War Game Rev 11. 1.0 The Game : Overview The players of this game see a row of 7 LEDs represented by the numbers L3 through R3 in FIGURE 1 FIGURE 1. The tug of war machine. It contains 3 push-buttons, 7 light-emitting diodes (LEDs) and 1 field-programmable gate array (FPGA) Player 1 BL LEDs L3 L2 L1 0 R1 R2 R3 Player 2 BR LOK After pushing reset, all the LEDs should come on for a second and then go off. This is the get ready signal. After a random time the middle LED comes on again. Then each player will try to push his button before the other player does. The position of the lit LED will move toward the fastest button pusher. Thus if player 2 is fastest, LED 0 will go out and LED R1 will come on. This is the end of round one. After a second the LEDs will all go out. This is the get ready signal for round two. After a random time LED R1 will come on (assuming player 2 won the first round). Again each player will try to push his button first, and again the light will shift toward the fastest button pusher. The game is won when one player makes the position of the lit LED move off the end of the display. If a player jumps the light, i.e. he pushes his button while the LEDs are off, then the light will come on immediately and it will be shifted one position away from him as a penelty of an illegal move. The FAVOR-THE-LOSER circuit gives a slow starter a chance. When a player is about to win ( the R3 or L3) position) the light will jump back two spaces (to positions R1 or L1) if he loses, but only one position if he jumps-thelight. The circuit must be able to distinguish the winner within two gate delays (a few nanoseconds). Further the design must be fair. For example, the design should not assign ties to one of the players. 2.0 The Field Programmable Gate Array (FPGA) These are a collection of several hundred flip-flops, and several thousand gates, all collected in one integrated circuit. Also in the integrated circuit are a large number of wires which run across different parts of the integrated circuit. There are also many electrically controlled switches which connect the flip-flops and gates to the wires, and the wires to each other. By opening and closing the switches, one can build almost any digital circuit unless the circuit needs more gates or flip-flops than there are in the FPGA. Department of Electronics DIGITAL ELETRONIS (courtesy of J.Knight, 94) 1

arleton University ELE3500, The Tug-of-War Game Good Design Practice, Setting theses connection switches might be quite a job, Fortunately there is a computer program that does all the work. Just connect the FPGA to the serial port of a P, run the program, and in about five seconds, your circuit is built. It sure beats stripping wires! Your assignment is to design a Field-Programmable Gate Array (FPGA) to perform the tug-of-war game. All the logic will be on one I. Only the push buttons, LEDs, LED drivers and the oscillator will be external. 3.0 Good Design Practice The following practices shall be followed in your design: a. Do not gate the clock. The gate will cause the flip-flops controlled by the gated clock to flip later than the ones directly connected. Use enabled flip-flops, and gate the enable instead of the clock. b. Use only ONE clock for all timing. Divide its output to get slower timing signals. Then use a pulse fed into the clock-enable (E) flip-flop input to give a lower effective clock rate. c. Two related (passing through common logic) asynchronous input signals must be stable near the clock edge on which they are read. d. Do not allow one asynchronous input to change two state variables (flip-flops) together. If the clock changes just as the input changes you get a race. Instead clock the input into a single D flip-flop. This makes the input into a synchronous signal which can safely initiate multiple-variable state changes. e. Do not use asynchronous preset or clear in counters and shift registers. The clear signal may clear itself before clearing all the flip-flops. Asynchronous clear may, and should, be used to clear all flip-flops during power-on restart. f. Any asynchronous circuit which latches, i.e. your push button circuit, must be checked for hazards and races. g. Any unclocked latches in your circuit are asynchronous. If you place cross coupled NAND gates in the synchronous part of your circuit, you have created an asynchronous island in a supposedly synchronous circuit. You must then check for hazards, races and essential hazards at all latch inputs. 1 4.0 Initial Planning As with most specifications, there are a lot of subspecifications buried in the design document. You should read through the complete document and list these before you start serious design.. Figure 2. A possible block diagram for the game. The blocks are completely synchronous and run from a common clock, except for the BUTTON LATH which is asynchronous.. LOK BL BR BUTTON LATH DIVIDE BY 256 Tie PSEUDO RANDOM BIT GEN. SLOWENABLE LEAR SYNH PULSE ROUT OPP MASTER ONTROL R'(H)/L'(L) Tie Don t type brackets (, ) or single quotes ' or slash / into VIEW logic. For example use R_H or for R(H). LEDS_ctrl SORER LED MUX FAVOR THE LOSER Score Leds_out L3 L2 L1 0 R1 R2 R3 LIGHTS 1. There is another reason for not placing any of the above asynchronous concepts into a synchronous circuit. The testing method (Scan Testing) used for modern digital circuits will not work with embedded asynchronous elements. Electronic Engineering October 17, 2006 Tug Lab page 2, of 9

arleton University ELE3500, The Tug-of-War Game Initial Planning, lock and lock Divider 4.1 lock and lock Divider The master clock should be about 500 Hz. This is fast enough so humans will not see appreciable delay, but it is slow enough so a divide by LOK 256 can give the 1/2 second timing humans can see. The divide by 256 gives a pseudo-clock, a pulse one-clock-cycle wide every 2 8 or 256 clock cycles., called SLOWENABLE. they can only change at a 1/2 sec rate, even though they are clocked at 500 Hz. 4.2 Push Button Latch This must be asynchronous since it must tell which button was pushed first within a couple of gate delays. It debounces the buttons by merely latching on the first contact of the first button pushed. It should hold the signal until reset by the LEAR input. It has three inputs: BL, BR and LEAR. 4.3 The FAVOR-THE-LOSER circuit. This pulse can enable/disable the flip-flops so When a player is in the L3 or R3 LED positions and the other player wins, the lights will jump back two positions. The block diagram above seems to suggest that this is a separate block. Another, probably better, way is to build it into the scorer. We would recommend you build the Favor the loser circuit into the Scorer. Note it only shifts back one position if the winner jumps-the-light. 4.4 The SORER DIVIDE BY 128 SLOWENABLE It is suggested that the SORER have three inputs: WinRnd... a one clock-cycle pulse which comes after a button push. It tells that somebody has won the round. R/L. tells which button was pushed first. Right if high, left if low.... tells if a LED is lit and thus can be used to tell if a player pushes his button ahead of time (jumps the light) The score will move left or right according to the formula Right = WinRnd MR. winrnd Left = WinRnd MR Where MR...move right = 1; if R/L, =1, 1, or 0,0 0; if R/L, =0, 1, or 1,0. LK Thus MR signifies a right move - if (the right button was pressed) and (the SORER player did not jump the light),or (the left button was pressed) and (the player jumped the light). L3 L2 L1 0 R1 R2 R3 BL BR D E BUTTON LATH D E LEAR 4.5 The Synchronizer ircuit The output from the BUTTON LATH is asynchronous, that is it may change at any time including on the clock edge. The SORER may not count correctly if its inputs change very near the clock edge. As you will learn in the lectures, inputs to an FSM s D flip-flops must never change near the clock edge. Near means inside the fli-flops setup and hold times. If the D inputs changes near the clock edge, one does not know whether the flipflops will capture the old D value, the new D value, or some will capture the old and some the new. The PBL output must be synchronized, so it cannot change on the clock edge. This is done by passing it through a D flip-flop. The clock-to-output delay, t HQV, inside the flip-flop will delay Q till after the clock edge. Thus Q acts as a slightly delayed synchronous D. FIGURE 2 shows how this happens. SYNH PULSE R'(H)/L'(L) Electronic Engineering October 17, 2006 Tug Lab page 3, of 9

arleton University ELE3500, The Tug-of-War Game Initial Planning, The Synchronizer ircuit FIGURE 2. How a D flip-flop synchronizes a signal. If the D input changes inside the flip-flop setup or hold times, the signal may: i) be captured, in which case it appears as the Q 1 output, rising a safe distance after the clock edge. ii) have the capture delayed until the next clock edge. Then it will appear as Q 2, which is delayed, but still a safe distance from the active clock edge. Either Q1 or Q2 is a safe, synchronized signal to feed to multiple flip-flops in a synchronous machine. iii) go metastable which is not a problem with very slow clocks like this one. D (asynch) (i) Q1 (ii) Q2 D Setup & hold times t HQV Q1 or Q2 t HQV OMPLEX SYNHRONOUS MAHINE The tentative design suggests two input signals: (H)...is latched true as soon as any button is pushed....tells which button was pushed first, the right button or the left.. While one asynchronous signal can be synchronized by passing it through a D flip-flop, two logically related asynchronous signals cannot. They will appear to be properly synchronized until they both change on the same clock edge. Then one may be captured by its D flip-flop but the other may not. The problems can be seen by looking at and in FIGURE 3 The two input signals and R(H)/ L(L) are logically related and change at about the same time. Suppose and both change inside the setup and hold time. Then the Synchronizer circuit might latch the correct and old incorrect value of R(H)/ L(L). On the next clock cycle R (H)/L (L) would be correct but it is too late! The SORER has already moved to the wrong light. FIGURE 3. The signals and are SORER counts on this edge logically related and occur only nanoseconds apart. Sy t HQV Suppose is captured on one cycle, but Setup and hold times is not captured until the next cycle. Then left will appear to have won because nanoseconds R/L = 0 on the next clock edge when SORER is R'(H)/L'(L) Signal Too late enabled. Right won but Left got the score! The cure is simple. Latch only ; do not latch. See FIGURE 5 on page 5. We know when goes high, is at worst nanoseconds behind it. The SORER reacts, not to the clock edge where is captured, but on the next (2nd) clock edge. By that time will be correct for sure Alternately, might not be captured and then would be delayed a clock cycle. See FIGURE 4. Then the SORER would not react until the 3rd clock edge. By that time will have been correct for two cycles.. FIGURE 4. This time was too late for the 1st clock edge and was captured on the 2nd as. SORER counts on the 3rd clock edge does not go through a flip-flop and rises within nanoseconds of Setup and hold times rising.remains correct until cleared. The SORER reacts to on the 3rd Alternate position for clock cycle. It counts in a direction given by (H) t HQV. Both signals are stable at the 3rd clock edge. Electronic Engineering October 17, 2006 Tug Lab page 4, of 9

arleton University ELE3500, The Tug-of-War Game Initial Planning, The OPP (One-Pulse-Per-Push) ircuit FIGURE 5. The signals and are logically related and occur only nanoseconds apart. (i) Suppose rises very near the clock edge, will rise either on the same clock edge or the next one. However, will be correct within nanoseconds of rising, and will remain correct until cleared. (ii) The SORER reacts to on the 2nd cycle. It counts up or down according to which is stable long before the 2nd clock edge. No flip-flop (H) (i) t HQV Setup and hold times Alternate capture of (H). See Figure 5. (i) R'(H)/L'(L) = SORER counts on the 2nd clock edge (i i) is correct on the 2nd clock edge. 4.6 The OPP (One-Pulse-Per-Push) ircuit The SORER must count only once, be it up or down, for each round played on the game. Otherwise each push will count for many wins. The OPP circuit insures this by giving out one-pulse-per-push (round). The synchronized push signal,, will initiate an output signal which will last exactly one clock cycle. FIGURE 6. The signal lasts a single clock cycle so one round of the game will only move the SORER once. OMB LOGI (H) One clock cycle long 4.7 The Pseudorandom ounter This circuit creates ROUT, a string of 1s and 0s which is unpredictable to the players. The time between bits should be about 1 second. SLOWENABLE 4.8 The Master ontroller The controller times the action of the game as follows: LEDS_trl a. Someone pushes a button either as a win or a jumped light. b. The LEDs will come on immediately after a button is pushed. c. The LEDs stay on for 1/2 to 1 second so it is clear who won; under 1/2 is too short, longer would be boring d. Then all the LEDs go out for a random time, minimum of 1/2 second. e. A single LEDs come back on after this random time. 4.8.1 Slow Players and Gloating Players PSEUDO RANDOM BIT GEN. MASTER ONTROL If the players are slow, the controller circuit should keep the lights on until a push occurs. It also holds the light on an additional 1/2 to 1 second after a push so the movement of the lights can be observed and the winner can gloat. 4.8.2 Jumping the Light If a player jumps the light, the light should change immediately. However the timing is the same as for a legitimate push. Also the controller should wait the gloat period and start the next round. ROUT SLOW LEAR Electronic Engineering October 17, 2006 Tug Lab page 5, of 9

arleton University ELE3500, The Tug-of-War Game Implementation details., Led Mux 4.8.3 lear After the LEDs go off, one must clear the push button latch. The master controller send out a LEAR pulse to do this. This arms the push buttons quickly and allows detecting any player jumping the light at anytime except the first clock cycle of the dark period (about 1/250 of a second). 4.9 Led Mux Led Mux is used to choose between whether the display lights should show all lights ON or all lights OFF or display the Score at that point of the Game depending on the LEDS_trl signal from the master controller. LEDS_ctrl LEDS_out 5.0 Implementation details. 5.1 The SORER ircuit If you decide to add extras, like separate win states, flashing lights, music, or a siren, you are free to do so however design them into your state machine now. Do not stick patches on at the end! 5.2 The Master ontroller The inputs signals shown for this subcircuit are: ROUT... the bit string from the pseudorandom bit generator....goes high for one clock cycle after a button is pushed. SLOWENABLE... which acts like a slow clock The output signals might be:...to say one or more LEDs are on. LEDS_trl... controls the LED MUX to show the appropriate lights LEAR..which generates LEAR signal to clear the -BUTTON LATH. 5.2.1 Initial Lamp heck On, all the LEDs should immediately come on, and stay on for 1 sec after is released. This shows that all the lights work. All LEDs should then go out and the center LED should come back on after the next rising edge of ROUT. FIGURE 7. The game after the initial reset. Here comes on again, a Moore machine delay after the rising edge of ROUT. Note SLOW ENABLE does not run during. (random) ROUT 1/2 sec min delay Score SLOW ENABLE All lights flash waiting for light wait for push 5.2.2 The Mid-Game onsider midgame play as in FIGURE 8. (a) When the ROUT signal goes high it raises on the next SLOWENABLE. This turns on a LED and signals the players to push. Note ROUT rises just after pulse hence it cannot cause a reaction until pulse B. (b) Pushes generate a signal which moves the light and will eventually turn off. However stays on for at least 1 second after, so the players can see who won, and remove their fingers. Electronic Engineering October 17, 2006 Tug Lab page 6, of 9

arleton University ELE3500, The Tug-of-War Game Implementation details., Pseudorandom Sequence (c) After the 1 sec extra delay, will go off even though ROUT may stay high. (d) The Master controller generates LEAR which clears the push-button latch. (e) should wait a short time before coming on again. If ROUT stays high it would come back on the next SLOW ENABLE. FIGURE 8..The midgame after one or more rounds. (a) ROUT rising turns on the LEDs, the signal to the players to push. (b) A push raises the pulse, which will, after 1/2 to 1 sec, (c) lower and pulse SLOWLEAR. (d) SLOWLEAR in turn will pulse FASTLEAR. (e) The next will wait till the next rising edge of ROUT. (random) ROUT 1/2 sec extra delay SLOW ENABLE A B? A B? (a) (b) (c) (e) one LED on waiting for light waiting for push waiting for push a push happened LEAR 5.3 Pseudorandom Sequence Generators FIGURE 11 on page 8 shows a widely used circuit which generates a sequence of bits. The output may be taken from any of Q1,Q2.Q3 or Q4. While the sequence is periodic, inside of its 15 cycle period, it passes many of the statistical tests for randomness. Notice it is a 15, not a 16,cycle FSM. The 16th state is all zeros. IF IT GETS INTO THAT STATE IT WILL NEVER OME OUT. These pseudorandom shift registers can be made in any length but the most efficient ones have N flip-flops and have sequence length 2 N -1. The final state is all zeros and not used. onnections for sequences with periods up to 511 bits are shown in FIGURE 10. A B D Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 FIGURE 10 A general pseudorandom bit stream generator. The number of flip-flops used depends on the length of sequence desired. Thus, for a 15 bit sequence remove all but 4 flip-flops. For a 31 bit sequence, remove all but 5 flip-flops, etc. See FIGURE 11 and FIGURE 12 SEQUENE LENGTHS FOR FIGURE 10 Link 15 31 63 127 255 511 A to Q3 Q3 Q5 Q6 Q2 Q5 B to Q4 Q5 Q6 Q7 Q3 Q9 to Omit Omit Omit Omit Q4 Omit D to Omit Omit Omit Omit Q8 Omit Examples using this table are shown in FIGURE 11 and especially FIGURE 12. Note that the generator must not be all zeros initially or it will not start, i.e. this is a state machine which will lock up in the 0000 state! Note cycle 0 and 15 are the same The sequence is always of length 2 N -1 because the flip-flops can never be all zeros! Verilog code to imply the random number generator on the right, is given below. Electronic Engineering October 17, 2006 Tug Lab page 7, of 9

arleton University ELE3500, The Tug-of-War Game Implementation details., Generating the SLOWENABLE.reg [4:1] Q; always @(posedge clk or posedge clr) begin if (clr) Q<=4'd8; // Must not reset state to zero. else if (clk) begin Q[4:2]<=Q[3:1]; //(line 7) Q[1] <= Q[1]^Q[4]; //(line 8) end /* The <= is called a nonblocking assignment. The Qs on the right all use the values they had at the begin. Thus line 8 uses the original Q[4] and not the revised value from line 7.*/ 5.4 Generating the SLOWENABLE This circuit must generate a single pulse every 256 clock pulses. One needs a 8 bit counter which gives a carry pulse (T) out every time it rolls over from say 11111111 -> 00000000. ounters are trivial to generate in Verilog. 5.5 The Basis of the Design of the Push Button ircuit LK The push button circuit shall be as fair 1 0 0 0 1 as modern technology can make it. 0 0 0 0 0 i) It must tell who pushed first within a time equal to the propagation delay of two inverters. ii) It shall have no theoretical bias toward one player. Because of the difference in delays between gates and/ or lead lengths, it is impossible not to have some bias in the circuit after construction. iii) If your circuit goes into a tie state, it shall either: a. have equal theoretical probability of exiting toward either player. b. leave the light stationary for that round. iv) It should not depend on which player releases their button first. In a poor design, this can happen in the case of a tie, which causes the winner to be determined by the bounce properties of the push buttons. 5.6 The Design of the Synchronizer ircuit FIGURE 11 A circuit made from XOR and FFs which gives repeatable random number sequences. This example can be constructed from the general example of FIGURE 10 by connecting A to Q3 and B to Q4 clock cycles A B 1 0 0 0 0 1 0 0 0 0 1 0 1 0 0 1 1 1 0 0 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 The synchronizer circuit takes the asynchronous input which may change anytime and makes it into which cannot change near the clock edge. That is during the setup or hold times of the flipflops. Logically independent asynchronous input signals should be sent through a single D flip-flop before they enter the rest of the synchronous machine. But this will not work for two logically-dependent signals. See Sect 4.5. 4 9 6 5 13 15 3 8 2 12 11 10 14 7 Q1 Q2 Q3 Q4 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 0 0 1 1 Electronic Engineering October 17, 2006 Tug Lab page 8, of 9

arleton University ELE3500, The Tug-of-War GameImplementation details., The Design of the OPP (One-Pulse- 5.7 The Design of the OPP (One-Pulse-per-Push) ircuit It gives out a single synchronous pulse one clock cycle long. It always gives one pulse, and only one pulse. FIGURE 12The sychronizer D flip-flop and a the OPP circuit. The OPP circuit is simpler to implement as a Mealy machine, as shown by its state graph. Start of 1 Pulse ircuit Timing for the OPP ircuit asynchronous synchronous State Graph for the OPP ircuit LOK / / 0 1 / Stay in state 1 if Sypush=1 / Output for state 1 and =1 More Details on Implementation will be on the over page for each lab, don t forget to check them!!! Electronic Engineering October 17, 2006 Tug Lab page 9, of 9