我有一個名爲amux的數組,我想在數組內保存整數倍的信號A
。下面的僞代碼給出了一個想法:用信號值的整數倍填充一個數組
amux(0) <= "00001101";
amux(1) <= amux(0);
....
amux(n) <= amux(n-1);
我完整的代碼看起來是這樣的:
-- n is 4 and m is 3, amux is an array, mzeros is 0's
regA: process(clk)
variable r : integer := 2**m;
begin
if rising_edge(clk) then
if ld_a = '1' then
amux(0) <= std_logic_vector(to_unsigned((0),n*m+m));
amux(1) <= mzeros & A;
for i in 2 to r-1 loop
if (i mod 2) = 0 then
amux(i) <= amux(i/2)(n*m+m-2 downto 0) & '0';
else
amux(i) <= std_logic_vector(unsigned(amux(i-1))+unsigned(amux(1)));
end if;
end loop;
end if;
end if;
結束進程雷加;
我目前的實現輸出所有「00000000」,除了amux(0)。我的方法有什麼問題?
需要更多的上下文:發佈一個小的完整的可編譯示例。 –
只是猜測,但聽起來像你期望的「00001101」波及到所有amux(1).. amux(n)。然而,這不是'<='在VHDL中的工作方式,因爲在下一個模擬週期之前,用'<='指定給amux(0)的值是不可見的,所以分配給amux(1)使用當前「old」)amux(0)的值,它可能全是「00000000」,並且對於其餘的amux分配類似。 –
我想要保存數組中信號A的整數倍數 – hassicho