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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_23/] [or1200/] [rtl/] [verilog/] [or1200_defines.v] - Blame information for rev 1132

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's definitions                                        ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Parameters of the OR1200 core                               ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - add parameters that are missing                          ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 1132 lampret
// Revision 1.31  2002/12/08 08:57:56  lampret
48
// Added optional support for WB B3 specification (xwb_cti_o, xwb_bte_o). Made xwb_cab_o optional.
49
//
50 1104 lampret
// Revision 1.30  2002/10/28 15:09:22  mohor
51
// Previous check-in was done by mistake.
52
//
53 1078 mohor
// Revision 1.29  2002/10/28 15:03:50  mohor
54
// Signal scanb_sen renamed to scanb_en.
55 1077 mohor
//
56
// Revision 1.28  2002/10/17 20:04:40  lampret
57
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
58
//
59 1063 lampret
// Revision 1.27  2002/09/16 03:13:23  lampret
60
// Removed obsolete comment.
61
//
62 1055 lampret
// Revision 1.26  2002/09/08 05:52:16  lampret
63
// Added optional l.div/l.divu insns. By default they are disabled.
64
//
65 1035 lampret
// Revision 1.25  2002/09/07 19:16:10  lampret
66
// If SR[CY] implemented with OR1200_IMPL_ADDC enabled, l.add/l.addi also set SR[CY].
67
//
68 1033 lampret
// Revision 1.24  2002/09/07 05:42:02  lampret
69
// Added optional SR[CY]. Added define to enable additional (compare) flag modifiers. Defines are OR1200_IMPL_ADDC and OR1200_ADDITIONAL_FLAG_MODIFIERS.
70
//
71 1032 lampret
// Revision 1.23  2002/09/04 00:50:34  lampret
72
// Now most of the configuration registers are updatded automatically based on defines in or1200_defines.v.
73
//
74 1023 lampret
// Revision 1.22  2002/09/03 22:28:21  lampret
75
// As per Taylor Su suggestion all case blocks are full case by default and optionally (OR1200_CASE_DEFAULT) can be disabled to increase clock frequncy.
76
//
77 1022 lampret
// Revision 1.21  2002/08/22 02:18:55  lampret
78
// Store buffer has been tested and it works. BY default it is still disabled until uClinux confirms correct operation on FPGA board.
79
//
80 994 lampret
// Revision 1.20  2002/08/18 21:59:45  lampret
81
// Disable SB until it is tested
82
//
83 984 lampret
// Revision 1.19  2002/08/18 19:53:08  lampret
84
// Added store buffer.
85
//
86 977 lampret
// Revision 1.18  2002/08/15 06:04:11  lampret
87
// Fixed Xilinx trace buffer address. REported by Taylor Su.
88
//
89 962 lampret
// Revision 1.17  2002/08/12 05:31:44  lampret
90
// Added OR1200_WB_RETRY. Moved WB registered outsputs / samples inputs into lower section.
91
//
92 944 lampret
// Revision 1.16  2002/07/14 22:17:17  lampret
93
// Added simple trace buffer [only for Xilinx Virtex target]. Fixed instruction fetch abort when new exception is recognized.
94
//
95 895 lampret
// Revision 1.15  2002/06/08 16:20:21  lampret
96
// Added defines for enabling generic FF based memory macro for register file.
97
//
98 870 lampret
// Revision 1.14  2002/03/29 16:24:06  lampret
99
// Changed comment about synopsys to _synopsys_ because synthesis was complaining about unknown directives
100
//
101 790 lampret
// Revision 1.13  2002/03/29 15:16:55  lampret
102
// Some of the warnings fixed.
103
//
104 788 lampret
// Revision 1.12  2002/03/28 19:25:42  lampret
105
// Added second type of Virtual Silicon two-port SRAM (for register file). Changed defines for VS STP RAMs.
106
//
107 778 lampret
// Revision 1.11  2002/03/28 19:13:17  lampret
108
// Updated defines.
109
//
110 776 lampret
// Revision 1.10  2002/03/14 00:30:24  lampret
111
// Added alternative for critical path in DU.
112
//
113 737 lampret
// Revision 1.9  2002/03/11 01:26:26  lampret
114
// Fixed async loop. Changed multiplier type for ASIC.
115
//
116 735 lampret
// Revision 1.8  2002/02/11 04:33:17  lampret
117
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
118
//
119 660 lampret
// Revision 1.7  2002/02/01 19:56:54  lampret
120
// Fixed combinational loops.
121
//
122 636 lampret
// Revision 1.6  2002/01/19 14:10:22  lampret
123
// Fixed OR1200_XILINX_RAM32X1D.
124
//
125 597 lampret
// Revision 1.5  2002/01/18 07:56:00  lampret
126
// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.
127
//
128 589 lampret
// Revision 1.4  2002/01/14 09:44:12  lampret
129
// Default ASIC configuration does not sample WB inputs.
130
//
131 569 lampret
// Revision 1.3  2002/01/08 00:51:08  lampret
132
// Fixed typo. OR1200_REGISTERED_OUTPUTS was not defined. Should be.
133
//
134 536 lampret
// Revision 1.2  2002/01/03 21:23:03  lampret
135
// Uncommented OR1200_REGISTERED_OUTPUTS for FPGA target.
136
//
137 512 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
138
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
139
//
140 504 lampret
// Revision 1.20  2001/12/04 05:02:36  lampret
141
// Added OR1200_GENERIC_MULTP2_32X32 and OR1200_ASIC_MULTP2_32X32
142
//
143
// Revision 1.19  2001/11/27 19:46:57  lampret
144
// Now FPGA and ASIC target are separate.
145
//
146
// Revision 1.18  2001/11/23 21:42:31  simons
147
// Program counter divided to PPC and NPC.
148
//
149
// Revision 1.17  2001/11/23 08:38:51  lampret
150
// Changed DSR/DRR behavior and exception detection.
151
//
152
// Revision 1.16  2001/11/20 21:30:38  lampret
153
// Added OR1200_REGISTERED_INPUTS.
154
//
155
// Revision 1.15  2001/11/19 14:29:48  simons
156
// Cashes disabled.
157
//
158
// Revision 1.14  2001/11/13 10:02:21  lampret
159
// Added 'setpc'. Renamed some signals (except_flushpipe into flushpipe etc)
160
//
161
// Revision 1.13  2001/11/12 01:45:40  lampret
162
// Moved flag bit into SR. Changed RF enable from constant enable to dynamic enable for read ports.
163
//
164
// Revision 1.12  2001/11/10 03:43:57  lampret
165
// Fixed exceptions.
166
//
167
// Revision 1.11  2001/11/02 18:57:14  lampret
168
// Modified virtual silicon instantiations.
169
//
170
// Revision 1.10  2001/10/21 17:57:16  lampret
171
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
172
//
173
// Revision 1.9  2001/10/19 23:28:46  lampret
174
// Fixed some synthesis warnings. Configured with caches and MMUs.
175
//
176
// Revision 1.8  2001/10/14 13:12:09  lampret
177
// MP3 version.
178
//
179
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
180
// no message
181
//
182
// Revision 1.3  2001/08/17 08:01:19  lampret
183
// IC enable/disable.
184
//
185
// Revision 1.2  2001/08/13 03:36:20  lampret
186
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
187
//
188
// Revision 1.1  2001/08/09 13:39:33  lampret
189
// Major clean-up.
190
//
191
// Revision 1.2  2001/07/22 03:31:54  lampret
192
// Fixed RAM's oen bug. Cache bypass under development.
193
//
194
// Revision 1.1  2001/07/20 00:46:03  lampret
195
// Development version of RTL. Libraries are missing.
196
//
197
//
198
 
199
//
200
// Dump VCD
201
//
202
//`define OR1200_VCD_DUMP
203
 
204
//
205
// Generate debug messages during simulation
206
//
207
//`define OR1200_VERBOSE
208
 
209 1078 mohor
//  `define OR1200_ASIC
210 504 lampret
////////////////////////////////////////////////////////
211
//
212
// Typical configuration for an ASIC
213
//
214
`ifdef OR1200_ASIC
215
 
216
//
217
// Target ASIC memories
218
//
219
//`define OR1200_ARTISAN_SSP
220
//`define OR1200_ARTISAN_SDP
221
//`define OR1200_ARTISAN_STP
222
`define OR1200_VIRTUALSILICON_SSP
223 1077 mohor
//`define OR1200_VIRTUALSILICON_STP_T1
224 778 lampret
//`define OR1200_VIRTUALSILICON_STP_T2
225 504 lampret
 
