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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_avnet_lx9microbard/] [rtl/] [verilog/] [omsp_system_0.v] - Blame information for rev 157

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

Line No. Rev Author Line
1 157 olivier.gi
//----------------------------------------------------------------------------
2
// Copyright (C) 2011 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 Avnet LX9 Microboard
29
//
30
// *Author(s):
31
//              - Ricardo Ribalda,    ricardo.ribalda@gmail.com
32
//              - Olivier Girard,    olgirard@gmail.com
33
//
34
//----------------------------------------------------------------------------
35
`include "openmsp430/openMSP430_defines.v"
36
 
37
module omsp_system_0 (
38
 
39
// Clock & Reset
40
    dco_clk,                               // Fast oscillator (fast clock)
41
    reset_n,                               // Reset Pin (low active, asynchronous and non-glitchy)
42
 
43
// Serial Debug Interface (UART)
44
    dbg_uart_rxd,                          // Debug interface: UART RXD (asynchronous)
45
    dbg_uart_txd,                          // Debug interface: UART TXD
46
 
47
// Serial Debug Interface (I2C)
48
    dbg_i2c_addr,                          // Debug interface: I2C Address
49
    dbg_i2c_broadcast,                     // Debug interface: I2C Broadcast Address (for multicore systems)
50
    dbg_i2c_scl,                           // Debug interface: I2C SCL
51
    dbg_i2c_sda_in,                        // Debug interface: I2C SDA IN
52
    dbg_i2c_sda_out,                       // Debug interface: I2C SDA OUT
53
 
54
// Data Memory
55
    dmem_addr,                             // Data Memory address
56
    dmem_cen,                              // Data Memory chip enable (low active)
57
    dmem_din,                              // Data Memory data input
58
    dmem_wen,                              // Data Memory write enable (low active)
59
    dmem_dout,                             // Data Memory data output
60
 
61
// Program Memory
62
    pmem_addr,                             // Program Memory address
63
    pmem_cen,                              // Program Memory chip enable (low active)
64
    pmem_din,                              // Program Memory data input (optional)
65
    pmem_wen,                              // Program Memory write enable (low active) (optional)
66
    pmem_dout,                             // Program Memory data output
67
 
68
// UART
69
    uart_rxd,                              // UART Data Receive (RXD)
70
    uart_txd,                              // UART Data Transmit (TXD)
71
 
72
// Switches & LEDs
73
    switch,                                // Input switches
74
    led                                    // LEDs
75
);
76
 
77
// Clock & Reset
78
input                dco_clk;              // Fast oscillator (fast clock)
79
input                reset_n;              // Reset Pin (low active, asynchronous and non-glitchy)
80
 
81
// Serial Debug Interface (UART)
82
input                dbg_uart_rxd;         // Debug interface: UART RXD (asynchronous)
83
output               dbg_uart_txd;         // Debug interface: UART TXD
84
 
85
// Serial Debug Interface (I2C)
86
input          [6:0] dbg_i2c_addr;         // Debug interface: I2C Address
87
input          [6:0] dbg_i2c_broadcast;    // Debug interface: I2C Broadcast Address (for multicore systems)
88
input                dbg_i2c_scl;          // Debug interface: I2C SCL
89
input                dbg_i2c_sda_in;       // Debug interface: I2C SDA IN
90
output               dbg_i2c_sda_out;      // Debug interface: I2C SDA OUT
91
 
92
// Data Memory
93
input         [15:0] dmem_dout;            // Data Memory data output
94
output [`DMEM_MSB:0] dmem_addr;            // Data Memory address
95
output               dmem_cen;             // Data Memory chip enable (low active)
96
output        [15:0] dmem_din;             // Data Memory data input
97
output         [1:0] dmem_wen;             // Data Memory write enable (low active)
98
 
99
// Program Memory
100
input         [15:0] pmem_dout;            // Program Memory data output
101
output [`PMEM_MSB:0] pmem_addr;            // Program Memory address
102
output               pmem_cen;             // Program Memory chip enable (low active)
103
output        [15:0] pmem_din;             // Program Memory data input (optional)
104
output         [1:0] pmem_wen;             // Program Memory write enable (low active) (optional)
105
 
106
// UART
107
input                uart_rxd;             // UART Data Receive (RXD)
108
output               uart_txd;             // UART Data Transmit (TXD)
109
 
110
// Switches & LEDs
111
input          [3:0] switch;               // Input switches
112
output         [3:0] led;                  // LEDs
113
 
114
 
115
//=============================================================================
116
// 1)  INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
117
//=============================================================================
118
 
119
// Clock & Reset
120
wire               mclk;
121
wire               aclk_en;
122
wire               smclk_en;
123
wire               puc_rst;
124
 
125
// Debug interface
126
wire               dbg_freeze;
127
wire               dbg_uart_txd;
128
wire               dbg_uart_rxd;
129
 
130
// Data memory
131
wire [`DMEM_MSB:0] dmem_addr;
132
wire               dmem_cen;
133
wire        [15:0] dmem_din;
134
wire         [1:0] dmem_wen;
135
wire        [15:0] dmem_dout;
136
 
