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

Subversion Repositories openfire2

[/] [openfire2/] [trunk/] [rtl/] [openfire_cpu.v] - Blame information for rev 3

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

Line No. Rev Author Line
1 3 toni32
/*      MODULE: openfire_cpu
2
 
3
        DESCRIPTION: This is the top module for the openfire processor, instantiating
4
the fetch, decode, execute, pipeline_ctrl, and register file modules.
5
 
6
AUTHOR:
7
Stephen Douglas Craven
8
Configurable Computing Lab
9
Virginia Tech
10
scraven@vt.edu
11
 
12
REVISION HISTORY:
13
Revision 0.2, 8/10/2005 SDC
14
Initial release
15
 
16
Revision 0.3, 12/17/2005 SDC
17
Fixed PC size bug
18
 
19
Revision 0.4  27/03/2007 Antonio J. Anton
20
Improved (interrupts, exceptions, msr)
21
Ripup of memory signals
22
 
23
COPYRIGHT:
24
Copyright (c) 2005 Stephen Douglas Craven
25
 
26
Permission is hereby granted, free of charge, to any person obtaining a copy of
27
this software and associated documentation files (the "Software"), to deal in
28
the Software without restriction, including without limitation the rights to
29
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
30
of the Software, and to permit persons to whom the Software is furnished to do
31
so, subject to the following conditions:
32
 
33
The above copyright notice and this permission notice shall be included in all
34
copies or substantial portions of the Software.
35
 
36
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42
SOFTWARE.  */
43
 
44
`include "openfire_define.v"
45
 
46
module openfire_cpu (
47
        clock, reset,
48
`ifdef ENABLE_INTERRUPTS
49
        interrupt,
50
`endif
51
`ifdef ENABLE_ALIGNMENT_EXCEPTION
52
        dmem_alignment_exception,
53
`endif
54
        dmem_addr,      dmem_data_in, dmem_data_out,                                            // ins/data ports
55
        dmem_we,        dmem_re,                  dmem_input_sel, dmem_done,
56
        imem_addr,      imem_data_in, imem_re,                  imem_done
57
);
58
 
59
input                           clock;
60
input                           reset;
61
input   [31:0]   dmem_data_in;
62
input   [31:0]   imem_data_in;
63
input                           dmem_done;
64
input                           imem_done;
65
`ifdef ENABLE_INTERRUPTS
66
input                           interrupt;
67
`endif
68
`ifdef ENABLE_ALIGNMENT_EXCEPTION
69
input                           dmem_alignment_exception;
70
`endif
71
 
72
output [31:0]    dmem_data_out;
73
output [31:0]    dmem_addr;
74
output [31:0]    imem_addr;
75
output                  imem_re;
76
output                  dmem_we;
77
output                  dmem_re;
78
output [1:0]     dmem_input_sel; //0=byte, 1=hw, 2=word
79
 
80
wire                                            branch_taken;
81
wire    [`A_SPACE+1:0]   pc_branch;
82
wire    [`A_SPACE+1:0]   pc_decode;
83
wire    [`A_SPACE+1:0]   pc_exe_rf;
84
wire    [31:0]                   instruction;
85
wire    [4:0]                            regA_addr;
86
wire    [4:0]                            regB_addr;
87
wire    [4:0]                            regD_addr;
88
wire    [31:0]                   immediate;
89
 
90
wire    [2:0]    alu_inputA_sel;
91
wire    [1:0]    alu_inputB_sel;
92
wire    [1:0]    alu_inputC_sel;
93
wire    [3:0]    alu_fns_sel;
94
wire    [2:0]    comparator_fns_sel;
95
wire                    we_alu_branch;
96
wire                    we_load;
97
wire                    we_store;
98
wire                    we_regfile;
99
wire    [3:0]    regfile_input_sel;
100
wire                    delay_bit;
101
wire [31:0] result;
102
 
103
wire [31:0]      regA;
104
wire [31:0]      regB;
105
wire [31:0]      regD;
106
wire                    update_carry;
107
wire                    stall_exe;
108
wire                    stall_decode;
109
wire                    stall_fetch;
110
wire                    instr_complete;
111
wire                    flush;
112
wire                    branch_instr;
113
 
114
`ifdef ENABLE_MSR_BIP
115
wire            update_msr_bip;
116
wire            value_msr_bip;
117
`endif
118
`ifdef ENABLE_INTERRUPTS
119
wire            int_ip;
120
wire            int_dc;
121
wire            set_msr_ie;
122
`endif
123
`ifdef ENABLE_EXCEPTIONS
124
wire    reset_msr_eip;
125
wire    insert_exception;
126
`endif
127
`ifdef ENABLE_OPCODE_EXCEPTION
128
wire    opcode_exception;
129
`endif
130
`ifdef ENABLE_MSR_OPCODES
131
wire    rS_update;
132
`endif
133
 
134
openfire_fetch  FETCH (
135
        .stall(stall_fetch),
136
        .clock(clock),
137
        .reset(reset),
138
        .branch_taken(branch_taken),
139
        .pc_branch(pc_branch),
140
        .idata(imem_data_in),
141
        .imem_addr(imem_addr),
142
        .imem_re(imem_re),
143
        .pc_decode(pc_decode),
144
        .instruction(instruction)
145
);
146
 
