Line 82... |
Line 82... |
-- bytes for each word of SRAM_SIZE
|
-- bytes for each word of SRAM_SIZE
|
type t_sram is array(0 to SRAM_SIZE*2-1) of std_logic_vector(7 downto 0);
|
type t_sram is array(0 to SRAM_SIZE*2-1) of std_logic_vector(7 downto 0);
|
signal sram1 : t_sram := (@data31@);
|
signal sram1 : t_sram := (@data31@);
|
signal sram0 : t_sram := (@data20@);
|
signal sram0 : t_sram := (@data20@);
|
|
|
|
signal sram_chip_addr : std_logic_vector(SRAM_ADDR_SIZE downto 1);
|
|
signal sram_output : std_logic_vector(15 downto 0);
|
|
|
-- PROM table and interface signals --------------------------------------------
|
-- PROM table and interface signals --------------------------------------------
|
|
|
-- We'll simulate a 16-bit-wide static PROM (e.g. a Flash) with some serious
|
-- We'll simulate a 16-bit-wide static PROM (e.g. a Flash) with some serious
|
-- cycle time (70 or 90 ns).
|
-- cycle time (70 or 90 ns).
|
|
|
--constant PROM_SIZE : integer := @flash_table_size@;
|
constant PROM_SIZE : integer := @prom_size@;
|
--constant PROM_ADDR_SIZE : integer := log2(PROM_SIZE);
|
constant PROM_ADDR_SIZE : integer := log2(PROM_SIZE);
|
--
|
|
--subtype t_prom_address is std_logic_vector(PROM_ADDR_SIZE-1 downto 0);
|
subtype t_prom_address is std_logic_vector(PROM_ADDR_SIZE-1 downto 0);
|
--type t_prom is array(0 to PROM_SIZE-1) of t_hword;
|
type t_prom is array(0 to PROM_SIZE-1) of t_word;
|
--
|
|
--signal prom_rd_addr : t_prom_address;
|
signal prom_rd_addr : t_prom_address;
|
--signal prom_databus : t_hword;
|
signal prom_output : std_logic_vector(7 downto 0);
|
--signal prom_oe_n : std_logic;
|
signal prom_oe_n : std_logic;
|
--
|
|
---- bram0 is LSB, bram3 is MSB
|
-- bram0 is LSB, bram3 is MSB
|
--signal prom : t_prom := (@flash@);
|
signal prom : t_prom := (@flash@);
|
--
|
|
|
|
|
|
-- I/O devices -----------------------------------------------------------------
|
-- I/O devices -----------------------------------------------------------------
|
|
|
signal data_uart : std_logic_vector(31 downto 0);
|
signal data_uart : std_logic_vector(31 downto 0);
|
Line 117... |
Line 120... |
signal reset : std_logic := '1';
|
signal reset : std_logic := '1';
|
signal interrupt : std_logic := '0';
|
signal interrupt : std_logic := '0';
|
signal done : std_logic := '0';
|
signal done : std_logic := '0';
|
|
|
-- interface to asynchronous 16-bit-wide external SRAM
|
-- interface to asynchronous 16-bit-wide external SRAM
|
signal sram_address : std_logic_vector(SRAM_ADDR_SIZE downto 1);
|
signal sram_address : std_logic_vector(31 downto 0);
|
signal sram_databus : std_logic_vector(15 downto 0);
|
signal sram_data_rd : std_logic_vector(15 downto 0);
|
|
signal sram_data_wr : std_logic_vector(15 downto 0);
|
signal sram_byte_we_n : std_logic_vector(1 downto 0);
|
signal sram_byte_we_n : std_logic_vector(1 downto 0);
|
signal sram_oe_n : std_logic;
|
signal sram_oe_n : std_logic;
|
|
|
-- interface cpu-cache
|
-- interface cpu-cache
|
signal cpu_data_rd_addr : t_word;
|
signal cpu_data_rd_addr : t_word;
|
Line 198... |
Line 202... |
);
|
);
|
|
|
cache: entity work.mips_cache_stub
|
cache: entity work.mips_cache_stub
|
generic map (
|
generic map (
|
BRAM_ADDR_SIZE => BRAM_ADDR_SIZE,
|
BRAM_ADDR_SIZE => BRAM_ADDR_SIZE,
|
SRAM_ADDR_SIZE => SRAM_ADDR_SIZE
|
SRAM_ADDR_SIZE => 32 -- we need the full address to decode sram vs flash
|
)
|
)
|
port map (
|
port map (
|
clk => clk,
|
clk => clk,
|
reset => reset,
|
reset => reset,
|
|
|
Line 238... |
Line 242... |
bram_byte_we => bram_byte_we,
|
bram_byte_we => bram_byte_we,
|
bram_data_rd_vma=> bram_data_rd_vma,
|
bram_data_rd_vma=> bram_data_rd_vma,
|
|
|
-- interface to asynchronous 16-bit-wide external SRAM
|
-- interface to asynchronous 16-bit-wide external SRAM
|
sram_address => sram_address,
|
sram_address => sram_address,
|
sram_databus => sram_databus,
|
sram_data_rd => sram_data_rd,
|
|
sram_data_wr => sram_data_wr,
|
sram_byte_we_n => sram_byte_we_n,
|
sram_byte_we_n => sram_byte_we_n,
|
sram_oe_n => sram_oe_n
|
sram_oe_n => sram_oe_n
|
);
|
);
|
|
|
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
Line 306... |
Line 311... |
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process data_ram_block;
|
end process data_ram_block;
|
|
|
sram_databus <=
|
sram_data_rd <=
|
sram1(conv_integer(unsigned(sram_address))) &
|
X"00" & prom_output when sram_address(31 downto 27)="10110" else
|
sram0(conv_integer(unsigned(sram_address))) when sram_oe_n='0'
|
sram_output;
|
|
|
|
|
|
|
|
-- Do a very basic simulation of an external SRAM ---------------
|
|
|
|
sram_chip_addr <= sram_address(SRAM_ADDR_SIZE downto 1);
|
|
|
|
-- FIXME should add some verification of /WE
|
|
sram_output <=
|
|
sram1(conv_integer(unsigned(sram_chip_addr))) &
|
|
sram0(conv_integer(unsigned(sram_chip_addr))) when sram_oe_n='0'
|
else (others => 'Z');
|
else (others => 'Z');
|
|
|
-- Do a very basic simulation of an external SRAM
|
simulated_sram_write:
|
simulated_sram:
|
|
process(sram_byte_we_n, sram_address, sram_oe_n)
|
process(sram_byte_we_n, sram_address, sram_oe_n)
|
begin
|
begin
|
-- Write cycle
|
-- Write cycle
|
-- FIXME should add OE\ to write control logic
|
-- FIXME should add OE\ to write control logic
|
if sram_byte_we_n'event or sram_address'event then
|
if sram_byte_we_n'event or sram_address'event then
|
if sram_byte_we_n(1)='0' then
|
if sram_byte_we_n(1)='0' then
|
sram1(conv_integer(unsigned(sram_address))) <= sram_databus(15 downto 8);
|
sram1(conv_integer(unsigned(sram_chip_addr))) <= sram_data_wr(15 downto 8);
|
end if;
|
end if;
|
if sram_byte_we_n(0)='0' then
|
if sram_byte_we_n(0)='0' then
|
sram0(conv_integer(unsigned(sram_address))) <= sram_databus( 7 downto 0);
|
sram0(conv_integer(unsigned(sram_chip_addr))) <= sram_data_wr( 7 downto 0);
|
end if;
|
end if;
|
end if;
|
end if;
|
|
end process simulated_sram_write;
|
|
|
-- Read cycle
|
|
-- FIXME should add some verification of /WE
|
|
--if sram_oe_n'event or sram_address'event then
|
|
-- if sram_oe_n='0' then
|
|
-- sram_databus <=
|
|
-- sram1(conv_integer(unsigned(sram_address))) &
|
|
-- sram0(conv_integer(unsigned(sram_address)));
|
|
-- else
|
|
-- sram_databus <= (others => 'Z');
|
|
-- end if;
|
|
--end if;
|
|
|
|
end process simulated_sram;
|
|
|
|
-- Do a very basic simulation of an external PROM wired to the same bus
|
-- Do a very basic simulation of an external PROM wired to the same bus
|
-- as the sram (both are static).
|
-- as the sram (both are static).
|
-- prom_databus <=
|
|
-- prom(conv_integer(unsigned(sram_address))) when prom_oe_n='0'
|
prom_rd_addr <= sram_address(PROM_ADDR_SIZE+1 downto 2);
|
-- else (others => 'Z');
|
|
|
prom_oe_n <= sram_oe_n;
|
|
|
|
prom_output <=
|
|
prom(conv_integer(unsigned(prom_rd_addr)))(31 downto 24) when prom_oe_n='0' and sram_address(1 downto 0)="00" else
|
|
prom(conv_integer(unsigned(prom_rd_addr)))(23 downto 16) when prom_oe_n='0' and sram_address(1 downto 0)="01" else
|
|
prom(conv_integer(unsigned(prom_rd_addr)))(15 downto 8) when prom_oe_n='0' and sram_address(1 downto 0)="10" else
|
|
prom(conv_integer(unsigned(prom_rd_addr)))( 7 downto 0) when prom_oe_n='0' and sram_address(1 downto 0)="11" else
|
|
(others => 'Z');
|
|
|
|
|
simulated_io:
|
simulated_io:
|
process(clk)
|
process(clk)
|
variable i : integer;
|
variable i : integer;
|