1 |
2 |
alfik |
//======================================================== conditions
|
2 |
|
|
wire cond_0 = state == STATE_TLB_REQUEST;
|
3 |
|
|
wire cond_1 = ~(pr_reset) && prefetch_length > 5'd0 && prefetchfifo_used < 5'd3;
|
4 |
|
|
wire cond_2 = tlbcode_do;
|
5 |
|
|
wire cond_3 = state == STATE_ICACHE;
|
6 |
|
|
wire cond_4 = page_cross || pr_reset || prefetchfifo_used >= 5'd8;
|
7 |
|
|
wire cond_5 = offset_update;
|
8 |
|
|
//======================================================== saves
|
9 |
|
|
wire [31:0] physical_to_reg =
|
10 |
|
|
(cond_0 && cond_1 && cond_2)? ( tlbcode_physical) :
|
11 |
|
|
(cond_3 && cond_5)? ( { physical[31:12], prefetch_address[11:0] }) :
|
12 |
|
|
physical;
|
13 |
|
|
wire [31:0] linear_to_reg =
|
14 |
|
|
(cond_0 && cond_1 && cond_2)? ( tlbcode_linear) :
|
15 |
|
|
(cond_3 && cond_5)? ( { linear[31:12], prefetch_address[11:0] }) :
|
16 |
|
|
linear;
|
17 |
|
|
wire [1:0] state_to_reg =
|
18 |
|
|
(cond_0 && cond_1 && cond_2)? ( STATE_ICACHE) :
|
19 |
|
|
(cond_3 && cond_4)? ( STATE_TLB_REQUEST) :
|
20 |
|
|
state;
|
21 |
|
|
wire cache_disable_to_reg =
|
22 |
|
|
(cond_0 && cond_1 && cond_2)? ( tlbcode_cache_disable) :
|
23 |
|
|
cache_disable;
|
24 |
|
|
//======================================================== always
|
25 |
|
|
always @(posedge clk or negedge rst_n) begin
|
26 |
|
|
if(rst_n == 1'b0) physical <= 32'd0;
|
27 |
|
|
else physical <= physical_to_reg;
|
28 |
|
|
end
|
29 |
|
|
always @(posedge clk or negedge rst_n) begin
|
30 |
|
|
if(rst_n == 1'b0) linear <= 32'd0;
|
31 |
|
|
else linear <= linear_to_reg;
|
32 |
|
|
end
|
33 |
|
|
always @(posedge clk or negedge rst_n) begin
|
34 |
|
|
if(rst_n == 1'b0) state <= 2'd0;
|
35 |
|
|
else state <= state_to_reg;
|
36 |
|
|
end
|
37 |
|
|
always @(posedge clk or negedge rst_n) begin
|
38 |
|
|
if(rst_n == 1'b0) cache_disable <= 1'd0;
|
39 |
|
|
else cache_disable <= cache_disable_to_reg;
|
40 |
|
|
end
|
41 |
|
|
//======================================================== sets
|
42 |
|
|
assign icacheread_length =
|
43 |
|
|
(cond_0 && cond_1 && cond_2)? ( length) :
|
44 |
|
|
(cond_3)? ( length) :
|
45 |
|
|
5'd0;
|
46 |
|
|
assign tlbcoderequest_do =
|
47 |
|
|
(cond_0 && cond_1)? (`TRUE) :
|
48 |
|
|
1'd0;
|
49 |
|
|
assign icacheread_do =
|
50 |
|
|
(cond_0 && cond_1 && cond_2)? (`TRUE) :
|
51 |
|
|
(cond_3 && ~cond_4)? (`TRUE) :
|
52 |
|
|
1'd0;
|
53 |
|
|
assign icacheread_cache_disable =
|
54 |
|
|
(cond_0 && cond_1 && cond_2)? ( tlbcode_cache_disable) :
|
55 |
|
|
(cond_3)? ( cache_disable) :
|
56 |
|
|
1'd0;
|
57 |
|
|
assign icacheread_address =
|
58 |
|
|
(cond_0 && cond_1 && cond_2)? ( tlbcode_physical) :
|
59 |
|
|
(cond_3)? ( (offset_update)? { physical[31:12], prefetch_address[11:0] } : physical) :
|
60 |
|
|
32'd0;
|