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

Subversion Repositories RISCMCU

[/] [RISCMCU/] [trunk/] [vhdl/] [v_riscmcu.vhd] - Blame information for rev 8

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

Line No. Rev Author Line
1 8 yapzihe
----------------------------------------------------------------------------
2
----                                                                    ----
3
---- WISHBONE RISCMCU IP Core                                           ----
4
----                                                                    ----
5
---- This file is part of the RISCMCU project                           ----
6
---- http://www.opencores.org/projects/riscmcu/                         ----
7
----                                                                    ----
8
---- Description                                                        ----
9
---- Implementation of a RISC Microcontroller based on Atmel AVR        ----
10
---- AT90S1200 instruction set and features with Altera Flex10k20 FPGA. ----
11
----                                                                    ----
12
---- Author(s):                                                         ----
13
----    - Yap Zi He, yapzihe@hotmail.com                                ----
14
----                                                                    ----
15
----------------------------------------------------------------------------
16
----                                                                    ----
17
---- Copyright (C) 2001 Authors and OPENCORES.ORG                       ----
18
----                                                                    ----
19
---- This source file may be used and distributed without               ----
20
---- restriction provided that this copyright statement is not          ----
21
---- removed from the file and that any derivative work contains        ----
22
---- the original copyright notice and the associated disclaimer.       ----
23
----                                                                    ----
24
---- This source file is free software; you can redistribute it         ----
25
---- and/or modify it under the terms of the GNU Lesser General         ----
26
---- Public License as published by the Free Software Foundation;       ----
27
---- either version 2.1 of the License, or (at your option) any         ----
28
---- later version.                                                     ----
29
----                                                                    ----
30
---- This source is distributed in the hope that it will be             ----
31
---- useful, but WITHOUT ANY WARRANTY; without even the implied         ----
32
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR            ----
33
---- PURPOSE. See the GNU Lesser General Public License for more        ----
34
---- details.                                                           ----
35
----                                                                    ----
36
---- You should have received a copy of the GNU Lesser General          ----
37
---- Public License along with this source; if not, download it         ----
38
---- from http://www.opencores.org/lgpl.shtml                           ----
39
----                                                                    ----
40
----------------------------------------------------------------------------
41
 
42
library ieee;
43
use ieee.std_logic_1164.all;
44
 
45
entity v_riscmcu is
46
        port (
47
                clock : in STD_LOGIC;
48
                reset : in STD_LOGIC;
49
                pinb : inout STD_LOGIC_VECTOR(7 downto 0);
50
                pinc : inout STD_LOGIC_VECTOR(7 downto 0);
51
                pind : inout STD_LOGIC_VECTOR(7 downto 0)
52
        );
53
end v_riscmcu;
54
 
55
architecture riscmcu of v_riscmcu is
56
 
57
signal extpin : std_logic;
58
 
59
signal clk, clrn, div2, div4, div8, div16 : std_logic;
60
signal sr, reg_rd, reg_rr, c, addrbus: std_logic_vector(7 downto 0);
61
 
62
signal pc, offset : std_logic_vector(8 downto 0);
63
signal instruction, ir : std_logic_vector(15 downto 0);
64
 
65
signal skip, en, wr_reg : std_logic;
66
signal sren : std_logic_vector (6 downto 0);
67
signal c2a, c2b, add, subcp, logic, right, dir, pass_a : std_logic;
68
signal wcarry : std_logic;
69
signal logicsel : integer range 0 to 3;
70
signal rightsel : integer range 0 to 2;
71
signal dirsel : integer range 0 to 1;
72
signal addoffset, push, pull, cpse, skiptest : std_logic;
73
signal bclr,bset, bld, cbisbi : std_logic;
74
signal dest, rr, rd : integer range 0 to 15;
75
signal srsel : integer range 0 to 7;
76
signal imm_value : std_logic_vector(7 downto 0);
77
 
78
signal tosr : std_logic_vector (6 downto 0);
79
 
