OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [actel_m1a3pl_dev_kit/] [rtl/] [verilog/] [openmsp430/] [omsp_mem_backbone.v] - Blame information for rev 104

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 80 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: omsp_mem_backbone.v
26
// 
27
// *Module Description:
28
//                       Memory interface backbone (decoder + arbiter)
29
//
30
// *Author(s):
31
//              - Olivier Girard,    olgirard@gmail.com
32
//
33
//----------------------------------------------------------------------------
34 104 olivier.gi
// $Rev: 103 $
35 80 olivier.gi
// $LastChangedBy: olivier.girard $
36 104 olivier.gi
// $LastChangedDate: 2011-03-05 15:44:48 +0100 (Sat, 05 Mar 2011) $
37 80 olivier.gi
//----------------------------------------------------------------------------
38 104 olivier.gi
`ifdef OMSP_NO_INCLUDE
39
`else
40 80 olivier.gi
`include "openMSP430_defines.v"
41 104 olivier.gi
`endif
42 80 olivier.gi
 
43
module  omsp_mem_backbone (
44
 
45
// OUTPUTs
46
    dbg_mem_din,                    // Debug unit Memory data input
47
    dmem_addr,                      // Data Memory address
48
    dmem_cen,                       // Data Memory chip enable (low active)
49
    dmem_din,                       // Data Memory data input
50
    dmem_wen,                       // Data Memory write enable (low active)
51
    eu_mdb_in,                      // Execution Unit Memory data bus input
52
    fe_mdb_in,                      // Frontend Memory data bus input
53
    fe_pmem_wait,                   // Frontend wait for Instruction fetch
54
    per_addr,                       // Peripheral address
55
    per_din,                        // Peripheral data input
56
    per_wen,                        // Peripheral write enable (high active)
57
    per_en,                         // Peripheral enable (high active)
58
    pmem_addr,                      // Program Memory address
59
    pmem_cen,                       // Program Memory chip enable (low active)
60
    pmem_din,                       // Program Memory data input (optional)
61
    pmem_wen,                       // Program Memory write enable (low active) (optional)
62
 
63
// INPUTs
64
    dbg_halt_st,                    // Halt/Run status from CPU
65
    dbg_mem_addr,                   // Debug address for rd/wr access
66
    dbg_mem_dout,                   // Debug unit data output
67
    dbg_mem_en,                     // Debug unit memory enable
68
    dbg_mem_wr,                     // Debug unit memory write
69
    dmem_dout,                      // Data Memory data output
70
    eu_mab,                         // Execution Unit Memory address bus
71
    eu_mb_en,                       // Execution Unit Memory bus enable
72
    eu_mb_wr,                       // Execution Unit Memory bus write transfer
73
    eu_mdb_out,                     // Execution Unit Memory data bus output
74
    fe_mab,                         // Frontend Memory address bus
75
    fe_mb_en,                       // Frontend Memory bus enable
76
    mclk,                           // Main system clock
77
    per_dout,                       // Peripheral data output
78
    pmem_dout,                      // Program Memory data output
79
    puc                             // Main system reset
80
);
81
 
82
// OUTPUTs
83
//=========
84
output        [15:0] dbg_mem_din;   // Debug unit Memory data input
85
output [`DMEM_MSB:0] dmem_addr;     // Data Memory address
86
output               dmem_cen;      // Data Memory chip enable (low active)
87
output        [15:0] dmem_din;      // Data Memory data input
88
output         [1:0] dmem_wen;      // Data Memory write enable (low active)
89
output        [15:0] eu_mdb_in;     // Execution Unit Memory data bus input
90
output        [15:0] fe_mdb_in;     // Frontend Memory data bus input
91
output               fe_pmem_wait;  // Frontend wait for Instruction fetch
92
output         [7:0] per_addr;      // Peripheral address
93
output        [15:0] per_din;       // Peripheral data input
94
output         [1:0] per_wen;       // Peripheral write enable (high active)
95
output               per_en;        // Peripheral enable (high active)
96
output [`PMEM_MSB:0] pmem_addr;     // Program Memory address
97
output               pmem_cen;      // Program Memory chip enable (low active)
98
output        [15:0] pmem_din;      // Program Memory data input (optional)
99
output         [1:0] pmem_wen;      // Program Memory write enable (low active) (optional)
100
 
