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

Subversion Repositories axi_slave

[/] [axi_slave/] [trunk/] [src/] [base/] [axi_slave_rd_buff.v] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 eyalhoc
<##//////////////////////////////////////////////////////////////////
2 2 eyalhoc
////                                                             ////
3
////  Author: Eyal Hochberg                                      ////
4
////          eyal@provartec.com                                 ////
5
////                                                             ////
6
////  Downloaded from: http://www.opencores.org                  ////
7
/////////////////////////////////////////////////////////////////////
8
////                                                             ////
9
//// Copyright (C) 2010 Provartec LTD                            ////
10
//// www.provartec.com                                           ////
11
//// info@provartec.com                                          ////
12
////                                                             ////
13
//// This source file may be used and distributed without        ////
14
//// restriction provided that this copyright statement is not   ////
15
//// removed from the file and that any derivative work contains ////
16
//// the original copyright notice and the associated disclaimer.////
17
////                                                             ////
18
//// This source file is free software; you can redistribute it  ////
19
//// and/or modify it under the terms of the GNU Lesser General  ////
20
//// Public License as published by the Free Software Foundation.////
21
////                                                             ////
22
//// This source is distributed in the hope that it will be      ////
23
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
24
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
25
//// PURPOSE.  See the GNU Lesser General Public License for more////
26
//// details. http://www.gnu.org/licenses/lgpl.html              ////
27
////                                                             ////
28 13 eyalhoc
//////////////////////////////////////////////////////////////////##>
29 2 eyalhoc
 
30
OUTFILE PREFIX_rd_buff.v
31
 
32
INCLUDE def_axi_slave.txt
33
 
34
module PREFIX_rd_buff(PORTS);
35
 
36
   input                      clk;
37
   input                      reset;
38
 
39
   output                     RD;
40
   input [DATA_BITS-1:0]      DOUT;
41
 
42
   input [LEN_BITS-1:0]       rcmd_len;
43
   input [LEN_BITS-1:0]       rcmd_len2;
44
   input [1:0]                 rcmd_resp;
45
   input                      rcmd_timeout;
46
   input                      rcmd_ready;
47
 
48
   output                     RVALID;
49
   input                      RREADY;
50
   output                     RLAST;
51
   output [DATA_BITS-1:0]     RDATA;
52
   output [1:0]        RRESP;
53
   output                     RD_last;
54
 
55
   input                      RBUSY;
56
 
57
 
58
 
59
   reg [LEN_BITS:0]            valid_counter;
60
   reg [LEN_BITS-1:0]          rd_counter;
61
   wire                       cmd_pending;
62
   reg                        RVALID;
63
   reg [1:0]                   RRESP;
64
   wire                       last_rd;
65
 
66
 
67
   assign                     cmd_pending = RVALID & (~RREADY);
68
 
69
   assign                     RDATA   = DOUT;
70
 
71
 
72
   assign                     RD      = rcmd_ready & (~cmd_pending) & (~RBUSY) & (~rcmd_timeout);
73
 
74
   assign                     RD_last = RD & (rd_counter == rcmd_len);
75
 
76
   assign                     RLAST   = RVALID & (valid_counter == rcmd_len2 + 1'b1);
77
 
78
 
79
 
80
   always @(posedge clk or posedge reset)
81
     if (reset)
82
       RRESP <= #FFD 2'b00;
83
     else if (RD)
84
       RRESP <= #FFD rcmd_resp;
85
 
86
   always @(posedge clk or posedge reset)
87
     if (reset)
88
       RVALID <= #FFD 1'b0;
89
     else if (RD)
90
       RVALID <= #FFD 1'b1;
91
     else if (RVALID & RREADY)
92
       RVALID <= #FFD 1'b0;
93
 
94
 
95
   always @(posedge clk or posedge reset)
96
     if (reset)
97
       valid_counter <= #FFD {LEN_BITS+1{1'b0}};
98
     else if (RVALID & RREADY & RLAST & RD)
99
       valid_counter <= #FFD 'd1;
100
     else if (RVALID & RREADY & RLAST)
101
       valid_counter <= #FFD {LEN_BITS+1{1'b0}};
102
     else if (RD)
103
       valid_counter <= #FFD valid_counter + 1'b1;
104
 
105
   always @(posedge clk or posedge reset)
106
     if (reset)
107
       rd_counter <= #FFD {LEN_BITS{1'b0}};
108
     else if (RD_last)
109
       rd_counter <= #FFD {LEN_BITS{1'b0}};
110
     else if (RD)
111
       rd_counter <= #FFD rd_counter + 1'b1;
112
 
113
 
114
endmodule
115
 
116
 

powered by: WebSVN 2.1.0

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