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

Subversion Repositories xgate

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

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
  input                  wbs_clk_i,     // master clock input
50
  input                  wbs_rst_i,     // synchronous active high reset
51
  input                  arst_i,        // asynchronous reset
52 41 rehayes
  input            [5:1] wbs_adr_i,     // lower address bits
53 5 rehayes
  input     [DWIDTH-1:0] wbs_dat_i,     // databus input
54
  input                  wbs_we_i,      // write enable input
55
  input                  wbs_stb_i,     // stobe/core select signal
56
  input                  wbs_cyc_i,     // valid bus cycle input
57
  input            [1:0] wbs_sel_i,     // Select byte in word bus transaction
58
  // Wishbone Master Signals
59
  output    [DWIDTH-1:0] wbm_dat_o,     // databus output
60
  output                 wbm_we_o,      // write enable output
61
  output                 wbm_stb_o,     // stobe/core select signal
62
  output                 wbm_cyc_o,     // valid bus cycle output
63
  output          [ 1:0] wbm_sel_o,     // Select byte in word bus transaction
64
  output          [15:0] wbm_adr_o,     // Address bits
65
  input     [DWIDTH-1:0] wbm_dat_i,     // databus input
66
  input                  wbm_ack_i,     // bus cycle acknowledge input
67 2 rehayes
  // XGATE IO Signals
68 5 rehayes
  output          [ 7:0] xgswt,         // XGATE Software Trigger Register
69 2 rehayes
  output                 write_mem_strb_l, // Strobe for writing low data byte
70
  output                 write_mem_strb_h, // Strobe for writing high data bye
71 12 rehayes
  output                 xg_sw_irq,        // Xgate Software interrupt
72 2 rehayes
  output [MAX_CHANNEL:0] xgif,             // XGATE Interrupt Flag
73
  input  [MAX_CHANNEL:0] chan_req_i,       // XGATE Interrupt request
74
  input                  risc_clk,         // Clock for RISC core
75 30 rehayes
  input                  debug_mode_i,     // Force RISC core into debug mode
76
  input                  secure_mode_i,    // Limit host asscess to Xgate RISC registers
77 2 rehayes
  input                  scantestmode      // Chip in in scan test mode
78
  );
79
 
80
  wire        zero_flag;
81
  wire        negative_flag;
82
  wire        carry_flag;
83
  wire        overflow_flag;
84
  wire [15:0] xgr1;          // XGATE Register #1
85
  wire [15:0] xgr2;          // XGATE Register #2
86
  wire [15:0] xgr3;          // XGATE Register #3
87
  wire [15:0] xgr4;          // XGATE Register #4
88
  wire [15:0] xgr5;          // XGATE Register #5
89
  wire [15:0] xgr6;          // XGATE Register #6
90
  wire [15:0] xgr7;          // XGATE Register #7
91
 
92
  wire [15:0] xgisp74;       // XGATE Interrupt level 7-4 stack pointer
93
  wire [15:0] xgisp30;       // XGATE Interrupt level 3-0 stack pointer
94
 
95
  wire        write_xgmctl;  // Write Strobe for XGMCTL register
96 17 rehayes
  wire        write_xgchid;  // Write Strobe for XGCHID register
97 2 rehayes
  wire        write_xgisp74; // Write Strobe for XGISP74 register
98 25 rehayes
  wire        write_xgisp30; // Write Strobe for XGISP30 register
99 41 rehayes
  wire  [1:0] write_xgvbr;   // Write Strobe for XGVBR register
100
  wire  [1:0] write_xgif_7;  // Write Strobe for Interrupt Flag Register 7
101
  wire  [1:0] write_xgif_6;  // Write Strobe for Interrupt Flag Register 6
102
  wire  [1:0] write_xgif_5;  // Write Strobe for Interrupt Flag Register 5
103
  wire  [1:0] write_xgif_4;  // Write Strobe for Interrupt Flag Register 4
104
  wire  [1:0] write_xgif_3;  // Write Strobe for Interrupt Flag Register 3
105
  wire  [1:0] write_xgif_2;  // Write Strobe for Interrupt Flag Register 2
106
  wire  [1:0] write_xgif_1;  // Write Strobe for Interrupt Flag Register 1
107
  wire  [1:0] write_xgif_0;  // Write Strobe for Interrupt Flag Register 0
108 2 rehayes
  wire        write_xgswt;   // Write Strobe for XGSWT register
109
  wire        write_xgsem;   // Write Strobe for XGSEM register
110
  wire        write_xgccr;   // Write Strobe for XGATE Condition Code Register
111 41 rehayes
  wire  [1:0] write_xgpc;    // Write Strobe for XGATE Program Counter
112
  wire  [1:0] write_xgr7;    // Write Strobe for XGATE Data Register R7
