Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Type mismatch in testbench

Reply
Thread Tools

Type mismatch in testbench

 
 
bitsimman bitsimman is offline
Junior Member
Join Date: Oct 2011
Posts: 4
 
      10-04-2011
Hello everyone,

After fighting for hours with an vhdl code for a problem from a study-book I finaly got it to work (use quartus). But now I am fighting again with the code, but this time for the testbench for Modelsim. The error given seems easy to solve but I really don't know how to solve.

The code for my design is the next:

----- Package: ------------------------
library ieee;
use ieee.std_logic_1164.all;
----------------------------
package my_data_types is
constant m : integer := 8; -- width input-bus
type mux_inp is array (natural range <>) of std_logic_vector((m-1) downto 0);
end my_data_types;
----------------------------

----- Main: ---------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.my_data_types.all;
use ieee.std_logic_unsigned.all;
----------------------------
entity gen_mux is
generic (n : positive := 4); -- width selection-bus
port( x : in mux_inp (0 to 2**n-1); -- 2^n inputs
sel: in std_logic_vector (n-1 downto 0);
y: out std_logic_vector ((m-1) downto 0)); -- width output-bus
end gen_mux;
------ Architecture: --------------
architecture gen_mux of gen_mux is

begin
y <= x(conv_integer(sel));
end gen_mux;
-----------------------------------


Quartus made the next testbench (template writer) of it: (including my code)


-- Vhdl Test Bench template for design : gen_mux
--
-- Simulation tool : ModelSim-Altera (VHDL)
--

LIBRARY ieee;
USE ieee.std_logic_1164.all;

PACKAGE gen_mux_data_type IS
TYPE x_7_0_type IS ARRAY (7 DOWNTO 0) OF STD_LOGIC;
TYPE x_7_0_0_15_type IS ARRAY (0 TO 15) OF x_7_0_type;
SUBTYPE x_type IS x_7_0_0_15_type;
END gen_mux_data_type;

LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

library work;
use work.gen_mux_data_type.all;

