1 |
2 |
olivier.gi |
//----------------------------------------------------------------------------
|
2 |
117 |
olivier.gi |
// Copyright (C) 2009 , Olivier Girard
|
3 |
2 |
olivier.gi |
//
|
4 |
117 |
olivier.gi |
// Redistribution and use in source and binary forms, with or without
|
5 |
|
|
// modification, are permitted provided that the following conditions
|
6 |
|
|
// are met:
|
7 |
|
|
// * Redistributions of source code must retain the above copyright
|
8 |
|
|
// notice, this list of conditions and the following disclaimer.
|
9 |
|
|
// * Redistributions in binary form must reproduce the above copyright
|
10 |
|
|
// notice, this list of conditions and the following disclaimer in the
|
11 |
|
|
// documentation and/or other materials provided with the distribution.
|
12 |
|
|
// * Neither the name of the authors nor the names of its contributors
|
13 |
|
|
// may be used to endorse or promote products derived from this software
|
14 |
|
|
// without specific prior written permission.
|
15 |
2 |
olivier.gi |
//
|
16 |
117 |
olivier.gi |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17 |
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18 |
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19 |
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
20 |
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
21 |
|
|
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22 |
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23 |
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24 |
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25 |
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
26 |
|
|
// THE POSSIBILITY OF SUCH DAMAGE
|
27 |
2 |
olivier.gi |
//
|
28 |
|
|
//----------------------------------------------------------------------------
|
29 |
|
|
//
|
30 |
23 |
olivier.gi |
// *File Name: openMSP430_defines.v
|
31 |
2 |
olivier.gi |
//
|
32 |
|
|
// *Module Description:
|
33 |
|
|
// openMSP430 Configuration file
|
34 |
|
|
//
|
35 |
|
|
// *Author(s):
|
36 |
|
|
// - Olivier Girard, olgirard@gmail.com
|
37 |
|
|
//
|
38 |
|
|
//----------------------------------------------------------------------------
|
39 |
17 |
olivier.gi |
// $Rev: 117 $
|
40 |
|
|
// $LastChangedBy: olivier.girard $
|
41 |
|
|
// $LastChangedDate: 2011-06-23 21:30:51 +0200 (Thu, 23 Jun 2011) $
|
42 |
|
|
//----------------------------------------------------------------------------
|
43 |
103 |
olivier.gi |
//`define OMSP_NO_INCLUDE
|
44 |
|
|
`ifdef OMSP_NO_INCLUDE
|
45 |
|
|
`else
|
46 |
33 |
olivier.gi |
`include "openMSP430_undefines.v"
|
47 |
103 |
olivier.gi |
`endif
|
48 |
2 |
olivier.gi |
|
49 |
111 |
olivier.gi |
//============================================================================
|
50 |
|
|
//============================================================================
|
51 |
|
|
// BASIC SYSTEM CONFIGURATION
|
52 |
|
|
//============================================================================
|
53 |
|
|
//============================================================================
|
54 |
72 |
olivier.gi |
//
|
55 |
111 |
olivier.gi |
// Note: the sum of program, data and peripheral memory spaces must not
|
56 |
|
|
// exceed 64 kB
|
57 |
72 |
olivier.gi |
//
|
58 |
2 |
olivier.gi |
|
59 |
33 |
olivier.gi |
// Program Memory Size:
|
60 |
72 |
olivier.gi |
// Uncomment the required memory size
|
61 |
|
|
//-------------------------------------------------------
|
62 |
|
|
//`define PMEM_SIZE_59_KB
|
63 |
|
|
//`define PMEM_SIZE_55_KB
|
64 |
|
|
//`define PMEM_SIZE_54_KB
|
65 |
|
|
//`define PMEM_SIZE_51_KB
|
66 |
|
|
//`define PMEM_SIZE_48_KB
|
67 |
|
|
//`define PMEM_SIZE_41_KB
|
68 |
|
|
//`define PMEM_SIZE_32_KB
|
69 |
|
|
//`define PMEM_SIZE_24_KB
|
70 |
|
|
//`define PMEM_SIZE_16_KB
|
71 |
|
|
//`define PMEM_SIZE_12_KB
|
72 |
|
|
//`define PMEM_SIZE_8_KB
|
73 |
|
|
//`define PMEM_SIZE_4_KB
|
74 |
|
|
`define PMEM_SIZE_2_KB
|
75 |
|
|
//`define PMEM_SIZE_1_KB
|
76 |
2 |
olivier.gi |
|
77 |
111 |
olivier.gi |
|
78 |
33 |
olivier.gi |
// Data Memory Size:
|
79 |
72 |
olivier.gi |
// Uncomment the required memory size
|
80 |
|
|
//-------------------------------------------------------
|
81 |
|
|
//`define DMEM_SIZE_32_KB
|
82 |
|
|
//`define DMEM_SIZE_24_KB
|
83 |
|
|
//`define DMEM_SIZE_16_KB
|
84 |
|
|
//`define DMEM_SIZE_10_KB
|
85 |
|
|
//`define DMEM_SIZE_8_KB
|
86 |
|
|
//`define DMEM_SIZE_5_KB
|
87 |
|
|
//`define DMEM_SIZE_4_KB
|
88 |
|
|
//`define DMEM_SIZE_2p5_KB
|
89 |
|
|
//`define DMEM_SIZE_2_KB
|
90 |
|
|
//`define DMEM_SIZE_1_KB
|
91 |
|
|
//`define DMEM_SIZE_512_B
|
92 |
|
|
//`define DMEM_SIZE_256_B
|
93 |
|
|
`define DMEM_SIZE_128_B
|
94 |
2 |
olivier.gi |
|
95 |
111 |
olivier.gi |
|
96 |
67 |
olivier.gi |
// Include/Exclude Hardware Multiplier
|
97 |
|
|
`define MULTIPLIER
|
98 |
|
|
|
99 |
|
|
|
100 |
111 |
olivier.gi |
// Include/Exclude Serial Debug interface
|
101 |
2 |
olivier.gi |
`define DBG_EN
|
102 |
|
|
|
103 |
|
|
|
104 |
111 |
olivier.gi |
//============================================================================
|
105 |
|
|
//============================================================================
|
106 |
|
|
// ADVANCED SYSTEM CONFIGURATION (FOR EXPERIENCED USERS)
|
107 |
|
|
//============================================================================
|
108 |
|
|
//============================================================================
|
109 |
|
|
|
110 |
|
|
//-------------------------------------------------------
|
111 |
|
|
// Peripheral Memory Space:
|
112 |
|
|
//-------------------------------------------------------
|
113 |
|
|
// The original MSP430 architecture map the peripherals
|
114 |
|
|
// from 0x0000 to 0x01FF (i.e. 512B of the memory space).
|
115 |
|
|
// The following defines allow you to expand this space
|
116 |
|
|
// up to 32 kB (i.e. from 0x0000 to 0x7fff).
|
117 |
|
|
// As a consequence, the data memory mapping will be
|
118 |
|
|
// shifted up and a custom linker script will therefore
|
119 |
|
|
// be required by the GCC compiler.
|
120 |
|
|
//-------------------------------------------------------
|
121 |
|
|
//`define PER_SIZE_32_KB
|
122 |
|
|
//`define PER_SIZE_16_KB
|
123 |
|
|
//`define PER_SIZE_8_KB
|
124 |
|
|
//`define PER_SIZE_4_KB
|
125 |
|
|
//`define PER_SIZE_2_KB
|
126 |
|
|
//`define PER_SIZE_1_KB
|
127 |
|
|
`define PER_SIZE_512_B
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
//-------------------------------------------------------
|
131 |
|
|
// Defines the debugger CPU_CTL.RST_BRK_EN reset value
|
132 |
|
|
// (CPU break on PUC reset)
|
133 |
|
|
//-------------------------------------------------------
|
134 |
|
|
// When defined, the CPU will automatically break after
|
135 |
|
|
// a PUC occurrence by default. This is typically usefull
|
136 |
|
|
// when the program memory can only be initialized through
|
137 |
|
|
// the serial debug interface.
|
138 |
|
|
//-------------------------------------------------------
|
139 |
|
|
//`define DBG_RST_BRK_EN
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
//-------------------------------------------------------
|
143 |
|
|
// Custom user version number
|
144 |
|
|
//-------------------------------------------------------
|
145 |
|
|
// This 5 bit field can be freely used in order to allow
|
146 |
112 |
olivier.gi |
// custom identification of the system through the debug
|
147 |
|
|
// interface.
|
148 |
111 |
olivier.gi |
// (see CPU_ID.USER_VERSION field in the documentation)
|
149 |
|
|
//-------------------------------------------------------
|
150 |
|
|
`define USER_VERSION 5'b00000
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
//============================================================================
|
154 |
|
|
//============================================================================
|
155 |
|
|
// EXPERT SYSTEM CONFIGURATION ( !!!! EXPERTS ONLY !!!! )
|
156 |
|
|
//============================================================================
|
157 |
|
|
//============================================================================
|
158 |
2 |
olivier.gi |
//
|
159 |
111 |
olivier.gi |
// IMPORTANT NOTE: Please update following configuration options ONLY if
|
160 |
|
|
// you have a good reason to do so... and if you know what
|
161 |
|
|
// you are doing :-P
|
162 |
|
|
//
|
163 |
|
|
//============================================================================
|
164 |
2 |
olivier.gi |
|
165 |
111 |
olivier.gi |
//-------------------------------------------------------
|
166 |
|
|
// Number of hardware breakpoint units (each unit contains
|
167 |
|
|
// two hardware address breakpoints):
|
168 |
|
|
// - DBG_HWBRK_0 -> Include hardware breakpoints unit 0
|
169 |
|
|
// - DBG_HWBRK_1 -> Include hardware breakpoints unit 1
|
170 |
|
|
// - DBG_HWBRK_2 -> Include hardware breakpoints unit 2
|
171 |
|
|
// - DBG_HWBRK_3 -> Include hardware breakpoints unit 3
|
172 |
|
|
//-------------------------------------------------------
|
173 |
|
|
// Please keep in mind that hardware breakpoints only
|
174 |
|
|
// make sense whenever the program memory is not an SRAM
|
175 |
|
|
// (i.e. Flash/OTP/ROM/...) or when you are interested
|
176 |
|
|
// in data breakpoints (btw. not supported by GDB).
|
177 |
|
|
//-------------------------------------------------------
|
178 |
|
|
//`define DBG_HWBRK_0
|
179 |
|
|
//`define DBG_HWBRK_1
|
180 |
|
|
//`define DBG_HWBRK_2
|
181 |
|
|
//`define DBG_HWBRK_3
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
//-------------------------------------------------------
|
185 |
|
|
// Enable/Disable the hardware breakpoint RANGE mode
|
186 |
|
|
//-------------------------------------------------------
|
187 |
|
|
// When enabled this feature allows the hardware breakpoint
|
188 |
|
|
// units to stop the cpu whenever an instruction or data
|
189 |
|
|
// access lays within an address range.
|
190 |
|
|
// Note that this feature is not supported by GDB.
|
191 |
|
|
//-------------------------------------------------------
|
192 |
|
|
//`define DBG_HWBRK_RANGE
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
//-------------------------------------------------------
|
196 |
|
|
// Input synchronizers
|
197 |
|
|
//-------------------------------------------------------
|
198 |
|
|
// In some cases, the asynchronous input ports might
|
199 |
|
|
// already be synchronized externally.
|
200 |
|
|
// If an extensive CDC design review showed that this
|
201 |
|
|
// is really the case, the individual synchronizers
|
202 |
|
|
// can be disabled with the following defines.
|
203 |
106 |
olivier.gi |
//
|
204 |
111 |
olivier.gi |
// Notes:
|
205 |
|
|
// - the dbg_en signal will reset the debug interface
|
206 |
|
|
// when 0. Therefore make sure it is glitch free.
|
207 |
106 |
olivier.gi |
//
|
208 |
111 |
olivier.gi |
// - the dbg_uart_rxd synchronizer must be set to 1
|
209 |
|
|
// when its reset is active.
|
210 |
|
|
//-------------------------------------------------------
|
211 |
|
|
`define SYNC_CPU_EN
|
212 |
|
|
`define SYNC_DBG_EN
|
213 |
|
|
`define SYNC_DBG_UART_RXD
|
214 |
|
|
`define SYNC_NMI
|
215 |
2 |
olivier.gi |
|
216 |
106 |
olivier.gi |
|
217 |
111 |
olivier.gi |
|
218 |
2 |
olivier.gi |
//==========================================================================//
|
219 |
|
|
//==========================================================================//
|
220 |
|
|
//==========================================================================//
|
221 |
|
|
//==========================================================================//
|
222 |
|
|
//===== SYSTEM CONSTANTS --- !!!!!!!! DO NOT EDIT !!!!!!!! =====//
|
223 |
|
|
//==========================================================================//
|
224 |
|
|
//==========================================================================//
|
225 |
|
|
//==========================================================================//
|
226 |
|
|
//==========================================================================//
|
227 |
|
|
|
228 |
72 |
olivier.gi |
//
|
229 |
111 |
olivier.gi |
// PROGRAM, DATA & PERIPHERAL MEMORY CONFIGURATION
|
230 |
|
|
//==================================================
|
231 |
2 |
olivier.gi |
|
232 |
72 |
olivier.gi |
// Program Memory Size
|
233 |
|
|
`ifdef PMEM_SIZE_59_KB
|
234 |
|
|
`define PMEM_AWIDTH 15
|
235 |
|
|
`define PMEM_SIZE 60416
|
236 |
|
|
`endif
|
237 |
|
|
`ifdef PMEM_SIZE_55_KB
|
238 |
|
|
`define PMEM_AWIDTH 15
|
239 |
|
|
`define PMEM_SIZE 56320
|
240 |
|
|
`endif
|
241 |
|
|
`ifdef PMEM_SIZE_54_KB
|
242 |
|
|
`define PMEM_AWIDTH 15
|
243 |
|
|
`define PMEM_SIZE 55296
|
244 |
|
|
`endif
|
245 |
|
|
`ifdef PMEM_SIZE_51_KB
|
246 |
|
|
`define PMEM_AWIDTH 15
|
247 |
|
|
`define PMEM_SIZE 52224
|
248 |
|
|
`endif
|
249 |
|
|
`ifdef PMEM_SIZE_48_KB
|
250 |
|
|
`define PMEM_AWIDTH 15
|
251 |
|
|
`define PMEM_SIZE 49152
|
252 |
|
|
`endif
|
253 |
|
|
`ifdef PMEM_SIZE_41_KB
|
254 |
|
|
`define PMEM_AWIDTH 15
|
255 |
|
|
`define PMEM_SIZE 41984
|
256 |
|
|
`endif
|
257 |
|
|
`ifdef PMEM_SIZE_32_KB
|
258 |
|
|
`define PMEM_AWIDTH 14
|
259 |
|
|
`define PMEM_SIZE 32768
|
260 |
|
|
`endif
|
261 |
|
|
`ifdef PMEM_SIZE_24_KB
|
262 |
|
|
`define PMEM_AWIDTH 14
|
263 |
|
|
`define PMEM_SIZE 24576
|
264 |
|
|
`endif
|
265 |
|
|
`ifdef PMEM_SIZE_16_KB
|
266 |
|
|
`define PMEM_AWIDTH 13
|
267 |
|
|
`define PMEM_SIZE 16384
|
268 |
|
|
`endif
|
269 |
|
|
`ifdef PMEM_SIZE_12_KB
|
270 |
|
|
`define PMEM_AWIDTH 13
|
271 |
|
|
`define PMEM_SIZE 12288
|
272 |
|
|
`endif
|
273 |
|
|
`ifdef PMEM_SIZE_8_KB
|
274 |
|
|
`define PMEM_AWIDTH 12
|
275 |
|
|
`define PMEM_SIZE 8192
|
276 |
|
|
`endif
|
277 |
|
|
`ifdef PMEM_SIZE_4_KB
|
278 |
|
|
`define PMEM_AWIDTH 11
|
279 |
|
|
`define PMEM_SIZE 4096
|
280 |
|
|
`endif
|
281 |
|
|
`ifdef PMEM_SIZE_2_KB
|
282 |
|
|
`define PMEM_AWIDTH 10
|
283 |
|
|
`define PMEM_SIZE 2048
|
284 |
|
|
`endif
|
285 |
|
|
`ifdef PMEM_SIZE_1_KB
|
286 |
|
|
`define PMEM_AWIDTH 9
|
287 |
|
|
`define PMEM_SIZE 1024
|
288 |
|
|
`endif
|
289 |
|
|
|
290 |
|
|
// Data Memory Size
|
291 |
|
|
`ifdef DMEM_SIZE_32_KB
|
292 |
|
|
`define DMEM_AWIDTH 14
|
293 |
|
|
`define DMEM_SIZE 32768
|
294 |
|
|
`endif
|
295 |
|
|
`ifdef DMEM_SIZE_24_KB
|
296 |
|
|
`define DMEM_AWIDTH 14
|
297 |
|
|
`define DMEM_SIZE 24576
|
298 |
|
|
`endif
|
299 |
|
|
`ifdef DMEM_SIZE_16_KB
|
300 |
|
|
`define DMEM_AWIDTH 13
|
301 |
|
|
`define DMEM_SIZE 16384
|
302 |
|
|
`endif
|
303 |
|
|
`ifdef DMEM_SIZE_10_KB
|
304 |
|
|
`define DMEM_AWIDTH 13
|
305 |
|
|
`define DMEM_SIZE 10240
|
306 |
|
|
`endif
|
307 |
|
|
`ifdef DMEM_SIZE_8_KB
|
308 |
|
|
`define DMEM_AWIDTH 12
|
309 |
|
|
`define DMEM_SIZE 8192
|
310 |
|
|
`endif
|
311 |
|
|
`ifdef DMEM_SIZE_5_KB
|
312 |
|
|
`define DMEM_AWIDTH 12
|
313 |
|
|
`define DMEM_SIZE 5120
|
314 |
|
|
`endif
|
315 |
|
|
`ifdef DMEM_SIZE_4_KB
|
316 |
|
|
`define DMEM_AWIDTH 11
|
317 |
|
|
`define DMEM_SIZE 4096
|
318 |
|
|
`endif
|
319 |
|
|
`ifdef DMEM_SIZE_2p5_KB
|
320 |
|
|
`define DMEM_AWIDTH 11
|
321 |
|
|
`define DMEM_SIZE 2560
|
322 |
|
|
`endif
|
323 |
|
|
`ifdef DMEM_SIZE_2_KB
|
324 |
|
|
`define DMEM_AWIDTH 10
|
325 |
|
|
`define DMEM_SIZE 2048
|
326 |
|
|
`endif
|
327 |
|
|
`ifdef DMEM_SIZE_1_KB
|
328 |
|
|
`define DMEM_AWIDTH 9
|
329 |
|
|
`define DMEM_SIZE 1024
|
330 |
|
|
`endif
|
331 |
|
|
`ifdef DMEM_SIZE_512_B
|
332 |
|
|
`define DMEM_AWIDTH 8
|
333 |
|
|
`define DMEM_SIZE 512
|
334 |
|
|
`endif
|
335 |
|
|
`ifdef DMEM_SIZE_256_B
|
336 |
|
|
`define DMEM_AWIDTH 7
|
337 |
|
|
`define DMEM_SIZE 256
|
338 |
|
|
`endif
|
339 |
|
|
`ifdef DMEM_SIZE_128_B
|
340 |
|
|
`define DMEM_AWIDTH 6
|
341 |
|
|
`define DMEM_SIZE 128
|
342 |
|
|
`endif
|
343 |
|
|
|
344 |
111 |
olivier.gi |
// Peripheral Memory Size
|
345 |
|
|
`ifdef PER_SIZE_32_KB
|
346 |
|
|
`define PER_AWIDTH 14
|
347 |
|
|
`define PER_SIZE 32768
|
348 |
|
|
`endif
|
349 |
|
|
`ifdef PER_SIZE_16_KB
|
350 |
|
|
`define PER_AWIDTH 13
|
351 |
|
|
`define PER_SIZE 16384
|
352 |
|
|
`endif
|
353 |
|
|
`ifdef PER_SIZE_8_KB
|
354 |
|
|
`define PER_AWIDTH 12
|
355 |
|
|
`define PER_SIZE 8192
|
356 |
|
|
`endif
|
357 |
|
|
`ifdef PER_SIZE_4_KB
|
358 |
|
|
`define PER_AWIDTH 11
|
359 |
|
|
`define PER_SIZE 4096
|
360 |
|
|
`endif
|
361 |
|
|
`ifdef PER_SIZE_2_KB
|
362 |
|
|
`define PER_AWIDTH 10
|
363 |
|
|
`define PER_SIZE 2048
|
364 |
|
|
`endif
|
365 |
|
|
`ifdef PER_SIZE_1_KB
|
366 |
|
|
`define PER_AWIDTH 9
|
367 |
|
|
`define PER_SIZE 1024
|
368 |
|
|
`endif
|
369 |
|
|
`ifdef PER_SIZE_512_B
|
370 |
|
|
`define PER_AWIDTH 8
|
371 |
|
|
`define PER_SIZE 512
|
372 |
|
|
`endif
|
373 |
|
|
|
374 |
33 |
olivier.gi |
// Data Memory Base Adresses
|
375 |
111 |
olivier.gi |
`define DMEM_BASE `PER_SIZE
|
376 |
2 |
olivier.gi |
|
377 |
33 |
olivier.gi |
// Program & Data Memory most significant address bit (for 16 bit words)
|
378 |
|
|
`define PMEM_MSB `PMEM_AWIDTH-1
|
379 |
|
|
`define DMEM_MSB `DMEM_AWIDTH-1
|
380 |
111 |
olivier.gi |
`define PER_MSB `PER_AWIDTH-1
|
381 |
2 |
olivier.gi |
|
382 |
72 |
olivier.gi |
//
|
383 |
|
|
// STATES, REGISTER FIELDS, ...
|
384 |
|
|
//======================================
|
385 |
2 |
olivier.gi |
|
386 |
|
|
// Instructions type
|
387 |
|
|
`define INST_SO 0
|
388 |
|
|
`define INST_JMP 1
|
389 |
|
|
`define INST_TO 2
|
390 |
|
|
|
391 |
|
|
// Single-operand arithmetic
|
392 |
|
|
`define RRC 0
|
393 |
|
|
`define SWPB 1
|
394 |
|
|
`define RRA 2
|
395 |
|
|
`define SXT 3
|
396 |
|
|
`define PUSH 4
|
397 |
|
|
`define CALL 5
|
398 |
|
|
`define RETI 6
|
399 |
|
|
`define IRQ 7
|
400 |
|
|
|
401 |
|
|
// Conditional jump
|
402 |
|
|
`define JNE 0
|
403 |
|
|
`define JEQ 1
|
404 |
|
|
`define JNC 2
|
405 |
|
|
`define JC 3
|
406 |
|
|
`define JN 4
|
407 |
|
|
`define JGE 5
|
408 |
|
|
`define JL 6
|
409 |
|
|
`define JMP 7
|
410 |
|
|
|
411 |
|
|
// Two-operand arithmetic
|
412 |
|
|
`define MOV 0
|
413 |
|
|
`define ADD 1
|
414 |
|
|
`define ADDC 2
|
415 |
|
|
`define SUBC 3
|
416 |
|
|
`define SUB 4
|
417 |
|
|
`define CMP 5
|
418 |
|
|
`define DADD 6
|
419 |
|
|
`define BIT 7
|
420 |
|
|
`define BIC 8
|
421 |
|
|
`define BIS 9
|
422 |
|
|
`define XOR 10
|
423 |
|
|
`define AND 11
|
424 |
|
|
|
425 |
|
|
// Addressing modes
|
426 |
|
|
`define DIR 0
|
427 |
|
|
`define IDX 1
|
428 |
|
|
`define INDIR 2
|
429 |
|
|
`define INDIR_I 3
|
430 |
|
|
`define SYMB 4
|
431 |
|
|
`define IMM 5
|
432 |
|
|
`define ABS 6
|
433 |
|
|
`define CONST 7
|
434 |
|
|
|
435 |
111 |
olivier.gi |
// Instruction state machine
|
436 |
|
|
`define I_IRQ_FETCH 3'h0
|
437 |
|
|
`define I_IRQ_DONE 3'h1
|
438 |
|
|
`define I_DEC 3'h2
|
439 |
|
|
`define I_EXT1 3'h3
|
440 |
|
|
`define I_EXT2 3'h4
|
441 |
|
|
`define I_IDLE 3'h5
|
442 |
|
|
|
443 |
2 |
olivier.gi |
// Execution state machine
|
444 |
111 |
olivier.gi |
`define E_IRQ_0 4'h0
|
445 |
|
|
`define E_IRQ_1 4'h1
|
446 |
|
|
`define E_IRQ_2 4'h2
|
447 |
|
|
`define E_IRQ_3 4'h3
|
448 |
|
|
`define E_IRQ_4 4'h4
|
449 |
|
|
`define E_SRC_AD 4'h5
|
450 |
|
|
`define E_SRC_RD 4'h6
|
451 |
|
|
`define E_SRC_WR 4'h7
|
452 |
|
|
`define E_DST_AD 4'h8
|
453 |
|
|
`define E_DST_RD 4'h9
|
454 |
|
|
`define E_DST_WR 4'hA
|
455 |
|
|
`define E_EXEC 4'hB
|
456 |
|
|
`define E_JUMP 4'hC
|
457 |
|
|
`define E_IDLE 4'hD
|
458 |
2 |
olivier.gi |
|
459 |
|
|
// ALU control signals
|
460 |
|
|
`define ALU_SRC_INV 0
|
461 |
|
|
`define ALU_INC 1
|
462 |
|
|
`define ALU_INC_C 2
|
463 |
|
|
`define ALU_ADD 3
|
464 |
|
|
`define ALU_AND 4
|
465 |
|
|
`define ALU_OR 5
|
466 |
|
|
`define ALU_XOR 6
|
467 |
|
|
`define ALU_DADD 7
|
468 |
|
|
`define ALU_STAT_7 8
|
469 |
|
|
`define ALU_STAT_F 9
|
470 |
|
|
`define ALU_SHIFT 10
|
471 |
|
|
`define EXEC_NO_WR 11
|
472 |
|
|
|
473 |
|
|
// Debug interface
|
474 |
|
|
`define DBG_UART_WR 18
|
475 |
|
|
`define DBG_UART_BW 17
|
476 |
|
|
`define DBG_UART_ADDR 16:11
|
477 |
|
|
|
478 |
|
|
// Debug interface CPU_CTL register
|
479 |
|
|
`define HALT 0
|
480 |
|
|
`define RUN 1
|
481 |
|
|
`define ISTEP 2
|
482 |
|
|
`define SW_BRK_EN 3
|
483 |
|
|
`define FRZ_BRK_EN 4
|
484 |
|
|
`define RST_BRK_EN 5
|
485 |
|
|
`define CPU_RST 6
|
486 |
|
|
|
487 |
|
|
// Debug interface CPU_STAT register
|
488 |
|
|
`define HALT_RUN 0
|
489 |
|
|
`define PUC_PND 1
|
490 |
|
|
`define SWBRK_PND 3
|
491 |
|
|
`define HWBRK0_PND 4
|
492 |
|
|
`define HWBRK1_PND 5
|
493 |
|
|
|
494 |
|
|
// Debug interface BRKx_CTL register
|
495 |
|
|
`define BRK_MODE_RD 0
|
496 |
|
|
`define BRK_MODE_WR 1
|
497 |
|
|
`define BRK_MODE 1:0
|
498 |
|
|
`define BRK_EN 2
|
499 |
|
|
`define BRK_I_EN 3
|
500 |
|
|
`define BRK_RANGE 4
|
501 |
|
|
|
502 |
|
|
// Basic clock module: BCSCTL1 Control Register
|
503 |
|
|
`define DIVAx 5:4
|
504 |
|
|
|
505 |
|
|
// Basic clock module: BCSCTL2 Control Register
|
506 |
|
|
`define SELS 3
|
507 |
|
|
`define DIVSx 2:1
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
//
|
511 |
|
|
// DEBUG INTERFACE EXTRA CONFIGURATION
|
512 |
|
|
//======================================
|
513 |
|
|
|
514 |
111 |
olivier.gi |
// Debug interface: CPU version
|
515 |
|
|
`define CPU_VERSION 3'h1
|
516 |
|
|
|
517 |
2 |
olivier.gi |
// Debug interface: Software breakpoint opcode
|
518 |
|
|
`define DBG_SWBRK_OP 16'h4343
|
519 |
|
|
|
520 |
|
|
// Debug UART interface auto data synchronization
|
521 |
|
|
// If the following define is commented out, then
|
522 |
|
|
// the DBG_UART_BAUD and DBG_DCO_FREQ need to be properly
|
523 |
|
|
// defined.
|
524 |
|
|
`define DBG_UART_AUTO_SYNC
|
525 |
|
|
|
526 |
|
|
// Debug UART interface data rate
|
527 |
|
|
// In order to properly setup the UART debug interface, you
|
528 |
|
|
// need to specify the DCO_CLK frequency (DBG_DCO_FREQ) and
|
529 |
|
|
// the chosen BAUD rate from the UART interface.
|
530 |
|
|
//
|
531 |
|
|
//`define DBG_UART_BAUD 9600
|
532 |
|
|
//`define DBG_UART_BAUD 19200
|
533 |
|
|
//`define DBG_UART_BAUD 38400
|
534 |
|
|
//`define DBG_UART_BAUD 57600
|
535 |
|
|
//`define DBG_UART_BAUD 115200
|
536 |
|
|
//`define DBG_UART_BAUD 230400
|
537 |
|
|
//`define DBG_UART_BAUD 460800
|
538 |
|
|
//`define DBG_UART_BAUD 576000
|
539 |
|
|
//`define DBG_UART_BAUD 921600
|
540 |
|
|
`define DBG_UART_BAUD 2000000
|
541 |
|
|
`define DBG_DCO_FREQ 20000000
|
542 |
|
|
`define DBG_UART_CNT ((`DBG_DCO_FREQ/`DBG_UART_BAUD)-1)
|
543 |
|
|
|
544 |
111 |
olivier.gi |
// Debug interface selection
|
545 |
|
|
// `define DBG_UART -> Enable UART (8N1) debug interface
|
546 |
|
|
// `define DBG_JTAG -> DON'T UNCOMMENT, NOT SUPPORTED
|
547 |
|
|
//
|
548 |
|
|
`define DBG_UART
|
549 |
|
|
//`define DBG_JTAG
|
550 |
|
|
|
551 |
57 |
olivier.gi |
// Enable/Disable the hardware breakpoint RANGE mode
|
552 |
111 |
olivier.gi |
`ifdef DBG_HWBRK_RANGE
|
553 |
|
|
`define HWBRK_RANGE 1'b1
|
554 |
|
|
`else
|
555 |
|
|
`define HWBRK_RANGE 1'b0
|
556 |
|
|
`endif
|
557 |
57 |
olivier.gi |
|
558 |
74 |
olivier.gi |
// Counter width for the debug interface UART
|
559 |
|
|
`define DBG_UART_XFER_CNT_W 16
|
560 |
|
|
|
561 |
2 |
olivier.gi |
// Check configuration
|
562 |
|
|
`ifdef DBG_EN
|
563 |
|
|
`ifdef DBG_UART
|
564 |
|
|
`ifdef DBG_JTAG
|
565 |
|
|
CONFIGURATION ERROR: JTAG AND UART DEBUG INTERFACE ARE BOTH ENABLED
|
566 |
|
|
`endif
|
567 |
|
|
`else
|
568 |
|
|
`ifdef DBG_JTAG
|
569 |
33 |
olivier.gi |
CONFIGURATION ERROR: JTAG INTERFACE NOT SUPPORTED
|
570 |
2 |
olivier.gi |
`else
|
571 |
|
|
CONFIGURATION ERROR: JTAG OR UART DEBUG INTERFACE SHOULD BE ENABLED
|
572 |
|
|
`endif
|
573 |
|
|
`endif
|
574 |
|
|
`endif
|
575 |
67 |
olivier.gi |
|
576 |
|
|
//
|
577 |
|
|
// MULTIPLIER CONFIGURATION
|
578 |
|
|
//======================================
|
579 |
|
|
|
580 |
|
|
// If uncommented, the following define selects
|
581 |
|
|
// the 16x16 multiplier (1 cycle) instead of the
|
582 |
|
|
// default 16x8 multplier (2 cycles)
|
583 |
|
|
//`define MPY_16x16
|
584 |
|
|
|