1 |
221 |
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 DE0 Nano Soc
|
29 |
|
|
//
|
30 |
|
|
// *Author(s):
|
31 |
|
|
// - Olivier Girard, olgirard@gmail.com
|
32 |
|
|
//
|
33 |
|
|
//----------------------------------------------------------------------------
|
34 |
|
|
`include "openmsp430/openMSP430_defines.v"
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
module openMSP430_fpga (
|
38 |
|
|
|
39 |
|
|
//-----------------------------
|
40 |
|
|
// USER CLOCKS
|
41 |
|
|
//-----------------------------
|
42 |
|
|
input FPGA_CLK1_50,
|
43 |
|
|
input FPGA_CLK2_50,
|
44 |
|
|
input FPGA_CLK3_50,
|
45 |
|
|
|
46 |
|
|
//-----------------------------
|
47 |
|
|
// USER INTERFACE (FPGA)
|
48 |
|
|
//-----------------------------
|
49 |
|
|
input [1:0] KEY,
|
50 |
|
|
input [3:0] SW,
|
51 |
|
|
output [7:0] LED,
|
52 |
|
|
|
53 |
|
|
//-----------------------------
|
54 |
|
|
// GPIO
|
55 |
|
|
//-----------------------------
|
56 |
|
|
inout [35:0] GPIO_0,
|
57 |
|
|
inout [35:0] GPIO_1,
|
58 |
|
|
|
59 |
|
|
//-----------------------------
|
60 |
|
|
// ARDUINO DIGITAL INTERFACE
|
61 |
|
|
//-----------------------------
|
62 |
|
|
inout [15:0] ARDUINO_IO,
|
63 |
|
|
inout ARDUINO_RESET_N,
|
64 |
|
|
|
65 |
|
|
//-----------------------------
|
66 |
|
|
// ADC
|
67 |
|
|
//-----------------------------
|
68 |
|
|
output ADC_CONVST,
|
69 |
|
|
output ADC_SCK,
|
70 |
|
|
output ADC_SDI,
|
71 |
|
|
input ADC_SDO
|
72 |
|
|
);
|
73 |
|
|
|
74 |
|
|
//=============================================================================
|
75 |
|
|
// 1) INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
|
76 |
|
|
//=============================================================================
|
77 |
|
|
|
78 |
|
|
// openMSP430 Program memory bus
|
79 |
|
|
wire [`PMEM_MSB:0] pmem_addr;
|
80 |
|
|
wire [15:0] pmem_din;
|
81 |
|
|
wire pmem_cen;
|
82 |
|
|
wire [1:0] pmem_wen;
|
83 |
|
|
wire [15:0] pmem_dout;
|
84 |
|
|
|
85 |
|
|
// openMSP430 Data memory bus
|
86 |
|
|
wire [`DMEM_MSB:0] dmem_addr;
|
87 |
|
|
wire [15:0] dmem_din;
|
88 |
|
|
wire dmem_cen;
|
89 |
|
|
wire [1:0] dmem_wen;
|
90 |
|
|
wire [15:0] dmem_dout;
|
91 |
|
|
|
92 |
|
|
// openMSP430 Peripheral memory bus
|
93 |
|
|
wire [13:0] per_addr;
|
94 |
|
|
wire [15:0] per_din;
|
95 |
|
|
wire per_en;
|
96 |
|
|
wire [1:0] per_we;
|
97 |
|
|
wire [15:0] per_dout;
|
98 |
|
|
|
99 |
|
|
// openMSP430 IRQs
|
100 |
|
|
wire nmi;
|
101 |
|
|
wire [13:0] irq_bus;
|
102 |
|
|
wire [13:0] irq_acc;
|
103 |
|
|
|
104 |
|
|
// openMSP430 debug interface
|
105 |
|
|
wire dbg_freeze;
|
106 |
|
|
wire [6:0] dbg_i2c_addr;
|
107 |
|
|
wire [6:0] dbg_i2c_broadcast;
|
108 |
|
|
wire dbg_i2c_scl;
|
109 |
|
|
wire dbg_i2c_sda_in;
|
110 |
|
|
wire dbg_i2c_sda_out;
|
111 |
|
|
wire dbg_uart_txd;
|
112 |
|
|
wire dbg_uart_rxd;
|
113 |
|
|
|
114 |
|
|
// openMSP430 clocks and resets
|
115 |
|
|
wire dco_clk;
|
116 |
|
|
wire lfxt_clk;
|
117 |
|
|
wire aclk_en;
|
118 |
|
|
wire smclk_en;
|
119 |
|
|
wire mclk;
|
120 |
|
|
wire reset_n;
|
121 |
|
|
wire puc_rst;
|
122 |
|
|
|
123 |
|
|
// LED / KEY / SW
|
124 |
|
|
wire irq_key;
|
125 |
|
|
wire irq_sw;
|
126 |
|
|
wire [15:0] per_dout_led_key_sw;
|
127 |
|
|
|
128 |
|
|
// Timer A
|
129 |
|
|
wire irq_ta0;
|
130 |
|
|
wire irq_ta1;
|
131 |
|
|
wire [15:0] per_dout_tA;
|
132 |
|
|
|
133 |
|
|
// Graphic Controller
|
134 |
|
|
wire irq_gfx;
|
135 |
|
|
wire [15:0] per_dout_gfx;
|
136 |
|
|
|
137 |
|
|
wire [8:0] lut_ram_addr;
|
138 |
|
|
wire lut_ram_wen;
|
139 |
|
|
wire lut_ram_cen;
|
140 |
|
|
wire [15:0] lut_ram_din;
|
141 |
|
|
wire [15:0] lut_ram_dout;
|
142 |
|
|
|
143 |
|
|
wire [16:0] vid_ram_addr;
|
144 |
|
|
wire vid_ram_wen;
|
145 |
|
|
wire vid_ram_cen;
|
146 |
|
|
wire [15:0] vid_ram_din;
|
147 |
|
|
wire [15:0] vid_ram_dout;
|
148 |
|
|
|
149 |
|
|
// Touch-Screen Controller
|
150 |
|
|
wire irq_touch;
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
//=============================================================================
|
154 |
|
|
// 2) CLOCK AND RESET GENERATION
|
155 |
|
|
//=============================================================================
|
156 |
|
|
|
157 |
|
|
assign dco_clk = FPGA_CLK1_50;
|
158 |
|
|
wire reset_in_n = KEY[0];
|
159 |
|
|
|
160 |
|
|
// Release system reset a few clock cyles after the FPGA power-on-reset
|
161 |
|
|
reg [7:0] reset_dly_chain;
|
162 |
|
|
always @ (posedge dco_clk or negedge reset_in_n)
|
163 |
|
|
if (!reset_in_n) reset_dly_chain <= 8'h00;
|
164 |
|
|
else reset_dly_chain <= {1'b1, reset_dly_chain[7:1]};
|
165 |
|
|
|
166 |
|
|
assign reset_n = reset_dly_chain[0];
|
167 |
|
|
|
168 |
|
|
// Generate a slow reference clock LFXT_CLK (10us period)
|
169 |
|
|
reg [8:0] lfxt_clk_cnt;
|
170 |
|
|
always @ (posedge dco_clk or negedge reset_n)
|
171 |
|
|
if (!reset_n) lfxt_clk_cnt <= 9'h000;
|
172 |
|
|
else lfxt_clk_cnt <= lfxt_clk_cnt + 9'h001;
|
173 |
|
|
|
174 |
|
|
assign lfxt_clk = lfxt_clk_cnt[8];
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
//=============================================================================
|
178 |
|
|
// 3) OPENMSP430
|
179 |
|
|
//=============================================================================
|
180 |
|
|
|
181 |
|
|
openMSP430 openmsp430_0 (
|
182 |
|
|
|
183 |
|
|
// OUTPUTs
|
184 |
|
|
.aclk (), // ASIC ONLY: ACLK
|
185 |
|
|
.aclk_en (aclk_en), // FPGA ONLY: ACLK enable
|
186 |
|
|
.dbg_freeze (dbg_freeze), // Freeze peripherals
|
187 |
|
|
.dbg_i2c_sda_out (dbg_i2c_sda_out), // Debug interface: I2C SDA OUT
|
188 |
|
|
.dbg_uart_txd (dbg_uart_txd), // Debug interface: UART TXD
|
189 |
|
|
.dco_enable (), // ASIC ONLY: Fast oscillator enable
|
190 |
|
|
.dco_wkup (), // ASIC ONLY: Fast oscillator wake-up (asynchronous)
|
191 |
|
|
.dmem_addr (dmem_addr), // Data Memory address
|
192 |
|
|
.dmem_cen (dmem_cen), // Data Memory chip enable (low active)
|
193 |
|
|
.dmem_din (dmem_din), // Data Memory data input
|
194 |
|
|
.dmem_wen (dmem_wen), // Data Memory write enable (low active)
|
195 |
|
|
.irq_acc (irq_acc), // Interrupt request accepted (one-hot signal)
|
196 |
|
|
.lfxt_enable (), // ASIC ONLY: Low frequency oscillator enable
|
197 |
|
|
.lfxt_wkup (), // ASIC ONLY: Low frequency oscillator wake-up (asynchronous)
|
198 |
|
|
.mclk (mclk), // Main system clock
|
199 |
|
|
.dma_dout (), // Direct Memory Access data output
|
200 |
|
|
.dma_ready (), // Direct Memory Access is complete
|
201 |
|
|
.dma_resp (), // Direct Memory Access response (0:Okay / 1:Error)
|
202 |
|
|
.per_addr (per_addr), // Peripheral address
|
203 |
|
|
.per_din (per_din), // Peripheral data input
|
204 |
|
|
.per_we (per_we), // Peripheral write enable (high active)
|
205 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
206 |
|
|
.pmem_addr (pmem_addr), // Program Memory address
|
207 |
|
|
.pmem_cen (pmem_cen), // Program Memory chip enable (low active)
|
208 |
|
|
.pmem_din (pmem_din), // Program Memory data input (optional)
|
209 |
|
|
.pmem_wen (pmem_wen), // Program Memory write enable (low active) (optional)
|
210 |
|
|
.puc_rst (puc_rst), // Main system reset
|
211 |
|
|
.smclk (), // ASIC ONLY: SMCLK
|
212 |
|
|
.smclk_en (smclk_en), // FPGA ONLY: SMCLK enable
|
213 |
|
|
|
214 |
|
|
// INPUTs
|
215 |
|
|
.cpu_en (1'b1), // Enable CPU code execution (asynchronous and non-glitchy)
|
216 |
|
|
.dbg_en (1'b1), // Debug interface enable (asynchronous and non-glitchy)
|
217 |
|
|
.dbg_i2c_addr (dbg_i2c_addr), // Debug interface: I2C Address
|
218 |
|
|
.dbg_i2c_broadcast (dbg_i2c_broadcast), // Debug interface: I2C Broadcast Address (for multicore systems)
|
219 |
|
|
.dbg_i2c_scl (dbg_i2c_scl), // Debug interface: I2C SCL
|
220 |
|
|
.dbg_i2c_sda_in (dbg_i2c_sda_in), // Debug interface: I2C SDA IN
|
221 |
|
|
.dbg_uart_rxd (dbg_uart_rxd), // Debug interface: UART RXD (asynchronous)
|
222 |
|
|
.dco_clk (dco_clk), // Fast oscillator (fast clock)
|
223 |
|
|
.dmem_dout (dmem_dout), // Data Memory data output
|
224 |
|
|
.irq (irq_bus), // Maskable interrupts
|
225 |
|
|
.lfxt_clk (lfxt_clk), // Low frequency oscillator (typ 32kHz)
|
226 |
|
|
.dma_addr (15'h0000), // Direct Memory Access address
|
227 |
|
|
.dma_din (16'h0000), // Direct Memory Access data input
|
228 |
|
|
.dma_en (1'b0), // Direct Memory Access enable (high active)
|
229 |
|
|
.dma_priority (1'b0), // Direct Memory Access priority (0:low / 1:high)
|
230 |
|
|
.dma_we (2'b00), // Direct Memory Access write byte enable (high active)
|
231 |
|
|
.dma_wkup (1'b0), // ASIC ONLY: DMA Sub-System Wake-up (asynchronous and non-glitchy)
|
232 |
|
|
.nmi (nmi), // Non-maskable interrupt (asynchronous)
|
233 |
|
|
.per_dout (per_dout), // Peripheral data output
|
234 |
|
|
.pmem_dout (pmem_dout), // Program Memory data output
|
235 |
|
|
.reset_n (reset_n), // Reset Pin (low active, asynchronous and non-glitchy)
|
236 |
|
|
.scan_enable (1'b0), // ASIC ONLY: Scan enable (active during scan shifting)
|
237 |
|
|
.scan_mode (1'b0), // ASIC ONLY: Scan mode
|
238 |
|
|
.wkup (1'b0) // ASIC ONLY: System Wake-up (asynchronous and non-glitchy)
|
239 |
|
|
);
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
//=============================================================================
|
243 |
|
|
// 4) OPENMSP430 PERIPHERALS
|
244 |
|
|
//=============================================================================
|
245 |
|
|
|
246 |
|
|
//-----------------------------
|
247 |
|
|
// LED / KEY / SW interface
|
248 |
|
|
//-----------------------------
|
249 |
|
|
omsp_de0_nano_soc_led_key_sw de0_nano_soc_led_key_sw_0 (
|
250 |
|
|
|
251 |
|
|
// OUTPUTs
|
252 |
|
|
.irq_key (irq_key), // Key/Button interrupt
|
253 |
|
|
.irq_sw (irq_sw), // Switch interrupt
|
254 |
|
|
|
255 |
|
|
.led (LED), // LED output control
|
256 |
|
|
.per_dout (per_dout_led_key_sw), // Peripheral data output
|
257 |
|
|
|
258 |
|
|
// INPUTs
|
259 |
|
|
.mclk (mclk), // Main system clock
|
260 |
|
|
.key (KEY), // key/button inputs
|
261 |
|
|
.sw (SW), // switches inputs
|
262 |
|
|
.per_addr (per_addr), // Peripheral address
|
263 |
|
|
.per_din (per_din), // Peripheral data input
|
264 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
265 |
|
|
.per_we (per_we), // Peripheral write enable (high active)
|
266 |
|
|
.puc_rst (puc_rst) // Main system reset
|
267 |
|
|
);
|
268 |
|
|
|
269 |
|
|
//-----------------------------
|
270 |
|
|
// Timer A
|
271 |
|
|
//-----------------------------
|
272 |
|
|
|
273 |
|
|
omsp_timerA timerA_0 (
|
274 |
|
|
|
275 |
|
|
// OUTPUTs
|
276 |
|
|
.irq_ta0 (irq_ta0), // Timer A interrupt: TACCR0
|
277 |
|
|
.irq_ta1 (irq_ta1), // Timer A interrupt: TAIV, TACCR1, TACCR2
|
278 |
|
|
.per_dout (per_dout_tA), // Peripheral data output
|
279 |
|
|
.ta_out0 (), // Timer A output 0
|
280 |
|
|
.ta_out0_en (), // Timer A output 0 enable
|
281 |
|
|
.ta_out1 (), // Timer A output 1
|
282 |
|
|
.ta_out1_en (), // Timer A output 1 enable
|
283 |
|
|
.ta_out2 (), // Timer A output 2
|
284 |
|
|
.ta_out2_en (), // Timer A output 2 enable
|
285 |
|
|
|
286 |
|
|
// INPUTs
|
287 |
|
|
.aclk_en (aclk_en), // ACLK enable (from CPU)
|
288 |
|
|
.dbg_freeze (dbg_freeze), // Freeze Timer A counter
|
289 |
|
|
.inclk (1'b0), // INCLK external timer clock (SLOW)
|
290 |
|
|
.irq_ta0_acc (irq_acc[9]), // Interrupt request TACCR0 accepted
|
291 |
|
|
.mclk (mclk), // Main system clock
|
292 |
|
|
.per_addr (per_addr), // Peripheral address
|
293 |
|
|
.per_din (per_din), // Peripheral data input
|
294 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
295 |
|
|
.per_we (per_we), // Peripheral write enable (high active)
|
296 |
|
|
.puc_rst (puc_rst), // Main system reset
|
297 |
|
|
.smclk_en (smclk_en), // SMCLK enable (from CPU)
|
298 |
|
|
.ta_cci0a (1'b0), // Timer A capture 0 input A
|
299 |
|
|
.ta_cci0b (1'b0), // Timer A capture 0 input B
|
300 |
|
|
.ta_cci1a (1'b0), // Timer A capture 1 input A
|
301 |
|
|
.ta_cci1b (1'b0), // Timer A capture 1 input B
|
302 |
|
|
.ta_cci2a (1'b0), // Timer A capture 2 input A
|
303 |
|
|
.ta_cci2b (1'b0), // Timer A capture 2 input B
|
304 |
|
|
.taclk (1'b0) // TACLK external timer clock (SLOW)
|
305 |
|
|
);
|
306 |
|
|
|
307 |
|
|
//-------------------------------
|
308 |
|
|
// GRAPHIC CONTROLER
|
309 |
|
|
// (Interfacing with LT24 board)
|
310 |
|
|
//-------------------------------
|
311 |
|
|
|
312 |
|
|
// Bidirectional data bus
|
313 |
|
|
wire [15:0] lt24_data;
|
314 |
|
|
wire [15:0] lt24_d_out;
|
315 |
|
|
wire lt24_d_out_en;
|
316 |
|
|
|
317 |
|
|
io_buf io_buf_lt24_data_00 (.datain(lt24_d_out[0]), .oe(lt24_d_out_en), .dataout(lt24_data[0]), .dataio(GPIO_0[8]) );
|
318 |
|
|
io_buf io_buf_lt24_data_01 (.datain(lt24_d_out[1]), .oe(lt24_d_out_en), .dataout(lt24_data[1]), .dataio(GPIO_0[7]) );
|
319 |
|
|
io_buf io_buf_lt24_data_02 (.datain(lt24_d_out[2]), .oe(lt24_d_out_en), .dataout(lt24_data[2]), .dataio(GPIO_0[6]) );
|
320 |
|
|
io_buf io_buf_lt24_data_03 (.datain(lt24_d_out[3]), .oe(lt24_d_out_en), .dataout(lt24_data[3]), .dataio(GPIO_0[5]) );
|
321 |
|
|
io_buf io_buf_lt24_data_04 (.datain(lt24_d_out[4]), .oe(lt24_d_out_en), .dataout(lt24_data[4]), .dataio(GPIO_0[13]));
|
322 |
|
|
io_buf io_buf_lt24_data_05 (.datain(lt24_d_out[5]), .oe(lt24_d_out_en), .dataout(lt24_data[5]), .dataio(GPIO_0[14]));
|
323 |
|
|
io_buf io_buf_lt24_data_06 (.datain(lt24_d_out[6]), .oe(lt24_d_out_en), .dataout(lt24_data[6]), .dataio(GPIO_0[15]));
|
324 |
|
|
io_buf io_buf_lt24_data_07 (.datain(lt24_d_out[7]), .oe(lt24_d_out_en), .dataout(lt24_data[7]), .dataio(GPIO_0[16]));
|
325 |
|
|
io_buf io_buf_lt24_data_08 (.datain(lt24_d_out[8]), .oe(lt24_d_out_en), .dataout(lt24_data[8]), .dataio(GPIO_0[17]));
|
326 |
|
|
io_buf io_buf_lt24_data_09 (.datain(lt24_d_out[9]), .oe(lt24_d_out_en), .dataout(lt24_data[9]), .dataio(GPIO_0[18]));
|
327 |
|
|
io_buf io_buf_lt24_data_10 (.datain(lt24_d_out[10]), .oe(lt24_d_out_en), .dataout(lt24_data[10]), .dataio(GPIO_0[19]));
|
328 |
|
|
io_buf io_buf_lt24_data_11 (.datain(lt24_d_out[11]), .oe(lt24_d_out_en), .dataout(lt24_data[11]), .dataio(GPIO_0[20]));
|
329 |
|
|
io_buf io_buf_lt24_data_12 (.datain(lt24_d_out[12]), .oe(lt24_d_out_en), .dataout(lt24_data[12]), .dataio(GPIO_0[21]));
|
330 |
|
|
io_buf io_buf_lt24_data_13 (.datain(lt24_d_out[13]), .oe(lt24_d_out_en), .dataout(lt24_data[13]), .dataio(GPIO_0[22]));
|
331 |
|
|
io_buf io_buf_lt24_data_14 (.datain(lt24_d_out[14]), .oe(lt24_d_out_en), .dataout(lt24_data[14]), .dataio(GPIO_0[23]));
|
332 |
|
|
io_buf io_buf_lt24_data_15 (.datain(lt24_d_out[15]), .oe(lt24_d_out_en), .dataout(lt24_data[15]), .dataio(GPIO_0[24]));
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
222 |
olivier.gi |
openGFX430 #(.BASE_ADDR(16'h0200)) opengfx430_0 (
|
337 |
221 |
olivier.gi |
|
338 |
|
|
// OUTPUTs
|
339 |
|
|
.irq_gfx_o (irq_gfx), // Graphic Controller interrupt
|
340 |
|
|
|
341 |
|
|
.lt24_cs_n_o (GPIO_0[25]), // LT24 Chip select (Active low)
|
342 |
|
|
.lt24_rd_n_o (GPIO_0[10]), // LT24 Read strobe (Active low)
|
343 |
|
|
.lt24_wr_n_o (GPIO_0[11]), // LT24 Write strobe (Active low)
|
344 |
|
|
.lt24_rs_o (GPIO_0[12]), // LT24 Command/Param selection (Cmd=0/Param=1)
|
345 |
|
|
.lt24_d_o (lt24_d_out), // LT24 Data output
|
346 |
|
|
.lt24_d_en_o (lt24_d_out_en), // LT24 Data output enable
|
347 |
|
|
.lt24_reset_n_o (GPIO_0[33]), // LT24 Reset (Active Low)
|
348 |
|
|
.lt24_on_o (GPIO_0[35]), // LT24 on/off
|
349 |
|
|
|
350 |
|
|
.per_dout_o (per_dout_gfx), // Peripheral data output
|
351 |
|
|
|
352 |
|
|
.lut_ram_addr_o (lut_ram_addr), // LUT-RAM address
|
353 |
|
|
.lut_ram_wen_o (lut_ram_wen ), // LUT-RAM write enable (active low)
|
354 |
|
|
.lut_ram_cen_o (lut_ram_cen ), // LUT-RAM enable (active low)
|
355 |
|
|
.lut_ram_din_o (lut_ram_din ), // LUT-RAM data input
|
356 |
|
|
|
357 |
|
|
.vid_ram_addr_o (vid_ram_addr), // Video-RAM address
|
358 |
|
|
.vid_ram_wen_o (vid_ram_wen ), // Video-RAM write enable (active low)
|
359 |
|
|
.vid_ram_cen_o (vid_ram_cen ), // Video-RAM enable (active low)
|
360 |
|
|
.vid_ram_din_o (vid_ram_din ), // Video-RAM data input
|
361 |
|
|
|
362 |
|
|
// INPUTs
|
363 |
|
|
.dbg_freeze_i (dbg_freeze), // Freeze address auto-incr on read
|
364 |
|
|
.mclk (mclk), // Main system clock
|
365 |
|
|
.per_addr_i (per_addr), // Peripheral address
|
366 |
|
|
.per_din_i (per_din), // Peripheral data input
|
367 |
|
|
.per_en_i (per_en), // Peripheral enable (high active)
|
368 |
|
|
.per_we_i (per_we), // Peripheral write enable (high active)
|
369 |
|
|
.puc_rst (puc_rst), // Main system reset
|
370 |
|
|
|
371 |
|
|
.lt24_d_i (lt24_data), // LT24 Data input
|
372 |
|
|
|
373 |
|
|
.lut_ram_dout_i (lut_ram_dout), // LUT-RAM data output
|
374 |
|
|
.vid_ram_dout_i (vid_ram_dout) // Video-RAM data output
|
375 |
|
|
);
|
376 |
|
|
|
377 |
|
|
// Video memory
|
378 |
|
|
ram_16x75k vid_ram_16x75k_0 (
|
379 |
|
|
|
380 |
|
|
.address ( vid_ram_addr),
|
381 |
|
|
.byteena (~{2{vid_ram_wen}}),
|
382 |
|
|
.clken (~vid_ram_cen),
|
383 |
|
|
.clock ( mclk),
|
384 |
|
|
.data ( vid_ram_din),
|
385 |
|
|
.wren (~vid_ram_wen),
|
386 |
|
|
.q ( vid_ram_dout)
|
387 |
|
|
);
|
388 |
|
|
|
389 |
|
|
// LUT memory
|
390 |
|
|
ram_16x512 lut_ram_16x512_0 (
|
391 |
|
|
|
392 |
|
|
.address ( lut_ram_addr),
|
393 |
|
|
.byteena (~{2{lut_ram_wen}}),
|
394 |
|
|
.clken (~lut_ram_cen),
|
395 |
|
|
.clock ( mclk),
|
396 |
|
|
.data ( lut_ram_din),
|
397 |
|
|
.wren (~lut_ram_wen),
|
398 |
|
|
.q ( lut_ram_dout)
|
399 |
|
|
);
|
400 |
|
|
|
401 |
|
|
assign GPIO_0[34] = 1'b1; // .adc_cs_n (GPIO_0[34]), // ADC Chip select (Active low)
|
402 |
|
|
assign GPIO_0[4] = 1'b0; // .adc_dclk (GPIO_0[4]), // ADC Clock
|
403 |
|
|
assign GPIO_0[3] = 1'b0; // .adc_din (GPIO_0[3]), // ADC Data input
|
404 |
|
|
assign irq_touch = 1'b0; //
|
405 |
|
|
// .adc_busy (GPIO_0[2]), // ADC Busy output
|
406 |
|
|
// .adc_dount (GPIO_0[1]), // ADC Data output
|
407 |
|
|
// .adc_penirq_n (GPIO_0[0]), // Pen IRQ from touch controller
|
408 |
|
|
|
409 |
|
|
//-----------------------------
|
410 |
|
|
// Combine peripheral
|
411 |
|
|
// data buses
|
412 |
|
|
//-----------------------------
|
413 |
|
|
|
414 |
|
|
assign per_dout = per_dout_led_key_sw |
|
415 |
|
|
per_dout_tA |
|
416 |
|
|
per_dout_gfx;
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
//-----------------------------
|
420 |
|
|
// Assign interrupts
|
421 |
|
|
//-----------------------------
|
422 |
|
|
|
423 |
|
|
assign nmi = 1'b0;
|
424 |
|
|
assign irq_bus = {1'b0, // Vector 13 (0xFFFA)
|
425 |
|
|
1'b0, // Vector 12 (0xFFF8)
|
426 |
|
|
1'b0, // Vector 11 (0xFFF6)
|
427 |
|
|
1'b0, // Vector 10 (0xFFF4) - Watchdog -
|
428 |
|
|
irq_ta0, // Vector 9 (0xFFF2)
|
429 |
|
|
irq_ta1, // Vector 8 (0xFFF0)
|
430 |
|
|
1'b0, // Vector 7 (0xFFEE)
|
431 |
|
|
irq_gfx, // Vector 6 (0xFFEC)
|
432 |
|
|
irq_touch, // Vector 5 (0xFFEA)
|
433 |
|
|
1'b0, // Vector 4 (0xFFE8)
|
434 |
|
|
irq_key, // Vector 3 (0xFFE6)
|
435 |
|
|
irq_sw, // Vector 2 (0xFFE4)
|
436 |
|
|
1'b0, // Vector 1 (0xFFE2)
|
437 |
|
|
1'b0}; // Vector 0 (0xFFE0)
|
438 |
|
|
|
439 |
|
|
|
440 |
|
|
//=============================================================================
|
441 |
|
|
// 5) PROGRAM AND DATA MEMORIES
|
442 |
|
|
//=============================================================================
|
443 |
|
|
|
444 |
|
|
ram_16x16k pmem_0 (
|
445 |
|
|
.address ( pmem_addr),
|
446 |
|
|
.byteena (~pmem_wen),
|
447 |
|
|
.clken (~pmem_cen),
|
448 |
|
|
.clock ( mclk),
|
449 |
|
|
.data ( pmem_din),
|
450 |
|
|
.wren (~(&pmem_wen)),
|
451 |
|
|
.q ( pmem_dout)
|
452 |
|
|
);
|
453 |
|
|
|
454 |
|
|
ram_16x8k dmem_0 (
|
455 |
|
|
.address ( dmem_addr),
|
456 |
|
|
.byteena (~dmem_wen),
|
457 |
|
|
.clken (~dmem_cen),
|
458 |
|
|
.clock ( mclk),
|
459 |
|
|
.data ( dmem_din),
|
460 |
|
|
.wren (~(&dmem_wen)),
|
461 |
|
|
.q ( dmem_dout)
|
462 |
|
|
);
|
463 |
|
|
|
464 |
|
|
//=============================================================================
|
465 |
|
|
// 6) DEBUG INTERFACE
|
466 |
|
|
//=============================================================================
|
467 |
|
|
|
468 |
|
|
assign dbg_i2c_addr = 7'd50;
|
469 |
|
|
assign dbg_i2c_broadcast = 7'd49;
|
470 |
|
|
assign dbg_i2c_scl = ARDUINO_IO[15];
|
471 |
|
|
io_buf io_buf_sda_0 (.datain(1'b0), .oe(~dbg_i2c_sda_out), .dataout(dbg_i2c_sda_in), .dataio(ARDUINO_IO[14]));
|
472 |
|
|
assign dbg_uart_rxd = 1'b0;
|
473 |
|
|
|
474 |
|
|
// Unused stuff
|
475 |
|
|
assign GPIO_0 = 36'hzzzzzzzzz;
|
476 |
|
|
assign GPIO_1 = 36'hzzzzzzzzz;
|
477 |
|
|
assign ARDUINO_IO[13:0] = 14'hzzzz;
|
478 |
|
|
assign ARDUINO_RESET_N = 1'hz;
|
479 |
|
|
assign ADC_CONVST = 1'hz;
|
480 |
|
|
assign ADC_SCK = 1'hz;
|
481 |
|
|
assign ADC_SDI = 1'hz;
|
482 |
|
|
|
483 |
|
|
endmodule
|