3
votes

Im trying to simulate a Xilinx GTXE2 transceiver with GHDL. In GTXE2_CHANNEL.vhd I got an error that 'std_logic_arith' can't be found in library 'ieee'.

First off all, here is my machine setup:

So question 1: Is this package included in GHDL?

I tried to change the VHDL standard to VHDL-2008 --std=08, but this option is not recognized by ghdl, so I'm currently compiling with VHDL-2002. But nothing changed.

I also tried to include the IEEE sources manually from Xilinx' vhdl source folder C:\Xilinx\14.7\ISE_DS \ISE\vhdl\src\ieee. But when I compile std_logic_arith it complains about a missing std_logic_1164, which is normally found. In addition to this, there is is a issue with the FOREIGN attribute in std_logic_1164.

So this is my file list/compile order to compile (a modified version of Xilinx' *.prj-files):

# board and device configuration
#vhdl poc       "tb/common/my_config_KC705.vhdl"

# IEEE packages
#xilinx ieee    "ieee/std_logic_1164.vhd"
#xilinx ieee    "ieee/std_logic_arith.vhd"

# Xilinx Packages and Primitives
xilinx unisim   "unisims/unisim_VCOMP.vhd"
xilinx unisim   "unisims/unisim_VPKG.vhd"
xilinx work     "unisims/primitive/FD.vhd"
xilinx work     "unisims/primitive/BUFG.vhd"
xilinx work     "unisims/primitive/BUFR.vhd"
xilinx work     "unisims/secureip/GTXE2_CHANNEL.vhd"

This list gets translated into GHDL commands, which were executed in a temp directory:

C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe -a --std=02 -P. --work=poc "D:\VHDL\git\SATAController\lib\PoC\tb\common\my_config_KC705.vhdl"
GHDL Messages:
  D:\VHDL\git\SATAController\lib\PoC\tb\common\my_config_KC705.vhdl:52:14:warning: package "my_config" does not require a body
C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe -a --std=02 -P. --work=unisim "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\unisim_VCOMP.vhd"
C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe -a --std=02 -P. --work=unisim "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\unisim_VPKG.vhd"
C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe -a --std=02 -P. --work=work "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\primitive\FD.vhd"
C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe -a --std=02 -P. --work=work "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\primitive\BUFG.vhd"
C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe -a --std=02 -P. --work=work "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\primitive\BUFR.vhd"
C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe -a --std=02 -P. --work=work "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\secureip\GTXE2_CHANNEL.vhd"
GHDL Messages:
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\secureip\GTXE2_CHANNEL.vhd:34:10: primary unit "std_logic_arith" not found in library "ieee"

And finally the FOREIGN attribute errors in ieee.std_logic_1164:

PS D:\VHDL\git\SATAController\lib\PoC\temp\ghdl> & 'C:\Program Files (x86)\GHDL\0.31\bin\ghdl.exe' -a --std=02 '-P.' --work=ieee 'C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd'
GHDL Messages:
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:211:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:212:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:213:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:214:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:215:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:216:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:218:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:219:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:220:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:221:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:223:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:224:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:225:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:227:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:228:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:229:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:231:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:232:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:233:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:235:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:236:15: value of 'FOREIGN attribute does not begin with VHPIDIRECT
  C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\ieee\std_logic_arith.vhd:238:15: 'FOREIGN allowed only for architectures and subprograms

Question 2: How can I compile ieee.std_logic_1164?

Everyone with an installed GHDL environment can test this example. The my_config_KC705.vhdl is not needed by the Xilinx libraries.


What is the purpose of this?

  • iSim simulation is very slow -> circa 15 ns sim-time is computed in 1 second cpu-time; 100 us -> 40 minutes of waiting
  • iSim uses circa 2.6 GiB of main memory - may be GHDL is thriftier
  • xSim has some complains about our VHDL library - so iSim is currently option #1
  • I previously tested GHDL with Xilinx primitives and it worked, so the next challenge is to simulate a secureip component :)
  • if I find enough time, I'll also try QuestaSim
1

1 Answers

6
votes

Yes this package is included with ghdl

In the ghdl manual or the man page you'd find that you can select --ieee=synopsys or --ieee=mentoras a command line option for the analysis and elaborate commands.

Looking in your library directories:

david_koontz@Macbook: ls /opt/ghdl/ghdl_mcode/libraries/synopsys
std_logic_arith.vhdl      std_logic_misc.vhdl       std_logic_textio.vhdl
std_logic_misc-body.vhdl  std_logic_signed.vhdl     std_logic_unsigned.vhdl

david_koontz@Macbook: ls /opt/ghdl/ghdl_mcode/libraries/mentor
std_logic_arith.vhdl       std_logic_arith_body.vhdl

You'd find package std_logic_arith.

Because there are conflicting declarations you can find it necessary to also use the -fexplicit command line option during analysis and elaboration.

Options given during analysis (-a) or elaboration (-e) follow the commands.

How can I compile ieee.std_logic_1164?

You should not need to analyze package ieee.std_logic_1164, they are pre-analyzed. Try the above first (more commonly synopsys). Notice neither the mentor nor the synopsys packages contain any FOREIGN attribute. The FOREIGN attribute decorates a subprogram declaration (function) that is implemented in a foreign programming language.

info ghdl or ghdl.html (the GHDL guide) section 5 GHDL Implementation of VHDL (the subsection Using vendor libraries, which gives a small bit of advice on dealing with unisim). There's also a section Interfacing to other languages which deals with how to use the FOREIGN attribute.

Also see 3.10 IEEE library pitfalls, explaining issues with non-IEEE 'standard' libraries, Tristan's non-native English spelling errors aside.

And if you really want to analyze IEEE libraries yourself read through the entire GHDL guide first. It involves several command line options that should be understood first. The Windows ghdl distribution is based on a just-in-time code generation system (mcode) which analyzes code into library files (ending with the .cf suffix) and reanalyzes the very same source code found in your distribution's libraries during elaboration.

I've successfully analyzed and used unisim libraries on an mcode version of ghdl under OS X without tinkering with the IEEE libraries.

You'll find that ghdl isn't the thriftiest in terms of memory utilization nor the fastest.

There's also a Ghdl-discuss mail list you can join. ghdl is being actively developed on Sourceforge. See ghdl-updates. ghdl-0.32 should be released this year (hopefully) and will have increased -2008 support as well as a myriad of fixes.

The Windows release will likely be a new interpreted version supplanting the mcode version (which is a 32 bit binary). All the development work is being done solely by Tristan Gingold currently. He's also implementing an all around LLVM backend version which may hold promise of better performance on Windows.

On the FOREIGN attributes

I found I had several Xilinx std_logic_arith package source files that contained the FOREIGN attributes, albeit with line number off by four.

The combination of attributes along and compiler pragmas, e.g.:

  -- pragma map_to_operator MULT_TC_OP
  -- pragma type_function MULT_SIGNED_ARG
  -- pragma return_port_name Z

Are used to allow accelerated function execution. The foreign language libraries aren't available to ghdl, the mcode (Windows) version can't use them in any event. Also the requirement found in 5.8.1 Foreign declarations of the GHDL guide that the FOREIGN attribute's string value contain be prefixed with "VHPIDIRECT " is a restriction enabling linking in the gcc version where the ABI for those libraries if found wouldn't be guaranteed to be compatible anyway.

You could simply comment out the attributes found by the error messages. Thhere is no possibility for accelerated execution, which would require the gcc version of ghdl at present in any event.

There is no performance advantage over using ghdl's Synopsys packages.