226
//
227
// Do not implement Data cache
228
//
229
//`define OR1200_NO_DC
230
 
231
//
232
// Do not implement Insn cache
233
//
234
//`define OR1200_NO_IC
235
 
236
//
237
// Do not implement Data MMU
238
//
239
//`define OR1200_NO_DMMU
240
 
241
//
242
// Do not implement Insn MMU
243
//
244
//`define OR1200_NO_IMMU
245
 
246
//
247 944 lampret
// Select between ASIC optimized and generic multiplier
248 504 lampret
//
249 735 lampret
//`define OR1200_ASIC_MULTP2_32X32
250
`define OR1200_GENERIC_MULTP2_32X32
251 504 lampret
 
252
//
253
// Size/type of insn/data cache if implemented
254
//
255
// `define OR1200_IC_1W_4KB
256
`define OR1200_IC_1W_8KB
257
// `define OR1200_DC_1W_4KB
258
`define OR1200_DC_1W_8KB
259
 
260
`else
261
 
262
 
263
/////////////////////////////////////////////////////////
264
//
265
// Typical configuration for an FPGA
266
//
267
 
268
//
269
// Target FPGA memories
270
//
271 1132 lampret
//`define OR1200_ALTERA_LPM
272 504 lampret
`define OR1200_XILINX_RAMB4
273 776 lampret
//`define OR1200_XILINX_RAM32X1D
274 895 lampret
//`define OR1200_USE_RAM16X1D_FOR_RAM32X1D
275 504 lampret
 
276
//
277
// Do not implement Data cache
278
//
279
//`define OR1200_NO_DC
280
 
281
//
282
// Do not implement Insn cache
283
//
284
//`define OR1200_NO_IC
285
 
286
//
287
// Do not implement Data MMU
288
//
289
//`define OR1200_NO_DMMU
290
 
291
//
292
// Do not implement Insn MMU
293
//
294
//`define OR1200_NO_IMMU
295
 
296
//
297 944 lampret
// Select between ASIC and generic multiplier
298 504 lampret
//
299 944 lampret
// (Generic seems to trigger a bug in the Cadence Ncsim simulator)
300 504 lampret
//
301
//`define OR1200_ASIC_MULTP2_32X32
302
`define OR1200_GENERIC_MULTP2_32X32
303
 
304
//
305
// Size/type of insn/data cache if implemented
306
// (consider available FPGA memory resources)
307
//
308
`define OR1200_IC_1W_4KB
309
//`define OR1200_IC_1W_8KB
310
`define OR1200_DC_1W_4KB
311
//`define OR1200_DC_1W_8KB
312
 
313
`endif
314
 
315
 
316
//////////////////////////////////////////////////////////
317
//
318
// Do not change below unless you know what you are doing
319
//
320
 
321 788 lampret
//
322 1063 lampret
// Enable RAM BIST
323
//
324
// At the moment this only works for Virtual Silicon
325
// single port RAMs. For other RAMs it has not effect.
326
// Special wrapper for VS RAMs needs to be provided
327
// with scan flops to facilitate bist scan.
328
//
329 1078 mohor
//`define OR1200_BIST
330 1063 lampret
 
331
//
332 944 lampret
// Register OR1200 WISHBONE outputs
333
// (must be defined/enabled)
334
//
335
`define OR1200_REGISTERED_OUTPUTS
336
 
337
//
338
// Register OR1200 WISHBONE inputs
339
//
340
// (must be undefined/disabled)
341
//
342
//`define OR1200_REGISTERED_INPUTS
343
 
344
//
345 895 lampret
// Disable bursts if they are not supported by the
346
// memory subsystem (only affect cache line fill)
347
//
348
//`define OR1200_NO_BURSTS
349
//
350
 
351
//
352 944 lampret
// WISHBONE retry counter range
353
//
354
// 2^value range for retry counter. Retry counter
355
// is activated whenever *wb_rty_i is asserted and
356
// until retry counter expires, corresponding
357
// WISHBONE interface is deactivated.
358
//
359
// To disable retry counters and *wb_rty_i all together,
360
// undefine this macro.
361
//
362
//`define OR1200_WB_RETRY 7
363
 
364
//
365 1104 lampret
// WISHBONE Consecutive Address Burst
366
//
367
// This was used prior to WISHBONE B3 specification
368
// to identify bursts. It is no longer needed but
369
// remains enabled for compatibility with old designs.
370
//
371
// To remove *wb_cab_o ports undefine this macro.
372
//
373
`define OR1200_WB_CAB
374
 
375
//
376
// WISHBONE B3 compatible interface
377
//
378
// This follows the WISHBONE B3 specification.
379
// It is not enabled by default because most
380
// designs still don't use WB b3.
381
//
382
// To enable *wb_cti_o/*wb_bte_o ports,
383
// define this macro.
384
//
385
//`define OR1200_WB_B3
386
 
387
//
388 788 lampret
// Enable additional synthesis directives if using
389 790 lampret
// _Synopsys_ synthesis tool
390 788 lampret
//
391
//`define OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
392
 
393
//
394 1022 lampret
// Enables default statement in some case blocks
395
// and disables Synopsys synthesis directive full_case
396
//
397
// By default it is enabled. When disabled it
398
// can increase clock frequency.
399
//
400
`define OR1200_CASE_DEFAULT
401
 
402
//
403 504 lampret
// Operand width / register file address width
404 788 lampret
//
405
// (DO NOT CHANGE)
406
//
407 504 lampret
`define OR1200_OPERAND_WIDTH            32
408
`define OR1200_REGFILE_ADDR_WIDTH       5
409
 
410
//
411 1032 lampret
// l.add/l.addi/l.and and optional l.addc/l.addic
412
// also set (compare) flag when result of their
413
// operation equals zero
414
//
415
// At the time of writing this, default or32
416
// C/C++ compiler doesn't generate code that
417
// would benefit from this optimization.
418
//
419
// By default this optimization is disabled to
420
// save area.
421
//
422
//`define OR1200_ADDITIONAL_FLAG_MODIFIERS
423
 
424
//
425
// Implement l.addc/l.addic instructions and SR[CY]
426
//
427
// At the time of writing this, or32
428
// C/C++ compiler doesn't generate l.addc/l.addic
429
// instructions. However or32 assembler
430
// can assemble code that uses l.addc/l.addic insns.
431
//
432
// By default implementation of l.addc/l.addic
433
// instructions and SR[CY] is disabled to save
434
// area.
435
//
436 1033 lampret
// [Because this define controles implementation
437
//  of SR[CY] write enable, if it is not enabled,
438
//  l.add/l.addi also don't set SR[CY].]
439
//
440 1032 lampret
//`define OR1200_IMPL_ADDC
441
 
442
//
443 1035 lampret
// Implement optional l.div/l.divu instructions
444
//
445
// By default divide instructions are not implemented
446
// to save area and increase clock frequency. or32 C/C++
447
// compiler can use soft library for division.
448
//
449
//`define OR1200_IMPL_DIV
450
 
451
//
452 504 lampret
// Implement rotate in the ALU
453
//
454 1032 lampret
// At the time of writing this, or32
455
// C/C++ compiler doesn't generate rotate
456
// instructions. However or32 assembler
457
// can assemble code that uses rotate insn.
458
// This means that rotate instructions
459
// must be used manually inserted.
460
//
461
// By default implementation of rotate
462
// is disabled to save area and increase
463
// clock frequency.
464
//
465 504 lampret
//`define OR1200_IMPL_ALU_ROTATE
466
 
467
//
468
// Type of ALU compare to implement
469
//
470 1032 lampret
// Try either one to find what yields
471
// higher clock frequencyin your case.
472
//
473 504 lampret
//`define OR1200_IMPL_ALU_COMP1
474
`define OR1200_IMPL_ALU_COMP2
475
 
476
//
477
// Select between low-power (larger) multiplier or faster multiplier
478
//
479 776 lampret
//`define OR1200_LOWPWR_MULT
480 504 lampret
 
481
//
482
// Clock synchronization for RISC clk and WB divided clocks
483
//
484
// If you plan to run WB:RISC clock 1:1, you can comment these two
485
//
486
`define OR1200_CLKDIV_2_SUPPORTED
487 776 lampret
//`define OR1200_CLKDIV_4_SUPPORTED
488 504 lampret
 
