Docsity

Sequential Logic - Digital Logic - Laboratory, Lecture notes of Computer Science

Toggle sidebar
bg1
EXPERIMENT
4
SEQUENTIAL LOGIC
CIRCUITS – Part 1
VERSION F05
In this experiment, you will design, implement and verify two different synchronous counters. After performing this
experiment, you should be able to:
1) Understand the difference between the behavior of a latch and a flip-flop,
2) Design sequential circuits for implementation in an FPGA,
3) Use hierarchy in circuit design, and
4) Use an FPGA-prototyping system to verify sequential circuit function.
In this lab, there are two principal circuits that you will design. The first is a synchronous binary-coded-decimal
(BCD) counter with asynchronous reset and a clock enable input to permit individual counters to be cascaded into
multi-digit synchronous counters. You will design this counter from individual flip-flops and input logic. You will
also convert this circuit to a hierarchy block to make it simpler to create multiple instances of the counter. To test
your counter, a schematic sheet acting as a test platform is provided for you. The second circuit to be designed is a
divide-by-N counter, where N is a specified constant. However, in this case, you will implement this counter using
a counter primitive that provides a 16-bit counter with synchronous reset, and simply add logic to force a counter
reset at the desired count.
In synchronous design, our efforts are premised on the assumption that the clock is occurring simultaneously at all
flip-flops. While this is simple to assume, actually getting the clock to all flip-flops with an acceptable delay is not
always so easy. To facilitate this, the FPGA has dedicated pins, buffers and routing channels specifically designed
to be used for clock distribution. When doing synchronous design, we need to ensure that our clocks are in fact
using these resources.
In the lab, you will also do a study of the difference in time-based behavior between a latch and a flip-flop. The bit
file for this part of the experiment will be provided. As preparation, review the subsection on the D Latch and the
section on Flip-Flops in Mano and Kime.
4-1 PRELAB
For the prelab, you will design and test (in simulation) a cascadable BCD counter and a divide-by-N counter.
BCD COUNTER DESIGN AND SIMULATION
Design a BCD counter using D flip-flops. In particular, you will use the Altera primitive DFFE, which is a D flip-
flop with clock enable (ENA) input and asynchronous preset/clear inputs. You will design your counter in the
manner illustrated in Mano & Kime 3rd edition, pages 337-339. A state table and K-maps are provided for your use
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Sequential Logic - Digital Logic - Laboratory and more Lecture notes Computer Science in PDF only on Docsity!

E X P E R I M E N T

SEQUENTIAL LOGIC

CIRCUITS – Part 1

VERSION F

In this experiment, you will design, implement and verify two different synchronous counters. After performing this experiment, you should be able to:

  1. Understand the difference between the behavior of a latch and a flip-flop,
  2. Design sequential circuits for implementation in an FPGA,
  3. Use hierarchy in circuit design, and
  4. Use an FPGA-prototyping system to verify sequential circuit function.

In this lab, there are two principal circuits that you will design. The first is a synchronous binary-coded-decimal (BCD) counter with asynchronous reset and a clock enable input to permit individual counters to be cascaded into multi-digit synchronous counters. You will design this counter from individual flip-flops and input logic. You will also convert this circuit to a hierarchy block to make it simpler to create multiple instances of the counter. To test your counter, a schematic sheet acting as a test platform is provided for you. The second circuit to be designed is a divide-by-N counter, where N is a specified constant. However, in this case, you will implement this counter using a counter primitive that provides a 16-bit counter with synchronous reset, and simply add logic to force a counter reset at the desired count.

In synchronous design, our efforts are premised on the assumption that the clock is occurring simultaneously at all flip-flops. While this is simple to assume, actually getting the clock to all flip-flops with an acceptable delay is not always so easy. To facilitate this, the FPGA has dedicated pins, buffers and routing channels specifically designed to be used for clock distribution. When doing synchronous design, we need to ensure that our clocks are in fact using these resources.

In the lab, you will also do a study of the difference in time-based behavior between a latch and a flip-flop. The bit file for this part of the experiment will be provided. As preparation, review the subsection on the D Latch and the section on Flip-Flops in Mano and Kime.

4-1 PRELAB

For the prelab, you will design and test (in simulation) a cascadable BCD counter and a divide-by-N counter.

BCD COUNTER DESIGN AND SIMULATION

