星期三, 5月 09, 2007

65536 與 32

一個是2^16一個是2^5,就這樣,但是在一個很簡單的SRAM程式碼(實作非常非常簡單的記憶體)與MAX PLUS II卻有不同的結果


LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

ENTITY SRAM IS
generic(S_size: integer:= 65536;
S_address: integer:= 16;
S_length: integer:= 16);
PORT(enable: in std_logic;
M_rw: in std_logic;
address: in std_logic_vector(S_address-1 downto 0);
in_data: in std_logic_vector(S_length-1 downto 0);
out_data: out std_logic_vector(S_length-1 downto 0));
END SRAM;

ARCHITECTURE beheavor OF SRAM IS
type memory_array is array(0 to S_size-1) of std_logic_vector(S_length-1 downto 0);
signal sram_unit: memory_array;
BEGIN
process(enable)
begin
if(enable = '1') then
if(M_rw = '1') then
out_data <= sram_unit(conv_integer(address));
else
sram_unit(conv_integer(address)) <= in_data;
end if;
end if;
end process;
END beheavor;


其中

generic(S_size: integer:= 65536;
S_address: integer:= 16;
S_length: integer:= 16);

這個在MAX PLUS II我放了將近兩個小時complier還是沒跑完,後來將S_size改成32,S_address改成5,才能夠有點lag的complie過。

---
實驗講義寫的2^16 * 16bit 是怎麼回事XD

沒有留言: