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

Subversion Repositories wb2axip

[/] [wb2axip/] [trunk/] [rtl/] [axim2wbsp.v] - Blame information for rev 10

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

Line No. Rev Author Line
1 8 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    axim2wbsp.v
4
//
5
// Project:     Pipelined Wishbone to AXI converter
6
//
7
// Purpose:     So ... this converter works in the other direction.  This 
8
//              converter takes AXI commands, and organizes them into pipelined
9
//      wishbone commands.
10
//
11
//
12
//      We'll treat AXI as two separate busses: one for writes, another for
13
//      reads, further, we'll insist that the two channels AXI uses for writes
14
//      combine into one channel for our purposes.
15
//
16
//
17
// Creator:     Dan Gisselquist, Ph.D.
18
//              Gisselquist Technology, LLC
19
//
20
////////////////////////////////////////////////////////////////////////////////
21
//
22
// Copyright (C) 2016, Gisselquist Technology, LLC
23
//
24
// This program is free software (firmware): you can redistribute it and/or
25
// modify it under the terms of  the GNU General Public License as published
26
// by the Free Software Foundation, either version 3 of the License, or (at
27
// your option) any later version.
28
//
29
// This program is distributed in the hope that it will be useful, but WITHOUT
30
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
31
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
32
// for more details.
33
//
34
// You should have received a copy of the GNU General Public License along
35
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
36
// target there if the PDF file isn't present.)  If not, see
37
// <http://www.gnu.org/licenses/> for a copy.
38
//
39
// License:     GPL, v3, as defined and found on www.gnu.org,
40
//              http://www.gnu.org/licenses/gpl.html
41
//
42
//
43
////////////////////////////////////////////////////////////////////////////////
44
//
45
//
46
module axim2wbsp( i_clk, i_axi_reset_n,
47
        //
48
        o_axi_awready, // Slave is ready to accept
49
        i_axi_awid, i_axi_awaddr, i_axi_awlen, i_axi_awsize, i_axi_awburst,
50
        i_axi_awlock, i_axi_awcache, i_axi_awprot, i_axi_awqos, i_axi_awvalid,
51
        //
52
        o_axi_wready, i_axi_wdata, i_axi_wstrb, i_axi_wlast, i_axi_wvalid,
53
        //
54
        o_axi_bid, o_axi_bresp, o_axi_bvalid, i_axi_bready,
55
        //
56
        o_axi_arready,  // Read address ready
57
        i_axi_arid,     // Read ID
58
        i_axi_araddr,   // Read address
59
        i_axi_arlen,    // Read Burst Length
60
        i_axi_arsize,   // Read Burst size
61
        i_axi_arburst,  // Read Burst type
62
        i_axi_arlock,   // Read lock type
63
        i_axi_arcache,  // Read Cache type
64
        i_axi_arprot,   // Read Protection type
65
        i_axi_arqos,    // Read Protection type
66
        i_axi_arvalid,  // Read address valid
67
        //
68
        o_axi_rid,     // Response ID
69
        o_axi_rresp,   // Read response
70
        o_axi_rvalid,  // Read reponse valid
71
        o_axi_rdata,    // Read data
72
        o_axi_rlast,    // Read last
73
        i_axi_rready,  // Read Response ready
74
        // Wishbone interface
75
        o_reset, o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data, o_wb_sel,
76
        i_wb_ack, i_wb_stall, i_wb_data, i_wb_err);
77
        //
78
        parameter C_AXI_ID_WIDTH        = 6; // The AXI id width used for R&W
79
                                             // This is an int between 1-16
80
        parameter C_AXI_DATA_WIDTH      = 32;// Width of the AXI R&W data
81
        parameter C_AXI_ADDR_WIDTH      = 28;   // AXI Address width
82
        localparam DW = C_AXI_DATA_WIDTH;
83
        localparam AW =   (C_AXI_DATA_WIDTH==  8) ? (C_AXI_ADDR_WIDTH)
84
                        :((C_AXI_DATA_WIDTH== 16) ? (C_AXI_ADDR_WIDTH-1)
85
                        :((C_AXI_DATA_WIDTH== 32) ? (C_AXI_ADDR_WIDTH-2)
86
                        :((C_AXI_DATA_WIDTH== 64) ? (C_AXI_ADDR_WIDTH-3)
87
                        :((C_AXI_DATA_WIDTH==128) ? (C_AXI_ADDR_WIDTH-4)
88
                        :(C_AXI_ADDR_WIDTH-5)))));
89
        //
