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

Subversion Repositories xgate

[/] [xgate/] [trunk/] [rtl/] [verilog/] [xgate_top.v] - Blame information for rev 53

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

Line No. Rev Author Line
1 2 rehayes
////////////////////////////////////////////////////////////////////////////////
2
//
3
//  XGATE Coprocessor - XGATE Top Level Module
4
//
5
//  Author: Robert Hayes
6
//          rehayes@opencores.org
7
//
8
//  Downloaded from: http://www.opencores.org/projects/xgate.....
9
//
10
////////////////////////////////////////////////////////////////////////////////
11
// Copyright (c) 2009, Robert Hayes
12
//
13
// This source file is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU Lesser General Public License as published
15
// by the Free Software Foundation, either version 3 of the License, or
16
// (at your option) any later version.
17
//
18
// Supplemental terms.
19
//     * Redistributions of source code must retain the above copyright
20
//       notice, this list of conditions and the following disclaimer.
21
//     * Neither the name of the <organization> nor the
22
//       names of its contributors may be used to endorse or promote products
23
//       derived from this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY Robert Hayes ''AS IS'' AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
// DISCLAIMED. IN NO EVENT SHALL Robert Hayes BE LIABLE FOR ANY
29
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
//
36
// You should have received a copy of the GNU General Public License
37
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
38
////////////////////////////////////////////////////////////////////////////////
39
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
40
 
41
module xgate_top #(parameter ARST_LVL = 1'b0,      // asynchronous reset level
42
                   parameter SINGLE_CYCLE = 1'b0,  // 
43
                   parameter MAX_CHANNEL = 127,    // Max XGATE Interrupt Channel Number
44
                   parameter DWIDTH = 16)          // Data bus width
45
  (
46 5 rehayes
  // Wishbone Slave Signals
47
  output    [DWIDTH-1:0] wbs_dat_o,     // databus output
48
  output                 wbs_ack_o,     // bus cycle acknowledge output
49 53 rehayes
  output                 wbs_err_o,     // bus error, lost module select durning wait state
50 5 rehayes
  input                  wbs_clk_i,     // master clock input
51
  input                  wbs_rst_i,     // synchronous active high reset
52
  input                  arst_i,        // asynchronous reset
53 41 rehayes
  input            [5:1] wbs_adr_i,     // lower address bits
54 5 rehayes
  input     [DWIDTH-1:0] wbs_dat_i,     // databus input
55
  input                  wbs_we_i,      // write enable input
56
  input                  wbs_stb_i,     // stobe/core select signal
57
  input                  wbs_cyc_i,     // valid bus cycle input
58
  input            [1:0] wbs_sel_i,     // Select byte in word bus transaction
59
  // Wishbone Master Signals
60
  output    [DWIDTH-1:0] wbm_dat_o,     // databus output
61
  output                 wbm_we_o,      // write enable output
62
  output                 wbm_stb_o,     // stobe/core select signal
63
  output                 wbm_cyc_o,     // valid bus cycle output
64
  output          [ 1:0] wbm_sel_o,     // Select byte in word bus transaction
65
  output          [15:0] wbm_adr_o,     // Address bits
66
  input     [DWIDTH-1:0] wbm_dat_i,     // databus input
67
  input                  wbm_ack_i,     // bus cycle acknowledge input
68 2 rehayes
  // XGATE IO Signals
69 5 rehayes
  output          [ 7:0] xgswt,         // XGATE Software Trigger Register
70 2 rehayes
  output                 write_mem_strb_l, // Strobe for writing low data byte
71
  output                 write_mem_strb_h, // Strobe for writing high data bye
72 12 rehayes
  output                 xg_sw_irq,        // Xgate Software interrupt
73 2 rehayes
  output [MAX_CHANNEL:0] xgif,             // XGATE Interrupt Flag
74
  input  [MAX_CHANNEL:0] chan_req_i,       // XGATE Interrupt request
75
  input                  risc_clk,         // Clock for RISC core
76 30 rehayes
  input                  debug_mode_i,     // Force RISC core into debug mode
77
  input                  secure_mode_i,    // Limit host asscess to Xgate RISC registers
78 2 rehayes
  input                  scantestmode      // Chip in in scan test mode
79
  );
80
 
81
  wire        zero_flag;
82
  wire        negative_flag;
83
  wire        carry_flag;
84
  wire        overflow_flag;
85
  wire [15:0] xgr1;          // XGATE Register #1
