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