-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFSM_DIRECTORY_table.v
91 lines (89 loc) · 2.81 KB
/
FSM_DIRECTORY_table.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
module FSM_DIRECTORY_table(
input read_miss, write_miss,//within the directory
input external_write_back, external_write_miss, external_read_miss,
input [7:0] requesting_processor,
input [1:0] state_in,
input [7:0] bit_vector,// block's sharers
output reg send_fetch, send_invalidate, send_data_value_reply,
output reg [1:0] state_out,
output reg [7:0] bit_vector_out
);
parameter UNCACHED = 2'b0, EXCLUSIVE = 2'b01, SHARED = 2'b10;
// it was meant to be for at most 8 processors, which is the reason which the sharers(bitvector) is eight bits, as well as the processors indexing
initial begin
send_fetch <= 1'b0;
send_invalidate <= 1'b0;
send_data_value_reply <= 1'b0;
state_out <= UNCACHED;
bit_vector_out <= 7'b0;
end
always@(*) begin
$display("t: state_in %b rm %b wm %b ewb %b ewm %b wrm %b req %b bitv %b -->> state_out %b sf %b si %b sdvr %b bitvo %b",
state_in, read_miss, write_miss, external_write_back, external_write_miss, external_read_miss, requesting_processor, bit_vector,
state_out, send_fetch, send_invalidate, send_data_value_reply, bit_vector_out
);
case(state_in)
UNCACHED:begin
case({external_write_miss,external_read_miss})
2'b01:begin
send_fetch <= 1'b0;
send_invalidate <= 1'b0;
send_data_value_reply <= 1'b1;
state_out <= SHARED;
bit_vector_out <= bit_vector;
end
2'b10:begin
send_fetch <= 1'b0;
send_invalidate <= 1'b0;
send_data_value_reply <= 1'b1;
state_out <= EXCLUSIVE;
bit_vector_out <= bit_vector;
end
endcase
end
EXCLUSIVE:begin
case({read_miss,external_write_back,external_write_miss})
3'b001:begin
send_fetch <= 1'b1;
send_invalidate <= 1'b1;
send_data_value_reply <= 1'b1;
state_out <= EXCLUSIVE;
bit_vector_out <= requesting_processor;
end
3'b010:begin
send_fetch <= 1'b0;
send_invalidate <= 1'b0;
send_data_value_reply <= 1'b0;
state_out <= UNCACHED;
bit_vector_out <= 7'b0;
end
3'b100:begin
send_fetch <= 1'b1;
send_invalidate <= 1'b0;
send_data_value_reply <= 1'b1;
state_out <= SHARED;
bit_vector_out <= bit_vector | requesting_processor;// sharers U= p
end
endcase
end
SHARED:begin
case({write_miss,external_read_miss})
2'b01:begin
send_fetch <= 1'b0;
send_invalidate <= 1'b0;
send_data_value_reply <= 1'b1;
state_out <= SHARED;
bit_vector_out <= bit_vector | requesting_processor;
end
2'b10:begin
send_fetch <= 1'b0;
send_invalidate <= 1'b1;
send_data_value_reply <= 1'b1;
state_out <= EXCLUSIVE;
bit_vector_out <= bit_vector;
end
endcase
end
endcase
end
endmodule