86
  wire [15:0] xgr2;          // XGATE Register #2
87
  wire [15:0] xgr3;          // XGATE Register #3
88
  wire [15:0] xgr4;          // XGATE Register #4
89
  wire [15:0] xgr5;          // XGATE Register #5
90
  wire [15:0] xgr6;          // XGATE Register #6
91
  wire [15:0] xgr7;          // XGATE Register #7
92
 
93
  wire        write_xgmctl;  // Write Strobe for XGMCTL register
94 17 rehayes
  wire        write_xgchid;  // Write Strobe for XGCHID register
95 41 rehayes
  wire  [1:0] write_xgvbr;   // Write Strobe for XGVBR register
96
  wire  [1:0] write_xgif_7;  // Write Strobe for Interrupt Flag Register 7
97
  wire  [1:0] write_xgif_6;  // Write Strobe for Interrupt Flag Register 6
98
  wire  [1:0] write_xgif_5;  // Write Strobe for Interrupt Flag Register 5
99
  wire  [1:0] write_xgif_4;  // Write Strobe for Interrupt Flag Register 4
100
  wire  [1:0] write_xgif_3;  // Write Strobe for Interrupt Flag Register 3
101
  wire  [1:0] write_xgif_2;  // Write Strobe for Interrupt Flag Register 2
102
  wire  [1:0] write_xgif_1;  // Write Strobe for Interrupt Flag Register 1
103
  wire  [1:0] write_xgif_0;  // Write Strobe for Interrupt Flag Register 0
104 2 rehayes
  wire        write_xgswt;   // Write Strobe for XGSWT register
105
  wire        write_xgsem;   // Write Strobe for XGSEM register
106
  wire        write_xgccr;   // Write Strobe for XGATE Condition Code Register
107 41 rehayes
  wire  [1:0] write_xgpc;    // Write Strobe for XGATE Program Counter
108
  wire  [1:0] write_xgr7;    // Write Strobe for XGATE Data Register R7
109
  wire  [1:0] write_xgr6;    // Write Strobe for XGATE Data Register R6
110
  wire  [1:0] write_xgr5;    // Write Strobe for XGATE Data Register R5
111
  wire  [1:0] write_xgr4;    // Write Strobe for XGATE Data Register R4
112
  wire  [1:0] write_xgr3;    // Write Strobe for XGATE Data Register R3
113
  wire  [1:0] write_xgr2;    // Write Strobe for XGATE Data Register R2
114
  wire  [1:0] write_xgr1;    // Write Strobe for XGATE Data Register R1
115 2 rehayes
 
116
  wire        clear_xgif_7;    // Strobe for decode to clear interrupt flag bank 7
117
  wire        clear_xgif_6;    // Strobe for decode to clear interrupt flag bank 6
118
  wire        clear_xgif_5;    // Strobe for decode to clear interrupt flag bank 5
119
  wire        clear_xgif_4;    // Strobe for decode to clear interrupt flag bank 4
120
  wire        clear_xgif_3;    // Strobe for decode to clear interrupt flag bank 3
121
  wire        clear_xgif_2;    // Strobe for decode to clear interrupt flag bank 2
122
  wire        clear_xgif_1;    // Strobe for decode to clear interrupt flag bank 1
123
  wire        clear_xgif_0;    // Strobe for decode to clear interrupt flag bank 0
124
  wire [15:0] clear_xgif_data; // Data for decode to clear interrupt flag
125
 
126
  wire        xge;           // XGATE Module Enable
127
  wire        xgfrz;         // Stop XGATE in Freeze Mode
128 15 rehayes
  wire        xgdbg_set;     // Enter XGATE Debug Mode
129
  wire        xgdbg_clear;   // Leave XGATE Debug Mode
130 41 rehayes
  wire        xgfact;        // Fake Activity
131 2 rehayes
  wire        xgss;          // XGATE Single Step
132
  wire        xgsweif_c;     // Clear XGATE Software Error Interrupt FLag
133
  wire        xgie;          // XGATE Interrupt Enable
134
  wire [ 6:0] int_req;       // Encoded interrupt request
135
  wire [ 6:0] xgchid;        // Channel actively being processed
136 30 rehayes
  wire [127:0] xgif_status;   // Status bits of interrupt output flags that have been set
137 2 rehayes
  wire [15:1] xgvbr;         // XGATE vector Base Address Register
