1 |
2 |
olivier.gi |
//----------------------------------------------------------------------------
|
2 |
117 |
olivier.gi |
// Copyright (C) 2009 , Olivier Girard
|
3 |
2 |
olivier.gi |
//
|
4 |
117 |
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 |
2 |
olivier.gi |
//
|
16 |
117 |
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 |
2 |
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 |
17 |
olivier.gi |
// $Rev: 175 $
|
40 |
|
|
// $LastChangedBy: olivier.girard $
|
41 |
|
|
// $LastChangedDate: 2013-01-30 22:21:42 +0100 (Wed, 30 Jan 2013) $
|
42 |
|
|
//----------------------------------------------------------------------------
|
43 |
103 |
olivier.gi |
`ifdef OMSP_NO_INCLUDE
|
44 |
|
|
`else
|
45 |
23 |
olivier.gi |
`include "openMSP430_defines.v"
|
46 |
103 |
olivier.gi |
`endif
|
47 |
2 |
olivier.gi |
|
48 |
|
|
module openMSP430 (
|
49 |
|
|
|
50 |
|
|
// OUTPUTs
|
51 |
154 |
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 |
2 |
olivier.gi |
|
78 |
|
|
// INPUTs
|
79 |
154 |
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 |
2 |
olivier.gi |
);
|
98 |
|
|
|
99 |
154 |
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 |
2 |
olivier.gi |
// OUTPUTs
|
105 |
154 |
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 |
2 |
olivier.gi |
|
133 |
|
|
|
134 |
|
|
// INPUTs
|
135 |
154 |
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 |
2 |
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 |
2 |
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 |
2 |
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 |
134 |
olivier.gi |
wire scg0;
|
181 |
111 |
olivier.gi |
wire scg1;
|
182 |
|
|
wire por;
|
183 |
|
|
wire gie;
|
184 |
134 |
olivier.gi |
wire mclk_enable;
|
185 |
|
|
wire mclk_wkup;
|
186 |
|
|
wire [31:0] cpu_id;
|
187 |
154 |
olivier.gi |
wire [7:0] cpu_nr_inst = INST_NR;
|
188 |
|
|
wire [7:0] cpu_nr_total = TOTAL_NR;
|
189 |
|
|
|
190 |
2 |
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 |
2 |
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 |
2 |
olivier.gi |
|
200 |
111 |
olivier.gi |
wire pc_sw_wr;
|
201 |
2 |
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 |
134 |
olivier.gi |
wire nmi_pnd;
|
207 |
|
|
wire nmi_wkup;
|
208 |
111 |
olivier.gi |
|
209 |
|
|
wire wdtie;
|
210 |
134 |
olivier.gi |
wire wdtnmies;
|
211 |
|
|
wire wdtifg;
|
212 |
111 |
olivier.gi |
wire wdt_irq;
|
213 |
134 |
olivier.gi |
wire wdt_wkup;
|
214 |
111 |
olivier.gi |
wire wdt_reset;
|
215 |
134 |
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 |
106 |
olivier.gi |
wire dbg_cpu_reset;
|
226 |
2 |
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 |
134 |
olivier.gi |
wire puc_pnd_set;
|
232 |
|
|
|
233 |
2 |
olivier.gi |
wire [15:0] per_dout_or;
|
234 |
|
|
wire [15:0] per_dout_sfr;
|
235 |
|
|
wire [15:0] per_dout_wdog;
|
236 |
67 |
olivier.gi |
wire [15:0] per_dout_mpy;
|
237 |
2 |
olivier.gi |
wire [15:0] per_dout_clk;
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
//=============================================================================
|
241 |
|
|
// 2) GLOBAL CLOCK & RESET MANAGEMENT
|
242 |
|
|
//=============================================================================
|
243 |
|
|
|
244 |
34 |
olivier.gi |
omsp_clock_module clock_module_0 (
|
245 |
2 |
olivier.gi |
|
246 |
|
|
// OUTPUTs
|
247 |
134 |
olivier.gi |
.aclk (aclk), // ACLK
|
248 |
2 |
olivier.gi |
.aclk_en (aclk_en), // ACLK enablex
|
249 |
106 |
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 |
134 |
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 |
2 |
olivier.gi |
.mclk (mclk), // Main system clock
|
258 |
|
|
.per_dout (per_dout_clk), // Peripheral data output
|
259 |
|
|
.por (por), // Power-on reset
|
260 |
134 |
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 |
134 |
olivier.gi |
.smclk (smclk), // SMCLK
|
263 |
2 |
olivier.gi |
.smclk_en (smclk_en), // SMCLK enable
|
264 |
|
|
|
265 |
|
|
// INPUTs
|
266 |
106 |
olivier.gi |
.cpu_en (cpu_en), // Enable CPU code execution (asynchronous)
|
267 |
134 |
olivier.gi |
.cpuoff (cpuoff), // Turns off the CPU
|
268 |
106 |
olivier.gi |
.dbg_cpu_reset(dbg_cpu_reset), // Reset CPU from debug interface
|
269 |
|
|
.dbg_en (dbg_en), // Debug interface enable (asynchronous)
|
270 |
2 |
olivier.gi |
.dco_clk (dco_clk), // Fast oscillator (fast clock)
|
271 |
|
|
.lfxt_clk (lfxt_clk), // Low frequency oscillator (typ 32kHz)
|
272 |
134 |
olivier.gi |
.mclk_enable (mclk_enable), // Main System Clock enable
|
273 |
|
|
.mclk_wkup (mclk_wkup), // Main System Clock wake-up (asynchronous)
|
274 |
2 |
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 |
106 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
279 |
|
|
.reset_n (reset_n), // Reset Pin (low active, asynchronous)
|
280 |
134 |
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 |
2 |
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 |
34 |
olivier.gi |
omsp_frontend frontend_0 (
|
293 |
2 |
olivier.gi |
|
294 |
|
|
// OUTPUTs
|
295 |
|
|
.dbg_halt_st (dbg_halt_st), // Halt/Run status from CPU
|
296 |
53 |
olivier.gi |
.decode_noirq (decode_noirq), // Frontend decode instruction
|
297 |
2 |
olivier.gi |
.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 |
2 |
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 |
134 |
olivier.gi |
.mclk_enable (mclk_enable), // Main System Clock enable
|
316 |
|
|
.mclk_wkup (mclk_wkup), // Main System Clock wake-up (asynchronous)
|
317 |
2 |
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 |
106 |
olivier.gi |
.cpu_en_s (cpu_en_s), // Enable CPU code execution (synchronous)
|
323 |
2 |
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 |
33 |
olivier.gi |
.fe_pmem_wait (fe_pmem_wait), // Frontend wait for Instruction fetch
|
327 |
2 |
olivier.gi |
.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 |
134 |
olivier.gi |
.nmi_pnd (nmi_pnd), // Non-maskable interrupt pending
|
332 |
|
|
.nmi_wkup (nmi_wkup), // NMI Wakeup
|
333 |
2 |
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 |
134 |
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 |
2 |
olivier.gi |
);
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
//=============================================================================
|
344 |
|
|
// 4) EXECUTION UNIT
|
345 |
|
|
//=============================================================================
|
346 |
|
|
|
347 |
34 |
olivier.gi |
omsp_execution_unit execution_unit_0 (
|
348 |
2 |
olivier.gi |
|
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 |
134 |
olivier.gi |
.scg0 (scg0), // System clock generator 1. Turns off the DCO
|
360 |
2 |
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 |
2 |
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 |
134 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
387 |
|
|
.scan_enable (scan_enable) // Scan enable (active during scan shifting)
|
388 |
2 |
olivier.gi |
);
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
//=============================================================================
|
392 |
|
|
// 5) MEMORY BACKBONE
|
393 |
|
|
//=============================================================================
|
394 |
|
|
|
395 |
34 |
olivier.gi |
omsp_mem_backbone mem_backbone_0 (
|
396 |
2 |
olivier.gi |
|
397 |
|
|
// OUTPUTs
|
398 |
|
|
.dbg_mem_din (dbg_mem_din), // Debug unit Memory data input
|
399 |
33 |
olivier.gi |
.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 |
2 |
olivier.gi |
.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 |
33 |
olivier.gi |
.fe_pmem_wait (fe_pmem_wait), // Frontend wait for Instruction fetch
|
406 |
2 |
olivier.gi |
.per_addr (per_addr), // Peripheral address
|
407 |
|
|
.per_din (per_din), // Peripheral data input
|
408 |
106 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
409 |
2 |
olivier.gi |
.per_en (per_en), // Peripheral enable (high active)
|
410 |
33 |
olivier.gi |
.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 |
2 |
olivier.gi |
|
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 |
33 |
olivier.gi |
.dmem_dout (dmem_dout), // Data Memory data output
|
422 |
2 |
olivier.gi |
.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 |
33 |
olivier.gi |
.pmem_dout (pmem_dout), // Program Memory data output
|
431 |
134 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
432 |
|
|
.scan_enable (scan_enable) // Scan enable (active during scan shifting)
|
433 |
2 |
olivier.gi |
);
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
//=============================================================================
|
437 |
|
|
// 6) SPECIAL FUNCTION REGISTERS
|
438 |
|
|
//=============================================================================
|
439 |
34 |
olivier.gi |
omsp_sfr sfr_0 (
|
440 |
2 |
olivier.gi |
|
441 |
|
|
// OUTPUTs
|
442 |
134 |
olivier.gi |
.cpu_id (cpu_id), // CPU ID
|
443 |
|
|
.nmi_pnd (nmi_pnd), // NMI Pending
|
444 |
|
|
.nmi_wkup (nmi_wkup), // NMI Wakeup
|
445 |
2 |
olivier.gi |
.per_dout (per_dout_sfr), // Peripheral data output
|
446 |
|
|
.wdtie (wdtie), // Watchdog-timer interrupt enable
|
447 |
134 |
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 |
2 |
olivier.gi |
|
450 |
|
|
// INPUTs
|
451 |
154 |
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 |
2 |
olivier.gi |
.mclk (mclk), // Main system clock
|
454 |
134 |
olivier.gi |
.nmi (nmi), // Non-maskable interrupt (asynchronous)
|
455 |
2 |
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 |
106 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
460 |
111 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
461 |
134 |
olivier.gi |
.scan_mode (scan_mode), // Scan mode
|
462 |
|
|
.wdtifg (wdtifg), // Watchdog-timer interrupt flag
|
463 |
|
|
.wdtnmies (wdtnmies) // Watchdog-timer NMI edge selection
|
464 |
2 |
olivier.gi |
);
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
//=============================================================================
|
468 |
|
|
// 7) WATCHDOG TIMER
|
469 |
|
|
//=============================================================================
|
470 |
134 |
olivier.gi |
`ifdef WATCHDOG
|
471 |
34 |
olivier.gi |
omsp_watchdog watchdog_0 (
|
472 |
2 |
olivier.gi |
|
473 |
|
|
// OUTPUTs
|
474 |
134 |
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 |
2 |
olivier.gi |
|
481 |
|
|
// INPUTs
|
482 |
134 |
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 |
2 |
olivier.gi |
);
|
501 |
134 |
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 |
2 |
olivier.gi |
|
510 |
|
|
|
511 |
|
|
//=============================================================================
|
512 |
67 |
olivier.gi |
// 8) HARDWARE MULTIPLIER
|
513 |
2 |
olivier.gi |
//=============================================================================
|
514 |
67 |
olivier.gi |
`ifdef MULTIPLIER
|
515 |
|
|
omsp_multiplier multiplier_0 (
|
516 |
2 |
olivier.gi |
|
517 |
67 |
olivier.gi |
// 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 |
106 |
olivier.gi |
.per_we (per_we), // Peripheral write enable (high active)
|
526 |
134 |
olivier.gi |
.puc_rst (puc_rst), // Main system reset
|
527 |
|
|
.scan_enable (scan_enable) // Scan enable (active during scan shifting)
|
528 |
67 |
olivier.gi |
);
|
529 |
|
|
`else
|
530 |
|
|
assign per_dout_mpy = 16'h0000;
|
531 |
|
|
`endif
|
532 |
|
|
|
533 |
|
|
//=============================================================================
|
534 |
|
|
// 9) PERIPHERALS' OUTPUT BUS
|
535 |
|
|
//=============================================================================
|
536 |
|
|
|
537 |
2 |
olivier.gi |
assign per_dout_or = per_dout |
|
538 |
|
|
per_dout_clk |
|
539 |
|
|
per_dout_sfr |
|
540 |
67 |
olivier.gi |
per_dout_wdog |
|
541 |
|
|
per_dout_mpy;
|
542 |
2 |
olivier.gi |
|
543 |
|
|
|
544 |
|
|
//=============================================================================
|
545 |
67 |
olivier.gi |
// 10) DEBUG INTERFACE
|
546 |
2 |
olivier.gi |
//=============================================================================
|
547 |
|
|
|
548 |
|
|
`ifdef DBG_EN
|
549 |
34 |
olivier.gi |
omsp_dbg dbg_0 (
|
550 |
2 |
olivier.gi |
|
551 |
|
|
// OUTPUTs
|
552 |
154 |
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 |
2 |
olivier.gi |
|
563 |
|
|
// INPUTs
|
564 |
154 |
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 |
|
|
.fe_mdb_in (fe_mdb_in), // Frontend Memory data bus input
|
584 |
|
|
.pc (pc), // Program counter
|
585 |
|
|
.puc_pnd_set (puc_pnd_set) // PUC pending set for the serial debug interface
|
586 |
2 |
olivier.gi |
);
|
587 |
|
|
|
588 |
|
|
`else
|
589 |
154 |
olivier.gi |
assign dbg_cpu_reset = 1'b0;
|
590 |
|
|
assign dbg_freeze = ~cpu_en_s;
|
591 |
|
|
assign dbg_halt_cmd = 1'b0;
|
592 |
|
|
assign dbg_i2c_sda_out = 1'b1;
|
593 |
|
|
assign dbg_mem_addr = 16'h0000;
|
594 |
|
|
assign dbg_mem_dout = 16'h0000;
|
595 |
|
|
assign dbg_mem_en = 1'b0;
|
596 |
|
|
assign dbg_mem_wr = 2'b00;
|
597 |
|
|
assign dbg_reg_wr = 1'b0;
|
598 |
|
|
assign dbg_uart_txd = 1'b1;
|
599 |
2 |
olivier.gi |
`endif
|
600 |
|
|
|
601 |
|
|
|
602 |
|
|
endmodule // openMSP430
|
603 |
|
|
|
604 |
103 |
olivier.gi |
`ifdef OMSP_NO_INCLUDE
|
605 |
|
|
`else
|
606 |
33 |
olivier.gi |
`include "openMSP430_undefines.v"
|
607 |
103 |
olivier.gi |
`endif
|