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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [include/] [or1200_defines.v] - Blame information for rev 476

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

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's definitions                                        ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6 348 julius
////  http://opencores.org/project,or1k                           ////
7 6 julius
////                                                              ////
8
////  Description                                                 ////
9 348 julius
////  Defines for the OR1200 core                                 ////
10 6 julius
////                                                              ////
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
// $Log: or1200_defines.v,v $
45 348 julius
// Revision 2.0  2010/06/30 11:00:00  ORSoC
46
// Minor update: 
47
// Defines added, bugs fixed. 
48 6 julius
 
49
//
50
// Dump VCD
51
//
52
//`define OR1200_VCD_DUMP
53
 
54
//
55
// Generate debug messages during simulation
56
//
57
//`define OR1200_VERBOSE
58
 
59
//  `define OR1200_ASIC
60
////////////////////////////////////////////////////////
61
//
62
// Typical configuration for an ASIC
63
//
64
`ifdef OR1200_ASIC
65
 
66
//
67
// Target ASIC memories
68
//
69
//`define OR1200_ARTISAN_SSP
70
//`define OR1200_ARTISAN_SDP
71
//`define OR1200_ARTISAN_STP
72
`define OR1200_VIRTUALSILICON_SSP
73
//`define OR1200_VIRTUALSILICON_STP_T1
74
//`define OR1200_VIRTUALSILICON_STP_T2
75
 
76
//
77
// Do not implement Data cache
78
//
79
//`define OR1200_NO_DC
80
 
81
//
82
// Do not implement Insn cache
83
//
84
//`define OR1200_NO_IC
85
 
86
//
87
// Do not implement Data MMU
88
//
89
//`define OR1200_NO_DMMU
90
 
91
//
92
// Do not implement Insn MMU
93
//
94
//`define OR1200_NO_IMMU
95
 
96
//
97
// Select between ASIC optimized and generic multiplier
98
//
99
//`define OR1200_ASIC_MULTP2_32X32
100
`define OR1200_GENERIC_MULTP2_32X32
101
 
102
//
103
// Size/type of insn/data cache if implemented
104
//
105
// `define OR1200_IC_1W_512B
106
// `define OR1200_IC_1W_4KB
107
`define OR1200_IC_1W_8KB
108
// `define OR1200_DC_1W_4KB
109
`define OR1200_DC_1W_8KB
110
 
111
`else
112
 
113
 
114
/////////////////////////////////////////////////////////
115
//
116
// Typical configuration for an FPGA
117
//
118
 
119
//
120
// Target FPGA memories
121
//
122
//`define OR1200_ALTERA_LPM
123
//`define OR1200_XILINX_RAMB16
124
//`define OR1200_XILINX_RAMB4
125
//`define OR1200_XILINX_RAM32X1D
126
//`define OR1200_USE_RAM16X1D_FOR_RAM32X1D
127 348 julius
// Generic models should infer RAM blocks at synthesis time (not only effects 
128
// single port ram.)
129
`define OR1200_GENERIC
130 6 julius
 
131
//
132
// Do not implement Data cache
133
//
134 348 julius
//`define OR1200_NO_DC
135 6 julius
 
136
//
137
// Do not implement Insn cache
138
//
139
//`define OR1200_NO_IC
140
 
141
//
142
// Do not implement Data MMU
143
//
144
//`define OR1200_NO_DMMU
145
 
146
//
147
// Do not implement Insn MMU
148
//
149
//`define OR1200_NO_IMMU
150
 
151
//
152
// Select between ASIC and generic multiplier
153
//
154
// (Generic seems to trigger a bug in the Cadence Ncsim simulator)
155
//
156
//`define OR1200_ASIC_MULTP2_32X32
157
`define OR1200_GENERIC_MULTP2_32X32
158
 
159
//
160
// Size/type of insn/data cache if implemented
161
// (consider available FPGA memory resources)
162
//
163
//`define OR1200_IC_1W_512B
164 49 julius
//`define OR1200_IC_1W_4KB
165 476 julius
//`define OR1200_IC_1W_8KB
166
`define OR1200_IC_1W_16KB
167 348 julius
//`define OR1200_DC_1W_4KB
168 476 julius
//`define OR1200_DC_1W_8KB
169
`define OR1200_DC_1W_16KB
170 6 julius
 
171
`endif
172
 
173
 
174
//////////////////////////////////////////////////////////
175
//
176
// Do not change below unless you know what you are doing
177
//
178
 
179
//
180 358 julius
// Reset active low
181
//
182
//`define OR1200_RST_ACT_LOW
183
 
184
//
185 6 julius
// Enable RAM BIST
186
//
187
// At the moment this only works for Virtual Silicon
188
// single port RAMs. For other RAMs it has not effect.
189
// Special wrapper for VS RAMs needs to be provided
190
// with scan flops to facilitate bist scan.
191
//
192
//`define OR1200_BIST
193
 
194
//
195
// Register OR1200 WISHBONE outputs
196
// (must be defined/enabled)
197
//
198
`define OR1200_REGISTERED_OUTPUTS
199
 
200
//
201
// Register OR1200 WISHBONE inputs
202
//
203
// (must be undefined/disabled)
204
//
205
//`define OR1200_REGISTERED_INPUTS
206
 
207
//
208
// Disable bursts if they are not supported by the
209
// memory subsystem (only affect cache line fill)
210
//
211 348 julius
//`define OR1200_NO_BURSTS
212 6 julius
//
213
 
214
//
215
// WISHBONE retry counter range
216
//
217
// 2^value range for retry counter. Retry counter
218
// is activated whenever *wb_rty_i is asserted and
219
// until retry counter expires, corresponding
220
// WISHBONE interface is deactivated.
221
//
222
// To disable retry counters and *wb_rty_i all together,
223
// undefine this macro.
224
//
225
//`define OR1200_WB_RETRY 7
226
 
227
//
228
// WISHBONE Consecutive Address Burst
229
//
230
// This was used prior to WISHBONE B3 specification
231
// to identify bursts. It is no longer needed but
232
// remains enabled for compatibility with old designs.
233
//
234
// To remove *wb_cab_o ports undefine this macro.
235
//
236
//`define OR1200_WB_CAB
237
 
238
//
239
// WISHBONE B3 compatible interface
240
//
241
// This follows the WISHBONE B3 specification.
242
// It is not enabled by default because most
243
// designs still don't use WB b3.
244
//
245
// To enable *wb_cti_o/*wb_bte_o ports,
246
// define this macro.
247
//
248
`define OR1200_WB_B3
249
 
250
//
251
// LOG all WISHBONE accesses
252
//
253
`define OR1200_LOG_WB_ACCESS
254
 
255
//
256
// Enable additional synthesis directives if using
257
// _Synopsys_ synthesis tool
258
//
259
//`define OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
260
 
261
//
262
// Enables default statement in some case blocks
263
// and disables Synopsys synthesis directive full_case
264
//
265
// By default it is enabled. When disabled it
266
// can increase clock frequency.
267
//
268
`define OR1200_CASE_DEFAULT
269
 
270
//
271
// Operand width / register file address width
272
//
273
// (DO NOT CHANGE)
274
//
275
`define OR1200_OPERAND_WIDTH            32
276
`define OR1200_REGFILE_ADDR_WIDTH       5
277
 
278
//
279
// l.add/l.addi/l.and and optional l.addc/l.addic
280
// also set (compare) flag when result of their
281
// operation equals zero
282
//
283
// At the time of writing this, default or32
284
// C/C++ compiler doesn't generate code that
285
// would benefit from this optimization.
286
//
287
// By default this optimization is disabled to
288
// save area.
289
//
290
//`define OR1200_ADDITIONAL_FLAG_MODIFIERS
291
 
292
//
293
// Implement l.addc/l.addic instructions
294
//
295
// By default implementation of l.addc/l.addic
296
// instructions is enabled in case you need them.
297
// If you don't use them, then disable implementation
298
// to save area.
299
//
300 348 julius
//`define OR1200_IMPL_ADDC
301 6 julius
 
302
//
303 348 julius
// Implement l.sub instruction
304 6 julius
//
305 348 julius
// By default implementation of l.sub instructions
306
// is enabled to be compliant with the simulator.
307
// If you don't use carry bit, then disable
308
// implementation to save area.
309 6 julius
//
310 348 julius
`define OR1200_IMPL_SUB
311 6 julius
 
312
//
313 348 julius
// Implement carry bit SR[CY]
314 6 julius
//
315
//
316 348 julius
// By default implementation of SR[CY] is enabled
317
// to be compliant with the simulator. However SR[CY]
318
// is explicitly only used by l.addc/l.addic/l.sub
319
// instructions and if these three insns are not
320
// implemented there is not much point having SR[CY].
321 6 julius
//
322 348 julius
//`define OR1200_IMPL_CY
323 6 julius
 
324
//
325
// Implement rotate in the ALU
326
//
327
// At the time of writing this, or32
328
// C/C++ compiler doesn't generate rotate
329
// instructions. However or32 assembler
330
// can assemble code that uses rotate insn.
331
// This means that rotate instructions
332
// must be used manually inserted.
333
//
334
// By default implementation of rotate
335
// is disabled to save area and increase
336
// clock frequency.
337
//
338
//`define OR1200_IMPL_ALU_ROTATE
339
 
340
//
341
// Type of ALU compare to implement
342
//
343
// Try either one to find what yields
344
// higher clock frequencyin your case.
345
//
346
//`define OR1200_IMPL_ALU_COMP1
347
`define OR1200_IMPL_ALU_COMP2
348
 
349
//
350 403 julius
// Implement Find First/Last '1'
351
//
352
`define OR1200_IMPL_ALU_FFL1
353
 
354
//
355 6 julius
// Implement multiplier
356
//
357
// By default multiplier is implemented
358
//
359
`define OR1200_MULT_IMPLEMENTED
360
 
361
//
362
// Implement multiply-and-accumulate
363
//
364
// By default MAC is implemented. To
365 435 julius
// implement MAC, multiplier (non-serial) needs to be
366 6 julius
// implemented.
367
//
368
`define OR1200_MAC_IMPLEMENTED
369
 
