VIVADOFLOW
VIVADOFLOW
EE4218
EMBEDDED HARDWARE SYSTEMS
NOTE:
Save all your work in D:\MyWork if you are using a lab PC. Any files saved on the hard drive of the computers in the lab will be cleared
on a daily basis.
After that, there is one assignment specified in Section 5 and some notes in Section 6.
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 1 Page 2 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 1 Page 3 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 2 Page 4 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 2 Page 5 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 3 Page 6 of 20
Behavioural simulation is performed before actual design implementation on hardware to verify that the logic created is correct.
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 3 Page 7 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 3 Page 8 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 3 Page 9 of 20
This section illustrates using text files for giving stimuli for the test bench. This enables fast verification of complex designs where a number of cases
have to be tested.
stim_proc: process
file inputfile : TEXT open READ_MODE is "ip.txt";
file outputfile : TEXT open WRITE_MODE is "op.txt";
variable Lr, Lw : line;
variable ab : std_logic_vector(1 downto 0);
begin
while not endfile(inputfile) loop
wait for 100 ns;
readline (inputfile, Lr);
read(Lr, ab);
a <= ab(1);
b <= ab(0);
wait for 1 ns;
write(Lw, string'(" ab = "));
write(Lw, ab);
write(Lw, string'(" sum = "));
write(Lw, sum);
write(Lw, string'(" carry = "));
write(Lw, carry);
writeline(outputfile, Lw);
end loop;
file_close(inputfile);
file_close(outputfile);
wait;
end process;
3. Create a text file ip.txt using a text editor (eg: Notepad) with the
following contents, and save it in your project folder as ip.txt.
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 3 Page 10 of 20
This section will show how to write a VHDL Test Bench for a clocked circuit, illustrated using a positive edge triggered D Flip-Flop
entity d_flip_flop is
Port ( clk : in STD_LOGIC;
D : in STD_LOGIC;
Q : out STD_LOGIC);
end d_flip_flop;
begin
process(clk)
begin
if clk'event and clk = '1' then
Q <= D;
end if;
end process;
end behavioral;
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 3 Page 11 of 20
use IEEE.STD_LOGIC_ARITH.ALL
use IEEE.STD_LOGIC_UNSIGNED.ALL;
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 4 Page 12 of 20
This section describes how to implement the design made in section 1 on an actual FPGA hardware.
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 4 Page 13 of 20
# Mapping A to SW<0>
set_property LOC F22 [get_ports A]
set_property IOSTANDARD LVCMOS18
[get_ports A]
# Mapping B to SW<1>
set_property LOC G22 [get_ports B]
set_property IOSTANDARD LVCMOS18
[get_ports B]
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 4 Page 14 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 4 Page 15 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 4 Page 16 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 4 Page 17 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 5 Page 18 of 20
5. Assignments
[Hint: The frequency of the oscillator on the FPGA board is 100MHz. You will have to implement some kind of clock
scaling. An apparent clock rate in the order of 1s is fine (i.e., need not be precisely 1s). ]
An automated take-off permission system is to be implemented in De Morgan’s Airport, where one runway is dedicated for
take-offs. The airport handles 8 different types of planes (numbered 0-7), broadly classified into two: narrow-body and
wide-body; usually referred to as light and heavy respectively by the ATC. Plane types numbered 1, 3 and 7 are in the heavy
category while the rest are light. A light jet taking off immediately behind a heavy jet is risky due to the wake turbulence left
behind by the heavy jet.
A plane requests take off by pressing a REQ push-button after setting its TYPE_NUMBER on a 3-bit DIP switch. The request
is GRANTED under the following 3 circumstances
1) The request is from a heavy jet
2) The request is from a light jet, and the previous jet which took off is also light
3) The request is from a light jet, the previous jet which took off is heavy, and 10 seconds have passed since the
previous jet was granted permission to take off
and is DENIED otherwise.
Results (GRANTED/DENIED) are shown using separate LEDs, for exactly 3 seconds (i.e., exactly 3 cycles of the divided clock)
immediately following the request, during which take-off requests (i.e pressing the REQ button) will have no effect.
[Hint : You will need to implement one or more counters, which should be used as component(s) controlled by a controller
FSM ]
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 6 Page 19 of 20
6. Appendix
###########################################
# Global Clock, which is 100MHz
###########################################
set_property PACKAGE_PIN Y9 [get_ports {GCLK}]
###########################################
# Buttons
###########################################
#Center
set_property PACKAGE_PIN P16 [get_ports {BTNC}]
#Down
set_property PACKAGE_PIN R16 [get_ports {BTND}]
#Left
set_property PACKAGE_PIN N15 [get_ports {BTNL}]
#Right
set_property PACKAGE_PIN R18 [get_ports {BTNR}]
#Up
set_property PACKAGE_PIN T18 [get_ports {BTNU}]
###########################################
# LEDs
###########################################
set_property PACKAGE_PIN T22 [get_ports {LD0}]
set_property PACKAGE_PIN T21 [get_ports {LD1}]
set_property PACKAGE_PIN U22 [get_ports {LD2}]
set_property PACKAGE_PIN U21 [get_ports {LD3}]
set_property PACKAGE_PIN V22 [get_ports {LD4}]
set_property PACKAGE_PIN W22 [get_ports {LD5}]
set_property PACKAGE_PIN U19 [get_ports {LD6}]
set_property PACKAGE_PIN U14 [get_ports {LD7}]
###########################################
# DIP Switches
###########################################
set_property PACKAGE_PIN F22 [get_ports {SW0}]
set_property PACKAGE_PIN G22 [get_ports {SW1}]
set_property PACKAGE_PIN H22 [get_ports {SW2}]
set_property PACKAGE_PIN F21 [get_ports {SW3}]
set_property PACKAGE_PIN H19 [get_ports {SW4}]
set_property PACKAGE_PIN H18 [get_ports {SW5}]
set_property PACKAGE_PIN H17 [get_ports {SW6}]
set_property PACKAGE_PIN M15 [get_ports {SW7}]
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1
SECTION 6 Page 20 of 20
Virtual Easter Egg: Original Egg a nd Ma nual Create d by .©LLC i n Aug ust 201 1