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

Subversion Repositories ax8

[/] [ax8/] [trunk/] [rtl/] [vhdl/] [A90S1200.vhd] - Blame information for rev 5

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

Line No. Rev Author Line
1 5 jesus
--
2
-- 90S1200 compatible microcontroller core
3
--
4
-- Version : 0220b
5
--
6
-- Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
7
--
8
-- All rights reserved
9
--
10
-- Redistribution and use in source and synthezised forms, with or without
11
-- modification, are permitted provided that the following conditions are met:
12
--
13
-- Redistributions of source code must retain the above copyright notice,
14
-- this list of conditions and the following disclaimer.
15
--
16
-- Redistributions in synthesized form must reproduce the above copyright
17
-- notice, this list of conditions and the following disclaimer in the
18
-- documentation and/or other materials provided with the distribution.
19
--
20
-- Neither the name of the author nor the names of other contributors may
21
-- be used to endorse or promote products derived from this software without
22
-- specific prior written permission.
23
--
24
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
28
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
-- POSSIBILITY OF SUCH DAMAGE.
35
--
36
-- Please report bugs to the author, but before you do so, please
37
-- make sure that this is not a derivative work and that
38
-- you have the latest version of this file.
39
--
40
-- The latest version of this file can be found at:
41
--      http://www.opencores.org/cvsweb.shtml/t51/
42
--
43
-- Limitations :
44
--
45
-- File history :
46
--
47
 
48
--Registers:                                                                                            Comments:
49
--$3F SREG Status Register                                                                      Implemented in the AX8 core
50
--$3B GIMSK General Interrupt Mask register
51
--$39 TIMSK Timer/Counter Interrupt Mask register
52
--$38 TIFR Timer/Counter Interrupt Flag register
53
--$35 MCUCR MCU general Control Register                                        No power down
54
--$33 TCCR0 Timer/Counter 0 Control Register
55
--$32 TCNT0 Timer/Counter 0 (8-bit)
56
--$21 WDTCR Watchdog Timer Control Register                                     Not implemented
57
--$1E EEAR EEPROM Address Register                                                      Not implemented
58
--$1D EEDR EEPROM Data Register                                                         Not implemented
59
--$1C EECR EEPROM Control Register                                                      Not implemented
60
--$18 PORTB Data Register, Port B                                                       No pullup
61
--$17 DDRB Data Direction Register, Port B
62
--$16 PINB Input Pins, Port B
63
--$12 PORTD Data Register, Port D                                                       No pullup
64
--$11 DDRD Data Direction Register, Port D
65
--$10 PIND Input Pins, Port D
66
--$08 ACSR Analog Comparator Control and Status Register        Not implemented
67
 
68
library IEEE;
69
use IEEE.std_logic_1164.all;
70
use work.AX_Pack.all;
71
 
72
entity A90S1200 is
73
        generic(
74
                SyncReset : boolean := true
75
        );
76
        port(
77
                Clk             : in std_logic;
78
                Reset_n : in std_logic;
79
                INT0    : in std_logic;
80
                T0              : in std_logic;
81
                Port_B  : inout std_logic_vector(7 downto 0);
82
                Port_D  : inout std_logic_vector(7 downto 0)
83
        );
84
end A90S1200;
85
 
86
architecture rtl of A90S1200 is
87
 
88
        constant        ROMAddressWidth         : integer := 9;
89
        constant        RAMAddressWidth         : integer := 0;
90
        constant        BigISet                         : boolean := false;
91
 
92
        component ROM1200
93
                port(
94
                        Clk     : in std_logic;
95
                        A       : in std_logic_vector(ROMAddressWidth - 1 downto 0);
96
                        D       : out std_logic_vector(15 downto 0)
97
                );
98
        end component;
99
 
100
        signal  Reset_s_n       : std_logic;
101
        signal  ROM_Addr        : std_logic_vector(ROMAddressWidth - 1 downto 0);
102
        signal  ROM_Data        : std_logic_vector(15 downto 0);
103
        signal  IO_Rd           : std_logic;
104
        signal  IO_Wr           : std_logic;
