Friday 10 February 2012

Developing & Delivering KnowHow

Home > Knowhow > Fpga > Setting Generics/Parameters for Synthesis

Settings Generics/Parameters for Synthesis

VHDL has the powerful feature of generics, while Verilog has the option of defining parameters. Both these techniques allow parameterisable designs, that is designs that an be easily re-used in different situations. Here is the entity declaration of a parameterised counter in VHDL:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity Counter is
  generic (NBits, MaxCount : positive);
  port ( Reset, Clock, UpDn : std_logic;
         Q                  : std_logic_vector(NBits-1 downto 0));
end entity Counter;

This can be simulated - the testbench wires up the ports and sets the generic as follows

  U1: entity work.Counter
     generic map (NBits => 8, MaxCount => 100)
     port map (Reset => Reset, Clock => Clock,
               UpDn => UpDn, Q => Q);

This works fine for simulation, but of course if you try to synthesize the counter on its own, the synthesis tool does not know the value of the generics. One way round this is simply to give the generics default values - the synthesis tool will then use those defaults. If you do that, it makes sense to re-write the generic declaration so that each generic can be given a different default value, i.e.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity Counter is
  generic (NBits : positive := 8;
           MaxCount : positive := 255);
  port ( Reset, Clock, UpDn : std_logic;
         Q                  : std_logic_vector(NBits-1 downto 0));
end entity Counter;

To go further than this, and override the generics from a synthesis tool, you'll have use tool specific features. The rest of this page shows some examples. Note that because each tool has to analyze the code first to identify the generics, it is a good plan to put default values as shown above so that the code will definitely synthesize even without overriding the generic values.

Setting Generics/Parameters in Actel Libero

Actel Libero uses Synplify as its synthesis tool, so see the section below about Synplify

Setting Generics/Parameters in Altera Quartus II

Load in your design, and analyze it by clicking the button Start Analysis and Synthesis.

Now use the menu option Assignments > Settings... and click on Default Parameters. You can now set the generics - see the following screen shot:


Of course you can also use Tcl

  set_parameter -name NBits 4
  set_parameter -name MaxCount 9

Setting Generics/Parameters in Lattice ispLever

Lattice ispLever uses Synplify as its synthesis tool, so see the section below about Synplify

Setting Generics/Parameters in Mentor Precision RTL

Mentor Precision RTL can set generics, but it must be done from a Tcl command. The Tcl command has to set a "list of lists" as follows:

setup_design -overrides { {NBits 4} {Depth 16} }

Note the use of curly brackets to enclose each list. This command can be typed at the console of the Precision GUI, or put in a Tcl script.

Setting Generics/Parameters in Synplicity Synplify

Synplify can set generics from the menu Options > Configure VHDL Compiler. This menu has an Extract Generics button which will identify the generics and add them to the form, so you can fill in the values. Here is a screenshot.

Alternatively with the magic of Tcl:

set_option -hdl_param -set nbits 4
set_option -hdl_param -set maxcount 9

Setting Generics/Parameters in Xilinx ISE

In Xilinx ISE, set up your project, import your code, and synthesise it. To set generics, you'll need to make sure that you are viewing Advanced properties in the synthesis properties.

To do this, carry out the following steps:

  1. Make sure set Sources For: to Implementation
  2. Highlight your design in the Sources windows
  3. Right-click on Synthesize - XST and select Properties
  4. Highlight the Category Synthesis Options in the left of the form
  5. Set the Properties Display Level to Advanced

Now you will be able to type in your generic/parameter settings - see the following screenshot.

The syntax is a space separate list of assignments such as NBits=4.

In Xilinx Tcl, the following command has been created:

project set "Generics, Parameters" "NBits=4 MaxCount=9" -process "Synthesize - XST"

Back to top

Privacy Policy Site Map Contact Us