1 |
227 |
jshamlet |
-- Copyright (c)2020 Jeremy Seth Henry
|
2 |
|
|
-- 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 |
|
|
-- (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 |
|
|
|
24 |
|
|
-- VHDL Units : open8_cfg
|
25 |
|
|
-- Description: Contains project specific constants to configure an Open8
|
26 |
|
|
-- system. This file contains an example from a working
|
27 |
|
|
-- configuration to demonstrate how it was used.
|
28 |
|
|
--
|
29 |
|
|
-- Revision History
|
30 |
|
|
-- Author Date Change
|
31 |
|
|
------------------ -------- ---------------------------------------------------
|
32 |
|
|
-- Seth Henry 04/16/20 Design Start
|
33 |
|
|
|
34 |
|
|
library ieee;
|
35 |
|
|
use ieee.std_logic_1164.all;
|
36 |
|
|
use ieee.std_logic_unsigned.all;
|
37 |
|
|
use ieee.std_logic_arith.all;
|
38 |
|
|
|
39 |
|
|
library work;
|
40 |
|
|
use work.open8_pkg.all;
|
41 |
|
|
|
42 |
|
|
package open8_cfg is
|
43 |
|
|
|
44 |
|
|
-- Internal signals & constants
|
45 |
|
|
constant Clock_Frequency : real := 100000000.0;
|
46 |
|
|
|
47 |
|
|
-- Peripheral Options
|
48 |
|
|
|
49 |
|
|
-- SDLC Configuration
|
50 |
|
|
constant Master_Mode : boolean := true;
|
51 |
|
|
constant BitClock_Freq : real := 20000000.0;
|
52 |
|
|
constant Clock_Offset : integer := 3;
|
53 |
|
|
|
54 |
|
|
-- MAX7221 Driver Configuration
|
55 |
|
|
constant MAX7221_BITRATE : real := 5000000.0;
|
56 |
|
|
|
57 |
|
|
-- Open8 CPU Options
|
58 |
|
|
constant Allow_Stack_Address_Move : boolean := true;
|
59 |
|
|
constant Stack_Xfer_Flag : integer := PSR_GP4;
|
60 |
|
|
constant Enable_Auto_Increment : boolean := true;
|
61 |
|
|
constant BRK_Implements_WAI : boolean := true;
|
62 |
|
|
constant Enable_NMI : boolean := true;
|
63 |
|
|
constant Sequential_Interrupts : boolean := true;
|
64 |
|
|
constant RTI_Ignores_GP_Flags : boolean := true;
|
65 |
|
|
constant Default_Int_Mask : DATA_TYPE := x"00";
|
66 |
|
|
|
67 |
|
|
-- Location and size of variable memory (BSS_START)
|
68 |
|
|
constant LRAM_Size : integer := 4096; -- Should match the LRAM model
|
69 |
|
|
constant LRAM_Address : ADDRESS_TYPE := x"0000";
|
70 |
|
|
|
71 |
|
|
-- Store interrupt vectors at the top of ROM (INTR_VEC_TABLE)
|
72 |
|
|
constant ISR_Start_Addr : ADDRESS_TYPE := x"FFF0";
|
73 |
|
|
|
74 |
|
|
-- Interrupt assignments
|
75 |
|
|
-- These are assigned in order priority from 0 (highest) to 7 (lowest)
|
76 |
|
|
constant INT_PIT : integer range 0 to OPEN8_DATA_WIDTH - 1 := 0;
|
77 |
|
|
constant INT_ETC : integer range 0 to OPEN8_DATA_WIDTH - 1 := 1;
|
78 |
|
|
constant INT_ALU : integer range 0 to OPEN8_DATA_WIDTH - 1 := 2;
|
79 |
|
|
constant INT_RTC : integer range 0 to OPEN8_DATA_WIDTH - 1 := 3;
|
80 |
|
|
constant INT_SDLC : integer range 0 to OPEN8_DATA_WIDTH - 1 := 4;
|
81 |
|
|
constant INT_BTN : integer range 0 to OPEN8_DATA_WIDTH - 1 := 5;
|
82 |
|
|
constant INT_VEC : integer range 0 to OPEN8_DATA_WIDTH - 1 := 6;
|
83 |
|
|
|
84 |
|
|
-- Peripheral I/O map
|
85 |
|
|
constant ALU_Address : ADDRESS_TYPE := x"1000"; -- ALU16 coprocessor
|
86 |
|
|
constant TMR_Address : ADDRESS_TYPE := x"1100"; -- System Timer / RT Clock
|
87 |
|
|
constant ETC_Address : ADDRESS_TYPE := x"1200"; -- Epoch Timer/Alarm Clock
|
88 |
|
|
constant LED_Address : ADDRESS_TYPE := x"1400"; -- LED Display
|
89 |
|
|
constant DSW_Address : ADDRESS_TYPE := x"1800"; -- Dip Switches
|
90 |
|
|
constant BTN_Address : ADDRESS_TYPE := x"2000"; -- Push Buttons
|
91 |
|
|
constant SDLC_Address : ADDRESS_TYPE := x"2200"; -- LCD serial interface
|
92 |
|
|
constant SER_Address : ADDRESS_TYPE := x"2400"; -- UART interface
|
93 |
|
|
constant MAX_Address : ADDRESS_TYPE := x"2800"; -- Max 7221 base address
|
94 |
|
|
constant ROM_Address : ADDRESS_TYPE := x"8000"; -- Application ROM
|
95 |
|
|
|
96 |
|
|
-- Set this to the number of readable modules in the design, as it sets the
|
97 |
|
|
-- number of ports on the read aggregator function.
|
98 |
|
|
constant OPEN8_READ_BUSES : integer := 10;
|
99 |
|
|
|
100 |
|
|
-- Read Data Bus aggregator and bus assignments.
|
101 |
|
|
-- Note that the ordering isn't important, only that each device has a
|
102 |
|
|
-- unique number less than READ_BUS_COUNT.
|
103 |
|
|
constant RDB_RAM : integer range 0 to OPEN8_READ_BUSES - 1 := 0;
|
104 |
|
|
constant RDB_ALU : integer range 0 to OPEN8_READ_BUSES - 1 := 1;
|
105 |
|
|
constant RDB_TMR : integer range 0 to OPEN8_READ_BUSES - 1 := 2;
|
106 |
|
|
constant RDB_ETC : integer range 0 to OPEN8_READ_BUSES - 1 := 3;
|
107 |
|
|
constant RDB_LED : integer range 0 to OPEN8_READ_BUSES - 1 := 4;
|
108 |
|
|
constant RDB_DSW : integer range 0 to OPEN8_READ_BUSES - 1 := 5;
|
109 |
|
|
constant RDB_BTN : integer range 0 to OPEN8_READ_BUSES - 1 := 6;
|
110 |
|
|
constant RDB_SDLC : integer range 0 to OPEN8_READ_BUSES - 1 := 7;
|
111 |
|
|
constant RDB_SER : integer range 0 to OPEN8_READ_BUSES - 1 := 8;
|
112 |
|
|
constant RDB_ROM : integer range 0 to OPEN8_READ_BUSES - 1 := 9;
|
113 |
|
|
|
114 |
|
|
-- System configuration calculations - no adjustable parameters below this point
|
115 |
|
|
type OPEN8_BUS_ARRAY is array(0 to OPEN8_READ_BUSES - 1) of DATA_TYPE;
|
116 |
|
|
|
117 |
|
|
constant INIT_READ_BUS : OPEN8_BUS_ARRAY := (others => OPEN8_NULLBUS);
|
118 |
|
|
|
119 |
|
|
function merge_buses (x : in OPEN8_BUS_ARRAY) return DATA_TYPE;
|
120 |
|
|
|
121 |
|
|
-- Compute the stack start address based on the RAM size
|
122 |
|
|
constant RAM_Vector_Size : integer := ceil_log2(LRAM_Size - 1);
|
123 |
|
|
constant RAM_END_vector : std_logic_vector(RAM_Vector_Size - 1 downto 0)
|
124 |
|
|
:= (others => '1');
|
125 |
|
|
|
126 |
|
|
constant Stack_Start_Addr : ADDRESS_TYPE := LRAM_Address + RAM_END_vector;
|
127 |
|
|
|
128 |
|
|
end package;
|
129 |
|
|
|
130 |
|
|
package body open8_cfg is
|
131 |
|
|
|
132 |
|
|
function merge_buses (x : in OPEN8_BUS_ARRAY) return DATA_TYPE is
|
133 |
|
|
variable i : integer := 0;
|
134 |
|
|
variable retval : DATA_TYPE := x"00";
|
135 |
|
|
begin
|
136 |
|
|
retval := x"00";
|
137 |
|
|
for i in 0 to OPEN8_READ_BUSES - 1 loop
|
138 |
|
|
retval := retval or x(i);
|
139 |
|
|
end loop;
|
140 |
|
|
return retval;
|
141 |
|
|
end function;
|
142 |
|
|
|
143 |
|
|
end package body;
|