1 |
62 |
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 Xilinx synthesis.
|
29 |
|
|
//
|
30 |
|
|
// *Author(s):
|
31 |
|
|
// - Olivier Girard, olgirard@gmail.com
|
32 |
|
|
//
|
33 |
|
|
//----------------------------------------------------------------------------
|
34 |
|
|
// $Rev: 37 $
|
35 |
|
|
// $LastChangedBy: olivier.girard $
|
36 |
|
|
// $LastChangedDate: 2009-12-29 21:58:14 +0100 (Tue, 29 Dec 2009) $
|
37 |
|
|
//----------------------------------------------------------------------------
|
38 |
|
|
`include "timescale.v"
|
39 |
|
|
`include "openMSP430_defines.v"
|
40 |
|
|
`include "arch.v"
|
41 |
|
|
|
42 |
|
|
module openMSP430_fpga (
|
43 |
|
|
|
44 |
|
|
// OUTPUTs
|
45 |
|
|
aclk_en, // ACLK enable
|
46 |
|
|
dbg_freeze, // Freeze peripherals
|
47 |
|
|
dbg_uart_txd, // Debug interface: UART TXD
|
48 |
|
|
irq_acc, // Interrupt request accepted (one-hot signal)
|
49 |
|
|
per_addr, // Peripheral address
|
50 |
|
|
per_din, // Peripheral data input
|
51 |
|
|
per_wen, // Peripheral write enable (high active)
|
52 |
|
|
per_en, // Peripheral enable (high active)
|
53 |
|
|
smclk_en, // SMCLK enable
|
54 |
|
|
|
55 |
|
|
// INPUTs
|
56 |
|
|
dbg_uart_rxd, // Debug interface: UART RXD
|
57 |
|
|
dco_clk, // Fast oscillator (fast clock)
|
58 |
|
|
irq, // Maskable interrupts
|
59 |
|
|
lfxt_clk, // Low frequency oscillator (typ 32kHz)
|
60 |
|
|
nmi, // Non-maskable interrupt (asynchronous)
|
61 |
|
|
per_dout, // Peripheral data output
|
62 |
|
|
reset_n // Reset Pin (low active)
|
63 |
|
|
);
|
64 |
|
|
|
65 |
|
|
// OUTPUTs
|
66 |
|
|
//=========
|
67 |
|
|
output aclk_en; // ACLK enable
|
68 |
|
|
output dbg_freeze; // Freeze peripherals
|
69 |
|
|
output dbg_uart_txd; // Debug interface: UART TXD
|
70 |
|
|
output [13:0] irq_acc; // Interrupt request accepted (one-hot signal)
|
71 |
|
|
output [7:0] per_addr; // Peripheral address
|
72 |
|
|
output [15:0] per_din; // Peripheral data input
|
73 |
|
|
output [1:0] per_wen; // Peripheral write enable (high active)
|
74 |
|
|
output per_en; // Peripheral enable (high active)
|
75 |
|
|
output smclk_en; // SMCLK enable
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
// INPUTs
|
79 |
|
|
//=========
|
80 |
|
|
input dbg_uart_rxd; // Debug interface: UART RXD
|
81 |
|
|
input dco_clk; // Fast oscillator (fast clock)
|
82 |
|
|
input [13:0] irq; // Maskable interrupts
|
83 |
|
|
input lfxt_clk; // Low frequency oscillator (typ 32kHz)
|
84 |
|
|
input nmi; // Non-maskable interrupt (asynchronous)
|
85 |
|
|
input [15:0] per_dout; // Peripheral data output
|
86 |
|
|
input reset_n; // Reset Pin (active low)
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
//=============================================================================
|
90 |
|
|
// 1) INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
|
91 |
|
|
//=============================================================================
|
92 |
|
|
|
93 |
|
|
wire [`DMEM_MSB:0] dmem_addr;
|
94 |
|
|
wire dmem_cen;
|
95 |
|
|
wire [15:0] dmem_din;
|
96 |
|
|
wire [1:0] dmem_wen;
|
97 |
|
|
wire [15:0] dmem_dout;
|
98 |
|
|
|
99 |
|
|
wire [`PMEM_MSB:0] pmem_addr;
|
100 |
|
|
wire pmem_cen;
|
101 |
|
|
wire [15:0] pmem_din;
|
102 |
|
|
wire [1:0] pmem_wen;
|
103 |
|
|
wire [15:0] pmem_dout;
|
104 |
|
|
|
105 |
|
|
wire mclk;
|
106 |
|
|
wire puc;
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
//=============================================================================
|
110 |
|
|
// 2) PROGRAM AND DATA MEMORIES
|
111 |
|
|
//=============================================================================
|
112 |
|
|
|
113 |
|
|
`ifdef SPARTAN3
|
114 |
|
|
spartan3_pmem pmem_hi (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen[1]), .addra(pmem_addr), .dina(pmem_din[15:8]), .douta(pmem_dout[15:8]));
|
115 |
|
|
spartan3_pmem pmem_lo (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen[0]), .addra(pmem_addr), .dina(pmem_din[7:0]), .douta(pmem_dout[7:0]));
|
116 |
|
|
spartan3_dmem dmem_hi (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen[1]), .addra(dmem_addr), .dina(dmem_din[15:8]), .douta(dmem_dout[15:8]));
|
117 |
|
|
spartan3_dmem dmem_lo (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen[0]), .addra(dmem_addr), .dina(dmem_din[7:0]), .douta(dmem_dout[7:0]));
|
118 |
|
|
`endif
|
119 |
|
|
`ifdef SPARTAN3E
|
120 |
|
|
spartan3e_pmem pmem_hi (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen[1]), .addra(pmem_addr), .dina(pmem_din[15:8]), .douta(pmem_dout[15:8]));
|
121 |
|
|
spartan3e_pmem pmem_lo (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen[0]), .addra(pmem_addr), .dina(pmem_din[7:0]), .douta(pmem_dout[7:0]));
|
122 |
|
|
spartan3e_dmem dmem_hi (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen[1]), .addra(dmem_addr), .dina(dmem_din[15:8]), .douta(dmem_dout[15:8]));
|
123 |
|
|
spartan3e_dmem dmem_lo (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen[0]), .addra(dmem_addr), .dina(dmem_din[7:0]), .douta(dmem_dout[7:0]));
|
124 |
|
|
`endif
|
125 |
|
|
`ifdef SPARTAN3A
|
126 |
|
|
spartan3a_pmem pmem (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen), .addra(pmem_addr), .dina(pmem_din), .douta(pmem_dout));
|
127 |
|
|
spartan3a_dmem dmem (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen), .addra(dmem_addr), .dina(dmem_din), .douta(dmem_dout));
|
128 |
|
|
`endif
|
129 |
|
|
`ifdef SPARTAN3ADSP
|
130 |
|
|
spartan3adsp_pmem pmem (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen), .addra(pmem_addr), .dina(pmem_din), .douta(pmem_dout));
|
131 |
|
|
spartan3adsp_dmem dmem (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen), .addra(dmem_addr), .dina(dmem_din), .douta(dmem_dout));
|
132 |
|
|
`endif
|
133 |
|
|
`ifdef SPARTAN6
|
134 |
|
|
spartan6_pmem pmem (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen), .addra(pmem_addr), .dina(pmem_din), .douta(pmem_dout));
|
135 |
|
|
spartan6_dmem dmem (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen), .addra(dmem_addr), .dina(dmem_din), .douta(dmem_dout));
|
136 |
|
|
`endif
|
137 |
|
|
`ifdef VIRTEX4
|
138 |
|
|
virtex4_pmem pmem (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen), .addra(pmem_addr), .dina(pmem_din), .douta(pmem_dout));
|
139 |
|
|
virtex4_dmem dmem (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen), .addra(dmem_addr), .dina(dmem_din), .douta(dmem_dout));
|
140 |
|
|
`endif
|
141 |
|
|
`ifdef VIRTEX5
|
142 |
|
|
virtex5_pmem pmem (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen), .addra(pmem_addr), .dina(pmem_din), .douta(pmem_dout));
|
143 |
|
|
virtex5_dmem dmem (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen), .addra(dmem_addr), .dina(dmem_din), .douta(dmem_dout));
|
144 |
|
|
`endif
|
145 |
|
|
`ifdef VIRTEX6
|
146 |
|
|
virtex6_pmem pmem (.clka(mclk), .ena(~pmem_cen), .wea(~pmem_wen), .addra(pmem_addr), .dina(pmem_din), .douta(pmem_dout));
|
147 |
|
|
virtex6_dmem dmem (.clka(mclk), .ena(~dmem_cen), .wea(~dmem_wen), .addra(dmem_addr), .dina(dmem_din), .douta(dmem_dout));
|
148 |
|
|
`endif
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
//=============================================================================
|
152 |
|
|
// 3) OPENMSP430
|
153 |
|
|
//=============================================================================
|
154 |
|
|
|
155 |
|
|
openMSP430 openMSP430_0 (
|
156 |
|
|
|
157 |
|
|
// OUTPUTs
|
158 |
|
|
.aclk_en (aclk_en), // ACLK enable
|
159 |
|
|
.dbg_freeze (dbg_freeze), // Freeze peripherals
|
160 |
|
|
.dbg_uart_txd (dbg_uart_txd), // Debug interface: UART TXD
|
161 |
|
|
.dmem_addr (dmem_addr), // Data Memory address
|
162 |
|
|
.dmem_cen (dmem_cen), // Data Memory chip enable (low active)
|
163 |
|
|
.dmem_din (dmem_din), // Data Memory data input
|
164 |
|
|
.dmem_wen (dmem_wen), // Data Memory write enable (low active)
|
165 |
|
|
.irq_acc (irq_acc), // Interrupt request accepted (one-hot signal)
|
166 |
|
|
.mclk (mclk), // Main system clock
|
167 |
|
|
.per_addr (per_addr), // Peripheral address
|
168 |
|
|
.per_din (per_din), // Peripheral data input
|
169 |
|
|
.per_wen (per_wen), // Peripheral write enable (high active)
|
170 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
171 |
|
|
.pmem_addr (pmem_addr), // Program Memory address
|
172 |
|
|
.pmem_cen (pmem_cen), // Program Memory chip enable (low active)
|
173 |
|
|
.pmem_din (pmem_din), // Program Memory data input (optional)
|
174 |
|
|
.pmem_wen (pmem_wen), // Program Memory write enable (low active) (optional)
|
175 |
|
|
.puc (puc), // Main system reset
|
176 |
|
|
.smclk_en (smclk_en), // SMCLK enable
|
177 |
|
|
|
178 |
|
|
// INPUTs
|
179 |
|
|
.dbg_uart_rxd (dbg_uart_rxd), // Debug interface: UART RXD
|
180 |
|
|
.dco_clk (dco_clk), // Fast oscillator (fast clock)
|
181 |
|
|
.dmem_dout (dmem_dout), // Data Memory data output
|
182 |
|
|
.irq (irq), // Maskable interrupts
|
183 |
|
|
.lfxt_clk (lfxt_clk), // Low frequency oscillator (typ 32kHz)
|
184 |
|
|
.nmi (nmi), // Non-maskable interrupt (asynchronous)
|
185 |
|
|
.per_dout (per_dout), // Peripheral data output
|
186 |
|
|
.pmem_dout (pmem_dout), // Program Memory data output
|
187 |
|
|
.reset_n (reset_n) // Reset Pin (low active)
|
188 |
|
|
);
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
endmodule // openMSP430_fpga
|
193 |
|
|
|