90
        input   wire                    i_clk;  // System clock
91
        input   wire                    i_axi_reset_n;
92
 
93
// AXI write address channel signals
94
        output  wire                    o_axi_awready; // Slave is ready to accept
95
        input   wire    [C_AXI_ID_WIDTH-1:0]     i_axi_awid;     // Write ID
96
        input   wire    [C_AXI_ADDR_WIDTH-1:0]   i_axi_awaddr;   // Write address
97
        input   wire    [7:0]            i_axi_awlen;    // Write Burst Length
98
        input   wire    [2:0]            i_axi_awsize;   // Write Burst size
99
        input   wire    [1:0]            i_axi_awburst;  // Write Burst type
100
        input   wire    [0:0]             i_axi_awlock;   // Write lock type
101
        input   wire    [3:0]            i_axi_awcache;  // Write Cache type
102
        input   wire    [2:0]            i_axi_awprot;   // Write Protection type
103
        input   wire    [3:0]            i_axi_awqos;    // Write Quality of Svc
104
        input   wire                    i_axi_awvalid;  // Write address valid
105
 
106
// AXI write data channel signals
107
        output  wire                    o_axi_wready;  // Write data ready
108
        input   wire    [C_AXI_DATA_WIDTH-1:0]   i_axi_wdata;    // Write data
109
        input   wire    [C_AXI_DATA_WIDTH/8-1:0] i_axi_wstrb;    // Write strobes
110
        input   wire                    i_axi_wlast;    // Last write transaction   
111
        input   wire                    i_axi_wvalid;   // Write valid
112
 
113
// AXI write response channel signals
114
        output  wire [C_AXI_ID_WIDTH-1:0] o_axi_bid;     // Response ID
115
        output  wire [1:0]               o_axi_bresp;    // Write response
116
        output  wire                    o_axi_bvalid;  // Write reponse valid
117
        input   wire                    i_axi_bready;  // Response ready
118
 
119
// AXI read address channel signals
120
        output  wire                    o_axi_arready;  // Read address ready
121
        input   wire    [C_AXI_ID_WIDTH-1:0]     i_axi_arid;     // Read ID
122
        input   wire    [C_AXI_ADDR_WIDTH-1:0]   i_axi_araddr;   // Read address
123
        input   wire    [7:0]            i_axi_arlen;    // Read Burst Length
124
        input   wire    [2:0]            i_axi_arsize;   // Read Burst size
125
        input   wire    [1:0]            i_axi_arburst;  // Read Burst type
126
        input   wire    [0:0]             i_axi_arlock;   // Read lock type
127
        input   wire    [3:0]            i_axi_arcache;  // Read Cache type
128
        input   wire    [2:0]            i_axi_arprot;   // Read Protection type
129
        input   wire    [3:0]            i_axi_arqos;    // Read Protection type
130
        input   wire                    i_axi_arvalid;  // Read address valid
131
 
132
// AXI read data channel signals   
133
        output  wire [C_AXI_ID_WIDTH-1:0] o_axi_rid;     // Response ID
134
        output  wire [1:0]               o_axi_rresp;   // Read response
135
        output  wire                    o_axi_rvalid;  // Read reponse valid
136
        output  wire [C_AXI_DATA_WIDTH-1:0] o_axi_rdata;    // Read data
137
        output  wire                    o_axi_rlast;    // Read last
138
        input   wire                    i_axi_rready;  // Read Response ready
139
 
140
        // We'll share the clock and the reset
141
        output  wire                    o_reset;
142
        output  wire                    o_wb_cyc;
143
        output  wire                    o_wb_stb;
144
        output  wire                    o_wb_we;
145
        output  wire [(AW-1):0]  o_wb_addr;
146
        output  wire [(C_AXI_DATA_WIDTH-1):0]    o_wb_data;
147
        output  wire [(C_AXI_DATA_WIDTH/8-1):0]  o_wb_sel;
148
        input   wire                    i_wb_ack;
149
        input   wire                    i_wb_stall;
150
        input   wire [(C_AXI_DATA_WIDTH-1):0]    i_wb_data;
151
        input   wire                    i_wb_err;
152
 
153
 
154
        //
155
        //
156
        //
157
 
158
 
159
        wire    [(AW-1):0]                       w_wb_addr, r_wb_addr;
160
        wire    [(C_AXI_DATA_WIDTH-1):0] w_wb_data;
161
        wire    [(C_AXI_DATA_WIDTH/8-1):0]       w_wb_sel;
