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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [rtl/] [verilog/] [openMSP430.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 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
`timescale 1ns / 100ps
35
 
36
module  openMSP430 (
37
 
38
// OUTPUTs
39
    aclk_en,                      // ACLK enable
40
    dbg_freeze,                   // Freeze peripherals
41
    dbg_uart_txd,                 // Debug interface: UART TXD
42
    irq_acc,                      // Interrupt request accepted (one-hot signal)
43
    mclk,                         // Main system clock
44
    per_addr,                     // Peripheral address
45
    per_din,                      // Peripheral data input
46
    per_wen,                      // Peripheral write enable (high active)
47
    per_en,                       // Peripheral enable (high active)
48
    puc,                          // Main system reset
49
    ram_addr,                     // RAM address
50
    ram_cen,                      // RAM chip enable (low active)
51
    ram_din,                      // RAM data input
52
    ram_wen,                      // RAM write enable (low active)
53
    rom_addr,                     // ROM address
54
    rom_cen,                      // ROM chip enable (low active)
55
    rom_din_dbg,                  // ROM data input --FOR DEBUG INTERFACE--
56
    rom_wen_dbg,                  // ROM write enable (low active) --FOR DBG IF--
57
    smclk_en,                     // SMCLK enable
58
 
59
// INPUTs
60
    dbg_uart_rxd,                 // Debug interface: UART RXD
61
    dco_clk,                      // Fast oscillator (fast clock)
62
    irq,                          // Maskable interrupts
63
    lfxt_clk,                     // Low frequency oscillator (typ 32kHz)
64
    nmi,                          // Non-maskable interrupt (asynchronous)
65
    per_dout,                     // Peripheral data output
66
    ram_dout,                     // RAM data output
67
    reset_n,                      // Reset Pin (low active)
68
    rom_dout                      // ROM data output
69
);
70
 
71
// OUTPUTs
72
//=========
73
output              aclk_en;      // ACLK enable
74
output              dbg_freeze;   // Freeze peripherals
75
output              dbg_uart_txd; // Debug interface: UART TXD
76
output       [13:0] irq_acc;      // Interrupt request accepted (one-hot signal)
77
output              mclk;         // Main system clock
78
output        [7:0] per_addr;     // Peripheral address
79
output       [15:0] per_din;      // Peripheral data input
80
output        [1:0] per_wen;      // Peripheral write enable (high active)
81
output              per_en;       // Peripheral enable (high active)
82
output              puc;          // Main system reset
83
output [`RAM_MSB:0] ram_addr;     // RAM address
84
output              ram_cen;      // RAM chip enable (low active)
85
output       [15:0] ram_din;      // RAM data input
86
output        [1:0] ram_wen;      // RAM write enable (low active)
87
output [`ROM_MSB:0] rom_addr;     // ROM address
88
output              rom_cen;      // ROM chip enable (low active)
89
output       [15:0] rom_din_dbg;  // ROM data input --FOR DEBUG INTERFACE--
90
output        [1:0] rom_wen_dbg;  // ROM write enable (low active) --FOR DBG IF--
91
output              smclk_en;     // SMCLK enable
92
 
93
 
94
// INPUTs
95
//=========
96
input               dbg_uart_rxd; // Debug interface: UART RXD
97
input               dco_clk;      // Fast oscillator (fast clock)
98
input        [13:0] irq;          // Maskable interrupts
99
input               lfxt_clk;     // Low frequency oscillator (typ 32kHz)
100
input               nmi;          // Non-maskable interrupt (asynchronous)
101
input        [15:0] per_dout;     // Peripheral data output
102
input        [15:0] ram_dout;     // RAM data output
103
input               reset_n;      // Reset Pin (active low)
104
input        [15:0] rom_dout;     // ROM data output
105
 
106
 
107
 
108
//=============================================================================
109
// 1)  INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
110
//=============================================================================
111
 
112
wire          [7:0] inst_ad;
113
wire          [7:0] inst_as;
114
wire         [11:0] inst_alu;
115
wire                inst_bw;
116
wire         [15:0] inst_dest;
117
wire         [15:0] inst_dext;
118
wire         [15:0] inst_sext;
119
wire          [7:0] inst_so;
120
wire         [15:0] inst_src;
121
wire          [2:0] inst_type;
122
wire          [3:0] e_state;
123
wire                exec_done;
124
 
125
wire         [15:0] eu_mab;
126
wire         [15:0] eu_mdb_in;
127
wire         [15:0] eu_mdb_out;
128
wire          [1:0] eu_mb_wr;
129
wire         [15:0] fe_mab;
130
wire         [15:0] fe_mdb_in;
131
 
132
wire         [15:0] pc_sw;
133
wire          [7:0] inst_jmp;
134
wire         [15:0] pc;
135
wire         [15:0] pc_nxt;
136
 
137
wire         [15:0] dbg_mem_addr;
138
wire         [15:0] dbg_mem_dout;
139
wire         [15:0] dbg_mem_din;
140
wire         [15:0] dbg_reg_din;
141
wire          [1:0] dbg_mem_wr;
142
 
143
wire         [15:0] per_dout_or;
144
wire         [15:0] per_dout_sfr;
145
wire         [15:0] per_dout_wdog;
146
wire         [15:0] per_dout_clk;
147
 
148
 
149
//=============================================================================
150
// 2)  GLOBAL CLOCK & RESET MANAGEMENT
151
//=============================================================================
152
 
153
clock_module clock_module_0 (
154
 
155
// OUTPUTs
156
    .aclk_en      (aclk_en),       // ACLK enablex
157
    .mclk         (mclk),          // Main system clock
158
    .per_dout     (per_dout_clk),  // Peripheral data output
159
    .por          (por),           // Power-on reset
160
    .puc          (puc),           // Main system reset
161
    .smclk_en     (smclk_en),      // SMCLK enable
162
 
163
// INPUTs
164
    .dbg_reset    (dbg_reset),     // Reset CPU from debug interface
165
    .dco_clk      (dco_clk),       // Fast oscillator (fast clock)
166
    .lfxt_clk     (lfxt_clk),      // Low frequency oscillator (typ 32kHz)
167
    .oscoff       (oscoff),        // Turns off LFXT1 clock input
168
    .per_addr     (per_addr),      // Peripheral address
169
    .per_din      (per_din),       // Peripheral data input
170
    .per_en       (per_en),        // Peripheral enable (high active)
171
    .per_wen      (per_wen),       // Peripheral write enable (high active)
172
    .reset_n      (reset_n),       // Reset Pin (low active)
173
    .scg1         (scg1),          // System clock generator 1. Turns off the SMCLK
174
    .wdt_reset    (wdt_reset)      // Watchdog-timer reset
175
);
176
 
177
 
178
//=============================================================================
179
// 3)  FRONTEND (<=> FETCH & DECODE)
180
//=============================================================================
181
 
182
frontend frontend_0 (
183
 
184
// OUTPUTs
185
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
186
    .decode       (decode),        // Frontend decode instruction
187
    .e_state      (e_state),       // Execution state
188
    .exec_done    (exec_done),     // Execution completed
189
    .inst_ad      (inst_ad),       // Decoded Inst: destination addressing mode
190
    .inst_as      (inst_as),       // Decoded Inst: source addressing mode
191
    .inst_alu     (inst_alu),      // ALU control signals
192
    .inst_bw      (inst_bw),       // Decoded Inst: byte width
193
    .inst_dest    (inst_dest),     // Decoded Inst: destination (one hot)
194
    .inst_dext    (inst_dext),     // Decoded Inst: destination extended instruction word
195
    .inst_irq_rst (inst_irq_rst),  // Decoded Inst: Reset interrupt
196
    .inst_jmp     (inst_jmp),      // Decoded Inst: Conditional jump
197
    .inst_sext    (inst_sext),     // Decoded Inst: source extended instruction word
198
    .inst_so      (inst_so),       // Decoded Inst: Single-operand arithmetic
199
    .inst_src     (inst_src),      // Decoded Inst: source (one hot)
200
    .inst_type    (inst_type),     // Decoded Instruction type
201
    .irq_acc      (irq_acc),       // Interrupt request accepted
202
    .mab          (fe_mab),        // Frontend Memory address bus
203
    .mb_en        (fe_mb_en),      // Frontend Memory bus enable
204
    .nmi_acc      (nmi_acc),       // Non-Maskable interrupt request accepted
205
    .pc           (pc),            // Program counter
206
    .pc_nxt       (pc_nxt),        // Next PC value (for CALL & IRQ)
207
 
208
// INPUTs
209
    .cpuoff       (cpuoff),        // Turns off the CPU
210
    .dbg_halt_cmd (dbg_halt_cmd),  // Halt CPU command
211
    .dbg_reg_sel  (dbg_mem_addr[3:0]), // Debug selected register for rd/wr access
212
    .fe_rom_wait  (fe_rom_wait),   // Frontend wait for ROM
213
    .gie          (gie),           // General interrupt enable
214
    .irq          (irq),           // Maskable interrupts
215
    .mclk         (mclk),          // Main system clock
216
    .mdb_in       (fe_mdb_in),     // Frontend Memory data bus input
217
    .nmi_evt      (nmi_evt),       // Non-maskable interrupt event
218
    .pc_sw        (pc_sw),         // Program counter software value
219
    .pc_sw_wr     (pc_sw_wr),      // Program counter software write
220
    .puc          (puc),           // Main system reset
221
    .wdt_irq      (wdt_irq)        // Watchdog-timer interrupt
222
);
223
 
224
 
225
//=============================================================================
226
// 4)  EXECUTION UNIT
227
//=============================================================================
228
 
229
execution_unit execution_unit_0 (
230
 
231
// OUTPUTs
232
    .cpuoff       (cpuoff),        // Turns off the CPU
233
    .dbg_reg_din  (dbg_reg_din),   // Debug unit CPU register data input
234
    .mab          (eu_mab),        // Memory address bus
235
    .mb_en        (eu_mb_en),      // Memory bus enable
236
    .mb_wr        (eu_mb_wr),      // Memory bus write transfer
237
    .mdb_out      (eu_mdb_out),    // Memory data bus output
238
    .oscoff       (oscoff),        // Turns off LFXT1 clock input
239
    .pc_sw        (pc_sw),         // Program counter software value
240
    .pc_sw_wr     (pc_sw_wr),      // Program counter software write
241
    .scg1         (scg1),          // System clock generator 1. Turns off the SMCLK
242
 
243
// INPUTs
244
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
245
    .dbg_mem_dout (dbg_mem_dout),  // Debug unit data output
246
    .dbg_reg_wr   (dbg_reg_wr),    // Debug unit CPU register write
247
    .e_state      (e_state),       // Execution state
248
    .exec_done    (exec_done),     // Execution completed
249
    .gie          (gie),           // General interrupt enable
250
    .inst_ad      (inst_ad),       // Decoded Inst: destination addressing mode
251
    .inst_as      (inst_as),       // Decoded Inst: source addressing mode
252
    .inst_alu     (inst_alu),      // ALU control signals
253
    .inst_bw      (inst_bw),       // Decoded Inst: byte width
254
    .inst_dest    (inst_dest),     // Decoded Inst: destination (one hot)
255
    .inst_dext    (inst_dext),     // Decoded Inst: destination extended instruction word
256
    .inst_irq_rst (inst_irq_rst),  // Decoded Inst: reset interrupt
257
    .inst_jmp     (inst_jmp),      // Decoded Inst: Conditional jump
258
    .inst_sext    (inst_sext),     // Decoded Inst: source extended instruction word
259
    .inst_so      (inst_so),       // Decoded Inst: Single-operand arithmetic
260
    .inst_src     (inst_src),      // Decoded Inst: source (one hot)
261
    .inst_type    (inst_type),     // Decoded Instruction type
262
    .mclk         (mclk),          // Main system clock
263
    .mdb_in       (eu_mdb_in),     // Memory data bus input
264
    .pc           (pc),            // Program counter
265
    .pc_nxt       (pc_nxt),        // Next PC value (for CALL & IRQ)
266
    .puc          (puc)            // Main system reset
267
);
268
 
269
 
270
//=============================================================================
271
// 5)  MEMORY BACKBONE
272
//=============================================================================
273
 
274
mem_backbone mem_backbone_0 (
275
 
276
// OUTPUTs
277
    .dbg_mem_din  (dbg_mem_din),   // Debug unit Memory data input
278
    .eu_mdb_in    (eu_mdb_in),     // Execution Unit Memory data bus input
279
    .fe_mdb_in    (fe_mdb_in),     // Frontend Memory data bus input
280
    .fe_rom_wait  (fe_rom_wait),   // Frontend wait for ROM
281
    .per_addr     (per_addr),      // Peripheral address
282
    .per_din      (per_din),       // Peripheral data input
283
    .per_wen      (per_wen),       // Peripheral write enable (high active)
284
    .per_en       (per_en),        // Peripheral enable (high active)
285
    .ram_addr     (ram_addr),      // RAM address
286
    .ram_cen      (ram_cen),       // RAM chip enable (low active)
287
    .ram_din      (ram_din),       // RAM data input
288
    .ram_wen      (ram_wen),       // RAM write enable (low active)
289
    .rom_addr     (rom_addr),      // ROM address
290
    .rom_cen      (rom_cen),       // ROM chip enable (low active)
291
    .rom_din_dbg  (rom_din_dbg),   // ROM data input --FOR DEBUG INTERFACE--
292
    .rom_wen_dbg  (rom_wen_dbg),   // ROM write enable (low active) --FOR DBG IF--
293
 
294
// INPUTs
295
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
296
    .dbg_mem_addr (dbg_mem_addr),  // Debug address for rd/wr access
297
    .dbg_mem_dout (dbg_mem_dout),  // Debug unit data output
298
    .dbg_mem_en   (dbg_mem_en),    // Debug unit memory enable
299
    .dbg_mem_wr   (dbg_mem_wr),    // Debug unit memory write
300
    .eu_mab       (eu_mab[15:1]),  // Execution Unit Memory address bus
301
    .eu_mb_en     (eu_mb_en),      // Execution Unit Memory bus enable
302
    .eu_mb_wr     (eu_mb_wr),      // Execution Unit Memory bus write transfer
303
    .eu_mdb_out   (eu_mdb_out),    // Execution Unit Memory data bus output
304
    .fe_mab       (fe_mab[15:1]),  // Frontend Memory address bus
305
    .fe_mb_en     (fe_mb_en),      // Frontend Memory bus enable
306
    .mclk         (mclk),          // Main system clock
307
    .per_dout     (per_dout_or),   // Peripheral data output
308
    .puc          (puc),           // Main system reset
309
    .ram_dout     (ram_dout),      // RAM data output
310
    .rom_dout     (rom_dout)       // ROM data output
311
);
312
 
313
 
314
//=============================================================================
315
// 6)  SPECIAL FUNCTION REGISTERS
316
//=============================================================================
317
 
318
sfr sfr_0 (
319
 
320
// OUTPUTs
321
    .nmie         (nmie),          // Non-maskable interrupt enable
322
    .per_dout     (per_dout_sfr),  // Peripheral data output
323
    .wdt_irq      (wdt_irq),       // Watchdog-timer interrupt
324
    .wdt_reset    (wdt_reset),     // Watchdog-timer reset
325
    .wdtie        (wdtie),         // Watchdog-timer interrupt enable
326
 
327
// INPUTs
328
    .mclk         (mclk),          // Main system clock
329
    .nmi_acc      (nmi_acc),       // Non-Maskable interrupt request accepted
330
    .per_addr     (per_addr),      // Peripheral address
331
    .per_din      (per_din),       // Peripheral data input
332
    .per_en       (per_en),        // Peripheral enable (high active)
333
    .per_wen      (per_wen),       // Peripheral write enable (high active)
334
    .por          (por),           // Power-on reset
335
    .puc          (puc),           // Main system reset
336
    .wdtifg_clr   (irq_acc[10]),   // Clear Watchdog-timer interrupt flag
337
    .wdtifg_set   (wdtifg_set),    // Set Watchdog-timer interrupt flag
338
    .wdtpw_error  (wdtpw_error),   // Watchdog-timer password error
339
    .wdttmsel     (wdttmsel)       // Watchdog-timer mode select
340
);
341
 
342
 
343
//=============================================================================
344
// 7)  WATCHDOG TIMER
345
//=============================================================================
346
 
347
watchdog watchdog_0 (
348
 
349
// OUTPUTs
350
    .nmi_evt      (nmi_evt),       // NMI Event
351
    .per_dout     (per_dout_wdog), // Peripheral data output
352
    .wdtifg_set   (wdtifg_set),    // Set Watchdog-timer interrupt flag
353
    .wdtpw_error  (wdtpw_error),   // Watchdog-timer password error
354
    .wdttmsel     (wdttmsel),      // Watchdog-timer mode select
355
 
356
// INPUTs
357
    .aclk_en      (aclk_en),       // ACLK enable
358
    .dbg_freeze   (dbg_freeze),    // Freeze Watchdog counter
359
    .mclk         (mclk),          // Main system clock
360
    .nmi          (nmi),           // Non-maskable interrupt (asynchronous)
361
    .nmie         (nmie),          // Non-maskable interrupt enable
362
    .per_addr     (per_addr),      // Peripheral address
363
    .per_din      (per_din),       // Peripheral data input
364
    .per_en       (per_en),        // Peripheral enable (high active)
365
    .per_wen      (per_wen),       // Peripheral write enable (high active)
366
    .puc          (puc),           // Main system reset
367
    .smclk_en     (smclk_en),      // SMCLK enable
368
    .wdtie        (wdtie)          // Watchdog-timer interrupt enable
369
);
370
 
371
 
372
//=============================================================================
373
// 8)  PERIPHERALS' OUTPUT BUS
374
//=============================================================================
375
 
376
assign  per_dout_or  =  per_dout      |
377
                        per_dout_clk  |
378
                        per_dout_sfr  |
379
                        per_dout_wdog;
380
 
381
 
382
//=============================================================================
383
// 9)  DEBUG INTERFACE
384
//=============================================================================
385
 
386
`ifdef DBG_EN
387
dbg dbg_0 (
388
 
389
// OUTPUTs
390
    .dbg_freeze   (dbg_freeze),    // Freeze peripherals
391
    .dbg_halt_cmd (dbg_halt_cmd),  // Halt CPU command
392
    .dbg_mem_addr (dbg_mem_addr),  // Debug address for rd/wr access
393
    .dbg_mem_dout (dbg_mem_dout),  // Debug unit data output
394
    .dbg_mem_en   (dbg_mem_en),    // Debug unit memory enable
395
    .dbg_mem_wr   (dbg_mem_wr),    // Debug unit memory write
396
    .dbg_reg_wr   (dbg_reg_wr),    // Debug unit CPU register write
397
    .dbg_reset    (dbg_reset),     // Reset CPU from debug interface
398
    .dbg_uart_txd (dbg_uart_txd),  // Debug interface: UART TXD
399
 
400
// INPUTs
401
    .dbg_halt_st  (dbg_halt_st),   // Halt/Run status from CPU
402
    .dbg_mem_din  (dbg_mem_din),   // Debug unit Memory data input
403
    .dbg_reg_din  (dbg_reg_din),   // Debug unit CPU register data input
404
    .dbg_uart_rxd (dbg_uart_rxd),  // Debug interface: UART RXD
405
    .decode       (decode),        // Frontend decode instruction
406
    .eu_mab       (eu_mab),        // Execution-Unit Memory address bus
407
    .eu_mb_en     (eu_mb_en),      // Execution-Unit Memory bus enable
408
    .eu_mb_wr     (eu_mb_wr),      // Execution-Unit Memory bus write transfer
409
    .eu_mdb_in    (eu_mdb_in),     // Memory data bus input
410
    .eu_mdb_out   (eu_mdb_out),    // Memory data bus output
411
    .exec_done    (exec_done),     // Execution completed
412
    .fe_mb_en     (fe_mb_en),      // Frontend Memory bus enable
413
    .fe_mdb_in    (fe_mdb_in),     // Frontend Memory data bus input
414
    .mclk         (mclk),          // Main system clock
415
    .pc           (pc),            // Program counter
416
    .por          (por),           // Power on reset
417
    .puc          (puc)            // Main system reset
418
);
419
 
420
`else
421
assign dbg_freeze   =  1'b0;
422
assign dbg_halt_cmd =  1'b0;
423
assign dbg_mem_addr = 16'h0000;
424
assign dbg_mem_dout = 16'h0000;
425
assign dbg_mem_en   =  1'b0;
426
assign dbg_mem_wr   =  2'b00;
427
assign dbg_reg_wr   =  1'b0;
428
assign dbg_reset    =  1'b0;
429
assign dbg_uart_txd =  1'b0;
430
`endif
431
 
432
 
433
endmodule // openMSP430
434
 

powered by: WebSVN 2.1.0

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