0% found this document useful (0 votes)
6 views3 pages

Counter Design Lab Preparation Guide

The lab focuses on designing a counter using flip-flops and gates to simulate rolling a die, with students implementing individualized counting sequences. It includes pre-lab preparation, design requirements for both Moore and Mealy machines, and verification steps using Quartus and ModelSim. A lab report is required, detailing the design process, simulation results, and answers to specific questions comparing the two designs.

Uploaded by

Samyak Varshney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Counter Design Lab Preparation Guide

The lab focuses on designing a counter using flip-flops and gates to simulate rolling a die, with students implementing individualized counting sequences. It includes pre-lab preparation, design requirements for both Moore and Mealy machines, and verification steps using Quartus and ModelSim. A lab report is required, detailing the design process, simulation results, and answers to specific questions comparing the two designs.

Uploaded by

Samyak Varshney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIVERSITY OF CALIFORNIA, DAVIS

Department of Electrical and Computer Engineering

EEC180A DIGITAL SYSTEMS I WINTER 2018

LAB 5: COUNTER DESIGN

Objective: Given a desired counting sequence, design and build the counter using flip-flops and
gates. Derive the flip-flop input equations using a state table and K-maps

Preparation (Pre-lab)
 Do the complete paper design for the counter specified in Design I. Your paper design
must include the following items:
o State transition table for the counter
o K-maps for each of the flip-flop input equations.
o Minimized sum of products (SoP) equation for each flip-flop input signal.

Description
In this lab, you will design a unique counter that implements the state diagram shown in the
figure below. Each student will be given an individualized count sequence to implement. The
count values X1 – X6 shown in the figure will be some sequence of the numbers 1 – 6, with
each number used only once. This circuit will simulate rolling a die.

Rb’ Rb’ Rb’


Reset

0 X1 X2 X3
Rb Rb Rb

Rb Rb

Rb’
Rb Rb
X6 X5 X4

Rb’ Rb’ Rb’

Figure 1. Counter State Diagram

Note that the counter has an input, Rb, which stands for “Roll button”. The counter counts as
long as Rb = 1, but when Rb = 0 the counter maintains the last count value.

There is one other possible state in a 3-bit counter design. For example if X1 to X6 correspond to
state bits 001 to 110 and the reset state corresponds to state bits 000, the “missing” state has state
bits 111. It is possible that the state machine could power-up in this state. If so, you must
guarantee that the state machine does not remain stuck in this state, even when the reset switch is
not pressed. Thus, the next state assignment from the missing state must be to one of the states in
the count sequence, X1 to X6, or the reset state.

Design I. Moore Machine with the State Bits as the Outputs


Design the counter as a Moore machine where the state bits serve as the count outputs.

a) Draw a state transition table and derive the input equations for implementing the counter
using D flip-flops and logic gates.

b) Enter your design in Quartus. Use the 7474 or the DFF component for the D flip-flops,
the 7447 component for the seven-segment display logic, INPUT and OUTPUT
components and basic logic gates (AND, OR, NOT, etc.) Use pushbutton switches for Rb
and for Reset. Display the output on HEX0. This circuit should be clocked by the 50 MHz
clock signal, MAX10_CLK1_50.

c) Verify your design by simulating in ModelSim. Print a copy of your simulation waveforms
for one complete cycle for your lab report. Set the radix to hex for the seven-segment
output signal. Have your TA verify your simulation.

You should simulate with a clock period of 20 ns and run the simulation for 100 ns each step.

Design II. Mealy Machine


Design the counter as a Mealy machine. Do a complete paper design. However, you do not need
to enter your design as a Quartus schematic or simulate your design. Compare the number of
gates required for the Mealy machine with the number required for the Moore machine in Design
I.

Implementation of Design I
Once your simulation for Design I works, download your design to the DE10-Lite board and
verify that your circuit works. Don’t forget to import the pin assignments!! The output will
change too fast to observe the sequence while the counter is counting, but you should observe
that the counter stops on numbers 1 to 6 with about equal probability. If the die seems to be
‘unfair’, check your simulation and your circuit carefully. Another debugging technique is to test
your circuit with a slow clock so you can see the count sequence. (This circuit will be used as
part of the final lab, so save your project files.) Have your TA verify your working circuit.

Lab Report
Each individual will be required to submit a lab report. Use the format specified in the "Lab
Report Requirements" document available on the class web page. Be sure to include the
following items in your lab report:

 Lab cover sheet with TA verification for circuit simulation and performance
 Graded pre-lab
 Logic design documentation (truth table, K maps, logic equations) for both designs
 Quartus schematics for Design I
 ModelSim simulation waveforms for Design I
Answer the following questions in your Lab Report:
Q1: Compare Design I and Design II of the sequential circuit. Describe any advantages or
disadvantages of the Moore design for this circuit.

