2015-09-28 66 views
0

我無法通過拆分reg_mem來更新reg_1和reg_2向量? 這是我在VHDL中的代碼,我寫在MODELSIM中: 在其他程序中,我試圖將另一個矢量拆分成兩個部分,並將它們存儲到兩個不同的Vectors.It工作正常。但相同的語法不在此代碼中工作無法在VHDL中拆分向量

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.numeric_std.all; 

entity Register_unit is 
port (
    reg_read : in std_logic; 
    reg_write : in std_logic; 
    reg_mem : inout std_logic_vector(3 downto 0); 
    reg_start : inout std_logic_vector(3 downto 0); 
    reg_end : inout std_logic_vector(3 downto 0); 
    reg_write_comp : out std_logic; 
    reg_read_comp : out std_logic; 
    reg_1 : inout std_logic_vector(1 downto 0); 
    reg_2 : inout std_logic_vector(1 downto 0)); 
end Register_unit; 

architecture Register_unit_arch of Register_unit is 
begin 

    process (reg_read,reg_write) 
    begin 
    if (reg_read = '1' and reg_write = '0') then 
     reg_end <= reg_mem; 
     reg_read_comp <= '1'; 
    elsif (reg_write = '1' and reg_read = '0') then 
     reg_mem <= reg_start; 
     reg_write_comp <= '1'; 
    end if; 
    reg_1 <= reg_mem(1 downto 0); --reg_1 is not getting updated 
    reg_2 <= reg_mem(3 downto 2); --reg2 is not getting updated 
    end process; 

end Register_unit_arch; 
+0

靈敏度列表錯誤在非同步的過程。一個解決方案:將流程拆分到流程外部。另請閱讀http://stackoverflow.com/questions/13954193/is-process-in-vhdl-reentrant/13956532#13956532還要注意,沒有辦法重置'reg _ * _ comp'信號。 –

回答

0

reg_1reg_2被更新,但它們被更新爲reg_mem以前值。這條線;

reg_mem <= reg_start; 

直到過程結束才生效。您正在製作reg_1reg_2作品,然後reg_mem有新的價值!

即使您處於process中,VHDL也不能像編程語言那樣工作。

在你的情況下,你應該使用一個變量(*)或直接從reg_start這樣分配;

reg_1 <= reg_start(1 downto 0); 
reg_2 <= reg_start(3 downto 2); 

(*)變量是在一個過程中會立即派,你可以用它們類似的編程語言變量

+0

@HeyYOThanks我明白我在哪裏出錯只是改變了過程變量,一切都正常工作 – saideep1808