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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [actel_m1a3pl_dev_kit/] [rtl/] [verilog/] [openmsp430/] [openMSP430.v] - Blame information for rev 80

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

Line No. Rev Author Line
1 80 olivier.gi
//----------------------------------------------------------------------------
2
// Copyright (C) 2001 Authors
3
//
4
// This source file may be used and distributed without restriction provided
5
// that this copyright statement is not removed from the file and that any
6
// derivative work contains the original copyright notice and the associated
7
// disclaimer.
8
//
9
// This source file is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU Lesser General Public License as published
11
// by the Free Software Foundation; either version 2.1 of the License, or
12
// (at your option) any later version.
13
//
14
// This source is distributed in the hope that it will be useful, but WITHOUT
15
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
// License for more details.
18
//
19
// You should have received a copy of the GNU Lesser General Public License
20
// along with this source; if not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
//
23
//----------------------------------------------------------------------------
24
//
25
// *File Name: openMSP430.v
26
// 
27
// *Module Description:
28
//                       openMSP430 Top level file
29
//
30
// *Author(s):
31
//              - Olivier Girard,    olgirard@gmail.com
32
//
33
//----------------------------------------------------------------------------
34
// $Rev: 71 $
35
// $LastChangedBy: olivier.girard $
36
// $LastChangedDate: 2010-03-07 21:14:33 +0100 (Sun, 07 Mar 2010) $
37
//----------------------------------------------------------------------------
38
`include "timescale.v"
39
`include "openMSP430_defines.v"
40
 
41
module  openMSP430 (
42
 
43
// OUTPUTs
44
    aclk_en,                       // ACLK enable
45
    dbg_freeze,                    // Freeze peripherals
46
    dbg_uart_txd,                  // Debug interface: UART TXD
47
    dmem_addr,                     // Data Memory address
48
    dmem_cen,                      // Data Memory chip enable (low active)
49
    dmem_din,                      // Data Memory data input
50
    dmem_wen,                      // Data Memory write enable (low active)
51
    irq_acc,                       // Interrupt request accepted (one-hot signal)
52
    mclk,                          // Main system clock
53
    per_addr,                      // Peripheral address
54
    per_din,                       // Peripheral data input
55
    per_wen,                       // Peripheral write enable (high active)
56
    per_en,                        // Peripheral enable (high active)
57
    pmem_addr,                     // Program Memory address
58
    pmem_cen,                      // Program Memory chip enable (low active)
59
    pmem_din,                      // Program Memory data input (optional)
60
    pmem_wen,                      // Program Memory write enable (low active) (optional)
61
    puc,                           // Main system reset
62
    smclk_en,                      // SMCLK enable
63
 
64
// INPUTs
65
    dbg_uart_rxd,                  // Debug interface: UART RXD
66
    dco_clk,                       // Fast oscillator (fast clock)
67
    dmem_dout,                     // Data Memory data output
68
    irq,                           // Maskable interrupts
69
    lfxt_clk,                      // Low frequency oscillator (typ 32kHz)
70
    nmi,                           // Non-maskable interrupt (asynchronous)
71
    per_dout,                      // Peripheral data output
72
    pmem_dout,                     // Program Memory data output
73
    reset_n                        // Reset Pin (low active)
74
);
75
 
76
// OUTPUTs
77
//=========
78
output               aclk_en;      // ACLK enable
79
output               dbg_freeze;   // Freeze peripherals
80
output               dbg_uart_txd; // Debug interface: UART TXD
81
output [`DMEM_MSB:0] dmem_addr;    // Data Memory address
82
output               dmem_cen;     // Data Memory chip enable (low active)
83
output        [15:0] dmem_din;     // Data Memory data input
84
output         [1:0] dmem_wen;     // Data Memory write enable (low active)
85
output        [13:0] irq_acc;      // Interrupt request accepted (one-hot signal)
86
output               mclk;         // Main system clock
87
output         [7:0] per_addr;     // Peripheral address
88
output        [15:0] per_din;      // Peripheral data input
89
output         [1:0] per_wen;      // Peripheral write enable (high active)
90
output               per_en;       // Peripheral enable (high active)
91
output [`PMEM_MSB:0] pmem_addr;    // Program Memory address
92
output               pmem_cen;     // Program Memory chip enable (low active)
93
output        [15:0] pmem_din;     // Program Memory data input (optional)
94
output         [1:0] pmem_wen;     // Program Memory write enable (low active) (optional)
95
output               puc;          // Main system reset
96
output               smclk_en;     // SMCLK enable
97
 