80
signal vec2, vec4, clr_i, set_i, clr_tov0, clr_intf, timerirq, extirq : std_logic;
81
 
82
signal rd_sreg,wr_sreg,rd_gimsk,wr_gimsk,rd_timsk, wr_timsk, rd_tifr,wr_tifr : std_logic;
83
signal rd_mcucr,wr_mcucr, rd_tccr0, wr_tccr0, rd_tcnt0,wr_tcnt0 : std_logic;
84
signal rd_portb,wr_portb,rd_ddrb,wr_ddrb,rd_pinb : std_logic;
85
signal rd_portc,wr_portc,rd_ddrc,wr_ddrc,rd_pinc : std_logic;
86
signal rd_portd,wr_portd,rd_ddrd,wr_ddrd,rd_pind : std_logic;
87
 
88
signal t_flag, c_flag : std_logic;
89
 
90
signal vcc, gnd : std_logic;
91
 
92
signal rd_ram, wr_ram, ld_mar, ld_mbr, inc_zp, dec_zp :std_logic;
93
 
94
signal bitsel : integer range 0 to 7;
95
signal set : std_logic;
96
 
97
signal asel : integer range 0 to 1;
98
signal bsel : integer range 0 to 3;
99
 
100
        component v_freqdiv
101
        port (  clock : in std_logic;
102
                div2, div4, div8, div16 : buffer std_logic
103
        );
104
        end component;
105
 
106
        component v_pc
107
        port (  offset : in std_logic_vector(8 downto 0);
108
                en, addoffset, push, pull, vec2, vec4 : in std_logic;
109
                clk, clrn : in std_logic;
110
                pc : buffer std_logic_vector(8 downto 0)
111
        );
112
        end component;
113
 
114
        component v_rom
115
        port (  pc : in std_logic_vector(8 downto 0);
116
                instruction : out std_logic_vector(15 downto 0)
117
        );
118
        end component;
119
 
120
        component v_ir
121
        port (  instruction : in std_logic_vector(15 downto 0);
122
                en, clk, clrn : in std_logic;
123
                ir : buffer std_logic_vector(15 downto 0);
124
                imm_value : out std_logic_vector(7 downto 0);
125
                rd, rr : out integer range 0 to 15
126
        );
127
        end component;
128
 
129
        component v_controlunit
130
        port (  ir      : in std_logic_vector(15 downto 0);
131
                sr : in std_logic_vector(7 downto 0);
132
                clk, clrn : in std_logic;
133
                skip, extirq, timerirq : in std_logic;
134
 
135
                en : buffer std_logic;
136
                wr_reg : buffer std_logic;
137
                rd_ram, wr_ram, ld_mar, ld_mbr, inc_zp, dec_zp : out std_logic;
138
                sren : out std_logic_vector (6 downto 0);
139
 
140
                c2a,c2b : out std_logic;
141
                asel : out integer range 0 to 1;
142
                bsel : out integer range 0 to 3;
143
                bitsel : out integer range 0 to 7;
144
                set : out std_logic;
145
 
146
                add, subcp, logic, right, dir, pass_a : out std_logic;
147
 
148
                wcarry : out std_logic;
149
                logicsel : out integer range 0 to 3;
150
                rightsel : out integer range 0 to 2;
151
                dirsel : out integer range 0 to 1;
152
 
153
                addoffset : out std_logic;
154
                push, pull : out std_logic;
155
 
156
                cpse, skiptest : out std_logic;
157
 
158
                bclr,bset : out std_logic;
159
                bld : out std_logic;
160
 
161
                cbisbi : out std_logic;
162
 
163
                vec2, vec4 : buffer std_logic;
164
 
165
                dest : out integer range 0 to 15;
166
                srsel : out integer range 0 to 7;
167
                offset : out std_logic_vector(8 downto 0);
168
 
169
                clr_i, set_i, clr_intf, clr_tov0 : out std_logic;
170
 
171
                rd_sreg, wr_sreg : out std_logic;
172
                rd_gimsk, wr_gimsk, rd_timsk, wr_timsk, rd_tifr,wr_tifr : out std_logic;
173
                rd_mcucr,wr_mcucr, rd_tccr0, wr_tccr0, rd_tcnt0,wr_tcnt0 : out std_logic;
174
                rd_portb, wr_portb, rd_ddrb, wr_ddrb, rd_pinb : out std_logic;
175
                rd_portc, wr_portc, rd_ddrc, wr_ddrc, rd_pinc : out std_logic;
176
                rd_portd, wr_portd, rd_ddrd, wr_ddrd, rd_pind : out std_logic
177
        );