101
// INPUTs
102
//=========
103
input                dbg_halt_st;   // Halt/Run status from CPU
104
input         [15:0] dbg_mem_addr;  // Debug address for rd/wr access
105
input         [15:0] dbg_mem_dout;  // Debug unit data output
106
input                dbg_mem_en;    // Debug unit memory enable
107
input          [1:0] dbg_mem_wr;    // Debug unit memory write
108
input         [15:0] dmem_dout;     // Data Memory data output
109
input         [14:0] eu_mab;        // Execution Unit Memory address bus
110
input                eu_mb_en;      // Execution Unit Memory bus enable
111
input          [1:0] eu_mb_wr;      // Execution Unit Memory bus write transfer
112
input         [15:0] eu_mdb_out;    // Execution Unit Memory data bus output
113
input         [14:0] fe_mab;        // Frontend Memory address bus
114
input                fe_mb_en;      // Frontend Memory bus enable
115
input                mclk;          // Main system clock
116
input         [15:0] per_dout;      // Peripheral data output
117
input         [15:0] pmem_dout;     // Program Memory data output
118
input                puc;           // Main system reset
119
 
120
 
121
//=============================================================================
122
// 1)  DECODER
123
//=============================================================================
124
 
125
// RAM Interface
126
//------------------
127
 