113
  wire  [1:0] write_xgr6;    // Write Strobe for XGATE Data Register R6
114
  wire  [1:0] write_xgr5;    // Write Strobe for XGATE Data Register R5
115
  wire  [1:0] write_xgr4;    // Write Strobe for XGATE Data Register R4
116
  wire  [1:0] write_xgr3;    // Write Strobe for XGATE Data Register R3
117
  wire  [1:0] write_xgr2;    // Write Strobe for XGATE Data Register R2
118
  wire  [1:0] write_xgr1;    // Write Strobe for XGATE Data Register R1
119 2 rehayes
 
120
  wire        clear_xgif_7;    // Strobe for decode to clear interrupt flag bank 7
121
  wire        clear_xgif_6;    // Strobe for decode to clear interrupt flag bank 6
122
  wire        clear_xgif_5;    // Strobe for decode to clear interrupt flag bank 5
123
  wire        clear_xgif_4;    // Strobe for decode to clear interrupt flag bank 4
124
  wire        clear_xgif_3;    // Strobe for decode to clear interrupt flag bank 3
125
  wire        clear_xgif_2;    // Strobe for decode to clear interrupt flag bank 2
126
  wire        clear_xgif_1;    // Strobe for decode to clear interrupt flag bank 1
127
  wire        clear_xgif_0;    // Strobe for decode to clear interrupt flag bank 0
128
  wire [15:0] clear_xgif_data; // Data for decode to clear interrupt flag
129
 
130
  wire        xge;           // XGATE Module Enable
131
  wire        xgfrz;         // Stop XGATE in Freeze Mode
132 15 rehayes
  wire        xgdbg_set;     // Enter XGATE Debug Mode
133
  wire        xgdbg_clear;   // Leave XGATE Debug Mode
134 41 rehayes
  wire        xgfact;        // Fake Activity
135 2 rehayes
  wire        xgss;          // XGATE Single Step
136
  wire        xgsweif_c;     // Clear XGATE Software Error Interrupt FLag
137
  wire        xgie;          // XGATE Interrupt Enable
138
  wire [ 6:0] int_req;       // Encoded interrupt request
139
  wire [ 6:0] xgchid;        // Channel actively being processed
140 30 rehayes
  wire [127:0] xgif_status;   // Status bits of interrupt output flags that have been set
141 2 rehayes
  wire [15:1] xgvbr;         // XGATE vector Base Address Register
142 12 rehayes
  wire        brk_irq_ena;   // Enable BRK instruction to generate interrupt
143 2 rehayes
 
144 5 rehayes
  wire [15:0] xgate_address;   //
145
  wire [15:0] write_mem_data;  //
146
  wire [15:0] read_mem_data;   //
147 34 rehayes
  wire        mem_access;      //
148 5 rehayes
  wire        mem_req_ack;     //
149 12 rehayes
 
150
  wire        debug_active;    // RISC state machine in Debug mode 
151 5 rehayes
 
152 2 rehayes
  wire [ 7:0] host_semap;    // Semaphore status for host
153
//  wire [15:0] write_mem_data;
154
//  wire [15:0] read_mem_data;
155
//  wire [15:0] perif_data;
156
 
157 30 rehayes
  assign xgif = xgif_status[MAX_CHANNEL:0];
158 2 rehayes
  // ---------------------------------------------------------------------------
159
  // Wishbone Slave Bus interface
160
  xgate_wbs_bus #(.ARST_LVL(ARST_LVL),
161 5 rehayes
                  .SINGLE_CYCLE(SINGLE_CYCLE))