162
        wire    r_wb_err, r_wb_cyc, r_wb_stb, r_wb_stall, r_wb_ack;
163
        wire    w_wb_err, w_wb_cyc, w_wb_stb, w_wb_stall, w_wb_ack;
164
 
165
        // verilator lint_off UNUSED
166
        wire    r_wb_we, w_wb_we;
167
 
168
        assign  r_wb_we = 1'b0;
169
        assign  w_wb_we = 1'b1;
170
        // verilator lint_on  UNUSED
171
 
172
        aximwr2wbsp #(
173
                .C_AXI_ID_WIDTH(C_AXI_ID_WIDTH),
174
                .C_AXI_DATA_WIDTH(C_AXI_DATA_WIDTH),
175
                .C_AXI_ADDR_WIDTH(C_AXI_ADDR_WIDTH), .AW(AW))
176
                axi_write_decoder(
177
                        .i_axi_clk(i_clk), .i_axi_reset_n(i_axi_reset_n),
178
                        //
179
                        .o_axi_awready(o_axi_awready),
180
                        .i_axi_awid(   i_axi_awid),
181
                        .i_axi_awaddr( i_axi_awaddr),
182
                        .i_axi_awlen(  i_axi_awlen),
183
                        .i_axi_awsize( i_axi_awsize),
184
                        .i_axi_awburst(i_axi_awburst),
185
                        .i_axi_awlock( i_axi_awlock),
186
                        .i_axi_awcache(i_axi_awcache),
187
                        .i_axi_awprot( i_axi_awprot),
188
                        .i_axi_awqos(  i_axi_awqos),
189
                        .i_axi_awvalid(i_axi_awvalid),
190
                        //
191
                        .o_axi_wready( o_axi_wready),
192
                        .i_axi_wdata(  i_axi_wdata),
193
                        .i_axi_wstrb(  i_axi_wstrb),
194
                        .i_axi_wlast(  i_axi_wlast),
195
                        .i_axi_wvalid( i_axi_wvalid),
196
                        //
197
                        .o_axi_bid(o_axi_bid),
198
                        .o_axi_bresp(o_axi_bresp),
199
                        .o_axi_bvalid(o_axi_bvalid),
200
                        .i_axi_bready(i_axi_bready),
201
                        //
202
                        .o_wb_cyc(  w_wb_cyc),
203
                        .o_wb_stb(  w_wb_stb),
204
                        .o_wb_addr( w_wb_addr),
205
                        .o_wb_data( w_wb_data),
206
                        .o_wb_sel(  w_wb_sel),
207
                        .i_wb_ack(  w_wb_ack),
208
                        .i_wb_stall(w_wb_stall),
209
                        .i_wb_err(  w_wb_err));
210
        assign  w_wb_we = 1'b1;
211
 
212
        aximrd2wbsp #(
213
                .C_AXI_ID_WIDTH(C_AXI_ID_WIDTH),
214
                .C_AXI_DATA_WIDTH(C_AXI_DATA_WIDTH),
215
                .C_AXI_ADDR_WIDTH(C_AXI_ADDR_WIDTH), .AW(AW))
216
                axi_read_decoder(
217
                        .i_axi_clk(i_clk), .i_axi_reset_n(i_axi_reset_n),
218
                        //
219
                        .o_axi_arready(o_axi_arready),
220
                        .i_axi_arid(   i_axi_arid),
221
                        .i_axi_araddr( i_axi_araddr),
222
                        .i_axi_arlen(  i_axi_arlen),
223
                        .i_axi_arsize( i_axi_arsize),
224
                        .i_axi_arburst(i_axi_arburst),
225
                        .i_axi_arlock( i_axi_arlock),
226
                        .i_axi_arcache(i_axi_arcache),
227
                        .i_axi_arprot( i_axi_arprot),
228
                        .i_axi_arqos(  i_axi_arqos),
229
                        .i_axi_arvalid(i_axi_arvalid),
230
                        //
231
                        .o_axi_rid(   o_axi_rid),
232
                        .o_axi_rresp( o_axi_rresp),
233
                        .o_axi_rvalid(o_axi_rvalid),
234
                        .o_axi_rdata( o_axi_rdata),
235
                        .o_axi_rlast( o_axi_rlast),
236
                        .i_axi_rready(i_axi_rready),
237
                        //
238
                        .o_wb_cyc(  r_wb_cyc),
239
                        .o_wb_stb(  r_wb_stb),
240
                        .o_wb_addr( r_wb_addr),
241
                        .i_wb_ack(  r_wb_ack),
242
                        .i_wb_stall(r_wb_stall),
243
                        .i_wb_data( i_wb_data),
244
                        .i_wb_err(  r_wb_err));
