| 1 |
64 |
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 |
|
|
|
| 41 |
|
|
module openMSP430_fpga (
|
| 42 |
|
|
|
| 43 |
|
|
// OUTPUTs
|
| 44 |
|
|
aclk_en, // ACLK enable
|
| 45 |
|
|
dbg_freeze, // Freeze peripherals
|
| 46 |
|
|
dbg_uart_txd, // Debug interface: UART TXD
|
| 47 |
|
|
irq_acc, // Interrupt request accepted (one-hot signal)
|
| 48 |
|
|
per_addr, // Peripheral address
|
| 49 |
|
|
per_din, // Peripheral data input
|
| 50 |
|
|
per_wen, // Peripheral write enable (high active)
|
| 51 |
|
|
per_en, // Peripheral enable (high active)
|
| 52 |
|
|
smclk_en, // SMCLK enable
|
| 53 |
|
|
|
| 54 |
|
|
// INPUTs
|
| 55 |
|
|
dbg_uart_rxd, // Debug interface: UART RXD
|
| 56 |
|
|
dco_clk, // Fast oscillator (fast clock)
|
| 57 |
|
|
irq, // Maskable interrupts
|
| 58 |
|
|
lfxt_clk, // Low frequency oscillator (typ 32kHz)
|
| 59 |
|
|
nmi, // Non-maskable interrupt (asynchronous)
|
| 60 |
|
|
per_dout, // Peripheral data output
|
| 61 |
|
|
reset_n // Reset Pin (low active)
|
| 62 |
|
|
);
|
| 63 |
|
|
|
| 64 |
|
|
// OUTPUTs
|
| 65 |
|
|
//=========
|
| 66 |
|
|
output aclk_en; // ACLK enable
|
| 67 |
|
|
output dbg_freeze; // Freeze peripherals
|
| 68 |
|
|
output dbg_uart_txd; // Debug interface: UART TXD
|
| 69 |
|
|
output [13:0] irq_acc; // Interrupt request accepted (one-hot signal)
|
| 70 |
|
|
output [7:0] per_addr; // Peripheral address
|
| 71 |
|
|
output [15:0] per_din; // Peripheral data input
|
| 72 |
|
|
output [1:0] per_wen; // Peripheral write enable (high active)
|
| 73 |
|
|
output per_en; // Peripheral enable (high active)
|
| 74 |
|
|
output smclk_en; // SMCLK enable
|
| 75 |
|
|
|
| 76 |
|
|
|
| 77 |
|
|
// INPUTs
|
| 78 |
|
|
//=========
|
| 79 |
|
|
input dbg_uart_rxd; // Debug interface: UART RXD
|
| 80 |
|
|
input dco_clk; // Fast oscillator (fast clock)
|
| 81 |
|
|
input [13:0] irq; // Maskable interrupts
|
| 82 |
|
|
input lfxt_clk; // Low frequency oscillator (typ 32kHz)
|
| 83 |
|
|
input nmi; // Non-maskable interrupt (asynchronous)
|
| 84 |
|
|
input [15:0] per_dout; // Peripheral data output
|
| 85 |
|
|
input reset_n; // Reset Pin (active low)
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
//=============================================================================
|
| 89 |
|
|
// 1) INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
|
| 90 |
|
|
//=============================================================================
|
| 91 |
|
|
|
| 92 |
|
|
wire [`DMEM_MSB:0] dmem_addr;
|
| 93 |
|
|
wire dmem_cen;
|
| 94 |
|
|
wire [15:0] dmem_din;
|
| 95 |
|
|
wire [1:0] dmem_wen;
|
| 96 |
|
|
wire [15:0] dmem_dout;
|
| 97 |
|
|
|
| 98 |
|
|
wire [`PMEM_MSB:0] pmem_addr;
|
| 99 |
|
|
wire pmem_cen;
|
| 100 |
|
|
wire [15:0] pmem_din;
|
| 101 |
|
|
wire [1:0] pmem_wen;
|
| 102 |
|
|
wire [15:0] pmem_dout;
|
| 103 |
|
|
|
| 104 |
|
|
wire mclk;
|
| 105 |
|
|
wire puc;
|
| 106 |
|
|
|
| 107 |
|
|
|
| 108 |
|
|
//=============================================================================
|
| 109 |
|
|
// 2) PROGRAM AND DATA MEMORIES
|
| 110 |
|
|
//=============================================================================
|
| 111 |
|
|
|
| 112 |
|
|
dmem dmem_hi (.WD(dmem_din[15:8]), .RD(dmem_dout[15:8]), .WEN(dmem_wen[1] | dmem_cen), .REN(dmem_cen), .WADDR(dmem_addr) , .RADDR(dmem_addr), .RWCLK(mclk), .RESET(puc));
|
| 113 |
|
|
dmem dmem_lo (.WD(dmem_din[7:0]), .RD(dmem_dout[7:0]), .WEN(dmem_wen[0] | dmem_cen), .REN(dmem_cen), .WADDR(dmem_addr) , .RADDR(dmem_addr), .RWCLK(mclk), .RESET(puc));
|
| 114 |
|
|
|
| 115 |
|
|
pmem pmem_hi (.WD(pmem_din[15:8]), .RD(pmem_dout[15:8]), .WEN(pmem_wen[1] | pmem_cen), .REN(pmem_cen), .WADDR(pmem_addr) , .RADDR(pmem_addr), .RWCLK(mclk), .RESET(puc));
|
| 116 |
|
|
pmem pmem_lo (.WD(pmem_din[7:0]), .RD(pmem_dout[7:0]), .WEN(pmem_wen[0] | pmem_cen), .REN(pmem_cen), .WADDR(pmem_addr) , .RADDR(pmem_addr), .RWCLK(mclk), .RESET(puc));
|
| 117 |
|
|
|
| 118 |
|
|
|
| 119 |
|
|
//=============================================================================
|
| 120 |
|
|
// 3) OPENMSP430
|
| 121 |
|
|
//=============================================================================
|
| 122 |
|
|
|
| 123 |
|
|
openMSP430 openMSP430_0 (
|
| 124 |
|
|
|
| 125 |
|
|
// OUTPUTs
|
| 126 |
|
|
.aclk_en (aclk_en), // ACLK enable
|
| 127 |
|
|
.dbg_freeze (dbg_freeze), // Freeze peripherals
|
| 128 |
|
|
.dbg_uart_txd (dbg_uart_txd), // Debug interface: UART TXD
|
| 129 |
|
|
.dmem_addr (dmem_addr), // Data Memory address
|
| 130 |
|
|
.dmem_cen (dmem_cen), // Data Memory chip enable (low active)
|
| 131 |
|
|
.dmem_din (dmem_din), // Data Memory data input
|
| 132 |
|
|
.dmem_wen (dmem_wen), // Data Memory write enable (low active)
|
| 133 |
|
|
.irq_acc (irq_acc), // Interrupt request accepted (one-hot signal)
|
| 134 |
|
|
.mclk (mclk), // Main system clock
|
| 135 |
|
|
.per_addr (per_addr), // Peripheral address
|
| 136 |
|
|
.per_din (per_din), // Peripheral data input
|
| 137 |
|
|
.per_wen (per_wen), // Peripheral write enable (high active)
|
| 138 |
|
|
.per_en (per_en), // Peripheral enable (high active)
|
| 139 |
|
|
.pmem_addr (pmem_addr), // Program Memory address
|
| 140 |
|
|
.pmem_cen (pmem_cen), // Program Memory chip enable (low active)
|
| 141 |
|
|
.pmem_din (pmem_din), // Program Memory data input (optional)
|
| 142 |
|
|
.pmem_wen (pmem_wen), // Program Memory write enable (low active) (optional)
|
| 143 |
|
|
.puc (puc), // Main system reset
|
| 144 |
|
|
.smclk_en (smclk_en), // SMCLK enable
|
| 145 |
|
|
|
| 146 |
|
|
// INPUTs
|
| 147 |
|
|
.dbg_uart_rxd (dbg_uart_rxd), // Debug interface: UART RXD
|
| 148 |
|
|
.dco_clk (dco_clk), // Fast oscillator (fast clock)
|
| 149 |
|
|
.dmem_dout (dmem_dout), // Data Memory data output
|
| 150 |
|
|
.irq (irq), // Maskable interrupts
|
| 151 |
|
|
.lfxt_clk (lfxt_clk), // Low frequency oscillator (typ 32kHz)
|
| 152 |
|
|
.nmi (nmi), // Non-maskable interrupt (asynchronous)
|
| 153 |
|
|
.per_dout (per_dout), // Peripheral data output
|
| 154 |
|
|
.pmem_dout (pmem_dout), // Program Memory data output
|
| 155 |
|
|
.reset_n (reset_n) // Reset Pin (low active)
|
| 156 |
|
|
);
|
| 157 |
|
|
|
| 158 |
|
|
|
| 159 |
|
|
|
| 160 |
|
|
endmodule // openMSP430_fpga
|
| 161 |
|
|
|