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 333

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 313 jshamlet
    Program_Start_Addr       : ADDRESS_TYPE := x"8000"; -- Initial PC location
114
    ISR_Start_Addr           : ADDRESS_TYPE := x"FFF0"; -- Bottom of ISR vec's
115
    Stack_Start_Addr         : ADDRESS_TYPE := x"03FF"; -- Top of Stack
116
    Allow_Stack_Address_Move : boolean      := false;   -- Use Normal v8 RSP
117
    Enable_Auto_Increment    : boolean      := false;   -- Modify indexed instr
118
    BRK_Implements_WAI       : boolean      := false;   -- BRK -> Wait for Int
119
    Enable_NMI               : boolean      := false;   -- Force INTR0 enabled
120
    Sequential_Interrupts    : boolean      := false;   -- Interruptable ISRs
121
    RTI_Ignores_GP_Flags     : boolean      := false;   -- RTI sets all flags
122
    Supervisor_Mode          : boolean      := false;   -- I bit is restricted
123
    Unsigned_Index_Offsets   : boolean      := false;   -- Offsets are signed
124
    Rotate_Ignores_Carry     : boolean      := false;   -- Rotate thru Carry
125
    Default_Interrupt_Mask   : DATA_TYPE    := x"FF";   -- Enable all Ints
126
    Clock_Frequency          : real                     -- Clock Frequency
127 224 jshamlet
  );
128 181 jshamlet
  port(
129
    Clock                    : in  std_logic;
130 224 jshamlet
    PLL_Locked               : in  std_logic;
131 226 jshamlet
    Halt_Req                 : in  std_logic := '0';
132
    Halt_Ack                 : out std_logic;
133 223 jshamlet
    Open8_Bus                : out OPEN8_BUS_TYPE;
134 181 jshamlet
    Rd_Data                  : in  DATA_TYPE;
135 224 jshamlet
    Interrupts               : in  INTERRUPT_BUNDLE := x"00"
136 223 jshamlet
  );
137 181 jshamlet
  end component;
138
 
139 189 jshamlet
  -- This function is used to calculate RAM parameters, but is generally
140
  --  useful for making things more generic.
141
  function ceil_log2 (x : in natural) return natural;
142
 
143 227 jshamlet
end package;
144 186 jshamlet
 
145
package body Open8_pkg is
146 189 jshamlet
 
147
  -- The ceil_log2 function returns the minimum register width required to
148
  --  hold the supplied integer.
149
  function ceil_log2 (x : in natural) return natural is
150
    variable retval          : natural;
151
  begin
152
    retval                   := 1;
153
    while ((2**retval) - 1) < x loop
154
      retval                 := retval + 1;
155
    end loop;
156
    return retval;
157 227 jshamlet
  end function;
158 189 jshamlet
 
159 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.