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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_diligent_s3board/] [rtl/] [verilog/] [openMSP430_fpga.v] - Blame information for rev 23

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_fpga.v
26
// 
27
// *Module Description:
28
//                      openMSP430 FPGA Top-level for the Diligent
29
//                     Spartan-3 starter kit.
30
//
31
// *Author(s):
32
//              - Olivier Girard,    olgirard@gmail.com
33
//
34
//----------------------------------------------------------------------------
35 16 olivier.gi
// $Rev: 23 $
36
// $LastChangedBy: olivier.girard $
37
// $LastChangedDate: 2009-08-30 18:39:26 +0200 (Sun, 30 Aug 2009) $
38
//----------------------------------------------------------------------------
39 23 olivier.gi
`include "timescale.v"
40
`include "openMSP430_defines.v"
41 2 olivier.gi
 
42
module openMSP430_fpga (
43
 
44
// Clock Sources
45
    CLK_50MHz,
46
    CLK_SOCKET,
47
 
48
// Slide Switches
49
    SW7,
50
    SW6,
51
    SW5,
52
    SW4,
53
    SW3,
54
    SW2,
55
    SW1,
56
    SW0,
57
 
58
// Push Button Switches
59
    BTN3,
60
    BTN2,
61
    BTN1,
62
    BTN0,
63
 
64
// LEDs
65
    LED7,
66
    LED6,
67
    LED5,
68
    LED4,
69
    LED3,
70
    LED2,
71
    LED1,
72
    LED0,
73
 
74
// Four-Sigit, Seven-Segment LED Display
75
    SEG_A,
76
    SEG_B,
77
    SEG_C,
78
    SEG_D,
79
    SEG_E,
80
    SEG_F,
81
    SEG_G,
82
    SEG_DP,
83
    SEG_AN0,
84
    SEG_AN1,
85
    SEG_AN2,
86
    SEG_AN3,
87
 
88
// RS-232 Port
89
    UART_RXD,
90
    UART_TXD,
91
    UART_RXD_A,
92
    UART_TXD_A,
93
 
94
// PS/2 Mouse/Keyboard Port
95
    PS2_D,
96
    PS2_C,
97
 
98
// Fast, Asynchronous SRAM
99
    SRAM_A17,               // Address Bus Connections
100
    SRAM_A16,
101
    SRAM_A15,
102
    SRAM_A14,
103
    SRAM_A13,
104
    SRAM_A12,
105
    SRAM_A11,
106
    SRAM_A10,
107
    SRAM_A9,
108
    SRAM_A8,
109
    SRAM_A7,
110
    SRAM_A6,
111
    SRAM_A5,
112
    SRAM_A4,
113
    SRAM_A3,
114
    SRAM_A2,
115
    SRAM_A1,
116
    SRAM_A0,
117
    SRAM_OE,                // Write enable and output enable control signals
118
    SRAM_WE,
119
    SRAM0_IO15,             // SRAM Data signals, chip enables, and byte enables
120
    SRAM0_IO14,
121
    SRAM0_IO13,
122
    SRAM0_IO12,
123
    SRAM0_IO11,
124
    SRAM0_IO10,
125
    SRAM0_IO9,
126
    SRAM0_IO8,
127
    SRAM0_IO7,
128
    SRAM0_IO6,
129
    SRAM0_IO5,
130
    SRAM0_IO4,
131
    SRAM0_IO3,
132
    SRAM0_IO2,
133
    SRAM0_IO1,
134
    SRAM0_IO0,
135
    SRAM0_CE1,
136
    SRAM0_UB1,
137
    SRAM0_LB1,
138
    SRAM1_IO15,
139
    SRAM1_IO14,
140
    SRAM1_IO13,
141
    SRAM1_IO12,
142
    SRAM1_IO11,
143
    SRAM1_IO10,
144
    SRAM1_IO9,
145
    SRAM1_IO8,
146
    SRAM1_IO7,
147
    SRAM1_IO6,
148
    SRAM1_IO5,
149
    SRAM1_IO4,
150
    SRAM1_IO3,
151
    SRAM1_IO2,
152
    SRAM1_IO1,
153
    SRAM1_IO0,
154
    SRAM1_CE2,
155
    SRAM1_UB2,
156
    SRAM1_LB2,
157
 
158
// VGA Port
159
    VGA_R,
160
    VGA_G,
161
    VGA_B,
162
    VGA_HS,
163
    VGA_VS
164
);
165
 
166
// Clock Sources
167
input     CLK_50MHz;
168
input     CLK_SOCKET;
169
 
170
// Slide Switches
171
input     SW7;
172
input     SW6;
173
input     SW5;
174
input     SW4;
175
input     SW3;
176
input     SW2;
177
input     SW1;
178
input     SW0;
179
 
180
// Push Button Switches
181
input     BTN3;
182
input     BTN2;
183
input     BTN1;
184
input     BTN0;
185
 
186
// LEDs
187
output    LED7;
188
output    LED6;
189
output    LED5;
190
output    LED4;
191
output    LED3;
192
output    LED2;
193
output    LED1;
194
output    LED0;
195
 
196
// Four-Sigit, Seven-Segment LED Display
197
output    SEG_A;
198
output    SEG_B;
199
output    SEG_C;
200
output    SEG_D;
201
output    SEG_E;
202
output    SEG_F;
203
output    SEG_G;
204
output    SEG_DP;
205
output    SEG_AN0;
206
output    SEG_AN1;
207
output    SEG_AN2;
208
output    SEG_AN3;
209
 
