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