178
        end component;
179
 
180
        component v_gpr
181
        port (  c : in std_logic_vector(7 downto 0);
182
                wr_reg, inc_zp, dec_zp : in std_logic;
183
                rd, rr, dest : in integer range 0 to 15;
184
                clk, clrn : in std_logic;
185
                reg_rd, reg_rr, addrbus : out std_logic_vector(7 downto 0)
186
        );
187
        end component;
188
 
189
        component v_alu
190
        port (  reg_rd, reg_rr, imm_value : in std_logic_vector(7 downto 0);
191
                c2a, c2b : in std_logic;
192
                asel : in integer range 0 to 1;
193
                bsel : in integer range 0 to 3;
194
 
195
                bitsel : in integer range 0 to 7;
196
                set : in std_logic;
197
                c_flag, t_flag : in std_logic;
198
 
199
                add, subcp, logic, right, dir, bld, cbisbi, pass_a : in std_logic;
200
                cpse, skiptest : in std_logic;
201
 
202
                wcarry : in std_logic;
203
                logicsel : in integer range 0 to 3;
204
                rightsel : in integer range 0 to 2;
205
                dirsel : in integer range 0 to 1;
206
 
207
                clk, clrn : in std_logic;
208
 
209
                c : buffer std_logic_vector(7 downto 0);
210
                tosr : buffer std_logic_vector (6 downto 0);
211
                skip : out std_logic
212
        );
213
        end component;
214
 
215
        component v_sr
216
        port (  clk,clrn: in std_logic;
217
                        sren,tosr : in std_logic_vector(6 downto 0);
218
                        srsel : in integer range 0 to 7;
219
                        clr_i,set_i,bset,bclr : in std_logic;
220
                        rd_sreg, wr_sreg : in std_logic;
221
                        c : inout std_logic_vector(7 downto 0);
222
                        sr : inout std_logic_vector(7 downto 0)
223
        );
224
        end component;
225
 
226
        component v_ram
227
        port (  addrbus : in std_logic_vector(7 downto 0);
228
                rd_ram, wr_ram, ld_mar, ld_mbr : in std_logic;
229
                clk, clrn : in std_logic;
230
                c : inout std_logic_vector(7 downto 0)
231
        );
232
        end component;
233
 
234
        component v_port
235
        port (  rd_port, wr_port, rd_ddr, wr_ddr, rd_pin : in std_logic;
236
                clk, clrn : in std_logic;
237
                c : inout std_logic_vector(7 downto 0);
238
                pin : inout std_logic_vector(7 downto 0)
239
        );
240
        end component;
241
 
242
        component v_timer
243
        port (  extpin, clr_tov0 : in std_logic;
244
                rd_timsk, wr_timsk, rd_tifr, wr_tifr : in std_logic;
245
                rd_tccr0, wr_tccr0, rd_tcnt0, wr_tcnt0 : in std_logic;
246
                clk, clrn : in std_logic;
247
                c : inout std_logic_vector(7 downto 0);
248
                timerirq : out std_logic
249
        );
250
        end component;
251
 
252
        component v_extint
253
        port (  clk, clrn, extpin, clr_intf : in std_logic;
254
                rd_mcucr, wr_mcucr, rd_gimsk, wr_gimsk : in std_logic;
255
                extirq  : out std_logic;
256
                c : inout std_logic_vector(7 downto 0)
257
        );
