Can you import a vhdl package in a systemverilog file?
Let's say I have a VHDL package:
library ieee;
use ieee.std_logic_1164.all;
-- FILE: my_pkg.vhd
package my_pkg is
type type1 is record
sig2 : std_logic;
vec1 : std_logic_vector(7 downto 0);
end record;
end package;
Can I use it in a System Verilog file like this:
// FILE: testbench.sv
import my_pkg::*;
module testbench;
type1 sigtype1;
initial begin
sigtype1.sig2 = 1'b1;
sigtype1.vec1 = 8'hA;
$finish(2);
end
endmodule
would this generate a syntax error or would it imply the equivalent systemverilog package:
// FILE: my_pkg.sv
package my_pkg;
typedef struct packed {
bit sig2;
bit [7:0] vec1;
};
endpackage;
Here's my simulator output:
C:\questasim64_2020.4\win64\vcom.exe -2002 -l simout.vhdl.log
-work work ./hdl/my_pkg.vhd
QuestaSim-64 vcom 2020.4 Compiler 2020.10 Oct 13 2020
Start time: 11:39:52 on Jan 19,2022
vcom -2002 -l simout.vhdl.log -work work ./hdl/my_pkg.vhd
-- Loading package STANDARD
-- Loading package TEXTIO
-- Loading package std_logic_1164
-- Compiling package my_pkg
End time: 11:39:52 on Jan 19,2022, Elapsed time: 0:00:00
Errors: 0, Warnings: 0
ok
C:\questasim64_2020.4\win64\vlog.exe -work work -l simout.vlog.log
./hdl/testbench.sv
QuestaSim-64 vlog 2020.4 Compiler 2020.10 Oct 13 2020
Start time: 11:39:52 on Jan 19,2022
vlog -work work -l simout.vlog.log ./hdl/testbench.sv
** Error:
C:/Users/wpmoore/Desktop/collins/sandbox/sandbox.try1/hdl/testbench.sv(
2): (vlog-13006) Could not find the package (my_pkg). Design read will
continue, but expect a cascade of errors after this failure.
Furthermore if you experience a vopt-7 error immediately before this
error then please check the package names or the library search paths
on the command line.
End time: 11:39:52 on Jan 19,2022, Elapsed time: 0:00:00
Errors: 1, Warnings: 0
I am only aware of one tool, Modelsim/Questa that allows sharing of packages between SystemVerilog and VHDL, and only for the sharing of data types/typedefs across these languages. The most useful purpose being connecting ports between mixed language instances with a shared data type.
Look for the -mixedsvvh switch in the Questa User Manual.
Short answer 'No'.
If you can get your simulator to compile a VHDL module you may well be able to instantiate it in a Verilog / SV module, and vice versa. Although you are mixing languages here it is fairly unambiguous how the simulator should connect these. However because they are different languages it is not defined how code written in both should interact with each other. Certainly I would not expect any VHDL packages to be usable in Verilog/SV. Can you migrate the contents to SV? Or perhaps create a tool to generate two files equivalent VHDL and SV?
Related
I am getting this vsim error when I'm trying to use an Intel On-Chip Flash IP generated by Quartus. There's an altera_onchip_flash_block.v file in the submodules/rtl folder but it's only hex numbers in it so it's not compilable by ModelSim.
# Time: 0 ps Iteration: 0 Instance: /ufm_testbench/ufm_inst/flash/onchip_flash_0 File: ../../FFB900_UFM/verilog/altera_onchip_flash.v Line: 309
# Searched libraries:
(all my libraries)
The altera_onchip_flash_block gets instantiated in the altera_onchip_flash.v as seen above.
When I'm only compiling the IP it's working but when I'm using it from my Top-Level testbench I always get this error. I am using VHDL in all my files, except the verilog files generated by quartus.
Any help is appreciated.
As you already realized, this is a precompiled IP-Core. Normally these precompiled IP-Cores come with files for simulation.
This pdf includes a step-by-step tutorial to instantiate the IP-Core and generate simulation files with Quartus (on page 12 of 36 or section 4-2).
thanks for reading my question.
If i generate a component with the "IP Catalog" in Vivado (2016.2), Vivado creates the following Folder(s) in my Project (I generated a counter for this example):
<proj>/ip_user_files/ip/c_counter_binary/c_counter_binary_0.veo
/c_counter_binary_0.vho
/c_counter_binary_0_stub.v
/c_counter_binary_0_stub.vhdl
<proj>/ip_user_files/ipstatic/c_addsub_v12_0_9/hdl/c_addsub_v12_0.vhd
/c_addsub_v12_0_vh_rfs.vhd
/...(and a few more)
<proj>/ip_user_files/sim_scripts/c_counter_binary_0/modelsim/compile.do
/c_counter_binary_0.sh
/simulate.do
/wave.do
(I think the rest is irrelevant for my question)
I want to simulate the counter in ModelSim. So I think I have to run the "c_counter_binary_0.sh" to generate the necessary Simulation Librarys for ModelSim.
Whats a good way to compile these Librarys using Windows 7?
I'm trying to simulate the counter in ModelSim for a few days now, but I really have no idea left what I can try next.
Since it's a common think to do (isn't it?), i can't understand why I wasn't able to find any documentation.
Things I've tried:
Run c_counter_binary_0.sh with the ModelSim Transcript Console:
do c_counter_binary_0.sh
# ** Error: invalid command name "#!/bin/bash"
Run the file compile.do in ModelSim Transcript Console:
do compile.do
# ** Warning: (vlib-34) Library already exists at "work".
#
# Model Technology ModelSim PE vmap 10.4a Lib Mapping Utility 2015.03 Apr 7 2015
# vmap -modelsim_quiet xbip_utils_v3_0_6 msim/xbip_utils_v3_0_6
# Modifying C:/Xilinx/wkdir/lab_counter/lab_counter.ip_user_files/sim_scripts/c_counter_binary_0/modelsim/lab_counter.mpf
# Model Technology ModelSim PE vmap 10.4a Lib Mapping Utility 2015.03 Apr 7 2015
# vmap -modelsim_quiet c_reg_fd_v12_0_2 msim/c_reg_fd_v12_0_2
# Modifying C:/Xilinx/wkdir/lab_counter/lab_counter.ip_user_files/sim_scripts/c_counter_binary_0/modelsim/lab_counter.mpf
(...and so on...)
# Model Technology ModelSim PE Student Edition vcom 10.4a Compiler 2015.03 Apr 7 2015
# Start time: 00:59:17 on Oct 31,2016
# vcom -reportprogress 300 -work xbip_utils_v3_0_6 -64 -93 ../../../ipstatic/xbip_utils_v3_0_6/hdl/xbip_utils_v3_0_vh_rfs.vhd
# -- Loading package STANDARD
# End time: 00:59:18 on Oct 31,2016, Elapsed time: 0:00:01
# Errors: 0, Warnings: 1
# ** Warning: (vcom-159) Mode option -64 is not supported in this context and will be ignored.
#
(...and so on...all with no error...)
#
# Model Technology ModelSim PE Student Edition vcom 10.4a Compiler 2015.03 Apr 7 2015
# Start time: 00:59:28 on Oct 31,2016
# vcom -reportprogress 300 -work xil_defaultlib -64 -93 ../../../../lab_counter.srcs/sources_1/ip/c_counter_binary_0/sim/c_counter_binary_0.vhd
# -- Loading package STANDARD
# -- Loading package TEXTIO
# -- Loading package std_logic_1164
# -- Loading package NUMERIC_STD
# -- Compiling entity c_counter_binary_0
# -- Compiling architecture c_counter_binary_0_arch of c_counter_binary_0
# End time: 00:59:29 on Oct 31,2016, Elapsed time: 0:00:01
# Errors: 0, Warnings: 1
But I end up with empty librarys except:
xil_defaultlib --> [Entity]c_counter_binary_0 --> [Architecture]c_counter_binary_0_arch
If i try to run the Simulation with the generated Librarys:
vsim work.top_tb
# vsim
# Start time: 01:08:10 on Oct 31,2016
# Loading std.standard
# Loading std.textio(body)
# Loading ieee.std_logic_1164(body)
# Loading work.top_tb(tb)
# Loading work.top(rtl)
# Loading ieee.numeric_std(body)
# Loading work.c_counter_binary_0(c_counter_binary_0_arch)
# Loading ieee.std_logic_arith(body)
# Loading ieee.std_logic_unsigned(body)
# Loading unisim.muxcy(muxcy_v)
# Loading unisim.xorcy(xorcy_v)
# ** Fatal: Attempting to load -nodebug design unit.
# Nodebug designs are not supported.
#
# Time: 0 ns Iteration: 0 Instance: /top_tb File: C:/Xilinx/wkdir/lab_counter/lab_counter.srcs/sim_1/imports/vhdl/tb_top.vhd Line: UNKNOWN
# FATAL ERROR while loading design
# Error loading design
Installed Cygwin and run c_counter_binary_0.sh
$ ./c_counter_binary_0.sh
./c_counter_binary_0.sh: line 1: uFEFF#!/bin/bash: No such file or directory
./c_counter_binary_0.sh: line 32: $'\r': command not found
./c_counter_binary_0.sh: line 33: $'\r': command not found
c_counter_binary_0.sh - Script generated by export_simulation (Vivado v2016.2 (64-bit)-id)
./c_counter_binary_0.sh: line 36: $'\r': command not found
./c_counter_binary_0.sh: line 38: syntax error near unexpected token `$'\r''
'/c_counter_binary_0.sh: line 38: `run()
Looks like the student version is simply not able to load protected devices...
A friend of mine who is really into FPGAs took a look at my library mappings etc. and everything was ok... So he tested the design with a full Modelsim License...
ModelSim PE Student Edition:
...
# Loading unisim.xorcy(xorcy_v)
# ** Fatal: Attempting to load -nodebug design unit.
# Nodebug designs are not supported.
#
...
Modelsim with a full-license key:
...
# Loading unisim.xorcy(xorcy_v)
# ** Warning: (vsim-8684) No drivers exist on out port /top_tb
/DUT/c_counter_binary_0_1/U0/<protected>/<protected>/<protected>
/<protected>, and its initial value is not used.
#
...
I extended my testbench scripts with Active-HDL support. Active-HDL behaves mostly like QuestaSim or ModelSim, even the command line arguments are similar.
I have an Active-HDL Student Edition and Active-HDL Lattice Edition from Lattice Diamond 3.7 installed. I'm currently using the latter one, because this version is shipped with a full vsimsa (vsim standalone) environment.
My scripts processes the selected testbench in 3 steps:
It creates all necessary VHDL libraries with vlib.exe (alib)
It compiles all VHDL source files with vcom.exe (acom)
It launches vsimsa.exe with a TCL command:
asim -lib test arith_prng_tb; run -all; bye
The simulation runs and shows a good output:
VHDL/Verilog/EDIF/SystemC Simulator 10.2.3312.5682.02
(c) 1997-2015 Aldec, Inc. All rights reserved.
VSIMSA: Configuration files: `D:\git\PoC\temp\activehdl\library.cfg', `D:\Lattice\diamond\3.7_x64\active-hdl\BIN\vsimsa.cfg'
Welcome to VSIMSA!
This message was printed from `startup.do' macro file.
asim -lib test arith_prng_tb; run -all; bye
VSIM: Selected architecture `tb' of entity `arith_prng_tb' from library `test'.
....
....
KERNEL: ASDB file was created in location D:\git\PoC\temp\activehdl\wave.asdb
========================================
POC TESTBENCH REPORT
========================================
Tests 2
-1: Default test
0: Test setup for BITS=8; SEED=0x12
Overall
Assertions 256
failed 0
Processes 3
active 0
Runtime 2.6 us
========================================
SIMULATION RESULT = PASSED
========================================
Simulation has finished. There are no more test vectors to simulate.
As one can see, asim creates a wave.asdb file, which can be loaded from the GUI, but it's empty (no signals).
So my questions are:
How can I trace signals into that waveform database file?
How can I open this file from command line in the GUI?
trace or log command must be used to specify signals to be logged into the simulation database (note these commands are supported in different situations, depending on how you invoke Active HDL).
For example:
log -ports UUT/*
Traces all ports declared in the UUT design region.
log -mem -rec UUT/*
Traces recursively all signals (including Verilog memories) declared in the UUT design region.
log CLK RST
Traces the CLK and RST signals from the current region
You may need to change your compilation optimization options in order to trace all signals of interest.
To answer your second question, you can use the wave command to add waveforms to the current waveform display.
Seems a lot more convenient than typing each one individually every time.
This link was very unclear to me:
http://sagekingthegreat.blogspot.com/2013/08/how-to-execute-tcl-script-in-xilinx.html
Sample Code:
#Sample Script:
restart
run 20 ns
dump
run 20 ns
dump
quit
I'm just looking for the Tcl command to enter in the Console Window of the Simulation GUI to run these commands (entered in Notepad ++, and saved as a .tcl file in my project folder)
Just pass your tcl file as a parametet to your compiled/fused testbench via -tclbatch <filename>.
.\fifo_tb.exe -tclbatch fifo_tb.tcl -gui
-gui opens the testbench in GUI mode with iSim connected to the testbench executable.
To see all supported options of a testbench, run the testbench executable with -h.
To show all supported TCL commands in iSim, use the help command. I'm currently not aware of any loadfile/source/do instruction for iSim.
Example fifo_cc_got_tb:
All needed VHDL files are listed in a fifo_cc_got_tb.prj file:
vhdl poc "D:\git\PoC\tb\common\my_config_ML505.vhdl"
vhdl poc "D:\git\PoC\tb\common\my_project.vhdl"
vhdl unisim "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\primitive\MUXCY.vhd"
vhdl unisim "C:\Xilinx\14.7\ISE_DS\ISE\vhdl\src\unisims\primitive\XORCY.vhd"
vhdl poc "D:\git\PoC\src\common\utils.vhdl"
vhdl poc "D:\git\PoC\src\common\strings.vhdl"
vhdl poc "D:\git\PoC\src\common\vectors.vhdl"
vhdl poc "D:\git\PoC\src\common\board.vhdl"
vhdl poc "D:\git\PoC\src\common\config.vhdl"
vhdl poc "D:\git\PoC\src\common\physical.vhdl"
vhdl poc "D:\git\PoC\tb\common\simulation.v93.vhdl"
vhdl poc "D:\git\PoC\tb\common\simulation.v93.vhdl"
vhdl poc "D:\git\PoC\src\mem\ocram\ocram.pkg.vhdl"
vhdl poc "D:\git\PoC\src\mem\ocram\ocram_sdp.vhdl"
vhdl poc "D:\git\PoC\src\fifo\fifo_cc_got.vhdl"
vhdl test "D:\git\PoC\tb\fifo\fifo_cc_got_tb.vhdl"
The ISE ProjectNavigator collects this information for you and saves it in a prj file.
fuse.exe is executed to compile the testbench from given prj file:
cd D:\git\PoC\temp\isim\
C:\Xilinx\14.7\ISE_DS\ISE\bin\nt64\fuse.exe test.fifo_cc_got_tb --prj fifo_cc_got_tb.prj -o fifo_cc_got_tb.exe
This can also be found in the ProjectNavigator console window:
Started : "Simulate Behavioral Model".
Determining files marked for global include in the design...
Running fuse...
Command Line: fuse -intstyle ise -incremental -lib secureip -o D:/git/GitHub/PicoBlaze-Examples/Projects/SoFPGA_Atlys_ISE/ise/sync_Strobe_isim_beh.exe -prj D:/git/GitHub/PicoBlaze-Examples/Projects/SoFPGA_Atlys_ISE/ise/sync_Strobe_beh.prj PoC.sync_Strobe {}
Running: C:\Xilinx\14.7\ISE_DS\ISE\bin\nt64\unwrapped\fuse.exe -intstyle ise -incremental -lib secureip -o D:/git/GitHub/PicoBlaze-Examples/Projects/SoFPGA_Atlys_ISE/ise/sync_Strobe_isim_beh.exe -prj D:/git/GitHub/PicoBlaze-Examples/Projects/SoFPGA_Atlys_ISE/ise/sync_Strobe_beh.prj PoC.sync_Strobe
The simulation is launched with a TCL script
.\fifo_cc_got_tb.exe -tclbatch ..\..\sim\iSim.gui.tcl -gui
Also this can be seen in the ProjectNavigators console window:
....
Compiled 21 VHDL Units
Built simulation executable D:/git/GitHub/PicoBlaze-Examples/Projects/SoFPGA_Atlys_ISE/ise/sync_Strobe_isim_beh.exe
Fuse Memory Usage: 50240 KB
Fuse CPU Usage: 529 ms
Launching ISim simulation engine GUI...
"D:/git/GitHub/PicoBlaze-Examples/Projects/SoFPGA_Atlys_ISE/ise/sync_Strobe_isim_beh.exe" -intstyle ise -gui -tclbatch isim.cmd -wdb "D:/git/GitHub/PicoBlaze-Examples/Projects/SoFPGA_Atlys_ISE/ise/sync_Strobe_isim_beh.wdb"
ISim simulation engine GUI launched successfully
Here is the Simulation Process Property dialog to setup a user defined TCL script (red option) and if needed a user defined waveform configuration file (*.wcfg) green option.
On ModelSim I'm not able to start a simulation, for any of my projects.
I have installed ModelSim on 2 different machines, and both give me the same error message:
For a simple edge detector project, here's what happens in the console after I do "Simulation - Start Simulation":
vsim -gui work.edgedet_tb
# vsim -gui
# Start time: 22:48:53 on Nov 10,2014
# Loading std.standard
# Loading std.textio(body)
# Loading ieee.std_logic_1164(body)
# Loading ieee.numeric_std(body)
# Loading ieee.std_logic_arith(body)
# Loading ieee.std_logic_unsigned(body)
# Loading work.edgedet_tb(structural)
# ** Error: (vsim-3170) Could not find 'C:/Users/Andy/Google Drive/DigitaleSynthese/5-11-14/appl-layer/edgedetector/work.edgedet(behav)'.
#
# Error loading design
The code compiles with no errors/warnings.
If I check the work-folder in the project's directory it looks like it contains a bunch of standard files but no project-related files. In previous projects which I have made in the past (with an earlier version) it would contain more files with names conforming to the project.
Any ideas? Thanks!
As it turns out other projects did simulate, so it was a small error in the source code:
edgedet.vhd:
ARCHITECTURE behaviour OF edgedet IS
edgedet_tb.vhd:
for uut : edgedet use entity work.edgedet(behav);