370
//
371 348 julius
// Implement optional l.div/l.divu instructions
372
//
373
// By default divide instructions are not implemented
374 435 julius
// to save area.
375 348 julius
//
376
//
377
`define OR1200_DIV_IMPLEMENTED
378
 
379
//
380 435 julius
// Serial multiplier.
381 6 julius
//
382 435 julius
//`define OR1200_MULT_SERIAL
383
 
384 6 julius
//
385 435 julius
// Serial divider.
386
// Uncomment to use a serial divider, otherwise will
387
// be a generic parallel implementation.
388
//
389
//`define OR1200_DIV_SERIAL
390 6 julius
 
391
//
392 58 julius
// Implement HW Single Precision FPU
393
//
394 462 julius
`define OR1200_FPU_IMPLEMENTED
395 58 julius
 
396 462 julius
 
397 58 julius
//
398 6 julius
// Clock ratio RISC clock versus WB clock
399
//
400
// If you plan to run WB:RISC clock fixed to 1:1, disable
401
// both defines
402
//
403
// For WB:RISC 1:2 or 1:1, enable OR1200_CLKDIV_2_SUPPORTED
404
// and use clmode to set ratio
405
//
406
// For WB:RISC 1:4, 1:2 or 1:1, enable both defines and use
407
// clmode to set ratio
408
//
409 348 julius
//`define OR1200_CLKDIV_2_SUPPORTED
410 6 julius
//`define OR1200_CLKDIV_4_SUPPORTED
411
 
412
//
413
// Type of register file RAM
414
//
415
// Memory macro w/ two ports (see or1200_tpram_32x32.v)
416
//`define OR1200_RFRAM_TWOPORT
417
//
418 348 julius
// Memory macro dual port (see or1200_dpram.v)
419 6 julius
`define OR1200_RFRAM_DUALPORT
420
 
421
//
422
// Generic (flip-flop based) register file (see or1200_rfram_generic.v)
423
//`define OR1200_RFRAM_GENERIC
424
//  Generic register file supports - 16 registers 
425
`ifdef OR1200_RFRAM_GENERIC
426
//    `define OR1200_RFRAM_16REG
427
`endif
428
 
429
//
430
// Type of mem2reg aligner to implement.
431
//
432
// Once OR1200_IMPL_MEM2REG2 yielded faster
433
// circuit, however with today tools it will
434
// most probably give you slower circuit.
435
//
436
`define OR1200_IMPL_MEM2REG1
437
//`define OR1200_IMPL_MEM2REG2
438
 