147
openfire_decode DECODE (
148
`ifdef ENABLE_MSR_BIP
149
        .update_msr_bip(update_msr_bip),
150
        .value_msr_bip(value_msr_bip),
151
`endif
152
`ifdef ENABLE_INTERRUPTS
153
        .int_ip(int_ip),
154
        .int_dc(int_dc),
155
        .set_msr_ie(set_msr_ie),
156
`endif
157
`ifdef ENABLE_EXCEPTIONS
158
        .reset_msr_eip(reset_msr_eip),
159
        .insert_exception(insert_exception),
160
`endif
161
`ifdef ENABLE_OPCODE_EXCEPTION
162
        .opcode_exception(opcode_exception),
163
`endif
164
`ifdef ENABLE_MSR_OPCODES
165
        .rS_update(rs_update),
166
`endif
167
        .clock(clock),
168
        .stall(stall_decode),
169
        .reset(reset),
170
        .pc_decode(pc_decode),
171
        .instruction(instruction),
172
        .regA_addr(regA_addr),
173
        .regB_addr(regB_addr),
174
        .regD_addr(regD_addr),
175
        .immediate(immediate),
176
        .pc_exe(pc_exe_rf),
177
        .alu_inputA_sel(alu_inputA_sel),
178
        .alu_inputB_sel(alu_inputB_sel),
179
        .alu_inputC_sel(alu_inputC_sel),
180
        .alu_fns_sel(alu_fns_sel),
181
        .comparator_fns_sel(comparator_fns_sel),
182
        .branch_instr(branch_instr),
183
        .we_alu_branch(we_alu_branch),
184
        .we_load(we_load),
185
        .we_store(we_store),
186
        .regfile_input_sel(regfile_input_sel),
187
        .dmem_input_sel(dmem_input_sel),
188
        .flush(flush),
189
        .delay_bit(delay_bit),
190
        .update_carry(update_carry)
191
);
192
 
193
openfire_execute        EXECUTE (
194
`ifdef ENABLE_MSR_BIP
195
        .update_msr_bip(update_msr_bip),
196
        .value_msr_bip(value_msr_bip),
197
`endif
198
`ifdef ENABLE_INTERRUPTS
199
        .interrupt(interrupt),
200
        .int_ip(int_ip),
201
        .int_dc(int_dc),
202
        .set_msr_ie(set_msr_ie),
203
`endif
204
`ifdef ENABLE_EXCEPTIONS
205
        .reset_msr_eip(reset_msr_eip),
206
        .insert_exception(insert_exception),
207
`endif
208
`ifdef ENABLE_OPCODE_EXCEPTION
209
        .opcode_exception(opcode_exception),
210
`endif
211
`ifdef ENABLE_ALIGNMENT_EXCEPTION
212
        .dmem_alignment_exception(dmem_alignment_exception),
213
`endif
214
`ifdef ENABLE_MSR_OPCODES
215
        .rS_update(rs_update),
216
`endif
217
        .clock(clock),
218
        .reset(reset),
219
        .stall(stall_exe),
220
        .immediate(immediate),
221
        .pc_exe(pc_exe_rf),
222
        .alu_inputA_sel(alu_inputA_sel),
223
        .alu_inputB_sel(alu_inputB_sel),
224
        .alu_inputC_sel(alu_inputC_sel),
225
        .alu_fns_sel(alu_fns_sel),
226
        .comparator_fns_sel(comparator_fns_sel),
227
        .we_load(we_load),
228
        .we_store(we_store),
229
        .update_carry(update_carry),
230
        .regA(regA),
231
        .regB(regB),
232
        .regD(regD),
233
        .alu_result(result),
234
   .pc_branch(pc_branch),
235
        .branch_instr(branch_instr),
236
        .branch_taken(branch_taken),
237
        .instr_complete(instr_complete),
238
        .dmem_addr(dmem_addr),
239
        .dmem_data_out(dmem_data_out),
240
        .dmem_done(dmem_done),
241
        .we_regfile(we_regfile),
242
        .dmem_we(dmem_we),
243
        .dmem_re(dmem_re)
244
);
245
 
246
openfire_regfile        REGFILE (
247
        .reset(reset),
248
        .clock(clock),
249
        .regA_addr(regA_addr),
250
        .regB_addr(regB_addr),
251
        .regD_addr(regD_addr),
252
        .result(result),
253
        .pc_regfile(pc_exe_rf),
254
        .dmem_data(dmem_data_in),
255
        .regfile_input_sel(regfile_input_sel),
256
        .we_regfile(we_regfile),
257
        .we_alu_branch(we_alu_branch),
258
        .regA(regA),
259
        .regB(regB),
260
        .regD(regD),
261
        .enable(~stall_exe)
262
);
263
 
264
openfire_pipeline_ctrl PIPELINE (
265
        .clock(clock),
266
        .reset(reset),
267
        .flush(flush),
268
        .imem_done(imem_done),
269
        .imem_re(imem_re),
270
        .branch_taken(branch_taken),
271
        .instr_complete(instr_complete),
272
        .delay_bit(delay_bit),
273
        .stall_fetch(stall_fetch),
274
        .stall_decode(stall_decode),
275
        .stall_exe(stall_exe)
276
);
277
 
278
endmodule

powered by: WebSVN 2.1.0

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