98
 
99
// INPUTs
100
//=========
101
input                dbg_uart_rxd; // Debug interface: UART RXD
102
input                dco_clk;      // Fast oscillator (fast clock)
103
input         [15:0] dmem_dout;    // Data Memory data output
104
input         [13:0] irq;          // Maskable interrupts
105
input                lfxt_clk;     // Low frequency oscillator (typ 32kHz)
106
input                nmi;          // Non-maskable interrupt (asynchronous)
107
input         [15:0] per_dout;     // Peripheral data output
108
input         [15:0] pmem_dout;    // Program Memory data output
109
input                reset_n;      // Reset Pin (active low)
110
 
111
 
112
 
113
//=============================================================================
114
// 1)  INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
115
//=============================================================================
116
 
117
wire          [7:0] inst_ad;
118
wire          [7:0] inst_as;
119
wire         [11:0] inst_alu;
120
wire                inst_bw;
121
wire         [15:0] inst_dest;
122
wire         [15:0] inst_dext;
123
wire         [15:0] inst_sext;
124
wire          [7:0] inst_so;
125
wire         [15:0] inst_src;
126
wire          [2:0] inst_type;
127
wire          [3:0] e_state;
128
wire                exec_done;
129
 
130
wire         [15:0] eu_mab;
131
wire         [15:0] eu_mdb_in;
132
wire         [15:0] eu_mdb_out;
133
wire          [1:0] eu_mb_wr;
134
wire         [15:0] fe_mab;
135
wire         [15:0] fe_mdb_in;
136
 
137
wire         [15:0] pc_sw;
138
wire          [7:0] inst_jmp;
139
wire         [15:0] pc;
140
wire         [15:0] pc_nxt;
141
 
142
wire         [15:0] dbg_mem_addr;
143
wire         [15:0] dbg_mem_dout;
144
wire         [15:0] dbg_mem_din;
145
wire         [15:0] dbg_reg_din;
146
wire          [1:0] dbg_mem_wr;
147
 
148
wire         [15:0] per_dout_or;
149
wire         [15:0] per_dout_sfr;
150
wire         [15:0] per_dout_wdog;
151
wire         [15:0] per_dout_mpy;
152
wire         [15:0] per_dout_clk;
153
 
154
 
155
//=============================================================================
156
// 2)  GLOBAL CLOCK & RESET MANAGEMENT
157
//=============================================================================
158
 
159
omsp_clock_module clock_module_0 (
160
 
161
// OUTPUTs
162
    .aclk_en      (aclk_en),       // ACLK enablex
163
    .mclk         (mclk),          // Main system clock
164
    .per_dout     (per_dout_clk),  // Peripheral data output
165
    .por          (por),           // Power-on reset
166
    .puc          (puc),           // Main system reset
167
    .smclk_en     (smclk_en),      // SMCLK enable
168
 
169
// INPUTs
170
    .dbg_reset    (dbg_reset),     // Reset CPU from debug interface
171
    .dco_clk      (dco_clk),       // Fast oscillator (fast clock)
172
    .lfxt_clk     (lfxt_clk),      // Low frequency oscillator (typ 32kHz)
173
    .oscoff       (oscoff),        // Turns off LFXT1 clock input
174
    .per_addr     (per_addr),      // Peripheral address
175
    .per_din      (per_din),       // Peripheral data input
176
    .per_en       (per_en),        // Peripheral enable (high active)
177
    .per_wen      (per_wen),       // Peripheral write enable (high active)
178
    .reset_n      (reset_n),       // Reset Pin (low active)
179
    .scg1         (scg1),          // System clock generator 1. Turns off the SMCLK
180
    .wdt_reset    (wdt_reset)      // Watchdog-timer reset
181
);
182
 