439
//
440 358 julius
// Reset value and event
441
//
442
`ifdef OR1200_RST_ACT_LOW
443
  `define OR1200_RST_VALUE      (1'b0)
444
  `define OR1200_RST_EVENT      negedge
445
`else
446
  `define OR1200_RST_VALUE      (1'b1)
447
  `define OR1200_RST_EVENT      posedge
448
`endif
449
 
450
//
451 6 julius
// ALUOPs
452
//
453
`define OR1200_ALUOP_WIDTH      4
454
`define OR1200_ALUOP_NOP        4'd4
455
/* Order defined by arith insns that have two source operands both in regs
456
   (see binutils/include/opcode/or32.h) */
457
`define OR1200_ALUOP_ADD        4'd0
458
`define OR1200_ALUOP_ADDC       4'd1
459
`define OR1200_ALUOP_SUB        4'd2
460
`define OR1200_ALUOP_AND        4'd3
461
`define OR1200_ALUOP_OR         4'd4
462
`define OR1200_ALUOP_XOR        4'd5
463
`define OR1200_ALUOP_MUL        4'd6
464
`define OR1200_ALUOP_CUST5      4'd7
465
`define OR1200_ALUOP_SHROT      4'd8
466
`define OR1200_ALUOP_DIV        4'd9
467
`define OR1200_ALUOP_DIVU       4'd10
468 435 julius
`define OR1200_ALUOP_MULU       4'd11
469
/* Values sent to ALU from decode unit - not strictly defined by ISA */
470 6 julius
`define OR1200_ALUOP_MOVHI      4'd12
471
`define OR1200_ALUOP_COMP       4'd13
472
`define OR1200_ALUOP_MTSR       4'd14
473
`define OR1200_ALUOP_MFSR       4'd15
474 348 julius
`define OR1200_ALUOP_CMOV       4'd14
475 403 julius
`define OR1200_ALUOP_FFL1       4'd15
476
 
477
 
478
// ALU instructions second opcode field (previously multicycle field in 
479
// machine word)
480
`define OR1200_ALUOP2_POS               9:8
481
`define OR1200_ALUOP2_WIDTH     2
482
 
483
 
484 6 julius
//
485
// MACOPs
486
//
487 348 julius
`define OR1200_MACOP_WIDTH      3
488
`define OR1200_MACOP_NOP        3'b000
489
`define OR1200_MACOP_MAC        3'b001
490
`define OR1200_MACOP_MSB        3'b010
491 6 julius
 
492
//
493
// Shift/rotate ops
494
//
495
`define OR1200_SHROTOP_WIDTH    2
496
`define OR1200_SHROTOP_NOP      2'd0
497
`define OR1200_SHROTOP_SLL      2'd0
498
`define OR1200_SHROTOP_SRL      2'd1
499
`define OR1200_SHROTOP_SRA      2'd2
500
`define OR1200_SHROTOP_ROR      2'd3
501
 
502
// Execution cycles per instruction
503 58 julius
`define OR1200_MULTICYCLE_WIDTH 3
504
`define OR1200_ONE_CYCLE                3'd0
505
`define OR1200_TWO_CYCLES               3'd1
506 6 julius
 
507 348 julius
// Execution control which will "wait on" a module to finish
508
`define OR1200_WAIT_ON_WIDTH 2
509
`define OR1200_WAIT_ON_FPU `OR1200_WAIT_ON_WIDTH'd1
510
`define OR1200_WAIT_ON_MTSPR `OR1200_WAIT_ON_WIDTH'd2
511
 
512 6 julius
// Operand MUX selects
513
`define OR1200_SEL_WIDTH                2
514
`define OR1200_SEL_RF                   2'd0
515
`define OR1200_SEL_IMM                  2'd1
516
`define OR1200_SEL_EX_FORW              2'd2
517
`define OR1200_SEL_WB_FORW              2'd3
518
 
519
//
520
// BRANCHOPs
521
//
522
`define OR1200_BRANCHOP_WIDTH           3
523
`define OR1200_BRANCHOP_NOP             3'd0
524
`define OR1200_BRANCHOP_J               3'd1
525
`define OR1200_BRANCHOP_JR              3'd2
526
`define OR1200_BRANCHOP_BAL             3'd3
527
`define OR1200_BRANCHOP_BF              3'd4
528
`define OR1200_BRANCHOP_BNF             3'd5
529
`define OR1200_BRANCHOP_RFE             3'd6
530
 
531
//
532
// LSUOPs
533
//
534
// Bit 0: sign extend
535
// Bits 1-2: 00 doubleword, 01 byte, 10 halfword, 11 singleword
536
// Bit 3: 0 load, 1 store
537
`define OR1200_LSUOP_WIDTH              4
538
`define OR1200_LSUOP_NOP                4'b0000
539
`define OR1200_LSUOP_LBZ                4'b0010
540
`define OR1200_LSUOP_LBS                4'b0011
541
`define OR1200_LSUOP_LHZ                4'b0100
542
`define OR1200_LSUOP_LHS                4'b0101
543
`define OR1200_LSUOP_LWZ                4'b0110
544
`define OR1200_LSUOP_LWS                4'b0111
545 348 julius
`define OR1200_LSUOP_LD                 4'b0001
546
`define OR1200_LSUOP_SD                 4'b1000
547
`define OR1200_LSUOP_SB                 4'b1010
548
`define OR1200_LSUOP_SH                 4'b1100
549
`define OR1200_LSUOP_SW                 4'b1110
550 6 julius
 
551 348 julius
// Number of bits of load/store EA precalculated in ID stage
552
// for balancing ID and EX stages.
553
//
554
// Valid range: 2,3,...,30,31
555
`define OR1200_LSUEA_PRECALC            2
556
 
557 6 julius
// FETCHOPs
558
`define OR1200_FETCHOP_WIDTH            1
559
`define OR1200_FETCHOP_NOP              1'b0
560
`define OR1200_FETCHOP_LW               1'b1
561
 
562
//
563
// Register File Write-Back OPs
564
//
565
// Bit 0: register file write enable
566 58 julius
// Bits 3-1: write-back mux selects
567 348 julius
//
568 358 julius
`define OR1200_RFWBOP_WIDTH             4
569
`define OR1200_RFWBOP_NOP               4'b0000
570
`define OR1200_RFWBOP_ALU               3'b000
571
`define OR1200_RFWBOP_LSU               3'b001
572
`define OR1200_RFWBOP_SPRS              3'b010
573
`define OR1200_RFWBOP_LR                3'b011
574
`define OR1200_RFWBOP_FPU               3'b100
575 6 julius
 
576
// Compare instructions
577
`define OR1200_COP_SFEQ       3'b000
578
`define OR1200_COP_SFNE       3'b001
579
`define OR1200_COP_SFGT       3'b010
580
`define OR1200_COP_SFGE       3'b011
581
`define OR1200_COP_SFLT       3'b100
582
`define OR1200_COP_SFLE       3'b101
583
`define OR1200_COP_X          3'b111
584
`define OR1200_SIGNED_COMPARE 'd3
585
`define OR1200_COMPOP_WIDTH     4
586
 
587
//
588 348 julius
// FP OPs
589 58 julius
//
590
// MSbit indicates FPU operation valid
591
//
592 348 julius
`define OR1200_FPUOP_WIDTH      8
593
// FPU unit from Usselman takes 5 cycles from decode, so 4 ex. cycles
594
`define OR1200_FPUOP_CYCLES 3'd4
595
// FP instruction is double precision if bit 4 is set. We're a 32-bit 
596
// implementation thus do not support double precision FP 
597
`define OR1200_FPUOP_DOUBLE_BIT 4
598
`define OR1200_FPUOP_ADD  8'b0000_0000
599
`define OR1200_FPUOP_SUB  8'b0000_0001
600
`define OR1200_FPUOP_MUL  8'b0000_0010
601
`define OR1200_FPUOP_DIV  8'b0000_0011
602
`define OR1200_FPUOP_ITOF 8'b0000_0100
603
`define OR1200_FPUOP_FTOI 8'b0000_0101
604
`define OR1200_FPUOP_REM  8'b0000_0110
605
`define OR1200_FPUOP_RESERVED  8'b0000_0111
606 58 julius
// FP Compare instructions
607 348 julius
`define OR1200_FPCOP_SFEQ 8'b0000_1000
608
`define OR1200_FPCOP_SFNE 8'b0000_1001
609
`define OR1200_FPCOP_SFGT 8'b0000_1010
610
`define OR1200_FPCOP_SFGE 8'b0000_1011
611
`define OR1200_FPCOP_SFLT 8'b0000_1100
612
`define OR1200_FPCOP_SFLE 8'b0000_1101
613 58 julius
 
614
//
615 6 julius
// TAGs for instruction bus
616
//
617
`define OR1200_ITAG_IDLE        4'h0    // idle bus
618
`define OR1200_ITAG_NI          4'h1    // normal insn
619
`define OR1200_ITAG_BE          4'hb    // Bus error exception
620
`define OR1200_ITAG_PE          4'hc    // Page fault exception
621
`define OR1200_ITAG_TE          4'hd    // TLB miss exception
622
 
623
//
624
// TAGs for data bus
625
//
626
`define OR1200_DTAG_IDLE        4'h0    // idle bus
627
`define OR1200_DTAG_ND          4'h1    // normal data
628
`define OR1200_DTAG_AE          4'ha    // Alignment exception
629
`define OR1200_DTAG_BE          4'hb    // Bus error exception
630
`define OR1200_DTAG_PE          4'hc    // Page fault exception
631
`define OR1200_DTAG_TE          4'hd    // TLB miss exception
632
 
633
 
634
//////////////////////////////////////////////
635
//
636
// ORBIS32 ISA specifics
637
//
638
 
639
// SHROT_OP position in machine word
640
`define OR1200_SHROTOP_POS              7:6
641
 
642
//
643
// Instruction opcode groups (basic)
644
//
645
`define OR1200_OR32_J                 6'b000000
646
`define OR1200_OR32_JAL               6'b000001
647
`define OR1200_OR32_BNF               6'b000011
648
`define OR1200_OR32_BF                6'b000100
649
`define OR1200_OR32_NOP               6'b000101
650
`define OR1200_OR32_MOVHI             6'b000110
651
`define OR1200_OR32_XSYNC             6'b001000
652
`define OR1200_OR32_RFE               6'b001001
653
/* */
654
`define OR1200_OR32_JR                6'b010001
655
`define OR1200_OR32_JALR              6'b010010
656
`define OR1200_OR32_MACI              6'b010011
657
/* */
658
`define OR1200_OR32_LWZ               6'b100001
659
`define OR1200_OR32_LBZ               6'b100011
660
`define OR1200_OR32_LBS               6'b100100
661
`define OR1200_OR32_LHZ               6'b100101
662
`define OR1200_OR32_LHS               6'b100110
663
`define OR1200_OR32_ADDI              6'b100111
664
`define OR1200_OR32_ADDIC             6'b101000
665
`define OR1200_OR32_ANDI              6'b101001
666
`define OR1200_OR32_ORI               6'b101010
667
`define OR1200_OR32_XORI              6'b101011
668
`define OR1200_OR32_MULI              6'b101100
669
`define OR1200_OR32_MFSPR             6'b101101
670
`define OR1200_OR32_SH_ROTI           6'b101110
671
`define OR1200_OR32_SFXXI             6'b101111
672
/* */
673
`define OR1200_OR32_MTSPR             6'b110000
674
`define OR1200_OR32_MACMSB            6'b110001
675 348 julius
`define OR1200_OR32_FLOAT             6'b110010
676 6 julius
/* */
677
`define OR1200_OR32_SW                6'b110101
678
`define OR1200_OR32_SB                6'b110110
679
`define OR1200_OR32_SH                6'b110111
680
`define OR1200_OR32_ALU               6'b111000
681
`define OR1200_OR32_SFXX              6'b111001
682
//`define OR1200_OR32_CUST5             6'b111100
683
 
684 348 julius
 
685 6 julius
/////////////////////////////////////////////////////
686
//
687
// Exceptions
688
//
689
 
690
//
691
// Exception vectors per OR1K architecture:
692
// 0xPPPPP100 - reset
693
// 0xPPPPP200 - bus error
694
// ... etc
695
// where P represents exception prefix.
696
//
697
// Exception vectors can be customized as per
698
// the following formula:
699
// 0xPPPPPNVV - exception N
700
//
701
// P represents exception prefix
702
// N represents exception N
703
// VV represents length of the individual vector space,
704
//   usually it is 8 bits wide and starts with all bits zero
705
//
706
 
707
//
708
// PPPPP and VV parts
709
//
710
// Sum of these two defines needs to be 28
711
//
712
`define OR1200_EXCEPT_EPH0_P    20'h00000
713
`define OR1200_EXCEPT_EPH1_P    20'hF0000
714
`define OR1200_EXCEPT_V             8'h00
715
 
716
//
717
// N part width
718
//
719
`define OR1200_EXCEPT_WIDTH 4
720
 
721
//
722
// Definition of exception vectors
723
//
724
// To avoid implementation of a certain exception,
725
// simply comment out corresponding line
726
//
727
`define OR1200_EXCEPT_UNUSED            `OR1200_EXCEPT_WIDTH'hf
728
`define OR1200_EXCEPT_TRAP              `OR1200_EXCEPT_WIDTH'he
729 58 julius
`define OR1200_EXCEPT_FLOAT             `OR1200_EXCEPT_WIDTH'hd
730 6 julius
`define OR1200_EXCEPT_SYSCALL           `OR1200_EXCEPT_WIDTH'hc
731
`define OR1200_EXCEPT_RANGE             `OR1200_EXCEPT_WIDTH'hb
732
`define OR1200_EXCEPT_ITLBMISS          `OR1200_EXCEPT_WIDTH'ha
733
`define OR1200_EXCEPT_DTLBMISS          `OR1200_EXCEPT_WIDTH'h9
734
`define OR1200_EXCEPT_INT               `OR1200_EXCEPT_WIDTH'h8
735
`define OR1200_EXCEPT_ILLEGAL           `OR1200_EXCEPT_WIDTH'h7
736
`define OR1200_EXCEPT_ALIGN             `OR1200_EXCEPT_WIDTH'h6
737
`define OR1200_EXCEPT_TICK              `OR1200_EXCEPT_WIDTH'h5
738
`define OR1200_EXCEPT_IPF               `OR1200_EXCEPT_WIDTH'h4
739
`define OR1200_EXCEPT_DPF               `OR1200_EXCEPT_WIDTH'h3
740
`define OR1200_EXCEPT_BUSERR            `OR1200_EXCEPT_WIDTH'h2
741
`define OR1200_EXCEPT_RESET             `OR1200_EXCEPT_WIDTH'h1
742
`define OR1200_EXCEPT_NONE              `OR1200_EXCEPT_WIDTH'h0
743
 
744
 
745
/////////////////////////////////////////////////////
746
//
747
// SPR groups
748
//
749
 
750
// Bits that define the group
751
`define OR1200_SPR_GROUP_BITS   15:11
752
 
753
// Width of the group bits
754
`define OR1200_SPR_GROUP_WIDTH  5
755
 
756
// Bits that define offset inside the group
757
`define OR1200_SPR_OFS_BITS 10:0
758
 
759
// List of groups
760
`define OR1200_SPR_GROUP_SYS    5'd00
761
`define OR1200_SPR_GROUP_DMMU   5'd01
762
`define OR1200_SPR_GROUP_IMMU   5'd02
763
`define OR1200_SPR_GROUP_DC     5'd03
764
`define OR1200_SPR_GROUP_IC     5'd04
765
`define OR1200_SPR_GROUP_MAC    5'd05
766
`define OR1200_SPR_GROUP_DU     5'd06
767
`define OR1200_SPR_GROUP_PM     5'd08
768
`define OR1200_SPR_GROUP_PIC    5'd09
769
`define OR1200_SPR_GROUP_TT     5'd10
770 348 julius
`define OR1200_SPR_GROUP_FPU    5'd11
771 6 julius
 
772
/////////////////////////////////////////////////////
773
//
774
// System group
775
//
776
 
777
//
778
// System registers
779
//
780
`define OR1200_SPR_CFGR         7'd0
781
`define OR1200_SPR_RF           6'd32   // 1024 >> 5
782
`define OR1200_SPR_NPC          11'd16
783
`define OR1200_SPR_SR           11'd17
784
`define OR1200_SPR_PPC          11'd18
785 348 julius
`define OR1200_SPR_FPCSR        11'd20
786 6 julius
`define OR1200_SPR_EPCR         11'd32
787
`define OR1200_SPR_EEAR         11'd48
788
`define OR1200_SPR_ESR          11'd64
789
 
790
//
791
// SR bits
792
//
793 348 julius
`define OR1200_SR_WIDTH 17
794 6 julius
`define OR1200_SR_SM   0
795
`define OR1200_SR_TEE  1
796
`define OR1200_SR_IEE  2
797
`define OR1200_SR_DCE  3
798
`define OR1200_SR_ICE  4
799
`define OR1200_SR_DME  5
800
`define OR1200_SR_IME  6
801
`define OR1200_SR_LEE  7
802
`define OR1200_SR_CE   8
803
`define OR1200_SR_F    9
804
`define OR1200_SR_CY   10       // Unused
805
`define OR1200_SR_OV   11       // Unused
806
`define OR1200_SR_OVE  12       // Unused
807
`define OR1200_SR_DSX  13       // Unused
808
`define OR1200_SR_EPH  14
809
`define OR1200_SR_FO   15
810 348 julius
`define OR1200_SR_TED  16
811 6 julius
`define OR1200_SR_CID  31:28    // Unimplemented
812
 
813
//
814
// Bits that define offset inside the group
815
//
816
`define OR1200_SPROFS_BITS 10:0
817
 
818
//
819
// Default Exception Prefix
820
//
821
// 1'b0 - OR1200_EXCEPT_EPH0_P (0x0000_0000)
822
// 1'b1 - OR1200_EXCEPT_EPH1_P (0xF000_0000)
823
//
824
`define OR1200_SR_EPH_DEF       1'b0
825
 
826 348 julius
 
827 58 julius
//
828
// FPCSR bits
829
//
830
`define OR1200_FPCSR_WIDTH 12
831
`define OR1200_FPCSR_FPEE  0
832
`define OR1200_FPCSR_RM    2:1
833
`define OR1200_FPCSR_OVF   3
834
`define OR1200_FPCSR_UNF   4
835
`define OR1200_FPCSR_SNF   5
836
`define OR1200_FPCSR_QNF   6
837
`define OR1200_FPCSR_ZF    7
838
`define OR1200_FPCSR_IXF   8
839
`define OR1200_FPCSR_IVF   9
840
`define OR1200_FPCSR_INF   10
841
`define OR1200_FPCSR_DZF   11
842
`define OR1200_FPCSR_RES   31:12
843
 
844 6 julius
/////////////////////////////////////////////////////
845
//
846
// Power Management (PM)
847
//
848
 
849
// Define it if you want PM implemented
850
//`define OR1200_PM_IMPLEMENTED
851
 
852
// Bit positions inside PMR (don't change)
853
`define OR1200_PM_PMR_SDF 3:0
854
`define OR1200_PM_PMR_DME 4
855
`define OR1200_PM_PMR_SME 5
856
`define OR1200_PM_PMR_DCGE 6
857
`define OR1200_PM_PMR_UNUSED 31:7
858
 
859
// PMR offset inside PM group of registers
860
`define OR1200_PM_OFS_PMR 11'b0
861
 
862
// PM group
863
`define OR1200_SPRGRP_PM 5'd8
864
 
865
// Define if PMR can be read/written at any address inside PM group
866
`define OR1200_PM_PARTIAL_DECODING
867
 
868
// Define if reading PMR is allowed
869
`define OR1200_PM_READREGS
870
 
871
// Define if unused PMR bits should be zero
872
`define OR1200_PM_UNUSED_ZERO
873
 
874
 
875
/////////////////////////////////////////////////////
876
//
877
// Debug Unit (DU)
878
//
879
 
880
// Define it if you want DU implemented
881 403 julius
`define OR1200_DU_IMPLEMENTED
882 6 julius
 
883
//
884
// Define if you want HW Breakpoints
885
// (if HW breakpoints are not implemented
886
// only default software trapping is
887
// possible with l.trap insn - this is
888
// however already enough for use
889
// with or32 gdb)
890
//
891 348 julius
//`define OR1200_DU_HWBKPTS
892 6 julius
 
893 348 julius
// Number of DVR/DCR pairs if HW breakpoints enabled
894
//      Comment / uncomment DU_DVRn / DU_DCRn pairs bellow according to this number ! 
895
//      DU_DVR0..DU_DVR7 should be uncommented for 8 DU_DVRDCR_PAIRS 
896
`define OR1200_DU_DVRDCR_PAIRS 8
897 6 julius
 
898
// Define if you want trace buffer
899 348 julius
//      (for now only available for Xilinx Virtex FPGAs)
900 6 julius
//`define OR1200_DU_TB_IMPLEMENTED
901
 
902 348 julius
 
903 6 julius
//
904
// Address offsets of DU registers inside DU group
905
//
906
// To not implement a register, doq not define its address
907
//
908
`ifdef OR1200_DU_HWBKPTS
909
`define OR1200_DU_DVR0          11'd0
910
`define OR1200_DU_DVR1          11'd1
911
`define OR1200_DU_DVR2          11'd2
912
`define OR1200_DU_DVR3          11'd3
913
`define OR1200_DU_DVR4          11'd4
914
`define OR1200_DU_DVR5          11'd5
915
`define OR1200_DU_DVR6          11'd6
916
`define OR1200_DU_DVR7          11'd7
917
`define OR1200_DU_DCR0          11'd8
918
`define OR1200_DU_DCR1          11'd9
919
`define OR1200_DU_DCR2          11'd10
920
`define OR1200_DU_DCR3          11'd11
921
`define OR1200_DU_DCR4          11'd12
922
`define OR1200_DU_DCR5          11'd13
923
`define OR1200_DU_DCR6          11'd14
924
`define OR1200_DU_DCR7          11'd15
925
`endif
926
`define OR1200_DU_DMR1          11'd16
927
`ifdef OR1200_DU_HWBKPTS
928
`define OR1200_DU_DMR2          11'd17
929
`define OR1200_DU_DWCR0         11'd18
930
`define OR1200_DU_DWCR1         11'd19
931
`endif
932
`define OR1200_DU_DSR           11'd20
933
`define OR1200_DU_DRR           11'd21
934
`ifdef OR1200_DU_TB_IMPLEMENTED
935
`define OR1200_DU_TBADR         11'h0ff
936 363 julius
`define OR1200_DU_TBIA          11'h1??
937
`define OR1200_DU_TBIM          11'h2??
938
`define OR1200_DU_TBAR          11'h3??
939
`define OR1200_DU_TBTS          11'h4??
940 6 julius
`endif
941
 
942
// Position of offset bits inside SPR address
943
`define OR1200_DUOFS_BITS       10:0
944
 
945
// DCR bits
946
`define OR1200_DU_DCR_DP        0
947
`define OR1200_DU_DCR_CC        3:1
948
`define OR1200_DU_DCR_SC        4
949
`define OR1200_DU_DCR_CT        7:5
950
 
951
// DMR1 bits
952
`define OR1200_DU_DMR1_CW0      1:0
953
`define OR1200_DU_DMR1_CW1      3:2
954
`define OR1200_DU_DMR1_CW2      5:4
955
`define OR1200_DU_DMR1_CW3      7:6
956
`define OR1200_DU_DMR1_CW4      9:8
957
`define OR1200_DU_DMR1_CW5      11:10
958
`define OR1200_DU_DMR1_CW6      13:12
959
`define OR1200_DU_DMR1_CW7      15:14
960
`define OR1200_DU_DMR1_CW8      17:16
961
`define OR1200_DU_DMR1_CW9      19:18
962
`define OR1200_DU_DMR1_CW10     21:20
963
`define OR1200_DU_DMR1_ST       22
964
`define OR1200_DU_DMR1_BT       23
965
`define OR1200_DU_DMR1_DXFW     24
966
`define OR1200_DU_DMR1_ETE      25
967
 
968
// DMR2 bits
969
`define OR1200_DU_DMR2_WCE0     0
970
`define OR1200_DU_DMR2_WCE1     1
971 348 julius
`define OR1200_DU_DMR2_AWTC     12:2
972
`define OR1200_DU_DMR2_WGB      23:13
973 6 julius
 
974
// DWCR bits
975
`define OR1200_DU_DWCR_COUNT    15:0
976
`define OR1200_DU_DWCR_MATCH    31:16
977
 
978
// DSR bits
979
`define OR1200_DU_DSR_WIDTH     14
980
`define OR1200_DU_DSR_RSTE      0
981
`define OR1200_DU_DSR_BUSEE     1
982
`define OR1200_DU_DSR_DPFE      2
983
`define OR1200_DU_DSR_IPFE      3
984
`define OR1200_DU_DSR_TTE       4
985
`define OR1200_DU_DSR_AE        5
986
`define OR1200_DU_DSR_IIE       6
987
`define OR1200_DU_DSR_IE        7
988
`define OR1200_DU_DSR_DME       8
989
`define OR1200_DU_DSR_IME       9
990
`define OR1200_DU_DSR_RE        10
991
`define OR1200_DU_DSR_SCE       11
992 58 julius
`define OR1200_DU_DSR_FPE       12
993 6 julius
`define OR1200_DU_DSR_TE        13
994
 
995
// DRR bits
996
`define OR1200_DU_DRR_RSTE      0
997
`define OR1200_DU_DRR_BUSEE     1
998
`define OR1200_DU_DRR_DPFE      2
999
`define OR1200_DU_DRR_IPFE      3
1000
`define OR1200_DU_DRR_TTE       4
1001
`define OR1200_DU_DRR_AE        5
1002
`define OR1200_DU_DRR_IIE       6
1003
`define OR1200_DU_DRR_IE        7
1004
`define OR1200_DU_DRR_DME       8
1005
`define OR1200_DU_DRR_IME       9
1006
`define OR1200_DU_DRR_RE        10
1007
`define OR1200_DU_DRR_SCE       11
1008 58 julius
`define OR1200_DU_DRR_FPE       12
1009 6 julius
`define OR1200_DU_DRR_TE        13
1010
 
1011
// Define if reading DU regs is allowed
1012
`define OR1200_DU_READREGS
1013
 
1014
// Define if unused DU registers bits should be zero
1015
`define OR1200_DU_UNUSED_ZERO
1016
 
1017
// Define if IF/LSU status is not needed by devel i/f
1018
`define OR1200_DU_STATUS_UNIMPLEMENTED
1019
 
1020
/////////////////////////////////////////////////////
1021
//
1022
// Programmable Interrupt Controller (PIC)
1023
//
1024
 
1025
// Define it if you want PIC implemented
1026
`define OR1200_PIC_IMPLEMENTED
1027
 
1028
// Define number of interrupt inputs (2-31)
1029
`define OR1200_PIC_INTS 20
1030
 
1031
// Address offsets of PIC registers inside PIC group
1032
`define OR1200_PIC_OFS_PICMR 2'd0
1033
`define OR1200_PIC_OFS_PICSR 2'd2
1034
 
1035
// Position of offset bits inside SPR address
1036
`define OR1200_PICOFS_BITS 1:0
1037
 
1038
// Define if you want these PIC registers to be implemented
1039
`define OR1200_PIC_PICMR
1040
`define OR1200_PIC_PICSR
1041
 
1042
// Define if reading PIC registers is allowed
1043
`define OR1200_PIC_READREGS
1044
 
1045
// Define if unused PIC register bits should be zero
1046
`define OR1200_PIC_UNUSED_ZERO
1047
 
1048
 
1049
/////////////////////////////////////////////////////
1050
//
1051
// Tick Timer (TT)
1052
//
1053
 
1054
// Define it if you want TT implemented
1055
`define OR1200_TT_IMPLEMENTED
1056
 
1057
// Address offsets of TT registers inside TT group
1058
`define OR1200_TT_OFS_TTMR 1'd0
1059
`define OR1200_TT_OFS_TTCR 1'd1
1060
 
1061
// Position of offset bits inside SPR group
1062
`define OR1200_TTOFS_BITS 0
1063
 
1064
// Define if you want these TT registers to be implemented
1065
`define OR1200_TT_TTMR
1066
`define OR1200_TT_TTCR
1067
 
1068
// TTMR bits
1069
`define OR1200_TT_TTMR_TP 27:0
1070
`define OR1200_TT_TTMR_IP 28
1071
`define OR1200_TT_TTMR_IE 29
1072
`define OR1200_TT_TTMR_M 31:30
1073
 
1074
// Define if reading TT registers is allowed
1075
`define OR1200_TT_READREGS
1076
 
1077
 
1078
//////////////////////////////////////////////
1079
//
1080
// MAC
1081
//
1082
`define OR1200_MAC_ADDR         0        // MACLO 0xxxxxxxx1, MACHI 0xxxxxxxx0
1083
`define OR1200_MAC_SPR_WE               // Define if MACLO/MACHI are SPR writable
1084
 
1085
//
1086
// Shift {MACHI,MACLO} into destination register when executing l.macrc
1087
//
1088
// According to architecture manual there is no shift, so default value is 0.
1089 356 julius
// However the implementation has deviated in this from the arch manual and had
1090
// hard coded shift by 28 bits which is a useful optimization for MP3 decoding 
1091
// (if using libmad fixed point library). Shifts are no longer default setup, 
1092
// but if you need to remain backward compatible, define your shift bits, which
1093
// were normally
1094 6 julius
// dest_GPR = {MACHI,MACLO}[59:28]
1095
`define OR1200_MAC_SHIFTBY      0        // 0 = According to arch manual, 28 = obsolete backward compatibility
1096
 
1097
 
1098
//////////////////////////////////////////////
1099
//
1100
// Data MMU (DMMU)
1101
//
1102
 
1103
//
1104
// Address that selects between TLB TR and MR
1105
//
1106
`define OR1200_DTLB_TM_ADDR     7
1107
 
1108
//
1109
// DTLBMR fields
1110
//
1111
`define OR1200_DTLBMR_V_BITS    0
1112
`define OR1200_DTLBMR_CID_BITS  4:1
1113
`define OR1200_DTLBMR_RES_BITS  11:5
1114
`define OR1200_DTLBMR_VPN_BITS  31:13
1115
 
1116
//
1117
// DTLBTR fields
1118
//
1119
`define OR1200_DTLBTR_CC_BITS   0
1120
`define OR1200_DTLBTR_CI_BITS   1
1121
`define OR1200_DTLBTR_WBC_BITS  2
1122
`define OR1200_DTLBTR_WOM_BITS  3
1123
`define OR1200_DTLBTR_A_BITS    4
1124
`define OR1200_DTLBTR_D_BITS    5
1125
`define OR1200_DTLBTR_URE_BITS  6
1126
`define OR1200_DTLBTR_UWE_BITS  7
1127
`define OR1200_DTLBTR_SRE_BITS  8
1128
`define OR1200_DTLBTR_SWE_BITS  9
1129
`define OR1200_DTLBTR_RES_BITS  11:10
1130
`define OR1200_DTLBTR_PPN_BITS  31:13
1131
 
1132
//
1133
// DTLB configuration
1134
//
1135
`define OR1200_DMMU_PS          13                                      // 13 for 8KB page size
1136
`define OR1200_DTLB_INDXW       6                                       // 6 for 64 entry DTLB  7 for 128 entries
1137
`define OR1200_DTLB_INDXL       `OR1200_DMMU_PS                         // 13                   13
1138
`define OR1200_DTLB_INDXH       `OR1200_DMMU_PS+`OR1200_DTLB_INDXW-1    // 18                   19
1139
`define OR1200_DTLB_INDX        `OR1200_DTLB_INDXH:`OR1200_DTLB_INDXL   // 18:13                19:13
1140
`define OR1200_DTLB_TAGW        32-`OR1200_DTLB_INDXW-`OR1200_DMMU_PS   // 13                   12
1141
`define OR1200_DTLB_TAGL        `OR1200_DTLB_INDXH+1                    // 19                   20
1142
`define OR1200_DTLB_TAG         31:`OR1200_DTLB_TAGL                    // 31:19                31:20
1143
`define OR1200_DTLBMRW          `OR1200_DTLB_TAGW+1                     // +1 because of V bit
1144
`define OR1200_DTLBTRW          32-`OR1200_DMMU_PS+5                    // +5 because of protection bits and CI
1145
 
1146
//
1147
// Cache inhibit while DMMU is not enabled/implemented
1148
//
1149
// cache inhibited 0GB-4GB              1'b1
1150
// cache inhibited 0GB-2GB              !dcpu_adr_i[31]
1151
// cache inhibited 0GB-1GB 2GB-3GB      !dcpu_adr_i[30]
1152
// cache inhibited 1GB-2GB 3GB-4GB      dcpu_adr_i[30]
1153
// cache inhibited 2GB-4GB (default)    dcpu_adr_i[31]
1154
// cached 0GB-4GB                       1'b0
1155
//
1156 348 julius
`define OR1200_DMMU_CI                  dcpu_adr_i[31]
1157 6 julius
 
1158
 
1159
//////////////////////////////////////////////
1160
//
1161
// Insn MMU (IMMU)
1162
//
1163
 
1164
//
1165
// Address that selects between TLB TR and MR
1166
//
1167
`define OR1200_ITLB_TM_ADDR     7
1168
 
1169
//
1170
// ITLBMR fields
1171
//
1172
`define OR1200_ITLBMR_V_BITS    0
1173
`define OR1200_ITLBMR_CID_BITS  4:1
1174
`define OR1200_ITLBMR_RES_BITS  11:5
1175
`define OR1200_ITLBMR_VPN_BITS  31:13
1176
 
1177
//
1178
// ITLBTR fields
1179
//
1180
`define OR1200_ITLBTR_CC_BITS   0
1181
`define OR1200_ITLBTR_CI_BITS   1
1182
`define OR1200_ITLBTR_WBC_BITS  2
1183
`define OR1200_ITLBTR_WOM_BITS  3
1184
`define OR1200_ITLBTR_A_BITS    4
1185
`define OR1200_ITLBTR_D_BITS    5
1186
`define OR1200_ITLBTR_SXE_BITS  6
1187
`define OR1200_ITLBTR_UXE_BITS  7
1188
`define OR1200_ITLBTR_RES_BITS  11:8
1189
`define OR1200_ITLBTR_PPN_BITS  31:13
1190
 
1191
//
1192
// ITLB configuration
1193
//
1194
`define OR1200_IMMU_PS          13                                      // 13 for 8KB page size
1195
`define OR1200_ITLB_INDXW       6                                       // 6 for 64 entry ITLB  7 for 128 entries
1196
`define OR1200_ITLB_INDXL       `OR1200_IMMU_PS                         // 13                   13
1197
`define OR1200_ITLB_INDXH       `OR1200_IMMU_PS+`OR1200_ITLB_INDXW-1    // 18                   19
1198
`define OR1200_ITLB_INDX        `OR1200_ITLB_INDXH:`OR1200_ITLB_INDXL   // 18:13                19:13
1199
`define OR1200_ITLB_TAGW        32-`OR1200_ITLB_INDXW-`OR1200_IMMU_PS   // 13                   12
1200
`define OR1200_ITLB_TAGL        `OR1200_ITLB_INDXH+1                    // 19                   20
1201
`define OR1200_ITLB_TAG         31:`OR1200_ITLB_TAGL                    // 31:19                31:20
1202
`define OR1200_ITLBMRW          `OR1200_ITLB_TAGW+1                     // +1 because of V bit
1203
`define OR1200_ITLBTRW          32-`OR1200_IMMU_PS+3                    // +3 because of protection bits and CI
1204
 
1205
//
1206
// Cache inhibit while IMMU is not enabled/implemented
1207
// Note: all combinations that use icpu_adr_i cause async loop
1208
//
1209
// cache inhibited 0GB-4GB              1'b1
1210
// cache inhibited 0GB-2GB              !icpu_adr_i[31]
1211
// cache inhibited 0GB-1GB 2GB-3GB      !icpu_adr_i[30]
1212
// cache inhibited 1GB-2GB 3GB-4GB      icpu_adr_i[30]
1213
// cache inhibited 2GB-4GB (default)    icpu_adr_i[31]
1214
// cached 0GB-4GB                       1'b0
1215
//
1216
`define OR1200_IMMU_CI                  1'b0
1217
 
1218
 
1219
/////////////////////////////////////////////////
1220
//
1221
// Insn cache (IC)
1222
//
1223
 
1224
// 3 for 8 bytes, 4 for 16 bytes etc
1225
`define OR1200_ICLS             4
1226
 
1227
//
1228
// IC configurations
1229
//
1230
`ifdef OR1200_IC_1W_512B
1231
`define OR1200_ICSIZE   9     // 512
1232
`define OR1200_ICINDX   `OR1200_ICSIZE-2 // 7
1233
`define OR1200_ICINDXH  `OR1200_ICSIZE-1 // 8
1234
`define OR1200_ICTAGL   `OR1200_ICINDXH+1 // 9
1235
`define OR1200_ICTAG    `OR1200_ICSIZE-`OR1200_ICLS // 5
1236
`define OR1200_ICTAG_W  24
1237
`endif
1238
`ifdef OR1200_IC_1W_4KB
1239
`define OR1200_ICSIZE                   12                      // 4096
1240
`define OR1200_ICINDX                   `OR1200_ICSIZE-2        // 10
1241
`define OR1200_ICINDXH                  `OR1200_ICSIZE-1        // 11
1242
`define OR1200_ICTAGL                   `OR1200_ICINDXH+1       // 12
1243
`define OR1200_ICTAG                    `OR1200_ICSIZE-`OR1200_ICLS     // 8
1244
`define OR1200_ICTAG_W                  21
1245
`endif
1246
`ifdef OR1200_IC_1W_8KB
1247
`define OR1200_ICSIZE                   13                      // 8192
1248
`define OR1200_ICINDX                   `OR1200_ICSIZE-2        // 11
1249
`define OR1200_ICINDXH                  `OR1200_ICSIZE-1        // 12
1250
`define OR1200_ICTAGL                   `OR1200_ICINDXH+1       // 13
1251
`define OR1200_ICTAG                    `OR1200_ICSIZE-`OR1200_ICLS     // 9
1252
`define OR1200_ICTAG_W                  20
1253
`endif
1254 476 julius
`ifdef OR1200_IC_1W_16KB
1255
`define OR1200_ICSIZE                   14                      // 16384
1256
`define OR1200_ICINDX                   `OR1200_ICSIZE-2        // 12
1257
`define OR1200_ICINDXH                  `OR1200_ICSIZE-1        // 13
1258
`define OR1200_ICTAGL                   `OR1200_ICINDXH+1       // 14
1259
`define OR1200_ICTAG                    `OR1200_ICSIZE-`OR1200_ICLS     // 10
1260
`define OR1200_ICTAG_W                  19
1261
`endif
1262 6 julius
 
1263
 
1264
/////////////////////////////////////////////////
1265
//
1266
// Data cache (DC)
1267
//
1268
 
1269
// 3 for 8 bytes, 4 for 16 bytes etc
1270
`define OR1200_DCLS             4
1271
 
1272 348 julius
// Define to enable default behavior of cache as write through
1273
// Turning this off enabled write back statergy
1274
//
1275
`define OR1200_DC_WRITETHROUGH
1276 6 julius
 
1277 348 julius
// Define to enable stores from the stack not doing writethrough.
1278
// EXPERIMENTAL
1279
//`define OR1200_DC_NOSTACKWRITETHROUGH
1280
 
1281
// Data cache SPR definitions
1282
`define OR1200_SPRGRP_DC_ADR_WIDTH 3
1283
// Data cache group SPR addresses
1284
`define OR1200_SPRGRP_DC_DCCR           3'd0 // Not implemented
1285
`define OR1200_SPRGRP_DC_DCBPR          3'd1 // Not implemented
1286
`define OR1200_SPRGRP_DC_DCBFR          3'd2
1287
`define OR1200_SPRGRP_DC_DCBIR          3'd3
1288
`define OR1200_SPRGRP_DC_DCBWR          3'd4 // Not implemented
1289
`define OR1200_SPRGRP_DC_DCBLR          3'd5 // Not implemented
1290
 
1291 6 julius
//
1292
// DC configurations
1293
//
1294
`ifdef OR1200_DC_1W_4KB
1295
`define OR1200_DCSIZE                   12                      // 4096
1296
`define OR1200_DCINDX                   `OR1200_DCSIZE-2        // 10
1297
`define OR1200_DCINDXH                  `OR1200_DCSIZE-1        // 11
1298
`define OR1200_DCTAGL                   `OR1200_DCINDXH+1       // 12
1299
`define OR1200_DCTAG                    `OR1200_DCSIZE-`OR1200_DCLS     // 8
1300
`define OR1200_DCTAG_W                  21
1301
`endif
1302
`ifdef OR1200_DC_1W_8KB
1303
`define OR1200_DCSIZE                   13                      // 8192
1304
`define OR1200_DCINDX                   `OR1200_DCSIZE-2        // 11
1305
`define OR1200_DCINDXH                  `OR1200_DCSIZE-1        // 12
1306
`define OR1200_DCTAGL                   `OR1200_DCINDXH+1       // 13
1307
`define OR1200_DCTAG                    `OR1200_DCSIZE-`OR1200_DCLS     // 9
1308
`define OR1200_DCTAG_W                  20
1309
`endif
1310 476 julius
`ifdef OR1200_DC_1W_16KB
1311
`define OR1200_DCSIZE                   14                      // 16384
1312
`define OR1200_DCINDX                   `OR1200_DCSIZE-2        // 12
1313
`define OR1200_DCINDXH                  `OR1200_DCSIZE-1        // 13
1314
`define OR1200_DCTAGL                   `OR1200_DCINDXH+1       // 14
1315
`define OR1200_DCTAG                    `OR1200_DCSIZE-`OR1200_DCLS     // 10
1316
`define OR1200_DCTAG_W                  19
1317
`endif
1318 6 julius
 
1319 348 julius
 
1320 6 julius
/////////////////////////////////////////////////
1321
//
1322
// Store buffer (SB)
1323
//
1324
 
1325
//
1326
// Store buffer
1327
//
1328
// It will improve performance by "caching" CPU stores
1329
// using store buffer. This is most important for function
1330
// prologues because DC can only work in write though mode
1331
// and all stores would have to complete external WB writes
1332
// to memory.
1333
// Store buffer is between DC and data BIU.
1334
// All stores will be stored into store buffer and immediately
1335
// completed by the CPU, even though actual external writes
1336
// will be performed later. As a consequence store buffer masks
1337
// all data bus errors related to stores (data bus errors
1338
// related to loads are delivered normally).
1339
// All pending CPU loads will wait until store buffer is empty to
1340
// ensure strict memory model. Right now this is necessary because
1341
// we don't make destinction between cached and cache inhibited
1342
// address space, so we simply empty store buffer until loads
1343
// can begin.
1344
//
1345
// It makes design a bit bigger, depending what is the number of
1346
// entries in SB FIFO. Number of entries can be changed further
1347
// down.
1348
//
1349
//`define OR1200_SB_IMPLEMENTED
1350
 
1351
//
1352
// Number of store buffer entries
1353
//
1354
// Verified number of entries are 4 and 8 entries
1355
// (2 and 3 for OR1200_SB_LOG). OR1200_SB_ENTRIES must
1356
// always match 2**OR1200_SB_LOG.
1357
// To disable store buffer, undefine
1358
// OR1200_SB_IMPLEMENTED.
1359
//
1360
`define OR1200_SB_LOG           2       // 2 or 3
1361
`define OR1200_SB_ENTRIES       4       // 4 or 8
1362
 
1363
 
1364
/////////////////////////////////////////////////
1365
//
1366
// Quick Embedded Memory (QMEM)
1367
//
1368
 
1369
//
1370
// Quick Embedded Memory
1371
//
1372
// Instantiation of dedicated insn/data memory (RAM or ROM).
1373
// Insn fetch has effective throughput 1insn / clock cycle.
1374
// Data load takes two clock cycles / access, data store
1375
// takes 1 clock cycle / access (if there is no insn fetch)).
1376
// Memory instantiation is shared between insn and data,
1377
// meaning if insn fetch are performed, data load/store
1378
// performance will be lower.
1379
//
1380
// Main reason for QMEM is to put some time critical functions
1381
// into this memory and to have predictable and fast access
1382
// to these functions. (soft fpu, context switch, exception
1383
// handlers, stack, etc)
1384
//
1385
// It makes design a bit bigger and slower. QMEM sits behind
1386
// IMMU/DMMU so all addresses are physical (so the MMUs can be
1387
// used with QMEM and QMEM is seen by the CPU just like any other
1388
// memory in the system). IC/DC are sitting behind QMEM so the
1389
// whole design timing might be worse with QMEM implemented.
1390
//
1391
//`define OR1200_QMEM_IMPLEMENTED
1392
 
1393
//
1394
// Base address and mask of QMEM
1395
//
1396
// Base address defines first address of QMEM. Mask defines
1397
// QMEM range in address space. Actual size of QMEM is however
1398
// determined with instantiated RAM/ROM. However bigger
1399
// mask will reserve more address space for QMEM, but also
1400
// make design faster, while more tight mask will take
1401
// less address space but also make design slower. If
1402
// instantiated RAM/ROM is smaller than space reserved with
1403
// the mask, instatiated RAM/ROM will also be shadowed
1404
// at higher addresses in reserved space.
1405
//
1406
`define OR1200_QMEM_IADDR       32'h0080_0000
1407 348 julius
`define OR1200_QMEM_IMASK       32'hfff0_0000 // Max QMEM size 1MB
1408
`define OR1200_QMEM_DADDR       32'h0080_0000
1409
`define OR1200_QMEM_DMASK       32'hfff0_0000 // Max QMEM size 1MB
1410 6 julius
 
1411
//
1412
// QMEM interface byte-select capability
1413
//
1414
// To enable qmem_sel* ports, define this macro.
1415
//
1416
//`define OR1200_QMEM_BSEL
1417
 
1418
//
1419
// QMEM interface acknowledge
1420
//
1421
// To enable qmem_ack port, define this macro.
1422
//
1423
//`define OR1200_QMEM_ACK
1424
 
1425
/////////////////////////////////////////////////////
1426
//
1427
// VR, UPR and Configuration Registers
1428
//
1429
//
1430
// VR, UPR and configuration registers are optional. If 
1431
// implemented, operating system can automatically figure
1432
// out how to use the processor because it knows 
1433
// what units are available in the processor and how they
1434
// are configured.
1435
//
1436
// This section must be last in or1200_defines.v file so
1437
// that all units are already configured and thus
1438
// configuration registers are properly set.
1439
// 
1440
 
1441
// Define if you want configuration registers implemented
1442
`define OR1200_CFGR_IMPLEMENTED
1443
 
1444
// Define if you want full address decode inside SYS group
1445
`define OR1200_SYS_FULL_DECODE
1446
 
1447
// Offsets of VR, UPR and CFGR registers
1448
`define OR1200_SPRGRP_SYS_VR            4'h0
1449
`define OR1200_SPRGRP_SYS_UPR           4'h1
1450
`define OR1200_SPRGRP_SYS_CPUCFGR       4'h2
1451
`define OR1200_SPRGRP_SYS_DMMUCFGR      4'h3
1452
`define OR1200_SPRGRP_SYS_IMMUCFGR      4'h4
1453
`define OR1200_SPRGRP_SYS_DCCFGR        4'h5
1454
`define OR1200_SPRGRP_SYS_ICCFGR        4'h6
1455
`define OR1200_SPRGRP_SYS_DCFGR 4'h7
1456
 
1457
// VR fields
1458
`define OR1200_VR_REV_BITS              5:0
1459
`define OR1200_VR_RES1_BITS             15:6
1460
`define OR1200_VR_CFG_BITS              23:16
1461
`define OR1200_VR_VER_BITS              31:24
1462
 
1463
// VR values
1464 348 julius
`define OR1200_VR_REV                   6'h08
1465 6 julius
`define OR1200_VR_RES1                  10'h000
1466
`define OR1200_VR_CFG                   8'h00
1467
`define OR1200_VR_VER                   8'h12
1468
 
1469
// UPR fields
1470
`define OR1200_UPR_UP_BITS              0
1471
`define OR1200_UPR_DCP_BITS             1
1472
`define OR1200_UPR_ICP_BITS             2
1473
`define OR1200_UPR_DMP_BITS             3
1474
`define OR1200_UPR_IMP_BITS             4
1475
`define OR1200_UPR_MP_BITS              5
1476
`define OR1200_UPR_DUP_BITS             6
1477
`define OR1200_UPR_PCUP_BITS            7
1478
`define OR1200_UPR_PMP_BITS             8
1479
`define OR1200_UPR_PICP_BITS            9
1480
`define OR1200_UPR_TTP_BITS             10
1481 348 julius
`define OR1200_UPR_FPP_BITS             11
1482
`define OR1200_UPR_RES1_BITS            23:12
1483 6 julius
`define OR1200_UPR_CUP_BITS             31:24
1484
 
1485
// UPR values
1486
`define OR1200_UPR_UP                   1'b1
1487
`ifdef OR1200_NO_DC
1488
`define OR1200_UPR_DCP                  1'b0
1489
`else
1490
`define OR1200_UPR_DCP                  1'b1
1491
`endif
1492
`ifdef OR1200_NO_IC
1493
`define OR1200_UPR_ICP                  1'b0
1494
`else
1495
`define OR1200_UPR_ICP                  1'b1
1496
`endif
1497
`ifdef OR1200_NO_DMMU
1498
`define OR1200_UPR_DMP                  1'b0
1499
`else
1500
`define OR1200_UPR_DMP                  1'b1
1501
`endif
1502
`ifdef OR1200_NO_IMMU
1503
`define OR1200_UPR_IMP                  1'b0
1504
`else
1505
`define OR1200_UPR_IMP                  1'b1
1506
`endif
1507 348 julius
`ifdef OR1200_MAC_IMPLEMENTED
1508
`define OR1200_UPR_MP                   1'b1
1509
`else
1510
`define OR1200_UPR_MP                   1'b0
1511
`endif
1512 6 julius
`ifdef OR1200_DU_IMPLEMENTED
1513
`define OR1200_UPR_DUP                  1'b1
1514
`else
1515
`define OR1200_UPR_DUP                  1'b0
1516
`endif
1517
`define OR1200_UPR_PCUP                 1'b0    // Performance counters not present
1518 348 julius
`ifdef OR1200_PM_IMPLEMENTED
1519 6 julius
`define OR1200_UPR_PMP                  1'b1
1520
`else
1521
`define OR1200_UPR_PMP                  1'b0
1522
`endif
1523 348 julius
`ifdef OR1200_PIC_IMPLEMENTED
1524 6 julius
`define OR1200_UPR_PICP                 1'b1
1525
`else
1526
`define OR1200_UPR_PICP                 1'b0
1527
`endif
1528 348 julius
`ifdef OR1200_TT_IMPLEMENTED
1529 6 julius
`define OR1200_UPR_TTP                  1'b1
1530
`else
1531
`define OR1200_UPR_TTP                  1'b0
1532
`endif
1533 348 julius
`ifdef OR1200_FPU_IMPLEMENTED
1534
`define OR1200_UPR_FPP                  1'b1
1535
`else
1536
`define OR1200_UPR_FPP                  1'b0
1537
`endif
1538
`define OR1200_UPR_RES1                 12'h000
1539 6 julius
`define OR1200_UPR_CUP                  8'h00
1540
 
1541
// CPUCFGR fields
1542
`define OR1200_CPUCFGR_NSGF_BITS        3:0
1543
`define OR1200_CPUCFGR_HGF_BITS     4
1544
`define OR1200_CPUCFGR_OB32S_BITS       5
1545
`define OR1200_CPUCFGR_OB64S_BITS       6
1546
`define OR1200_CPUCFGR_OF32S_BITS       7
1547
`define OR1200_CPUCFGR_OF64S_BITS       8
1548
`define OR1200_CPUCFGR_OV64S_BITS       9
1549
`define OR1200_CPUCFGR_RES1_BITS        31:10
1550
 
1551
// CPUCFGR values
1552
`define OR1200_CPUCFGR_NSGF                 4'h0
1553
`ifdef OR1200_RFRAM_16REG
1554
    `define OR1200_CPUCFGR_HGF                  1'b1
1555
`else
1556
    `define OR1200_CPUCFGR_HGF                  1'b0
1557
`endif
1558
`define OR1200_CPUCFGR_OB32S            1'b1
1559
`define OR1200_CPUCFGR_OB64S            1'b0
1560 348 julius
`ifdef OR1200_FPU_IMPLEMENTED
1561
 `define OR1200_CPUCFGR_OF32S           1'b1
1562
`else
1563
 `define OR1200_CPUCFGR_OF32S           1'b0
1564
`endif
1565
 
1566 6 julius
`define OR1200_CPUCFGR_OF64S            1'b0
1567
`define OR1200_CPUCFGR_OV64S            1'b0
1568
`define OR1200_CPUCFGR_RES1             22'h000000
1569
 
1570
// DMMUCFGR fields
1571
`define OR1200_DMMUCFGR_NTW_BITS        1:0
1572
`define OR1200_DMMUCFGR_NTS_BITS        4:2
1573
`define OR1200_DMMUCFGR_NAE_BITS        7:5
1574
`define OR1200_DMMUCFGR_CRI_BITS        8
1575
`define OR1200_DMMUCFGR_PRI_BITS        9
1576
`define OR1200_DMMUCFGR_TEIRI_BITS      10
1577
`define OR1200_DMMUCFGR_HTR_BITS        11
1578
`define OR1200_DMMUCFGR_RES1_BITS       31:12
1579
 
1580
// DMMUCFGR values
1581
`ifdef OR1200_NO_DMMU
1582
`define OR1200_DMMUCFGR_NTW             2'h0    // Irrelevant
1583
`define OR1200_DMMUCFGR_NTS             3'h0    // Irrelevant
1584
`define OR1200_DMMUCFGR_NAE             3'h0    // Irrelevant
1585
`define OR1200_DMMUCFGR_CRI             1'b0    // Irrelevant
1586
`define OR1200_DMMUCFGR_PRI             1'b0    // Irrelevant
1587
`define OR1200_DMMUCFGR_TEIRI           1'b0    // Irrelevant
1588
`define OR1200_DMMUCFGR_HTR             1'b0    // Irrelevant
1589
`define OR1200_DMMUCFGR_RES1            20'h00000
1590
`else
1591
`define OR1200_DMMUCFGR_NTW             2'h0    // 1 TLB way
1592
`define OR1200_DMMUCFGR_NTS 3'h`OR1200_DTLB_INDXW       // Num TLB sets
1593
`define OR1200_DMMUCFGR_NAE             3'h0    // No ATB entries
1594
`define OR1200_DMMUCFGR_CRI             1'b0    // No control register
1595
`define OR1200_DMMUCFGR_PRI             1'b0    // No protection reg
1596
`define OR1200_DMMUCFGR_TEIRI           1'b1    // TLB entry inv reg impl.
1597
`define OR1200_DMMUCFGR_HTR             1'b0    // No HW TLB reload
1598
`define OR1200_DMMUCFGR_RES1            20'h00000
1599
`endif
1600
 
1601
// IMMUCFGR fields
1602
`define OR1200_IMMUCFGR_NTW_BITS        1:0
1603
`define OR1200_IMMUCFGR_NTS_BITS        4:2
1604
`define OR1200_IMMUCFGR_NAE_BITS        7:5
1605
`define OR1200_IMMUCFGR_CRI_BITS        8
1606
`define OR1200_IMMUCFGR_PRI_BITS        9
1607
`define OR1200_IMMUCFGR_TEIRI_BITS      10
1608
`define OR1200_IMMUCFGR_HTR_BITS        11
1609
`define OR1200_IMMUCFGR_RES1_BITS       31:12
1610
 
1611
// IMMUCFGR values
1612
`ifdef OR1200_NO_IMMU
1613
`define OR1200_IMMUCFGR_NTW             2'h0    // Irrelevant
1614
`define OR1200_IMMUCFGR_NTS             3'h0    // Irrelevant
1615
`define OR1200_IMMUCFGR_NAE             3'h0    // Irrelevant
1616
`define OR1200_IMMUCFGR_CRI             1'b0    // Irrelevant
1617
`define OR1200_IMMUCFGR_PRI             1'b0    // Irrelevant
1618
`define OR1200_IMMUCFGR_TEIRI           1'b0    // Irrelevant
1619
`define OR1200_IMMUCFGR_HTR             1'b0    // Irrelevant
1620
`define OR1200_IMMUCFGR_RES1            20'h00000
1621
`else
1622
`define OR1200_IMMUCFGR_NTW             2'h0    // 1 TLB way
1623
`define OR1200_IMMUCFGR_NTS 3'h`OR1200_ITLB_INDXW       // Num TLB sets
1624
`define OR1200_IMMUCFGR_NAE             3'h0    // No ATB entry
1625
`define OR1200_IMMUCFGR_CRI             1'b0    // No control reg
1626
`define OR1200_IMMUCFGR_PRI             1'b0    // No protection reg
1627
`define OR1200_IMMUCFGR_TEIRI           1'b1    // TLB entry inv reg impl
1628
`define OR1200_IMMUCFGR_HTR             1'b0    // No HW TLB reload
1629
`define OR1200_IMMUCFGR_RES1            20'h00000
1630
`endif
1631
 
1632
// DCCFGR fields
1633
`define OR1200_DCCFGR_NCW_BITS          2:0
1634
`define OR1200_DCCFGR_NCS_BITS          6:3
1635
`define OR1200_DCCFGR_CBS_BITS          7
1636
`define OR1200_DCCFGR_CWS_BITS          8
1637
`define OR1200_DCCFGR_CCRI_BITS         9
1638
`define OR1200_DCCFGR_CBIRI_BITS        10
1639
`define OR1200_DCCFGR_CBPRI_BITS        11
1640
`define OR1200_DCCFGR_CBLRI_BITS        12
1641
`define OR1200_DCCFGR_CBFRI_BITS        13
1642
`define OR1200_DCCFGR_CBWBRI_BITS       14
1643
`define OR1200_DCCFGR_RES1_BITS 31:15
1644
 
1645
// DCCFGR values
1646
`ifdef OR1200_NO_DC
1647
`define OR1200_DCCFGR_NCW               3'h0    // Irrelevant
1648
`define OR1200_DCCFGR_NCS               4'h0    // Irrelevant
1649
`define OR1200_DCCFGR_CBS               1'b0    // Irrelevant
1650
`define OR1200_DCCFGR_CWS               1'b0    // Irrelevant
1651 348 julius
`define OR1200_DCCFGR_CCRI              1'b0    // Irrelevant
1652
`define OR1200_DCCFGR_CBIRI             1'b0    // Irrelevant
1653 6 julius
`define OR1200_DCCFGR_CBPRI             1'b0    // Irrelevant
1654
`define OR1200_DCCFGR_CBLRI             1'b0    // Irrelevant
1655 348 julius
`define OR1200_DCCFGR_CBFRI             1'b0    // Irrelevant
1656 6 julius
`define OR1200_DCCFGR_CBWBRI            1'b0    // Irrelevant
1657
`define OR1200_DCCFGR_RES1              17'h00000
1658
`else
1659
`define OR1200_DCCFGR_NCW               3'h0    // 1 cache way
1660
`define OR1200_DCCFGR_NCS (`OR1200_DCTAG)       // Num cache sets
1661 363 julius
`define OR1200_DCCFGR_CBS `OR1200_DCLS==4 ? 1'b0 : 1'b1 // 16 byte cache block
1662 348 julius
`ifdef OR1200_DC_WRITETHROUGH
1663
 `define OR1200_DCCFGR_CWS              1'b0    // Write-through strategy
