2013-06-05 32 views
-1

我想用VHDL設計一個32位二進制串行加法器,使用結構化描述。加法器應該使用一個完整的加法器和一個d-latch。我看到它的方式是:二進制串行加法器 - VHDL

全加器:

architecture Behavioral of FullAdder is 
begin 

s <= (x xor y) xor cin; 
cout <= (x and y) or (y and cin) or (x and cin); 
end Behavioral; 

d-鎖:

architecture Behavioral of dLatch is 
begin 
state: process(clk) 
begin 
    if(clk'event and clk = '1') then 
     q <= d; 
    end if; 
end process; 
end Behavioral; 

串行加法:

add: process (clk) 
    variable count : integer range 0 to 31; 
     variable aux : STD_LOGIC; 
     variable aux2 : STD_LOGIC; 
    begin 
     if(clk'event and clk = '1') then 
     fa: FullAdder port map(x(count), y(count), aux, s(count), aux2); 
        dl: dLatch port map(clock, aux2, aux); 
     count := count + 1; 
    end if; 
    end process; 

但是,它似乎並沒有工作。 另外,管道串行加法器最簡單的方法是什麼?

+0

因爲您已經使用信號到端口的postional映射,所以在沒有實體聲明的情況下檢查有點困難。我建議使用命名的端口映射(pinname => signal_name)。你建立了一個模擬?如果不這樣做。如果你有,用它來向我們解釋「這似乎不起作用」的意思 - 你期望看到什麼?你究竟看到了什麼? –

回答

0

「它似乎沒有工作」是非常普遍的,但我看到的一個問題是,您正試圖在進程中實例化組件fa: FullAdder。想想硬件中的組件實例是什麼意思,你會意識到,在clk的rising_edge上實例化模塊是沒有意義的...

將實例化移出進程,並且它應該至少刪除語法您應該看到錯誤(ModelSim中的「非法順序語句」)。

0

對於流水線串行加法器,最好的方法是將加法器和觸發器依次連接起來。所以,你應該將第一個加法器的輸出作爲觸發器的輸入。該觸發器的輸出將是下一個加法器的cin,依此類推。但要小心,因爲你必須將每個加法器的s以及輸入的每一位都流水,通過將幾個d觸發器放在一行中來複制它們通過不同的流水線階段。