Professional Documents
Culture Documents
1. Create a new ISE project in order to create the new source VHDL files that
will be necessary in the following exercises
Exercise 1
1. Copy the prescaler.vhd and pack_pract.vhd files from the tutorial, and add
them to the project, since they will be used in the next step.
entity pulse_4 is
port(
clk,rst: in std_logic;
width: in std_logic_vector(3 downto 0);
strt: in std_logic;
rdy: out std_logic;
e: in std_logic;
o: out std_logic );
end entity;
3. Add at the botton of the pulse.vhd the testbench tb_pulse_4 which attaches
an instance of the pulse_4 module (dut) with a prescaler instance (ps0)
configured with NPS=5.
-----------------------------------------
--synthesis translate_off
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity tb_pulse_4 is
end entity;
process begin
dut_width<=(others=>'X'); dut_strt<='0';
wait until rst='1';
wait until rst='0';
wait for 5*TCLK;
dut_width<=(others=>'X'); dut_strt<='0';
wait;
end process;
Among the ps0 and dut instances, the testbench contains a process which
changes the width(3:0) from “0000” to “1111” (from 0 to 15) , asserting strt=’1’
and incrementing width(3:0) when rdy=’1’, in order to simulate all the possible
pulse-widths.
4. Simulate the tb_pulse_4 for a long time in order to check that the output o is
working as expected (pulse-width=width*5) for every width(3:0) possible
combination.
Exercise 2
1. Create a new pulse.vhd file, and copy and paste the content from
pulse_4.vhd to pulse.vhd.
2. The pulse_4 module declared the input port width(3:0) as a 4-bit port. Edit
pulse.vhd and rename the entity name as pulse, and add a generic (named
NBIT) to pulse in order to parametrize the number of bits of the pulse-width.
The pulse module should work as expected with an arbitrary number NBIT.
Write the modifications done in the report and justify them.
4. Simulate the tb_pulse for a long time in order to check that the output o is
working as expected (pulse-width=width*NPS=width*5) for every width(5:0)
possible combination.
Exercise 3
1. Create a new architecture beh2 for the pulse entity. This architecture joins
the fsm and counter processes into a single process called fsm_counter.
The fsm sentences are identical. The counter sentences are very similar, but
the cnt is a variable instead of a signal.
fsm_counter: process
subtype T_CNT is unsigned(width'range);
variable cnt: T_CNT;
begin
wait until rising_edge(clk);
case state is --fsm (same sentences as in pulse-beh1)
when IDLE=>
...
when START=>
...
when BUSY=>
...
end case;
if rst='1' then ... end if;
2 Simulate the beh2 in the tb_pulse. Check if the simulation results are the
same as for the beh1 architecture? Justify the answer
3 Create a new architecture beh3 for the pulse entity, which is very similar to
the beh2 architecture, but reversing the set of fsm and counter sentences.
fsm_counter: process
subtype T_CNT is unsigned(width'range);
variable cnt: T_CNT;
begin
wait until rising_edge(clk);
case state is --counter
when IDLE=>
if strt='1' then ...; end if;
when others=>
if e='1' then ...; end if;
end case;
4 Simulate the beh3 in the tb_pulse. Check if the simulation results are the
same as for the beh1 architecture? Justify the answer
5 Modify the process fsm_counter (beh2 or beh3, in the different one) in order
to behave as the beh1 architecture (do not change the cnt from variable to
signal, and maintain separately the assignation sentences of the cnt variable
form the state signal). Report the changes done and justity them.
Exercise 4
1. Create a top.vhd file, in order to synthetize the pulse module for the LX9
Microboard. The top module should contain a pulse circuit attached to the
switches or buttons of the board, one of the leds. The ps_o is assigned to ‘1’
(instead to the output of a prescaler) in order to test only the synthesis of the
pulse.
entity top is
port(
clk,rst: in std_logic;
switches: in std_logic_vector(3 downto 0);
led: out std_logic );
end entity;
ps_o<='1';
-- ps0: entity work.prescaler(a1d) generic map(10e+6) port map(
-- clk=>clk, rst=>rst, o=>ps_o );
end architecture;
2. Check the synthesis results of beh1, beh2 and beh3. Justify the results
3. Create a new architecture beh1b for pulse, which is quite similar to beh1 but
using integer type for the signal cnt, instead of unsigned type.
4. Check the simulation results when compared with beh1. Justify the results
5. Check the synthesis result when compared with beh1. Justify the results