105
        signal  IO_Addr         : std_logic_vector(5 downto 0);
106
        signal  IO_WData        : std_logic_vector(7 downto 0);
107
        signal  IO_RData        : std_logic_vector(7 downto 0);
108
        signal  TCCR_Sel        : std_logic;
109
        signal  TCNT_Sel        : std_logic;
110
        signal  PORTB_Sel       : std_logic;
111
        signal  DDRB_Sel        : std_logic;
112
        signal  PINB_Sel        : std_logic;
113
        signal  PORTD_Sel       : std_logic;
114
        signal  DDRD_Sel        : std_logic;
115
        signal  PIND_Sel        : std_logic;
116
        signal  Sleep_En        : std_logic;
117
        signal  ISC0            : std_logic_vector(1 downto 0);
118
        signal  Int0_ET         : std_logic;
119
        signal  Int0_En         : std_logic;
120
        signal  Int0_r          : std_logic_vector(1 downto 0);
121
        signal  TC_Trig         : std_logic;
122
        signal  TOIE0           : std_logic;
123
        signal  TOV0            : std_logic;
124
        signal  Int_Trig        : std_logic_vector(15 downto 1);
125
        signal  Int_Acc         : std_logic_vector(15 downto 1);
126
 
127
begin
128
 
129
        -- Synchronise reset
130
        process (Reset_n, Clk)
131
                variable Reset_v : std_logic;
132
        begin
133
                if Reset_n = '0' then
134
                        if SyncReset then
135
                                Reset_s_n <= '0';
136
                                Reset_v := '0';
137
                        end if;
138
                elsif Clk'event and Clk = '1' then
139
                        if SyncReset then
140
                                Reset_s_n <= Reset_v;
141
                                Reset_v := '1';
142
                        end if;
143
                end if;
144
        end process;
145
 
146
        g_reset : if not SyncReset generate
147
                Reset_s_n <= Reset_n;
148
        end generate;
149
 
150
        -- Registers/Interrupts
151
        IO_RData <= "00" & Sleep_En & "000" & ISC0 when IO_Rd = '1' and IO_Addr = "110101" else "ZZZZZZZZ";     -- $35 MCUCR
152
        IO_RData <= "0" & Int0_En & "000000" when IO_Rd = '1' and IO_Addr = "111011" else "ZZZZZZZZ";            -- $3B GIMSK
153
        IO_RData <= "000000" & TOIE0 & "0" when IO_Rd = '1' and IO_Addr = "111001" else "ZZZZZZZZ";              -- $39 TIMSK
154
        IO_RData <= "000000" & TOV0 & "0" when IO_Rd = '1' and IO_Addr = "111000" else "ZZZZZZZZ";               -- $38 TIFR
155
        process (Reset_s_n, Clk)
156
        begin
157
                if Reset_s_n = '0' then
158
                        Sleep_En <= '0';
159
                        ISC0 <= "00";
160
                        Int0_ET <= '0';
161
                        Int0_En <= '0';
162
                        Int0_r <= "11";
163
                        TOIE0 <= '0';
164
                        TOV0 <= '0';
165
                elsif Clk'event and Clk = '1' then
166
                        Int0_r(0) <= INT0;
167
                        Int0_r(1) <= Int0_r(0);
168
                        if IO_Wr = '1' and IO_Addr = "110101" then      -- $35 MCUCR
169
                                Sleep_En <= IO_WData(5);
170
                                ISC0 <= IO_WData(1 downto 0);
171
                        end if;
172
                        if IO_Wr = '1' and IO_Addr = "111011" then      -- $3B GIMSK
173
                                Int0_En <= IO_WData(6);
174
                        end if;
175
                        if IO_Wr = '1' and IO_Addr = "111001" then      -- $39 TIMSK
176
                                TOIE0 <= IO_WData(1);
177
                        end if;
178
                        if IO_Wr = '1' and IO_Addr = "111000" then      -- $38 TIFR
179
                                if IO_WData(1) = '1' then
180
                                        TOV0 <= '0';
181
                                end if;
