Lab5
Lab5
Şenol Mutlu
1
EE244 Prof. Dr. Şenol Mutlu
Value = (1-2S)×M×2E
where S is the sign bit, M is the mantissa and E is the exponent. The 4-bit mantissa, M,
ranges from (0000)2 to (1111)2 representing 0 to 15, respectively and the exponent ranges
from (000)2 to (111)2 representing 0 to 7, respectively. Here are some examples for the
number representations in floating point number and their magnitudes’ binary values in 11
bit.
2
EE244 Prof. Dr. Şenol Mutlu
a
f g b b
e c c
d
Segments of the seven-segment LED display.
entity BCD_to_seven_segment is
port ( d: in std_logic_vector (3 downto 0);
s: out std_logic_vector ( 6 downto 0) );
end BCD_to_seven_segment;
begin
with d select
s <="1000000" when "0000",
"1111001" when "0001",
"0100100" when "0010",
"0110000" when "0011",
"0011001" when "0100",
"0010010" when "0101",
"0000010" when "0110",
"1111000" when "0111",
"0000000" when "1000",
"0010000" when "1001",
"1111111" when others;
end dataflow;
3
EE244 Prof. Dr. Şenol Mutlu
A seven-segment LED display is composed of individual LEDs with common anode (or
cathode) arranged in “figure 8” pattern. However, seven-segment name used for the
display of our FPGA board should not mislead you since it actually has eight LEDs (one
LED for the decimal point called DP) as shown in the figure below [1]. Each LED on the
seven-segment display can be turned on individually. In this lab, you are generating 7-bit
data but the board requires 8-bit input for each digit. Since we are not going to use this
decimal point, you can assign logic 1 value to the DP LED to turn it off, which is the most
significant bit. Therefore, Digit3[7], Digit2[7], Digit1[7] and Digit0[7] can be constant values
of logic 1.
We want to display four digits in this lab. You do not need to design and implement this
sequential seven-segment driver operation. This is already done for you. All you need to
do is to present your 4 digit data to the seven segment driver component, which is given
in the nexys3_sseg_driver.vhd file. You can use structural vhdl to connect your design
and this seven segment driver design. Thus, your design should have 32 outputs. The first
8-bit output (least significant digit) is connected to Digit0. The second 8-bit output is
connected to Digit1, so on and so forth. We are not going to display the sign bit of the
number. Hence, do not worry about the sign bit. The entity of your design should have four
sets of 8-bit output ports. These outputs will be connected to seven-segment driver design.
Seven segment driver uses a clock signal to turn on individual digits one at a time with a
refresh rate of 100 Hz. Thus, this driver also needs a clock signal. The given VHDL code
uses the board clock to generate the 100 Hz refresh rate.
4
EE244 Prof. Dr. Şenol Mutlu
5
EE244 Prof. Dr. Şenol Mutlu
Overall Design
As explained above your design will generate 8-bit input (in reality, you will generate 7 bit,
since we ignore sign bit). You will use a slow counter with a frequency of 2 Hz to generate
this signal named FP. You will, then, calculate its value as a 11-bit binary value. Finally,
you will display this value as 4 decimal digit on 7-segment displays. Your design will
generate 8-bit digit3 output, 8-bit digit2 output, 8-bit digit1 output and 8-bit digit0 output.
Then, these outputs will be inputs to the design given in the nexys3_sseg_driver.vhd file
using structural VHDL style. This design will generate the SSEG_CA(7 downto 0) and
SSEG_AN(3 downto 0) outputs using the clock signal it generates from the board clock.
As a starting point your VHDL code for this design can have a structure as shown below.
You should complete its architecture. Your VHDL code can use only structural and/or
dataflow style VHDL. Behavioral style is not allowed in this lab. If you want, you can build
the required frequency dividers by first building their schematics and then turning their
schematics into structural VHDL code.
-- Synthesizable Floating Point to Signed Magnitude Decoder, EE244 class Bogazici University
-- Implemented on Xilinx Spartan VI FPGA chip
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE ieee.std_logic_signed.all ;
USE ieee.std_logic_arith.all ;
entity FP_decoder is
port (
6
EE244 Prof. Dr. Şenol Mutlu
MY_CLK: in std_logic;
SSEG_CA: out std_logic_vector(7 downto 0);
SSEG_AN: out std_logic_vector(3 downto 0));
end;
--digit3(7 downto 0), digit2(7 downto 0), digit1(7 downto 0) and digit0(7 downto 0) will be
-- input to the design given in the nexys3_sseg_driver.vhd file using structural vhdl style.
-- This design will generate the SSEG_CA(7 downto 0) and SSEG_AN(3 downto 0)
-- outputs using the board clock signal.
end arch_FP_decoder;
You may need to use a multiplier in this design. A VHDL multiplier example is given below.
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
7
EE244 Prof. Dr. Şenol Mutlu
USE ieee.std_logic_signed.all ;
USE ieee.std_logic_arith.all ;
entity mymultiply is
port(
a : in STD_LOGIC_VECTOR(15 downto 0);
b : in STD_LOGIC_VECTOR(7 downto 0);
mult : out STD_LOGIC_VECTOR(23 downto 0);
);
end mymultiply;
architecture dataflow of mymultiply is
begin
mult <= a * b;
end dataflow;
Pin Assignment
After successfully completing the design, compilation, ISim simulations and synthesis, you
should show that your design work on the FPGA board. FPGA board has certain wiring.
Only specific pins of the FPGA are connected to seven-segment displays. The input and
output ports of your design should be connected to these pins of FPGA. You can specify
which pin of the FPGA is connected to your input and output of your design before starting
synthesis. You can achieve this pin assignment either manually by entering the
corresponding pin numbers below using the graphical interface of the Xilinx ISE CAD tool
or using the .ucf file below. By looking at the manual of the Nexys3 Board, we can find
which FPGA pins are connected to which components. The following is a list of pin
connection we want and their meanings.
MY_CLK ->V10
8
EE244 Prof. Dr. Şenol Mutlu
Preparation (Prelab)
For Floating point to 11 bit binary magnitude conversion
• Write a VHDL code for this component. Use only structural or dataflow style.
• Run ISim and verify that it functions as expected by running a few test sequences.
For the 11-bit binary to BCD Conversion (or 11-bit to directly 4 digit 7-segment
conversion)
• Write a VHDL code for this component. Use only structural or dataflow style.
• Run ISim and verify that it functions as expected by running a few test sequences.
In Lab
• Use Xilinx ISE to synthesize the design based on Xilinx Spartan VI family. Use either
the given ucf file or enter manually to make pin assignment.
• Generate the bit file and upload it to your FPGA.
• On the hardware show that your design works.
• See if the LEDs show what you expect every half second as your input counts up
automatically.
Summary
• Open a new Xilinx ISE project.
• Complete VHDL definition of your design.
• Simulate your design using lsim and verify correct functionality.
• Use Xilinx ISE to synthesize your design on the FPGA board.
• Demonstrate your TA that your decoder calculates the values of the floating point
number that is updated every half second and displays correctly on the four of the7
segment LED displays on the board.
References
[1] "Nexys 3 Manual." (accessed 18 March 2021).