1664
`else
1665
 `define OR1200_DCCFGR_CWS              1'b1    // Write-back strategy
1666
`endif
1667 6 julius
`define OR1200_DCCFGR_CCRI              1'b1    // Cache control reg impl.
1668
`define OR1200_DCCFGR_CBIRI             1'b1    // Cache block inv reg impl.
1669
`define OR1200_DCCFGR_CBPRI             1'b0    // Cache block prefetch reg not impl.
1670
`define OR1200_DCCFGR_CBLRI             1'b0    // Cache block lock reg not impl.
1671
`define OR1200_DCCFGR_CBFRI             1'b1    // Cache block flush reg impl.
1672 348 julius
`ifdef OR1200_DC_WRITETHROUGH
1673
 `define OR1200_DCCFGR_CBWBRI           1'b0    // Cache block WB reg not impl.
1674
`else
1675
 `define OR1200_DCCFGR_CBWBRI           1'b1    // Cache block WB reg impl.
1676
`endif
1677 6 julius
`define OR1200_DCCFGR_RES1              17'h00000
1678
`endif
1679
 
1680
// ICCFGR fields
1681
`define OR1200_ICCFGR_NCW_BITS          2:0
1682
`define OR1200_ICCFGR_NCS_BITS          6:3
1683
`define OR1200_ICCFGR_CBS_BITS          7
1684
`define OR1200_ICCFGR_CWS_BITS          8
1685
`define OR1200_ICCFGR_CCRI_BITS         9
1686
`define OR1200_ICCFGR_CBIRI_BITS        10
1687
`define OR1200_ICCFGR_CBPRI_BITS        11
1688
`define OR1200_ICCFGR_CBLRI_BITS        12
1689
`define OR1200_ICCFGR_CBFRI_BITS        13
1690
`define OR1200_ICCFGR_CBWBRI_BITS       14
1691
`define OR1200_ICCFGR_RES1_BITS 31:15
1692
 
