1 |
2 |
alfik |
/*
|
2 |
|
|
* Copyright (c) 2014, Aleksander Osman
|
3 |
|
|
* All rights reserved.
|
4 |
|
|
*
|
5 |
|
|
* Redistribution and use in source and binary forms, with or without
|
6 |
|
|
* modification, are permitted provided that the following conditions are met:
|
7 |
|
|
*
|
8 |
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
9 |
|
|
* list of conditions and the following disclaimer.
|
10 |
|
|
*
|
11 |
|
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
12 |
|
|
* this list of conditions and the following disclaimer in the documentation
|
13 |
|
|
* and/or other materials provided with the distribution.
|
14 |
|
|
*
|
15 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16 |
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18 |
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
19 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21 |
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
22 |
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23 |
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
24 |
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25 |
|
|
*/
|
26 |
|
|
|
27 |
|
|
`include "defines.v"
|
28 |
|
|
|
29 |
|
|
module prefetch_fifo(
|
30 |
|
|
input clk,
|
31 |
|
|
input rst_n,
|
32 |
|
|
|
33 |
|
|
input pr_reset,
|
34 |
|
|
|
35 |
|
|
//RESP:
|
36 |
|
|
input prefetchfifo_signal_limit_do,
|
37 |
|
|
//END
|
38 |
|
|
|
39 |
|
|
//RESP:
|
40 |
|
|
input prefetchfifo_signal_pf_do,
|
41 |
|
|
//END
|
42 |
|
|
|
43 |
|
|
//RESP:
|
44 |
|
|
input prefetchfifo_write_do,
|
45 |
|
|
input [135:0] prefetchfifo_write_data,
|
46 |
|
|
//END
|
47 |
|
|
|
48 |
|
|
output [4:0] prefetchfifo_used,
|
49 |
|
|
|
50 |
|
|
//RESP:
|
51 |
|
|
input prefetchfifo_accept_do,
|
52 |
|
|
output [67:0] prefetchfifo_accept_data,
|
53 |
|
|
output prefetchfifo_accept_empty
|
54 |
|
|
//END
|
55 |
|
|
);
|
56 |
|
|
|
57 |
|
|
//------------------------------------------------------------------------------
|
58 |
|
|
|
59 |
|
|
assign prefetchfifo_accept_data = (second_processing)? second : q[67:0];
|
60 |
|
|
|
61 |
|
|
assign prefetchfifo_accept_empty= empty && second_processing == `FALSE;
|
62 |
|
|
|
63 |
|
|
//------------------------------------------------------------------------------
|
64 |
|
|
|
65 |
|
|
wire [135:0] q;
|
66 |
|
|
wire empty;
|
67 |
|
|
|
68 |
|
|
//------------------------------------------------------------------------------
|
69 |
|
|
|
70 |
|
|
//------------------------------------------------------------------------------
|
71 |
|
|
|
72 |
|
|
reg second_processing;
|
73 |
|
|
reg [67:0] second;
|
74 |
|
|
|
75 |
|
|
//------------------------------------------------------------------------------
|
76 |
|
|
|
77 |
|
|
always @(posedge clk or negedge rst_n) begin
|
78 |
|
|
if(rst_n == 1'b0) second_processing <= `FALSE;
|
79 |
|
|
else if(pr_reset) second_processing <= `FALSE;
|
80 |
|
|
else if(prefetchfifo_accept_do && second_processing == `FALSE && q[135:132] != 4'd0 && ~(empty)) second_processing <= `TRUE;
|
81 |
|
|
else if(prefetchfifo_accept_do && second_processing == `TRUE) second_processing <= `FALSE;
|
82 |
|
|
end
|
83 |
|
|
|
84 |
|
|
always @(posedge clk or negedge rst_n) begin
|
85 |
|
|
if(rst_n == 1'b0) second <= 68'd0;
|
86 |
|
|
else if(prefetchfifo_accept_do && second_processing == `FALSE) second <= q[135:68];
|
87 |
|
|
end
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
//------------------------------------------------------------------------------
|
91 |
|
|
|
92 |
|
|
simple_fifo #(
|
93 |
|
|
.width (136),
|
94 |
|
|
.widthu (4)
|
95 |
|
|
)
|
96 |
|
|
prefetch_fifo_inst(
|
97 |
|
|
.clk (clk), //input
|
98 |
|
|
.rst_n (rst_n), //input
|
99 |
|
|
.sclr (pr_reset), //input
|
100 |
|
|
|
101 |
|
|
.rdreq (prefetchfifo_accept_do && second_processing == `FALSE), //input
|
102 |
|
|
.wrreq (prefetchfifo_write_do || prefetchfifo_signal_limit_do || prefetchfifo_signal_pf_do), //input
|
103 |
|
|
.data ((prefetchfifo_signal_limit_do)? { 4'd0, 64'd0, `PREFETCH_GP_FAULT, 64'd0 } :
|
104 |
|
|
(prefetchfifo_signal_pf_do)? { 4'd0, 64'd0, `PREFETCH_PF_FAULT, 64'd0 } :
|
105 |
|
|
prefetchfifo_write_data), //input [135:0]
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
.empty (empty), //output
|
109 |
|
|
.full (prefetchfifo_used[4]), //output
|
110 |
|
|
.q (q), //output [135:0]
|
111 |
|
|
.usedw (prefetchfifo_used[3:0]) //output [3:0]
|
112 |
|
|
);
|
113 |
|
|
|
114 |
|
|
//------------------------------------------------------------------------------
|
115 |
|
|
|
116 |
|
|
//------------------------------------------------------------------------------
|
117 |
|
|
|
118 |
|
|
//------------------------------------------------------------------------------
|
119 |
|
|
|
120 |
|
|
//------------------------------------------------------------------------------
|
121 |
|
|
|
122 |
|
|
endmodule
|