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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [wb.v] - Blame information for rev 79

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

Line No. Rev Author Line
1 12 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Versatile library, wishbone stuff                           ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  Wishbone compliant modules                                  ////
7
////                                                              ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////   -                                                          ////
11
////                                                              ////
12
////  Author(s):                                                  ////
13
////      - Michael Unneback, unneback@opencores.org              ////
14
////        ORSoC AB                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2010 Authors and OPENCORES.ORG                 ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43 75 unneback
`ifdef WB_ADR_INC
44
// async wb3 - wb3 bridge
45
`timescale 1ns/1ns
46
`define MODULE wb_adr_inc
47
module `BASE`MODULE (
48
`undef MODULE
49
 
50
    always @ (posedge clk or posedge rst)
51
        if (rst)
52
           col_reg <= {col_reg_width{1'b0}};
53
        else
54
            case (state)
55
            `FSM_IDLE:
56
               col_reg <= col[col_reg_width-1:0];
57
            `FSM_RW:
58
               if (~stall)
59
                  case (bte_i)
60
`ifdef SDR_BEAT4
61
                        beat4:  col_reg[2:0] <= col_reg[2:0] + 3'd1;
62
`endif
63
`ifdef SDR_BEAT8
64
                        beat8:  col_reg[3:0] <= col_reg[3:0] + 4'd1;
65
`endif
66
`ifdef SDR_BEAT16
67
                        beat16: col_reg[4:0] <= col_reg[4:0] + 5'd1;
68
`endif
69
                  endcase
70
            endcase
71
`endif
72
 
73 40 unneback
`ifdef WB3WB3_BRIDGE
74 12 unneback
// async wb3 - wb3 bridge
75
`timescale 1ns/1ns
76 40 unneback
`define MODULE wb3wb3_bridge
77
module `BASE`MODULE (
78
`undef MODULE
79 12 unneback
        // wishbone slave side
80
        wbs_dat_i, wbs_adr_i, wbs_sel_i, wbs_bte_i, wbs_cti_i, wbs_we_i, wbs_cyc_i, wbs_stb_i, wbs_dat_o, wbs_ack_o, wbs_clk, wbs_rst,
81
        // wishbone master side
82
        wbm_dat_o, wbm_adr_o, wbm_sel_o, wbm_bte_o, wbm_cti_o, wbm_we_o, wbm_cyc_o, wbm_stb_o, wbm_dat_i, wbm_ack_i, wbm_clk, wbm_rst);
83
 
84
input [31:0] wbs_dat_i;
85
input [31:2] wbs_adr_i;
86
input [3:0]  wbs_sel_i;
87
input [1:0]  wbs_bte_i;
88
input [2:0]  wbs_cti_i;
89
input wbs_we_i, wbs_cyc_i, wbs_stb_i;
90
output [31:0] wbs_dat_o;
91 14 unneback
output wbs_ack_o;
92 12 unneback
input wbs_clk, wbs_rst;
93
 
94
output [31:0] wbm_dat_o;
95
output reg [31:2] wbm_adr_o;
96
output [3:0]  wbm_sel_o;
97
output reg [1:0]  wbm_bte_o;
98
output reg [2:0]  wbm_cti_o;
99 14 unneback
output reg wbm_we_o;
100
output wbm_cyc_o;
101 12 unneback
output wbm_stb_o;
102
input [31:0]  wbm_dat_i;
103
input wbm_ack_i;
104
input wbm_clk, wbm_rst;
105
 
106
parameter addr_width = 4;
107
 
108
// bte
109
parameter linear       = 2'b00;
110
parameter wrap4        = 2'b01;
111
parameter wrap8        = 2'b10;
112
parameter wrap16       = 2'b11;
113
// cti
114
parameter classic      = 3'b000;
115
parameter incburst     = 3'b010;
116
parameter endofburst   = 3'b111;
117
 
118
parameter wbs_adr  = 1'b0;
119
parameter wbs_data = 1'b1;
120
 
121 33 unneback
parameter wbm_adr0      = 2'b00;
122
parameter wbm_adr1      = 2'b01;
123
parameter wbm_data      = 2'b10;
124
parameter wbm_data_wait = 2'b11;
125 12 unneback
 
126
reg [1:0] wbs_bte_reg;
127
reg wbs;
128
wire wbs_eoc_alert, wbm_eoc_alert;
129
reg wbs_eoc, wbm_eoc;
130
reg [1:0] wbm;
131
 
132 14 unneback
wire [1:16] wbs_count, wbm_count;
133 12 unneback
 
134
wire [35:0] a_d, a_q, b_d, b_q;
135
wire a_wr, a_rd, a_fifo_full, a_fifo_empty, b_wr, b_rd, b_fifo_full, b_fifo_empty;
136
reg a_rd_reg;
137
wire b_rd_adr, b_rd_data;
138 14 unneback
wire b_rd_data_reg;
139
wire [35:0] temp;
140 12 unneback
 
141
`define WE 5
142
`define BTE 4:3
143
`define CTI 2:0
144
 
145
assign wbs_eoc_alert = (wbs_bte_reg==wrap4 & wbs_count[3]) | (wbs_bte_reg==wrap8 & wbs_count[7]) | (wbs_bte_reg==wrap16 & wbs_count[15]);
146
always @ (posedge wbs_clk or posedge wbs_rst)
147
if (wbs_rst)
148
        wbs_eoc <= 1'b0;
149
else
150
        if (wbs==wbs_adr & wbs_stb_i & !a_fifo_full)
151 78 unneback
                wbs_eoc <= (wbs_bte_i==linear) | (wbs_cti_i==3'b111);
152 12 unneback
        else if (wbs_eoc_alert & (a_rd | a_wr))
153
                wbs_eoc <= 1'b1;
154
 
155 40 unneback
`define MODULE cnt_shreg_ce_clear
156
`BASE`MODULE # ( .length(16))
157
`undef MODULE
158 12 unneback
    cnt0 (
159
        .cke(wbs_ack_o),
160
        .clear(wbs_eoc),
161
        .q(wbs_count),
162
        .rst(wbs_rst),
163
        .clk(wbs_clk));
164
 
165
always @ (posedge wbs_clk or posedge wbs_rst)
166
if (wbs_rst)
167
        wbs <= wbs_adr;
168
else
169 75 unneback
        if ((wbs==wbs_adr) & wbs_cyc_i & wbs_stb_i & a_fifo_empty)
170 12 unneback
                wbs <= wbs_data;
171
        else if (wbs_eoc & wbs_ack_o)
172
                wbs <= wbs_adr;
173
 
174
// wbs FIFO
175 75 unneback
assign a_d = (wbs==wbs_adr) ? {wbs_adr_i[31:2],wbs_we_i,((wbs_cti_i==3'b111) ? {2'b00,3'b000} : {wbs_bte_i,wbs_cti_i})} : {wbs_dat_i,wbs_sel_i};
176
assign a_wr = (wbs==wbs_adr)  ? wbs_cyc_i & wbs_stb_i & a_fifo_empty :
177 12 unneback
              (wbs==wbs_data) ? wbs_we_i  & wbs_stb_i & !a_fifo_full :
178
              1'b0;
179
assign a_rd = !a_fifo_empty;
180
always @ (posedge wbs_clk or posedge wbs_rst)
181
if (wbs_rst)
182
        a_rd_reg <= 1'b0;
183
else
184
        a_rd_reg <= a_rd;
185
assign wbs_ack_o = a_rd_reg | (a_wr & wbs==wbs_data);
186
 
187
assign wbs_dat_o = a_q[35:4];
188
 
189
always @ (posedge wbs_clk or posedge wbs_rst)
190
if (wbs_rst)
191 13 unneback
        wbs_bte_reg <= 2'b00;
192 12 unneback
else
193 13 unneback
        wbs_bte_reg <= wbs_bte_i;
194 12 unneback
 
195
// wbm FIFO
196
assign wbm_eoc_alert = (wbm_bte_o==wrap4 & wbm_count[3]) | (wbm_bte_o==wrap8 & wbm_count[7]) | (wbm_bte_o==wrap16 & wbm_count[15]);
197
always @ (posedge wbm_clk or posedge wbm_rst)
198
if (wbm_rst)
199
        wbm_eoc <= 1'b0;
200
else
201
        if (wbm==wbm_adr0 & !b_fifo_empty)
202
                wbm_eoc <= b_q[`BTE] == linear;
203
        else if (wbm_eoc_alert & wbm_ack_i)
204
                wbm_eoc <= 1'b1;
205
 
206
always @ (posedge wbm_clk or posedge wbm_rst)
207
if (wbm_rst)
208
        wbm <= wbm_adr0;
209
else
210 33 unneback
/*
211 12 unneback
    if ((wbm==wbm_adr0 & !b_fifo_empty) |
212
        (wbm==wbm_adr1 & !b_fifo_empty & wbm_we_o) |
213
        (wbm==wbm_adr1 & !wbm_we_o) |
214
        (wbm==wbm_data & wbm_ack_i & wbm_eoc))
215
        wbm <= {wbm[0],!(wbm[1] ^ wbm[0])};  // count sequence 00,01,10
216 33 unneback
*/
217
    case (wbm)
218
    wbm_adr0:
219
        if (!b_fifo_empty)
220
            wbm <= wbm_adr1;
221
    wbm_adr1:
222
        if (!wbm_we_o | (!b_fifo_empty & wbm_we_o))
223
            wbm <= wbm_data;
224
    wbm_data:
225
        if (wbm_ack_i & wbm_eoc)
226
            wbm <= wbm_adr0;
227
        else if (b_fifo_empty & wbm_we_o & wbm_ack_i)
228
            wbm <= wbm_data_wait;
229
    wbm_data_wait:
230
        if (!b_fifo_empty)
231
            wbm <= wbm_data;
232
    endcase
233 12 unneback
 
234
assign b_d = {wbm_dat_i,4'b1111};
235
assign b_wr = !wbm_we_o & wbm_ack_i;
236
assign b_rd_adr  = (wbm==wbm_adr0 & !b_fifo_empty);
237
assign b_rd_data = (wbm==wbm_adr1 & !b_fifo_empty & wbm_we_o) ? 1'b1 : // b_q[`WE]
238
                   (wbm==wbm_data & !b_fifo_empty & wbm_we_o & wbm_ack_i & !wbm_eoc) ? 1'b1 :
239 33 unneback
                   (wbm==wbm_data_wait & !b_fifo_empty) ? 1'b1 :
240 12 unneback
                   1'b0;
241
assign b_rd = b_rd_adr | b_rd_data;
242
 
243 40 unneback
`define MODULE dff
244
`BASE`MODULE dff1 ( .d(b_rd_data), .q(b_rd_data_reg), .clk(wbm_clk), .rst(wbm_rst));
245
`undef MODULE
246
`define MODULE dff_ce
247
`BASE`MODULE # ( .width(36)) dff2 ( .d(b_q), .ce(b_rd_data_reg), .q(temp), .clk(wbm_clk), .rst(wbm_rst));
248
`undef MODULE
249 12 unneback
 
250
assign {wbm_dat_o,wbm_sel_o} = (b_rd_data_reg) ? b_q : temp;
251
 
252 40 unneback
`define MODULE cnt_shreg_ce_clear
253 42 unneback
`BASE`MODULE # ( .length(16))
254 40 unneback
`undef MODULE
255 12 unneback
    cnt1 (
256
        .cke(wbm_ack_i),
257
        .clear(wbm_eoc),
258
        .q(wbm_count),
259
        .rst(wbm_rst),
260
        .clk(wbm_clk));
261
 
262 33 unneback
assign wbm_cyc_o = (wbm==wbm_data | wbm==wbm_data_wait);
263
assign wbm_stb_o = (wbm==wbm_data);
264 12 unneback
 
265
always @ (posedge wbm_clk or posedge wbm_rst)
266
if (wbm_rst)
267
        {wbm_adr_o,wbm_we_o,wbm_bte_o,wbm_cti_o} <= {30'h0,1'b0,linear,classic};
268
else begin
269
        if (wbm==wbm_adr0 & !b_fifo_empty)
270
                {wbm_adr_o,wbm_we_o,wbm_bte_o,wbm_cti_o} <= b_q;
271
        else if (wbm_eoc_alert & wbm_ack_i)
272
                wbm_cti_o <= endofburst;
273
end
274
 
275
//async_fifo_dw_simplex_top
276 40 unneback
`define MODULE fifo_2r2w_async_simplex
277
`BASE`MODULE
278
`undef MODULE
279 12 unneback
# ( .data_width(36), .addr_width(addr_width))
280
fifo (
281
    // a side
282
    .a_d(a_d),
283
    .a_wr(a_wr),
284
    .a_fifo_full(a_fifo_full),
285
    .a_q(a_q),
286
    .a_rd(a_rd),
287
    .a_fifo_empty(a_fifo_empty),
288
    .a_clk(wbs_clk),
289
    .a_rst(wbs_rst),
290
    // b side
291
    .b_d(b_d),
292
    .b_wr(b_wr),
293
    .b_fifo_full(b_fifo_full),
294
    .b_q(b_q),
295
    .b_rd(b_rd),
296
    .b_fifo_empty(b_fifo_empty),
297
    .b_clk(wbm_clk),
298
    .b_rst(wbm_rst)
299
    );
300
 
301
endmodule
302 40 unneback
`undef WE
303
`undef BTE
304
`undef CTI
305
`endif
306 17 unneback
 
307 75 unneback
`ifdef WB3AVALON_BRIDGE
308
`define MODULE wb3avalon_bridge
309
module `BASE`MODULE (
310
`undef MODULE
311
        // wishbone slave side
312
        wbs_dat_i, wbs_adr_i, wbs_sel_i, wbs_bte_i, wbs_cti_i, wbs_we_i, wbs_cyc_i, wbs_stb_i, wbs_dat_o, wbs_ack_o, wbs_clk, wbs_rst,
313 77 unneback
        // avalon master side
314 75 unneback
        readdata, readdatavalid, address, read, be, write, burstcount, writedata, waitrequest, beginbursttransfer, clk, rst);
315
 
316
input [31:0] wbs_dat_i;
317
input [31:2] wbs_adr_i;
318
input [3:0]  wbs_sel_i;
319
input [1:0]  wbs_bte_i;
320
input [2:0]  wbs_cti_i;
321
input wbs_we_i, wbs_cyc_i, wbs_stb_i;
322
output [31:0] wbs_dat_o;
323
output wbs_ack_o;
324
input wbs_clk, wbs_rst;
325
 
326
input [31:0] readdata;
327
output [31:0] writedata;
328
output [31:2] address;
329
output [3:0]  be;
330
output write;
331
output read;
332
output beginbursttransfer;
333
output [3:0] burstcount;
334
input readdatavalid;
335
input waitrequest;
336
input clk;
337
input rst;
338
 
339
wire [1:0] wbm_bte_o;
340
wire [2:0] wbm_cti_o;
341
wire wbm_we_o, wbm_cyc_o, wbm_stb_o, wbm_ack_i;
342
reg last_cyc;
343 79 unneback
reg [3:0] counter;
344 75 unneback
 
345
always @ (posedge clk or posedge rst)
346
if (rst)
347
    last_cyc <= 1'b0;
348
else
349
    last_cyc <= wbm_cyc_o;
350
 
351 79 unneback
always @ (posedge clk or posedge rst)
352
if (rst)
353
    read <= 1'b0;
354
else
355
    if (!last_cyc & wbm_cyc_o)
356
        read <= 1'b1;
357
    else if (!waitrequest)
358
        read <= 1'b0;
359
 
360 75 unneback
assign beginbursttransfer = (!last_cyc & wbm_cyc_o) & wbm_cti_o==3'b010;
361
assign burstcount = (wbm_bte_o==2'b01) ? 4'd4 :
362
                    (wbm_bte_o==2'b10) ? 4'd8 :
363 78 unneback
                    (wbm_bte_o==2'b11) ? 4'd16:
364
                    4'd1;
365 75 unneback
assign wbm_ack_i = (readdatavalid & !waitrequest) | (write & !waitrequest);
366
 
367 79 unneback
always @ (posedge clk or posedge rst)
368
if (rst) begin
369
    counter <= 4'd0;
370
    write <= 1'b0;
371
end else
372
    if (!waitrequest & last_cyc & wbm_cyc_o) begin
373
        write <= 1'b1;
374
        counter <= burstcount -1;
375
    end else if (waitrequest & last_cyc & wbm_cyc_o) begin
376
        write <= 1'b1;
377
        counter <= burstcount;
378
    end else if (!waitrequst) begin
379
        counter <= counter - 4'd1;
380
        write <= (counter!=4'd0 & wbm_stb_o)
381
    end
382
 
383 75 unneback
`define MODULE wb3wb3_bridge
384 77 unneback
`BASE`MODULE wbwb3inst (
385 75 unneback
`undef MODULE
386
    // wishbone slave side
387
    .wbs_dat_i(wbs_dat_i),
388
    .wbs_adr_i(wbs_adr_i),
389
    .wbs_sel_i(wbs_sel_i),
390
    .wbs_bte_i(wbs_bte_i),
391
    .wbs_cti_i(wbs_cti_i),
392
    .wbs_we_i(wbs_we_i),
393
    .wbs_cyc_i(wbs_cyc_i),
394
    .wbs_stb_i(wbs_stb_i),
395
    .wbs_dat_o(wbs_dat_o),
396
    .wbs_ack_o(wbs_ack_o),
397
    .wbs_clk(wbs_clk),
398
    .wbs_rst(wbs_rst),
399
    // wishbone master side
400
    .wbm_dat_o(writedata),
401 78 unneback
    .wbm_adr_o(address),
402 75 unneback
    .wbm_sel_o(be),
403
    .wbm_bte_o(wbm_bte_o),
404
    .wbm_cti_o(wbm_cti_o),
405
    .wbm_we_o(wbm_we_o),
406
    .wbm_cyc_o(wbm_cyc_o),
407
    .wbm_stb_o(wbm_stb_o),
408
    .wbm_dat_i(readdata),
409
    .wbm_ack_i(wbm_ack_i),
410
    .wbm_clk(clk),
411
    .wbm_rst(rst));
412
 
413
 
414
endmodule
415
`endif
416
 
417 40 unneback
`ifdef WB3_ARBITER_TYPE1
418
`define MODULE wb3_arbiter_type1
419 42 unneback
module `BASE`MODULE (
420 40 unneback
`undef MODULE
421 39 unneback
    wbm_dat_o, wbm_adr_o, wbm_sel_o, wbm_cti_o, wbm_bte_o, wbm_we_o, wbm_stb_o, wbm_cyc_o,
422
    wbm_dat_i, wbm_ack_i, wbm_err_i, wbm_rty_i,
423
    wbs_dat_i, wbs_adr_i, wbs_sel_i, wbs_cti_i, wbs_bte_i, wbs_we_i, wbs_stb_i, wbs_cyc_i,
424
    wbs_dat_o, wbs_ack_o, wbs_err_o, wbs_rty_o,
425
    wb_clk, wb_rst
426
);
427
 
428
parameter nr_of_ports = 3;
429
parameter adr_size = 26;
430
parameter adr_lo   = 2;
431
parameter dat_size = 32;
432
parameter sel_size = dat_size/8;
433
 
434
localparam aw = (adr_size - adr_lo) * nr_of_ports;
435
localparam dw = dat_size * nr_of_ports;
436
localparam sw = sel_size * nr_of_ports;
437
localparam cw = 3 * nr_of_ports;
438
localparam bw = 2 * nr_of_ports;
439
 
440
input  [dw-1:0] wbm_dat_o;
441
input  [aw-1:0] wbm_adr_o;
442
input  [sw-1:0] wbm_sel_o;
443
input  [cw-1:0] wbm_cti_o;
444
input  [bw-1:0] wbm_bte_o;
445
input  [nr_of_ports-1:0] wbm_we_o, wbm_stb_o, wbm_cyc_o;
446
output [dw-1:0] wbm_dat_i;
447
output [nr_of_ports-1:0] wbm_ack_i, wbm_err_i, wbm_rty_i;
448
 
449
output [dat_size-1:0] wbs_dat_i;
450
output [adr_size-1:adr_lo] wbs_adr_i;
451
output [sel_size-1:0] wbs_sel_i;
452
output [2:0] wbs_cti_i;
453
output [1:0] wbs_bte_i;
454
output wbs_we_i, wbs_stb_i, wbs_cyc_i;
455
input  [dat_size-1:0] wbs_dat_o;
456
input  wbs_ack_o, wbs_err_o, wbs_rty_o;
457
 
458
input wb_clk, wb_rst;
459
 
460 44 unneback
reg  [nr_of_ports-1:0] select;
461 39 unneback
wire [nr_of_ports-1:0] state;
462
wire [nr_of_ports-1:0] eoc; // end-of-cycle
463
wire [nr_of_ports-1:0] sel;
464
wire idle;
465
 
466
genvar i;
467
 
468
assign idle = !(|state);
469
 
470
generate
471
if (nr_of_ports == 2) begin
472
 
473
    wire [2:0] wbm1_cti_o, wbm0_cti_o;
474
 
475
    assign {wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
476
 
477 44 unneback
    //assign select = (idle) ? {wbm_cyc_o[1],!wbm_cyc_o[1] & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
478
 
479
    always @ (idle or wbm_cyc_o)
480
    if (idle)
481
        casex (wbm_cyc_o)
482
        2'b1x : select = 2'b10;
483
        2'b01 : select = 2'b01;
484
        default : select = {nr_of_ports{1'b0}};
485
        endcase
486
    else
487
        select = {nr_of_ports{1'b0}};
488
 
489 39 unneback
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
490
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
491
 
492
end
493
endgenerate
494
 
495
generate
496
if (nr_of_ports == 3) begin
497
 
498
    wire [2:0] wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
499
 
500
    assign {wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
501
 
502 44 unneback
    always @ (idle or wbm_cyc_o)
503
    if (idle)
504
        casex (wbm_cyc_o)
505
        3'b1xx : select = 3'b100;
506
        3'b01x : select = 3'b010;
507
        3'b001 : select = 3'b001;
508
        default : select = {nr_of_ports{1'b0}};
509
        endcase
510
    else
511
        select = {nr_of_ports{1'b0}};
512
 
513
//    assign select = (idle) ? {wbm_cyc_o[2],!wbm_cyc_o[2] & wbm_cyc_o[1],wbm_cyc_o[2:1]==2'b00 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
514 39 unneback
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
515
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
516
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
517
 
518
end
519
endgenerate
520
 
521
generate
522 44 unneback
if (nr_of_ports == 4) begin
523
 
524
    wire [2:0] wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
525
 
526
    assign {wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
527
 
528
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
529
 
530
    always @ (idle or wbm_cyc_o)
531
    if (idle)
532
        casex (wbm_cyc_o)
533
        4'b1xxx : select = 4'b1000;
534
        4'b01xx : select = 4'b0100;
535
        4'b001x : select = 4'b0010;
536
        4'b0001 : select = 4'b0001;
537
        default : select = {nr_of_ports{1'b0}};
538
        endcase
539
    else
540
        select = {nr_of_ports{1'b0}};
541
 
542
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
543
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
544
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
545
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
546
 
547
end
548
endgenerate
549
 
550
generate
551
if (nr_of_ports == 5) begin
552
 
553
    wire [2:0] wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
554
 
555
    assign {wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
556
 
557
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
558
 
559
    always @ (idle or wbm_cyc_o)
560
    if (idle)
561
        casex (wbm_cyc_o)
562
        5'b1xxxx : select = 5'b10000;
563
        5'b01xxx : select = 5'b01000;
564
        5'b001xx : select = 5'b00100;
565
        5'b0001x : select = 5'b00010;
566
        5'b00001 : select = 5'b00001;
567
        default : select = {nr_of_ports{1'b0}};
568
        endcase
569
    else
570
        select = {nr_of_ports{1'b0}};
571
 
572
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
573
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
574
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
575
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
576
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
577
 
578
end
579
endgenerate
580
 
581
generate
582 67 unneback
if (nr_of_ports == 6) begin
583
 
584
    wire [2:0] wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
585
 
586
    assign {wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
587
 
588
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
589
 
590
    always @ (idle or wbm_cyc_o)
591
    if (idle)
592
        casex (wbm_cyc_o)
593
        6'b1xxxxx : select = 6'b100000;
594
        6'b01xxxx : select = 6'b010000;
595
        6'b001xxx : select = 6'b001000;
596
        6'b0001xx : select = 6'b000100;
597
        6'b00001x : select = 6'b000010;
598
        6'b000001 : select = 6'b000001;
599
        default : select = {nr_of_ports{1'b0}};
600
        endcase
601
    else
602
        select = {nr_of_ports{1'b0}};
603
 
604
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
605
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
606
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
607
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
608
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
609
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
610
 
611
end
612
endgenerate
613
 
614
generate
615
if (nr_of_ports == 7) begin
616
 
617
    wire [2:0] wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
618
 
619
    assign {wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
620
 
621
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
622
 
623
    always @ (idle or wbm_cyc_o)
624
    if (idle)
625
        casex (wbm_cyc_o)
626
        7'b1xxxxxx : select = 7'b1000000;
627
        7'b01xxxxx : select = 7'b0100000;
628
        7'b001xxxx : select = 7'b0010000;
629
        7'b0001xxx : select = 7'b0001000;
630
        7'b00001xx : select = 7'b0000100;
631
        7'b000001x : select = 7'b0000010;
632
        7'b0000001 : select = 7'b0000001;
633
        default : select = {nr_of_ports{1'b0}};
634
        endcase
635
    else
636
        select = {nr_of_ports{1'b0}};
637
 
638
    assign eoc[6] = (wbm_ack_i[6] & (wbm6_cti_o == 3'b000 | wbm6_cti_o == 3'b111)) | !wbm_cyc_o[6];
639
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
640
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
641
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
642
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
643
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
644
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
645
 
646
end
647
endgenerate
648
 
649
generate
650
if (nr_of_ports == 8) begin
651
 
652
    wire [2:0] wbm7_cti_o, wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
653
 
654
    assign {wbm7_cti_o, wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
655
 
656
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
657
 
658
    always @ (idle or wbm_cyc_o)
659
    if (idle)
660
        casex (wbm_cyc_o)
661
        8'b1xxxxxxx : select = 8'b10000000;
662
        8'b01xxxxxx : select = 8'b01000000;
663
        8'b001xxxxx : select = 8'b00100000;
664
        8'b0001xxxx : select = 8'b00010000;
665
        8'b00001xxx : select = 8'b00001000;
666
        8'b000001xx : select = 8'b00000100;
667
        8'b0000001x : select = 8'b00000010;
668
        8'b00000001 : select = 8'b00000001;
669
        default : select = {nr_of_ports{1'b0}};
670
        endcase
671
    else
672
        select = {nr_of_ports{1'b0}};
673
 
674
    assign eoc[7] = (wbm_ack_i[7] & (wbm7_cti_o == 3'b000 | wbm7_cti_o == 3'b111)) | !wbm_cyc_o[7];
675
    assign eoc[6] = (wbm_ack_i[6] & (wbm6_cti_o == 3'b000 | wbm6_cti_o == 3'b111)) | !wbm_cyc_o[6];
676
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
677
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
678
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
679
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
680
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
681
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
682
 
683
end
684
endgenerate
685
 
686
generate
687 63 unneback
for (i=0;i<nr_of_ports;i=i+1) begin : spr0
688 42 unneback
`define MODULE spr
689
    `BASE`MODULE sr0( .sp(select[i]), .r(eoc[i]), .q(state[i]), .clk(wb_clk), .rst(wb_rst));
690
`undef MODULE
691 39 unneback
end
692
endgenerate
693
 
694
    assign sel = select | state;
695
 
696 40 unneback
`define MODULE mux_andor
697
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(32)) mux0 ( .a(wbm_dat_o), .sel(sel), .dout(wbs_dat_i));
698
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(adr_size-adr_lo)) mux1 ( .a(wbm_adr_o), .sel(sel), .dout(wbs_adr_i));
699
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(sel_size)) mux2 ( .a(wbm_sel_o), .sel(sel), .dout(wbs_sel_i));
700
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(3)) mux3 ( .a(wbm_cti_o), .sel(sel), .dout(wbs_cti_i));
701
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(2)) mux4 ( .a(wbm_bte_o), .sel(sel), .dout(wbs_bte_i));
702
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(1)) mux5 ( .a(wbm_we_o), .sel(sel), .dout(wbs_we_i));
703
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(1)) mux6 ( .a(wbm_stb_o), .sel(sel), .dout(wbs_stb_i));
704
`undef MODULE
705 39 unneback
    assign wbs_cyc_i = |sel;
706
 
707
    assign wbm_dat_i = {nr_of_ports{wbs_dat_o}};
708
    assign wbm_ack_i = {nr_of_ports{wbs_ack_o}} & sel;
709
    assign wbm_err_i = {nr_of_ports{wbs_err_o}} & sel;
710
    assign wbm_rty_i = {nr_of_ports{wbs_rty_o}} & sel;
711
 
712
endmodule
713 40 unneback
`endif
714 39 unneback
 
715 60 unneback
`ifdef WB_B3_RAM_BE
716 49 unneback
// WB RAM with byte enable
717 59 unneback
`define MODULE wb_b3_ram_be
718
module `BASE`MODULE (
719
`undef MODULE
720 69 unneback
    wbs_dat_i, wbs_adr_i, wbs_cti_i, wbs_bte_i, wbs_sel_i, wbs_we_i, wbs_stb_i, wbs_cyc_i,
721
    wbs_dat_o, wbs_ack_o, wb_clk, wb_rst);
722 59 unneback
 
723 68 unneback
parameter adr_size = 16;
724 60 unneback
parameter adr_lo   = 2;
725 68 unneback
parameter mem_size = 1<<16;
726 60 unneback
parameter dat_size = 32;
727
parameter memory_init = 1;
728
parameter memory_file = "vl_ram.vmem";
729 59 unneback
 
730 69 unneback
localparam aw = (adr_size - adr_lo);
731
localparam dw = dat_size;
732
localparam sw = dat_size/8;
733
localparam cw = 3;
734
localparam bw = 2;
735 60 unneback
 
736 70 unneback
input [dw-1:0] wbs_dat_i;
737
input [aw-1:0] wbs_adr_i;
738
input [cw-1:0] wbs_cti_i;
739
input [bw-1:0] wbs_bte_i;
740
input [sw-1:0] wbs_sel_i;
741
input wbs_we_i, wbs_stb_i, wbs_cyc_i;
742
output [dw-1:0] wbs_dat_o;
743
output wbs_ack_o;
744 71 unneback
input wb_clk, wb_rst;
745 59 unneback
 
746 60 unneback
wire [sw-1:0] cke;
747 59 unneback
 
748 60 unneback
reg wbs_ack_o;
749
 
750
`define MODULE ram_be
751
`BASE`MODULE # (
752
    .data_width(dat_size),
753 72 unneback
    .addr_width(adr_size-2),
754 69 unneback
    .mem_size(mem_size),
755 68 unneback
    .memory_init(memory_init),
756
    .memory_file(memory_file))
757 60 unneback
ram0(
758
`undef MODULE
759
    .d(wbs_dat_i),
760
    .adr(wbs_adr_i[adr_size-1:2]),
761
    .be(wbs_sel_i),
762
    .we(wbs_we_i),
763
    .q(wbs_dat_o),
764
    .clk(wb_clk)
765
);
766
 
767 59 unneback
always @ (posedge wb_clk or posedge wb_rst)
768
if (wb_rst)
769 60 unneback
    wbs_ack_o <= 1'b0;
770 59 unneback
else
771 60 unneback
    if (wbs_cti_i==3'b000 | wbs_cti_i==3'b111)
772
        wbs_ack_o <= wbs_stb_i & wbs_cyc_i & !wbs_ack_o;
773 59 unneback
    else
774 60 unneback
        wbs_ack_o <= wbs_stb_i & wbs_cyc_i;
775
 
776 59 unneback
endmodule
777
`endif
778
 
779
`ifdef WB_B4_RAM_BE
780
// WB RAM with byte enable
781 49 unneback
`define MODULE wb_b4_ram_be
782
module `BASE`MODULE (
783
`undef MODULE
784
    wb_dat_i, wb_adr_i, wb_sel_i, wb_we_i, wb_stb_i, wb_cyc_i,
785 52 unneback
    wb_dat_o, wb_stall_o, wb_ack_o, wb_clk, wb_rst);
786 49 unneback
 
787
    parameter dat_width = 32;
788
    parameter adr_width = 8;
789
 
790
input [dat_width-1:0] wb_dat_i;
791
input [adr_width-1:0] wb_adr_i;
792
input [dat_width/8-1:0] wb_sel_i;
793
input wb_we_i, wb_stb_i, wb_cyc_i;
794
output [dat_width-1:0] wb_dat_o;
795 51 unneback
reg [dat_width-1:0] wb_dat_o;
796 52 unneback
output wb_stall_o;
797 49 unneback
output wb_ack_o;
798
reg wb_ack_o;
799
input wb_clk, wb_rst;
800
 
801 56 unneback
wire [dat_width/8-1:0] cke;
802
 
803 49 unneback
generate
804
if (dat_width==32) begin
805 51 unneback
reg [7:0] ram3 [1<<(adr_width-2)-1:0];
806
reg [7:0] ram2 [1<<(adr_width-2)-1:0];
807
reg [7:0] ram1 [1<<(adr_width-2)-1:0];
808
reg [7:0] ram0 [1<<(adr_width-2)-1:0];
809 56 unneback
assign cke = wb_sel_i & {(dat_width/8){wb_we_i}};
810 49 unneback
    always @ (posedge wb_clk)
811
    begin
812 56 unneback
        if (cke[3]) ram3[wb_adr_i[adr_width-1:2]] <= wb_dat_i[31:24];
813
        if (cke[2]) ram2[wb_adr_i[adr_width-1:2]] <= wb_dat_i[23:16];
814
        if (cke[1]) ram1[wb_adr_i[adr_width-1:2]] <= wb_dat_i[15:8];
815
        if (cke[0]) ram0[wb_adr_i[adr_width-1:2]] <= wb_dat_i[7:0];
816 49 unneback
    end
817 59 unneback
    always @ (posedge wb_clk or posedge wb_rst)
818
    begin
819
        if (wb_rst)
820
            wb_dat_o <= 32'h0;
821
        else
822
            wb_dat_o <= {ram3[wb_adr_i[adr_width-1:2]],ram2[wb_adr_i[adr_width-1:2]],ram1[wb_adr_i[adr_width-1:2]],ram0[wb_adr_i[adr_width-1:2]]};
823
    end
824 49 unneback
end
825
endgenerate
826
 
827 52 unneback
always @ (posedge wb_clk or posedge wb_rst)
828 55 unneback
if (wb_rst)
829 52 unneback
    wb_ack_o <= 1'b0;
830
else
831 54 unneback
    wb_ack_o <= wb_stb_i & wb_cyc_i;
832 52 unneback
 
833
assign wb_stall_o = 1'b0;
834
 
835 49 unneback
endmodule
836
`endif
837
 
838 48 unneback
`ifdef WB_B4_ROM
839
// WB ROM
840
`define MODULE wb_b4_rom
841
module `BASE`MODULE (
842
`undef MODULE
843
    wb_adr_i, wb_stb_i, wb_cyc_i,
844
    wb_dat_o, stall_o, wb_ack_o, wb_clk, wb_rst);
845
 
846
    parameter dat_width = 32;
847
    parameter dat_default = 32'h15000000;
848
    parameter adr_width = 32;
849
 
850
/*
851
//E2_ifndef ROM
852
//E2_define ROM "rom.v"
853
//E2_endif
854
*/
855
    input [adr_width-1:2]   wb_adr_i;
856
    input                   wb_stb_i;
857
    input                   wb_cyc_i;
858
    output [dat_width-1:0]  wb_dat_o;
859
    reg [dat_width-1:0]     wb_dat_o;
860
    output                  wb_ack_o;
861
    reg                     wb_ack_o;
862
    output                  stall_o;
863
    input                   wb_clk;
864
    input                   wb_rst;
865
 
866
always @ (posedge wb_clk or posedge wb_rst)
867
    if (wb_rst)
868
        wb_dat_o <= {dat_width{1'b0}};
869
    else
870
         case (wb_adr_i[adr_width-1:2])
871
//E2_ifdef ROM
872
//E2_include `ROM
873
//E2_endif
874
           default:
875
             wb_dat_o <= dat_default;
876
 
877
         endcase // case (wb_adr_i)
878
 
879
 
880
always @ (posedge wb_clk or posedge wb_rst)
881
    if (wb_rst)
882
        wb_ack_o <= 1'b0;
883
    else
884
        wb_ack_o <= wb_stb_i & wb_cyc_i;
885
 
886
assign stall_o = 1'b0;
887
 
888
endmodule
889
`endif
890
 
891
 
892 40 unneback
`ifdef WB_BOOT_ROM
893 17 unneback
// WB ROM
894 40 unneback
`define MODULE wb_boot_rom
895
module `BASE`MODULE (
896
`undef MODULE
897 17 unneback
    wb_adr_i, wb_stb_i, wb_cyc_i,
898 18 unneback
    wb_dat_o, wb_ack_o, hit_o, wb_clk, wb_rst);
899 17 unneback
 
900 18 unneback
    parameter adr_hi = 31;
901
    parameter adr_lo = 28;
902
    parameter adr_sel = 4'hf;
903
    parameter addr_width = 5;
904 33 unneback
/*
905 17 unneback
//E2_ifndef BOOT_ROM
906
//E2_define BOOT_ROM "boot_rom.v"
907
//E2_endif
908 33 unneback
*/
909 18 unneback
    input [adr_hi:2]    wb_adr_i;
910
    input               wb_stb_i;
911
    input               wb_cyc_i;
912
    output [31:0]        wb_dat_o;
913
    output              wb_ack_o;
914
    output              hit_o;
915
    input               wb_clk;
916
    input               wb_rst;
917
 
918
    wire hit;
919
    reg [31:0] wb_dat;
920
    reg wb_ack;
921
 
922
assign hit = wb_adr_i[adr_hi:adr_lo] == adr_sel;
923 17 unneback
 
924
always @ (posedge wb_clk or posedge wb_rst)
925
    if (wb_rst)
926 18 unneback
        wb_dat <= 32'h15000000;
927 17 unneback
    else
928 18 unneback
         case (wb_adr_i[addr_width-1:2])
929 33 unneback
//E2_ifdef BOOT_ROM
930 17 unneback
//E2_include `BOOT_ROM
931 33 unneback
//E2_endif
932 17 unneback
           /*
933
            // Zero r0 and jump to 0x00000100
934 18 unneback
 
935
            1 : wb_dat <= 32'hA8200000;
936
            2 : wb_dat <= 32'hA8C00100;
937
            3 : wb_dat <= 32'h44003000;
938
            4 : wb_dat <= 32'h15000000;
939 17 unneback
            */
940
           default:
941 18 unneback
             wb_dat <= 32'h00000000;
942 17 unneback
 
943
         endcase // case (wb_adr_i)
944
 
945
 
946
always @ (posedge wb_clk or posedge wb_rst)
947
    if (wb_rst)
948 18 unneback
        wb_ack <= 1'b0;
949 17 unneback
    else
950 18 unneback
        wb_ack <= wb_stb_i & wb_cyc_i & hit & !wb_ack;
951 17 unneback
 
952 18 unneback
assign hit_o = hit;
953
assign wb_dat_o = wb_dat & {32{wb_ack}};
954
assign wb_ack_o = wb_ack;
955
 
956 17 unneback
endmodule
957 40 unneback
`endif
958 32 unneback
 
959 40 unneback
`ifdef WB_DPRAM
960
`define MODULE wb_dpram
961
module `BASE`MODULE (
962
`undef MODULE
963 32 unneback
        // wishbone slave side a
964
        wbsa_dat_i, wbsa_adr_i, wbsa_we_i, wbsa_cyc_i, wbsa_stb_i, wbsa_dat_o, wbsa_ack_o,
965
        wbsa_clk, wbsa_rst,
966
        // wishbone slave side a
967
        wbsb_dat_i, wbsb_adr_i, wbsb_we_i, wbsb_cyc_i, wbsb_stb_i, wbsb_dat_o, wbsb_ack_o,
968
        wbsb_clk, wbsb_rst);
969
 
970
parameter data_width = 32;
971
parameter addr_width = 8;
972
 
973
parameter dat_o_mask_a = 1;
974
parameter dat_o_mask_b = 1;
975
 
976
input [31:0] wbsa_dat_i;
977
input [addr_width-1:2] wbsa_adr_i;
978
input wbsa_we_i, wbsa_cyc_i, wbsa_stb_i;
979
output [31:0] wbsa_dat_o;
980
output wbsa_ack_o;
981
input wbsa_clk, wbsa_rst;
982
 
983
input [31:0] wbsb_dat_i;
984
input [addr_width-1:2] wbsb_adr_i;
985
input wbsb_we_i, wbsb_cyc_i, wbsb_stb_i;
986
output [31:0] wbsb_dat_o;
987
output wbsb_ack_o;
988
input wbsb_clk, wbsb_rst;
989
 
990
wire wbsa_dat_tmp, wbsb_dat_tmp;
991
 
992 40 unneback
`define MODULE dpram_2r2w
993
`BASE`MODULE # (
994
`undef MODULE
995 33 unneback
    .data_width(data_width), .addr_width(addr_width) )
996 32 unneback
dpram0(
997
    .d_a(wbsa_dat_i),
998
    .q_a(wbsa_dat_tmp),
999
    .adr_a(wbsa_adr_i),
1000
    .we_a(wbsa_we_i),
1001
    .clk_a(wbsa_clk),
1002
    .d_b(wbsb_dat_i),
1003
    .q_b(wbsb_dat_tmp),
1004
    .adr_b(wbsb_adr_i),
1005
    .we_b(wbsb_we_i),
1006
    .clk_b(wbsb_clk) );
1007
 
1008 33 unneback
generate if (dat_o_mask_a==1)
1009 32 unneback
    assign wbsa_dat_o = wbsa_dat_tmp & {data_width{wbsa_ack_o}};
1010
endgenerate
1011 33 unneback
generate if (dat_o_mask_a==0)
1012 32 unneback
    assign wbsa_dat_o = wbsa_dat_tmp;
1013
endgenerate
1014
 
1015 33 unneback
generate if (dat_o_mask_b==1)
1016 32 unneback
    assign wbsb_dat_o = wbsb_dat_tmp & {data_width{wbsb_ack_o}};
1017
endgenerate
1018 33 unneback
generate if (dat_o_mask_b==0)
1019 32 unneback
    assign wbsb_dat_o = wbsb_dat_tmp;
1020
endgenerate
1021
 
1022 40 unneback
`define MODULE spr
1023
`BASE`MODULE ack_a( .sp(wbsa_cyc_i & wbsa_stb_i & !wbsa_ack_o), .r(1'b1), .q(wbsa_ack_o), .clk(wbsa_clk), .rst(wbsa_rst));
1024
`BASE`MODULE ack_b( .sp(wbsb_cyc_i & wbsb_stb_i & !wbsb_ack_o), .r(1'b1), .q(wbsb_ack_o), .clk(wbsb_clk), .rst(wbsb_rst));
1025
`undef MODULE
1026 32 unneback
 
1027
endmodule
1028 40 unneback
`endif

powered by: WebSVN 2.1.0

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