Design a BCD counter using D flip-flops. In particular, you will use the Altera primitive DFFE , which is a D flip- flop with clock enable (ENA) input and asynchronous preset/clear inputs. You will design your counter in the manner illustrated in Mano & Kime 3rd^ edition, pages 337-339. A state table and K-maps are provided for your use

CE Clock Enable

Inputs

CLR Clear (asynchronous) Outputs Q8, Q4, Q2, Q1 Counter value (Q8 = most significant bit) TC Terminal count output for cascading (high only when count = 9 and CE = 1)

BCD COUNTER DESIGN AND SIMULATION

  1. Complete the state table and flip-flop inputs provided at the end of the document with the required information for this counter design.
  2. Fill in the K-maps provided at the end of this document with the information from the state table and flip- flop inputs. Extract the required input logic equations and note them adjacent to the corresponding K-map.
  3. Create a new Quartus project named BCD_CNT in a new directory LAB4\BCD_CNT. Import the standard ECE 351 pin assignments.
  4. Create a new schematic diagram file named BCD_CNTR. You will design the BCD counter logic in this file, and then use it to create a block.
  5. Place four (4) DFFE flip-flops in your BCD_CNTR schematic file, add input/output pins named as shown above, and add the required input and output logic. Since this flip-flop has clock enable implemented in the primitive, we do not need to incorporate it into our input logic (which would complicate things more than a little bit). Instead, we can simply tie together all of the flip-flop ENA inputs and use that as the clock enable input to the counter.
  6. Functionally simulate your counter and verify its functionality, debugging and modifying as necessary. To do this, first set BCD_CNTR as the top-level entity by clicking on the Hierarchy tab, the right click on Compilation Hierarchy , select Settings… , and under General , set the top level entity to be BCD_CNTR.
  7. Compile your project, then open the Simulator Tool. Set it to Functional , and click Generate Functional Simulation Netlist. Then, select Open to open the waveforms window, and use Node Finder [set the Filter to Pins: (unassigned)] to select all of the BCD_CNTR input/output pins. Then, set CE to a 1 for the duration of the simulation, set CLK to a 10ns clock, and set CLR to 1 for the first 10ns then 0 afterwards. Save the waveforms, and run the simulation.
  8. When you believe your counter is functioning properly, use it to create a hierarchy block named BCD_CNTR.
  9. Print the schematic of your BCD counter for submission with your prelab report.
  10. Download the schematic sheet CNTR_TEST from the course web page. You will use this schematic (shown below) to test your counter blocks in a cascaded connection. Add the schematic sheet to your project, and set it as the top level entity. Compile and then devise a simulation waveform set that will test the counters through a complete 0 to 99 and back to 0 counting cycle. (Organize the waveforms so that the outputs of each counter are grouped together.) Run your simulation, and if necessary, go back and make the required changes to you counter design. Once you are satisfied with it, print a single page of your simulation trace (at a suitable scale) that shows the operation of the least-significant counter through one complete cycle (0-9). Change the scale appropriately, and print a single page of your trace that shows the operation of the most-significant counter through one complete cycle.

First, to run a bus from the output of the counter to your logic, you use the “Orthogonal Bus tool” button pictured here. The operation of the bus drawing button is vary similar to drawing nets. Select the button, and starting at the counter block, run the bus out. End the bus, the right click it and set its name to match the counter outputs, i.e. Q[15..0]. With that done, you can now connect whatever logic you have to the bus. Draw a regular wire from the desired pin on the gate and connect it to the bus. You then name this net as the bus name followed by the desired number. So for example, name the net Q15 to connect to the counter’s most significant bit. The below exampleshows bits Q3 and Q4 being connected to an AND gate.

  1. Assign your counter input to CLK0 (which is the FPGA board’s 2.00MHz oscillator), and assign your counter output to BAR1_.
  2. Functionally simulate your design using a 100MHz clock to stimulate the CLK input, and submit a single page of the simulation trace that shows one complete cycle of the counter output. To get an accurate time measurement, insert a second Time Bar (right-click and Insert Time Bars… ), and place the Time Bars at the appropriate points to show the time required for a single cycle of the counter output. (Note: To do this accurately, you will need to zoom in on the trace to set one end of the measurement, and then scroll to the other end of the measurement. Then, zoom out so that both ends of the measurement are visible.)