245
 
246
        wbarbiter       #(
247
`ifdef  FORMAL
248
                .F_LGDEPTH(C_AXI_DATA_WIDTH),
249
`endif
250
                .DW(C_AXI_DATA_WIDTH),
251
                .AW(AW))
252
                readorwrite(i_clk, !i_axi_reset_n,
253
                r_wb_cyc, r_wb_stb, 1'b0, r_wb_addr, w_wb_data, w_wb_sel,
254
                        r_wb_ack, r_wb_stall, r_wb_err,
255
                w_wb_cyc, w_wb_stb, 1'b1, w_wb_addr, w_wb_data, w_wb_sel,
256
                        w_wb_ack, w_wb_stall, w_wb_err,
257
                o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data, o_wb_sel,
258
                        i_wb_ack, i_wb_stall, i_wb_err);
259
 
260
        assign  o_reset = (i_axi_reset_n == 1'b0);
261
 
262
`ifdef  FORMAL
263
 
264
`ifdef  AXIM2WBSP
265
        reg     f_last_clk;
266
 
267
        initial f_last_clk = 0;
268
        always @($global_clock)
269
        begin
270
                assume(i_clk == f_last_clk);
271
                f_last_clk <= !f_last_clk;
272
        end
273
`else
274
`endif
275
 
276
        reg     f_past_valid;
277
 
278
        initial f_past_valid = 1'b0;
279
        always @(posedge i_clk)
280
                f_past_valid = 1'b1;
281
 
282
        wire    [(C_AXI_ID_WIDTH-1):0]           f_axi_rd_outstanding,
283
                                                f_axi_wr_outstanding,
284
                                                f_axi_awr_outstanding;
285
        wire    [((1<<C_AXI_ID_WIDTH)-1):0]      f_axi_rd_id_outstanding,
286
                                                f_axi_awr_id_outstanding,
287
                                                f_axi_wr_id_outstanding;
288
        wire    [(C_AXI_ID_WIDTH-1):0]           f_wb_nreqs,
289
                                                f_wb_nacks, f_wb_outstanding;
290
        wire    [(C_AXI_ID_WIDTH-1):0]           f_wb_wr_nreqs,
291
                                                f_wb_wr_nacks, f_wb_wr_outstanding;
292
        wire    [(C_AXI_ID_WIDTH-1):0]           f_wb_rd_nreqs,
293
                                                f_wb_rd_nacks, f_wb_rd_outstanding;
294
 
295
        fwb_slave #(.DW(DW), .AW(AW),
296
                        .F_MAX_STALL(0),
297
                        .F_MAX_ACK_DELAY(0),
298
                        .F_LGDEPTH(C_AXI_ID_WIDTH),
299
                        .F_OPT_RMW_BUS_OPTION(1),
300
                        .F_OPT_DISCONTINUOUS(1))
301
                f_wb_wr(i_clk, !i_axi_reset_n,
302
                        w_wb_cyc, w_wb_stb, w_wb_we, w_wb_addr, w_wb_data,
303
                                w_wb_sel,
304
                        w_wb_ack, w_wb_stall, i_wb_data, w_wb_err,
305
                        f_wb_wr_nreqs, f_wb_wr_nacks, f_wb_wr_outstanding);
306
 
307
        fwb_slave #(.DW(DW), .AW(AW),
308
                        .F_MAX_STALL(0),
309
                        .F_MAX_ACK_DELAY(0),
310
                        .F_LGDEPTH(C_AXI_ID_WIDTH),
311
                        .F_OPT_RMW_BUS_OPTION(1),
312
                        .F_OPT_DISCONTINUOUS(1))
313
                f_wb_rd(i_clk, !i_axi_reset_n,
314
                        r_wb_cyc, r_wb_stb, r_wb_we, r_wb_addr, w_wb_data, w_wb_sel,
315
                                r_wb_ack, r_wb_stall, i_wb_data, r_wb_err,
316
                        f_wb_rd_nreqs, f_wb_rd_nacks, f_wb_rd_outstanding);
317
 
318
        fwb_master #(.DW(DW), .AW(AW),
319
                        .F_MAX_STALL(3),
320
                        .F_MAX_ACK_DELAY(3),
321
                        .F_LGDEPTH(C_AXI_ID_WIDTH))
