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

Subversion Repositories darkriscv

[/] [darkriscv/] [trunk/] [rtl/] [config.vh] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 marcelos
/*
2
 * Copyright (c) 2018, Marcelo Samsoniuk
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * * Redistributions of source code must retain the above copyright notice, this
9
 *   list of conditions and the following disclaimer.
10
 *
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 *   this list of conditions and the following disclaimer in the documentation
13
 *   and/or other materials provided with the distribution.
14
 *
15
 * * Neither the name of the copyright holder nor the names of its
16
 *   contributors may be used to endorse or promote products derived from
17
 *   this software without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
 
31
`timescale 1ns / 1ps
32
 
33
// memory architecture
34
//
35
// TODO: fix the different memory architecture concepts:
36
// status:
37
// ICACHE: works without interrupt
38
// DCACHE: does not work!
39
// WAITSTATE: works
40
// 
41
//`define __ICACHE__              // instruction cache
42
//`define __DCACHE__              // data cache (bug: simulation only)
43
//`define __WAITSTATES__          // wait-state tests, no cache
44
 
45
// peripheral configuration
46
//
47
// UART speed is set in bits per second, typically 115200 bps:
48
 
49
`define __UARTSPEED__ 115200
50
 
51
// darkriscv/darksocv configuration
52
// 
53
// pipeline stages:
54
// 
55
// 2-stage version: core and memory in different clock edges result in less
56
// clock performance, but less losses when the program counter changes
57
// (pipeline flush = 1 clock).  Works like a 4-stage pipeline and remember
58
// the 68040 clock scheme, with instruction per clock = 1.  alternatively,
59
// it is possible work w/ 1 wait-state and 1 clock edge, but with a penalty
60
// in performance (instruction per clock = 0.5).
61
// 
62
// 3-stage version: core and memory in the same clock edge require one extra
63
// stage in the pipeline, but keep a good performance most of time
64
// (instruction per clock = 1).  of course, read operations require 1
65
// wait-state, which means sometimes the read performance is reduced.
66
 
67
`define __3STAGE__
68
 
69
// muti-threading support:
70
//
71
// Decreases clock performance by 10% (90MHz), but enables two contexts
72
// (threads) in the core.  They start in the same code, but the "interrupt"
73
// handling is locked in a separate loop and the conext switch is always
74
// delayed until the next pipeline flush, in order to decrease the
75
// performance impact.  Note: threading is currently supported only in the
76
// 3-stage pipeline version.
77
 
78
//`define __THREADING__
79
 
80
// performance measurement:
81
//
82
// The performance measurement can be done in the simulation level by
83
// eabling the __PERFMETER__ define, in order to check how the clock cycles
84
// are used in the core.  The value defines how many clocks are computed
85
// before print the result.
86
 
87
//`define __PERFMETER__ 70000
88
 
89
// mac instruction: 
90
// 
91
// The mac instruction is similar to other register to register
92
// instructions, but with a different opcode 7'h1111111.  the format is mac
93
// rd,r1,r2, but is not currently possible encode in asm, by this way it is
94
// available in licb as int mac(int rd, short r1, short r2).  Although it
95
// can be used to accelerate the mul/div operations, the mac operation is
96
// designed for DSP applications.  with some effort (low level machine
97
// code), it is possible peak 100MMAC/s @100MHz.
98
 
99
//`define __MAC16X16__
100
 
101
// RV32I vs RV32E:
102
//
103
// The difference between the RV32I and RV32E regarding the logic space is 
104
// minimal in typical applications with modern 5 or 6 input LUT based FPGAs, 
105
// but the RV32E is better with old 4 input LUT based FPGAs.
106
 
107
`define __RV32E__
108
 
109
// initial PC and SP
110
//
111
// it is possible program the initial PC and SP.  Typically, the PC is set
112
// to address 0, representing the start of ROM memory and the SP is set to
113
// the final of RAM memory.  In the linker, the start of ROM memory matches
114
// with the .text area, which is defined in the boot.c code and the start of
115
// RAM memory matches with the .data and other volatile data, in a way that
116
// the stack can be positioned in the top of RAM and does not match with the
117
// .data.
118
 
119
`define __HARVARD__
120
 
121
// full harvard architecture:
122
// 
123
// When defined, enforses that the instruction and data buses are connected
124
// to fully separate memory banks.  Although the darkriscv always use
125
// harvard architecture in the core, with separate instruction and data
126
// buses, the logic levels outside the core can use different architectures
127
// and concepts, including von neumann, wich a single bus shared by
128
// instruction and data access, as well a mix between harvard and von
129
// neumann, which is possible in the case of dual-port blockrams, where is
130
// possible connect two separate buses in a single memory bank.  the main
131
// advantage of a single memory bank is that the .text and .data areas can
132
// be better allocated, but in this case is not possible protect the .text
133
// area as in the case of separate memory banks.
134
 
135
`define __FLEXBUZZ__
136
 
137
// flexbuzz interface (experimental):
138
//
139
// A new data bus interface similar to a well known c*ldfire bus interface, in 
140
// a way that part of the bus routing is moved to the core, in a way that 
141
// is possible support different bus widths (8, 16 or 32 bit) and endians more 
142
// easily (the new interface is natively big-endian, but the endian can be adjusted
143
// in the bus interface dinamically). Similarly to the standard 32-bit interface, 
144
// the external logic must detect the RD/WR operation quick enough and assert HLT 
145
// in order to insert wait-states and perform the required multiplexing to fit 
146
// the DLEN operand size in the data bus width available.
147
 
148
`define __RESETPC__ 32'd0
149
`define __RESETSP__ 32'd8192
150
 
151
// board definition:
152
// 
153
// The board is automatically defined in the xst/xise files via Makefile or
154
// ISE. Case it is not the case, please define you board name here:
155
 
156
//`define AVNET_MICROBOARD_LX9
157
//`define XILINX_AC701_A200
158
//`define QMTECH_SDRAM_LX16
159
 
160
// the following defines are automatically defined:
161
 
162
`ifdef __ICARUS__
163
    `define SIMULATION 1
164
`endif
165
 
166
`ifdef XILINX_ISIM
167
    `define SIMULATION 2
168
`endif
169
 
170
`ifdef MODEL_TECH
171
    `define SIMULATION 3
172
`endif
173
 
174
`ifdef XILINX_SIMULATOR
175
    `define SIMULATION 4
176
`endif
177
 
178
`ifdef AVNET_MICROBOARD_LX9
179
    `define BOARD_ID 1
180
    //`define BOARD_CK 100000000
181
    //`define BOARD_CK 66666666
182
    //`define BOARD_CK 40000000
183
    // example of DCM logic:
184
    `define BOARD_CK_REF 100000000
185
    `define BOARD_CK_MUL 2
186
    `ifdef __3STAGE__
187
        `define BOARD_CK_DIV 2 // 100MHz 
188
    `else
189
        `define BOARD_CK_DIV 4 // 50MHz
190
    `endif
191
`endif
192
 
193
`ifdef XILINX_AC701_A200
194
    `define BOARD_ID 2
195
    //`define BOARD_CK 90000000
196
    `define BOARD_CK_REF 90000000
197
    `define BOARD_CK_MUL 4
198
    `define BOARD_CK_DIV 2
199
`endif
200
 
201
`ifdef QMTECH_SDRAM_LX16
202
    `define BOARD_ID 3
203
    `define BOARD_CK_REF 50000000
204
    `define BOARD_CK_MUL 4
205
    `define BOARD_CK_DIV 2
206
    `define INVRES 1
207
`endif
208
 
209
`ifdef QMTECH_SPARTAN7_S15
210
    `define BOARD_ID 4
211
    `define BOARD_CK_REF 50000000
212
    `define BOARD_CK_MUL 20
213
    `define BOARD_CK_DIV 10
214
    `define XILINX7CLK 1
215
    `define VIVADO 1
216
    `define INVRES 1
217
`endif
218
 
219
`ifdef LATTICE_BREVIA2_XP2
220
    `define BOARD_ID 5
221
    `define BOARD_CK 50000000
222
    `define INVRES 1
223
`endif
224
 
225
`ifdef PISWORDS_RS485_LX9
226
    `define BOARD_ID 6
227
    `define BOARD_CK_REF 50000000
228
    `define BOARD_CK_MUL 4
229
    `define BOARD_CK_DIV 2
230
    `define INVRES 1
231
`endif
232
 
233
`ifdef DIGILENT_SPARTAN3_S200
234
    `define BOARD_ID 7
235
    `define BOARD_CK 50000000
236
`endif
237
 
238
`ifdef ALIEXPRESS_HPC40GBE_K420
239
    `define BOARD_ID 8
240
    //`define BOARD_CK 200000000
241
    `define BOARD_CK_REF 100000000
242
    `define BOARD_CK_MUL 11
243
    `define BOARD_CK_DIV 5
244
    `define XILINX7CLK 1
245
    `define INVRES 1
246
`endif
247
 
248
`ifdef QMTECH_ARTIX7_A35
249
    `define BOARD_ID 9
250
    `define BOARD_CK_REF 50000000
251
    `define BOARD_CK_MUL 20
252
    `define BOARD_CK_DIV 10
253
    `define XILINX7CLK 1
254
    `define VIVADO 1
255
    `define INVRES 1
256
`endif
257
 
258
`ifndef BOARD_ID
259
    `define BOARD_ID 0
260
    `define BOARD_CK 100000000
261
`endif
262
 
263
`ifdef BOARD_CK_REF
264
    `define BOARD_CK (`BOARD_CK_REF * `BOARD_CK_MUL / `BOARD_CK_DIV)
265
`endif
266
 
267
// darkuart baudrate automtically calculated according to board clock:
268
 
269
`ifndef __UARTSPEED__
270
  `define __UARTSPEED__ 115200
271
`endif
272
 
273
`define  __BAUD__ ((`BOARD_CK/`__UARTSPEED__))

powered by: WebSVN 2.1.0

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