138 12 rehayes
  wire        brk_irq_ena;   // Enable BRK instruction to generate interrupt
139 2 rehayes
 
140 5 rehayes
  wire [15:0] xgate_address;   //
141
  wire [15:0] write_mem_data;  //
142
  wire [15:0] read_mem_data;   //
143 34 rehayes
  wire        mem_access;      //
144 5 rehayes
  wire        mem_req_ack;     //
145 12 rehayes
 
146
  wire        debug_active;    // RISC state machine in Debug mode 
147 53 rehayes
  wire        debug_ack;       // Clear debug register
148
  wire        single_step;     // Pulse to trigger a single instruction execution in debug mode
149
  wire        ss_mem_ack;      // WISHBONE Bus has granted single step memory access
150 5 rehayes
 
151 2 rehayes
  wire [ 7:0] host_semap;    // Semaphore status for host
152
//  wire [15:0] write_mem_data;
153
//  wire [15:0] read_mem_data;
154
//  wire [15:0] perif_data;
155
 
156 30 rehayes
  assign xgif = xgif_status[MAX_CHANNEL:0];
157 2 rehayes
  // ---------------------------------------------------------------------------
158
  // Wishbone Slave Bus interface
159
  xgate_wbs_bus #(.ARST_LVL(ARST_LVL),
160 5 rehayes
                  .SINGLE_CYCLE(SINGLE_CYCLE))
