| 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 icache_read(
|
| 30 |
|
|
|
| 31 |
|
|
input [127:0] line,
|
| 32 |
|
|
input [31:0] read_data,
|
| 33 |
|
|
input [2:0] read_length,
|
| 34 |
|
|
|
| 35 |
|
|
input [31:0] address,
|
| 36 |
|
|
input [4:0] length,
|
| 37 |
|
|
|
| 38 |
|
|
output [11:0] length_burst,
|
| 39 |
|
|
output [11:0] length_line,
|
| 40 |
|
|
output [135:0] prefetch_line,
|
| 41 |
|
|
output [135:0] prefetch_partial
|
| 42 |
|
|
);
|
| 43 |
|
|
|
| 44 |
|
|
//------------------------------------------------------------------------------
|
| 45 |
|
|
|
| 46 |
|
|
//------------------------------------------------------------------------------
|
| 47 |
|
|
|
| 48 |
|
|
assign length_burst =
|
| 49 |
|
|
(address[1:0] == 2'd0)? { 3'd4, 3'd4, 3'd4, 3'd4 } :
|
| 50 |
|
|
(address[1:0] == 2'd1)? { 3'd4, 3'd4, 3'd4, 3'd3 } :
|
| 51 |
|
|
(address[1:0] == 2'd2)? { 3'd4, 3'd4, 3'd4, 3'd2 } :
|
| 52 |
|
|
{ 3'd4, 3'd4, 3'd4, 3'd1 };
|
| 53 |
|
|
assign length_line =
|
| 54 |
|
|
(address[3:0] == 4'd0)? { 3'd4, 3'd4, 3'd4, 3'd4 } :
|
| 55 |
|
|
(address[3:0] == 4'd1)? { 3'd4, 3'd4, 3'd4, 3'd3 } :
|
| 56 |
|
|
(address[3:0] == 4'd2)? { 3'd4, 3'd4, 3'd4, 3'd2 } :
|
| 57 |
|
|
(address[3:0] == 4'd3)? { 3'd4, 3'd4, 3'd4, 3'd1 } :
|
| 58 |
|
|
(address[3:0] == 4'd4)? { 3'd4, 3'd4, 3'd4, 3'd0 } :
|
| 59 |
|
|
(address[3:0] == 4'd5)? { 3'd4, 3'd4, 3'd3, 3'd0 } :
|
| 60 |
|
|
(address[3:0] == 4'd6)? { 3'd4, 3'd4, 3'd2, 3'd0 } :
|
| 61 |
|
|
(address[3:0] == 4'd7)? { 3'd4, 3'd4, 3'd1, 3'd0 } :
|
| 62 |
|
|
(address[3:0] == 4'd8)? { 3'd4, 3'd4, 3'd0, 3'd0 } :
|
| 63 |
|
|
(address[3:0] == 4'd9)? { 3'd4, 3'd3, 3'd0, 3'd0 } :
|
| 64 |
|
|
(address[3:0] == 4'd10)? { 3'd4, 3'd2, 3'd0, 3'd0 } :
|
| 65 |
|
|
(address[3:0] == 4'd11)? { 3'd4, 3'd1, 3'd0, 3'd0 } :
|
| 66 |
|
|
(address[3:0] == 4'd12)? { 3'd4, 3'd0, 3'd0, 3'd0 } :
|
| 67 |
|
|
(address[3:0] == 4'd13)? { 3'd3, 3'd0, 3'd0, 3'd0 } :
|
| 68 |
|
|
(address[3:0] == 4'd14)? { 3'd2, 3'd0, 3'd0, 3'd0 } :
|
| 69 |
|
|
{ 3'd1, 3'd0, 3'd0, 3'd0 };
|
| 70 |
|
|
|
| 71 |
|
|
assign prefetch_line =
|
| 72 |
|
|
(address[3:0] == 4'd15)? { 4'd0, 64'd0, 4'd1, 56'd0, line[127:120] } :
|
| 73 |
|
|
(address[3:0] == 4'd14)? { 4'd0, 64'd0, (length > 5'd2)? 4'd2 : length[3:0], 48'd0, line[127:112] } :
|
| 74 |
|
|
(address[3:0] == 4'd13)? { 4'd0, 64'd0, (length > 5'd3)? 4'd3 : length[3:0], 40'd0, line[127:104] } :
|
| 75 |
|
|
(address[3:0] == 4'd12)? { 4'd0, 64'd0, (length > 5'd4)? 4'd4 : length[3:0], 32'd0, line[127:96] } :
|
| 76 |
|
|
(address[3:0] == 4'd11)? { 4'd0, 64'd0, (length > 5'd5)? 4'd5 : length[3:0], 24'd0, line[127:88] } :
|
| 77 |
|
|
(address[3:0] == 4'd10)? { 4'd0, 64'd0, (length > 5'd6)? 4'd6 : length[3:0], 16'd0, line[127:80] } :
|
| 78 |
|
|
(address[3:0] == 4'd9)? { 4'd0, 64'd0, (length > 5'd7)? 4'd7 : length[3:0], 8'd0, line[127:72] } :
|
| 79 |
|
|
(address[3:0] == 4'd8)? { 4'd0, 64'd0, (length > 5'd8)? 4'd8 : length[3:0], line[127:64] } :
|
| 80 |
|
|
(address[3:0] == 4'd7)? { (length > 5'd8)? 4'd1 : 4'd0, 56'd0, line[127:120], (length > 5'd8)? 4'd8 : length[3:0], line[119:56] } :
|
| 81 |
|
|
(address[3:0] == 4'd6)? { (length > 5'd9)? 4'd2 : (length > 5'd8)? { 1'b0, length[2:0] } : 4'd0, 48'd0, line[127:112], (length > 5'd8)? 4'd8 : length[3:0], line[111:48] } :
|
| 82 |
|
|
(address[3:0] == 4'd5)? { (length > 5'd10)? 4'd3 : (length > 5'd8)? { 1'b0, length[2:0] } : 4'd0, 40'd0, line[127:104], (length > 5'd8)? 4'd8 : length[3:0], line[103:40] } :
|
| 83 |
|
|
(address[3:0] == 4'd4)? { (length > 5'd11)? 4'd4 : (length > 5'd8)? { 1'b0, length[2:0] } : 4'd0, 32'd0, line[127:96], (length > 5'd8)? 4'd8 : length[3:0], line[95:32] } :
|
| 84 |
|
|
(address[3:0] == 4'd3)? { (length > 5'd12)? 4'd5 : (length > 5'd8)? { 1'b0, length[2:0] } : 4'd0, 24'd0, line[127:88], (length > 5'd8)? 4'd8 : length[3:0], line[87:24] } :
|
| 85 |
|
|
(address[3:0] == 4'd2)? { (length > 5'd13)? 4'd6 : (length > 5'd8)? { 1'b0, length[2:0] } : 4'd0, 16'd0, line[127:80], (length > 5'd8)? 4'd8 : length[3:0], line[79:16] } :
|
| 86 |
|
|
(address[3:0] == 4'd1)? { (length > 5'd14)? 4'd7 : (length > 5'd8)? { 1'b0, length[2:0] } : 4'd0, 8'd0, line[127:72], (length > 5'd8)? 4'd8 : length[3:0], line[71:8] } :
|
| 87 |
|
|
{ (length > 5'd15)? 4'd8 : (length > 5'd8)? { 1'b0, length[2:0] } : 4'd0, line[127:64], (length > 5'd8)? 4'd8 : length[3:0], line[63:0] };
|
| 88 |
|
|
|
| 89 |
|
|
assign prefetch_partial =
|
| 90 |
|
|
(read_length[2:0] == 3'd1)? { 4'd0, 64'd0, 4'd1, 56'd0, read_data[31:24] } :
|
| 91 |
|
|
(read_length[2:0] == 3'd2)? { 4'd0, 64'd0, (length > 5'd2)? 4'd2 : length[3:0], 48'd0, read_data[31:16] } :
|
| 92 |
|
|
(read_length[2:0] == 3'd3)? { 4'd0, 64'd0, (length > 5'd3)? 4'd3 : length[3:0], 40'd0, read_data[31:8] } :
|
| 93 |
|
|
{ 4'd0, 64'd0, (length > 5'd4)? 4'd4 : length[3:0], 32'd0, read_data[31:0] };
|
| 94 |
|
|
|
| 95 |
|
|
//------------------------------------------------------------------------------
|
| 96 |
|
|
|
| 97 |
|
|
//------------------------------------------------------------------------------
|
| 98 |
|
|
|
| 99 |
|
|
// synthesis translate_off
|
| 100 |
|
|
wire _unused_ok = &{ 1'b0, address[31:4], 1'b0 };
|
| 101 |
|
|
// synthesis translate_on
|
| 102 |
|
|
|
| 103 |
|
|
//------------------------------------------------------------------------------
|
| 104 |
|
|
|
| 105 |
|
|
endmodule
|