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

Subversion Repositories ahb_master

[/] [ahb_master/] [trunk/] [src/] [base/] [axi2ahb_wr_fifo.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 eyalhoc
 
2
INCLUDE def_axi2ahb.txt
3
OUTFILE PREFIX_axi2ahb_wr_fifo.v
4
 
5
module  PREFIX_axi2ahb_wr_fifo (PORTS);
6
 
7
   parameter              FIFO_LINES = EXPR(2 * 16); //double buffer of max burst
8
   parameter              RESP_SLVERR = 2'b10;
9
 
10
   input                  clk;
11
   input                  reset;
12
 
13
   port                   WGROUP_AXI_W;
14
   port                   BGROUP_AXI_B;
15
   output [DATA_BITS-1:0] HWDATA;
16
   input                  HREADY;
17
   input [1:0]            HTRANS;
18
   input                  HRESP;
19
 
20
   input                  cmd_err;
21
   input                  wdata_phase;
22
   output                 wdata_ready;
23
   input                  data_last;
24
 
25
 
26
   wire                   data_push;
27
   wire                   data_pop;
28
   wire                   data_empty;
29
   wire                   data_full;
30
 
31
   wire                   resp_push;
32
   wire                   resp_pop;
33
   wire                   resp_empty;
34
   wire                   resp_full;
35
 
36
   reg [LOG2(CMD_DEPTH):0] burst_cnt;
37
   wire                    burst_full;
38
 
39
   wire                   axi_last;
40
   wire                   ahb_last;
41
   wire [1:0]             cmd_resp;
42
 
43
   assign                 cmd_resp = cmd_err | HRESP ? RESP_SLVERR : 2'b00;
44
 
45
   assign                 wdata_ready = burst_cnt > 'd0;
46
 
47
   assign                 WREADY = (~data_full) & (~burst_full);
48
 
49
 
50
   assign                 data_push = WVALID & WREADY;
51
   assign                 data_pop = wdata_phase & HREADY;
52
 
53
   assign                 axi_last = WVALID & WREADY & WLAST;
54
   assign                 ahb_last = wdata_phase & data_last;
55
 
56
   assign                 burst_full = burst_cnt == {EXPR(LOG2(CMD_DEPTH)+1){1'b1}};
57
 
58
   always @(posedge clk or posedge reset)
59
     if (reset)
60
       burst_cnt <= #FFD 'd0;
61
     else if (axi_last | ahb_last)
62
       burst_cnt <= #FFD burst_cnt + axi_last - ahb_last;
63
 
64
   prgen_fifo #(DATA_BITS, FIFO_LINES)
65
   data_fifo(
66
            .clk(clk),
67
            .reset(reset),
68
            .push(data_push),
69
            .pop(data_pop),
70
            .din({WDATA
71
                  }
72
                 ),
73
            .dout({HWDATA
74
                   }
75
                  ),
76
            .empty(data_empty),
77
            .full(data_full)
78
            );
79
 
80
 
81
   assign                 resp_push = ahb_last;
82
   assign                 resp_pop  = BVALID & BREADY;
83
 
84
   assign                 BVALID = (~resp_empty);
85
 
86
   prgen_fifo #(2+ID_BITS, CMD_DEPTH)
87
   resp_fifo(
88
            .clk(clk),
89
            .reset(reset),
90
            .push(resp_push),
91
            .pop(resp_pop),
92
            .din({cmd_resp,
93
                  WID
94
                  }
95
                 ),
96
            .dout({BRESP,
97
                   BID
98
                   }
99
                  ),
100
            .empty(resp_empty),
101
            .full(resp_full)
102
            );
103
 
104
 
105
 
106
endmodule
107
 
108
 

powered by: WebSVN 2.1.0

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