137
// Program memory
138
wire [`PMEM_MSB:0] pmem_addr;
139
wire               pmem_cen;
140
wire        [15:0] pmem_din;
141
wire         [1:0] pmem_wen;
142
wire        [15:0] pmem_dout;
143
 
144
// Peripheral bus
145
wire        [13:0] per_addr;
146
wire        [15:0] per_din;
147
wire         [1:0] per_we;
148
wire               per_en;
149
wire        [15:0] per_dout;
150
 
151
// Interrupts
152
wire        [13:0] irq_acc;
153
wire        [13:0] irq_bus;
154
wire               nmi;
155
 
156
// GPIO
157
wire         [7:0] p1_din;
158
wire         [7:0] p1_dout;
159
wire         [7:0] p1_dout_en;
160
wire         [7:0] p1_sel;
161
wire         [7:0] p2_din;
162
wire         [7:0] p2_dout;
163
wire         [7:0] p2_dout_en;
164
wire         [7:0] p2_sel;
165
wire        [15:0] per_dout_gpio;
166
 
167
// Timer A
168
wire        [15:0] per_dout_tA;
169
 
170
// Hardware UART
171
wire        [15:0] per_dout_uart;
172
 
173
 
174
//=============================================================================
175
// 2)  OPENMSP430 CORE
176
//=============================================================================
177
 
178
openMSP430 #(.INST_NR (0),
179
             .TOTAL_NR(0)) openMSP430_0 (
180
 
181
// OUTPUTs
182
    .aclk              (),                   // ASIC ONLY: ACLK
183
    .aclk_en           (aclk_en),            // FPGA ONLY: ACLK enable
184
    .dbg_freeze        (dbg_freeze),         // Freeze peripherals
185
    .dbg_i2c_sda_out   (dbg_i2c_sda_out),    // Debug interface: I2C SDA OUT
186
    .dbg_uart_txd      (dbg_uart_txd),       // Debug interface: UART TXD
187
    .dco_enable        (),                   // ASIC ONLY: Fast oscillator enable
188
    .dco_wkup          (),                   // ASIC ONLY: Fast oscillator wake-up (asynchronous)
189
    .dmem_addr         (dmem_addr),          // Data Memory address
190
    .dmem_cen          (dmem_cen),           // Data Memory chip enable (low active)
191
    .dmem_din          (dmem_din),           // Data Memory data input
192
    .dmem_wen          (dmem_wen),           // Data Memory write enable (low active)
193
    .irq_acc           (irq_acc),            // Interrupt request accepted (one-hot signal)
194
    .lfxt_enable       (),                   // ASIC ONLY: Low frequency oscillator enable
195
    .lfxt_wkup         (),                   // ASIC ONLY: Low frequency oscillator wake-up (asynchronous)
196
    .mclk              (mclk),               // Main system clock
197
    .per_addr          (per_addr),           // Peripheral address
198
    .per_din           (per_din),            // Peripheral data input
199
    .per_we            (per_we),             // Peripheral write enable (high active)
200
    .per_en            (per_en),             // Peripheral enable (high active)
201
    .pmem_addr         (pmem_addr),          // Program Memory address
202
    .pmem_cen          (pmem_cen),           // Program Memory chip enable (low active)
203
    .pmem_din          (pmem_din),           // Program Memory data input (optional)
204
    .pmem_wen          (pmem_wen),           // Program Memory write enable (low active) (optional)
205
    .puc_rst           (puc_rst),            // Main system reset
206
    .smclk             (),                   // ASIC ONLY: SMCLK
207
    .smclk_en          (smclk_en),           // FPGA ONLY: SMCLK enable
208
 
209
// INPUTs
210
    .cpu_en            (1'b1),               // Enable CPU code execution (asynchronous and non-glitchy)
211
    .dbg_en            (1'b1),               // Debug interface enable (asynchronous and non-glitchy)
212
    .dbg_i2c_addr      (dbg_i2c_addr),       // Debug interface: I2C Address
213
    .dbg_i2c_broadcast (dbg_i2c_broadcast),  // Debug interface: I2C Broadcast Address (for multicore systems)
214
    .dbg_i2c_scl       (dbg_i2c_scl),        // Debug interface: I2C SCL
215
    .dbg_i2c_sda_in    (dbg_i2c_sda_in),     // Debug interface: I2C SDA IN
216
    .dbg_uart_rxd      (dbg_uart_rxd),       // Debug interface: UART RXD (asynchronous)
217
    .dco_clk           (dco_clk),            // Fast oscillator (fast clock)
218
    .dmem_dout         (dmem_dout),          // Data Memory data output
219
    .irq               (irq_bus),            // Maskable interrupts
220
    .lfxt_clk          (1'b0),               // Low frequency oscillator (typ 32kHz)
221
    .nmi               (nmi),                // Non-maskable interrupt (asynchronous)
222
    .per_dout          (per_dout),           // Peripheral data output
223
    .pmem_dout         (pmem_dout),          // Program Memory data output
224
    .reset_n           (reset_n),            // Reset Pin (low active, asynchronous and non-glitchy)
225
    .scan_enable       (1'b0),               // ASIC ONLY: Scan enable (active during scan shifting)
226
    .scan_mode         (1'b0),               // ASIC ONLY: Scan mode
227
    .wkup              (1'b0)                // ASIC ONLY: System Wake-up (asynchronous and non-glitchy)
228
);
229
 
230
 
231
//=============================================================================
232
// 3)  OPENMSP430 PERIPHERALS
233
//=============================================================================
234
 
235
//
236
// Digital I/O
237
//-------------------------------
238
 
239
omsp_gpio #(.P1_EN(1),
240
            .P2_EN(1),
241
            .P3_EN(0),
242
            .P4_EN(0),
243
            .P5_EN(0),
244
            .P6_EN(0)) gpio_0 (
245
 
246
// OUTPUTs
247
    .irq_port1    (irq_port1),             // Port 1 interrupt
248
    .irq_port2    (irq_port2),             // Port 2 interrupt
249
    .p1_dout      (p1_dout),               // Port 1 data output
250
    .p1_dout_en   (p1_dout_en),            // Port 1 data output enable
251
    .p1_sel       (p1_sel),                // Port 1 function select
252
    .p2_dout      (p2_dout),               // Port 2 data output
253
    .p2_dout_en   (p2_dout_en),            // Port 2 data output enable
254
    .p2_sel       (p2_sel),                // Port 2 function select
255
    .p3_dout      (),                      // Port 3 data output
256
    .p3_dout_en   (),                      // Port 3 data output enable
257
    .p3_sel       (),                      // Port 3 function select
258
    .p4_dout      (),                      // Port 4 data output
259
    .p4_dout_en   (),                      // Port 4 data output enable
260
    .p4_sel       (),                      // Port 4 function select
261
    .p5_dout      (),                      // Port 5 data output
262
    .p5_dout_en   (),                      // Port 5 data output enable
263
    .p5_sel       (),                      // Port 5 function select
264
    .p6_dout      (),                      // Port 6 data output
265
    .p6_dout_en   (),                      // Port 6 data output enable
266
    .p6_sel       (),                      // Port 6 function select
267
    .per_dout     (per_dout_gpio),         // Peripheral data output
268
 
269
// INPUTs
270
    .mclk         (mclk),                  // Main system clock
271
    .p1_din       (p1_din),                // Port 1 data input
272
    .p2_din       (p2_din),                // Port 2 data input
273
    .p3_din       (8'h00),                 // Port 3 data input
274
    .p4_din       (8'h00),                 // Port 4 data input
275
    .p5_din       (8'h00),                 // Port 5 data input
276
    .p6_din       (8'h00),                 // Port 6 data input
277
    .per_addr     (per_addr),              // Peripheral address
278
    .per_din      (per_din),               // Peripheral data input
279
    .per_en       (per_en),                // Peripheral enable (high active)
280
    .per_we       (per_we),                // Peripheral write enable (high active)
281
    .puc_rst      (puc_rst)                // Main system reset
282
);
283
 
284
// Assign LEDs
285
assign  led         = p2_dout[3:0] & p2_dout_en[3:0];
286
 
287
// Assign Switches
288
assign  p1_din[7:4] = 4'h0;
289
assign  p1_din[3:0] = switch;
290
 
291
 
292
//
293
// Timer A
294
//----------------------------------------------
295
 
296
omsp_timerA timerA_0 (
297
 
298
// OUTPUTs
299
    .irq_ta0      (irq_ta0),               // Timer A interrupt: TACCR0
300
    .irq_ta1      (irq_ta1),               // Timer A interrupt: TAIV, TACCR1, TACCR2
301
    .per_dout     (per_dout_tA),           // Peripheral data output
302
    .ta_out0      (),                      // Timer A output 0
303
    .ta_out0_en   (),                      // Timer A output 0 enable
304
    .ta_out1      (),                      // Timer A output 1
305
    .ta_out1_en   (),                      // Timer A output 1 enable
306
    .ta_out2      (),                      // Timer A output 2
307
    .ta_out2_en   (),                      // Timer A output 2 enable
308
 
309
// INPUTs
310
    .aclk_en      (aclk_en),               // ACLK enable (from CPU)
311
    .dbg_freeze   (dbg_freeze),            // Freeze Timer A counter
312
    .inclk        (1'b0),                  // INCLK external timer clock (SLOW)
313
    .irq_ta0_acc  (irq_acc[9]),            // Interrupt request TACCR0 accepted
314
    .mclk         (mclk),                  // Main system clock
315
    .per_addr     (per_addr),              // Peripheral address
316
    .per_din      (per_din),               // Peripheral data input
317
    .per_en       (per_en),                // Peripheral enable (high active)
318
    .per_we       (per_we),                // Peripheral write enable (high active)
319
    .puc_rst      (puc_rst),               // Main system reset
320
    .smclk_en     (smclk_en),              // SMCLK enable (from CPU)
321
    .ta_cci0a     (1'b0),                  // Timer A capture 0 input A
322
    .ta_cci0b     (1'b0),                  // Timer A capture 0 input B
323
    .ta_cci1a     (1'b0),                  // Timer A capture 1 input A
324
    .ta_cci1b     (1'b0),                  // Timer A capture 1 input B
325
    .ta_cci2a     (1'b0),                  // Timer A capture 2 input A
326
    .ta_cci2b     (1'b0),                  // Timer A capture 2 input B
327
    .taclk        (1'b0)                   // TACLK external timer clock (SLOW)
328
);
329
 
330
 
331
//
332
// Hardware UART
333
//----------------------------------------------
334
 
335
omsp_uart uart_0 (
336
 
337
// OUTPUTs
338
    .irq_uart_rx  (irq_uart_rx),           // UART receive interrupt
339
    .irq_uart_tx  (irq_uart_tx),           // UART transmit interrupt
340
    .per_dout     (per_dout_uart),         // Peripheral data output
341
    .uart_txd     (uart_txd),              // UART Data Transmit (TXD)
342
 
343
// INPUTs
344
    .mclk         (mclk),                  // Main system clock
345
    .per_addr     (per_addr),              // Peripheral address
346
    .per_din      (per_din),               // Peripheral data input
347
    .per_en       (per_en),                // Peripheral enable (high active)
348
    .per_we       (per_we),                // Peripheral write enable (high active)
349
    .puc_rst      (puc_rst),               // Main system reset
350
    .smclk_en     (smclk_en),              // SMCLK enable (from CPU)
351
    .uart_rxd     (uart_rxd)               // UART Data Receive (RXD)
352
);
353
 
354
 
355
//
356
// Combine peripheral data buses
357
//-------------------------------
358
 
359
assign per_dout = per_dout_gpio  |
360
                  per_dout_uart  |
361
                  per_dout_tA;
362
 
363
//
364
// Assign interrupts
365
//-------------------------------
366
 
367
assign nmi      =   1'b0;
368
assign irq_bus  =  {1'b0,         // Vector 13  (0xFFFA)
369
                    1'b0,         // Vector 12  (0xFFF8)
370
                    1'b0,         // Vector 11  (0xFFF6)
371
                    1'b0,         // Vector 10  (0xFFF4) - Watchdog -
372
                    irq_ta0,      // Vector  9  (0xFFF2)
373
                    irq_ta1,      // Vector  8  (0xFFF0)
374
                    irq_uart_rx,  // Vector  7  (0xFFEE)
375
                    irq_uart_tx,  // Vector  6  (0xFFEC)
376
                    1'b0,         // Vector  5  (0xFFEA)
377
                    1'b0,         // Vector  4  (0xFFE8)
378
                    irq_port2,    // Vector  3  (0xFFE6)
379
                    irq_port1,    // Vector  2  (0xFFE4)
380
                    1'b0,         // Vector  1  (0xFFE2)
381
                    1'b0};        // Vector  0  (0xFFE0)
382
 
383
 
384
endmodule // omsp_system_0
385
 
386
 
387
 

powered by: WebSVN 2.1.0

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