To import a Verilog-AMS module with explicitly declared analog ports into VHDL, do the following:
- Use the
xmvlogcompiler to compile the Verilog-AMS source code for the module that you want to import. - Use the
xmshellcommand to generate model import shells for the module you want to import. - In the source VHDL file, specify the architecture name to be used for entity.
If you specified the-viewoption for thexmshellutility in the previous step, use that name for the architecture. If you did not specify the-viewoption, useverilogfor the architecture name. - Add a clause in the source VHDL file to specify the package.
If you specified the-packageoption for the xmshell command in step 2, use a clause such asuse library. packagename.all;If you did not specify the-packageoption, use a clause such asuse library. HDLModels.all; - Compile all VHDL source code using
xmvhdl. - Elaborate the design using the
xmelabelaborator.
Example
To import the Verilog-AMS module in the file comparator_analog.v, do the following:
|
- Compile the Verilog-AMS source code.
xmvlog -ams -use5x comparator_analog.v
If your working library isamsLib, this command compiles the module comparator intoamslib.comparator:module. The-use5xoption is used because 5x configurations are used later to elaborate the design. -
Generate model import shells using
xmshell.The argument to thexmshellcommand is the Library.Cell:View specification for the compiled module.xmshell -import verilog -ams -into vhdl -generic amslib.comparator:moduleThis command generates two shells. The digital Verilog shell, generated in the filecomparator.vds, looks like this:module comparator(cout, inp, inm);output cout ;input inp ;input inm ;
parameter td =1.000000e09, tr =1.000000e-09, tf =1.000000e-09,i =5, j =5;
comparator #(.td(td), .tr(tr), .tf(tf))(* integer view_binding="module"; *) comparator1(.cout(cout), .inp(inp), .inm(inm));endmoduleThis module has an instance
comparator1of the same cell namecomparator. It also has a view binding attribute module, which binds the instance to theamslib.comparator:moduleview. The source that is compiled into theamslib.comparator:moduleview is a Verilog-AMS description. This switches the elaborator into using the Verilog-AMS language.
The VHDL shell, generated in a file calledcomparator.vhd, looks like this:library ieee;use ieee.std_logic_1164.all;entity comparator isgeneric (td: real :=1.000000e-09;tr: real :=1.000000e-09;tf: real :=1.000000e-09,i: integer :=5,j: integer :=5);port (cout: out std_logic;inp: in std_logic;inm: in std_logic);end comparator;
architecture verilog of comparator isattribute foreign of verilog:architecture is "VERILOG(event)amslib.comparator:digital_shell";beginend;Notice that the name of the architecture in the shell defaults to verilog.
The architectureveriloghas a foreign attributeamslib.comparator:digital_shell, which tells the elaborator that the architecture is actually a shell for the Verilog module compiled into the viewamslib.comparator:digital_shell. This attribute causes the elaborator to switch from the VHDL language into digital Verilog.
Thexmshellutility also generates the following VHDL component declaration in the filecomparator_comp.vhd:library ieee;use ieee.std_logic_1164.all;
packageHDLModelsis
component comparatorgeneric (td: real :=1.000000e-09;tr: real :=1.000000e-09;tf: real :=1.000000e-09,i: integer :=5,j: integer :=5);
port (cout: out std_logic;inp: in std_logic;inm: in std_logic);end component;
end HDLModels;In Verilog-AMS, identifiers are case sensitive. By default, mixed-case and uppercase identifiers in Verilog-AMS are escaped in VHDL shells. For example, if the Verilog-AMS module isVlog, this identifier appears in the VHDL shell as\Vlog\. Use the-noescapeoption if you want the Verilog-AMS module name to be matched exactly in the shell. Do not set theCDS_ALT_NMPenvironment variable, which is not supported. -
In the source VHDL file, specify that architecture
verilogis to be used for entitycomparator(because this example uses the default value). Add theuseclause (using the default version). With these changes, the source VHDL file for this example looks like:-- top.vhdlibrary ieee;use ieee.std_logic_1164.all;use work.HDLModels.all;entity top isend top;
architecture testbench of top issignal in1, in2, output : std_logic;forall: comparator use entity work.comparator(verilog);begin
test: process beginin1 <='0';in2 <='0';wait;end process;
comparator12: comparator port map(output, in1, in2);
end;The
for allstatement binds the comparator instance to the design unit in amslib.comparator:verilog, which is a compiled version of the architectureverilog. - Compile the top-level VHDL file (
top.vhd) and the VHDL package generated earlier byxmshell.
xmvhdl -v93 comparator_comp.vhd top.vhd -use5x - Elaborate the design with
xmelab. Assuming that the corresponding 5x configuration isamslib.top:configand that theconnectrulesmodule is compiled intoamslib.AMSconnect:module, you can elaborate the design with a command such asxmelab amslib.top:config AMSconnect -discipline logicIn this example, using the-discipline logicoption sets the discipline of the shell ports to logic.
