ECNG3016 Practical 3
ECNG3016 Practical 3
ECNG 3016
ADVANCED DIGITAL ELECTRONICS
http://myelearning.sta.uwi.edu/course/view.php?id=686
Semester II 2010
1.
GENERAL INFORMATION
Lab #:
Name of the Lab:
Practical 3
Using a Keypad Encoder to Illustrate Writing Testbenches in VHDL using Xilinx
ISim Simulator
0%
Estimated total study
3
hours1:
Lecture
Online
Lab
Other
Lab Weighting:
Delivery mode:
Microprocessor Laboratory
Lab Dependencies2
Recommended prior
knowledge and
skills3:
Course Staff
Position/Role
Cathy Radix
Lecturer
E-mail
[email protected]
Azim Abdool
Instructor
Phone
x3157
x2636
Office
Office
Hours
Rm
321, Mon/Tue
Blk 1
11am 2pm
Rm 341/ Mon/
RTSG, Blk 1 Thu
11am12pm
2.
Upon successful completion of the lab assignment, students will be able to:
1. Create VHDL testbenches using the ISim simulator in Xilinx ISE to test simple
VHDL circuits
3.
Cognitive Level
Ap
Ap
Ap, Sy
PRE-LAB
Due Date:
Submission
Procedure:
Estimated time to
completion:
NA
-
Create a project in Xilinx ISE Webpack. The project should conform to the project settings as illustrated.
Be sure when creating your project the simulator options should be set as shown. For this lab we are
utilizing the ISim simulator in VHDL.
You are first required to build a keypad encoder module in VHDL that would conform to the specifications as
given by the following table.
Table 1 below shows the data format that is recognized by the keypad encoder:
Create an encoder module that would take as input the 12 bit code output of the keypad module as an
input and produce a 4-bit coded word output that represents the key pressed. If either a * or # was pressed,
output 0. The module should latch the last key pressed. Use the language template version of an encoder
module as a guide.
Synthesize your design. Ensure that there are no synthesis errors or warnings. Read the generated timing
report.
For the project (so far) what is the maximum synthesizable frequency?
Would this meet the constraint imposed by the 50MHz clock on the Spartan 3 development board?
What must the setup time and hold time constraints be, according to the timing report?
Now well move on to testing your design using a VHDL written testbench using the ISim simulator.
The webpack should automatically generate a file with template code filled.
This testbench file acts as a driver module which would present a set of inputs to your DUT (device under
test), in this case, the encoder module. There should be two main processes generated, one which controls
the toggling of the clock signal and the other for you to fill out with the stimulus which you are providing.
For the first process, the clock signal generation, fill in the constraint for the clock period. What is the clock
period on the Spartan 3 development board? Since we will be using this board for testing, well utilize this
constraint within the simulator.
-- Stimulus process
stim_proc: process
begin
wait for clk_period*10;
reset <= '1';
wait for 40 ns;
reset<= '0';
keys_i <= "001000000000";
wait for 100 ns;
keys_i <= "000000000000";
wait;
end process;
Note that the above is a simple example of an absolute time test. Now we can also in our simple example
create a self checking testbench.
The file which it verifies with is named values.txt and should be put into the working directory. The content
of the file is given as:
Run the testbench simulation model at the behavioural simulation level. If everything was done correctly to
this point there should be a successful simulation output.
View the testbench waveform. Ensure that you can run the model from the ISim window and zoom in and
out of the result waveform. Look at the console output and verify that the testbench reported that there
were no deviations from the given simulation file.
Try next running at the Post Place and Route simulation level. Does this simulation still meet the expected
output given in the values.txt file?
Look at the report summary for the Post Place and Route Static Timing Report. For the particular net that
we are investigating, what are the timing analysis reports? Pay particular attention to the clock to pad
section within the report. For that matter, what is a clock to pad time? Do the numbers presented here
correlate with what is seen on the testbench output?
If this is the case, what should your golden vector file truly represent?
Rewrite your testbench to fully test the encoder module. What test vectors should you run? For each key?
What if multiple keys are pressed?
It is important that you plan ahead and know what you want before you test for it. This is to ensure that
your final design meets some predetermined constraints. For example, what if this were a design which had
to run on a 100MHz clock in the end. After adding all of your modules, would it meet that constraint?
After you have finally finished creating your module and testing to ensure that it meets the constraint of the
50MHz clock on the Spartan 3 board, create a decoder module which would take as an output your 4bit
coded output and decode it to match a 7-segment display output.
The idea would be to display your result on one of the 4 seven segment displays on the Spartan 3
development board. You can use the language templates to assist with this.
Draw a diagram depicting the interconnections between your encoder and decoder modules. Be sure to
show all of the inputs and outputs. Be sure to set only one of the anodes as being on all of the time while
taking off all of the others. For simplicity, we can create this decoder module as a totally asynchronous
module.
Create testbenches for the decoder module and ensure that this module meets functional requirements.
Map the encoder and decoder together and ensure that the final system meets your requirements.
Create a ucf which has the following constraints:
Design Port
Clk
Reset
keys(0)
keys(1)
keys(2)
keys(3)
keys(4)
keys(5)
keys(6)
keys(7)
keys(8)
keys(9)
keys(10)
keys(11)
anode(0)
anode(1)
anode(2)
anode(3)
seg(0)
seg(1)
seg(2)
seg(3)
seg(4)
seg(5)
seg(6)
T9
any available pushbutton
D11
R10
C12
T7
D12
R7
E11
N6
B16
M6
R3
C15
D14
G14
F14
E13
Dependent on your encoding scheme
Dependent on your encoding scheme
Dependent on your encoding scheme
Dependent on your encoding scheme
Dependent on your encoding scheme
Dependent on your encoding scheme
Dependent on your encoding scheme
What is the maximum static post PAR timing that you would expect from any of the seven segment PADs?
What is the maximum frequency at which you can run your system?
Does this meet the constraint of the Spartan 3 development board?
4.
IN-LAB
Allotted Completion
Time:
Required lab
Equipment:
3 hours
1 Computer
1 Spartan 3 Toolkit
1 keypad + 40-pin ribbon cable circuit(completely wired)
Now we have simulated the design up till this point. However, there are some hardware constraints
which must be taken into consideration when completing your design.
At this point we know that our design would take a key that is pressed according to the one-hot keypad
output and be translated to a 7-segment output.
However, what about the specific voltages and currents that are presented to the FPGA pin?
Consult your datasheet. What is the maximum permissible current and voltage levels which can be
sourced/sunk by the FPGA pins?
Do the keypad output pins need debouncing? What would be an appropriate debounce time?
Add in a module to debounce the switches at the debounce rate that you have determined.
You can use the language templates to assist with this (VHDL -> Synthesis Constructs -> Coding Examples
-> Misc -> Debounce).
After mapping together your entire system, download on to the Spartan 3 development board.
Does it work as expected?
10
11
5.
POST-LAB
Due Date:
Submission
Procedure:
Deliverables:
NA
-
12