322
                f_wb(i_clk, !i_axi_reset_n,
323
                        o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
324
                                o_wb_sel,
325
                        i_wb_ack, i_wb_stall, i_wb_data, i_wb_err,
326
                        f_wb_nreqs, f_wb_nacks, f_wb_outstanding);
327
 
328
        always @(*)
329
                assume(i_axi_awlen < 8'h4);
330
 
331
        always @(*)
332
                assume(i_axi_arlen < 8'h4);
333
 
334
        always @(*)
335
                assume(i_axi_arvalid == 0);
336
 
337
        faxi_slave #(
338
                        .C_AXI_ID_WIDTH(C_AXI_ID_WIDTH),
339
                        .C_AXI_DATA_WIDTH(C_AXI_DATA_WIDTH),
340
                        .C_AXI_ADDR_WIDTH(C_AXI_ADDR_WIDTH),
341
                        .F_AXI_MAXSTALL(0),
342
                        .F_AXI_MAXDELAY(0))
343
                f_axi(.i_clk(i_clk), .i_axi_reset_n(i_axi_reset_n),
344
                        // AXI write address channnel
345
                        .i_axi_awready(o_axi_awready),
346
                        .i_axi_awid(   i_axi_awid),
347
                        .i_axi_awaddr( i_axi_awaddr),
348
                        .i_axi_awlen(  i_axi_awlen),
349
                        .i_axi_awsize( i_axi_awsize),
350
                        .i_axi_awburst(i_axi_awburst),
351
                        .i_axi_awlock( i_axi_awlock),
352
                        .i_axi_awcache(i_axi_awcache),
353
                        .i_axi_awprot( i_axi_awprot),
354
                        .i_axi_awqos(  i_axi_awqos),
355
                        .i_axi_awvalid(i_axi_awvalid),
356
                        // AXI write data channel
357
                        .i_axi_wready( o_axi_wready),
358
                        .i_axi_wdata(  i_axi_wdata),
359
                        .i_axi_wstrb(  i_axi_wstrb),
360
                        .i_axi_wlast(  i_axi_wlast),
361
                        .i_axi_wvalid( i_axi_wvalid),
362
                        // AXI write acknowledgement channel
363
                        .i_axi_bid(   o_axi_bid),       // Response ID
364
                        .i_axi_bresp( o_axi_bresp),     // Write response
365
                        .i_axi_bvalid(o_axi_bvalid),  // Write reponse valid
366
                        .i_axi_bready(i_axi_bready),  // Response ready
367
                        // AXI read address channel
368
                        .i_axi_arready(o_axi_arready),  // Read address ready
369
                        .i_axi_arid(   i_axi_arid),     // Read ID
370
                        .i_axi_araddr( i_axi_araddr),   // Read address
371
                        .i_axi_arlen(  i_axi_arlen),    // Read Burst Length
372
                        .i_axi_arsize( i_axi_arsize),   // Read Burst size
373
                        .i_axi_arburst(i_axi_arburst),  // Read Burst type
374
                        .i_axi_arlock( i_axi_arlock),   // Read lock type
375
                        .i_axi_arcache(i_axi_arcache),  // Read Cache type
376
                        .i_axi_arprot( i_axi_arprot),   // Read Protection type
377
                        .i_axi_arqos(  i_axi_arqos),    // Read Protection type
378
                        .i_axi_arvalid(i_axi_arvalid),  // Read address valid
379
                        // AXI read data return
380
                        .i_axi_rid(    o_axi_rid),     // Response ID
381
                        .i_axi_rresp(  o_axi_rresp),   // Read response
382
                        .i_axi_rvalid( o_axi_rvalid),  // Read reponse valid
383
                        .i_axi_rdata(  o_axi_rdata),    // Read data
384
                        .i_axi_rlast(  o_axi_rlast),    // Read last
385
                        .i_axi_rready( i_axi_rready),  // Read Response ready
386
                        // Quantify where we are within a transaction
387
                        .f_axi_rd_outstanding( f_axi_rd_outstanding),
388
                        .f_axi_wr_outstanding( f_axi_wr_outstanding),
389
                        .f_axi_awr_outstanding(f_axi_awr_outstanding),
390
                        .f_axi_rd_id_outstanding(f_axi_rd_id_outstanding),
391
                        .f_axi_awr_id_outstanding(f_axi_awr_id_outstanding),
392
                        .f_axi_wr_id_outstanding(f_axi_wr_id_outstanding));
393
 
394
`endif
395
endmodule
396
 

powered by: WebSVN 2.1.0

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