| 1 |
195 |
ja_rd |
--------------------------------------------------------------------------------
|
| 2 |
|
|
-- @fileinfo@
|
| 3 |
|
|
--------------------------------------------------------------------------------
|
| 4 |
|
|
-- Stuff used in the simulation of external ROM (FLASH).
|
| 5 |
|
|
--
|
| 6 |
|
|
-- This package provides constants and types to be used when simulating an
|
| 7 |
|
|
-- external ROM (FLASH) connected to the MCU. It is only meant to be used
|
| 8 |
|
|
-- in the test bench.
|
| 9 |
|
|
--------------------------------------------------------------------------------
|
| 10 |
|
|
-- Copyright (C) 2011 Jose A. Ruiz
|
| 11 |
|
|
--
|
| 12 |
|
|
-- This source file may be used and distributed without
|
| 13 |
|
|
-- restriction provided that this copyright statement is not
|
| 14 |
|
|
-- removed from the file and that any derivative work contains
|
| 15 |
|
|
-- the original copyright notice and the associated disclaimer.
|
| 16 |
|
|
--
|
| 17 |
|
|
-- This source file is free software; you can redistribute it
|
| 18 |
|
|
-- and/or modify it under the terms of the GNU Lesser General
|
| 19 |
|
|
-- Public License as published by the Free Software Foundation;
|
| 20 |
|
|
-- either version 2.1 of the License, or (at your option) any
|
| 21 |
|
|
-- later version.
|
| 22 |
|
|
--
|
| 23 |
|
|
-- This source is distributed in the hope that it will be
|
| 24 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied
|
| 25 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
| 26 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more
|
| 27 |
|
|
-- details.
|
| 28 |
|
|
--
|
| 29 |
|
|
-- You should have received a copy of the GNU Lesser General
|
| 30 |
|
|
-- Public License along with this source; if not, download it
|
| 31 |
|
|
-- from http://www.opencores.org/lgpl.shtml
|
| 32 |
|
|
--------------------------------------------------------------------------------
|
| 33 |
|
|
|
| 34 |
|
|
library ieee;
|
| 35 |
|
|
use ieee.std_logic_1164.all;
|
| 36 |
|
|
use ieee.std_logic_arith.all;
|
| 37 |
|
|
use ieee.std_logic_unsigned.all;
|
| 38 |
|
|
use work.mips_pkg.all;
|
| 39 |
|
|
|
| 40 |
|
|
package sim_params_pkg is
|
| 41 |
|
|
|
| 42 |
|
|
---- General simulation parameters ---------------------------------------------
|
| 43 |
|
|
|
| 44 |
|
|
-- Master clock period...
|
| 45 |
|
|
constant T : time := 20 ns;
|
| 46 |
|
|
-- ...and matching clock rate
|
| 47 |
|
|
-- FIXME define them once, use formula with clumsy VHDL type conversion
|
| 48 |
|
|
constant CLOCK_RATE : integer := 50000000;
|
| 49 |
|
|
|
| 50 |
|
|
-- Simulation length in clock cycles, should be long enough.
|
| 51 |
|
|
-- This is adjusted by trial and error for each code sample.
|
| 52 |
|
|
constant SIMULATION_LENGTH : integer := @sim_len@;
|
| 53 |
|
|
|
| 54 |
|
|
-- This is the address that will trigger logging when fetched from
|
| 55 |
|
|
constant LOG_TRIGGER_ADDRESS : t_word := @log_trigger_addr@;
|
| 56 |
|
|
|
| 57 |
|
|
|
| 58 |
|
|
---- Data for the simulation of external FLASH ---------------------------------
|
| 59 |
|
|
|
| 60 |
|
|
-- Simulated FLASH table and address sizes...
|
| 61 |
|
|
constant PROM_SIZE : integer := @prom_size@;
|
| 62 |
|
|
constant PROM_ADDR_SIZE : integer := log2(PROM_SIZE);
|
| 63 |
|
|
-- ...and the type of the table that will hold the simulated data
|
| 64 |
|
|
subtype t_prom_address is std_logic_vector(PROM_ADDR_SIZE-1 downto 0);
|
| 65 |
|
|
type t_prom is array(0 to PROM_SIZE-1) of t_word;
|
| 66 |
|
|
|
| 67 |
|
|
-- This constant is where the simulated FLASH contents are defined.
|
| 68 |
|
|
constant PROM_DATA : t_prom := (@flash@);
|
| 69 |
|
|
|
| 70 |
|
|
---- Data for the simulation of external 16-bit-wide SRAM ----------------------
|
| 71 |
|
|
|
| 72 |
|
|
-- Simulated external SRAM size in 32-bit words
|
| 73 |
|
|
constant SRAM_SIZE : integer := @xram_size@;
|
| 74 |
|
|
|
| 75 |
|
|
-- External SRAM address length
|
| 76 |
|
|
-- Memory is 16 bits wide so we stick an extra address bit
|
| 77 |
|
|
constant SRAM_ADDR_SIZE : integer := log2(SRAM_SIZE)+1;
|
| 78 |
|
|
|
| 79 |
|
|
-- This is a 16-bit SRAM split in 2 byte slices; so each slice will have two
|
| 80 |
|
|
-- bytes for each word of SRAM_SIZE
|
| 81 |
|
|
-- FIXME in simulation we can use a simpler 16-bit-wide table
|
| 82 |
|
|
type t_sram is array(0 to SRAM_SIZE*2-1) of std_logic_vector(7 downto 0);
|
| 83 |
|
|
|
| 84 |
|
|
end package;
|