489
//
490
// Type of register file RAM
491
//
492 1132 lampret
// Memory macro w/ two ports (see or1200_tpram_32x32.v)
493 504 lampret
// `define OR1200_RFRAM_TWOPORT
494 870 lampret
//
495 1132 lampret
// Memory macro dual port (see or1200_dpram_32x32.v)
496 870 lampret
`define OR1200_RFRAM_DUALPORT
497
//
498 1132 lampret
// Generic (flip-flop based) register file (see or1200_rfram_generic.v)
499
//`define OR1200_RFRAM_GENERIC
500 504 lampret
 
501
//
502 776 lampret
// Type of mem2reg aligner to implement.
503 504 lampret
//
504 776 lampret
// Once OR1200_IMPL_MEM2REG2 yielded faster
505
// circuit, however with today tools it will
506
// most probably give you slower circuit.
507
//
508
`define OR1200_IMPL_MEM2REG1
509
//`define OR1200_IMPL_MEM2REG2
510 504 lampret
 
511
//
512
// ALUOPs
513
//
514
`define OR1200_ALUOP_WIDTH      4
515 636 lampret
`define OR1200_ALUOP_NOP        4'd4
516 504 lampret
/* Order defined by arith insns that have two source operands both in regs
517
   (see binutils/include/opcode/or32.h) */
518
`define OR1200_ALUOP_ADD        4'd0
519
`define OR1200_ALUOP_ADDC       4'd1
520
`define OR1200_ALUOP_SUB        4'd2
521
`define OR1200_ALUOP_AND        4'd3
522 636 lampret
`define OR1200_ALUOP_OR         4'd4
523 504 lampret
`define OR1200_ALUOP_XOR        4'd5
524
`define OR1200_ALUOP_MUL        4'd6
525
`define OR1200_ALUOP_SHROT      4'd8
526
`define OR1200_ALUOP_DIV        4'd9
527
`define OR1200_ALUOP_DIVU       4'd10
528
/* Order not specifically defined. */
529
`define OR1200_ALUOP_IMM        4'd11
530
`define OR1200_ALUOP_MOVHI      4'd12
531
`define OR1200_ALUOP_COMP       4'd13
532
`define OR1200_ALUOP_MTSR       4'd14
533
`define OR1200_ALUOP_MFSR       4'd15
534
 
535
//
536
// MACOPs
537
//
538
`define OR1200_MACOP_WIDTH      2
539
`define OR1200_MACOP_NOP        2'b00
540
`define OR1200_MACOP_MAC        2'b01
541
`define OR1200_MACOP_MSB        2'b10
542
 
543
//
544
// Shift/rotate ops
545
//
546
`define OR1200_SHROTOP_WIDTH    2
547
`define OR1200_SHROTOP_NOP      2'd0
548
`define OR1200_SHROTOP_SLL      2'd0
549
`define OR1200_SHROTOP_SRL      2'd1
550
`define OR1200_SHROTOP_SRA      2'd2
551
`define OR1200_SHROTOP_ROR      2'd3
552
 
553
// Execution cycles per instruction
554
`define OR1200_MULTICYCLE_WIDTH 2
555
`define OR1200_ONE_CYCLE                2'd0
556
`define OR1200_TWO_CYCLES               2'd1
557
 
558
// Operand MUX selects
559
`define OR1200_SEL_WIDTH                2
560
`define OR1200_SEL_RF                   2'd0
561
`define OR1200_SEL_IMM                  2'd1
562
`define OR1200_SEL_EX_FORW              2'd2
563
`define OR1200_SEL_WB_FORW              2'd3
564
 
565
//
566
// BRANCHOPs
567
//
568
`define OR1200_BRANCHOP_WIDTH           3
569
`define OR1200_BRANCHOP_NOP             3'd0
570
`define OR1200_BRANCHOP_J               3'd1
571
`define OR1200_BRANCHOP_JR              3'd2
572
`define OR1200_BRANCHOP_BAL             3'd3
573
`define OR1200_BRANCHOP_BF              3'd4
574
`define OR1200_BRANCHOP_BNF             3'd5
575
`define OR1200_BRANCHOP_RFE             3'd6
576
 
577
//
578
// LSUOPs
579
//
580
// Bit 0: sign extend
581
// Bits 1-2: 00 doubleword, 01 byte, 10 halfword, 11 singleword
582
// Bit 3: 0 load, 1 store
583
`define OR1200_LSUOP_WIDTH              4
584
`define OR1200_LSUOP_NOP                4'b0000
585
`define OR1200_LSUOP_LBZ                4'b0010
586
`define OR1200_LSUOP_LBS                4'b0011
587
`define OR1200_LSUOP_LHZ                4'b0100
588
`define OR1200_LSUOP_LHS                4'b0101
589
`define OR1200_LSUOP_LWZ                4'b0110
590
`define OR1200_LSUOP_LWS                4'b0111
591
`define OR1200_LSUOP_LD         4'b0001
592
`define OR1200_LSUOP_SD         4'b1000
593
`define OR1200_LSUOP_SB         4'b1010
594
`define OR1200_LSUOP_SH         4'b1100
595
`define OR1200_LSUOP_SW         4'b1110
596
 
597
// FETCHOPs
598
`define OR1200_FETCHOP_WIDTH            1
599
`define OR1200_FETCHOP_NOP              1'b0
600
`define OR1200_FETCHOP_LW               1'b1
601
 
602
//
603
// Register File Write-Back OPs
604
//
605
// Bit 0: register file write enable
606
// Bits 2-1: write-back mux selects
607
`define OR1200_RFWBOP_WIDTH             3
608
`define OR1200_RFWBOP_NOP               3'b000
609
`define OR1200_RFWBOP_ALU               3'b001
610
`define OR1200_RFWBOP_LSU               3'b011
611
`define OR1200_RFWBOP_SPRS              3'b101
612
`define OR1200_RFWBOP_LR                3'b111
613
 
614
// Compare instructions
615
`define OR1200_COP_SFEQ       3'b000
616
`define OR1200_COP_SFNE       3'b001
617
`define OR1200_COP_SFGT       3'b010
618
`define OR1200_COP_SFGE       3'b011
619
`define OR1200_COP_SFLT       3'b100
620
`define OR1200_COP_SFLE       3'b101
621
`define OR1200_COP_X          3'b111
622
`define OR1200_SIGNED_COMPARE 'd3
623
`define OR1200_COMPOP_WIDTH     4
624
 
625
//
626
// TAGs for instruction bus
627
//
628
`define OR1200_ITAG_IDLE        4'h0    // idle bus
629
`define OR1200_ITAG_NI          4'h1    // normal insn
630
`define OR1200_ITAG_BE          4'hb    // Bus error exception
631
`define OR1200_ITAG_PE          4'hc    // Page fault exception
632
`define OR1200_ITAG_TE          4'hd    // TLB miss exception
633
 
634
//
635
// TAGs for data bus
636
//
637
`define OR1200_DTAG_IDLE        4'h0    // idle bus
638
`define OR1200_DTAG_ND          4'h1    // normal data
639
`define OR1200_DTAG_AE          4'ha    // Alignment exception
640
`define OR1200_DTAG_BE          4'hb    // Bus error exception
641
`define OR1200_DTAG_PE          4'hc    // Page fault exception
642
`define OR1200_DTAG_TE          4'hd    // TLB miss exception
643
 
644
 
645
//////////////////////////////////////////////
646
//
647
// ORBIS32 ISA specifics
648
//
649
 
650
// SHROT_OP position in machine word
651
`define OR1200_SHROTOP_POS              7:6
652
 