Changing the Simulation Length: To change the default length of the vector waveform files used for simulation, select Tools Æ Options from the Quartus menu, then select Waveform Editor to see the waveform file options. You can set the " default file end time " here; the setting will affect all new VWF files that you create. Also, the VWF files are simply ASCII text files, so you can open them using File Æ Open... (but specify " Text " instead of "Auto" in the Open as: box at the bottom of the open file dialog) and then edit the file directly. If you look at a simple VWF file (i.e. just a clock signal), it's pretty obvious how the basic syntax works.

  1. Print your schematic for submission with the prelab report.

PRELAB REPORT

Your report on 8.5 by 11 inch pages should consist of the following:

  1. a cover with the experiment number, experiment name, your name, name(s) of the other team member(s), and your instructor’s name, and your lab section,
  2. Your state table and K-maps for the BCD counter,
  3. Your annotated simulation traces and schematic diagram for the BCD counters.
  4. Your annotated simulation trace and schematic diagram for the divide-by-2000 counter.
  5. All questions in the question box below with your individual answers.

4-2 LAB WORK

W ARNING : All lab results and all answers to questions or discussion are to appear in the lab reports of individual students. All tangible lab results are to be identical (unless indicated otherwise). When a printout of results is specified, a copy should be made for each team member. All answers to questions or discussion are to be the work of individual students, not the lab team. Evidence of collaboration on these aspects of a report within or between teams will be noted and is subject to University disciplinary action.

EQUIPMENT NEEDED

In addition to the equipment already on the lab bench, your instructor will have you check out a plastic tray containing:

  1. an FPGA prototyping board,
  2. a power supply module for the prototyping board,
  3. two scope probes,
  4. a logic analyzer probe,
  5. four black logic analyzer extension wires in a plastic bag, and
  6. some blue interconnect leads.

W ARNING – LAB EQUIPMENT HANDLING : Much of the lab equipment is small and delicate. In particular, this applies to the XESS prototyping boards, scopes, scope probes, and logic analyzer probes. So please be careful and handle the equipment with a light and careful touch and do not use the scope probes with the grabbers removed. Perform wiring on the board ONLY with the power disconnected.

LATCHES AND FLIP-FLOPS

The circuit you will be exploring, given in Figure 2, consists of two nearly identical circuits, one of which contains a D flip-flop and the other of which contains a D latch. The bit file for this design is provided for you, you don’t need to do the actual design.

TESTING THE DIVIDE-BY-2000 COUNTER

T ESTING SETUP

  1. Perform the POWER DOWN sequence.
  2. Remove the blue lead you installed previously.
  3. Connect the oscilloscope to observe the clock input (CLKIN) on D0 and the counter output (BAR1_1) on D1. Trigger the oscilloscope on the counter output.

PERFORMING T ESTS AND RECORDING RESULTS

  1. Perform the POWER UP sequence.
  2. Download your div2000.sof file to the prototyping board.
  3. Obtain a suitable display on the oscilloscope, and use the cursors to accurately measure the period of counter output. Print the screen for submission with your report.

CHECKPOINT: Have your instructor observe the operation of your counter.

4-3 REPORT

Your individual report on 8.5 by 11 inch pages should follow the report format available on the course web page and consist of:

  1. A cover with the experiment number, experiment name, your name, name(s) of other team member(s), and your instructor’s name, your lab section, the number on the equipment tray used, and name on the PC used.
  2. Description of Laboratory Exercise and Conclusions as shown in the report format,
  3. Your individual answers to all of the questions given in the green-bordered boxes (online version has color), and
  4. Copies of all printouts for the lab properly annotated and in the order produced. a. printouts for the Latches and Flip-Flops portion of the experiment. b. printout of the Divide-By-2000 counter test.

REFERENCES

1. MANO, M. M AND C. R. K IME. Logic and Computer Design Fundamentals, 3rd ed_._ Upper Saddle River, NJ: Prentice Hall, 2003.

Inputs Next State Output Flip-Flop Inputs Q8 Q4 Q2 Q1 CE CLR Q8 Q4 Q2 Q1 TC D8 D4 D2 D

0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 1 0 0 1 1 0

X X X X 0 0

X X X X X 1

00 01 11

10

11

01

00

Q2 Q Q8 Q

K-map for FF Input D

00 01 11 10

10

11

01

00

Q2 Q Q8 Q

K-map for FF Input D

00 01 11 10

10

11

01

00

Q2 Q Q8 Q

K-map for FF Input D

00 01 11 10

10

11

01

00

Q2 Q Q8 Q

K-map for Output TC

00 01 11 10

10

11

01

00

Q2 Q Q8 Q