183
 
184
//=============================================================================
185
// 3)  FRONTEND (<=> FETCH & DECODE)
186
//=============================================================================
187
 
188
omsp_frontend frontend_0 (
189
 
190
// OUTPUTs
191
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
192
    .decode_noirq (decode_noirq),  // Frontend decode instruction
193
    .e_state      (e_state),       // Execution state
194
    .exec_done    (exec_done),     // Execution completed
195
    .inst_ad      (inst_ad),       // Decoded Inst: destination addressing mode
196
    .inst_as      (inst_as),       // Decoded Inst: source addressing mode
197
    .inst_alu     (inst_alu),      // ALU control signals
198
    .inst_bw      (inst_bw),       // Decoded Inst: byte width
199
    .inst_dest    (inst_dest),     // Decoded Inst: destination (one hot)
200
    .inst_dext    (inst_dext),     // Decoded Inst: destination extended instruction word
201
    .inst_irq_rst (inst_irq_rst),  // Decoded Inst: Reset interrupt
202
    .inst_jmp     (inst_jmp),      // Decoded Inst: Conditional jump
203
    .inst_sext    (inst_sext),     // Decoded Inst: source extended instruction word
204
    .inst_so      (inst_so),       // Decoded Inst: Single-operand arithmetic
205
    .inst_src     (inst_src),      // Decoded Inst: source (one hot)
206
    .inst_type    (inst_type),     // Decoded Instruction type
207
    .irq_acc      (irq_acc),       // Interrupt request accepted
208
    .mab          (fe_mab),        // Frontend Memory address bus
209
    .mb_en        (fe_mb_en),      // Frontend Memory bus enable
210
    .nmi_acc      (nmi_acc),       // Non-Maskable interrupt request accepted
211
    .pc           (pc),            // Program counter
212
    .pc_nxt       (pc_nxt),        // Next PC value (for CALL & IRQ)
213
 
214
// INPUTs
215
    .cpuoff       (cpuoff),        // Turns off the CPU
216
    .dbg_halt_cmd (dbg_halt_cmd),  // Halt CPU command
217
    .dbg_reg_sel  (dbg_mem_addr[3:0]), // Debug selected register for rd/wr access
218
    .fe_pmem_wait (fe_pmem_wait),  // Frontend wait for Instruction fetch
219
    .gie          (gie),           // General interrupt enable
220
    .irq          (irq),           // Maskable interrupts
221
    .mclk         (mclk),          // Main system clock
222
    .mdb_in       (fe_mdb_in),     // Frontend Memory data bus input
223
    .nmi_evt      (nmi_evt),       // Non-maskable interrupt event
224
    .pc_sw        (pc_sw),         // Program counter software value
225
    .pc_sw_wr     (pc_sw_wr),      // Program counter software write
226
    .puc          (puc),           // Main system reset
227
    .wdt_irq      (wdt_irq)        // Watchdog-timer interrupt
228
);
229
 
230
 
231
//=============================================================================
232
// 4)  EXECUTION UNIT
233
//=============================================================================
234
 