ENTITY gen_mux_vhd_tst IS
END gen_mux_vhd_tst;
ARCHITECTURE gen_mux_arch OF gen_mux_vhd_tst IS
-- constants
-- signals
SIGNAL sel : STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL x : x_type;
SIGNAL y : STD_LOGIC_VECTOR(7 DOWNTO 0);
COMPONENT gen_mux IS
PORT (
sel : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
x : IN x_type;
y : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END COMPONENT;
BEGIN
i1 : gen_mux
PORT MAP (
-- list connections between master ports and signals
sel => sel,
x => x,
y => y
);
init : PROCESS
-- variable declarations

BEGIN
-- code that executes only once

for i in 0 to sel'high loop
sel<= conv_std_logic_vector(i, sel'length);
wait for 50 ns;
end loop;

WAIT;
END PROCESS init;
always : PROCESS
-- optional sensitivity list
-- ( )
-- variable declarations
BEGIN
-- code executes for every event on sensitivity list
WAIT;
END PROCESS always;
END gen_mux_arch;


After clicking the "EDA RTL Simulation" button, modelsim gives the next error:

# Reading C:/altera/11.0/modelsim_ase/tcl/vsim/pref.tcl
# do gen_mux_run_msim_rtl_vhdl.do
# if {[file exists rtl_work]} {
# vdel -lib rtl_work -all
# }
# vlib rtl_work
# vmap work rtl_work
# Copying C:\altera\11.0\modelsim_ase\win32aloem/../modelsim.ini to modelsim.ini
# Modifying modelsim.ini
# ** Warning: Copied C:\altera\11.0\modelsim_ase\win32aloem/../modelsim.ini to modelsim.ini.
# Updated modelsim.ini.
#
# vcom -93 -work work {C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/gen_mux.vhd}
# Model Technology ModelSim ALTERA vcom 6.6d Compiler 2010.11 Nov 2 2010
# -- Loading package standard
# -- Loading package std_logic_1164
# -- Compiling package my_data_types
# -- Loading package my_data_types
# -- Loading package std_logic_arith
# -- Loading package std_logic_unsigned
# -- Compiling entity gen_mux
# -- Compiling architecture gen_mux of gen_mux
#
# vcom -93 -work work {C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/simulation/modelsim/gen_mux.vht}
# Model Technology ModelSim ALTERA vcom 6.6d Compiler 2010.11 Nov 2 2010
# -- Loading package standard
# -- Loading package std_logic_1164
# -- Compiling package gen_mux_data_type
# -- Loading package std_logic_arith
# -- Loading package gen_mux_data_type
# -- Compiling entity gen_mux_vhd_tst
# -- Compiling architecture gen_mux_arch of gen_mux_vhd_tst
#
# vsim -t 1ps -L altera -L lpm -L sgate -L altera_mf -L altera_lnsim -L maxii -L rtl_work -L work -voptargs="+acc" gen_mux_vhd_tst
# vsim -L altera -L lpm -L sgate -L altera_mf -L altera_lnsim -L maxii -L rtl_work -L work -voptargs=\"+acc\" -t 1ps gen_mux_vhd_tst
# Loading std.standard
# Loading ieee.std_logic_1164(body)
# Loading ieee.std_logic_arith(body)
# Loading work.gen_mux_data_type
# Loading work.gen_mux_vhd_tst(gen_mux_arch)
# Loading work.my_data_types
# Loading ieee.std_logic_unsigned(body)
# Loading work.gen_mux(gen_mux)
# ** Failure: (vsim-3807) Types do not match between component and entity for port "x".
# Time: 0 ps Iteration: 0 Instance: /gen_mux_vhd_tst/i1 File: C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/gen_mux.vhd Line: 19
# Fatal error in file C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/gen_mux.vhd
# while elaborating region: /gen_mux_vhd_tst/i1
# Fatal error in file C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/simulation/modelsim/gen_mux.vht
# while elaborating region: /gen_mux_vhd_tst
# Error loading design
# Error: Error loading design
# Pausing macro execution
# MACRO ./gen_mux_run_msim_rtl_vhdl.do PAUSED at line 12

Does anybody know how I have to solve this?

Greets, Jan
 
Reply With Quote
 
 
 
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 153
 
      10-06-2011
You should use exactly the same types in the component declaration as in the entity declaration:
Code:
library work;
use work.my_data_types.all;

ENTITY gen_mux_vhd_tst IS
END gen_mux_vhd_tst;
ARCHITECTURE gen_mux_arch OF gen_mux_vhd_tst IS
-- constants
constant n : positive := 4;
-- signals
SIGNAL sel : STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL x : mux_inp (0 to 2**n-1);
SIGNAL y : STD_LOGIC_VECTOR(7 DOWNTO 0);
COMPONENT gen_mux IS
generic (n : positive := 4); -- width selection-bus
port( x : in mux_inp (0 to 2**n-1); -- 2^n inputs
sel: in std_logic_vector (n-1 downto 0);
y: out std_logic_vector ((m-1) downto 0)); -- width output-bus
END COMPONENT;
BEGIN
  -- as before
END gen_mux_arch;
 
Reply With Quote
 
 
 
 
bitsimman bitsimman is offline
Junior Member
Join Date: Oct 2011
Posts: 4
 
      10-07-2011
Thank you for your reply. I have changed the code like you suggested.

-- Vhdl Test Bench template for design : gen_mux
--
-- Simulation tool : ModelSim-Altera (VHDL)
--

LIBRARY ieee;
USE ieee.std_logic_1164.all;

PACKAGE gen_mux_data_type IS
constant m : integer := 8; -- width input-bus
TYPE mux_inp IS ARRAY (natural range<>) OF STD_LOGIC_VECTOR (m-1 DOWNTO 0);
END gen_mux_data_type;

LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

library work;
use work.gen_mux_data_type.all;

ENTITY gen_mux_vhd_tst IS
END gen_mux_vhd_tst;
ARCHITECTURE gen_mux_arch OF gen_mux_vhd_tst IS
-- constants
constant n : positive := 4;
-- signals
SIGNAL sel : STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL x : mux_inp (0 to 2**n-1);
SIGNAL y : STD_LOGIC_VECTOR(7 DOWNTO 0);
COMPONENT gen_mux IS
generic (n : positive := 4); -- width selection-bus
PORT (
sel: in std_logic_vector (n-1 downto 0);
x : in mux_inp (0 to 2**n-1); -- 2^n inputs
y: out std_logic_vector ((m-1) downto 0) -- width output-bus
);
END COMPONENT;
BEGIN
i1 : gen_mux
-- GENERIC MAP( n )
PORT MAP (
-- list connections between master ports and signals
sel => sel,
x => x,
y => y
);
init : PROCESS
-- variable declarations

BEGIN
-- code that executes only once

for i in 0 to 2**sel'high-1 loop
sel<= conv_std_logic_vector(i, sel'length);
wait for 50 ns;
end loop;

WAIT;
END PROCESS init;
always : PROCESS
-- optional sensitivity list
-- ( )
-- variable declarations
BEGIN
-- code executes for every event on sensitivity list
WAIT;
END PROCESS always;
END gen_mux_arch;

But Modelsim is still bugging me with the error:

** Failure: (vsim-3807) Types do not match between component and entity for port "x".
# Time: 0 ps Iteration: 0 Instance: /gen_mux_vhd_tst/i1 File: C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/gen_mux.vhd Line: 19
# Fatal error in file C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/gen_mux.vhd
# while elaborating region: /gen_mux_vhd_tst/i1
# Fatal error in file C:/Users/Stage/Desktop/rotzooimapje/problem5_1_V4/simulation/modelsim/gen_mux.vht
# while elaborating region: /gen_mux_vhd_tst
# Error loading design

How can there still be an error? How do the types still don't match? Is it some kind of conflict with library's or something?
 
Reply With Quote
 
joris joris is offline
Senior Member
Join Date: Jan 2009
Posts: 153
 
      10-07-2011
The only thing I can think of is that I don't see this:
Code:
use work.my_data_types.all;
in the code you just posted.
However if that's the cause, it would seem Modelsim should complain about not finding the type, not about 'not matching'.
 
Reply With Quote
 
bitsimman bitsimman is offline
Junior Member
Join Date: Oct 2011
Posts: 4
 
      10-11-2011
Thank you Joris,

It seems that you were right. This solved the problem. I guess because the test bench template writer also made the package that Modelsim didn't cry about not finding a type.

Now that the original package is included Modelsim started telling me that it doesn't know which constants to take. For example work.gen_mux_data_type.m or work.my_data_types.m. I solved this problem by throwing gen_mux_data_type out of the test bench.
Now Modelsim doesn't give errors anymore and just runs the test bench (which isn't complete).

Conclusion is that I learned never to use pre-made packages in test benches and just to include the original. Thank you for helping me learn this.

Greets, Jan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL Type Mismatch error indexed name returns a value whose type does not match programmingzeal VHDL 0 05-06-2012 06:38 AM
type mismatch error amitbadgi@gmail.com ASP .Net 3 08-12-2005 11:23 AM
data type mismatch error amitbadgi@gmail.com ASP .Net 1 08-10-2005 01:04 PM
WORD shutdown - microsoft visual basic Run Time Error 13 - Type Mismatch frodo Computer Support 0 05-20-2004 05:39 PM
Type mismatch using Mozilla ActiveX in place of Microsoft WebBrowser? Noozer Firefox 0 05-19-2004 08:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57