653
// ALU instructions multicycle field in machine word
654
`define OR1200_ALUMCYC_POS              9:8
655
 
656
//
657
// Instruction opcode groups (basic)
658
//
659
`define OR1200_OR32_J                 6'b000000
660
`define OR1200_OR32_JAL               6'b000001
661
`define OR1200_OR32_BNF               6'b000011
662
`define OR1200_OR32_BF                6'b000100
663
`define OR1200_OR32_NOP               6'b000101
664
`define OR1200_OR32_MOVHI             6'b000110
665
`define OR1200_OR32_XSYNC             6'b001000
666
`define OR1200_OR32_RFE               6'b001001
667
/* */
668
`define OR1200_OR32_JR                6'b010001
669
`define OR1200_OR32_JALR              6'b010010
670
`define OR1200_OR32_MACI              6'b010011
671
/* */
672
`define OR1200_OR32_LWZ               6'b100001
673
`define OR1200_OR32_LBZ               6'b100011
674
`define OR1200_OR32_LBS               6'b100100
675
`define OR1200_OR32_LHZ               6'b100101
676
`define OR1200_OR32_LHS               6'b100110
677
`define OR1200_OR32_ADDI              6'b100111
678
`define OR1200_OR32_ADDIC             6'b101000
679
`define OR1200_OR32_ANDI              6'b101001
680
`define OR1200_OR32_ORI               6'b101010
681
`define OR1200_OR32_XORI              6'b101011
682
`define OR1200_OR32_MULI              6'b101100
683
`define OR1200_OR32_MFSPR             6'b101101
684
`define OR1200_OR32_SH_ROTI           6'b101110
685
`define OR1200_OR32_SFXXI             6'b101111
686
/* */
687
`define OR1200_OR32_MTSPR             6'b110000
688
`define OR1200_OR32_MACMSB            6'b110001
689
/* */
690
`define OR1200_OR32_SW                6'b110101
691
`define OR1200_OR32_SB                6'b110110
692
`define OR1200_OR32_SH                6'b110111
693
`define OR1200_OR32_ALU               6'b111000
694
`define OR1200_OR32_SFXX              6'b111001
695
 
696
 
697
/////////////////////////////////////////////////////
698
//
699
// Exceptions
700
//
701
`define OR1200_EXCEPT_WIDTH 4
702
`define OR1200_EXCEPT_UNUSED            `OR1200_EXCEPT_WIDTH'hf
703
`define OR1200_EXCEPT_TRAP              `OR1200_EXCEPT_WIDTH'he
704
`define OR1200_EXCEPT_BREAK             `OR1200_EXCEPT_WIDTH'hd
705
`define OR1200_EXCEPT_SYSCALL           `OR1200_EXCEPT_WIDTH'hc
706
`define OR1200_EXCEPT_RANGE             `OR1200_EXCEPT_WIDTH'hb
707
`define OR1200_EXCEPT_ITLBMISS          `OR1200_EXCEPT_WIDTH'ha
708
`define OR1200_EXCEPT_DTLBMISS          `OR1200_EXCEPT_WIDTH'h9
709 589 lampret
`define OR1200_EXCEPT_INT               `OR1200_EXCEPT_WIDTH'h8
710 504 lampret
`define OR1200_EXCEPT_ILLEGAL           `OR1200_EXCEPT_WIDTH'h7
711
`define OR1200_EXCEPT_ALIGN             `OR1200_EXCEPT_WIDTH'h6
712 589 lampret
`define OR1200_EXCEPT_TICK              `OR1200_EXCEPT_WIDTH'h5
713 504 lampret
`define OR1200_EXCEPT_IPF               `OR1200_EXCEPT_WIDTH'h4
714
`define OR1200_EXCEPT_DPF               `OR1200_EXCEPT_WIDTH'h3
715
`define OR1200_EXCEPT_BUSERR            `OR1200_EXCEPT_WIDTH'h2
716
`define OR1200_EXCEPT_RESET             `OR1200_EXCEPT_WIDTH'h1
717
`define OR1200_EXCEPT_NONE              `OR1200_EXCEPT_WIDTH'h0
718
 
719
 
720
/////////////////////////////////////////////////////
721
//
722
// SPR groups
723
//
724
 
725
// Bits that define the group
726
`define OR1200_SPR_GROUP_BITS   15:11
727
 
728
// Width of the group bits
729
`define OR1200_SPR_GROUP_WIDTH  5
730
 
731
// Bits that define offset inside the group
732
`define OR1200_SPR_OFS_BITS 10:0
733
 
734
// List of groups
735
`define OR1200_SPR_GROUP_SYS    5'd00
736
`define OR1200_SPR_GROUP_DMMU   5'd01
737
`define OR1200_SPR_GROUP_IMMU   5'd02
738
`define OR1200_SPR_GROUP_DC     5'd03
739
`define OR1200_SPR_GROUP_IC     5'd04
740
`define OR1200_SPR_GROUP_MAC    5'd05
741
`define OR1200_SPR_GROUP_DU     5'd06
742
`define OR1200_SPR_GROUP_PM     5'd08
743
`define OR1200_SPR_GROUP_PIC    5'd09
744
`define OR1200_SPR_GROUP_TT     5'd10
745
 
746
 
747
/////////////////////////////////////////////////////
748
//
749
// System group
750
//
751
 
752
//
753
// System registers
754
//
755
`define OR1200_SPR_CFGR         7'd0
756
`define OR1200_SPR_RF           6'd32   // 1024 >> 5
757
`define OR1200_SPR_NPC          11'd16
758
`define OR1200_SPR_SR           11'd17
759
`define OR1200_SPR_PPC          11'd18
760
`define OR1200_SPR_EPCR         11'd32
761
`define OR1200_SPR_EEAR         11'd48
762
`define OR1200_SPR_ESR          11'd64
763
 
764
//
765
// SR bits
766
//
767 589 lampret
`define OR1200_SR_WIDTH 16
768
`define OR1200_SR_SM   0
769
`define OR1200_SR_TEE  1
770
`define OR1200_SR_IEE  2
771 504 lampret
`define OR1200_SR_DCE  3
772
`define OR1200_SR_ICE  4
773
`define OR1200_SR_DME  5
774
`define OR1200_SR_IME  6
775
`define OR1200_SR_LEE  7
776
`define OR1200_SR_CE   8
777
`define OR1200_SR_F    9
778 589 lampret
`define OR1200_SR_CY   10       // Unused
779
`define OR1200_SR_OV   11       // Unused
780
`define OR1200_SR_OVE  12       // Unused
781
`define OR1200_SR_DSX  13       // Unused
782
`define OR1200_SR_EPH  14
783
`define OR1200_SR_FO   15
784
`define OR1200_SR_CID  31:28    // Unimplemented
785 504 lampret
 
786
// Bits that define offset inside the group
787
`define OR1200_SPROFS_BITS 10:0
788
 
789
 
790
/////////////////////////////////////////////////////
791
//
792
// Power Management (PM)
793
//
794
 
795
// Define it if you want PM implemented
796
`define OR1200_PM_IMPLEMENTED
797
 
798
// Bit positions inside PMR (don't change)
799
`define OR1200_PM_PMR_SDF 3:0
800
`define OR1200_PM_PMR_DME 4
801
`define OR1200_PM_PMR_SME 5
802
`define OR1200_PM_PMR_DCGE 6
803
`define OR1200_PM_PMR_UNUSED 31:7
804
 
805
// PMR offset inside PM group of registers
806
`define OR1200_PM_OFS_PMR 11'b0
807
 
808
// PM group
809
`define OR1200_SPRGRP_PM 5'd8
810
 
811
// Define if PMR can be read/written at any address inside PM group
812
`define OR1200_PM_PARTIAL_DECODING
813
 
814
// Define if reading PMR is allowed
815
`define OR1200_PM_READREGS
816
 
817
// Define if unused PMR bits should be zero
818
`define OR1200_PM_UNUSED_ZERO
819
 
820
 
821
/////////////////////////////////////////////////////
822
//
823
// Debug Unit (DU)
824
//
825
 
826
// Define it if you want DU implemented
827
`define OR1200_DU_IMPLEMENTED
828
 
829 895 lampret
// Define if you want trace buffer
830
// (for now only available for Xilinx Virtex FPGAs)
831 962 lampret
`ifdef OR1200_ASIC
832
`else
833 895 lampret
`define OR1200_DU_TB_IMPLEMENTED
834 962 lampret
`endif
835 895 lampret
 
836 504 lampret
// Address offsets of DU registers inside DU group
837 895 lampret
`define OR1200_DU_OFS_DMR1 11'd16
838
`define OR1200_DU_OFS_DMR2 11'd17
839
`define OR1200_DU_OFS_DSR 11'd20
840
`define OR1200_DU_OFS_DRR 11'd21
841 962 lampret
`define OR1200_DU_OFS_TBADR 11'h0ff
842
`define OR1200_DU_OFS_TBIA 11'h1xx
843
`define OR1200_DU_OFS_TBIM 11'h2xx
844
`define OR1200_DU_OFS_TBAR 11'h3xx
845
`define OR1200_DU_OFS_TBTS 11'h4xx
846 504 lampret
 
847
// Position of offset bits inside SPR address
848 895 lampret
`define OR1200_DUOFS_BITS 10:0
849 504 lampret
 
