OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [Open8_pkg.vhd] - Blame information for rev 270

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 185 jshamlet
-- Copyright (c)2006,2011,2012,2013,2015,2020 Jeremy Seth Henry
2 181 jshamlet
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 220 jshamlet
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 181 jshamlet
 
24
-- VHDL Units :  Open8_pkg
25
-- Description:  Contains constant definitions for the Open8 processor
26 220 jshamlet
--
27 181 jshamlet
-- Revision History
28
-- Author          Date     Change
29
------------------ -------- ---------------------------------------------------
30
-- Seth Henry      07/22/06 Design Start
31
-- Seth Henry      02/03/12 Updated generics to match current model
32
-- Seth Henry      10/29/15 Migrated type/constant definitions to this file
33 227 jshamlet
-- Seth Henry      03/09/20 Created new ALU/SP opcodes for handling new RSP
34 185 jshamlet
-- Seth Henry      03/12/20 Rationalized the naming of the CPU flags to match
35
--                           the assembler names. Also removed superfluous
36
--                           signals in the ALU and PC records.
37 188 jshamlet
-- Seth Henry      03/17/20 Added new subtype and constants for external
38
--                           GP flags.
39 189 jshamlet
-- Seth Henry      03/18/20 Added the ceil_log2 function, since it is used in
40
--                           memory sizing calculations.
41 210 jshamlet
-- Seth Henry      04/09/20 Added the I bit to the exported flags for use in
42
--                           memory protection schemes.
43 226 jshamlet
-- Seth Henry      04/16/20 Added the OPEN8_BUS_TYPE record to simplify
44
--                           peripheral connections.
45 269 jshamlet
-- Seth Henry      10/21/20 Modified the write data path to use separate
46
--                           enumerated states rather than reuse the .reg field
47
--                           to improve performance.
48 270 jshamlet
-- Seth Henry      10/23/20 Moved CPU internal constants to o8_cpu.vhd
49 181 jshamlet
 
50
library ieee;
51
use ieee.std_logic_1164.all;
52 185 jshamlet
use ieee.std_logic_arith.all;
53 181 jshamlet
 
54
package Open8_pkg is
55
 
56
-------------------------------------------------------------------------------
57
-- External constants and type declarations
58
--
59
-- These subtypes can be used with external peripherals to simplify
60
--  connection to the core.
61
-------------------------------------------------------------------------------
62
 
63
  -- These must never be changed, as the core requires them to be these static
64
  --  values for proper operation. These are ONLY defined here to allow user
65 185 jshamlet
  --  code to dynamically configure itself to match the Open8 core.
66 181 jshamlet
 
67
  constant OPEN8_ADDR_WIDTH  : integer := 16; -- DON'T EVEN CONTEMPLATE
68
  constant OPEN8_DATA_WIDTH  : integer := 8;  -- CHANGING THESE!
69
 
70
  subtype ADDRESS_TYPE is std_logic_vector(OPEN8_ADDR_WIDTH - 1 downto 0);
71
  subtype DATA_TYPE    is std_logic_vector(OPEN8_DATA_WIDTH - 1 downto 0);
72
  -- Note: INTERRUPT_BUNDLE must be exactly the same width as DATA_TYPE
73
  subtype INTERRUPT_BUNDLE is DATA_TYPE;
74
 
75 210 jshamlet
  subtype EXT_GP_FLAGS is std_logic_vector(4 downto 0);
76 188 jshamlet
 
77 210 jshamlet
  constant EXT_ISR           : integer := 0;
78
  constant EXT_GP4           : integer := 1;
79
  constant EXT_GP5           : integer := 2;
80
  constant EXT_GP6           : integer := 3;
81
  constant EXT_GP7           : integer := 4;
82 188 jshamlet
 
83 191 jshamlet
  constant OPEN8_NULLBUS     : DATA_TYPE := x"00";
84
 
85 228 jshamlet
  constant Reset_Level       : std_logic := '1';
86
 
87 223 jshamlet
  type OPEN8_BUS_TYPE is record
88 224 jshamlet
    Clock                    : std_logic;
89
    Reset                    : std_logic;
90
    uSec_Tick                : std_logic;
91 223 jshamlet
    Address                  : ADDRESS_TYPE;
92
    Wr_En                    : std_logic;
93
    Wr_Data                  : DATA_TYPE;
94
    Rd_En                    : std_logic;
95 224 jshamlet
    GP_Flags                 : EXT_GP_FLAGS;
96 223 jshamlet
  end record;
97
 
98 228 jshamlet
  constant INIT_OPEN8_BUS    : OPEN8_BUS_TYPE := (
99
                                 '0',           -- Clock
100
                                 Reset_Level,   -- Reset
101
                                 '0',           -- uSec_Tick
102
                                 x"0000",       -- Address
103
                                 '0',           -- Wr_En
104
                                 OPEN8_NULLBUS, -- Wr_Data
105
                                 '0',           -- Rd_En
106
                                 "00000"        -- GP_Flags
107
                               );
108 224 jshamlet
 
109 181 jshamlet
  -- Component declaration
110 185 jshamlet
  --  (assumes a 1K RAM at 0x0000 and ROM at the top of the memory map)
111 183 jshamlet
  component o8_cpu is
112 181 jshamlet
  generic(
113 185 jshamlet
    Program_Start_Addr       : ADDRESS_TYPE := x"8000";
114
    ISR_Start_Addr           : ADDRESS_TYPE := x"FFF0";
115
    Stack_Start_Addr         : ADDRESS_TYPE := x"03FF";
116
    Allow_Stack_Address_Move : boolean      := false;
117
    Enable_Auto_Increment    : boolean      := false;
118
    BRK_Implements_WAI       : boolean      := false;
119
    Enable_NMI               : boolean      := true;
120 188 jshamlet
    RTI_Ignores_GP_Flags     : boolean      := false;
121 185 jshamlet
    Default_Interrupt_Mask   : DATA_TYPE    := x"FF";
122 224 jshamlet
    Clock_Frequency          : real
123
  );
124 181 jshamlet
  port(
125
    Clock                    : in  std_logic;
126 224 jshamlet
    PLL_Locked               : in  std_logic;
127 226 jshamlet
    Halt_Req                 : in  std_logic := '0';
128
    Halt_Ack                 : out std_logic;
129 223 jshamlet
    Open8_Bus                : out OPEN8_BUS_TYPE;
130 181 jshamlet
    Rd_Data                  : in  DATA_TYPE;
131 224 jshamlet
    Interrupts               : in  INTERRUPT_BUNDLE := x"00"
132 223 jshamlet
  );
133 181 jshamlet
  end component;
134
 
135 189 jshamlet
  -- This function is used to calculate RAM parameters, but is generally
136
  --  useful for making things more generic.
137
  function ceil_log2 (x : in natural) return natural;
138
 
139 227 jshamlet
end package;
140 186 jshamlet
 
141
package body Open8_pkg is
142 189 jshamlet
 
143
  -- The ceil_log2 function returns the minimum register width required to
144
  --  hold the supplied integer.
145
  function ceil_log2 (x : in natural) return natural is
146
    variable retval          : natural;
147
  begin
148
    retval                   := 1;
149
    while ((2**retval) - 1) < x loop
150
      retval                 := retval + 1;
151
    end loop;
152
    return retval;
153 227 jshamlet
  end function;
154 189 jshamlet
 
155 186 jshamlet
end package body;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.