161 2 rehayes
    wishbone_s(
162
    .wbs_dat_o( wbs_dat_o ),
163
    .wbs_ack_o( wbs_ack_o ),
164 53 rehayes
    .wbs_err_o( wbs_err_o ),
165 2 rehayes
    .wbs_clk_i( wbs_clk_i ),
166
    .wbs_rst_i( wbs_rst_i ),
167
    .arst_i( arst_i ),
168
    .wbs_adr_i( wbs_adr_i ),
169
    .wbs_dat_i( wbs_dat_i ),
170
    .wbs_we_i( wbs_we_i ),
171
    .wbs_stb_i( wbs_stb_i ),
172
    .wbs_cyc_i( wbs_cyc_i ),
173
    .wbs_sel_i( wbs_sel_i ),
174
 
175
    // outputs
176
    .sync_reset( sync_reset ),
177
    .write_xgmctl( write_xgmctl ),
178 17 rehayes
    .write_xgchid( write_xgchid ),
179 2 rehayes
    .write_xgvbr( write_xgvbr ),
180
    .write_xgif_7( write_xgif_7 ),
181
    .write_xgif_6( write_xgif_6 ),
182
    .write_xgif_5( write_xgif_5 ),
183
    .write_xgif_4( write_xgif_4 ),
184
    .write_xgif_3( write_xgif_3 ),
185
    .write_xgif_2( write_xgif_2 ),
186
    .write_xgif_1( write_xgif_1 ),
187
    .write_xgif_0( write_xgif_0 ),
188
    .write_xgswt( write_xgswt ),
189
    .write_xgsem( write_xgsem ),
190
    .write_xgccr( write_xgccr ),
191
    .write_xgpc( write_xgpc ),
192
    .write_xgr7( write_xgr7 ),
193
    .write_xgr6( write_xgr6 ),
194
    .write_xgr5( write_xgr5 ),
195
    .write_xgr4( write_xgr4 ),
196
    .write_xgr3( write_xgr3 ),
197
    .write_xgr2( write_xgr2 ),
198
    .write_xgr1( write_xgr1 ),
199
    // inputs    
200
    .async_rst_b  ( async_rst_b ),
201
    .read_regs    (               // in  -- read register bits
202
                   { xgr7,             // XGR7
203
                     xgr6,             // XGR6
204
                     xgr5,             // XGR5
205
                     xgr4,             // XGR4
206
                     xgr3,             // XGR3
207
                     xgr2,             // XGR2
208
                     xgr1,             // XGR1
209
                     16'b0,            // Reserved (XGR0)
210
                     xgate_address,    // XGPC
211
                     {12'h000,  negative_flag, zero_flag, overflow_flag, carry_flag},  // XGCCR
212 17 rehayes
                     16'b0,                // Reserved
213 2 rehayes
                     {8'h00, host_semap},  // XGSEM
214 17 rehayes
                     {8'h00, xgswt},       // XGSWT
215 30 rehayes
                     xgif_status[ 15:  0], // XGIF_0
216
                     xgif_status[ 31: 16], // XGIF_1
217
                     xgif_status[ 47: 32], // XGIF_2
218
                     xgif_status[ 63: 48], // XGIF_3
219
                     xgif_status[ 79: 64], // XGIF_4
220
                     xgif_status[ 95: 80], // XGIF_5
221
                     xgif_status[111: 96], // XGIF_6
222
                     xgif_status[127:112], // XGIF_7
223 2 rehayes
                     {xgvbr[15:1], 1'b0},  // XGVBR
224 43 rehayes
                     16'b0,                // Reserved
225
                     16'b0,                // Reserved
226 17 rehayes
                     {8'b0, 1'b0, xgchid}, // XGCHID
227 41 rehayes
                     {8'b0, xge, xgfrz, debug_active, 1'b0, xgfact, brk_irq_ena, xg_sw_irq, xgie}  // XGMCTL
228 2 rehayes
                   }
229
                  )
230
  );
231
 
232
  // ---------------------------------------------------------------------------
233
  xgate_regs #(.ARST_LVL(ARST_LVL),
234
               .MAX_CHANNEL(MAX_CHANNEL))
235
    regs(
236
    // outputs
237
    .xge( xge ),
238
    .xgfrz( xgfrz ),
239 15 rehayes
    .xgdbg_set( xgdbg_set ),
240
    .xgdbg_clear( xgdbg_clear ),
241 41 rehayes
    .xgfact( xgfact ),
242 2 rehayes
    .xgss( xgss ),
243
    .xgsweif_c( xgsweif_c ),
244
    .xgie( xgie ),
245 12 rehayes
    .brk_irq_ena( brk_irq_ena ),
246 2 rehayes
    .xgvbr( xgvbr ),
247
    .xgswt( xgswt ),
248
    .clear_xgif_7( clear_xgif_7 ),
249
    .clear_xgif_6( clear_xgif_6 ),
250
    .clear_xgif_5( clear_xgif_5 ),
251
    .clear_xgif_4( clear_xgif_4 ),
252
    .clear_xgif_3( clear_xgif_3 ),
253
    .clear_xgif_2( clear_xgif_2 ),
254
    .clear_xgif_1( clear_xgif_1 ),
255
    .clear_xgif_0( clear_xgif_0 ),
256
    .clear_xgif_data( clear_xgif_data ),
257
 
258
    // inputs
259
    .async_rst_b( async_rst_b ),
260
    .sync_reset( sync_reset ),
261
    .bus_clk( wbs_clk_i ),
262
    .write_bus( wbs_dat_i ),
263
    .write_xgmctl( write_xgmctl ),
264
    .write_xgvbr( write_xgvbr ),
265
    .write_xgif_7( write_xgif_7 ),
266
    .write_xgif_6( write_xgif_6 ),
267
    .write_xgif_5( write_xgif_5 ),
268
    .write_xgif_4( write_xgif_4 ),
269
    .write_xgif_3( write_xgif_3 ),
270
    .write_xgif_2( write_xgif_2 ),
271
    .write_xgif_1( write_xgif_1 ),
272
    .write_xgif_0( write_xgif_0 ),
273 53 rehayes
    .write_xgswt( write_xgswt ),
274
    .debug_ack( debug_ack )
275 2 rehayes
  );
276
 
277
  // ---------------------------------------------------------------------------
278
  xgate_risc #(.MAX_CHANNEL(MAX_CHANNEL))
279
    risc(
280
    // outputs
281
    .xgate_address( xgate_address ),
282
    .write_mem_strb_l( write_mem_strb_l ),
283
    .write_mem_strb_h( write_mem_strb_h ),
284
    .write_mem_data( write_mem_data ),
285
    .zero_flag( zero_flag ),
286
    .negative_flag( negative_flag ),
287
    .carry_flag( carry_flag ),
288
    .overflow_flag( overflow_flag ),
289
    .xgchid( xgchid ),
290
    .host_semap( host_semap ),
291
    .xgr1( xgr1 ),
292
    .xgr2( xgr2 ),
293
    .xgr3( xgr3 ),
294
    .xgr4( xgr4 ),
295
    .xgr5( xgr5 ),
296
    .xgr6( xgr6 ),
297
    .xgr7( xgr7 ),
298 30 rehayes
    .xgif_status( xgif_status ),
299 12 rehayes
    .debug_active( debug_active ),
300 53 rehayes
    .debug_ack( debug_ack ),
301 12 rehayes
    .xg_sw_irq( xg_sw_irq ),
302 34 rehayes
    .mem_access( mem_access ),
303 53 rehayes
    .single_step( single_step ),
304 2 rehayes
 
305
    // inputs
306
    .risc_clk( risc_clk ),
307
    .perif_data( wbs_dat_i ),
308
    .async_rst_b( async_rst_b ),
309
    .read_mem_data( read_mem_data ),
310 5 rehayes
    .mem_req_ack( mem_req_ack ),
311 53 rehayes
    .ss_mem_ack( ss_mem_ack ),
312 2 rehayes
    .xge( xge ),
313 15 rehayes
    .xgdbg_set( xgdbg_set ),
314
    .xgdbg_clear( xgdbg_clear ),
315 30 rehayes
    .debug_mode_i(debug_mode_i),
316 2 rehayes
    .xgss( xgss ),
317
    .xgvbr( xgvbr ),
318 5 rehayes
    .int_req( int_req ),
319 12 rehayes
    .xgie( xgie ),
320
    .brk_irq_ena( brk_irq_ena ),
321 2 rehayes
    .write_xgsem( write_xgsem ),
322 17 rehayes
    .write_xgchid( write_xgchid ),
323 2 rehayes
    .write_xgccr( write_xgccr ),
324
    .write_xgpc( write_xgpc ),
325
    .write_xgr7( write_xgr7 ),
326
    .write_xgr6( write_xgr6 ),
327
    .write_xgr5( write_xgr5 ),
328
    .write_xgr4( write_xgr4 ),
329
    .write_xgr3( write_xgr3 ),
330
    .write_xgr2( write_xgr2 ),
331
    .write_xgr1( write_xgr1 ),
332
    .clear_xgif_7( clear_xgif_7 ),
333
    .clear_xgif_6( clear_xgif_6 ),
334
    .clear_xgif_5( clear_xgif_5 ),
335
    .clear_xgif_4( clear_xgif_4 ),
336
    .clear_xgif_3( clear_xgif_3 ),
337
    .clear_xgif_2( clear_xgif_2 ),
338
    .clear_xgif_1( clear_xgif_1 ),
339
    .clear_xgif_0( clear_xgif_0 ),
340 12 rehayes
    .xgsweif_c( xgsweif_c ),
341 2 rehayes
    .clear_xgif_data( clear_xgif_data )
342
  );
343
 
344
  xgate_irq_encode #(.MAX_CHANNEL(MAX_CHANNEL))
345
    irq_encode(
346
    // outputs
347
    .int_req( int_req ),
348
    // inputs
349
    .chan_req_i( chan_req_i )
350
  );
351
 
352 5 rehayes
  // ---------------------------------------------------------------------------
353
  // Wishbone Master Bus interface
354
  xgate_wbm_bus #(.ARST_LVL(ARST_LVL))
355
    wishbone_m(
356
  // Wishbone Master Signals
357
    .wbm_dat_o( wbm_dat_o ),
358
    .wbm_we_o( wbm_we_o ),
359
    .wbm_stb_o( wbm_stb_o ),
360
    .wbm_cyc_o( wbm_cyc_o ),
361
    .wbm_sel_o( wbm_sel_o ),
362
    .wbm_adr_o( wbm_adr_o ),
363
    .wbm_dat_i( wbm_dat_i ),
364
    .wbm_ack_i( wbm_ack_i ),
365
    .wbs_clk_i( wbs_clk_i ),
366
    .wbs_rst_i( wbs_rst_i ),
367
    .arst_i( arst_i ),
368
 // XGATE Control Signals
369 53 rehayes
    .risc_clk( risc_clk ),
370
    .async_rst_b( async_rst_b ),
371 34 rehayes
    .xge( xge ),
372
    .mem_access( mem_access ),
373 53 rehayes
    .single_step( single_step ),
374
    .ss_mem_ack( ss_mem_ack ),
375 5 rehayes
    .read_mem_data( read_mem_data ),
376
    .xgate_address( xgate_address ),
377
    .mem_req_ack( mem_req_ack ),
378
    .write_mem_strb_l( write_mem_strb_l ),
379
    .write_mem_strb_h( write_mem_strb_h ),
380
    .write_mem_data( write_mem_data )
381
  );
382 2 rehayes
 
383 5 rehayes
 
384 2 rehayes
endmodule  // xgate_top
385
 

powered by: WebSVN 2.1.0

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