850
// Define if you want these DU registers to be implemented
851
`define OR1200_DU_DMR1
852
`define OR1200_DU_DMR2
853
`define OR1200_DU_DSR
854
`define OR1200_DU_DRR
855
 
856
// DMR1 bits
857
`define OR1200_DU_DMR1_ST 22
858
 
859
// DSR bits
860
`define OR1200_DU_DSR_WIDTH     14
861
`define OR1200_DU_DSR_RSTE      0
862
`define OR1200_DU_DSR_BUSEE     1
863
`define OR1200_DU_DSR_DPFE      2
864
`define OR1200_DU_DSR_IPFE      3
865 589 lampret
`define OR1200_DU_DSR_TTE       4
866 504 lampret
`define OR1200_DU_DSR_AE        5
867
`define OR1200_DU_DSR_IIE       6
868 589 lampret
`define OR1200_DU_DSR_IE        7
869 504 lampret
`define OR1200_DU_DSR_DME       8
870
`define OR1200_DU_DSR_IME       9
871
`define OR1200_DU_DSR_RE        10
872
`define OR1200_DU_DSR_SCE       11
873
`define OR1200_DU_DSR_BE        12
874
`define OR1200_DU_DSR_TE        13
875
 
876
// DRR bits
877
`define OR1200_DU_DRR_RSTE      0
878
`define OR1200_DU_DRR_BUSEE     1
879
`define OR1200_DU_DRR_DPFE      2
880
`define OR1200_DU_DRR_IPFE      3
881 589 lampret
`define OR1200_DU_DRR_TTE       4
882 504 lampret
`define OR1200_DU_DRR_AE        5
883
`define OR1200_DU_DRR_IIE       6
884 589 lampret
`define OR1200_DU_DRR_IE        7
885 504 lampret
`define OR1200_DU_DRR_DME       8
886
`define OR1200_DU_DRR_IME       9
887
`define OR1200_DU_DRR_RE        10
888
`define OR1200_DU_DRR_SCE       11
889
`define OR1200_DU_DRR_BE        12
890
`define OR1200_DU_DRR_TE        13
891
 
892
// Define if reading DU regs is allowed
893
`define OR1200_DU_READREGS
894
 
895
// Define if unused DU registers bits should be zero
896
`define OR1200_DU_UNUSED_ZERO
897
 
898
// DU operation commands
899
`define OR1200_DU_OP_READSPR    3'd4
900
`define OR1200_DU_OP_WRITESPR   3'd5
901
 
902 737 lampret
// Define if IF/LSU status is not needed by devel i/f
903
`define OR1200_DU_STATUS_UNIMPLEMENTED
904 504 lampret
 
905
/////////////////////////////////////////////////////
906
//
907
// Programmable Interrupt Controller (PIC)
908
//
909
 
910
// Define it if you want PIC implemented
911
`define OR1200_PIC_IMPLEMENTED
912
 
913
// Define number of interrupt inputs (2-31)
914
`define OR1200_PIC_INTS 20
915
 
916
// Address offsets of PIC registers inside PIC group
917
`define OR1200_PIC_OFS_PICMR 2'd0
918
`define OR1200_PIC_OFS_PICSR 2'd2
919
 
920
// Position of offset bits inside SPR address
921
`define OR1200_PICOFS_BITS 1:0
922
 
923
// Define if you want these PIC registers to be implemented
924
`define OR1200_PIC_PICMR
925
`define OR1200_PIC_PICSR
926
 
927
// Define if reading PIC registers is allowed
928
`define OR1200_PIC_READREGS
929
 
930
// Define if unused PIC register bits should be zero
931
`define OR1200_PIC_UNUSED_ZERO
932
 
933
 
934
/////////////////////////////////////////////////////
935
//
936
// Tick Timer (TT)
937
//
938
 
939
// Define it if you want TT implemented
940
`define OR1200_TT_IMPLEMENTED
941
 
942
// Address offsets of TT registers inside TT group
943
`define OR1200_TT_OFS_TTMR 1'd0
944
`define OR1200_TT_OFS_TTCR 1'd1
945
 
946
// Position of offset bits inside SPR group
947
`define OR1200_TTOFS_BITS 0
948
 
949
// Define if you want these TT registers to be implemented
950
`define OR1200_TT_TTMR
951
`define OR1200_TT_TTCR
952
 
953
// TTMR bits
954
`define OR1200_TT_TTMR_TP 27:0
955
`define OR1200_TT_TTMR_IP 28
956
`define OR1200_TT_TTMR_IE 29
957
`define OR1200_TT_TTMR_M 31:30
958
 
959
// Define if reading TT registers is allowed
960
`define OR1200_TT_READREGS
961
 
962
 
963
//////////////////////////////////////////////
964
//
965
// MAC
966
//
967
`define OR1200_MAC_ADDR         0        // MACLO 0xxxxxxxx1, MACHI 0xxxxxxxx0
968
`define OR1200_MAC_SPR_WE               // Define if MACLO/MACHI are SPR writable
969
 
970
 
971
//////////////////////////////////////////////
972
//
973
// Data MMU (DMMU)
974
//
975
 
976
//
977
// Address that selects between TLB TR and MR
978
//
979 660 lampret
`define OR1200_DTLB_TM_ADDR     7
980 504 lampret
 
981
//
982
// DTLBMR fields
983
//
984
`define OR1200_DTLBMR_V_BITS    0
985
`define OR1200_DTLBMR_CID_BITS  4:1
986
`define OR1200_DTLBMR_RES_BITS  11:5
987
`define OR1200_DTLBMR_VPN_BITS  31:13
988
 
989
//
990
// DTLBTR fields
991
//
992
`define OR1200_DTLBTR_CC_BITS   0
993
`define OR1200_DTLBTR_CI_BITS   1
994
`define OR1200_DTLBTR_WBC_BITS  2
995
`define OR1200_DTLBTR_WOM_BITS  3
996
`define OR1200_DTLBTR_A_BITS    4
997
`define OR1200_DTLBTR_D_BITS    5
998
`define OR1200_DTLBTR_URE_BITS  6
999
`define OR1200_DTLBTR_UWE_BITS  7
1000
`define OR1200_DTLBTR_SRE_BITS  8
1001
`define OR1200_DTLBTR_SWE_BITS  9
1002
`define OR1200_DTLBTR_RES_BITS  11:10
1003
`define OR1200_DTLBTR_PPN_BITS  31:13
1004
 
1005
//
1006
// DTLB configuration
1007
//
1008
`define OR1200_DMMU_PS          13                                      // 13 for 8KB page size
1009
`define OR1200_DTLB_INDXW       6                                       // 6 for 64 entry DTLB  7 for 128 entries
1010
`define OR1200_DTLB_INDXL       `OR1200_DMMU_PS                         // 13                   13
1011
`define OR1200_DTLB_INDXH       `OR1200_DMMU_PS+`OR1200_DTLB_INDXW-1    // 18                   19
1012
`define OR1200_DTLB_INDX        `OR1200_DTLB_INDXH:`OR1200_DTLB_INDXL   // 18:13                19:13
1013
`define OR1200_DTLB_TAGW        32-`OR1200_DTLB_INDXW-`OR1200_DMMU_PS   // 13                   12
1014
`define OR1200_DTLB_TAGL        `OR1200_DTLB_INDXH+1                    // 19                   20
1015
`define OR1200_DTLB_TAG         31:`OR1200_DTLB_TAGL                    // 31:19                31:20
1016
`define OR1200_DTLBMRW          `OR1200_DTLB_TAGW+1                     // +1 because of V bit
1017
`define OR1200_DTLBTRW          32-`OR1200_DMMU_PS+5                    // +5 because of protection bits and CI
1018
 
1019 660 lampret
//
1020
// Cache inhibit while DMMU is not enabled/implemented
1021
//
1022
// cache inhibited 0GB-4GB              1'b1
1023 735 lampret
// cache inhibited 0GB-2GB              !dcpu_adr_i[31]
1024
// cache inhibited 0GB-1GB 2GB-3GB      !dcpu_adr_i[30]
1025
// cache inhibited 1GB-2GB 3GB-4GB      dcpu_adr_i[30]
1026
// cache inhibited 2GB-4GB (default)    dcpu_adr_i[31]
1027 660 lampret
// cached 0GB-4GB                       1'b0
1028
//
1029
`define OR1200_DMMU_CI                  dcpu_adr_i[31]
1030 504 lampret
 
1031 660 lampret
 
