2017-04-17 89 views
0

我試圖讓集&負荷d-觸發器代碼(同步),但它一直給我count <= '0' & d; it has 2 elements but must have 9 elements error.Thanks提前VHDL錯誤10344不知道該怎麼辦

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.std_logic_unsigned.all; 
entity syn is 
port (
clk : in std_logic; 
rst_n : in std_logic; 
d : in std_logic; 
ld : in std_logic; 
q : out std_logic_vector(7 downto 0); 
co : out std_logic); 
end syn; 
architecture rtl of syn is 
signal count : std_logic_vector(8 downto 0); 
begin 
co <= count(8); 
q <= count(7 downto 0); 
process (clk) 
begin 
    if (clk'event and clk = '1') then 
     if (rst_n = '0') then 
      count <= (others => '0'); -- sync reset 
     elsif (ld = '1') then 
      count <= '0' & d; -- sync load 
     else 
      count <= count + 1; -- sync increment 
     end if; 
    end if; 
end process; 
end rtl; 
+0

錯誤消息告訴你什麼是錯的 - 在這種情況下非常準確。 –

+1

聚集,例如'count <= (0 => d,others =>'0');'其中count(0)被賦值爲d,其他(8 downto 1)賦值爲'0'。否則你的意圖不明確。你是否打算只加載兩個索引位置? – user1155120

回答

2

輸入d是STD_LOGIC,所以'0' & d是2位向量。 Count是長度爲9的std_logic_vector,所以你不能像這樣分配任務。 我不完全確定你想要達到的目標。如果你想分配「0」 & d爲載體的某些部分,比如,你可以

count(1 downto 0) <= '0' & d 

寫如果d應該是櫃檯的大小相等,然後改變它在實體聲明大小。

+0

如果此答案有用,請將其標記爲已接受。 – Staszek

相關問題