258
        end component;
259
 
260
begin
261
 
262
        U_v_freqdiv: v_freqdiv
263
                port map (clock, div2, div4, div8, div16);
264
 
265
        U_v_pc: v_pc
266
                port map (offset, en, addoffset, push, pull, vec2, vec4, clk, clrn, pc);
267
 
268
        U_v_rom: v_rom
269
                port map (pc, instruction);
270
 
271
        U_v_ir: v_ir
272
                port map (instruction, en, clk, clrn, ir, imm_value, rd, rr);
273
 
274
        U_v_controlunit: v_controlunit
275
                port map (ir, sr, clk, clrn, skip, extirq, timerirq, en, wr_reg, rd_ram, wr_ram, ld_mar, ld_mbr, inc_zp, dec_zp, sren, c2a, c2b, asel, bsel, bitsel, set, add, subcp, logic, right, dir, pass_a, wcarry, logicsel, rightsel, dirsel, addoffset, push, pull, cpse, skiptest, bclr, bset, bld, cbisbi, vec2, vec4, dest, srsel, offset, clr_i, set_i, clr_intf, clr_tov0, rd_sreg, wr_sreg, rd_gimsk, wr_gimsk, rd_timsk, wr_timsk, rd_tifr, wr_tifr, rd_mcucr, wr_mcucr, rd_tccr0, wr_tccr0, rd_tcnt0, wr_tcnt0, rd_portb, wr_portb, rd_ddrb, wr_ddrb, rd_pinb, rd_portc, wr_portc, rd_ddrc, wr_ddrc, rd_pinc, rd_portd, wr_portd, rd_ddrd, wr_ddrd, rd_pind);
276
 
277
        U_v_gpr: v_gpr
278
                port map (c, wr_reg, inc_zp, dec_zp, rd, rr, dest, clk, clrn, reg_rd, reg_rr, addrbus);
279
 
280
        U_v_alu: v_alu
281
                port map (reg_rd, reg_rr, imm_value, c2a, c2b, asel, bsel, bitsel, set, c_flag, t_flag, add, subcp, logic, right, dir, bld, cbisbi, pass_a, cpse, skiptest, wcarry, logicsel, rightsel, dirsel, clk, clrn, c, tosr, skip);
282
 
283
        U_v_sr: v_sr
284
                port map (clk, clrn, sren, tosr, srsel, clr_i, set_i, bset, bclr, rd_sreg, wr_sreg, c, sr);
285
 
286
        U_v_ram: v_ram
287
                port map (addrbus, rd_ram, wr_ram, ld_mar, ld_mbr, clk, clrn, c);
288
 
289
        U_v_timer: v_timer
290
                port map (extpin, clr_tov0, rd_timsk, wr_timsk, rd_tifr, wr_tifr, rd_tccr0, wr_tccr0, rd_tcnt0, wr_tcnt0, clk, clrn, c, timerirq);
291
 
292
        U_v_extint: v_extint
293
                port map (clk, clrn, extpin, clr_intf, rd_mcucr, wr_mcucr, rd_gimsk, wr_gimsk, extirq, c);
294
 
295
 
296
        U_v_portB: v_port
297
                port map (rd_portb, wr_portb, rd_ddrb, wr_ddrb, rd_pinb, clk, clrn, c, pinb);
298
 
299
        U_v_portC: v_port
300
                port map (rd_portc, wr_portc, rd_ddrc, wr_ddrc, rd_pinc, clk, clrn, c, pinc);
301
 
302
        U_v_portD: v_port
303
                port map (rd_portd, wr_portd, rd_ddrd, wr_ddrd, rd_pind, clk, clrn, c, pind);
304
 
305
        extpin <= pind(7);
306
        clrn <= reset;
307
        clk <= div4;
308
        vcc <= '1';
309
        gnd <= '0';
310
        t_flag <= sr(6);
311
        c_flag <= sr(0);
312
 
313
end riscmcu;
314
 
315
 

powered by: WebSVN 2.1.0

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