210
// RS-232 Port
211
input     UART_RXD;
212
output    UART_TXD;
213
input     UART_RXD_A;
214
output    UART_TXD_A;
215
 
216
// PS/2 Mouse/Keyboard Port
217
inout     PS2_D;
218
output    PS2_C;
219
 
220
// Fast, Asynchronous SRAM
221
output    SRAM_A17;         // Address Bus Connections
222
output    SRAM_A16;
223
output    SRAM_A15;
224
output    SRAM_A14;
225
output    SRAM_A13;
226
output    SRAM_A12;
227
output    SRAM_A11;
228
output    SRAM_A10;
229
output    SRAM_A9;
230
output    SRAM_A8;
231
output    SRAM_A7;
232
output    SRAM_A6;
233
output    SRAM_A5;
234
output    SRAM_A4;
235
output    SRAM_A3;
236
output    SRAM_A2;
237
output    SRAM_A1;
238
output    SRAM_A0;
239
output    SRAM_OE;          // Write enable and output enable control signals
240
output    SRAM_WE;
241
inout     SRAM0_IO15;       // SRAM Data signals, chip enables, and byte enables
242
inout     SRAM0_IO14;
243
inout     SRAM0_IO13;
244
inout     SRAM0_IO12;
245
inout     SRAM0_IO11;
246
inout     SRAM0_IO10;
247
inout     SRAM0_IO9;
248
inout     SRAM0_IO8;
249
inout     SRAM0_IO7;
250
inout     SRAM0_IO6;
251
inout     SRAM0_IO5;
252
inout     SRAM0_IO4;
253
inout     SRAM0_IO3;
254
inout     SRAM0_IO2;
255
inout     SRAM0_IO1;
256
inout     SRAM0_IO0;
257
output    SRAM0_CE1;
258
output    SRAM0_UB1;
259
output    SRAM0_LB1;
260
inout     SRAM1_IO15;
261
inout     SRAM1_IO14;
262
inout     SRAM1_IO13;
263
inout     SRAM1_IO12;
264
inout     SRAM1_IO11;
265
inout     SRAM1_IO10;
266
inout     SRAM1_IO9;
267
inout     SRAM1_IO8;
268
inout     SRAM1_IO7;
269
inout     SRAM1_IO6;
270
inout     SRAM1_IO5;
271
inout     SRAM1_IO4;
272
inout     SRAM1_IO3;
273
inout     SRAM1_IO2;
274
inout     SRAM1_IO1;
275
inout     SRAM1_IO0;
276
output    SRAM1_CE2;
277
output    SRAM1_UB2;
278
output    SRAM1_LB2;
279
 
280
// VGA Port
281
output    VGA_R;
282
output    VGA_G;
283
output    VGA_B;
284
output    VGA_HS;
285
output    VGA_VS;
286
 
287
 
288
//=============================================================================
289
// 1)  INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
290
//=============================================================================
291
 
292
// openMSP430 output buses
293
wire        [7:0] per_addr;
294
wire       [15:0] per_din;
295
wire        [1:0] per_wen;
296
wire [`RAM_MSB:0] ram_addr;
297
wire       [15:0] ram_din;
298
wire        [1:0] ram_wen;
299
wire [`ROM_MSB:0] rom_addr;
300
wire       [15:0] rom_din_dbg;
301
wire        [1:0] rom_wen_dbg;
302
wire       [13:0] irq_acc;
303
 
304
// openMSP430 input buses
305
wire       [13:0] irq_bus;
306
wire       [15:0] per_dout;
307
wire       [15:0] ram_dout;
308
wire       [15:0] rom_dout;
309
 
310
// GPIO
311
wire        [7:0] p1_din;
312
wire        [7:0] p1_dout;
313
wire        [7:0] p1_dout_en;
314
wire        [7:0] p1_sel;
315
wire        [7:0] p2_din;
316
wire        [7:0] p2_dout;
317
wire        [7:0] p2_dout_en;
318
wire        [7:0] p2_sel;
319
wire        [7:0] p3_din;
320
wire        [7:0] p3_dout;
321
wire        [7:0] p3_dout_en;
322
wire        [7:0] p3_sel;
323
wire       [15:0] per_dout_dio;
324
 
325
// Timer A
326
wire       [15:0] per_dout_tA;
327
 
328
// 7 segment driver
329
wire       [15:0] per_dout_7seg;
330
 
331
// Others
332
wire              reset_pin;
333
 
334
 
335
//=============================================================================
336
// 2)  CLOCK GENERATION
337
//=============================================================================
338
 
339
// Input buffers
340
//------------------------
341
IBUFG ibuf_clk_main   (.O(clk_50M_in),    .I(CLK_50MHz));
342
IBUFG ibuf_clk_socket (.O(clk_socket_in), .I(CLK_SOCKET));
343
 
344
 
345
// Digital Clock Manager
346
//------------------------
347
 