162 2 rehayes
    wishbone_s(
163
    .wbs_dat_o( wbs_dat_o ),
164
    .wbs_ack_o( wbs_ack_o ),
165
    .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_xgisp74( write_xgisp74 ),
180
    .write_xgisp30( write_xgisp30 ),
181
    .write_xgvbr( write_xgvbr ),
182
    .write_xgif_7( write_xgif_7 ),
183
    .write_xgif_6( write_xgif_6 ),
184
    .write_xgif_5( write_xgif_5 ),
185
    .write_xgif_4( write_xgif_4 ),
186
    .write_xgif_3( write_xgif_3 ),
187
    .write_xgif_2( write_xgif_2 ),
188
    .write_xgif_1( write_xgif_1 ),
189
    .write_xgif_0( write_xgif_0 ),
190
    .write_xgswt( write_xgswt ),
191
    .write_xgsem( write_xgsem ),
192
    .write_xgccr( write_xgccr ),
193
    .write_xgpc( write_xgpc ),
194
    .write_xgr7( write_xgr7 ),
195
    .write_xgr6( write_xgr6 ),
196
    .write_xgr5( write_xgr5 ),
197
    .write_xgr4( write_xgr4 ),
198
    .write_xgr3( write_xgr3 ),
199
    .write_xgr2( write_xgr2 ),
200
    .write_xgr1( write_xgr1 ),
201
    // inputs    
202
    .async_rst_b  ( async_rst_b ),
203
    .read_regs    (               // in  -- read register bits
204
                   { xgr7,             // XGR7
205
                     xgr6,             // XGR6
206
                     xgr5,             // XGR5
207
                     xgr4,             // XGR4
208
                     xgr3,             // XGR3
209
                     xgr2,             // XGR2
210
                     xgr1,             // XGR1
211
                     16'b0,            // Reserved (XGR0)
212
                     xgate_address,    // XGPC
213
                     {12'h000,  negative_flag, zero_flag, overflow_flag, carry_flag},  // XGCCR
214 17 rehayes
                     16'b0,                // Reserved
215 2 rehayes
                     {8'h00, host_semap},  // XGSEM
216 17 rehayes
                     {8'h00, xgswt},       // XGSWT
217 30 rehayes
                     xgif_status[ 15:  0], // XGIF_0
218
                     xgif_status[ 31: 16], // XGIF_1
219
                     xgif_status[ 47: 32], // XGIF_2
220
                     xgif_status[ 63: 48], // XGIF_3
221
                     xgif_status[ 79: 64], // XGIF_4
222
                     xgif_status[ 95: 80], // XGIF_5
223
                     xgif_status[111: 96], // XGIF_6
224
                     xgif_status[127:112], // XGIF_7
225 2 rehayes
                     {xgvbr[15:1], 1'b0},  // XGVBR
226 17 rehayes
                     xgisp30,              // Reserved
227
                     xgisp74,              // Reserved
228
                     {8'b0, 1'b0, xgchid}, // XGCHID
229 41 rehayes
                     {8'b0, xge, xgfrz, debug_active, 1'b0, xgfact, brk_irq_ena, xg_sw_irq, xgie}  // XGMCTL
230 2 rehayes
                   }
231
                  )
232
  );
233
 
234
  // ---------------------------------------------------------------------------
235
  xgate_regs #(.ARST_LVL(ARST_LVL),
236
               .MAX_CHANNEL(MAX_CHANNEL))
237
    regs(
238
    // outputs
239
    .xge( xge ),
240
    .xgfrz( xgfrz ),
241 15 rehayes
    .xgdbg_set( xgdbg_set ),
242
    .xgdbg_clear( xgdbg_clear ),
243 41 rehayes
    .xgfact( xgfact ),
244 2 rehayes
    .xgss( xgss ),
245
    .xgsweif_c( xgsweif_c ),
246
    .xgie( xgie ),
247 12 rehayes
    .brk_irq_ena( brk_irq_ena ),
248 2 rehayes
    .xgvbr( xgvbr ),
249
    .xgswt( xgswt ),
250
    .xgisp74( xgisp74 ),
251
    .xgisp30( xgisp30 ),
252
    .clear_xgif_7( clear_xgif_7 ),
253
    .clear_xgif_6( clear_xgif_6 ),
254
    .clear_xgif_5( clear_xgif_5 ),
255
    .clear_xgif_4( clear_xgif_4 ),
256
    .clear_xgif_3( clear_xgif_3 ),
257
    .clear_xgif_2( clear_xgif_2 ),
258
    .clear_xgif_1( clear_xgif_1 ),
259
    .clear_xgif_0( clear_xgif_0 ),
260
    .clear_xgif_data( clear_xgif_data ),
261
 
262
    // inputs
263
    .async_rst_b( async_rst_b ),
264
    .sync_reset( sync_reset ),
265
    .bus_clk( wbs_clk_i ),
266
    .write_bus( wbs_dat_i ),
267
    .write_xgmctl( write_xgmctl ),
268
    .write_xgisp74( write_xgisp74 ),
269
    .write_xgisp30( write_xgisp30 ),
270
    .write_xgvbr( write_xgvbr ),
271
    .write_xgif_7( write_xgif_7 ),
272
    .write_xgif_6( write_xgif_6 ),
273
    .write_xgif_5( write_xgif_5 ),
274
    .write_xgif_4( write_xgif_4 ),
275
    .write_xgif_3( write_xgif_3 ),
276
    .write_xgif_2( write_xgif_2 ),
277
    .write_xgif_1( write_xgif_1 ),
278
    .write_xgif_0( write_xgif_0 ),
279
    .write_xgswt( write_xgswt )
280
  );
281
 
282
  // ---------------------------------------------------------------------------
283
  xgate_risc #(.MAX_CHANNEL(MAX_CHANNEL))
284
    risc(
285
    // outputs
286
    .xgate_address( xgate_address ),
287
    .write_mem_strb_l( write_mem_strb_l ),
288
    .write_mem_strb_h( write_mem_strb_h ),
289
    .write_mem_data( write_mem_data ),
290
    .zero_flag( zero_flag ),
291
    .negative_flag( negative_flag ),
292
    .carry_flag( carry_flag ),
293
    .overflow_flag( overflow_flag ),
294
    .xgchid( xgchid ),
295
    .host_semap( host_semap ),
296
    .xgr1( xgr1 ),
297
    .xgr2( xgr2 ),
298
    .xgr3( xgr3 ),
299
    .xgr4( xgr4 ),
300
    .xgr5( xgr5 ),
301
    .xgr6( xgr6 ),
302
    .xgr7( xgr7 ),
303 30 rehayes
    .xgif_status( xgif_status ),
304 12 rehayes
    .debug_active( debug_active ),
305
    .xg_sw_irq( xg_sw_irq ),
306 34 rehayes
    .mem_access( mem_access ),
307 2 rehayes
 
308
    // inputs
309
    .risc_clk( risc_clk ),
310
    .perif_data( wbs_dat_i ),
311
    .async_rst_b( async_rst_b ),
312
    .read_mem_data( read_mem_data ),
313 5 rehayes
    .mem_req_ack( mem_req_ack ),
314 2 rehayes
    .xge( xge ),
315 15 rehayes
    .xgdbg_set( xgdbg_set ),
316
    .xgdbg_clear( xgdbg_clear ),
317 30 rehayes
    .debug_mode_i(debug_mode_i),
318 2 rehayes
    .xgss( xgss ),
319
    .xgvbr( xgvbr ),
320 5 rehayes
    .int_req( int_req ),
321 12 rehayes
    .xgie( xgie ),
322
    .brk_irq_ena( brk_irq_ena ),
323 2 rehayes
    .write_xgsem( write_xgsem ),
324 17 rehayes
    .write_xgchid( write_xgchid ),
325 2 rehayes
    .write_xgccr( write_xgccr ),
326
    .write_xgpc( write_xgpc ),
327
    .write_xgr7( write_xgr7 ),
328
    .write_xgr6( write_xgr6 ),
329
    .write_xgr5( write_xgr5 ),
330
    .write_xgr4( write_xgr4 ),
331
    .write_xgr3( write_xgr3 ),
332
    .write_xgr2( write_xgr2 ),
333
    .write_xgr1( write_xgr1 ),
334
    .clear_xgif_7( clear_xgif_7 ),
335
    .clear_xgif_6( clear_xgif_6 ),
336
    .clear_xgif_5( clear_xgif_5 ),
337
    .clear_xgif_4( clear_xgif_4 ),
338
    .clear_xgif_3( clear_xgif_3 ),
339
    .clear_xgif_2( clear_xgif_2 ),
340
    .clear_xgif_1( clear_xgif_1 ),
341
    .clear_xgif_0( clear_xgif_0 ),
342 12 rehayes
    .xgsweif_c( xgsweif_c ),
343 2 rehayes
    .clear_xgif_data( clear_xgif_data )
344
  );
345
 
346
  xgate_irq_encode #(.MAX_CHANNEL(MAX_CHANNEL))
347
    irq_encode(
348
    // outputs
349
    .int_req( int_req ),
350
    // inputs
351
    .chan_req_i( chan_req_i )
352
  );
353
 
354 5 rehayes
  // ---------------------------------------------------------------------------
355
  // Wishbone Master Bus interface
356
  xgate_wbm_bus #(.ARST_LVL(ARST_LVL))
357
    wishbone_m(
358
  // Wishbone Master Signals
359
    .wbm_dat_o( wbm_dat_o ),
360
    .wbm_we_o( wbm_we_o ),
361
    .wbm_stb_o( wbm_stb_o ),
362
    .wbm_cyc_o( wbm_cyc_o ),
363
    .wbm_sel_o( wbm_sel_o ),
364
    .wbm_adr_o( wbm_adr_o ),
365
    .wbm_dat_i( wbm_dat_i ),
366
    .wbm_ack_i( wbm_ack_i ),
367
    .wbs_clk_i( wbs_clk_i ),
368
    .wbs_rst_i( wbs_rst_i ),
369
    .arst_i( arst_i ),
370
 // XGATE Control Signals
371 34 rehayes
    .xge( xge ),
372
    .mem_access( mem_access ),
373 5 rehayes
    .read_mem_data( read_mem_data ),
374
    .xgate_address( xgate_address ),
375
    .mem_req_ack( mem_req_ack ),
376
    .write_mem_strb_l( write_mem_strb_l ),
377
    .write_mem_strb_h( write_mem_strb_h ),
378
    .write_mem_data( write_mem_data )
379
  );
380 2 rehayes
 
381 5 rehayes
 
382 2 rehayes
endmodule  // xgate_top
383
 

powered by: WebSVN 2.1.0

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