1032 504 lampret
//////////////////////////////////////////////
1033
//
1034
// Insn MMU (IMMU)
1035
//
1036
 
1037
//
1038
// Address that selects between TLB TR and MR
1039
//
1040 660 lampret
`define OR1200_ITLB_TM_ADDR     7
1041 504 lampret
 
1042
//
1043
// ITLBMR fields
1044
//
1045
`define OR1200_ITLBMR_V_BITS    0
1046
`define OR1200_ITLBMR_CID_BITS  4:1
1047
`define OR1200_ITLBMR_RES_BITS  11:5
1048
`define OR1200_ITLBMR_VPN_BITS  31:13
1049
 
1050
//
1051
// ITLBTR fields
1052
//
1053
`define OR1200_ITLBTR_CC_BITS   0
1054
`define OR1200_ITLBTR_CI_BITS   1
1055
`define OR1200_ITLBTR_WBC_BITS  2
1056
`define OR1200_ITLBTR_WOM_BITS  3
1057
`define OR1200_ITLBTR_A_BITS    4
1058
`define OR1200_ITLBTR_D_BITS    5
1059
`define OR1200_ITLBTR_SXE_BITS  6
1060
`define OR1200_ITLBTR_UXE_BITS  7
1061
`define OR1200_ITLBTR_RES_BITS  11:8
1062
`define OR1200_ITLBTR_PPN_BITS  31:13
1063
 
1064
//
1065
// ITLB configuration
1066
//
1067
`define OR1200_IMMU_PS          13                                      // 13 for 8KB page size
1068
`define OR1200_ITLB_INDXW       6                                       // 6 for 64 entry ITLB  7 for 128 entries
1069
`define OR1200_ITLB_INDXL       `OR1200_IMMU_PS                         // 13                   13
1070
`define OR1200_ITLB_INDXH       `OR1200_IMMU_PS+`OR1200_ITLB_INDXW-1    // 18                   19
1071
`define OR1200_ITLB_INDX        `OR1200_ITLB_INDXH:`OR1200_ITLB_INDXL   // 18:13                19:13
1072
`define OR1200_ITLB_TAGW        32-`OR1200_ITLB_INDXW-`OR1200_IMMU_PS   // 13                   12
1073
`define OR1200_ITLB_TAGL        `OR1200_ITLB_INDXH+1                    // 19                   20
1074
`define OR1200_ITLB_TAG         31:`OR1200_ITLB_TAGL                    // 31:19                31:20
1075
`define OR1200_ITLBMRW          `OR1200_ITLB_TAGW+1                     // +1 because of V bit
1076
`define OR1200_ITLBTRW          32-`OR1200_IMMU_PS+3                    // +3 because of protection bits and CI
1077
 
1078 660 lampret
//
1079
// Cache inhibit while IMMU is not enabled/implemented
1080 735 lampret
// Note: all combinations that use icpu_adr_i cause async loop
1081 660 lampret
//
1082
// cache inhibited 0GB-4GB              1'b1
1083 735 lampret
// cache inhibited 0GB-2GB              !icpu_adr_i[31]
1084
// cache inhibited 0GB-1GB 2GB-3GB      !icpu_adr_i[30]
1085
// cache inhibited 1GB-2GB 3GB-4GB      icpu_adr_i[30]
1086
// cache inhibited 2GB-4GB (default)    icpu_adr_i[31]
1087 660 lampret
// cached 0GB-4GB                       1'b0
1088
//
1089 735 lampret
`define OR1200_IMMU_CI                  1'b0
1090 504 lampret
 
1091 660 lampret
 
1092 504 lampret
/////////////////////////////////////////////////
1093
//
1094
// Insn cache (IC)
1095
//
1096
 
1097
// 3 for 8 bytes, 4 for 16 bytes etc
1098
`define OR1200_ICLS             4
1099
 
1100
//
1101
// IC configurations
1102
//
1103
`ifdef OR1200_IC_1W_4KB
1104
`define OR1200_ICSIZE                   12                      // 4096
1105
`define OR1200_ICINDX                   `OR1200_ICSIZE-2        // 10
1106
`define OR1200_ICINDXH                  `OR1200_ICSIZE-1        // 11
1107
`define OR1200_ICTAGL                   `OR1200_ICINDXH+1       // 12
1108
`define OR1200_ICTAG                    `OR1200_ICSIZE-`OR1200_ICLS     // 8
1109
`define OR1200_ICTAG_W                  21
1110
`endif
1111
`ifdef OR1200_IC_1W_8KB
1112
`define OR1200_ICSIZE                   13                      // 8192
1113
`define OR1200_ICINDX                   `OR1200_ICSIZE-2        // 11
1114
`define OR1200_ICINDXH                  `OR1200_ICSIZE-1        // 12
1115
`define OR1200_ICTAGL                   `OR1200_ICINDXH+1       // 13
1116
`define OR1200_ICTAG                    `OR1200_ICSIZE-`OR1200_ICLS     // 9
1117
`define OR1200_ICTAG_W                  20
1118
`endif
1119
 
1120
 
1121
/////////////////////////////////////////////////
1122
//
1123
// Data cache (DC)
1124
//
1125
 
1126
// 3 for 8 bytes, 4 for 16 bytes etc
1127
`define OR1200_DCLS             4
1128
 
1129 636 lampret
// Define to perform store refill (potential performance penalty)
1130
// `define OR1200_DC_STORE_REFILL
1131
 
1132 504 lampret
//
1133
// DC configurations
1134
//
1135
`ifdef OR1200_DC_1W_4KB
1136
`define OR1200_DCSIZE                   12                      // 4096
1137
`define OR1200_DCINDX                   `OR1200_DCSIZE-2        // 10
1138
`define OR1200_DCINDXH                  `OR1200_DCSIZE-1        // 11
1139
`define OR1200_DCTAGL                   `OR1200_DCINDXH+1       // 12
1140
`define OR1200_DCTAG                    `OR1200_DCSIZE-`OR1200_DCLS     // 8
1141
`define OR1200_DCTAG_W                  21
1142
`endif
1143
`ifdef OR1200_DC_1W_8KB
1144
`define OR1200_DCSIZE                   13                      // 8192
1145
`define OR1200_DCINDX                   `OR1200_DCSIZE-2        // 11
1146
`define OR1200_DCINDXH                  `OR1200_DCSIZE-1        // 12
1147
`define OR1200_DCTAGL                   `OR1200_DCINDXH+1       // 13
1148
`define OR1200_DCTAG                    `OR1200_DCSIZE-`OR1200_DCLS     // 9
1149
`define OR1200_DCTAG_W                  20
1150
`endif
1151 994 lampret
 
1152
/////////////////////////////////////////////////
1153
//
1154
// Store buffer (SB)
1155
//
1156
 
1157
//
1158
// Store buffer
1159
//
1160
// It will improve performance by "caching" CPU stores
1161
// using store buffer. This is most important for function
1162
// prologues because DC can only work in write though mode
1163
// and all stores would have to complete external WB writes
1164
// to memory.
1165
// Store buffer is between DC and data BIU.
1166
// All stores will be stored into store buffer and immediately
1167
// completed by the CPU, even though actual external writes
1168
// will be performed later. As a consequence store buffer masks
1169
// all data bus errors related to stores (data bus errors
1170
// related to loads are delivered normally).
1171
// All pending CPU loads will wait until store buffer is empty to
1172
// ensure strict memory model. Right now this is necessary because
1173
// we don't make destinction between cached and cache inhibited
1174
// address space, so we simply empty store buffer until loads
1175
// can begin.
1176
//
1177
// It makes design a bit bigger, depending what is the number of
1178
// entries in SB FIFO. Number of entries can be changed further
1179
// down.
1180
//
1181
//`define OR1200_SB_IMPLEMENTED
1182
 
1183
//
1184
// Number of store buffer entries
1185
//
1186
// Verified number of entries are 4 and 8 entries
1187
// (2 and 3 for OR1200_SB_LOG). OR1200_SB_ENTRIES must
1188
// always match 2**OR1200_SB_LOG.
1189
// To disable store buffer, undefine
1190
// OR1200_SB_IMPLEMENTED.
1191
//
1192
`define OR1200_SB_LOG           2       // 2 or 3
1193
`define OR1200_SB_ENTRIES       4       // 4 or 8
1194 1023 lampret
 
1195
 