235
omsp_execution_unit execution_unit_0 (
236
 
237
// OUTPUTs
238
    .cpuoff       (cpuoff),        // Turns off the CPU
239
    .dbg_reg_din  (dbg_reg_din),   // Debug unit CPU register data input
240
    .mab          (eu_mab),        // Memory address bus
241
    .mb_en        (eu_mb_en),      // Memory bus enable
242
    .mb_wr        (eu_mb_wr),      // Memory bus write transfer
243
    .mdb_out      (eu_mdb_out),    // Memory data bus output
244
    .oscoff       (oscoff),        // Turns off LFXT1 clock input
245
    .pc_sw        (pc_sw),         // Program counter software value
246
    .pc_sw_wr     (pc_sw_wr),      // Program counter software write
247
    .scg1         (scg1),          // System clock generator 1. Turns off the SMCLK
248
 
249
// INPUTs
250
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
251
    .dbg_mem_dout (dbg_mem_dout),  // Debug unit data output
252
    .dbg_reg_wr   (dbg_reg_wr),    // Debug unit CPU register write
253
    .e_state      (e_state),       // Execution state
254
    .exec_done    (exec_done),     // Execution completed
255
    .gie          (gie),           // General interrupt enable
256
    .inst_ad      (inst_ad),       // Decoded Inst: destination addressing mode
257
    .inst_as      (inst_as),       // Decoded Inst: source addressing mode
258
    .inst_alu     (inst_alu),      // ALU control signals
259
    .inst_bw      (inst_bw),       // Decoded Inst: byte width
260
    .inst_dest    (inst_dest),     // Decoded Inst: destination (one hot)
261
    .inst_dext    (inst_dext),     // Decoded Inst: destination extended instruction word
262
    .inst_irq_rst (inst_irq_rst),  // Decoded Inst: reset interrupt
263
    .inst_jmp     (inst_jmp),      // Decoded Inst: Conditional jump
264
    .inst_sext    (inst_sext),     // Decoded Inst: source extended instruction word
265
    .inst_so      (inst_so),       // Decoded Inst: Single-operand arithmetic
266
    .inst_src     (inst_src),      // Decoded Inst: source (one hot)
267
    .inst_type    (inst_type),     // Decoded Instruction type
268
    .mclk         (mclk),          // Main system clock
269
    .mdb_in       (eu_mdb_in),     // Memory data bus input
270
    .pc           (pc),            // Program counter
271
    .pc_nxt       (pc_nxt),        // Next PC value (for CALL & IRQ)
272
    .puc          (puc)            // Main system reset
273
);
274
 
275
 
276
//=============================================================================
277
// 5)  MEMORY BACKBONE
278
//=============================================================================
279
 
280
omsp_mem_backbone mem_backbone_0 (
281
 
282
// OUTPUTs
283
    .dbg_mem_din  (dbg_mem_din),   // Debug unit Memory data input
284
    .dmem_addr    (dmem_addr),     // Data Memory address
285
    .dmem_cen     (dmem_cen),      // Data Memory chip enable (low active)
286
    .dmem_din     (dmem_din),      // Data Memory data input
287
    .dmem_wen     (dmem_wen),      // Data Memory write enable (low active)
288
    .eu_mdb_in    (eu_mdb_in),     // Execution Unit Memory data bus input
289
    .fe_mdb_in    (fe_mdb_in),     // Frontend Memory data bus input
290
    .fe_pmem_wait (fe_pmem_wait),  // Frontend wait for Instruction fetch
291
    .per_addr     (per_addr),      // Peripheral address
292
    .per_din      (per_din),       // Peripheral data input
293
    .per_wen      (per_wen),       // Peripheral write enable (high active)
294
    .per_en       (per_en),        // Peripheral enable (high active)
295
    .pmem_addr    (pmem_addr),     // Program Memory address
296
    .pmem_cen     (pmem_cen),      // Program Memory chip enable (low active)
297
    .pmem_din     (pmem_din),      // Program Memory data input (optional)
298
    .pmem_wen     (pmem_wen),      // Program Memory write enable (low active) (optional)
299
 
300
// INPUTs
301
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
302
    .dbg_mem_addr (dbg_mem_addr),  // Debug address for rd/wr access
303
    .dbg_mem_dout (dbg_mem_dout),  // Debug unit data output
304
    .dbg_mem_en   (dbg_mem_en),    // Debug unit memory enable
305
    .dbg_mem_wr   (dbg_mem_wr),    // Debug unit memory write
306
    .dmem_dout    (dmem_dout),     // Data Memory data output
307
    .eu_mab       (eu_mab[15:1]),  // Execution Unit Memory address bus
308
    .eu_mb_en     (eu_mb_en),      // Execution Unit Memory bus enable
309
    .eu_mb_wr     (eu_mb_wr),      // Execution Unit Memory bus write transfer
310
    .eu_mdb_out   (eu_mdb_out),    // Execution Unit Memory data bus output
311
    .fe_mab       (fe_mab[15:1]),  // Frontend Memory address bus
312
    .fe_mb_en     (fe_mb_en),      // Frontend Memory bus enable
313
    .mclk         (mclk),          // Main system clock
314
    .per_dout     (per_dout_or),   // Peripheral data output
315
    .pmem_dout    (pmem_dout),     // Program Memory data output
316
    .puc          (puc)            // Main system reset
317
);
318
 
