VHDL Lab Manual-1
VHDL Lab Manual-1
VHDL Lab Manual-1
ACTEL TRAINING
Section
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Introduction
This guide will take you through the design flow for VHDL using Actel Libero IDE version 2.3. It
explains briefly how to use the software tools and provides information about the example design.
i
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Overview
Purpose
The purpose of this lab is to become familiar with the Actel VHDL design flow. For this exercise, we
will implement a 16-bit loadable counter with an asynchronous reset and synchronous enable in an
AX500 FPGA.
Tools
For this lab, you will use the following tools:
• Libero IDE ver 2.3
• WaveFormer Lite 8.9
• ModelSim for Actel ver 5.6b
• Synplicity ver 7.2
• Designer R1-2003
Function
16 bit synchronous counter triggered with the positive edge of the clock
Pin list
ENABLE = enable count active high
RESETn = asynchronous reset of the counter active low
CLK = master clock
LOAD = parallel load of the counter active high
DATA = 16 bit data input to counter
COUNT = 16 bit counter output
LOAD
COUNT
COUNTER
DATA 16
16
Counter block diagram
2
A C T E L T R A I N I N G
V H D L L A B G U I D E
P R O G R A M
F O R L I B E R O I D E V E R 2 . 3
Section
From the File menu click New Project. The New Project dialog box appears, as shown.
3
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Save the counter description by selecting Save from the Libero IDE File menu. The counter
description will be visible in the HDL editor and on the Design Hierarchy tab as shown in the figure
below:
4
A C T E L T R A I N I N G
V H D L L A B G U I D E
P R O G R A M
F O R L I B E R O I D E V E R 2 . 3
Section
Note: if counter16 does not appear in bold font on the Design Hierarchy tab, highlight counter16,
right mouse click and select “Set As Root”.
WaveFormer Lite launches, with the port signals appearing in the Diagram window.
For additional information on using WaveFormer Lite, refer to the WaveFormer Lite User’s Guide
(wflite.pdf) which is contained in the docs folder in your Libero IDE installation path.
5
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Create the clock signal by clicking the CLK signal in the diagram window then right mouse clicking
and selecting “Signal(s) <-> Clock(s)”.
A Clock waveform will appear in the diagram window. Double click on the clock signal name in the
diagram window to open the Signal Properties window. Click the Clock Properties button to open
the “Edit Clock Parameters” window. Specify the clock parameters to generate clock signals.
Using the instructions above, create a clock signal with the following properties:
• CLK - 100 MHz • Duty Cycle: 50% (default)
• Starting Offset: 0 (default) • Invert (starts low) unchecked
Accept defaults for all other clock parameters. Click OK to close the Clock Properties dialog box.
Click Apply then OK in the Signal Properties dialog box to create the clock waveform.
Your waveforms should appear as shown in the figure on the next page.
6
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
7
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
The ModelSim for Actel VHDL Simulator will open and compile the source file and the testbench.
8
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
9
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
When the compilation completes, the simulator will run for 1 us and a Wave window will open to
display the simulation results.
Scroll in the wave window to verify the counter works correctly. Use the zoom buttons to zoom in
and out as necessary. The radix for the data and count signals can be changed to improve
readability.
Exit the simulator by selecting Quit from the File menu in the ModelSim for ACTEL 5.6b window.
Enter Yes in the Quit VSIM dialog box.
10
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
11
A C T E L T R A I N I N G P R O G R A M
Section
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
In this section, you will synthesize the counter design with Synplicity to create an EDIF netlist.
Invoke Synplify by double clicking the Synplify Synthesis button in the Libero IDE Process
Window or by right mouse clicking on counter16 in the Libero IDE Design Explorer Window and
selecting Synthesize. The Synplicity main window will open.
12
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
The "Options for Implementation: counter16_syn: hdl" dialog box will open. In the device tab,
confirm the following are set and click OK:
Click on the View Log button and scroll through the log file to answer the following questions:
Utilization
Frequency
13
A C T E L T R A I N I N G
V H D L L A B G U I D E
P R O G R A M
F O R L I B E R O I D E V E R 2 . 3
Section
When the compilation completes, the simulator will run for 1 us and a Wave window will open to
display the simulation results.
Scroll in the wave window to verify the counter works correctly. Use the zoom buttons to zoom in
and out as necessary. The radix for the data and count signals can be changed to improve
readability.
14
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
15
A C T E L T R A I N I N G
V H D L L A B G U I D E
P R O G R A M
F O R L I B E R O I D E V E R 2 . 3
Section
The next step in the design flow is to use Actel’s Designer to implement the counter design in an
AX500.
16
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
17
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
In the PinEdit window, the following color-coding scheme is used to denote pin type:
• Package pins shown in green with a black center are available for signals.
• Package pins shown in red are reserved for power and ground.
• Package pins shown in blue with a black center are for reserved pins (e.g. JTAG and Probe
pins) and for special pins such as clock inputs.
Selecting a signal pin will cause the pin outline to change from green to white. After assigning
signals to a pin, the pin outline will change to yellow indicating a fixed pin assignment.
The Axcelerator Family supports multiple I/O standards and I/Os are grouped onto I/O banks. The
I/O banks are color coded for quick identification. Colors can be customized using the Pin Editor
Color Manager if desired.
18
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Drag the Signal CLK from the Unassigned pane and drop it on the package pin labeled HCLKAP
(pin E10). Note that CLK now moves to the Assigned pane and the spreadsheet below is updated to
reflect the assignment of the CLK signal.
Drag and drop the RESETn signal to the package pin labeled CLKEP (pin V13). Note that each signal
moves to the Assigned pane and the spreadsheet is updated as it is placed.
Assign other signals to unused green pins. When you are finished placing all the pins, click File >
Close, to quit PinEdit and return to Designer. Answer Yes when prompted if you want to save
changes you made in Pin Edit.
19
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Layout
Now you will place and route the counter design – 100% automatically. To invoke the place & route
tool, click the Layout button. Accept the default settings in the Layout Options window and click
OK. If you had added timing constraints, the Timing-Driven option would be available. For designs
which were previously place & routed that have minor changes, you could select On or Fix under
the Incremental options in the Layout window.
Layout will place and route our design, and the Layout button will turn green when completed.
Timer
Next, we will do a quick timing analysis on the
counter design. Invoke Timer by clicking the Timer
icon. The Timer window will open showing a
speedometer with the max clock frequency for the
counter design. Note the frequency, temp and speed
grade. When finished, File > Close, to quit.
Select sort by Actual. In the Longest/Shortest Path(s) field, enter 10. Click OK.
Click OK in the Timing Report dialog box to accept the other default settings.
A Timing Report Dialog window will open as shown on the next page.
In the Timing Report window, select File > Save As. Name the file counter16.rpt.
20
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
21
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Back-annotate
To do timing simulation using post-layout results,
you need to generate the necessary files: post-
placement netlist and an SDF (Standard Delay
Format) file with actual timing numbers from our
place & route. Click the Back-Annotate button and
the Back-Annotate window will open.
22
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
23
A C T E L T R A I N I N G
V H D L L A B G U I D E
P R O G R A M
F O R L I B E R O I D E V E R 2 . 3
Section
Observe the waveforms in the Wave window and confirm that the counter operates correctly and
your results match the results from Sections 2 and 4. Change the radix of the signals and use the
zoom controls as necessary to match the results shown below.
24
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
Timing analysis
Using the zoom controls and the cursors in the Wave window you can measure the length of time it
takes for COUNT to change after a rising clock edge.
To make a time measurement between two edges, add cursors to the Wave window by clicking
Insert > Cursor from the Wave menu. Drag one of the cursors to a rising edge of clk and drag the
other cursor to the following transition on count. The difference between the cursors will be visible
at the bottom of the Wave window. Note the time.
1. What was the time between the rising clock edge and COUNT changing?
Close ModelSim for Actelby clicking File > Quit from the main menu. Select Yes when prompted if
you are sure you want to quit.
Close Libero IDE by clicking File > Exit from the main menu.
25
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter16 is
port (CLK, RESETn, LOAD, ENABLE: in std_logic;
DATA: in std_logic_vector(15 downto 0);
COUNT: out std_logic_vector(15 downto 0));
end counter16;
begin
end RTL;
26
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
entity stimulus is
port(
CLK : out std_logic;
RESETn : out std_logic;
LOAD : out std_logic;
ENABLE : out std_logic;
DATA : out std_logic_vector(15 downto 0);
COUNT : in std_logic_vector(15 downto 0)
);
end stimulus;
CLK_process : process
variable tb_stop_time : time := 1201 ns;
variable CLK_Offset : time := 0 ns;
variable CLK_Period : time := 10 ns;
variable CLK_MinLH : time := 0 ns;
variable CLK_MaxLH : time := 0 ns;
variable CLK_MinHL : time := 0 ns;
variable CLK_MaxHL : time := 0 ns;
variable CLK_JRise : time := 0 ns;
variable CLK_JFall : time := 0 ns;
variable CLK_Duty : time := 50 ns;
variable CLK_high : time;
variable CLK_low : time;
begin
CLK_high := CLK_Period * (CLK_Duty / ns) / 100;
CLK_low := CLK_Period - CLK_high;
CLK <= '0';
if (CLK_Offset + (CLK_MinLH - CLK_JRise/2) < 0 ns) then
assert FALSE report "Clock offset is less than 0 for CLK. This could be
caused by jitter. Increase offset to get rid of this error." severity
FAILURE;
else
wait for CLK_Offset + (CLK_MinLH - CLK_JRise/2);
while (now < tb_stop_time) loop
CLK <= '1';
wait for (CLK_high - (CLK_MaxLH + CLK_JRise/2) + (CLK_MinHL -
CLK_JFall/2));
CLK <= '0';
wait for (CLK_low - (CLK_MaxHL + CLK_JFall/2) + (CLK_MinLH -
CLK_JRise/2));
27
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
end loop;
end if;
end process;
process
begin
RESETn <= '0';
LOAD <= '0';
ENABLE <= '0';
DATA <= x"0000";
wait for 35 ns; -- Accumulated time = 35 ns
wait;
end process;
end GeneratedCode;
use work.all;
entity testbench is
end testbench;
28
A C T E L T R A I N I N G P R O G R A M
V H D L L A B G U I D E F O R L I B E R O I D E V E R 2 . 3
-- Ports are connected by matching the port names of the Test Module
begin
stimulus_0: stimulus
port map(
CLK,
RESETn,
LOAD,
ENABLE,
DATA,
COUNT
);
counter_0 : counter
port map(
CLK => CLK,
RESETn => RESETn,
LOAD => LOAD,
ENABLE => ENABLE,
DATA => DATA,
COUNT => COUNT
);
end tbGeneratedCode;
29