1693
// ICCFGR values
1694
`ifdef OR1200_NO_IC
1695
`define OR1200_ICCFGR_NCW               3'h0    // Irrelevant
1696
`define OR1200_ICCFGR_NCS               4'h0    // Irrelevant
1697
`define OR1200_ICCFGR_CBS               1'b0    // Irrelevant
1698
`define OR1200_ICCFGR_CWS               1'b0    // Irrelevant
1699
`define OR1200_ICCFGR_CCRI              1'b0    // Irrelevant
1700
`define OR1200_ICCFGR_CBIRI             1'b0    // Irrelevant
1701
`define OR1200_ICCFGR_CBPRI             1'b0    // Irrelevant
1702
`define OR1200_ICCFGR_CBLRI             1'b0    // Irrelevant
1703
`define OR1200_ICCFGR_CBFRI             1'b0    // Irrelevant
1704
`define OR1200_ICCFGR_CBWBRI            1'b0    // Irrelevant
1705
`define OR1200_ICCFGR_RES1              17'h00000
1706
`else
1707
`define OR1200_ICCFGR_NCW               3'h0    // 1 cache way
1708
`define OR1200_ICCFGR_NCS (`OR1200_ICTAG)       // Num cache sets
1709 363 julius
`define OR1200_ICCFGR_CBS `OR1200_ICLS==4 ? 1'b0: 1'b1  // 16 byte cache block
1710 6 julius
`define OR1200_ICCFGR_CWS               1'b0    // Irrelevant
1711
`define OR1200_ICCFGR_CCRI              1'b1    // Cache control reg impl.
1712
`define OR1200_ICCFGR_CBIRI             1'b1    // Cache block inv reg impl.
1713
`define OR1200_ICCFGR_CBPRI             1'b0    // Cache block prefetch reg not impl.
1714
`define OR1200_ICCFGR_CBLRI             1'b0    // Cache block lock reg not impl.
1715
`define OR1200_ICCFGR_CBFRI             1'b1    // Cache block flush reg impl.
1716
`define OR1200_ICCFGR_CBWBRI            1'b0    // Irrelevant
1717
`define OR1200_ICCFGR_RES1              17'h00000
1718
`endif
1719
 
1720
// DCFGR fields
1721 348 julius
`define OR1200_DCFGR_NDP_BITS           3:0
1722
`define OR1200_DCFGR_WPCI_BITS          4
1723
`define OR1200_DCFGR_RES1_BITS          31:5
1724 6 julius
 