319
 
320
//=============================================================================
321
// 6)  SPECIAL FUNCTION REGISTERS
322
//=============================================================================
323
 
324
omsp_sfr sfr_0 (
325
 
326
// OUTPUTs
327
    .nmie         (nmie),          // Non-maskable interrupt enable
328
    .per_dout     (per_dout_sfr),  // Peripheral data output
329
    .wdt_irq      (wdt_irq),       // Watchdog-timer interrupt
330
    .wdt_reset    (wdt_reset),     // Watchdog-timer reset
331
    .wdtie        (wdtie),         // Watchdog-timer interrupt enable
332
 
333
// INPUTs
334
    .mclk         (mclk),          // Main system clock
335
    .nmi_acc      (nmi_acc),       // Non-Maskable interrupt request accepted
336
    .per_addr     (per_addr),      // Peripheral address
337
    .per_din      (per_din),       // Peripheral data input
338
    .per_en       (per_en),        // Peripheral enable (high active)
339
    .per_wen      (per_wen),       // Peripheral write enable (high active)
340
    .por          (por),           // Power-on reset
341
    .puc          (puc),           // Main system reset
342
    .wdtifg_clr   (irq_acc[10]),   // Clear Watchdog-timer interrupt flag
343
    .wdtifg_set   (wdtifg_set),    // Set Watchdog-timer interrupt flag
344
    .wdtpw_error  (wdtpw_error),   // Watchdog-timer password error
345
    .wdttmsel     (wdttmsel)       // Watchdog-timer mode select
346
);
347
 
348
 
349
//=============================================================================
350
// 7)  WATCHDOG TIMER
351
//=============================================================================
352
 
353
omsp_watchdog watchdog_0 (
354
 
355
// OUTPUTs
356
    .nmi_evt      (nmi_evt),       // NMI Event
357
    .per_dout     (per_dout_wdog), // Peripheral data output
358
    .wdtifg_set   (wdtifg_set),    // Set Watchdog-timer interrupt flag
359
    .wdtpw_error  (wdtpw_error),   // Watchdog-timer password error
360
    .wdttmsel     (wdttmsel),      // Watchdog-timer mode select
361
 
362
// INPUTs
363
    .aclk_en      (aclk_en),       // ACLK enable
364
    .dbg_freeze   (dbg_freeze),    // Freeze Watchdog counter
365
    .mclk         (mclk),          // Main system clock
366
    .nmi          (nmi),           // Non-maskable interrupt (asynchronous)
367
    .nmie         (nmie),          // Non-maskable interrupt enable
368
    .per_addr     (per_addr),      // Peripheral address
369
    .per_din      (per_din),       // Peripheral data input
370
    .per_en       (per_en),        // Peripheral enable (high active)
371
    .per_wen      (per_wen),       // Peripheral write enable (high active)
372
    .puc          (puc),           // Main system reset
373
    .smclk_en     (smclk_en),      // SMCLK enable
374
    .wdtie        (wdtie)          // Watchdog-timer interrupt enable
375
);
376
 
377
 