1196
/////////////////////////////////////////////////////
1197
//
1198
// VR, UPR and Configuration Registers
1199
//
1200
//
1201
// VR, UPR and configuration registers are optional. If 
1202
// implemented, operating system can automatically figure
1203
// out how to use the processor because it knows 
1204
// what units are available in the processor and how they
1205
// are configured.
1206
//
1207
// This section must be last in or1200_defines.v file so
1208
// that all units are already configured and thus
1209
// configuration registers are properly set.
1210
// 
1211
 
1212
// Define if you want configuration registers implemented
1213
`define OR1200_CFGR_IMPLEMENTED
1214
 
1215
// Define if you want full address decode inside SYS group
1216
`define OR1200_SYS_FULL_DECODE
1217
 
1218
// Offsets of VR, UPR and CFGR registers
1219
`define OR1200_SPRGRP_SYS_VR            4'h0
1220
`define OR1200_SPRGRP_SYS_UPR           4'h1
1221
`define OR1200_SPRGRP_SYS_CPUCFGR       4'h2
1222
`define OR1200_SPRGRP_SYS_DMMUCFGR      4'h3
1223
`define OR1200_SPRGRP_SYS_IMMUCFGR      4'h4
1224
`define OR1200_SPRGRP_SYS_DCCFGR        4'h5
1225
`define OR1200_SPRGRP_SYS_ICCFGR        4'h6
1226
`define OR1200_SPRGRP_SYS_DCFGR 4'h7
1227
 
1228
// VR fields
1229
`define OR1200_VR_REV_BITS              5:0
1230
`define OR1200_VR_RES1_BITS             15:6
1231
`define OR1200_VR_CFG_BITS              23:16
1232
`define OR1200_VR_VER_BITS              31:24
1233
 
1234
// VR values
1235
`define OR1200_VR_REV                   6'h00
1236
`define OR1200_VR_RES1                  10'h000
1237
`define OR1200_VR_CFG                   8'h00
1238
`define OR1200_VR_VER                   8'h12
1239
 
1240
// UPR fields
1241
`define OR1200_UPR_UP_BITS              0
1242
`define OR1200_UPR_DCP_BITS             1
1243
`define OR1200_UPR_ICP_BITS             2
1244
`define OR1200_UPR_DMP_BITS             3
1245
`define OR1200_UPR_IMP_BITS             4
1246
`define OR1200_UPR_MP_BITS              5
1247
`define OR1200_UPR_DUP_BITS             6
1248
`define OR1200_UPR_PCUP_BITS            7
1249
`define OR1200_UPR_PMP_BITS             8
1250
`define OR1200_UPR_PICP_BITS            9
1251
`define OR1200_UPR_TTP_BITS             10
1252
`define OR1200_UPR_RES1_BITS            23:11
1253
`define OR1200_UPR_CUP_BITS             31:24
1254
 
1255
// UPR values
1256
`define OR1200_UPR_UP                   1'b1
1257
`ifdef OR1200_NO_DC
1258
`define OR1200_UPR_DCP                  1'b0
1259
`else
1260
`define OR1200_UPR_DCP                  1'b1
1261
`endif
1262
`ifdef OR1200_NO_IC
1263
`define OR1200_UPR_ICP                  1'b0
1264
`else
1265
`define OR1200_UPR_ICP                  1'b1
1266
`endif
1267
`ifdef OR1200_NO_DMMU
1268
`define OR1200_UPR_DMP                  1'b0
1269
`else
1270
`define OR1200_UPR_DMP                  1'b1
1271
`endif
1272
`ifdef OR1200_NO_IMMU
1273
`define OR1200_UPR_IMP                  1'b0
1274
`else
1275
`define OR1200_UPR_IMP                  1'b1
1276
`endif
1277
`define OR1200_UPR_MP                   1'b1    // MAC always present
1278
`ifdef OR1200_DU_IMPLEMENTED
1279
`define OR1200_UPR_DUP                  1'b1
1280
`else
1281
`define OR1200_UPR_DUP                  1'b0
1282
`endif
1283
`define OR1200_UPR_PCUP                 1'b0    // Performance counters not present
1284
`ifdef OR1200_DU_IMPLEMENTED
1285
`define OR1200_UPR_PMP                  1'b1
1286
`else
1287
`define OR1200_UPR_PMP                  1'b0
1288
`endif
1289
`ifdef OR1200_DU_IMPLEMENTED
1290
`define OR1200_UPR_PICP                 1'b1
1291
`else
1292
`define OR1200_UPR_PICP                 1'b0
1293
`endif
1294
`ifdef OR1200_DU_IMPLEMENTED
1295
`define OR1200_UPR_TTP                  1'b1
1296
`else
1297
`define OR1200_UPR_TTP                  1'b0
1298
`endif
1299
`define OR1200_UPR_RES1                 13'h0000
1300
`define OR1200_UPR_CUP                  8'h00
1301
 
1302
// CPUCFGR fields
1303
`define OR1200_CPUCFGR_NSGF_BITS        3:0
1304
`define OR1200_CPUCFGR_HGF_BITS 4
1305
`define OR1200_CPUCFGR_OB32S_BITS       5
1306
`define OR1200_CPUCFGR_OB64S_BITS       6
1307
`define OR1200_CPUCFGR_OF32S_BITS       7
1308
`define OR1200_CPUCFGR_OF64S_BITS       8
1309
`define OR1200_CPUCFGR_OV64S_BITS       9
1310
`define OR1200_CPUCFGR_RES1_BITS        31:10
1311
 
1312
// CPUCFGR values
1313
`define OR1200_CPUCFGR_NSGF             4'h0
1314
`define OR1200_CPUCFGR_HGF              1'b0
1315
`define OR1200_CPUCFGR_OB32S            1'b1
1316
`define OR1200_CPUCFGR_OB64S            1'b0
1317
`define OR1200_CPUCFGR_OF32S            1'b0
1318
`define OR1200_CPUCFGR_OF64S            1'b0
1319
`define OR1200_CPUCFGR_OV64S            1'b0
1320
`define OR1200_CPUCFGR_RES1             22'h000000
1321
 
1322
// DMMUCFGR fields
1323
`define OR1200_DMMUCFGR_NTW_BITS        1:0
1324
`define OR1200_DMMUCFGR_NTS_BITS        4:2
1325
`define OR1200_DMMUCFGR_NAE_BITS        7:5
1326
`define OR1200_DMMUCFGR_CRI_BITS        8
1327
`define OR1200_DMMUCFGR_PRI_BITS        9
1328
`define OR1200_DMMUCFGR_TEIRI_BITS      10
1329
`define OR1200_DMMUCFGR_HTR_BITS        11
1330
`define OR1200_DMMUCFGR_RES1_BITS       31:12
1331
 