128
// Execution unit access
129
wire               eu_dmem_cen   = ~(eu_mb_en & (eu_mab>=(`DMEM_BASE>>1)) &
130
                                                (eu_mab<((`DMEM_BASE+`DMEM_SIZE)>>1)));
131
wire        [15:0] eu_dmem_addr  = eu_mab-(`DMEM_BASE>>1);
132
 
133
// Debug interface access
134
wire               dbg_dmem_cen  = ~(dbg_mem_en & (dbg_mem_addr[15:1]>=(`DMEM_BASE>>1)) &
135
                                                  (dbg_mem_addr[15:1]<((`DMEM_BASE+`DMEM_SIZE)>>1)));
136
wire        [15:0] dbg_dmem_addr = dbg_mem_addr[15:1]-(`DMEM_BASE>>1);
137
 
138
 
139
// RAM Interface
140
wire [`DMEM_MSB:0] dmem_addr     = ~dbg_dmem_cen ? dbg_dmem_addr[`DMEM_MSB:0] : eu_dmem_addr[`DMEM_MSB:0];
141
wire               dmem_cen      =  dbg_dmem_cen & eu_dmem_cen;
142
wire         [1:0] dmem_wen      = ~(dbg_mem_wr | eu_mb_wr);
143
wire        [15:0] dmem_din      = ~dbg_dmem_cen ? dbg_mem_dout : eu_mdb_out;
144
 
145
 
146
// ROM Interface
147
//------------------
148
parameter          PMEM_OFFSET   = (16'hFFFF-`PMEM_SIZE+1);
149
 
150
// Execution unit access (only read access are accepted)
151
wire               eu_pmem_cen   = ~(eu_mb_en & ~|eu_mb_wr & (eu_mab>=(PMEM_OFFSET>>1)));
152
wire        [15:0] eu_pmem_addr  = eu_mab-(PMEM_OFFSET>>1);
153
 
154
// Front-end access
155
wire               fe_pmem_cen   = ~(fe_mb_en & (fe_mab>=(PMEM_OFFSET>>1)));
156
wire        [15:0] fe_pmem_addr  = fe_mab-(PMEM_OFFSET>>1);
157
 
158
// Debug interface access
159
wire               dbg_pmem_cen  = ~(dbg_mem_en & (dbg_mem_addr[15:1]>=(PMEM_OFFSET>>1)));
160
wire        [15:0] dbg_pmem_addr = dbg_mem_addr[15:1]-(PMEM_OFFSET>>1);
161
 
162
 
163
// ROM Interface (Execution unit has priority)
164
wire [`PMEM_MSB:0] pmem_addr     = ~dbg_pmem_cen ? dbg_pmem_addr[`PMEM_MSB:0] :
165
                                   ~eu_pmem_cen  ? eu_pmem_addr[`PMEM_MSB:0]  : fe_pmem_addr[`PMEM_MSB:0];
166
wire               pmem_cen      =  fe_pmem_cen & eu_pmem_cen & dbg_pmem_cen;
167
wire         [1:0] pmem_wen      = ~dbg_mem_wr;
168
wire        [15:0] pmem_din      =  dbg_mem_dout;
169
 
170
wire               fe_pmem_wait  = (~fe_pmem_cen & ~eu_pmem_cen);
171
 
172
 
173
// Peripherals
174
//--------------------
175
wire         dbg_per_en    =  dbg_mem_en & (dbg_mem_addr[15:9]==7'h00);
176
wire         eu_per_en     =  eu_mb_en   & (eu_mab[14:8]==7'h00);
177
 
178
wire   [7:0] per_addr      =  dbg_mem_en ? dbg_mem_addr[8:1] : eu_mab[7:0];
179
wire  [15:0] per_din       =  dbg_mem_en ? dbg_mem_dout      : eu_mdb_out;
180
wire   [1:0] per_wen       =  dbg_mem_en ? dbg_mem_wr        : eu_mb_wr;
181
wire         per_en        =  dbg_mem_en ? dbg_per_en        : eu_per_en;
182
 
183
reg   [15:0] per_dout_val;
184
always @ (posedge mclk or posedge puc)
185
  if (puc)      per_dout_val <= 16'h0000;
186
  else          per_dout_val <= per_dout;
187
 
188
 
189
// Frontend data Mux
190
//---------------------------------
191
// Whenever the frontend doesn't access the ROM,  backup the data
192
 
193
// Detect whenever the data should be backuped and restored
194
reg         fe_pmem_cen_dly;
195
always @(posedge mclk or posedge puc)
196
  if (puc)     fe_pmem_cen_dly <=  1'b0;
197
  else         fe_pmem_cen_dly <=  fe_pmem_cen;
198
 
199
wire fe_pmem_save    = ( fe_pmem_cen & ~fe_pmem_cen_dly) & ~dbg_halt_st;
200
wire fe_pmem_restore = (~fe_pmem_cen &  fe_pmem_cen_dly) |  dbg_halt_st;
201
 
202
reg  [15:0] pmem_dout_bckup;
203
always @(posedge mclk or posedge puc)
204
  if (puc)               pmem_dout_bckup     <=  16'h0000;
205
  else if (fe_pmem_save) pmem_dout_bckup     <=  pmem_dout;
206
 
207
// Mux between the ROM data and the backup
208
reg         pmem_dout_bckup_sel;
209
always @(posedge mclk or posedge puc)
210
  if (puc)                  pmem_dout_bckup_sel <=  1'b0;
211
  else if (fe_pmem_save)    pmem_dout_bckup_sel <=  1'b1;
212
  else if (fe_pmem_restore) pmem_dout_bckup_sel <=  1'b0;
213
 
214
assign fe_mdb_in = pmem_dout_bckup_sel ? pmem_dout_bckup : pmem_dout;
215
 
216
 
217
// Execution-Unit data Mux
218
//---------------------------------
219
 
220
// Select between peripherals, RAM and ROM
221
reg [1:0] eu_mdb_in_sel;
222
always @(posedge mclk or posedge puc)
223
  if (puc)  eu_mdb_in_sel <= 2'b00;
224
  else      eu_mdb_in_sel <= {~eu_pmem_cen, per_en};
225
 
226
// Mux
227
assign      eu_mdb_in      = eu_mdb_in_sel[1] ? pmem_dout    :
228
                             eu_mdb_in_sel[0] ? per_dout_val : dmem_dout;
229
 
230
// Debug interface  data Mux
231
//---------------------------------
232
 
233
// Select between peripherals, RAM and ROM
234
reg [1:0] dbg_mem_din_sel;
235
always @(posedge mclk or posedge puc)
236
  if (puc)  dbg_mem_din_sel <= 2'b00;
237
  else      dbg_mem_din_sel <= {~dbg_pmem_cen, dbg_per_en};
238
 
239
// Mux
240
assign      dbg_mem_din  = dbg_mem_din_sel[1] ? pmem_dout    :
241
                           dbg_mem_din_sel[0] ? per_dout_val : dmem_dout;
242
 
243
 
244
endmodule // omsp_mem_backbone
245
 
246 104 olivier.gi
`ifdef OMSP_NO_INCLUDE
247
`else
248 80 olivier.gi
`include "openMSP430_undefines.v"
249 104 olivier.gi
`endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.