1 |
80 |
olivier.gi |
//----------------------------------------------------------------------------
|
2 |
136 |
olivier.gi |
// Copyright (C) 2009 , Olivier Girard
|
3 |
80 |
olivier.gi |
//
|
4 |
136 |
olivier.gi |
// Redistribution and use in source and binary forms, with or without
|
5 |
|
|
// modification, are permitted provided that the following conditions
|
6 |
|
|
// are met:
|
7 |
|
|
// * Redistributions of source code must retain the above copyright
|
8 |
|
|
// notice, this list of conditions and the following disclaimer.
|
9 |
|
|
// * Redistributions in binary form must reproduce the above copyright
|
10 |
|
|
// notice, this list of conditions and the following disclaimer in the
|
11 |
|
|
// documentation and/or other materials provided with the distribution.
|
12 |
|
|
// * Neither the name of the authors nor the names of its contributors
|
13 |
|
|
// may be used to endorse or promote products derived from this software
|
14 |
|
|
// without specific prior written permission.
|
15 |
80 |
olivier.gi |
//
|
16 |
136 |
olivier.gi |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17 |
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18 |
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19 |
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
20 |
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
21 |
|
|
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22 |
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23 |
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24 |
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25 |
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
26 |
|
|
// THE POSSIBILITY OF SUCH DAMAGE
|
27 |
80 |
olivier.gi |
//
|
28 |
|
|
//----------------------------------------------------------------------------
|
29 |
|
|
//
|
30 |
|
|
// *File Name: openMSP430.v
|
31 |
|
|
//
|
32 |
|
|
// *Module Description:
|
33 |
|
|
// openMSP430 Top level file
|
34 |
|
|
//
|
35 |
|
|
// *Author(s):
|
36 |
|
|
// - Olivier Girard, olgirard@gmail.com
|
37 |
|
|
//
|
38 |
|
|
//----------------------------------------------------------------------------
|
39 |
155 |
olivier.gi |
// $Rev: 154 $
|
40 |
80 |
olivier.gi |
// $LastChangedBy: olivier.girard $
|
41 |
155 |
olivier.gi |
// $LastChangedDate: 2012-10-15 22:44:20 +0200 (Mon, 15 Oct 2012) $
|
42 |
80 |
olivier.gi |
//----------------------------------------------------------------------------
|
43 |
104 |
olivier.gi |
`ifdef OMSP_NO_INCLUDE
|
44 |
|
|
`else
|
45 |
80 |
olivier.gi |
`include "openMSP430_defines.v"
|
46 |
104 |
olivier.gi |
`endif
|
47 |
80 |
olivier.gi |
|
48 |
|
|
module openMSP430 (
|
49 |
|
|
|
50 |
|
|
// OUTPUTs
|
51 |
155 |
olivier.gi |
aclk, // ASIC ONLY: ACLK
|
52 |
|
|
aclk_en, // FPGA ONLY: ACLK enable
|
53 |
|
|
dbg_freeze, // Freeze peripherals
|
54 |
|
|
dbg_i2c_sda_out, // Debug interface: I2C SDA OUT
|
55 |
|
|
dbg_uart_txd, // Debug interface: UART TXD
|
56 |
|
|
dco_enable, // ASIC ONLY: Fast oscillator enable
|
57 |
|
|
dco_wkup, // ASIC ONLY: Fast oscillator wake-up (asynchronous)
|
58 |
|
|
dmem_addr, // Data Memory address
|
59 |
|
|
dmem_cen, // Data Memory chip enable (low active)
|
60 |
|
|
dmem_din, // Data Memory data input
|
61 |
|
|
dmem_wen, // Data Memory write enable (low active)
|
62 |
|
|
irq_acc, // Interrupt request accepted (one-hot signal)
|
63 |
|
|
lfxt_enable, // ASIC ONLY: Low frequency oscillator enable
|
64 |
|
|
lfxt_wkup, // ASIC ONLY: Low frequency oscillator wake-up (asynchronous)
|
65 |
|
|
mclk, // Main system clock
|
66 |
|
|
per_addr, // Peripheral address
|
67 |
|
|
per_din, // Peripheral data input
|
68 |
|
|
per_we, // Peripheral write enable (high active)
|
69 |
|
|
per_en, // Peripheral enable (high active)
|
70 |
|
|
pmem_addr, // Program Memory address
|
71 |
|
|
pmem_cen, // Program Memory chip enable (low active)
|
72 |
|
|
pmem_din, // Program Memory data input (optional)
|
73 |
|
|
pmem_wen, // Program Memory write enable (low active) (optional)
|
74 |
|
|
puc_rst, // Main system reset
|
75 |
|
|
smclk, // ASIC ONLY: SMCLK
|
76 |
|
|
smclk_en, // FPGA ONLY: SMCLK enable
|
77 |
80 |
olivier.gi |
|
78 |
|
|
// INPUTs
|
79 |
155 |
olivier.gi |
cpu_en, // Enable CPU code execution (asynchronous and non-glitchy)
|
80 |
|
|
dbg_en, // Debug interface enable (asynchronous and non-glitchy)
|
81 |
|
|
dbg_i2c_addr, // Debug interface: I2C Address
|
82 |
|
|
dbg_i2c_broadcast, // Debug interface: I2C Broadcast Address (for multicore systems)
|
83 |
|
|
dbg_i2c_scl, // Debug interface: I2C SCL
|
84 |
|
|
dbg_i2c_sda_in, // Debug interface: I2C SDA IN
|
85 |
|
|
dbg_uart_rxd, // Debug interface: UART RXD (asynchronous)
|
86 |
|
|
dco_clk, // Fast oscillator (fast clock)
|
87 |
|
|
dmem_dout, // Data Memory data output
|
88 |
|
|
irq, // Maskable interrupts
|
89 |
|
|
lfxt_clk, // Low frequency oscillator (typ 32kHz)
|
90 |
|
|
nmi, // Non-maskable interrupt (asynchronous)
|
91 |
|
|
per_dout, // Peripheral data output
|
92 |
|
|
pmem_dout, // Program Memory data output
|
93 |
|
|
reset_n, // Reset Pin (low active, asynchronous and non-glitchy)
|
94 |
|
|
scan_enable, // ASIC ONLY: Scan enable (active during scan shifting)
|
95 |
|
|
scan_mode, // ASIC ONLY: Scan mode
|
96 |
|
|
wkup // ASIC ONLY: System Wake-up (asynchronous and non-glitchy)
|
97 |
80 |
olivier.gi |
);
|
98 |
|
|
|
99 |
155 |
olivier.gi |
// PARAMETERs
|
100 |
|
|
//============
|
101 |
|
|
parameter INST_NR = 8'h00; // Current oMSP instance number (for multicore systems)
|
102 |
|
|
parameter TOTAL_NR = 8'h00; // Total number of oMSP instances-1 (for multicore systems)
|
103 |
|
|
|
104 |
80 |
olivier.gi |
// OUTPUTs
|
105 |
155 |
olivier.gi |
//============
|
106 |
|
|
output aclk; // ASIC ONLY: ACLK
|
107 |
|
|
output aclk_en; // FPGA ONLY: ACLK enable
|
108 |
|
|
output dbg_freeze; // Freeze peripherals
|
109 |
|
|
output dbg_i2c_sda_out; // Debug interface: I2C SDA OUT
|
110 |
|
|
output dbg_uart_txd; // Debug interface: UART TXD
|
111 |
|
|
output dco_enable; // ASIC ONLY: Fast oscillator enable
|
112 |
|
|
output dco_wkup; // ASIC ONLY: Fast oscillator wake-up (asynchronous)
|
113 |
|
|
output [`DMEM_MSB:0] dmem_addr; // Data Memory address
|
114 |
|
|
output dmem_cen; // Data Memory chip enable (low active)
|
115 |
|
|
output [15:0] dmem_din; // Data Memory data input
|
116 |
|
|
output [1:0] dmem_wen; // Data Memory write enable (low active)
|
117 |
|
|
output [13:0] irq_acc; // Interrupt request accepted (one-hot signal)
|
118 |
|
|
output lfxt_enable; // ASIC ONLY: Low frequency oscillator enable
|
119 |
|
|
output lfxt_wkup; // ASIC ONLY: Low frequency oscillator wake-up (asynchronous)
|
120 |
|
|
output mclk; // Main system clock
|
121 |
|
|
output [13:0] per_addr; // Peripheral address
|
122 |
|
|
output [15:0] per_din; // Peripheral data input
|
123 |
|
|
output [1:0] per_we; // Peripheral write enable (high active)
|
124 |
|
|
output per_en; // Peripheral enable (high active)
|
125 |
|
|
output [`PMEM_MSB:0] pmem_addr; // Program Memory address
|
126 |
|
|
output pmem_cen; // Program Memory chip enable (low active)
|
127 |
|
|
output [15:0] pmem_din; // Program Memory data input (optional)
|
128 |
|
|
output [1:0] pmem_wen; // Program Memory write enable (low active) (optional)
|
129 |
|
|
output puc_rst; // Main system reset
|
130 |
|
|
output smclk; // ASIC ONLY: SMCLK
|
131 |
|
|
output smclk_en; // FPGA ONLY: SMCLK enable
|
132 |
80 |
olivier.gi |
|
133 |
|
|
|
134 |
|
|
// INPUTs
|
135 |
155 |
olivier.gi |
//============
|
136 |
|
|
input cpu_en; // Enable CPU code execution (asynchronous and non-glitchy)
|
137 |
|
|
input dbg_en; // Debug interface enable (asynchronous and non-glitchy)
|
138 |
|
|
input [6:0] dbg_i2c_addr; // Debug interface: I2C Address
|
139 |
|
|
input [6:0] dbg_i2c_broadcast; // Debug interface: I2C Broadcast Address (for multicore systems)
|
140 |
|
|
input dbg_i2c_scl; // Debug interface: I2C SCL
|
141 |
|
|
input dbg_i2c_sda_in; // Debug interface: I2C SDA IN
|
142 |
|
|
input dbg_uart_rxd; // Debug interface: UART RXD (asynchronous)
|
143 |
|
|
input dco_clk; // Fast oscillator (fast clock)
|
144 |
|
|
input [15:0] dmem_dout; // Data Memory data output
|
145 |
|
|
input [13:0] irq; // Maskable interrupts
|
146 |
|
|
input lfxt_clk; // Low frequency oscillator (typ 32kHz)
|
147 |
|
|
input nmi; // Non-maskable interrupt (asynchronous and non-glitchy)
|
148 |
|
|
input [15:0] per_dout; // Peripheral data output
|
149 |
|
|
input [15:0] pmem_dout; // Program Memory data output
|
150 |
|
|
input reset_n; // Reset Pin (active low, asynchronous and non-glitchy)
|
151 |
|
|
input scan_enable; // ASIC ONLY: Scan enable (active during scan shifting)
|
152 |
|
|
input scan_mode; // ASIC ONLY: Scan mode
|
153 |
|
|
input wkup; // ASIC ONLY: System Wake-up (asynchronous and non-glitchy)
|
154 |
80 |
olivier.gi |
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
//=============================================================================
|
158 |
|
|
// 1) INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
|
159 |
|
|
//=============================================================================
|
160 |
|
|
|
161 |
|
|
wire [7:0] inst_ad;
|
162 |
|
|
wire [7:0] inst_as;
|
163 |
|
|
wire [11:0] inst_alu;
|
164 |
|
|
wire inst_bw;
|
165 |
111 |
olivier.gi |
wire inst_irq_rst;
|
166 |
|
|
wire inst_mov;
|
167 |
80 |
olivier.gi |
wire [15:0] inst_dest;
|
168 |
|
|
wire [15:0] inst_dext;
|
169 |
|
|
wire [15:0] inst_sext;
|
170 |
|
|
wire [7:0] inst_so;
|
171 |
|
|
wire [15:0] inst_src;
|
172 |
|
|
wire [2:0] inst_type;
|
173 |
111 |
olivier.gi |
wire [7:0] inst_jmp;
|
174 |
80 |
olivier.gi |
wire [3:0] e_state;
|
175 |
|
|
wire exec_done;
|
176 |
111 |
olivier.gi |
wire decode_noirq;
|
177 |
|
|
wire cpu_en_s;
|
178 |
|
|
wire cpuoff;
|
179 |
|
|
wire oscoff;
|
180 |
136 |
olivier.gi |
wire scg0;
|
181 |
111 |
olivier.gi |
wire scg1;
|
182 |
|
|
wire por;
|
183 |
|
|
wire gie;
|
184 |
136 |
olivier.gi |
wire mclk_enable;
|
185 |
|
|
wire mclk_wkup;
|
186 |
|
|
wire [31:0] cpu_id;
|
187 |
155 |
olivier.gi |
wire [7:0] cpu_nr_inst = INST_NR;
|
188 |
|
|
wire [7:0] cpu_nr_total = TOTAL_NR;
|
189 |
|
|
|
190 |
80 |
olivier.gi |
wire [15:0] eu_mab;
|
191 |
|
|
wire [15:0] eu_mdb_in;
|
192 |
|
|
wire [15:0] eu_mdb_out;
|
193 |
|
|
wire [1:0] eu_mb_wr;
|
194 |
111 |
olivier.gi |
wire eu_mb_en;
|
195 |
80 |
olivier.gi |
wire [15:0] fe_mab;
|
196 |
|
|
wire [15:0] fe_mdb_in;
|
197 |
111 |
olivier.gi |
wire fe_mb_en;
|
198 |
|
|
wire fe_pmem_wait;
|
199 |
80 |
olivier.gi |
|
200 |
111 |
olivier.gi |
wire pc_sw_wr;
|
201 |
80 |
olivier.gi |
wire [15:0] pc_sw;
|
202 |
|
|
wire [15:0] pc;
|
203 |
|
|
wire [15:0] pc_nxt;
|
204 |
|
|
|
205 |
111 |
olivier.gi |
wire nmi_acc;
|
206 |
136 |
olivier.gi |
wire nmi_pnd;
|
207 |
|
|
wire nmi_wkup;
|
208 |
111 |
olivier.gi |
|
209 |
|
|
wire wdtie;
|
210 |
136 |
olivier.gi |
wire wdtnmies;
|
211 |
|
|
wire wdtifg;
|
212 |
111 |
olivier.gi |
wire wdt_irq;
|
213 |
136 |
olivier.gi |
wire wdt_wkup;
|
214 |
111 |
olivier.gi |
wire wdt_reset;
|
215 |
136 |
olivier.gi |
wire wdtifg_sw_clr;
|
216 |
|
|
wire wdtifg_sw_set;
|
217 |
111 |
olivier.gi |
|
218 |
|
|
wire dbg_clk;
|
219 |
|
|
wire dbg_rst;
|
220 |
|
|
wire dbg_en_s;
|
221 |
|
|
wire dbg_halt_st;
|
222 |
86 |
olivier.gi |
wire dbg_halt_cmd;
|
223 |
|
|
wire dbg_mem_en;
|
224 |
|
|
wire dbg_reg_wr;
|
225 |
107 |
olivier.gi |
wire dbg_cpu_reset;
|
226 |
80 |
olivier.gi |
wire [15:0] dbg_mem_addr;
|
227 |
|
|
wire [15:0] dbg_mem_dout;
|
228 |
|
|
wire [15:0] dbg_mem_din;
|
229 |
|
|
wire [15:0] dbg_reg_din;
|
230 |
|
|
wire [1:0] dbg_mem_wr;
|
231 |
136 |
olivier.gi |
wire puc_pnd_set;
|
232 |
|
|
|
233 |
80 |
olivier.gi |
wire [15:0] per_dout_or;
|
234 |
|
|
wire [15:0] per_dout_sfr;
|
235 |
|
|
wire [15:0] per_dout_wdog;
|
236 |
|
|
wire [15:0] per_dout_mpy;
|
237 |
|
|
wire [15:0] per_dout_clk;
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
//=============================================================================
|
241 |
|
|
// 2) GLOBAL CLOCK & RESET MANAGEMENT
|
242 |
|
|
//=============================================================================
|
243 |
|
|
|
244 |
|
|
omsp_clock_module clock_module_0 (
|
245 |
|
|
|
246 |
|
|
// OUTPUTs
|
247 |
136 |
olivier.gi |
.aclk (aclk), // ACLK
|
248 |
80 |
olivier.gi |
.aclk_en (aclk_en), // ACLK enablex
|
249 |
107 |
olivier.gi |
.cpu_en_s (cpu_en_s), // Enable CPU code execution (synchronous)
|
250 |
|
|
.dbg_clk (dbg_clk), // Debug unit clock
|
251 |
|
|
.dbg_en_s (dbg_en_s), // Debug interface enable (synchronous)
|
252 |
|
|
.dbg_rst (dbg_rst), // Debug unit reset
|
253 |
136 |
olivier.gi |
.dco_enable (dco_enable), // Fast oscillator enable
|
254 |
|
|
.dco_wkup (dco_wkup), // Fast oscillator wake-up (asynchronous)
|
255 |
|
|
.lfxt_enable (lfxt_enable), // Low frequency oscillator enable
|
256 |
|
|
.lfxt_wkup (lfxt_wkup), // Low frequency oscillator wake-up (asynchronous)
|
257 |
80 |
olivier.gi |
.mclk (mclk), // Main system clock
|
258 |
|
|
.per_dout (per_dout_clk), // Peripheral data output
|
259 |
|
|
.por (por), // Power-on reset
|
260 |
136 |
olivier.gi |
.puc_pnd_set (puc_pnd_set), // PUC pending set for the serial debug interface
|
261 |
111 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
262 |
136 |
olivier.gi |
.smclk (smclk), // SMCLK
|
263 |
80 |
olivier.gi |
.smclk_en (smclk_en), // SMCLK enable
|
264 |
|
|
|
265 |
|
|
// INPUTs
|
266 |
107 |
olivier.gi |
.cpu_en (cpu_en), // Enable CPU code execution (asynchronous)
|
267 |
136 |
olivier.gi |
.cpuoff (cpuoff), // Turns off the CPU
|
268 |
107 |
olivier.gi |
.dbg_cpu_reset(dbg_cpu_reset), // Reset CPU from debug interface
|
269 |
|
|
.dbg_en (dbg_en), // Debug interface enable (asynchronous)
|
270 |
80 |
olivier.gi |
.dco_clk (dco_clk), // Fast oscillator (fast clock)
|
271 |
|
|
.lfxt_clk (lfxt_clk), // Low frequency oscillator (typ 32kHz)
|
272 |
136 |
olivier.gi |
.mclk_enable (mclk_enable), // Main System Clock enable
|
273 |
|
|
.mclk_wkup (mclk_wkup), // Main System Clock wake-up (asynchronous)
|
274 |
80 |
olivier.gi |
.oscoff (oscoff), // Turns off LFXT1 clock input
|
275 |
|
|
.per_addr (per_addr), // Peripheral address
|
276 |
|
|
.per_din (per_din), // Peripheral data input
|
277 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
278 |
107 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
279 |
|
|
.reset_n (reset_n), // Reset Pin (low active, asynchronous)
|
280 |
136 |
olivier.gi |
.scan_enable (scan_enable), // Scan enable (active during scan shifting)
|
281 |
|
|
.scan_mode (scan_mode), // Scan mode
|
282 |
|
|
.scg0 (scg0), // System clock generator 1. Turns off the DCO
|
283 |
80 |
olivier.gi |
.scg1 (scg1), // System clock generator 1. Turns off the SMCLK
|
284 |
|
|
.wdt_reset (wdt_reset) // Watchdog-timer reset
|
285 |
|
|
);
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
//=============================================================================
|
289 |
|
|
// 3) FRONTEND (<=> FETCH & DECODE)
|
290 |
|
|
//=============================================================================
|
291 |
|
|
|
292 |
|
|
omsp_frontend frontend_0 (
|
293 |
|
|
|
294 |
|
|
// OUTPUTs
|
295 |
|
|
.dbg_halt_st (dbg_halt_st), // Halt/Run status from CPU
|
296 |
|
|
.decode_noirq (decode_noirq), // Frontend decode instruction
|
297 |
|
|
.e_state (e_state), // Execution state
|
298 |
|
|
.exec_done (exec_done), // Execution completed
|
299 |
|
|
.inst_ad (inst_ad), // Decoded Inst: destination addressing mode
|
300 |
|
|
.inst_as (inst_as), // Decoded Inst: source addressing mode
|
301 |
|
|
.inst_alu (inst_alu), // ALU control signals
|
302 |
|
|
.inst_bw (inst_bw), // Decoded Inst: byte width
|
303 |
|
|
.inst_dest (inst_dest), // Decoded Inst: destination (one hot)
|
304 |
|
|
.inst_dext (inst_dext), // Decoded Inst: destination extended instruction word
|
305 |
|
|
.inst_irq_rst (inst_irq_rst), // Decoded Inst: Reset interrupt
|
306 |
|
|
.inst_jmp (inst_jmp), // Decoded Inst: Conditional jump
|
307 |
105 |
olivier.gi |
.inst_mov (inst_mov), // Decoded Inst: mov instruction
|
308 |
80 |
olivier.gi |
.inst_sext (inst_sext), // Decoded Inst: source extended instruction word
|
309 |
|
|
.inst_so (inst_so), // Decoded Inst: Single-operand arithmetic
|
310 |
|
|
.inst_src (inst_src), // Decoded Inst: source (one hot)
|
311 |
|
|
.inst_type (inst_type), // Decoded Instruction type
|
312 |
|
|
.irq_acc (irq_acc), // Interrupt request accepted
|
313 |
|
|
.mab (fe_mab), // Frontend Memory address bus
|
314 |
|
|
.mb_en (fe_mb_en), // Frontend Memory bus enable
|
315 |
136 |
olivier.gi |
.mclk_enable (mclk_enable), // Main System Clock enable
|
316 |
|
|
.mclk_wkup (mclk_wkup), // Main System Clock wake-up (asynchronous)
|
317 |
80 |
olivier.gi |
.nmi_acc (nmi_acc), // Non-Maskable interrupt request accepted
|
318 |
|
|
.pc (pc), // Program counter
|
319 |
|
|
.pc_nxt (pc_nxt), // Next PC value (for CALL & IRQ)
|
320 |
|
|
|
321 |
|
|
// INPUTs
|
322 |
107 |
olivier.gi |
.cpu_en_s (cpu_en_s), // Enable CPU code execution (synchronous)
|
323 |
80 |
olivier.gi |
.cpuoff (cpuoff), // Turns off the CPU
|
324 |
|
|
.dbg_halt_cmd (dbg_halt_cmd), // Halt CPU command
|
325 |
|
|
.dbg_reg_sel (dbg_mem_addr[3:0]), // Debug selected register for rd/wr access
|
326 |
|
|
.fe_pmem_wait (fe_pmem_wait), // Frontend wait for Instruction fetch
|
327 |
|
|
.gie (gie), // General interrupt enable
|
328 |
|
|
.irq (irq), // Maskable interrupts
|
329 |
|
|
.mclk (mclk), // Main system clock
|
330 |
|
|
.mdb_in (fe_mdb_in), // Frontend Memory data bus input
|
331 |
136 |
olivier.gi |
.nmi_pnd (nmi_pnd), // Non-maskable interrupt pending
|
332 |
|
|
.nmi_wkup (nmi_wkup), // NMI Wakeup
|
333 |
80 |
olivier.gi |
.pc_sw (pc_sw), // Program counter software value
|
334 |
|
|
.pc_sw_wr (pc_sw_wr), // Program counter software write
|
335 |
111 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
336 |
136 |
olivier.gi |
.scan_enable (scan_enable), // Scan enable (active during scan shifting)
|
337 |
|
|
.wdt_irq (wdt_irq), // Watchdog-timer interrupt
|
338 |
|
|
.wdt_wkup (wdt_wkup), // Watchdog Wakeup
|
339 |
|
|
.wkup (wkup) // System Wake-up (asynchronous)
|
340 |
80 |
olivier.gi |
);
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
//=============================================================================
|
344 |
|
|
// 4) EXECUTION UNIT
|
345 |
|
|
//=============================================================================
|
346 |
|
|
|
347 |
|
|
omsp_execution_unit execution_unit_0 (
|
348 |
|
|
|
349 |
|
|
// OUTPUTs
|
350 |
|
|
.cpuoff (cpuoff), // Turns off the CPU
|
351 |
|
|
.dbg_reg_din (dbg_reg_din), // Debug unit CPU register data input
|
352 |
|
|
.mab (eu_mab), // Memory address bus
|
353 |
|
|
.mb_en (eu_mb_en), // Memory bus enable
|
354 |
|
|
.mb_wr (eu_mb_wr), // Memory bus write transfer
|
355 |
|
|
.mdb_out (eu_mdb_out), // Memory data bus output
|
356 |
|
|
.oscoff (oscoff), // Turns off LFXT1 clock input
|
357 |
|
|
.pc_sw (pc_sw), // Program counter software value
|
358 |
|
|
.pc_sw_wr (pc_sw_wr), // Program counter software write
|
359 |
136 |
olivier.gi |
.scg0 (scg0), // System clock generator 1. Turns off the DCO
|
360 |
80 |
olivier.gi |
.scg1 (scg1), // System clock generator 1. Turns off the SMCLK
|
361 |
|
|
|
362 |
|
|
// INPUTs
|
363 |
|
|
.dbg_halt_st (dbg_halt_st), // Halt/Run status from CPU
|
364 |
|
|
.dbg_mem_dout (dbg_mem_dout), // Debug unit data output
|
365 |
|
|
.dbg_reg_wr (dbg_reg_wr), // Debug unit CPU register write
|
366 |
|
|
.e_state (e_state), // Execution state
|
367 |
|
|
.exec_done (exec_done), // Execution completed
|
368 |
|
|
.gie (gie), // General interrupt enable
|
369 |
|
|
.inst_ad (inst_ad), // Decoded Inst: destination addressing mode
|
370 |
|
|
.inst_as (inst_as), // Decoded Inst: source addressing mode
|
371 |
|
|
.inst_alu (inst_alu), // ALU control signals
|
372 |
|
|
.inst_bw (inst_bw), // Decoded Inst: byte width
|
373 |
|
|
.inst_dest (inst_dest), // Decoded Inst: destination (one hot)
|
374 |
|
|
.inst_dext (inst_dext), // Decoded Inst: destination extended instruction word
|
375 |
|
|
.inst_irq_rst (inst_irq_rst), // Decoded Inst: reset interrupt
|
376 |
|
|
.inst_jmp (inst_jmp), // Decoded Inst: Conditional jump
|
377 |
105 |
olivier.gi |
.inst_mov (inst_mov), // Decoded Inst: mov instruction
|
378 |
80 |
olivier.gi |
.inst_sext (inst_sext), // Decoded Inst: source extended instruction word
|
379 |
|
|
.inst_so (inst_so), // Decoded Inst: Single-operand arithmetic
|
380 |
|
|
.inst_src (inst_src), // Decoded Inst: source (one hot)
|
381 |
|
|
.inst_type (inst_type), // Decoded Instruction type
|
382 |
|
|
.mclk (mclk), // Main system clock
|
383 |
|
|
.mdb_in (eu_mdb_in), // Memory data bus input
|
384 |
|
|
.pc (pc), // Program counter
|
385 |
|
|
.pc_nxt (pc_nxt), // Next PC value (for CALL & IRQ)
|
386 |
136 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
387 |
|
|
.scan_enable (scan_enable) // Scan enable (active during scan shifting)
|
388 |
80 |
olivier.gi |
);
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
//=============================================================================
|
392 |
|
|
// 5) MEMORY BACKBONE
|
393 |
|
|
//=============================================================================
|
394 |
|
|
|
395 |
|
|
omsp_mem_backbone mem_backbone_0 (
|
396 |
|
|
|
397 |
|
|
// OUTPUTs
|
398 |
|
|
.dbg_mem_din (dbg_mem_din), // Debug unit Memory data input
|
399 |
|
|
.dmem_addr (dmem_addr), // Data Memory address
|
400 |
|
|
.dmem_cen (dmem_cen), // Data Memory chip enable (low active)
|
401 |
|
|
.dmem_din (dmem_din), // Data Memory data input
|
402 |
|
|
.dmem_wen (dmem_wen), // Data Memory write enable (low active)
|
403 |
|
|
.eu_mdb_in (eu_mdb_in), // Execution Unit Memory data bus input
|
404 |
|
|
.fe_mdb_in (fe_mdb_in), // Frontend Memory data bus input
|
405 |
|
|
.fe_pmem_wait (fe_pmem_wait), // Frontend wait for Instruction fetch
|
406 |
|
|
.per_addr (per_addr), // Peripheral address
|
407 |
|
|
.per_din (per_din), // Peripheral data input
|
408 |
107 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
409 |
80 |
olivier.gi |
.per_en (per_en), // Peripheral enable (high active)
|
410 |
|
|
.pmem_addr (pmem_addr), // Program Memory address
|
411 |
|
|
.pmem_cen (pmem_cen), // Program Memory chip enable (low active)
|
412 |
|
|
.pmem_din (pmem_din), // Program Memory data input (optional)
|
413 |
|
|
.pmem_wen (pmem_wen), // Program Memory write enable (low active) (optional)
|
414 |
|
|
|
415 |
|
|
// INPUTs
|
416 |
|
|
.dbg_halt_st (dbg_halt_st), // Halt/Run status from CPU
|
417 |
|
|
.dbg_mem_addr (dbg_mem_addr), // Debug address for rd/wr access
|
418 |
|
|
.dbg_mem_dout (dbg_mem_dout), // Debug unit data output
|
419 |
|
|
.dbg_mem_en (dbg_mem_en), // Debug unit memory enable
|
420 |
|
|
.dbg_mem_wr (dbg_mem_wr), // Debug unit memory write
|
421 |
|
|
.dmem_dout (dmem_dout), // Data Memory data output
|
422 |
|
|
.eu_mab (eu_mab[15:1]), // Execution Unit Memory address bus
|
423 |
|
|
.eu_mb_en (eu_mb_en), // Execution Unit Memory bus enable
|
424 |
|
|
.eu_mb_wr (eu_mb_wr), // Execution Unit Memory bus write transfer
|
425 |
|
|
.eu_mdb_out (eu_mdb_out), // Execution Unit Memory data bus output
|
426 |
|
|
.fe_mab (fe_mab[15:1]), // Frontend Memory address bus
|
427 |
|
|
.fe_mb_en (fe_mb_en), // Frontend Memory bus enable
|
428 |
|
|
.mclk (mclk), // Main system clock
|
429 |
|
|
.per_dout (per_dout_or), // Peripheral data output
|
430 |
|
|
.pmem_dout (pmem_dout), // Program Memory data output
|
431 |
136 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
432 |
|
|
.scan_enable (scan_enable) // Scan enable (active during scan shifting)
|
433 |
80 |
olivier.gi |
);
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
//=============================================================================
|
437 |
|
|
// 6) SPECIAL FUNCTION REGISTERS
|
438 |
|
|
//=============================================================================
|
439 |
|
|
omsp_sfr sfr_0 (
|
440 |
|
|
|
441 |
|
|
// OUTPUTs
|
442 |
136 |
olivier.gi |
.cpu_id (cpu_id), // CPU ID
|
443 |
|
|
.nmi_pnd (nmi_pnd), // NMI Pending
|
444 |
|
|
.nmi_wkup (nmi_wkup), // NMI Wakeup
|
445 |
80 |
olivier.gi |
.per_dout (per_dout_sfr), // Peripheral data output
|
446 |
|
|
.wdtie (wdtie), // Watchdog-timer interrupt enable
|
447 |
136 |
olivier.gi |
.wdtifg_sw_clr(wdtifg_sw_clr), // Watchdog-timer interrupt flag software clear
|
448 |
|
|
.wdtifg_sw_set(wdtifg_sw_set), // Watchdog-timer interrupt flag software set
|
449 |
80 |
olivier.gi |
|
450 |
|
|
// INPUTs
|
451 |
155 |
olivier.gi |
.cpu_nr_inst (cpu_nr_inst), // Current oMSP instance number
|
452 |
|
|
.cpu_nr_total (cpu_nr_total), // Total number of oMSP instances-1
|
453 |
80 |
olivier.gi |
.mclk (mclk), // Main system clock
|
454 |
136 |
olivier.gi |
.nmi (nmi), // Non-maskable interrupt (asynchronous)
|
455 |
80 |
olivier.gi |
.nmi_acc (nmi_acc), // Non-Maskable interrupt request accepted
|
456 |
|
|
.per_addr (per_addr), // Peripheral address
|
457 |
|
|
.per_din (per_din), // Peripheral data input
|
458 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
459 |
107 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
460 |
111 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
461 |
136 |
olivier.gi |
.scan_mode (scan_mode), // Scan mode
|
462 |
|
|
.wdtifg (wdtifg), // Watchdog-timer interrupt flag
|
463 |
|
|
.wdtnmies (wdtnmies) // Watchdog-timer NMI edge selection
|
464 |
80 |
olivier.gi |
);
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
//=============================================================================
|
468 |
|
|
// 7) WATCHDOG TIMER
|
469 |
|
|
//=============================================================================
|
470 |
136 |
olivier.gi |
`ifdef WATCHDOG
|
471 |
80 |
olivier.gi |
omsp_watchdog watchdog_0 (
|
472 |
|
|
|
473 |
|
|
// OUTPUTs
|
474 |
136 |
olivier.gi |
.per_dout (per_dout_wdog), // Peripheral data output
|
475 |
|
|
.wdt_irq (wdt_irq), // Watchdog-timer interrupt
|
476 |
|
|
.wdt_reset (wdt_reset), // Watchdog-timer reset
|
477 |
|
|
.wdt_wkup (wdt_wkup), // Watchdog Wakeup
|
478 |
|
|
.wdtifg (wdtifg), // Watchdog-timer interrupt flag
|
479 |
|
|
.wdtnmies (wdtnmies), // Watchdog-timer NMI edge selection
|
480 |
80 |
olivier.gi |
|
481 |
|
|
// INPUTs
|
482 |
136 |
olivier.gi |
.aclk (aclk), // ACLK
|
483 |
|
|
.aclk_en (aclk_en), // ACLK enable
|
484 |
|
|
.dbg_freeze (dbg_freeze), // Freeze Watchdog counter
|
485 |
|
|
.mclk (mclk), // Main system clock
|
486 |
|
|
.per_addr (per_addr), // Peripheral address
|
487 |
|
|
.per_din (per_din), // Peripheral data input
|
488 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
489 |
|
|
.per_we (per_we), // Peripheral write enable (high active)
|
490 |
|
|
.por (por), // Power-on reset
|
491 |
|
|
.puc_rst (puc_rst), // Main system reset
|
492 |
|
|
.scan_enable (scan_enable), // Scan enable (active during scan shifting)
|
493 |
|
|
.scan_mode (scan_mode), // Scan mode
|
494 |
|
|
.smclk (smclk), // SMCLK
|
495 |
|
|
.smclk_en (smclk_en), // SMCLK enable
|
496 |
|
|
.wdtie (wdtie), // Watchdog-timer interrupt enable
|
497 |
|
|
.wdtifg_irq_clr (irq_acc[10]), // Clear Watchdog-timer interrupt flag
|
498 |
|
|
.wdtifg_sw_clr (wdtifg_sw_clr), // Watchdog-timer interrupt flag software clear
|
499 |
|
|
.wdtifg_sw_set (wdtifg_sw_set) // Watchdog-timer interrupt flag software set
|
500 |
80 |
olivier.gi |
);
|
501 |
136 |
olivier.gi |
`else
|
502 |
|
|
assign per_dout_wdog = 16'h0000;
|
503 |
|
|
assign wdt_irq = 1'b0;
|
504 |
|
|
assign wdt_reset = 1'b0;
|
505 |
|
|
assign wdt_wkup = 1'b0;
|
506 |
|
|
assign wdtifg = 1'b0;
|
507 |
|
|
assign wdtnmies = 1'b0;
|
508 |
|
|
`endif
|
509 |
80 |
olivier.gi |
|
510 |
|
|
|
511 |
|
|
//=============================================================================
|
512 |
|
|
// 8) HARDWARE MULTIPLIER
|
513 |
|
|
//=============================================================================
|
514 |
|
|
`ifdef MULTIPLIER
|
515 |
|
|
omsp_multiplier multiplier_0 (
|
516 |
|
|
|
517 |
|
|
// OUTPUTs
|
518 |
|
|
.per_dout (per_dout_mpy), // Peripheral data output
|
519 |
|
|
|
520 |
|
|
// INPUTs
|
521 |
|
|
.mclk (mclk), // Main system clock
|
522 |
|
|
.per_addr (per_addr), // Peripheral address
|
523 |
|
|
.per_din (per_din), // Peripheral data input
|
524 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
525 |
107 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
526 |
136 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
527 |
|
|
.scan_enable (scan_enable) // Scan enable (active during scan shifting)
|
528 |
80 |
olivier.gi |
);
|
529 |
|
|
`else
|
530 |
|
|
assign per_dout_mpy = 16'h0000;
|
531 |
|
|
`endif
|
532 |
|
|
|
533 |
|
|
//=============================================================================
|
534 |
|
|
// 9) PERIPHERALS' OUTPUT BUS
|
535 |
|
|
//=============================================================================
|
536 |
|
|
|
537 |
|
|
assign per_dout_or = per_dout |
|
538 |
|
|
per_dout_clk |
|
539 |
|
|
per_dout_sfr |
|
540 |
|
|
per_dout_wdog |
|
541 |
|
|
per_dout_mpy;
|
542 |
|
|
|
543 |
|
|
|
544 |
|
|
//=============================================================================
|
545 |
|
|
// 10) DEBUG INTERFACE
|
546 |
|
|
//=============================================================================
|
547 |
|
|
|
548 |
|
|
`ifdef DBG_EN
|
549 |
|
|
omsp_dbg dbg_0 (
|
550 |
|
|
|
551 |
|
|
// OUTPUTs
|
552 |
155 |
olivier.gi |
.dbg_cpu_reset (dbg_cpu_reset), // Reset CPU from debug interface
|
553 |
|
|
.dbg_freeze (dbg_freeze), // Freeze peripherals
|
554 |
|
|
.dbg_halt_cmd (dbg_halt_cmd), // Halt CPU command
|
555 |
|
|
.dbg_i2c_sda_out (dbg_i2c_sda_out), // Debug interface: I2C SDA OUT
|
556 |
|
|
.dbg_mem_addr (dbg_mem_addr), // Debug address for rd/wr access
|
557 |
|
|
.dbg_mem_dout (dbg_mem_dout), // Debug unit data output
|
558 |
|
|
.dbg_mem_en (dbg_mem_en), // Debug unit memory enable
|
559 |
|
|
.dbg_mem_wr (dbg_mem_wr), // Debug unit memory write
|
560 |
|
|
.dbg_reg_wr (dbg_reg_wr), // Debug unit CPU register write
|
561 |
|
|
.dbg_uart_txd (dbg_uart_txd), // Debug interface: UART TXD
|
562 |
80 |
olivier.gi |
|
563 |
|
|
// INPUTs
|
564 |
155 |
olivier.gi |
.cpu_en_s (cpu_en_s), // Enable CPU code execution (synchronous)
|
565 |
|
|
.cpu_id (cpu_id), // CPU ID
|
566 |
|
|
.cpu_nr_inst (cpu_nr_inst), // Current oMSP instance number
|
567 |
|
|
.cpu_nr_total (cpu_nr_total), // Total number of oMSP instances-1
|
568 |
|
|
.dbg_clk (dbg_clk), // Debug unit clock
|
569 |
|
|
.dbg_en_s (dbg_en_s), // Debug interface enable (synchronous)
|
570 |
|
|
.dbg_halt_st (dbg_halt_st), // Halt/Run status from CPU
|
571 |
|
|
.dbg_i2c_addr (dbg_i2c_addr), // Debug interface: I2C Address
|
572 |
|
|
.dbg_i2c_broadcast (dbg_i2c_broadcast), // Debug interface: I2C Broadcast Address (for multicore systems)
|
573 |
|
|
.dbg_i2c_scl (dbg_i2c_scl), // Debug interface: I2C SCL
|
574 |
|
|
.dbg_i2c_sda_in (dbg_i2c_sda_in), // Debug interface: I2C SDA IN
|
575 |
|
|
.dbg_mem_din (dbg_mem_din), // Debug unit Memory data input
|
576 |
|
|
.dbg_reg_din (dbg_reg_din), // Debug unit CPU register data input
|
577 |
|
|
.dbg_rst (dbg_rst), // Debug unit reset
|
578 |
|
|
.dbg_uart_rxd (dbg_uart_rxd), // Debug interface: UART RXD (asynchronous)
|
579 |
|
|
.decode_noirq (decode_noirq), // Frontend decode instruction
|
580 |
|
|
.eu_mab (eu_mab), // Execution-Unit Memory address bus
|
581 |
|
|
.eu_mb_en (eu_mb_en), // Execution-Unit Memory bus enable
|
582 |
|
|
.eu_mb_wr (eu_mb_wr), // Execution-Unit Memory bus write transfer
|
583 |
|
|
.eu_mdb_in (eu_mdb_in), // Memory data bus input
|
584 |
|
|
.eu_mdb_out (eu_mdb_out), // Memory data bus output
|
585 |
|
|
.exec_done (exec_done), // Execution completed
|
586 |
|
|
.fe_mb_en (fe_mb_en), // Frontend Memory bus enable
|
587 |
|
|
.fe_mdb_in (fe_mdb_in), // Frontend Memory data bus input
|
588 |
|
|
.pc (pc), // Program counter
|
589 |
|
|
.puc_pnd_set (puc_pnd_set) // PUC pending set for the serial debug interface
|
590 |
80 |
olivier.gi |
);
|
591 |
|
|
|
592 |
|
|
`else
|
593 |
155 |
olivier.gi |
assign dbg_cpu_reset = 1'b0;
|
594 |
|
|
assign dbg_freeze = ~cpu_en_s;
|
595 |
|
|
assign dbg_halt_cmd = 1'b0;
|
596 |
|
|
assign dbg_i2c_sda_out = 1'b1;
|
597 |
|
|
assign dbg_mem_addr = 16'h0000;
|
598 |
|
|
assign dbg_mem_dout = 16'h0000;
|
599 |
|
|
assign dbg_mem_en = 1'b0;
|
600 |
|
|
assign dbg_mem_wr = 2'b00;
|
601 |
|
|
assign dbg_reg_wr = 1'b0;
|
602 |
|
|
assign dbg_uart_txd = 1'b1;
|
603 |
80 |
olivier.gi |
`endif
|
604 |
|
|
|
605 |
|
|
|
606 |
|
|
endmodule // openMSP430
|
607 |
|
|
|
608 |
104 |
olivier.gi |
`ifdef OMSP_NO_INCLUDE
|
609 |
|
|
`else
|
610 |
80 |
olivier.gi |
`include "openMSP430_undefines.v"
|
611 |
104 |
olivier.gi |
`endif
|