2015-09-25 95 views
0

我VHDL編程和編譯測試平臺時,我有一個問題出現以下錯誤:編譯錯誤與運營商「」&「」」 VHDL

錯誤(10327):在comparador_12_tb.vhd VHDL錯誤( 56):無法確定運營商 「」 & 「」 的定義 - 發現0可能的定義

代碼

library ieee; 
use ieee.std_logic_1164.all; 

entity comparador_12 is 
port(num1 : in std_logic_vector(3 downto 0); 
     num2 : in std_logic_vector(3 downto 0); 
     clock : in std_logic; 
     menor : out std_logic; 
     igual : out std_logic; 
     mayor : out std_logic 
     ); 
end comparador_12; 

architecture behavioral of comparador_12 is 
begin 
    process(num1,num2) 
     begin  
      if (num1&num1&num1 > num2&num2&num2) then 
       menor <= '0'; 
       igual <= '0'; 
       mayor <= '1'; 
      elsif (num1&num1&num1 < num2&num2&num2) then  
       menor <= '1'; 
       igual <= '0'; 
       mayor <= '0'; 
      else  
       menor <= '0'; 
       igual <= '1'; 
       mayor <= '0';   
     end if; 
    end process; 
end behavioral; 

測試平臺

LIBRARY ieee;            
USE ieee.std_logic_1164.all;         

ENTITY comparador_12_tb IS 
END comparador_12_tb; 

ARCHITECTURE behavioral OF comparador_12_tb IS 
-- constants             
-- signals             
SIGNAL igual : STD_LOGIC; 
SIGNAL mayor : STD_LOGIC; 
SIGNAL menor : STD_LOGIC; 
SIGNAL num1 : STD_LOGIC_VECTOR(3 DOWNTO 0); 
SIGNAL num2 : STD_LOGIC_VECTOR(3 DOWNTO 0); 
signal clk : std_logic := '0'; 
constant clk_period : time := 20 ns; 
signal x,y : std_logic; 

COMPONENT comparador_12 
    PORT (
    igual : BUFFER STD_LOGIC; 
    mayor : BUFFER STD_LOGIC; 
    menor : BUFFER STD_LOGIC; 
    num1 : IN STD_LOGIC_VECTOR(3 DOWNTO 0); 
    num2 : IN STD_LOGIC_VECTOR(3 DOWNTO 0) 
    ); 
END COMPONENT; 

BEGIN 
    uut : comparador_12 
    PORT MAP (
-- list connections between master ports and signals 
    igual => igual, 
    mayor => mayor, 
    menor => menor, 
    num1 => num1, 
    num2 => num2 
    ); 

clk_process :process 
    begin 
     clk <= '0'; 
     wait for clk_period/2; 
     clk <= '1'; 
     wait for clk_period/2; 
end process; 

tb : process 
begin 
     num1 <= "1001"; 
     num1 <= "1100"; 
     num1 <= "0100"; 
     num2 <= "1110"; 
     num2 <= "1101"; 
     num2 <= "1000"; 
     x <= num1&num1&num1; 
     y <= num2&num2&num2; 
    wait for 10 ns; 
end process;    
END behavioral; 
+1

由於結果(在「X」和「Y」)將是12位,VHDL編譯器無法找到「&」的過載,它需要3個4位輸入併產生1位輸出。你想要X和Y是什麼? –

回答

1

看着你的測試平臺如下信號聲明:

signal num1 : STD_LOGIC_VECTOR(3 DOWNTO 0); 
signal x,y : std_logic; 

,代碼:

x <= num1&num1&num1; 

&是連接運算符。在這種情況下,您將一個4位向量與自身連接起來,創建一個12位向量。然後您將結果分配給一位std_logic信號。我不確定你會在這裏發生什麼,但這是錯誤的原因。

+0

你碰巧知道是否會正確執行連接,因爲'&'不是有效的信號名稱字符?我不確定,因爲我永遠不會嘗試沒有空格的東西,哈哈。另外它可能值得一提的是,如果他試圖合乎邏輯,他需要使用'和'關鍵字。 – Ian

+0

@Ian我認爲,既然它已經確定'&'爲一個操作符,這是允許的;在modelsim中的快速測試似乎證實。我想不出有什麼理由使用reductive(因爲目標是'std_logic')'和'在* same * vector的三重連接上,所以沒有進一步猜測這行的意圖。 –

+0

是的我得出了同樣的結論,只是想知道如果有人知道,如果這是支持的,爲什麼。我認爲這是將信號名稱限制爲數字,字母和下劃線的副作用。並同意,但我想不出在這裏使用串聯的很好理由,或者哈哈。 – Ian