Professional Documents
Culture Documents
Mini Project Guide
Mini Project Guide
Mini Project Guide
This guide would have not been possible without inputs from
SEEE2263 lecturers past and present:
Izam Kamisian
Dr Ismahani Ismail
Norhafizah Ramli
Zuraimi Yahya
Dr Zulfakar Aspar
Ismail Ariffin
Dr Muhammad Nadzir Marsono
Dr Shaikh Nasir @ Nasir Shaikh Husin
Kamal Khalil
Abd Hamid Ahmad
Zulkifli Mohd Yusof (Universiti Malaysia Pahang)
Dr Amirjan Nawabjan
Dr Suhaila Isaak
Dr Shahidatul Sadiah
Overview of SEEE2263 Mini-Project
Objectives
• To build a complete digital system design containing a datapath unit and control unit
• To perform top-down design and bottom-up implementation of a digital system
• To implement and test the design on a CPLD board with all relevant I/O devices
• To manage a team project with the aid of a Gantt Chart
The mini-project contributes 30% to your overall marks. By the end of the semester,
you must implement a complete digital system on a CPLD board. To ensure you complete
the project, the mini-project has six different stages, so that you build the complete system
incrementally. The tasks are outlined in the following Gantt Chart.
Project Scheduling
Lecture Weeks
Milestone
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1
2
3
4
5
6
Milestone # Deliverable
1 Quartus familiarization
2 CPLD familiarization
3 Basic input/output
4 Finite state machines
5 Datapath unit
6 Control unit & system integration
What to Submit
1. Plagiarism Declaration
2. Marking Rubric
4. References
i
Required Equipment
Equipment Source
Quartus II Download at http://fpgasoftware.intel.com/13.1/?edition=web
EPM240 CPLD board
Ask your lecturer or find on Internet
USB Blaster
DuPont wires
Breadboard
LEDs Should be easy to find locally
DIP switches
Resistors
Tutorials
Application notes at http://raden.fke.utm.my/appnotes.
Additional Instructions
1. Your circuit must be modular
2. PLO8 Compliant
3. PLO11 Compliant
ii
PLAGIARISM DECLARATION
1. I know that plagiarism means taking and using the ideas, writings, works or inventions
of another as if they were one’s own. I know that plagiarism not only includes
verbatim copy- ing, but also the extensive use of another person’s ideas without proper
acknowledgement (which includes the proper use of quotation marks). I know that
plagiarism covers this sort of use of material found in textual sources and from the
Internet.
3. I understand that my research must be accurately referenced. I have followed the rules
and conventions concerning referencing, citation and the conventions concerning
referencing and citation.
5. I have not allowed, nor will I in the future allow, anyone to copy my work with the
intention of passing it off as their own work.
Team Name
Name
Matric Number
Signature
Date
Name
Matric Number
Signature
Date
Name
Matric Number
Signature
Date
MARKING RUBRIC
Milestone 1
5
Marks for the assignment = Total marks × 24
Student Name don’t use, this rubric is not ready yet Section
Score Score
Item Category 4 3 2 1
M2 M3
1. Overall Understands and Somewhat Has a low-level un- Fails to grasp the
Design: implements the full understands derstanding of top- concept of top-down
Concepts top-down design the concept of down design? design.
procedure top-down design
2. Detailed Proper bottom-up Mostly correct se- Some order of Seemingly random
Design, sequence circuits, quence. bottom-up series of collections of
Concepts from the lowest level circuits is missing. circuits. Many
up to the complete irrelevant circuits.
circuit
3. Detailed Complete Mostly complete Circuits can be read Hard to read circuit
Design, documentation documentation of but with effort. diagrams, improper
Diagrams & of unfamiliar unfamiliar circuits. use of signal labels.
Documenta- circuits. Proper use
tion of signal labels and
busses.
4. Simulation: Simulation is Simulation covers Simulation covers Simulation is brief
Data complete with most test cases. some interesting and missing signifi-
proper choice of test cases. cant test case.
inputs
5. Simulation: Clear & easy to read Reasonably easy to Readable reporting No analysis is re-
Analysis reporting read, with minimum but with some effort ported.
errors
6. Hardware Demonstration is Demonstration Demonstration is Demonstration is
Imple- very clear and is but and partly not clear. not complete.
mentation completely working. working.
(YouTube
video)
7. Report Report is well orga- Report is well or- Report is somewhat Report contains
Quality nized and compre- ganized but some organized many errors
hensive vital information is
missing
8. Sources, ref- All sources All sources All sources Some sources are
erences, re- are accurately are accurately are accurately not accurately docu-
flections documented in the documented, but a documented, but mented.
desired format. few are not in the many are not in the
desired format. desired format.
9. Plagiarism Signed by all mem- Missing one signa- Majority not signed. Submitted with no
Declaration bers. ture signature.
Form
Total Marks (36)
MARKING RUBRIC
Milestone 4/5/6
Student Name don’t use, this rubric is not ready yet Section
Step 1
Step 2
Compile the design. If there are no errors, print compilation report as PDF.
Step 3
Simulate by giving all 4 input combinations for a and b : 00, 01, 10 and 11. Maintain each
input combination for 100ns. That means the End Time for the simulation should be 400ns.
Check the result with the expected output. When the circuit is error-free, proceed to Step 4.
Step 4
1
Milestone 1 Quartus Familiarization
Step 5
Print the following 3 pages as PDF. You must choose landscape orientation.
Page 1: Schematic of half adder: Printscreen then convert to PDF.
Page 2: Compilation report
Page 3: Annotated simulation output waveform: This is not the same as the simulation input.
Printscreen first, then in MSPaint or similar software, highlight the important information.
Save as PDF.
Step 1
Use Quartus schematic entry to input two instances of half adder symbols from Part 1 Step
4. Combine the two half adders with an or2 gate to build a full adder.
Half adder
Half adder
ai
bi si
c i+1
ci
Step 2
Compile the design. If there are no errors, print compilation report as PDF.
Step 3
Simulate using all 8 input combinations 000 through 111. Maintain each input combination
for 100ns. That means the End Time for the simulation should be 800ns. Check the result
with the expected output. When the circuit is error-free, proceed to Step 4.
Step 4
Step 5
Print the following 3 pages as PDF. You must choose landscape orientation.
Page 4: Schematic of full adder..
Page 5: Compilation report
Page 6: Annotated simulation output waveform..
2
1.1 4-bit Ripple Carry Adder
Step 1
Use Quartus schematic entry to input four instances of full adder symbols from Part 2 Step
4. Combine to build the ripple carry as follows.
a3 b3 a2 b2 a1 b1 a0 b0
FA FA FA FA
c4 c3 c2 c1 c0
s3 s2 s1 s0
Step 2
Compile the design. If there are no errors, print compilation report as PDF.
Step 3
In Table 1.1, fill in columns COUT and S[3:0] so you know what is the expected output for
each input combination. Values in columns A, B and S are in hexadecimal.
In the simulation waveform input, use bus groups for A, B and S signal. (A bunch of
related signals are called a bus.) Use hexadecimal system. Simulate using the given test
data. Then mark with the adder complies with the expected results. Simulate using the 10
input combinations given below. Maintain each input combination for 100ns. That means
the End Time for the simulation should be 1000ns. When the circuit is error-free, proceed
to Step 4.
3
Milestone 1 Quartus Familiarization
Step 4
Print the following 4 pages as PDF. You must choose landscape orientation.
Page 7: Schematic of ripple carry adder..
Page 8: Compilation report
Page 9: Annotated simulation output waveform..
Page 10: References. On this page, list all web sites, articles or books you referred in
completing the assignment. You must any citation format but be consistent.
Step 5
Combine all 10 PDF pages into 1 PDF document. Add the plagiarism declaration as the
front cover. Upload to elearning.utm.my.
4
1.2 Bus Multiplexer
4. Convert the module into symbol file. Call it busmux4bit.bsf. It should like Fig. 1.6.
5
Milestone 1 Quartus Familiarization
6
1.3 Data Register
4. Convert the module into symbol file. Call it reg4bit.bsf. It should like Fig. 1.11.
7
MILESTONE 2
CPLD Familiarization
Objectives
• Getting started with EPM240 CPLD
• Familiarization with various methods of design entry
• Creation of more modules for design reuse
After going through the example in AN04, you should get a blinking LED driven by the
EPM240 CPLD.
VDD
50 1 Hz 4 10
mapper
We will create all low level modules first. Afterwards, they are integrated at the top level
schematic diagram.
8
2.2 BCD Counter
2. Save the blank file as knightrider (or milestone2 etc) and set it as Top-Level Entity.
3. Call up the New Symbol dialog and type lpm_counter in the Name field.
4. On Page 2c, click Next >
.
5. On Page 3, set the width of the ’q’ output bus to 4 bits. Click Next >
.
6. On Page 4, set counter type to Modulus, with a count modulus of 10. Click Finish
.
7. On Page 7, click Finish
.
10. Add a bus at the output of the counter and label it q[3..0]. Refer Figure 2.3.
9
Milestone 2 CPLD Familiarization
A 7442 BCD decoder has 10 outputs and accepts a value in the range of 0..9. The output
is active low. A value greater than 9 causes all outputs to be high.
1. Still in the schematic diagram from Section 2.2, call up the New Symbol dialog and
type 7442 in the Name field.
2. Add regular wires to all inputs of the 7442. Label the inputs as q0, q1, q2, and q3.
The BCD counter is now connected to the BCD decoder. Refer to Figure 2.5.
10
2.4 Mapper
2.4 Mapper
Section Objective
Design entry using primitives.
4. Save it as mapper.bdf.
Figure 2.7: Mapper symbol. You can see this symbol by opening another block diagram document
and importing it. Make sure the input pin numbering is sequential.
11
Milestone 2 CPLD Familiarization
2. Insert the mapper symbol and connect with the 7442 BCD decoder.
3. Add one input port to the BCD counter, and 6 output ports from the mapper.
The top level schematic should look like Figure 2.8.
7. Using the default setting for end time, set the clock period so that you can see at least
10 clock cycles in the simulation window. You should see something like Figure 2.9.
8. Save a copy the top-level bdf file so that you have two copies of the same file. Give
them distinct names such as knight_partial.bdf and knight_final.bdf or something
similar. Keep the first file as a “fallback” schematic in case something goes wrong
when you add extra modules later. Modify only the second file in the following steps.
12
2.6 Prescaler
2.6 Prescaler
Section Objective
Design entry using Verilog HDL.
The prescaler module slows the clock from 50 MHz to exactly 1 Hz.
2. Save as prescaler.v.
Figure 2.10: Prescaler symbol. Note: you can see this symbol by opening another block diagram
document and importing it.
5. In the top-level schematic diagram, add the prescaler module. The circuit now look
like Figure 2.11. Set the top-level module back to this diagram.
Note
After the prescaler is added, the circuit can no longer be simulated.
13
Milestone 2 CPLD Familiarization
1. From the Assignments å Device menu verify that you have chosen the EPM240T100C5
device.
3. Assign 6 more pins for the output ports. You can use any I/O bank. For example, you
can use the settings from Figure 2.13 to use pins closest to ground pin on the EPM240
connector block. However, any other combination can be used.
(The two I/O bank can theoretically use different supply voltages for interfacing. On
the red EPM240 board, this is not possible because the power supply rails are tied
together. Therefore, any I/O bank can be used.)
I/O bank VCCIO GNDIO
1 Pin 9, 31,45 Pin 10, 32, 46
2 Pin 59, 80, 94 Pin 60, 79, 93
4. Recompile the design. After recompilation, the assigned pins should appear at the
top level schematic. The final schematic should be like Fig. 2.14.
14
Figure 2.14: Final top level schematic.
15
2.7 Programming the CPLD
MILESTONE 3
Accumulator-Based Vending
Machine
Objectives
• Interfacing CPLD with simple input/output devices
• Design of high-level modules based on specifications
• Building a circuit on a strip board
The vending machine is based on a 4-bit accumulator which keeps tracks of how much
money has been deposited. The accumulator value equals multiples of 10 sens. It has two
button inputs: button 1 for 20 sen, button 2 for 50 sen. Pressing a button adds 2 or 5 to the
accumulator.
The 7 segment display shows the current value of accumulator in BCD up to 15. When
the accumulator contains 12 or more, the Knight Rider LEDs (from Milestone 2) will display
one round of lights (as opposed to unlimited rounds in Milestone 2).
Implementation steps:
1. Prepare all modules in Table 3.1. Simulate all independently, except the prescaler
(module 4).
16
4
3.3V 7
SW1 4 4 4
Accumulator Binary-to-BCD
7
Input filter
3.3V 4 Clear
Selector 3.3V
SW2
Input filter
4
A Knight
A>B
Comparator Rider
4
1011 B lights
CLK2(approx.100Hz)
50MHz Prescaler
CLK1(approx.1Hz) DONE
17
3.1 Overall Description
Milestone 3 Accumulator-Based Vending Machine
The following sections describes the module functions, grouped by level of reuse.
The 4-bit ripple carry adder from Milestone 1 can be used directly without modification. No
simulation is necessary for this circuit as it is completely reusable.
3.2.2 Accumulator
The procedure to build the accumulator from Milestone 1 can be followed. However, the
function is different. In this accumulator, the control line is called Clear.
Clear Function
0 Loads data at D0-D3
1 Register is cleared (Q←0) on next clock edge
D3 D0
D Q D Q
Clear
Clk
Q3 Q0
Figure 3.2: First and last cells of the register with synchronous clear.
Build and simulate one cell first. Then combine 4 cells to build the accumulator. Show the
compilation report, schematic and simulation of the 4-cell accumulator only.
The Knight Rider lights from Milestone 2 runs forever. Make two modificaitons:
• Add a control signal circuitry to enable/disable the lights, so that the LEDs runs only
when this input is high.
• Add a status signal (DONE) that indicates when the lights have run a complete round.
Simulate to check if the circuit can be enabled/disabled on demand, and the DONE is
activated at the correct time.
18
3.3 Modules based on Circuit in Textbook
3.2.4 Prescaler
• CLK1: a signal approximately 1 Hz. This speed is required so that the Knight Rider
light can run slowly and visible to humans.
• CLK2: a signal approximately 100Hz. This speed is required to eliminate contact
bounce that happens when a button is pressed.
Implement the prescaler using a 26-bit up counter from LPM_COUNTER. Use bit 25 as
CLK1 and another bit as CLK2. Do not use the Verilog version.
Do not simulate the prescaler. Do not integrate it with the main system yet. We will add it
at the final construction stage.
The comparator gives a high output when the accumulator contains a value more than 11.
Choose a combinational or iterative comparator from Section 6.4. For the comparator, show
the compilation reports, schematics and simulation.
The input to the converter is a binary input 0000 to 1111. The outputs are 7 lines to the tens
digits and 1 line to the ones digit. Inside the converter, the binary input is first converted to
BCD to produce a two-digit BCD result using the conditional add by 3 adder (cadd3) module
in Section 6.2.
A 7447 module turns the proper segments on the right hand LED display. No 7447 is
necessary for the left hand LED display because it is either turned off or displays the number
1. This is because the range of numbers displayed is limited to 0 through 15. The tens digit
is represented by d4 which can be either 0 or 1. Simply connect d4 to both segments b and
c to display the number 1 when required.
d4 to segments b, c
d4
0
d3
b3
cadd3 d2
b2 7-segment codes
d1 7447
b1 to ones display
b0 d0
Button presses produce glitches lasting 1-10 milliseconds which are detected as multiple
presses if a fast clock is used. A slow clock at the filter removes the glitches. The function
of the input filter is to convert a button press into a single clean pulse.
19
Milestone 3 Accumulator-Based Vending Machine
Note that if the clock is too slow, the user must press the button for an unreasonable
amount of time before the button press is detected. The frequency of clock input is not
fixed. Change it to a suitable frequency depending on the switches used.
pulse out
switch in D Q D Q
100 Hz
You will need two copies of the filter, one for each button. The buttons are active low,
meaning that it is high when not pressed, and low when pressed. The circuit is Fig. 3.4
produces a single pulse when a high-to-low transition is detected at its input.
3.4 Selector
The adder add the current value of the accumulator (first input) and the value chosen by the
selector circuit (second input). The selector chooses a value to place at the second adder
input based on this table:
The selected value is presented for exactly one clock cycle for every button press. This is
a combinational circuit which your team must design.
20
MILESTONE 4
Finite State Machines
Objectives
• Basics of finite state machine
After the LEDs have finished running, the machine returns to the intial state. Do not reset
the CPLD to return to the initial state.
1. On paper, sketch the state diagram to detect the sequence given to your group.
Solve it using both Moore and Mealy approaches. Keep this sketch as your
documentation.
2. Enter one state diagram (either Moore or Mealy) using the State Machine Editor in
Quartus.
5. When simulation is successful, add the Input Filter, Prescaler and Knight Rider (from
Milestones 2 and 3).
21
Milestone 4 Finite State Machines
7. Test it. The Knight Rider lights should run once when the correct sequence is entered
on the pushbuttons.
If you’re submitting the milestone by video, record the process of building and testing this
circuit. Show that entering the correct button sequence turns on the Knight Rider.
1. Based on the Moore version of the state diagram, get the next state equations and
output equation.
1. Based on the Mealy version of the state diagram, derive the state table. Use
straight/sequential binary encoding.
22
MILESTONE 5
Datapath Unit for Complex Digital
System
Objectives
• Selecting a complex digital system to implement using the naïve multiplier as a
template for construction procedure
• Identifying components to construct a datapath unit
• Integrating and testing the components of the datapath unit
5.1 Overview
For Milestones 5 and 6, each group will be specified a complex digital system. The options
are in Table 5.1. The list is not exhaustive. Your lecturer may have extra topics available.
You can also propose your own topic.
The steps for building the datapath for a naïve multiplier is shown in this handout. Follow
the same procedure for the circuit assigned to you.
0 + 2 + 2 + 2 + 2 + 2 = 10
23
Table 5.1: List of possible topics
Level of
Title Starting Point
Difficulty
Ones counter 1 In-book
GCD finder v1 2 In-book
Milestone 5 Datapath Unit for Complex Digital System
24
5.2 Problem Formulation
P = 0;
while( N != 0) {
P = P + M;
N = N - 1;
}
return P;
}
CU
Go Valid
Init Work Zero
DU
M 4 A[7..4]
0000
A
Init Load A[3..0] 8
M + P
Init Clear
4-bit Register B Work Load
N
Zero
8-bit Adder
P
4
8-bit Accumulator
Init Load
Work Count 4
N 8
4-bit Down counter
25
Milestone 5 Datapath Unit for Complex Digital System
Table 5.3 lists the components required to build a 4-bit × 4-bit naïve multiplier.
Design and build each component and test independently. Remember: this is a design
course. As a digital designer, you are expected to be able to design each module yourself,
individually. You are free to use lpm built-in modules, create your own module using
schematics or write Verilog code to implement the modules.
5.4 Integration
lpm_ff1 lpm_add_sub0
DFF
M[3..0] INPUT
VCC data[3..0] dataa[7..0] acc
d[3..0] A
clock result[7..0] OUTPUT P[7..0]
q[3..0] d[7..0] A+B D[7..0] Q[7..0]
enable datab[7..0]
B Load
inst3 d[7..4] inst
Clear
Clock
GND
inst4
Clock INPUT
VCC
lpm_counter0
down counter
Init INPUT
sload
VCC
N[3..0] INPUT
data[3..0]
VCC
inst5
Figure 5.2: Naïve multiplier datapath. The signal group Q[3..0] shows the current value of the
counter. It is not used in the final system because the controller only needs to know
whether the counter has reached zero (cout=Zero=1).
26
5.4 Integration
Figure 5.3: Simulation of naïve multiplier datapath. The Work signal enables the counter to count
down and the acccumulator to load a new value. When the controller is added later,
Work can be stopped automatically when Zero = 1.
27
MILESTONE 6
Controller for Complex Digital
System
Objectives
• Implementing the control unit to manage the datapath unit from the previous milestone
• Integrating the control unit with the datapath unit
• Demonstrating the complete system in hardware
6.1 Procedure
Fig. 6.1 illustrates the procedure for controller design.
State Machine
One-hot
Editor
controller
Verilog
Text
Editor
VHDL etc
• Algorithm describes the problem at high level. This is usually given as C code
fragment or pseudo-code.
• High-level ASM converts the algorithm to an ASM chart that closely follows the
algorithm using the Register Transfer Language (RTL) notation. All variable names
used in the algorithm are maintained.
• Low-level ASM or control ASM replaces the RTL statements to control and status
signals as defined in the datapath unit.
• The controller is finally implemented using one-hot or one of the highly encoded state
assignments. For full marks, submit a implementation based on the one-hot approach.
For quick prototyping and for partial marks, you can use the State Machine Editor. The
highly encoded state assignment is not recommended because the large number of
inputs to the next state logic.
28
6.2 High-Level ASM
Reset
S0
0
Go
1
0
P ← 0,
M ← multiplicand, 1
N ← multiplier Go
S1 S2
P←P+M
Valid ← 1
N←N-1
0 1
N=0
Reset
S0 001
0
Go
1 0
1
Init Go
S1 010 S2 100
Work Valid
0 1
Zero
From the low-level ASM chart, you can complete the design directly or you can experiment
with State Machine Editor for first.
29
Milestone 6 Controller for Complex Digital System
Init = S0 · Go
Work = S1 · Zero0
Valid = S2
The controller can now be entered using the schematic editor. The result is shown Fig.
6.4.
Go
S0
+
S0 S0 Init
D Q
S2
S0
+
S1 S1
D Q
S1 Work
S1
+
S2 S2
D Q Valid
S2
Zero
mi Clock
Figure 6.4: Controller for naïve multiplier. The inverted first flip-flop method is used to automatically
start the one-hot controller upon power-on-reset.
30
6.4 System Integration
inst
datapath
Figure 6.6: Simulation of 4 × 3 and 15 × 7 at the module level. Annotations helps the reader look at
the important parts of the waveform.
31
Milestone 6 Controller for Complex Digital System
6.5 Demonstration
After the simulations have shown the circuit to work correctly, add the necessary input and
output modules such as in Fig. 6.7. The number of DIP switches and LED displays depends
on the bit width used in your particular circuit.
3.3V
Go 1 EPM240
board 7
A Result displayed
Operand1 4
in hex or decimal
B 4
7
Operand2
Figure 6.7: Demonstrating the CU+DU with decimal output. Shown here, A = 4, B = 3 and P =
4 × 3 = 12.
To demonstrate, enter the operands using the DIP switches, and press Go. After some
processing, the output should be visible on the displays. You may want to use a slow clock
so that intermediate results can be made visible.
You can also use the hexadecimal number system to display the output. For example,
the biggest value generated by the multiplier is 15 × 15 = 225 which requires three digits in
decimal, but only two digits in hexadecimal. However, you must replace the 7447 decimal-
to-seven-segment-display code converter with your own converter.
32