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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [actel_m1a3pl_dev_kit/] [rtl/] [verilog/] [openMSP430_fpga.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_fpga.v
26
// 
27
// *Module Description:
28
//                      openMSP430 FPGA Top-level
29
//                      (targeting an Actel ProASIC3L).
30
//
31
// *Author(s):
32
//              - Olivier Girard,    olgirard@gmail.com
33
//
34
//----------------------------------------------------------------------------
35
// $Rev: 37 $
36
// $LastChangedBy: olivier.girard $
37
// $LastChangedDate: 2009-12-29 21:58:14 +0100 (Tue, 29 Dec 2009) $
38
//----------------------------------------------------------------------------
39
`include "timescale.v"
40
`include "openMSP430_defines.v"
41
 
42
module openMSP430_fpga (
43
 
44
// OUTPUTs
45
    din_x,                        // SPI Serial Data
46
    din_y,                        // SPI Serial Data
47
    led,                          // Board LEDs
48
    sclk_x,                       // SPI Serial Clock
49
    sclk_y,                       // SPI Serial Clock
50
    sync_n_x,                     // SPI Frame synchronization signal (low active)
51
    sync_n_y,                     // SPI Frame synchronization signal (low active)
52
    uart_tx,                      // Board UART TX pin
53
 
54
// INPUTs
55
    oscclk,                       // Board Oscillator (?? MHz)
56
    porst_n,                      // Board Power-On reset (active low)
57
    pbrst_n,                      // Board Push-Button reset (active low)
58
    uart_rx,                      // Board UART RX pin
59
    switch                        // Board Switches
60
);
61
 
62
// OUTPUTs
63
//=========
64
output              din_x;        // SPI Serial Data
65
output              din_y;        // SPI Serial Data
66
output        [9:0] led;          // Board LEDs
67
output              sclk_x;       // SPI Serial Clock
68
output              sclk_y;       // SPI Serial Clock
69
output              sync_n_x;     // SPI Frame synchronization signal (low active)
70
output              sync_n_y;     // SPI Frame synchronization signal (low active)
71
output              uart_tx;      // Board UART TX pin
72
 
73
// INPUTs
74
//=========
75
input               oscclk;       // Board Oscillator (?? MHz)
76
input               porst_n;      // Board Power-On reset (active low)
77
input               pbrst_n;      // Board Push-Button reset (active low)
78
input               uart_rx;      // Board UART RX pin
79
input         [9:0] switch;       // Board Switches
80
 
81
 
82
//=============================================================================
83
// 1)  INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
84
//=============================================================================
85
 
86
wire  [`DMEM_MSB:0] dmem_addr;
87
wire                dmem_cen;
88
wire         [15:0] dmem_din;
89
wire          [1:0] dmem_wen;
90
wire         [15:0] dmem_dout;
91
 
92
wire  [`PMEM_MSB:0] pmem_addr;
93
wire                pmem_cen;
94
wire         [15:0] pmem_din;
95
wire          [1:0] pmem_wen;
96
wire         [15:0] pmem_dout;
97
 
98
wire          [7:0] per_addr;
99
wire         [15:0] per_din;
100
wire                per_en;
101
wire          [1:0] per_wen;
102
wire         [15:0] per_dout;
103
 
104
wire         [13:0] irq_acc;
105
wire         [13:0] irq_bus;
106
wire                lfxt_clk;
107
wire                nmi;
108
wire                reset_n;
109
 
110
wire                dco_clk;
111
wire                mclk;
112
wire                puc;
113
 
114
wire          [7:0] p1_din;
115
wire          [7:0] p1_dout;
116
wire          [7:0] p1_dout_en;
117
wire          [7:0] p1_sel;
118
wire         [15:0] per_dout_dio;
119
 
120
wire         [15:0] per_dout_tA;
121
 
122
wire          [3:0] cntrl1;
123
wire          [3:0] cntrl2;
124
wire         [15:0] per_dout_dac_x;
125
wire         [15:0] per_dout_dac_y;
126
 
127
 
128
//=============================================================================
129
// 2)  PLL & CLOCK GENERATION
130
//=============================================================================
131
 
132
// Input clock buffer
133
PLLINT clk_in0 (.A(oscclk), .Y(oscclk_buf));
134
 
135
 
136
parameter  FCLKA  = 48.0;
137
parameter  M      = 7'd8;
138
parameter  N      = 7'd3;
139
parameter  U      = 5'd8;
140
parameter  V      = 5'd1;
141
parameter  W      = 5'd1;
142
 
143
parameter  FVCO   = FCLKA*M/N;  // 128 MHz
144
parameter  FGLA   = FVCO/U;     //  16 MHz
145
parameter  FGLB   = FVCO/V;     // 128 MHz
146
parameter  FGLC   = FVCO/W;     // 128 MHz
147
 
148
wire [4:0] oadiv  = U-5'h01;
149
wire [4:0] obdiv  = V-5'h01;
150
wire [4:0] ocdiv  = W-5'h01;
151
wire [6:0] findiv = N-7'h01;
152
wire [6:0] fbdiv  = M-7'h01;
153
 
154
PLL #(.VCOFREQUENCY(FVCO))  pll_0 (
155
 
156
// PLL Inputs
157
    .CLKA         (oscclk_buf),   // Reference Clock Input
158
    .EXTFB        (1'b0),         // External Feedback
159
    .POWERDOWN    (1'b1),         // Power-Down (active low)
160
 
161
// PLL Outputs
162
    .GLA          (dco_clk),      // Primary output
163
    .LOCK         (lock),         // PLL Lock Indicator
164
    .GLB          (glb),          // Secondary 1 output
165
    .YB           (yb),           // Core 1 output
166
    .GLC          (glc),          // Secondary 2 output
167
    .YC           (yc),           // Core 2 output
168
 
169
// GLA Configuration
170
    .OADIV0       (oadiv[0]),     // Primary output divider (divider is oadiv+1)
171
    .OADIV1       (oadiv[1]),
172
    .OADIV2       (oadiv[2]),
173
    .OADIV3       (oadiv[3]),
174
    .OADIV4       (oadiv[4]),
175
 
176
    .OAMUX0       (1'b0),         // Primary output select (selects from the VCO's four phases)
177
    .OAMUX1       (1'b0),
178
    .OAMUX2       (1'b1),
179
 
180
    .DLYGLA0      (1'b0),         // Primary output delay
181
    .DLYGLA1      (1'b0),
182
    .DLYGLA2      (1'b0),
183
    .DLYGLA3      (1'b0),
184
    .DLYGLA4      (1'b0),
185
 
186
// GLB/YB configuration
187
    .OBDIV0       (obdiv[0]),     // Secondary 1 output divider (divider is obdiv+1)
188
    .OBDIV1       (obdiv[1]),
189
    .OBDIV2       (obdiv[2]),
190
    .OBDIV3       (obdiv[3]),
191
    .OBDIV4       (obdiv[4]),
192
 
193
    .OBMUX0       (1'b1),         // Secondary 1 output select (selects from the VCO's four phases)
194
    .OBMUX1       (1'b0),
195
    .OBMUX2       (1'b1),
196
 
197
    .DLYYB0       (1'b0),         // Secondary 1 YB output delay
198
    .DLYYB1       (1'b0),
199
    .DLYYB2       (1'b0),
200
    .DLYYB3       (1'b0),
201
    .DLYYB4       (1'b0),
202
 
203
    .DLYGLB0      (1'b0),         // Secondary 1 GLB output delay
204
    .DLYGLB1      (1'b0),
205
    .DLYGLB2      (1'b0),
206
    .DLYGLB3      (1'b0),
207
    .DLYGLB4      (1'b0),
208
 
209
// GLC/YC configuration
210
    .OCDIV0       (ocdiv[0]),     // Secondary 2 output divider (divider is ocdiv+1)
211
    .OCDIV1       (ocdiv[1]),
212
    .OCDIV2       (ocdiv[2]),
213
    .OCDIV3       (ocdiv[3]),
214
    .OCDIV4       (ocdiv[4]),
215
 
216
    .OCMUX0       (1'b0),         // Secondary 2 output select (selects from the VCO's four phases)
217
    .OCMUX1       (1'b0),
218
    .OCMUX2       (1'b1),
219
 
220
    .DLYYC0       (1'b0),         // Secondary 2 YC output delay
221
    .DLYYC1       (1'b0),
222
    .DLYYC2       (1'b0),
223
    .DLYYC3       (1'b0),
224
    .DLYYC4       (1'b0),
225
 
226
    .DLYGLC0      (1'b0),         // Secondary 2 GLC output delay
227
    .DLYGLC1      (1'b0),
228
    .DLYGLC2      (1'b0),
229
    .DLYGLC3      (1'b0),
230
    .DLYGLC4      (1'b0),
231
 
232
// PLL Core configuration
233
    .FINDIV0      (findiv[0]),    // Input clock divider (divider is findiv+1)
234
    .FINDIV1      (findiv[1]),
235
    .FINDIV2      (findiv[2]),
236
    .FINDIV3      (findiv[3]),
237
    .FINDIV4      (findiv[4]),
238
    .FINDIV5      (findiv[5]),
239
    .FINDIV6      (findiv[6]),
240
 
241
    .FBDIV0       (fbdiv[0]),     // Feedback clock divider (divider is fbdiv+1)
242
    .FBDIV1       (fbdiv[1]),
243
    .FBDIV2       (fbdiv[2]),
244
    .FBDIV3       (fbdiv[3]),
245
    .FBDIV4       (fbdiv[4]),
246
    .FBDIV5       (fbdiv[5]),
247
    .FBDIV6       (fbdiv[6]),
248
 
249
    .FBDLY0       (1'b0),         // Feedback Delay
250
    .FBDLY1       (1'b0),
251
    .FBDLY2       (1'b0),
252
    .FBDLY3       (1'b0),
253
    .FBDLY4       (1'b0),
254
 
255
    .FBSEL0       (1'b1),         // Primary feedback delay select (0:no dly; 1:prog dly element; 2:external feedback)
256
    .FBSEL1       (1'b0),
257
 
258
    .XDLYSEL      (1'b0),         // System Delay Select (0: no dly; 1:inserts system dly)
259
 
260
    .VCOSEL0      (1'b1),         // VCO gear control
261
    .VCOSEL1      (1'b1),
262
    .VCOSEL2      (1'b1)
263
);
264
 
265
 
266
//=============================================================================
267
// 3)  PROGRAM AND DATA MEMORIES
268
//=============================================================================
269
 
270
dmem_128B dmem_hi (.WD(dmem_din[15:8]), .RD(dmem_dout[15:8]), .WEN(dmem_wen[1] | dmem_cen), .REN(~dmem_wen[1] | dmem_cen), .WADDR(dmem_addr) , .RADDR(dmem_addr), .RWCLK(mclk), .RESET(~puc));
271
dmem_128B dmem_lo (.WD(dmem_din[7:0]),  .RD(dmem_dout[7:0]),  .WEN(dmem_wen[0] | dmem_cen), .REN(~dmem_wen[0] | dmem_cen), .WADDR(dmem_addr) , .RADDR(dmem_addr), .RWCLK(mclk), .RESET(~puc));
272
 
273
pmem_2kB  pmem_hi (.WD(pmem_din[15:8]), .RD(pmem_dout[15:8]), .WEN(pmem_wen[1] | pmem_cen), .REN(~pmem_wen[1] | pmem_cen), .WADDR(pmem_addr) , .RADDR(pmem_addr), .RWCLK(mclk), .RESET(~puc));
274
pmem_2kB  pmem_lo (.WD(pmem_din[7:0]),  .RD(pmem_dout[7:0]),  .WEN(pmem_wen[0] | pmem_cen), .REN(~pmem_wen[0] | pmem_cen), .WADDR(pmem_addr) , .RADDR(pmem_addr), .RWCLK(mclk), .RESET(~puc));
275
 
276
 
277
//=============================================================================
278
// 4)  OPENMSP430
279
//=============================================================================
280
 
281
openMSP430 openMSP430_0 (
282
 
283
// OUTPUTs
284
    .aclk_en      (aclk_en),      // ACLK enable
285
    .dbg_freeze   (dbg_freeze),   // Freeze peripherals
286
    .dbg_uart_txd (uart_tx),      // Debug interface: UART TXD
287
    .dmem_addr    (dmem_addr),    // Data Memory address
288
    .dmem_cen     (dmem_cen),     // Data Memory chip enable (low active)
289
    .dmem_din     (dmem_din),     // Data Memory data input
290
    .dmem_wen     (dmem_wen),     // Data Memory write enable (low active)
291
    .irq_acc      (irq_acc),      // Interrupt request accepted (one-hot signal)
292
    .mclk         (mclk),         // Main system clock
293
    .per_addr     (per_addr),     // Peripheral address
294
    .per_din      (per_din),      // Peripheral data input
295
    .per_wen      (per_wen),      // Peripheral write enable (high active)
296
    .per_en       (per_en),       // Peripheral enable (high active)
297
    .pmem_addr    (pmem_addr),    // Program Memory address
298
    .pmem_cen     (pmem_cen),     // Program Memory chip enable (low active)
299
    .pmem_din     (pmem_din),     // Program Memory data input (optional)
300
    .pmem_wen     (pmem_wen),     // Program Memory write enable (low active) (optional)
301
    .puc          (puc),          // Main system reset
302
    .smclk_en     (smclk_en),     // SMCLK enable
303
 
304
// INPUTs
305
    .dbg_uart_rxd (uart_rx),      // Debug interface: UART RXD
306
    .dco_clk      (dco_clk),      // Fast oscillator (fast clock)
307
    .dmem_dout    (dmem_dout),    // Data Memory data output
308
    .irq          (irq_bus),      // Maskable interrupts
309
    .lfxt_clk     (1'b0),         // Low frequency oscillator (typ 32kHz)
310
    .nmi          (nmi),          // Non-maskable interrupt (asynchronous)
311
    .per_dout     (per_dout),     // Peripheral data output
312
    .pmem_dout    (pmem_dout),    // Program Memory data output
313
    .reset_n      (reset_n)       // Reset Pin (low active)
314
);
315
 
316
 
317
//=============================================================================
318
// 5)  OPENMSP430 PERIPHERALS
319
//=============================================================================
320
 
321
//
322
// SPI Interface for the 12 bit DACs
323
//-----------------------------------
324
 
325
dac_spi_if #(1, 9'h190) dac_spi_if_x (
326
 
327
// OUTPUTs
328
    .cntrl1       (cntrl1),         // Control value 1
329
    .cntrl2       (cntrl2),         // Control value 2
330
    .din          (din_x),          // SPI Serial Data
331
    .per_dout     (per_dout_dac_x), // Peripheral data output
332
    .sclk         (sclk_x),         // SPI Serial Clock
333
    .sync_n       (sync_n_x),       // SPI Frame synchronization signal (low active)
334
 
335
// INPUTs
336
    .mclk         (mclk),           // Main system clock
337
    .per_addr     (per_addr),       // Peripheral address
338
    .per_din      (per_din),        // Peripheral data input
339
    .per_en       (per_en),         // Peripheral enable (high active)
340
    .per_wen      (per_wen),        // Peripheral write enable (high active)
341
    .puc          (puc)             // Main system reset
342
);
343
 
344
dac_spi_if #(1, 9'h1A0) dac_spi_if_y (
345
 
346
// OUTPUTs
347
    .cntrl1       (),               // Control value 1
348
    .cntrl2       (),               // Control value 2
349
    .din          (din_y),          // SPI Serial Data
350
    .per_dout     (per_dout_dac_y), // Peripheral data output
351
    .sclk         (sclk_y),         // SPI Serial Clock
352
    .sync_n       (sync_n_y),       // SPI Frame synchronization signal (low active)
353
 
354
// INPUTs
355
    .mclk         (mclk),           // Main system clock
356
    .per_addr     (per_addr),       // Peripheral address
357
    .per_din      (per_din),        // Peripheral data input
358
    .per_en       (per_en),         // Peripheral enable (high active)
359
    .per_wen      (per_wen),        // Peripheral write enable (high active)
360
    .puc          (puc)             // Main system reset
361
);
362
 
363
//
364
// Digital I/O
365
//-------------------------------
366
 
367
omsp_gpio #(.P1_EN(1),
368
            .P2_EN(0),
369
            .P3_EN(0),
370
            .P4_EN(0),
371
            .P5_EN(0),
372
            .P6_EN(0)) gpio_0 (
373
 
374
// OUTPUTs
375
    .irq_port1    (irq_port1),     // Port 1 interrupt
376
    .irq_port2    (),              // Port 2 interrupt
377
    .p1_dout      (p1_dout),       // Port 1 data output
378
    .p1_dout_en   (p1_dout_en),    // Port 1 data output enable
379
    .p1_sel       (p1_sel),        // Port 1 function select
380
    .p2_dout      (),              // Port 2 data output
381
    .p2_dout_en   (),              // Port 2 data output enable
382
    .p2_sel       (),              // Port 2 function select
383
    .p3_dout      (),              // Port 3 data output
384
    .p3_dout_en   (),              // Port 3 data output enable
385
    .p3_sel       (),              // Port 3 function select
386
    .p4_dout      (),              // Port 4 data output
387
    .p4_dout_en   (),              // Port 4 data output enable
388
    .p4_sel       (),              // Port 4 function select
389
    .p5_dout      (),              // Port 5 data output
390
    .p5_dout_en   (),              // Port 5 data output enable
391
    .p5_sel       (),              // Port 5 function select
392
    .p6_dout      (),              // Port 6 data output
393
    .p6_dout_en   (),              // Port 6 data output enable
394
    .p6_sel       (),              // Port 6 function select
395
    .per_dout     (per_dout_dio),  // Peripheral data output
396
 
397
// INPUTs
398
    .mclk         (mclk),          // Main system clock
399
    .p1_din       (p1_din),        // Port 1 data input
400
    .p2_din       (8'h00),         // Port 2 data input
401
    .p3_din       (8'h00),         // Port 3 data input
402
    .p4_din       (8'h00),         // Port 4 data input
403
    .p5_din       (8'h00),         // Port 5 data input
404
    .p6_din       (8'h00),         // Port 6 data input
405
    .per_addr     (per_addr),      // Peripheral address
406
    .per_din      (per_din),       // Peripheral data input
407
    .per_en       (per_en),        // Peripheral enable (high active)
408
    .per_wen      (per_wen),       // Peripheral write enable (high active)
409
    .puc          (puc)            // Main system reset
410
);
411
 
412
//
413
// Timer A
414
//----------------------------------------------
415
 
416
omsp_timerA timerA_0 (
417
 
418
// OUTPUTs
419
    .irq_ta0      (irq_ta0),       // Timer A interrupt: TACCR0
420
    .irq_ta1      (irq_ta1),       // Timer A interrupt: TAIV, TACCR1, TACCR2
421
    .per_dout     (per_dout_tA),   // Peripheral data output
422
    .ta_out0      (ta_out0),       // Timer A output 0
423
    .ta_out0_en   (ta_out0_en),    // Timer A output 0 enable
424
    .ta_out1      (ta_out1),       // Timer A output 1
425
    .ta_out1_en   (ta_out1_en),    // Timer A output 1 enable
426
    .ta_out2      (ta_out2),       // Timer A output 2
427
    .ta_out2_en   (ta_out2_en),    // Timer A output 2 enable
428
 
429
// INPUTs
430
    .aclk_en      (aclk_en),       // ACLK enable (from CPU)
431
    .dbg_freeze   (dbg_freeze),    // Freeze Timer A counter
432
    .inclk        (1'b0),          // INCLK external timer clock (SLOW)
433
    .irq_ta0_acc  (irq_acc[9]),    // Interrupt request TACCR0 accepted
434
    .mclk         (mclk),          // Main system clock
435
    .per_addr     (per_addr),      // Peripheral address
436
    .per_din      (per_din),       // Peripheral data input
437
    .per_en       (per_en),        // Peripheral enable (high active)
438
    .per_wen      (per_wen),       // Peripheral write enable (high active)
439
    .puc          (puc),           // Main system reset
440
    .smclk_en     (smclk_en),      // SMCLK enable (from CPU)
441
    .ta_cci0a     (1'b0),          // Timer A capture 0 input A
442
    .ta_cci0b     (1'b0),          // Timer A capture 0 input B
443
    .ta_cci1a     (1'b0),          // Timer A capture 1 input A
444
    .ta_cci1b     (1'b0),          // Timer A capture 1 input B
445
    .ta_cci2a     (1'b0),          // Timer A capture 2 input A
446
    .ta_cci2b     (1'b0),          // Timer A capture 2 input B
447
    .taclk        (1'b0)           // TACLK external timer clock (SLOW)
448
);
449
 
450
//
451
// Combine peripheral data buses
452
//-------------------------------
453
 
454
assign per_dout = per_dout_dio   |
455
                  per_dout_tA    |
456
                  per_dout_dac_x |
457
                  per_dout_dac_y;
458
 
459
//
460
// Assign interrupts
461
//-------------------------------
462
 
463
assign nmi        =  1'b0;
464
assign irq_bus    = {1'b0,         // Vector 13  (0xFFFA)
465
                     1'b0,         // Vector 12  (0xFFF8)
466
                     1'b0,         // Vector 11  (0xFFF6)
467
                     1'b0,         // Vector 10  (0xFFF4) - Watchdog -
468
                     irq_ta0,      // Vector  9  (0xFFF2)
469
                     irq_ta1,      // Vector  8  (0xFFF0)
470
                     1'b0,         // Vector  7  (0xFFEE)
471
                     1'b0,         // Vector  6  (0xFFEC)
472
                     1'b0,         // Vector  5  (0xFFEA)
473
                     1'b0,         // Vector  4  (0xFFE8)
474
                     1'b0,         // Vector  3  (0xFFE6)
475
                     irq_port1,    // Vector  2  (0xFFE4)
476
                     1'b0,         // Vector  1  (0xFFE2)
477
                     1'b0};        // Vector  0  (0xFFE0)
478
 
479
//
480
// Diverse
481
//-------------------------------
482
 
483
assign  reset_n =  (porst_n & pbrst_n);
484
 
485
assign  p1_din  =  8'h00;
486
 
487
assign  led     =  {cntrl1, p1_dout, p1_dout, cntrl2};
488
 
489
 
490
endmodule // openMSP430_fpga
491
 

powered by: WebSVN 2.1.0

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