1725
// DCFGR values
1726
`ifdef OR1200_DU_HWBKPTS
1727 348 julius
`define OR1200_DCFGR_NDP                4'h`OR1200_DU_DVRDCR_PAIRS // # of DVR/DCR pairs
1728 6 julius
`ifdef OR1200_DU_DWCR0
1729
`define OR1200_DCFGR_WPCI               1'b1
1730
`else
1731
`define OR1200_DCFGR_WPCI               1'b0    // WP counters not impl.
1732
`endif
1733
`else
1734 348 julius
`define OR1200_DCFGR_NDP                4'h0    // Zero DVR/DCR pairs
1735 6 julius
`define OR1200_DCFGR_WPCI               1'b0    // WP counters not impl.
1736
`endif
1737 363 julius
`define OR1200_DCFGR_RES1               27'd0
1738 348 julius
 
1739
///////////////////////////////////////////////////////////////////////////////
1740
// Boot Address Selection                                                    //
1741
// This only changes where the initial reset occurs. EPH setting is still    //
1742
// used to determine where vectors are located.                              //
1743
///////////////////////////////////////////////////////////////////////////////
1744
 // Boot from 0xf0000100
1745
//`define OR1200_BOOT_PCREG_DEFAULT 30'h3c00003f
1746
//`define OR1200_BOOT_ADR 32'hf0000100
1747
// Boot from 0x100
1748
 `define OR1200_BOOT_PCREG_DEFAULT 30'h0000003f
1749
 `define OR1200_BOOT_ADR 32'h00000100

powered by: WebSVN 2.1.0

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