forked from younghogong/4-way-set-associative-cache-verilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatePriority.v
52 lines (52 loc) · 1.09 KB
/
updatePriority.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module updatePriority(input [1:0] way,input [1:0] in0,input [1:0] in1,input [1:0] in2,input [1:0] in3,
output reg [1:0] out0,output reg [1:0] out1,output reg [1:0] out2,output reg [1:0] out3);
always @ (way,in0,in1,in2,in3)
begin
out0=in0;
out1=in1;
out2=in2;
out3=in3;
case(way)
2'b00:
begin
if(in1>in0)
out1=in1-2'b01;
if(in2>in0)
out2=in2-2'b01;
if(in3>in0)
out3=in3-2'b01;
out0=2'b11;
end
2'b01:
begin
if(in0>in1)
out0=in0-2'b01;
if(in2>in1)
out2=in2-2'b01;
if(in3>in1)
out3=in3-2'b01;
out1=2'b11;
end
2'b10:
begin
if(in0>in2)
out0=in0-2'b01;
if(in1>in2)
out1=in1-2'b01;
if(in3>in2)
out3=in3-2'b01;
out2=2'b11;
end
2'b11:
begin
if(in0>in3)
out0=in0-2'b01;
if(in1>in3)
out1=in1-2'b01;
if(in2>in3)
out2=in2-2'b01;
out3=2'b11;
end
endcase
end
endmodule