348
// Generate 20MHz clock from 50MHz on-board oscillator
349
//`define DCM_FX_MODE
350
`ifdef DCM_FX_MODE
351
DCM dcm_adv_clk_main (
352
 
353
// OUTPUTs
354
    .CLK0         (),
355
    .CLK90        (),
356
    .CLK180       (),
357
    .CLK270       (),
358
    .CLK2X        (),
359
    .CLK2X180     (),
360
    .CLKDV        (),
361
    .CLKFX        (dcm_clk),
362
    .CLKFX180     (),
363
    .PSDONE       (),
364
    .STATUS       (),
365
    .LOCKED       (dcm_locked),
366
 
367
// INPUTs
368
    .CLKIN        (clk_50M_in),
369
    .CLKFB        (1'b0),
370
    .PSINCDEC     (1'b0),
371
    .PSEN         (1'b0),
372
    .DSSEN        (1'b0),
373
    .RST          (reset_pin),
374
    .PSCLK        (1'b0)
375
);
376
 
377
// synopsys translate_off
378
defparam dcm_adv_clk_main.CLK_FEEDBACK          = "NONE";
379
defparam dcm_adv_clk_main.CLKDV_DIVIDE          = 2.5;
380
defparam dcm_adv_clk_main.CLKIN_DIVIDE_BY_2     = "FALSE";
381
defparam dcm_adv_clk_main.CLKIN_PERIOD          = 20.0;
382
defparam dcm_adv_clk_main.CLKOUT_PHASE_SHIFT    = "NONE";
383
defparam dcm_adv_clk_main.DESKEW_ADJUST         = "SYSTEM_SYNCHRONOUS";
384
defparam dcm_adv_clk_main.DFS_FREQUENCY_MODE    = "LOW";
385
defparam dcm_adv_clk_main.DLL_FREQUENCY_MODE    = "LOW";
386
defparam dcm_adv_clk_main.DUTY_CYCLE_CORRECTION = "TRUE";
387
defparam dcm_adv_clk_main.FACTORY_JF            = 16'hC080;
388
defparam dcm_adv_clk_main.PHASE_SHIFT           = 0;
389
defparam dcm_adv_clk_main.STARTUP_WAIT          = "FALSE";
390
 
391
defparam dcm_adv_clk_main.CLKFX_DIVIDE          = 5;
392
defparam dcm_adv_clk_main.CLKFX_MULTIPLY        = 2;
393
// synopsys translate_on
394
`else
395
DCM dcm_adv_clk_main (
396
 
397
// OUTPUTs
398
    .CLKDV        (dcm_clk),
399
    .CLKFX        (),
400
    .CLKFX180     (),
401
    .CLK0         (CLK0_BUF),
402
    .CLK2X        (),
403
    .CLK2X180     (),
404
    .CLK90        (),
405
    .CLK180       (),
406
    .CLK270       (),
407
    .LOCKED       (dcm_locked),
408
    .PSDONE       (),
409
    .STATUS       (),
410
 
411
// INPUTs
412
    .CLKFB        (CLKFB_IN),
413
    .CLKIN        (clk_50M_in),
414
    .PSEN         (1'b0),
415
    .PSINCDEC     (1'b0),
416
    .DSSEN        (1'b0),
417
    .PSCLK        (1'b0),
418
    .RST          (reset_pin)
419
);
420
BUFG CLK0_BUFG_INST (
421
    .I(CLK0_BUF),
422
    .O(CLKFB_IN)
423
);
424
 
425
// synopsys translate_off
426
defparam dcm_adv_clk_main.CLK_FEEDBACK          = "1X";
427
defparam dcm_adv_clk_main.CLKDV_DIVIDE          = 2.5;
428
defparam dcm_adv_clk_main.CLKFX_DIVIDE          = 1;
429
defparam dcm_adv_clk_main.CLKFX_MULTIPLY        = 4;
430
defparam dcm_adv_clk_main.CLKIN_DIVIDE_BY_2     = "FALSE";
431
defparam dcm_adv_clk_main.CLKIN_PERIOD          = 20.000;
432
defparam dcm_adv_clk_main.CLKOUT_PHASE_SHIFT    = "NONE";
433
defparam dcm_adv_clk_main.DESKEW_ADJUST         = "SYSTEM_SYNCHRONOUS";
434
defparam dcm_adv_clk_main.DFS_FREQUENCY_MODE    = "LOW";
435
defparam dcm_adv_clk_main.DLL_FREQUENCY_MODE    = "LOW";
436
defparam dcm_adv_clk_main.DUTY_CYCLE_CORRECTION = "TRUE";
437
defparam dcm_adv_clk_main.FACTORY_JF            = 16'h8080;
438
defparam dcm_adv_clk_main.PHASE_SHIFT           = 0;
439
defparam dcm_adv_clk_main.STARTUP_WAIT          = "FALSE";
440
// synopsys translate_on  
441
`endif
442
 
443
 
444
//wire    dcm_locked = 1'b1;
445
//wire      reset_n;
446
 
447
//reg     dcm_clk;
448
//always @(posedge clk_50M_in)
449
//  if (~reset_n) dcm_clk <= 1'b0;
450
//  else          dcm_clk <= ~dcm_clk;
451
 
452
 
453
// Clock buffers
454
//------------------------
455
BUFG  buf_sys_clock  (.O(clk_sys), .I(dcm_clk));
456
 
457
 
458
//=============================================================================
459
// 3)  RESET GENERATION & FPGA STARTUP
460
//=============================================================================
461
 
462
// Reset input buffer
463
IBUF   ibuf_reset_n   (.O(reset_pin), .I(BTN3));
464
wire reset_pin_n = ~reset_pin;
465
 
466
// Release the reset only, if the DCM is locked
467
assign  reset_n = reset_pin_n & dcm_locked;
468
 
469
//Include the startup device   
470
wire  gsr_tb;
471
wire  gts_tb;
472
STARTUP_SPARTAN3 xstartup (.CLK(clk_sys), .GSR(gsr_tb), .GTS(gts_tb));
473
 
474
 
475
//=============================================================================
476
// 4)  OPENMSP430
477
//=============================================================================
478
 
479
openMSP430 openMSP430_0 (
480
 
481
// OUTPUTs
482
    .aclk_en      (aclk_en),      // ACLK enable
483
    .dbg_freeze   (dbg_freeze),   // Freeze peripherals
484
    .dbg_uart_txd (dbg_uart_txd), // Debug interface: UART TXD
485
    .irq_acc      (irq_acc),      // Interrupt request accepted (one-hot signal)
486
    .mclk         (mclk),         // Main system clock
487
    .per_addr     (per_addr),     // Peripheral address
488
    .per_din      (per_din),      // Peripheral data input
489
    .per_wen      (per_wen),      // Peripheral write enable (high active)
490
    .per_en       (per_en),       // Peripheral enable (high active)
491
    .puc          (puc),          // Main system reset
492
    .ram_addr     (ram_addr),     // RAM address
493
    .ram_cen      (ram_cen),      // RAM chip enable (low active)
494
    .ram_din      (ram_din),      // RAM data input
495
    .ram_wen      (ram_wen),      // RAM write enable (low active)
496
    .rom_addr     (rom_addr),     // ROM address
497
    .rom_cen      (rom_cen),      // ROM chip enable (low active)
498
    .rom_din_dbg  (rom_din_dbg),  // ROM data input --FOR DEBUG INTERFACE--
499
    .rom_wen_dbg  (rom_wen_dbg),  // ROM write enable (low active) --FOR DBG IF--
500
    .smclk_en     (smclk_en),     // SMCLK enable
501
 
502
// INPUTs
503
    .dbg_uart_rxd (dbg_uart_rxd), // Debug interface: UART RXD
504
    .dco_clk      (clk_sys),      // Fast oscillator (fast clock)
505
    .irq          (irq_bus),      // Maskable interrupts
506
    .lfxt_clk     (1'b0),         // Low frequency oscillator (typ 32kHz)
507
    .nmi          (nmi),          // Non-maskable interrupt (asynchronous)
508
    .per_dout     (per_dout),     // Peripheral data output
509
    .ram_dout     (ram_dout),     // RAM data output
510
    .reset_n      (reset_n),      // Reset Pin (low active)
511
    .rom_dout     (rom_dout)      // ROM data output
512
);
513
 
514
 
515
//=============================================================================
516
// 5)  OPENMSP430 PERIPHERALS
517
//=============================================================================
518
 
519
//
520
// Digital I/O
521
//-------------------------------
522
 
523
gpio #(.P1_EN(1),
524
       .P2_EN(1),
525
       .P3_EN(1),
526
       .P4_EN(0),
527
       .P5_EN(0),
528
       .P6_EN(0)) gpio_0 (
529
 
530
// OUTPUTs
531
    .irq_port1    (irq_port1),     // Port 1 interrupt
532
    .irq_port2    (irq_port2),     // Port 2 interrupt
533
    .p1_dout      (p1_dout),       // Port 1 data output
534
    .p1_dout_en   (p1_dout_en),    // Port 1 data output enable
535
    .p1_sel       (p1_sel),        // Port 1 function select
536
    .p2_dout      (p2_dout),       // Port 2 data output
537
    .p2_dout_en   (p2_dout_en),    // Port 2 data output enable
538
    .p2_sel       (p2_sel),        // Port 2 function select
539
    .p3_dout      (p3_dout),       // Port 3 data output
540
    .p3_dout_en   (p3_dout_en),    // Port 3 data output enable
541
    .p3_sel       (p3_sel),        // Port 3 function select
542
    .p4_dout      (),              // Port 4 data output
543
    .p4_dout_en   (),              // Port 4 data output enable
544
    .p4_sel       (),              // Port 4 function select
545
    .p5_dout      (),              // Port 5 data output
546
    .p5_dout_en   (),              // Port 5 data output enable
547
    .p5_sel       (),              // Port 5 function select
548
    .p6_dout      (),              // Port 6 data output
549
    .p6_dout_en   (),              // Port 6 data output enable
550
    .p6_sel       (),              // Port 6 function select
551
    .per_dout     (per_dout_dio),  // Peripheral data output
552
 
553
// INPUTs
554
    .mclk         (mclk),          // Main system clock
555
    .p1_din       (p1_din),        // Port 1 data input
556
    .p2_din       (p2_din),        // Port 2 data input
557
    .p3_din       (p3_din),        // Port 3 data input
558
    .p4_din       (8'h00),         // Port 4 data input
559
    .p5_din       (8'h00),         // Port 5 data input
560
    .p6_din       (8'h00),         // Port 6 data input
561
    .per_addr     (per_addr),      // Peripheral address
562
    .per_din      (per_din),       // Peripheral data input
563
    .per_en       (per_en),        // Peripheral enable (high active)
564
    .per_wen      (per_wen),       // Peripheral write enable (high active)
565
    .puc          (puc)            // Main system reset
566
);
567
 
568
//
569
// Timer A
570
//----------------------------------------------
571
 
572
timerA timerA_0 (
573
 
574
// OUTPUTs
575
    .irq_ta0      (irq_ta0),       // Timer A interrupt: TACCR0
576
    .irq_ta1      (irq_ta1),       // Timer A interrupt: TAIV, TACCR1, TACCR2
577
    .per_dout     (per_dout_tA),   // Peripheral data output
578
    .ta_out0      (ta_out0),       // Timer A output 0
579
    .ta_out0_en   (ta_out0_en),    // Timer A output 0 enable
580
    .ta_out1      (ta_out1),       // Timer A output 1
581
    .ta_out1_en   (ta_out1_en),    // Timer A output 1 enable
582
    .ta_out2      (ta_out2),       // Timer A output 2
583
    .ta_out2_en   (ta_out2_en),    // Timer A output 2 enable
584
 
585
// INPUTs
586
    .aclk_en      (aclk_en),       // ACLK enable (from CPU)
587
    .dbg_freeze   (dbg_freeze),    // Freeze Timer A counter
588
    .inclk        (inclk),         // INCLK external timer clock (SLOW)
589
    .irq_ta0_acc  (irq_acc[9]),    // Interrupt request TACCR0 accepted
590
    .mclk         (mclk),          // Main system clock
591
    .per_addr     (per_addr),      // Peripheral address
592
    .per_din      (per_din),       // Peripheral data input
593
    .per_en       (per_en),        // Peripheral enable (high active)
594
    .per_wen      (per_wen),       // Peripheral write enable (high active)
595
    .puc          (puc),           // Main system reset
596
    .smclk_en     (smclk_en),      // SMCLK enable (from CPU)
597
    .ta_cci0a     (ta_cci0a),      // Timer A capture 0 input A
598
    .ta_cci0b     (ta_cci0b),      // Timer A capture 0 input B
599
    .ta_cci1a     (ta_cci1a),      // Timer A capture 1 input A
600
    .ta_cci1b     (1'b0),          // Timer A capture 1 input B
601
    .ta_cci2a     (ta_cci2a),      // Timer A capture 2 input A
602
    .ta_cci2b     (1'b0),          // Timer A capture 2 input B
603
    .taclk        (taclk)          // TACLK external timer clock (SLOW)
604
);
605
 
606
 
607
//
608
// Four-Digit, Seven-Segment LED Display driver
609
//----------------------------------------------
610
 
611
driver_7segment driver_7segment_0 (
612
 
613
// OUTPUTs
614
    .per_dout     (per_dout_7seg), // Peripheral data output
615
    .seg_a        (seg_a_),        // Segment A control
616
    .seg_b        (seg_b_),        // Segment B control
617
    .seg_c        (seg_c_),        // Segment C control
618
    .seg_d        (seg_d_),        // Segment D control
619
    .seg_e        (seg_e_),        // Segment E control
620
    .seg_f        (seg_f_),        // Segment F control
621
    .seg_g        (seg_g_),        // Segment G control
622
    .seg_dp       (seg_dp_),       // Segment DP control
623
    .seg_an0      (seg_an0_),      // Anode 0 control
624
    .seg_an1      (seg_an1_),      // Anode 1 control
625
    .seg_an2      (seg_an2_),      // Anode 2 control
626
    .seg_an3      (seg_an3_),      // Anode 3 control
627
 
628
// INPUTs
629
    .mclk         (mclk),          // Main system clock
630
    .per_addr     (per_addr),      // Peripheral address
631
    .per_din      (per_din),       // Peripheral data input
632
    .per_en       (per_en),        // Peripheral enable (high active)
633
    .per_wen      (per_wen),       // Peripheral write enable (high active)
634
    .puc          (puc)            // Main system reset
635
);
636
 
637
 
638
//
639
// Combine peripheral data buses
640
//-------------------------------
641
 
642
assign per_dout = per_dout_dio  |
643
                  per_dout_tA   |
644
                  per_dout_7seg;
645
 
646
//
647
// Assign interrupts
648
//-------------------------------
649
 
650
assign nmi        =  1'b0;
651
assign irq_bus    = {1'b0,         // Vector 13  (0xFFFA)
652
                     1'b0,         // Vector 12  (0xFFF8)
653
                     1'b0,         // Vector 11  (0xFFF6)
654
                     1'b0,         // Vector 10  (0xFFF4) - Watchdog -
655
                     irq_ta0,      // Vector  9  (0xFFF2)
656
                     irq_ta1,      // Vector  8  (0xFFF0)
657
                     1'b0,         // Vector  7  (0xFFEE)
658
                     1'b0,         // Vector  6  (0xFFEC)
659
                     1'b0,         // Vector  5  (0xFFEA)
660
                     1'b0,         // Vector  4  (0xFFE8)
661
                     irq_port2,    // Vector  3  (0xFFE6)
662
                     irq_port1,    // Vector  2  (0xFFE4)
663
                     1'b0,         // Vector  1  (0xFFE2)
664
                     1'b0};        // Vector  0  (0xFFE0)
665
 
666
//
667
// GPIO Function selection
668
//--------------------------
669
 
670
// P1.0/TACLK      I/O pin / Timer_A, clock signal TACLK input
671
// P1.1/TA0        I/O pin / Timer_A, capture: CCI0A input, compare: Out0 output
672
// P1.2/TA1        I/O pin / Timer_A, capture: CCI1A input, compare: Out1 output
673
// P1.3/TA2        I/O pin / Timer_A, capture: CCI2A input, compare: Out2 output
674
// P1.4/SMCLK      I/O pin / SMCLK signal output
675
// P1.5/TA0        I/O pin / Timer_A, compare: Out0 output
676
// P1.6/TA1        I/O pin / Timer_A, compare: Out1 output
677
// P1.7/TA2        I/O pin / Timer_A, compare: Out2 output
678
wire [7:0] p1_io_mux_b_unconnected;
679
wire [7:0] p1_io_dout;
680
wire [7:0] p1_io_dout_en;
681
wire [7:0] p1_io_din;
682
 
683
io_mux #8 io_mux_p1 (
684
                     .a_din      (p1_din),
685
                     .a_dout     (p1_dout),
686
                     .a_dout_en  (p1_dout_en),
687
 
688
                     .b_din      ({p1_io_mux_b_unconnected[7],
689
                                   p1_io_mux_b_unconnected[6],
690
                                   p1_io_mux_b_unconnected[5],
691
                                   p1_io_mux_b_unconnected[4],
692
                                   ta_cci2a,
693
                                   ta_cci1a,
694
                                   ta_cci0a,
695
                                   taclk
696
                                  }),
697
                     .b_dout     ({ta_out2,
698
                                   ta_out1,
699
                                   ta_out0,
700
                                   (smclk_en & mclk),
701
                                   ta_out2,
702
                                   ta_out1,
703
                                   ta_out0,
704
                                   1'b0
705
                                  }),
706
                     .b_dout_en  ({ta_out2_en,
707
                                   ta_out1_en,
708
                                   ta_out0_en,
709
                                   1'b1,
710
                                   ta_out2_en,
711
                                   ta_out1_en,
712
                                   ta_out0_en,
713
                                   1'b0
714
                                  }),
715
 
716
                     .io_din     (p1_io_din),
717
                     .io_dout    (p1_io_dout),
718
                     .io_dout_en (p1_io_dout_en),
719
 
720
                     .sel        (p1_sel)
721
);
722
 
723
 
724
 
725
// P2.0/ACLK       I/O pin / ACLK output
726
// P2.1/INCLK      I/O pin / Timer_A, clock signal at INCLK
727
// P2.2/TA0        I/O pin / Timer_A, capture: CCI0B input
728
// P2.3/TA1        I/O pin / Timer_A, compare: Out1 output
729
// P2.4/TA2        I/O pin / Timer_A, compare: Out2 output
730
wire [7:0] p2_io_mux_b_unconnected;
731
wire [7:0] p2_io_dout;
732
wire [7:0] p2_io_dout_en;
733
wire [7:0] p2_io_din;
734
 
735
io_mux #8 io_mux_p2 (
736
                     .a_din      (p2_din),
737
                     .a_dout     (p2_dout),
738
                     .a_dout_en  (p2_dout_en),
739
 
740
                     .b_din      ({p2_io_mux_b_unconnected[7],
741
                                   p2_io_mux_b_unconnected[6],
742
                                   p2_io_mux_b_unconnected[5],
743
                                   p2_io_mux_b_unconnected[4],
744
                                   p2_io_mux_b_unconnected[3],
745
                                   ta_cci0b,
746
                                   inclk,
747
                                   p2_io_mux_b_unconnected[0]
748
                                  }),
749
                     .b_dout     ({1'b0,
750
                                   1'b0,
751
                                   1'b0,
752
                                   ta_out2,
753
                                   ta_out1,
754
                                   1'b0,
755
                                   1'b0,
756
                                   (aclk_en & mclk)
757
                                  }),
758
                     .b_dout_en  ({1'b0,
759
                                   1'b0,
760
                                   1'b0,
761
                                   ta_out2_en,
762
                                   ta_out1_en,
763
                                   1'b0,
764
                                   1'b0,
765
                                   1'b1
766
                                  }),
767
 
768
                     .io_din     (p2_io_din),
769
                     .io_dout    (p2_io_dout),
770
                     .io_dout_en (p2_io_dout_en),
771
 
772
                     .sel        (p2_sel)
773
);
774
 
775
 
776
//=============================================================================
777
// 6)  RAM / ROM
778
//=============================================================================
779
 
780
// RAM
781
ram_8x512_hi ram_8x512_hi_0 (
782
    .addr         (ram_addr),
783
    .clk          (clk_sys),
784
    .din          (ram_din[15:8]),
785
    .dout         (ram_dout[15:8]),
786
    .en           (ram_cen),
787
    .we           (ram_wen[1])
788
);
789
ram_8x512_lo ram_8x512_lo_0 (
790
    .addr         (ram_addr),
791
    .clk          (clk_sys),
792
    .din          (ram_din[7:0]),
793
    .dout         (ram_dout[7:0]),
794
    .en           (ram_cen),
795
    .we           (ram_wen[0])
796
);
797
 
798
 
799
// ROM
800
rom_8x2k_hi rom_8x2k_hi_0 (
801
    .addr         (rom_addr),
802
    .clk          (clk_sys),
803
    .din          (rom_din_dbg[15:8]),
804
    .dout         (rom_dout[15:8]),
805
    .en           (rom_cen),
806
    .we           (rom_wen_dbg[1])
807
);
808
 
809
rom_8x2k_lo rom_8x2k_lo_0 (
810
    .addr         (rom_addr),
811
    .clk          (clk_sys),
812
    .din          (rom_din_dbg[7:0]),
813
    .dout         (rom_dout[7:0]),
814
    .en           (rom_cen),
815
    .we           (rom_wen_dbg[0])
816
);
817
 
818
 
819
 
820
//=============================================================================
821
// 7)  I/O CELLS
822
//=============================================================================
823
 
824
 
825
// Slide Switches (Port 1 inputs)
826
//--------------------------------
827
IBUF  SW7_PIN        (.O(p3_din[7]),                   .I(SW7));
828
IBUF  SW6_PIN        (.O(p3_din[6]),                   .I(SW6));
829
IBUF  SW5_PIN        (.O(p3_din[5]),                   .I(SW5));
830
IBUF  SW4_PIN        (.O(p3_din[4]),                   .I(SW4));
831
IBUF  SW3_PIN        (.O(p3_din[3]),                   .I(SW3));
832
IBUF  SW2_PIN        (.O(p3_din[2]),                   .I(SW2));
833
IBUF  SW1_PIN        (.O(p3_din[1]),                   .I(SW1));
834
IBUF  SW0_PIN        (.O(p3_din[0]),                   .I(SW0));
835
 
836
// LEDs (Port 1 outputs)
837
//-----------------------
838
OBUF  LED7_PIN       (.I(p3_dout[7] & p3_dout_en[7]),  .O(LED7));
839
OBUF  LED6_PIN       (.I(p3_dout[6] & p3_dout_en[6]),  .O(LED6));
840
OBUF  LED5_PIN       (.I(p3_dout[5] & p3_dout_en[5]),  .O(LED5));
841
OBUF  LED4_PIN       (.I(p3_dout[4] & p3_dout_en[4]),  .O(LED4));
842
OBUF  LED3_PIN       (.I(p3_dout[3] & p3_dout_en[3]),  .O(LED3));
843
OBUF  LED2_PIN       (.I(p3_dout[2] & p3_dout_en[2]),  .O(LED2));
844
OBUF  LED1_PIN       (.I(p3_dout[1] & p3_dout_en[1]),  .O(LED1));
845
OBUF  LED0_PIN       (.I(p3_dout[0] & p3_dout_en[0]),  .O(LED0));
846
 
847
// Push Button Switches
848
//----------------------
849
IBUF  BTN2_PIN       (.O(),                            .I(BTN2));
850
IBUF  BTN1_PIN       (.O(),                            .I(BTN1));
851
IBUF  BTN0_PIN       (.O(),                            .I(BTN0));
852
 
853
// Four-Sigit, Seven-Segment LED Display
854
//---------------------------------------
855
OBUF  SEG_A_PIN      (.I(seg_a_),                      .O(SEG_A));
856
OBUF  SEG_B_PIN      (.I(seg_b_),                      .O(SEG_B));
857
OBUF  SEG_C_PIN      (.I(seg_c_),                      .O(SEG_C));
858
OBUF  SEG_D_PIN      (.I(seg_d_),                      .O(SEG_D));
859
OBUF  SEG_E_PIN      (.I(seg_e_),                      .O(SEG_E));
860
OBUF  SEG_F_PIN      (.I(seg_f_),                      .O(SEG_F));
861
OBUF  SEG_G_PIN      (.I(seg_g_),                      .O(SEG_G));
862
OBUF  SEG_DP_PIN     (.I(seg_dp_),                     .O(SEG_DP));
863
OBUF  SEG_AN0_PIN    (.I(seg_an0_),                    .O(SEG_AN0));
864
OBUF  SEG_AN1_PIN    (.I(seg_an1_),                    .O(SEG_AN1));
865
OBUF  SEG_AN2_PIN    (.I(seg_an2_),                    .O(SEG_AN2));
866
OBUF  SEG_AN3_PIN    (.I(seg_an3_),                    .O(SEG_AN3));
867
 
868
// RS-232 Port
869
//----------------------
870
// P1.1 (TX) and P2.2 (RX)
871
assign p1_io_din      = 8'h00;
872
assign p2_io_din[7:3] = 5'h00;
873
assign p2_io_din[1:0] = 2'h0;
874
 
875
// Mux the RS-232 port between IO port and the debug interface.
876
// The mux is controlled with the SW0 switch
877
wire   uart_txd_out = p3_din[0] ? dbg_uart_txd : p1_io_dout[1];
878
wire   uart_rxd_in;
879
assign p2_io_din[2] = p3_din[0] ? 1'b1         : uart_rxd_in;
880
assign dbg_uart_rxd = p3_din[0] ? uart_rxd_in  : 1'b1;
881
 
882
IBUF  UART_RXD_PIN   (.O(uart_rxd_in),                 .I(UART_RXD));
883
OBUF  UART_TXD_PIN   (.I(uart_txd_out),                .O(UART_TXD));
884
 
885
IBUF  UART_RXD_A_PIN (.O(),                            .I(UART_RXD_A));
886
OBUF  UART_TXD_A_PIN (.I(1'b0),                        .O(UART_TXD_A));
887
 
888
 
889
// PS/2 Mouse/Keyboard Port
890
//--------------------------
891
IOBUF PS2_D_PIN      (.O(), .I(1'b0), .T(1'b1),        .IO(PS2_D));
892
OBUF  PS2_C_PIN      (.I(1'b0),                        .O(PS2_C));
893
 
894
// Fast, Asynchronous SRAM
895
//--------------------------
896
OBUF  SRAM_A17_PIN   (.I(1'b0),                        .O(SRAM_A17));
897
OBUF  SRAM_A16_PIN   (.I(1'b0),                        .O(SRAM_A16));
898
OBUF  SRAM_A15_PIN   (.I(1'b0),                        .O(SRAM_A15));
899
OBUF  SRAM_A14_PIN   (.I(1'b0),                        .O(SRAM_A14));
900
OBUF  SRAM_A13_PIN   (.I(1'b0),                        .O(SRAM_A13));
901
OBUF  SRAM_A12_PIN   (.I(1'b0),                        .O(SRAM_A12));
902
OBUF  SRAM_A11_PIN   (.I(1'b0),                        .O(SRAM_A11));
903
OBUF  SRAM_A10_PIN   (.I(1'b0),                        .O(SRAM_A10));
904
OBUF  SRAM_A9_PIN    (.I(1'b0),                        .O(SRAM_A9));
905
OBUF  SRAM_A8_PIN    (.I(1'b0),                        .O(SRAM_A8));
906
OBUF  SRAM_A7_PIN    (.I(1'b0),                        .O(SRAM_A7));
907
OBUF  SRAM_A6_PIN    (.I(1'b0),                        .O(SRAM_A6));
908
OBUF  SRAM_A5_PIN    (.I(1'b0),                        .O(SRAM_A5));
909
OBUF  SRAM_A4_PIN    (.I(1'b0),                        .O(SRAM_A4));
910
OBUF  SRAM_A3_PIN    (.I(1'b0),                        .O(SRAM_A3));
911
OBUF  SRAM_A2_PIN    (.I(1'b0),                        .O(SRAM_A2));
912
OBUF  SRAM_A1_PIN    (.I(1'b0),                        .O(SRAM_A1));
913
OBUF  SRAM_A0_PIN    (.I(1'b0),                        .O(SRAM_A0));
914
OBUF  SRAM_OE_PIN    (.I(1'b1),                        .O(SRAM_OE));
915
OBUF  SRAM_WE_PIN    (.I(1'b1),                        .O(SRAM_WE));
916
IOBUF SRAM0_IO15_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO15));
917
IOBUF SRAM0_IO14_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO14));
918
IOBUF SRAM0_IO13_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO13));
919
IOBUF SRAM0_IO12_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO12));
920
IOBUF SRAM0_IO11_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO11));
921
IOBUF SRAM0_IO10_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO10));
922
IOBUF SRAM0_IO9_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO9));
923
IOBUF SRAM0_IO8_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO8));
924
IOBUF SRAM0_IO7_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO7));
925
IOBUF SRAM0_IO6_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO6));
926
IOBUF SRAM0_IO5_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO5));
927
IOBUF SRAM0_IO4_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO4));
928
IOBUF SRAM0_IO3_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO3));
929
IOBUF SRAM0_IO2_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO2));
930
IOBUF SRAM0_IO1_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO1));
931
IOBUF SRAM0_IO0_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM0_IO0));
932
OBUF  SRAM0_CE1_PIN  (.I(1'b1),                        .O(SRAM0_CE1));
933
OBUF  SRAM0_UB1_PIN  (.I(1'b1),                        .O(SRAM0_UB1));
934
OBUF  SRAM0_LB1_PIN  (.I(1'b1),                        .O(SRAM0_LB1));
935
IOBUF SRAM1_IO15_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO15));
936
IOBUF SRAM1_IO14_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO14));
937
IOBUF SRAM1_IO13_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO13));
938
IOBUF SRAM1_IO12_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO12));
939
IOBUF SRAM1_IO11_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO11));
940
IOBUF SRAM1_IO10_PIN (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO10));
941
IOBUF SRAM1_IO9_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO9));
942
IOBUF SRAM1_IO8_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO8));
943
IOBUF SRAM1_IO7_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO7));
944
IOBUF SRAM1_IO6_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO6));
945
IOBUF SRAM1_IO5_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO5));
946
IOBUF SRAM1_IO4_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO4));
947
IOBUF SRAM1_IO3_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO3));
948
IOBUF SRAM1_IO2_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO2));
949
IOBUF SRAM1_IO1_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO1));
950
IOBUF SRAM1_IO0_PIN  (.O(), .I(1'b0), .T(1'b1),        .IO(SRAM1_IO0));
951
OBUF  SRAM1_CE2_PIN  (.I(1'b1),                        .O(SRAM1_CE2));
952
OBUF  SRAM1_UB2_PIN  (.I(1'b1),                        .O(SRAM1_UB2));
953
OBUF  SRAM1_LB2_PIN  (.I(1'b1),                        .O(SRAM1_LB2));
954
 
955
// VGA Port
956
//---------------------------------------
957
OBUF  VGA_R_PIN      (.I(1'b0),                        .O(VGA_R));
958
OBUF  VGA_G_PIN      (.I(1'b0),                        .O(VGA_G));
959
OBUF  VGA_B_PIN      (.I(1'b0),                        .O(VGA_B));
960
OBUF  VGA_HS_PIN     (.I(1'b0),                        .O(VGA_HS));
961
OBUF  VGA_VS_PIN     (.I(1'b0),                        .O(VGA_VS));
962
 
963
 
964
endmodule // openMSP430_fpga
965
 

powered by: WebSVN 2.1.0

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