2016-02-04 17 views
1

我跑的ModelSim 10.3d,我有這樣的代碼包中的:的ModelSim不編譯重載函數和未定義的範圍類型

package core_params_types is 
    type array_1d_logic is array (natural range <>) of std_logic; 
type array_1d_logic_vector is array (natural range <>) of std_logic_vector (natural range <>); 
type array_2d_logic is array (natural range <>, natural range <>) of std_logic; 
type array_2d_logic_vector is array (natural range <>, natural range <>) of std_logic_vector (natural range <>); 

function or_reduce_2d_logic(a : array_2d_logic; i : integer) return std_logic; 
function or_reduce_2d_logic_vector(a : array_2d_logic_vector; i : integer) return std_logic_vector; 

function bitwise_cmp(a : std_logic_vector; b : std_logic_vector) return std_logic; 
function bitwise_cmp(a : std_logic; b : std_logic) return std_logic; 

function full_adder(a : std_logic_vector; b : std_logic_vector; ci : std_logic) return std_logic_vector; 

function sign_extend(a : std_logic_vector; b : integer) return std_logic_vector; 
function sign_extend(a : std_logic; b : integer) return std_logic_vector; 
function logic_extend(a : std_logic_vector; b : integer) return std_logic_vector; 
function logic_extend(a : std_logic; b : integer) return std_logic_vector; 

的ModelSim吐出以下錯誤:

-- Loading package STANDARD 
# -- Loading package TEXTIO 
# -- Loading package std_logic_1164 
# -- Loading package NUMERIC_STD 
# -- Loading package MATH_REAL 
# -- Loading package ATTRIBUTES 
# -- Loading package std_logic_misc 
# -- Compiling package core_params_types 
# ** Error: core_params_types.vhd(40): near "<>": syntax error 
# ** Error: core_params_types.vhd(42): near "<>": syntax error 
# ** Error: core_params_types.vhd(45): (vcom-1136) Unknown identifier "array_2d_logic_vector". 
# ** Error: core_params_types.vhd(48): (vcom-1295) Function "bitwise_cmp" has already been defined in this region. 
# ** =====> Prior declaration of "bitwise_cmp" is at core_params_types.vhd(47). 
# ** Error: core_params_types.vhd(53): (vcom-1295) Function "sign_extend" has already been defined in this region. 
# ** =====> Prior declaration of "sign_extend" is at core_params_types.vhd(52). 
# ** Error: core_params_types.vhd(55): (vcom-1295) Function "logic_extend" has already been defined in this region. 
# ** =====> Prior declaration of "logic_extend" is at core_params_types.vhd(54). 
# ** Error: core_params_types.vhd(310): VHDL Compiler exiting 

.do文件包含以下命令:

transcript on 
if {[file exists rtl_work]} { 
    vdel -lib rtl_work -all 
} 
vlib rtl_work 
vmap work rtl_work 

vcom -2008 -work work {core_params_types.vhd} 
vcom -2008 -work work {alu.vhd} 

vcom -2008 -work work {tb_alu.vhd} 
vcom -2008 -work work {alu.vhd} 

vsim -t 1ps -L altera -L lpm -L sgate -L altera_mf -L altera_lnsim -L cyclonev -L rtl_work -L work -voptargs="+acc" tb_alu 

add wave * 
view structure 
view signals 
run -all 

我從Quartus運行ModelSim仿真,其中c ompiles代碼沒有錯誤,並生成一個電路。 ModelSim說這些功能已經定義好了。這是正確的,但他們有不同的類型,所以他們應該超載。 ModelSim也不理解數組類型的聲明。

回答

4

類型聲明

type array_1d_logic_vector is array (natural range <>) of std_logic_vector (natural range <>); 

無效。您不聲明元素類型的索引類型。 相反嘗試:

type array_1d_logic_vector is array (natural range <>) of std_logic_vector; 

您約束元件亞型中的對象的聲明例如:

variable foo: array_1d_logic_vector(0 to 1)(7 downto 0); 

當元件亞型約束爲7 DOWNTO 0和陣列約束是0到1

參見IEEE Std 1076-2008 5.3.2陣列類型5.3.2.1通用第6段:

其中元素子類型指示表示無約束複合子類型或不是複合子類型的子類型的無限數組定義定義了數組類型和表示該類型的名稱。對於具有數組類型的每個對象,索引數,每個索引的類型和位置以及元素的子類型與類型定義中的一樣。根據定義,給定索引位置的索引子類型是由相應索引子類型定義的類型標記表示的子類型。每個索引範圍的左右邊界的值沒有定義,但應屬於相應的索引子類型;類似地,每個索引範圍的方向沒有被定義。索引子類型定義中的符號<>(稱爲盒子)代表未定義的範圍(不同類型的對象不必具有相同的邊界和方向)。

在5.3.2.1中有一個代碼示例(接近尾聲)。

而且,如果第二種形式看起來容易搞砸,那就是。您可以使用具有不同子類型約束的元素聲明具有相同類型的對象,並且在長度不同時不兼容。

沒有看到使用原始成功合成的任何合成操作的日誌文件輸出將不符合VHDL標準。

沒有經過精細梳齒的任何事情,您的測試用例包聲明與示例代碼中給出的行號不匹配。看起來你正在重新聲明包體中的函數(注意行號310)。嘗試刪除重複的函數聲明。

(你也可以提供一個實際的Minimal, Complete, and Verifiable example,它確實知道發生了什麼事)。

+0

你好。問題是不正確的類型聲明。一旦我修復了這個問題(以及其他一些小問題),它就會編譯並運行測試平臺。謝謝。 – Raul

相關問題