378
//=============================================================================
379
// 8)  HARDWARE MULTIPLIER
380
//=============================================================================
381
`ifdef MULTIPLIER
382
omsp_multiplier multiplier_0 (
383
 
384
// OUTPUTs
385
    .per_dout     (per_dout_mpy),  // Peripheral data output
386
 
387
// INPUTs
388
    .mclk         (mclk),          // Main system clock
389
    .per_addr     (per_addr),      // Peripheral address
390
    .per_din      (per_din),       // Peripheral data input
391
    .per_en       (per_en),        // Peripheral enable (high active)
392
    .per_wen      (per_wen),       // Peripheral write enable (high active)
393
    .puc          (puc)            // Main system reset
394
);
395
`else
396
assign per_dout_mpy = 16'h0000;
397
`endif
398
 
399
//=============================================================================
400
// 9)  PERIPHERALS' OUTPUT BUS
401
//=============================================================================
402
 
403
assign  per_dout_or  =  per_dout      |
404
                        per_dout_clk  |
405
                        per_dout_sfr  |
406
                        per_dout_wdog |
407
                        per_dout_mpy;
408
 
409
 
410
//=============================================================================
411
// 10)  DEBUG INTERFACE
412
//=============================================================================
413
 
414
`ifdef DBG_EN
415
omsp_dbg dbg_0 (
416
 
417
// OUTPUTs
418
    .dbg_freeze   (dbg_freeze),    // Freeze peripherals
419
    .dbg_halt_cmd (dbg_halt_cmd),  // Halt CPU command
420
    .dbg_mem_addr (dbg_mem_addr),  // Debug address for rd/wr access
421
    .dbg_mem_dout (dbg_mem_dout),  // Debug unit data output
422
    .dbg_mem_en   (dbg_mem_en),    // Debug unit memory enable
423
    .dbg_mem_wr   (dbg_mem_wr),    // Debug unit memory write
424
    .dbg_reg_wr   (dbg_reg_wr),    // Debug unit CPU register write
425
    .dbg_reset    (dbg_reset),     // Reset CPU from debug interface
426
    .dbg_uart_txd (dbg_uart_txd),  // Debug interface: UART TXD
427
 
428
// INPUTs
429
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
430
    .dbg_mem_din  (dbg_mem_din),   // Debug unit Memory data input
431
    .dbg_reg_din  (dbg_reg_din),   // Debug unit CPU register data input
432
    .dbg_uart_rxd (dbg_uart_rxd),  // Debug interface: UART RXD
433
    .decode_noirq (decode_noirq),  // Frontend decode instruction
434
    .eu_mab       (eu_mab),        // Execution-Unit Memory address bus
435
    .eu_mb_en     (eu_mb_en),      // Execution-Unit Memory bus enable
436
    .eu_mb_wr     (eu_mb_wr),      // Execution-Unit Memory bus write transfer
437
    .eu_mdb_in    (eu_mdb_in),     // Memory data bus input
438
    .eu_mdb_out   (eu_mdb_out),    // Memory data bus output
439
    .exec_done    (exec_done),     // Execution completed
440
    .fe_mb_en     (fe_mb_en),      // Frontend Memory bus enable
441
    .fe_mdb_in    (fe_mdb_in),     // Frontend Memory data bus input
442
    .mclk         (mclk),          // Main system clock
443
    .pc           (pc),            // Program counter
444
    .por          (por),           // Power on reset
445
    .puc          (puc)            // Main system reset
446
);
447
 
448
`else
449
assign dbg_freeze   =  1'b0;
450
assign dbg_halt_cmd =  1'b0;
451
assign dbg_mem_addr = 16'h0000;
452
assign dbg_mem_dout = 16'h0000;
453
assign dbg_mem_en   =  1'b0;
454
assign dbg_mem_wr   =  2'b00;
455
assign dbg_reg_wr   =  1'b0;
456
assign dbg_reset    =  1'b0;
457
assign dbg_uart_txd =  1'b0;
458
`endif
459
 
460
 
461
endmodule // openMSP430
462
 
463
`include "openMSP430_undefines.v"

powered by: WebSVN 2.1.0

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