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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [memory/] [dcache_matched.v] - Blame information for rev 6

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

Line No. Rev Author Line
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_matched(
30
    input [31:0]    address,
31
 
32
    input [10:0]    control,
33
    input [147:0]   data_0,
34
    input [147:0]   data_1,
35
    input [147:0]   data_2,
36
    input [147:0]   data_3,
37
 
38
    output          matched,
39
    output [1:0]    matched_index,
40
    output [127:0]  matched_data_line,
41
 
42
    output [1:0]    plru_index,
43
    output [147:0]  plru_data_line,
44
 
45
    output [10:0]   control_after_match,
46
    output [10:0]   control_after_line_read,
47
    output [10:0]   control_after_write_to_existing,
48
    output [10:0]   control_after_write_to_new,
49
 
50
    output          writeback_needed
51
);
52
 
53
//------------------------------------------------------------------------------
54
 
55
wire [2:0] matched_full_index;
56
 
57
//------------------------------------------------------------------------------
58
 
59
assign matched_full_index =
60
    (control[0] && data_0[147:128] == address[31:12])?  3'd0 :
61
    (control[2] && data_1[147:128] == address[31:12])?  3'd1 :
62
    (control[4] && data_2[147:128] == address[31:12])?  3'd2 :
63
    (control[6] && data_3[147:128] == address[31:12])?  3'd3 :
64
                                                        3'd4;
65
assign matched_index = matched_full_index[1:0];
66
 
67
assign matched = matched_full_index != 3'd4;
68
 
69
assign matched_data_line =
70
    (matched_full_index == 3'd0)? data_0[127:0] :
71
    (matched_full_index == 3'd1)? data_1[127:0] :
72
    (matched_full_index == 3'd2)? data_2[127:0] :
73
                                  data_3[127:0];
74
 
75
assign control_after_match =
76
    (matched_full_index == 3'd0)?    { control[10], 2'b11,     control[7:0] } :
77
    (matched_full_index == 3'd1)?    { control[10], 2'b01,     control[7:0] } :
78
    (matched_full_index == 3'd2)?    { 1'b1, control[9], 1'b0, control[7:0] } :
79
                                     { 1'b0, control[9], 1'b0, control[7:0] };
80
 
81
assign control_after_line_read =
82
    (~(control[0]))?        { control[10], 2'b11,     control[7:0] | 8'b00000001 } :
83
    (~(control[2]))?        { control[10], 2'b01,     control[7:0] | 8'b00000100 } :
84
    (~(control[4]))?        { 1'b1, control[9], 1'b0, control[7:0] | 8'b00010000 } :
85
    (~(control[6]))?        { 1'b0, control[9], 1'b0, control[7:0] | 8'b01000000 } :
86
    (plru_index == 2'd0)?   { control[10], 2'b11,     control[7:0] } :
87
    (plru_index == 2'd1)?   { control[10], 2'b01,     control[7:0] } :
88
    (plru_index == 2'd2)?   { 1'b1, control[9], 1'b0, control[7:0] } :
89
                            { 1'b0, control[9], 1'b0, control[7:0] }; //match dcache_ram_3_q[]
90
 
91
assign control_after_write_to_existing =
92
    (matched_full_index == 3'd0)?    { control[10], 2'b11,     control[7:0] | 8'b00000010 } :
93
    (matched_full_index == 3'd1)?    { control[10], 2'b01,     control[7:0] | 8'b00001000 } :
94
    (matched_full_index == 3'd2)?    { 1'b1, control[9], 1'b0, control[7:0] | 8'b00100000 } :
95
                                     { 1'b0, control[9], 1'b0, control[7:0] | 8'b10000000}; //match dcache_ram_3_q[]
96
 
97
assign control_after_write_to_new =
98
    (~(control[0]))?        { control[10], 2'b11,     control[7:0] | 8'b00000011 } :
99
    (~(control[2]))?        { control[10], 2'b01,     control[7:0] | 8'b00001100 } :
100
    (~(control[4]))?        { 1'b1, control[9], 1'b0, control[7:0] | 8'b00110000 } :
101
    (~(control[6]))?        { 1'b0, control[9], 1'b0, control[7:0] | 8'b11000000 } :
102
    (plru_index == 2'd0)?   { control[10], 2'b11,     control[7:0] | 8'b00000010 } :
103
    (plru_index == 2'd1)?   { control[10], 2'b01,     control[7:0] | 8'b00001000 } :
104
    (plru_index == 2'd2)?   { 1'b1, control[9], 1'b0, control[7:0] | 8'b00100000 } :
105
                            { 1'b0, control[9], 1'b0, control[7:0] | 8'b10000000 }; //match dcache_ram_3_q[]
106
 
107
assign plru_index =
108
    (~(control[0]))?                    2'd0 :
109
    (~(control[2]))?                    2'd1 :
110
    (~(control[4]))?                    2'd2 :
111
    (~(control[6]))?                    2'd3 :
112
    (~(control[8]) && ~(control[9]))?   2'd0 :
113
    (~(control[8]) &&  (control[9]))?   2'd1 :
114
    ( (control[8]) && ~(control[10]))?  2'd2 :
115
                                        2'd3; // ( (control[8]) &&  (control[10]))?
116
 
117
assign plru_data_line =
118
    (plru_index == 2'd0)?   data_0 :
119
    (plru_index == 2'd1)?   data_1 :
120
    (plru_index == 2'd2)?   data_2 :
121
                            data_3;
122
 
123
assign writeback_needed =
124
    control[0] && control[2] && control[4] && control[6] &&
125
    ( (plru_index == 2'd0 && control[1]) || (plru_index == 2'd1 && control[3]) ||
126
      (plru_index == 2'd2 && control[5]) || (plru_index == 2'd3 && control[7]) );
127
 
128
//------------------------------------------------------------------------------
129
 
130
//------------------------------------------------------------------------------
131
 
132
// synthesis translate_off
133
wire _unused_ok = &{ 1'b0, address[11:0], 1'b0 };
134
// synthesis translate_on
135
 
136
//------------------------------------------------------------------------------
137
 
138
endmodule

powered by: WebSVN 2.1.0

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