182
                        end if;
183
                        if Int_Acc(2) = '1' then
184
                                TOV0 <= '0';
185
                        end if;
186
                        if TC_Trig = '1' then
187
                                TOV0 <= '1';
188
                        end if;
189
                        if Int_Acc(1) = '1' then
190
                                Int0_ET <= '0';
191
                        end if;
192
                        if (ISC0 = "10" and Int0_r = "10") or (ISC0 = "11" and Int0_r = "01") then
193
                                Int0_ET <= '1';
194
                        end if;
195
                end if;
196
        end process;
197
 
198
        Int_Trig(1) <= '0' when Int0_En = '0' else not Int0_r(1) when ISC0 = "00" else Int0_ET;
199
        Int_Trig(2) <= '1' when TOIE0 = '1' and TOV0 = '0' else '0';
200
        Int_Trig(15 downto 3) <= (others => '0');
201
 
202
        rom : ROM1200 port map (
203
                        Clk => Clk,
204
                        A => ROM_Addr,
205
                        D => ROM_Data);
206
 
207
        ax : AX8
208
                generic map(
209
                        ROMAddressWidth => ROMAddressWidth,
210
                        RAMAddressWidth => RAMAddressWidth,
211
                        BigIset => BigIset)
212
                port map (
213
                        Clk => Clk,
214
                        Reset_n => Reset_s_n,
215
                        ROM_Addr => ROM_Addr,
216
                        ROM_Data => ROM_Data,
217
                        Sleep_En => Sleep_En,
218
                        Int_Trig => Int_Trig,
219
                        Int_Acc => Int_Acc,
220
                        IO_Rd => IO_Rd,
221
                        IO_Wr => IO_Wr,
222
                        IO_Addr => IO_Addr,
223
                        IO_WData => IO_WData,
224
                        IO_RData => IO_RData);
225
 
226
        TCCR_Sel <= '1' when IO_Addr = "110011" else '0';        -- $33 TCCR0
227
        TCNT_Sel <= '1' when IO_Addr = "110010" else '0';        -- $32 TCNT0
228
        tc : AX_TC8 port map(
229
                        Clk => Clk,
230
                        Reset_n => Reset_s_n,
231
                        T => T0,
232
                        TCCR_Sel => TCCR_Sel,
233
                        TCNT_Sel => TCNT_Sel,
234
                        Rd => IO_Rd,
235
                        Wr => IO_Wr,
236
                        Data_In => IO_WData,
237
                        Data_Out => IO_RData,
238
                        Int  => TC_Trig);
239
 
240
        PINB_Sel <= '1' when IO_Addr = "010101" else '0';
241
        DDRB_Sel <= '1' when IO_Addr = "010111" else '0';
242
        PORTB_Sel <= '1' when IO_Addr = "011000" else '0';
243
        PIND_Sel <= '1' when IO_Addr = "010000" else '0';
244
        DDRD_Sel <= '1' when IO_Addr = "010001" else '0';
245
        PORTD_Sel <= '1' when IO_Addr = "010010" else '0';
246
        porta : AX_Port port map(
247
                        Clk => Clk,
248
                        Reset_n => Reset_s_n,
249
                        PORT_Sel => PORTB_Sel,
250
                        DDR_Sel => DDRB_Sel,
251
                        PIN_Sel => PINB_Sel,
252
                        Rd => IO_Rd,
253
                        Wr => IO_Wr,
254
                        Data_In => IO_WData,
255
                        Data_Out => IO_RData,
256
                        IOPort  => Port_B);
257
        portb : AX_Port port map(
258
                        Clk => Clk,
259
                        Reset_n => Reset_s_n,
260
                        PORT_Sel => PORTD_Sel,
261
                        DDR_Sel => DDRD_Sel,
262
                        PIN_Sel => PIND_Sel,
263
                        Rd => IO_Rd,
264
                        Wr => IO_Wr,
265
                        Data_In => IO_WData,
266
                        Data_Out => IO_RData,
267
                        IOPort  => Port_D);
268
 
269
end;

powered by: WebSVN 2.1.0

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