Q2: A third design for the counter circuit might use a Moore machine where the state bits were
not used as the outputs. For example, the state bits might be the binary count sequence 0 – 6.
How would this design compare with Designs I and II (assuming your assigned count was not the
straight binary count sequence 1 to 6)? Which design is likely to require the fewest gates? Justify
your answer.

Grading
 Prelab 25 points
 Lab Verification (Simulation) 20 points
 Lab Verification (Hardware) 20 points
 Lab Report 35 points

The Lab Report grading will be as follows:


 Mealy machine paper design (Design II) 10
 Question Q1 5
 Question Q2 5
 Quartus schematic 5
 Quartus simulation waveform for your unique count sequence 10

Common questions

Powered by AI

Challenges in avoiding a 'stuck' state include ensuring proper initialization of the counter from any state, including unexpected power-up states like the unused state with bits 111. Strategies to mitigate this include designing a fallback mechanism from such states to transition to a valid state within the sequence or reset state. This involves clearly defining and implementing these transitions in the state transition table and verified them through simulation to ensure the design's reliability under all conditions .

In designing a Moore machine for the counter, the state transition table needs to define how the counter transitions between each unique state in the user-defined sequence, represented by state bits. The K-maps are used to derive minimized Boolean equations for the inputs of the flip-flops, ensuring optimal gate usage. Each state must have defined transitions for all input possibilities, particularly addressing what happens from the 'missing' state with state bits 111 to prevent it from 'getting stuck.' This involves mapping out each flip-flop's input equations meticulously .

The input Rb, which stands for 'Roll button,' affects the counter by allowing it to count when Rb = 1 and maintaining the current count value when Rb = 0. This means that if the button is not pressed, or is released (Rb = 0), the counter will pause and hold the last number shown in the sequence. When Rb is set back to 1, the counter continues its state transitions and counting .

The complexity of gate usage typically differs between Moore and Mealy machines in that the number of gates required for a Moore machine might be higher because each state output depends solely on the current state bits. In contrast, a Mealy machine output can depend on the present state and input, potentially reducing gate count. For the EEC180A lab, the comparison of Moore and Mealy machines involves assessing these differences, particularly since the Moore design directly uses state bits as outputs, possibly leading to less efficient logic minimization compared to a similar Mealy design .

Implementing a counter with state bits not directly used as outputs could increase the gate count and complexity compared to Designs I and II. This setup requires additional decoding logic to convert state bits to the desired outputs, thereby necessitating more gate logic. Since every state bit combination must be decoded to match the specific sequence required, it results in increased hardware usage, making the design potentially less efficient than one where state outputs directly correlate with the sequence .

The simulation phase in ModelSim allows for a detailed verification of the design's functionality under controlled conditions. By simulating the counter, designers can observe behavioral outputs, state transitions, and ensure that transitions properly occur between states as per the intended counting sequence. It allows for detection of issues such as undesired states or incorrect logic equations before physical implementation, ensuring that the complex, intended logic functions in practice as expected without hardware faults .

When setting the clock period for ModelSim simulation, it is crucial to ensure that the selected period accommodates the time it takes for signal propagation through all logic gates and flip-flops within one cycle. Hence, a sufficiently long period prevents timing errors and ensures that all state transitions and resultant outputs stabilize completely within each clock cycle, which is especially pertinent when verifying high-frequency counters like those clocked by a 50 MHz source in the EEC180A lab .

Thermal or electrical inefficiencies can lead to unstable or incorrect functionality in the hardware implementation. Thermal inefficiencies could cause overheating, resulting in inconsistent behavior or permanent damage to the components. Electrical inefficiencies, such as poor power distribution or excessive power consumption, might introduce noise, causing bit errors or disrupted signal integrity. These issues necessitate careful design considerations and debugging of the physical setup, ensuring robust clock and power management to uphold reliable counter operation .

Inaccuracies in flip-flop input equations can lead to a fundamentally flawed design, where the state machine may fail to transition correctly between states. Potential impacts include skipping states, halting unexpectedly, or cycling incorrectly through the sequences, impacting the reliability and intended function of the counter. These inaccuracies might arise from errors in minimizing logic expressions on K-maps or overlooked conditions, which make thorough verification critical. Every derived equation must be testing against the intended state transition table through simulation to preemptively identify such logical flaws .

A key advantage of using a Moore machine is its simplicity in design when each state naturally corresponds to a unique output, such as in a counting sequence. This makes debugging simpler, as each state consistently outputs the same value regardless of input changes. This intrinsic separation of state and input-output logic could simplify conceptually aligning with design goals like those in the EEC180A lab, where state bits represent the output directly, helping in understanding and verifying each transition visually .

You might also like