2017-04-17 91 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

相关问题