1332
// DMMUCFGR values
1333
`ifdef OR1200_NO_DMMU
1334
`define OR1200_DMMUCFGR_NTW             2'h0    // Irrelevant
1335
`define OR1200_DMMUCFGR_NTS             3'h0    // Irrelevant
1336
`define OR1200_DMMUCFGR_NAE             3'h0    // Irrelevant
1337
`define OR1200_DMMUCFGR_CRI             1'b0    // Irrelevant
1338
`define OR1200_DMMUCFGR_PRI             1'b0    // Irrelevant
1339
`define OR1200_DMMUCFGR_TEIRI           1'b0    // Irrelevant
1340
`define OR1200_DMMUCFGR_HTR             1'b0    // Irrelevant
1341
`define OR1200_DMMUCFGR_RES1            20'h00000
1342
`else
1343
`define OR1200_DMMUCFGR_NTW             2'h0    // 1 TLB way
1344
`define OR1200_DMMUCFGR_NTS 3'h`OR1200_DTLB_INDXW       // Num TLB sets
1345
`define OR1200_DMMUCFGR_NAE             3'h0    // No ATB entries
1346
`define OR1200_DMMUCFGR_CRI             1'b0    // No control register
1347
`define OR1200_DMMUCFGR_PRI             1'b0    // No protection reg
1348
`define OR1200_DMMUCFGR_TEIRI           1'b1    // TLB entry inv reg impl.
1349
`define OR1200_DMMUCFGR_HTR             1'b0    // No HW TLB reload
1350
`define OR1200_DMMUCFGR_RES1            20'h00000
1351
`endif
1352
 
1353
// IMMUCFGR fields
1354
`define OR1200_IMMUCFGR_NTW_BITS        1:0
1355
`define OR1200_IMMUCFGR_NTS_BITS        4:2
1356
`define OR1200_IMMUCFGR_NAE_BITS        7:5
1357
`define OR1200_IMMUCFGR_CRI_BITS        8
1358
`define OR1200_IMMUCFGR_PRI_BITS        9
1359
`define OR1200_IMMUCFGR_TEIRI_BITS      10
1360
`define OR1200_IMMUCFGR_HTR_BITS        11
1361
`define OR1200_IMMUCFGR_RES1_BITS       31:12
1362
 
1363
// IMMUCFGR values
1364
`ifdef OR1200_NO_IMMU
1365
`define OR1200_IMMUCFGR_NTW             2'h0    // Irrelevant
1366
`define OR1200_IMMUCFGR_NTS             3'h0    // Irrelevant
1367
`define OR1200_IMMUCFGR_NAE             3'h0    // Irrelevant
1368
`define OR1200_IMMUCFGR_CRI             1'b0    // Irrelevant
1369
`define OR1200_IMMUCFGR_PRI             1'b0    // Irrelevant
1370
`define OR1200_IMMUCFGR_TEIRI           1'b0    // Irrelevant
1371
`define OR1200_IMMUCFGR_HTR             1'b0    // Irrelevant
1372
`define OR1200_IMMUCFGR_RES1            20'h00000
1373
`else
1374
`define OR1200_IMMUCFGR_NTW             2'h0    // 1 TLB way
1375
`define OR1200_IMMUCFGR_NTS 3'h`OR1200_ITLB_INDXW       // Num TLB sets
1376
`define OR1200_IMMUCFGR_NAE             3'h0    // No ATB entry
1377
`define OR1200_IMMUCFGR_CRI             1'b0    // No control reg
1378
`define OR1200_IMMUCFGR_PRI             1'b0    // No protection reg
1379
`define OR1200_IMMUCFGR_TEIRI           1'b1    // TLB entry inv reg impl
1380
`define OR1200_IMMUCFGR_HTR             1'b0    // No HW TLB reload
1381
`define OR1200_IMMUCFGR_RES1            20'h00000
1382
`endif
1383
 
1384
// DCCFGR fields
1385
`define OR1200_DCCFGR_NCW_BITS          2:0
1386
`define OR1200_DCCFGR_NCS_BITS          6:3
1387
`define OR1200_DCCFGR_CBS_BITS          7
1388
`define OR1200_DCCFGR_CWS_BITS          8
1389
`define OR1200_DCCFGR_CCRI_BITS         9
1390
`define OR1200_DCCFGR_CBIRI_BITS        10
1391
`define OR1200_DCCFGR_CBPRI_BITS        11
1392
`define OR1200_DCCFGR_CBLRI_BITS        12
1393
`define OR1200_DCCFGR_CBFRI_BITS        13
1394
`define OR1200_DCCFGR_CBWBRI_BITS       14
1395
`define OR1200_DCCFGR_RES1_BITS 31:15
1396
 
1397
// DCCFGR values
1398
`ifdef OR1200_NO_DC
1399
`define OR1200_DCCFGR_NCW               3'h0    // Irrelevant
1400
`define OR1200_DCCFGR_NCS               4'h0    // Irrelevant
1401
`define OR1200_DCCFGR_CBS               1'b0    // Irrelevant
1402
`define OR1200_DCCFGR_CWS               1'b0    // Irrelevant
1403
`define OR1200_DCCFGR_CCRI              1'b1    // Irrelevant
1404
`define OR1200_DCCFGR_CBIRI             1'b1    // Irrelevant
1405
`define OR1200_DCCFGR_CBPRI             1'b0    // Irrelevant
1406
`define OR1200_DCCFGR_CBLRI             1'b0    // Irrelevant
1407
`define OR1200_DCCFGR_CBFRI             1'b1    // Irrelevant
1408
`define OR1200_DCCFGR_CBWBRI            1'b0    // Irrelevant
1409
`define OR1200_DCCFGR_RES1              17'h00000
1410
`else
1411
`define OR1200_DCCFGR_NCW               3'h0    // 1 cache way
1412
`define OR1200_DCCFGR_NCS (`OR1200_DCTAG)       // Num cache sets
1413
`define OR1200_DCCFGR_CBS (`OR1200_DCLS-4)      // 16 byte cache block
1414
`define OR1200_DCCFGR_CWS               1'b0    // Write-through strategy
1415
`define OR1200_DCCFGR_CCRI              1'b1    // Cache control reg impl.
1416
`define OR1200_DCCFGR_CBIRI             1'b1    // Cache block inv reg impl.
1417
`define OR1200_DCCFGR_CBPRI             1'b0    // Cache block prefetch reg not impl.
1418
`define OR1200_DCCFGR_CBLRI             1'b0    // Cache block lock reg not impl.
1419
`define OR1200_DCCFGR_CBFRI             1'b1    // Cache block flush reg impl.
1420
`define OR1200_DCCFGR_CBWBRI            1'b0    // Cache block WB reg not impl.
1421
`define OR1200_DCCFGR_RES1              17'h00000
1422
`endif
1423
 
1424
// ICCFGR fields
1425
`define OR1200_ICCFGR_NCW_BITS          2:0
1426
`define OR1200_ICCFGR_NCS_BITS          6:3
1427
`define OR1200_ICCFGR_CBS_BITS          7
1428
`define OR1200_ICCFGR_CWS_BITS          8
1429
`define OR1200_ICCFGR_CCRI_BITS         9
1430
`define OR1200_ICCFGR_CBIRI_BITS        10
1431
`define OR1200_ICCFGR_CBPRI_BITS        11
1432
`define OR1200_ICCFGR_CBLRI_BITS        12
1433
`define OR1200_ICCFGR_CBFRI_BITS        13
1434
`define OR1200_ICCFGR_CBWBRI_BITS       14
1435
`define OR1200_ICCFGR_RES1_BITS 31:15
1436
 
1437
// ICCFGR values
1438
`ifdef OR1200_NO_IC
1439
`define OR1200_ICCFGR_NCW               3'h0    // Irrelevant
1440
`define OR1200_ICCFGR_NCS               4'h0    // Irrelevant
1441
`define OR1200_ICCFGR_CBS               1'b0    // Irrelevant
1442
`define OR1200_ICCFGR_CWS               1'b0    // Irrelevant
1443
`define OR1200_ICCFGR_CCRI              1'b0    // Irrelevant
1444
`define OR1200_ICCFGR_CBIRI             1'b0    // Irrelevant
1445
`define OR1200_ICCFGR_CBPRI             1'b0    // Irrelevant
1446
`define OR1200_ICCFGR_CBLRI             1'b0    // Irrelevant
1447
`define OR1200_ICCFGR_CBFRI             1'b0    // Irrelevant
1448
`define OR1200_ICCFGR_CBWBRI            1'b0    // Irrelevant
1449
`define OR1200_ICCFGR_RES1              17'h00000
1450
`else
1451
`define OR1200_ICCFGR_NCW               3'h0    // 1 cache way
1452
`define OR1200_ICCFGR_NCS (`OR1200_ICTAG)       // Num cache sets
1453
`define OR1200_ICCFGR_CBS (`OR1200_ICLS-4)      // 16 byte cache block
1454
`define OR1200_ICCFGR_CWS               1'b0    // Irrelevant
1455
`define OR1200_ICCFGR_CCRI              1'b1    // Cache control reg impl.
1456
`define OR1200_ICCFGR_CBIRI             1'b1    // Cache block inv reg impl.
1457
`define OR1200_ICCFGR_CBPRI             1'b0    // Cache block prefetch reg not impl.
1458
`define OR1200_ICCFGR_CBLRI             1'b0    // Cache block lock reg not impl.
1459
`define OR1200_ICCFGR_CBFRI             1'b1    // Cache block flush reg impl.
1460
`define OR1200_ICCFGR_CBWBRI            1'b0    // Irrelevant
1461
`define OR1200_ICCFGR_RES1              17'h00000
1462
`endif
1463
 
1464
// DCFGR fields
1465
`define OR1200_DCFGR_NDP_BITS           2:0
1466
`define OR1200_DCFGR_WPCI_BITS          3
1467
`define OR1200_DCFGR_RES1_BITS          31:4
1468
 
1469
// DCFGR values
1470
`define OR1200_DCFGR_NDP                3'h0    // Zero DVR/DCR pairs
1471
`define OR1200_DCFGR_WPCI               1'b0    // WP counters not impl.
1472
`define OR1200_DCFGR_RES1               28'h0000000

powered by: WebSVN 2.1.0

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