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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [cpu/] [cpudefs.v] - Blame information for rev 32

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

Line No. Rev Author Line
1 2 dgisselq
///////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    cpudefs.v
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU soft core
6
//
7
// Purpose:     Some architectures have some needs, others have other needs.
8
//              Some of my projects need a Zip CPU with pipelining, others
9
//      can't handle the timing required to get the answer from the ALU
10
//      back into the input for the ALU.  As each different projects has
11
//      different needs, I can either 1) reconfigure my entire baseline prior
12
//      to building each project, or 2) host a configuration file which contains
13
//      the information regarding each baseline.  This file is that
14
//      configuration file.  It controls how the CPU (not the system,
15
//      peripherals, or other) is defined and implemented.  Several options
16
//      are available within here, making the Zip CPU pipelined or not,
17
//      able to handle a faster clock with more stalls or a slower clock with
18
//      no stalls, etc.
19
//
20
//      This file encapsulates those control options.
21
//
22
//      The number of LUTs the Zip CPU uses varies dramatically with the
23
//      options defined in this file.
24
//
25
//
26
// Creator:     Dan Gisselquist, Ph.D.
27
//              Gisselquist Technology, LLC
28
//
29
///////////////////////////////////////////////////////////////////////////////
30
//
31
// Copyright (C) 2015, Gisselquist Technology, LLC
32
//
33
// This program is free software (firmware): you can redistribute it and/or
34
// modify it under the terms of  the GNU General Public License as published
35
// by the Free Software Foundation, either version 3 of the License, or (at
36
// your option) any later version.
37
//
38
// This program is distributed in the hope that it will be useful, but WITHOUT
39
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
40
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
41
// for more details.
42
//
43
// License:     GPL, v3, as defined and found on www.gnu.org,
44
//              http://www.gnu.org/licenses/gpl.html
45
//
46
//
47
///////////////////////////////////////////////////////////////////////////////
48
`ifndef CPUDEFS_H
49
`define CPUDEFS_H
50
//
51
//
52
// The first couple options control the Zip CPU instruction set, and how
53
// it handles various instructions within the set:
54
//
55
//
56
// OPT_ILLEGAL_INSTRUCTION is part of a new section of code that is supposed
57
// to recognize illegal instructions and interrupt the CPU whenever one such
58
// instruction is encountered.  The goal is to create a soft floating point
59
// unit via this approach, that can then be replaced with a true floating point
60
// unit.  As I'm not there yet, it just catches illegal instructions and
61
// interrupts the CPU on any such instruction--when defined.  Otherwise,
62
// illegal instructions are quietly ignored and their behaviour is ...
63
// undefined. (Many get treated like NOOPs ...)
64
//
65
// I recommend setting this flag, although it can be taken out if area is
66
// critical ...
67
//
68
`define OPT_ILLEGAL_INSTRUCTION
69
//
70
//
71
//
72
// OPT_MULTIPLY controls whether or not the multiply is built and included
73
// in the ALU by default.  Set this option and a parameter will be set that
74
// includes the multiply.  (This parameter may still be overridden, as with
75
// any parameter ...)  If the multiply is not included and
76
// OPT_ILLEGAL_INSTRUCTION is set, then the multiply will create an illegal
77
// instruction that will then trip the illegal instruction trap.
78
//
79
//
80
`define OPT_MULTIPLY
81
//
82
//
83
//
84
// OPT_DIVIDE controls whether or not the divide instruction is built and
85
// included into the ZipCPU by default.  Set this option and a parameter will
86
// be set that causes the divide unit to be included.  (This parameter may
87
// still be overridden, as with any parameter ...)  If the divide is not
88
// included and OPT_ILLEGAL_INSTRUCTION is set, then the multiply will create
89
// an illegal instruction exception that will send the CPU into supervisor
90
// mode.
91
//
92
//
93 31 dgisselq
`ifdef  XULA25
94 2 dgisselq
`define OPT_DIVIDE
95 31 dgisselq
`endif
96 2 dgisselq
//
97
//
98
//
99
// OPT_IMPLEMENT_FPU will (one day) control whether or not the floating point
100
// unit (once I have one) is built and included into the ZipCPU by default. 
101
// At that time, if this option is set then a parameter will be set that
102
// causes the floating point unit to be included.  (This parameter may
103
// still be overridden, as with any parameter ...)  If the floating point unit
104
// is not included and OPT_ILLEGAL_INSTRUCTION is set, then as with the
105
// multiply and divide any floating point instruction will result in an illegal
106
// instruction exception that will send the CPU into supervisor mode.
107
//
108
//
109
// `define      OPT_IMPLEMENT_FPU
110
//
111
//
112
//
113
// OPT_NEW_INSTRUCTION_SET controls whether or not the new instruction set
114
// is in use.  The new instruction set contains space for floating point
115
// operations, signed and unsigned divide instructions, as well as bit reversal
116
// and ... at least two other operations yet to be defined.  The decoder alone
117
// uses about 70 fewer LUTs, although in practice this works out to 12 fewer
118
// when all works out in the wash.  Further, floating point and divide
119
// instructions will cause an illegal instruction exception if they are not
120
// implemented--so software capability can be built to use these instructions
121
// immediately, even if the hardware is not yet ready.
122
//
123
// This option is likely to go away in the future, obsoleting the previous
124
// instruction set, so I recommend setting this option and switching to the
125
// new instruction set as soon as possible.
126
//
127
`define OPT_NEW_INSTRUCTION_SET
128
//
129
//
130
//
131
//
132
//
133
//
134
// OPT_SINGLE_FETCH controls whether or not the prefetch has a cache, and 
135
// whether or not it can issue one instruction per clock.  When set, the
136
// prefetch has no cache, and only one instruction is fetched at a time.
137
// This effectively sets the CPU so that only one instruction is ever 
138
// in the pipeline at once, and hence you may think of this as a "kill 
139
// pipeline" option.  However, since the pipelined fetch component uses so
140
// much area on the FPGA, this is an important option to use in trimming down
141
// used area if necessary.  Hence, it needs to be maintained for that purpose.
142
// Be aware, though, it will drop your performance by a factor between 2x and
143
// 3x.
144
//
145
// We can either pipeline our fetches, or issue one fetch at a time.  Pipelined
146
// fetches are more complicated and therefore use more FPGA resources, while
147
// single fetches will cause the CPU to stall for about 5 stalls each 
148
// instruction cycle, effectively reducing the instruction count per clock to
149
// about 0.2.  However, the area cost may be worth it.  Consider:
150
//
151
//      Slice LUTs              ZipSystem       ZipCPU
152
//      Single Fetching         2521            1734
153
//      Pipelined fetching      2796            2046
154
//      (These numbers may be dated, but should still be representative ...)
155
//
156
// I recommend only defining this if you "need" to, if area is tight and
157
// speed isn't as important.  Otherwise, just leave this undefined.
158
//
159
// `define      OPT_SINGLE_FETCH
160
//
161
//
162
//
163
// The next several options are pipeline optimization options.  They make no
164
// sense in a single instruction fetch mode, hence we #ifndef them so they
165
// are only defined if we are in a full pipelined mode (i.e. OPT_SINGLE_FETCH
166
// is not defined).
167
//
168
`ifndef OPT_SINGLE_FETCH
169
//
170
//
171
//
172
// OPT_PIPELINED is the natural result and opposite of using the single 
173
// instruction fetch unit.  If you are not using that unit, the ZipCPU will
174
// be pipelined.  The option is defined here more for readability than 
175
// anything else, since OPT_PIPELINED makes more sense than OPT_SINGLE_FETCH,
176
// well ... that and it does a better job of explaining what is going on.
177
//
178
// In other words, leave this define alone--lest you break the ZipCPU.
179
//
180
`define OPT_PIPELINED
181
//
182
//
183
//
184
// OPT_TRADITIONAL_PFCACHE allows you to switch between one of two prefetch
185
// caches.  If enabled, a more traditional cache is implemented.  This more
186
// traditional cache (currently) uses many more LUTs, but it also reduces
187
// the stall count tremendously over the alternative hacked pipeline cache.
188
// (The traditional pfcache is also pipelined, whereas the pipeline cache
189
// implements a windowed approach to caching.)
190
//
191
// If you have the fabric to support this option, I recommend including it.
192
//
193 31 dgisselq
`ifdef  XULA25
194 2 dgisselq
`define OPT_TRADITIONAL_PFCACHE
195 31 dgisselq
`endif
196 2 dgisselq
//
197
//
198
//
199
// OPT_EARLY_BRANCHING is an attempt to execute a BRA statement as early
200
// as possible, to avoid as many pipeline stalls on a branch as possible.
201
// It's not tremendously successful yet--BRA's still suffer stalls,
202
// but I intend to keep working on this approach until the number of stalls
203
// gets down to one or (ideally) zero.  (With the OPT_TRADITIONAL_PFCACHE, this
204
// gets down to a single stall cycle ...)  That way a "BRA" can be used as the
205
// compiler's branch prediction optimizer: BRA's barely stall, while branches
206
// on conditions will always suffer about 4 stall cycles or so.
207
//
208
// I recommend setting this flag, so as to turn early branching on.
209
//
210
`define OPT_EARLY_BRANCHING
211
//
212
//
213
//
214
// OPT_PIPELINED_BUS_ACCESS controls whether or not LOD/STO instructions
215
// can take advantaged of pipelined bus instructions.  To be eligible, the
216
// operations must be identical (cannot pipeline loads and stores, just loads
217
// only or stores only), and the addresses must either be identical or one up
218
// from the previous address.  Further, the load/store string must all have
219
// the same conditional.  This approach gains the must use, in my humble
220
// opinion, when saving registers to or restoring registers from the stack
221
// at the beginning/end of a procedure, or when doing a context swap.
222
//
223
// I recommend setting this flag, for performance reasons, especially if your
224
// wishbone bus can handle pipelined bus accesses.
225
//
226
`define OPT_PIPELINED_BUS_ACCESS
227
//
228
//
229
//
230
`ifdef  OPT_NEW_INSTRUCTION_SET
231
//
232
//
233
//
234
// The new instruction set also defines a set of very long instruction words.
235
// Well, calling them "very long" instruction words is probably a misnomer,
236
// although we're going to do it.  They're really 2x16-bit instructions---
237
// instruction words that pack two instructions into one word.  (2x14 bit
238
// really--'cause you need a bit to note the instruction is a 2x instruction,
239
// and then 3-bits for the condition codes ...)  Set OPT_VLIW to include these
240
// double instructions as part of the new instruction set.  These allow a single
241
// instruction to contain two instructions within.   These instructions are
242
// designed to get more code density from the instruction set, and to hopefully
243
// take some pain off of the performance of the pre-fetch and instruction cache.
244
//
245
// These new instructions, however, also necessitate a change in the Zip
246
// CPU--the Zip CPU can no longer execute instructions atomically.  It must
247
// now execute non-VLIW instructions, or VLIW instruction pairs, atomically. 
248
// This logic has been added into the ZipCPU, but it has not (yet) been
249
// tested thoroughly.
250
//
251
// Oh, and the assembler, the debugger, and the object file dumper, and the
252
// simulator all need to be updated as well ....
253
//
254
`define OPT_VLIW
255
//
256
//
257
`endif // OPT_NEW_INSTRUCTION_SET
258
//
259
//
260
`endif  // OPT_SINGLE_FETCH
261
//
262
//
263
//
264
// Now let's talk about peripherals for a moment.  These next two defines
265
// control whether the DMA controller is included in the Zip System, and
266
// whether or not the 8 accounting timers are also included.  Set these to
267
// include the respective peripherals, comment them out not to.
268
//
269 31 dgisselq
`ifdef  XULA25
270 2 dgisselq
`define INCLUDE_DMA_CONTROLLER
271
`define INCLUDE_ACCOUNTING_COUNTERS
272
//
273
//
274
`define DEBUG_SCOPE
275 31 dgisselq
`endif
276 2 dgisselq
//
277
`endif  // CPUDEFS_H

powered by: WebSVN 2.1.0

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