1 |
2 |
alfik |
//======================================================== conditions
|
2 |
|
|
wire cond_0 = state == STATE_IDLE;
|
3 |
|
|
wire cond_1 = io_write_do && io_write_done == `FALSE && dcache_busy == `FALSE;
|
4 |
|
|
wire cond_2 = io_read_do && io_read_done == `FALSE && dcache_busy == `FALSE;
|
5 |
|
|
wire cond_3 = state == STATE_WRITE_1;
|
6 |
|
|
wire cond_4 = avalon_io_waitrequest == `FALSE || address_out_of_bounds;
|
7 |
|
|
wire cond_5 = write_two_stage;
|
8 |
|
|
wire cond_6 = state == STATE_WRITE_2;
|
9 |
|
|
wire cond_7 = state == STATE_READ_1;
|
10 |
|
|
wire cond_8 = avalon_io_readdatavalid || address_out_of_bounds;
|
11 |
|
|
wire cond_9 = read_two_stage;
|
12 |
|
|
wire cond_10 = avalon_io_waitrequest == `FALSE;
|
13 |
|
|
wire cond_11 = state == STATE_READ_2;
|
14 |
|
|
//======================================================== saves
|
15 |
|
|
wire was_readdatavalid_to_reg =
|
16 |
|
|
(cond_0 && ~cond_1 && cond_2)? ( `FALSE) :
|
17 |
|
|
was_readdatavalid;
|
18 |
|
|
wire [31:0] io_read_data_to_reg =
|
19 |
|
|
(cond_7 && cond_8)? ( read_data_1) :
|
20 |
|
|
(cond_11 && cond_8)? ( read_data_2) :
|
21 |
|
|
io_read_data;
|
22 |
|
|
wire io_read_done_to_reg =
|
23 |
|
|
(cond_0)? ( `FALSE) :
|
24 |
|
|
(cond_7 && cond_8 && ~cond_9)? ( `TRUE) :
|
25 |
|
|
(cond_11 && cond_8)? ( `TRUE) :
|
26 |
|
|
io_read_done;
|
27 |
|
|
wire [2:0] state_to_reg =
|
28 |
|
|
(cond_0 && cond_1)? ( STATE_WRITE_1) :
|
29 |
|
|
(cond_0 && ~cond_1 && cond_2)? ( STATE_READ_1) :
|
30 |
|
|
(cond_3 && cond_4 && cond_5)? ( STATE_WRITE_2) :
|
31 |
|
|
(cond_3 && cond_4 && ~cond_5)? ( STATE_IDLE) :
|
32 |
|
|
(cond_6 && cond_4)? ( STATE_IDLE) :
|
33 |
|
|
(cond_7 && cond_8 && cond_9)? ( STATE_READ_2) :
|
34 |
|
|
(cond_7 && cond_8 && ~cond_9)? ( STATE_IDLE) :
|
35 |
|
|
(cond_11 && cond_8)? ( STATE_IDLE) :
|
36 |
|
|
state;
|
37 |
|
|
wire [31:0] avalon_io_writedata_to_reg =
|
38 |
|
|
(cond_0 && cond_1)? ( write_1_data) :
|
39 |
|
|
(cond_3 && cond_4 && cond_5)? ( write_2_data) :
|
40 |
|
|
avalon_io_writedata;
|
41 |
|
|
wire [15:0] avalon_io_address_to_reg =
|
42 |
|
|
(cond_0 && cond_1)? ( { io_write_address[15:2], 2'b0 }) :
|
43 |
|
|
(cond_0 && ~cond_1 && cond_2)? ( { io_read_address[15:2], 2'b0 }) :
|
44 |
|
|
(cond_3 && cond_4 && cond_5)? ( { write_address_next[15:2], 2'b0 }) :
|
45 |
|
|
(cond_7 && cond_8 && cond_9)? ( { read_address_next[15:2], 2'b0 }) :
|
46 |
|
|
avalon_io_address;
|
47 |
|
|
wire avalon_io_write_reg_to_reg =
|
48 |
|
|
(cond_0 && cond_1)? ( `TRUE) :
|
49 |
|
|
(cond_3 && cond_4 && cond_5)? ( `TRUE) :
|
50 |
|
|
(cond_3 && cond_4 && ~cond_5)? ( `FALSE) :
|
51 |
|
|
(cond_6 && cond_4)? ( `FALSE) :
|
52 |
|
|
avalon_io_write_reg;
|
53 |
|
|
wire [3:0] avalon_io_byteenable_to_reg =
|
54 |
|
|
(cond_0 && cond_1)? ( write_1_byteenable) :
|
55 |
|
|
(cond_0 && ~cond_1 && cond_2)? ( read_1_byteenable) :
|
56 |
|
|
(cond_3 && cond_4 && cond_5)? ( write_2_byteenable) :
|
57 |
|
|
(cond_7 && cond_8 && cond_9)? ( read_2_byteenable) :
|
58 |
|
|
avalon_io_byteenable;
|
59 |
|
|
wire avalon_io_read_reg_to_reg =
|
60 |
|
|
(cond_0 && ~cond_1 && cond_2)? ( `TRUE) :
|
61 |
|
|
(cond_7 && cond_8 && cond_9)? ( `TRUE) :
|
62 |
|
|
(cond_7 && cond_8 && ~cond_9)? ( `FALSE) :
|
63 |
|
|
(cond_7 && cond_10)? ( `FALSE) :
|
64 |
|
|
(cond_11 && cond_8)? ( `FALSE) :
|
65 |
|
|
(cond_11 && cond_10)? ( `FALSE) :
|
66 |
|
|
avalon_io_read_reg;
|
67 |
|
|
wire io_write_done_to_reg =
|
68 |
|
|
(cond_0)? ( `FALSE) :
|
69 |
|
|
(cond_3 && cond_4 && ~cond_5)? ( `TRUE) :
|
70 |
|
|
(cond_6 && cond_4)? ( `TRUE) :
|
71 |
|
|
io_write_done;
|
72 |
|
|
//======================================================== always
|
73 |
|
|
always @(posedge clk or negedge rst_n) begin
|
74 |
|
|
if(rst_n == 1'b0) was_readdatavalid <= 1'd0;
|
75 |
|
|
else was_readdatavalid <= was_readdatavalid_to_reg;
|
76 |
|
|
end
|
77 |
|
|
always @(posedge clk or negedge rst_n) begin
|
78 |
|
|
if(rst_n == 1'b0) io_read_data <= 32'd0;
|
79 |
|
|
else io_read_data <= io_read_data_to_reg;
|
80 |
|
|
end
|
81 |
|
|
always @(posedge clk or negedge rst_n) begin
|
82 |
|
|
if(rst_n == 1'b0) io_read_done <= 1'd0;
|
83 |
|
|
else io_read_done <= io_read_done_to_reg;
|
84 |
|
|
end
|
85 |
|
|
always @(posedge clk or negedge rst_n) begin
|
86 |
|
|
if(rst_n == 1'b0) state <= 3'd0;
|
87 |
|
|
else state <= state_to_reg;
|
88 |
|
|
end
|
89 |
|
|
always @(posedge clk or negedge rst_n) begin
|
90 |
|
|
if(rst_n == 1'b0) avalon_io_writedata <= 32'd0;
|
91 |
|
|
else avalon_io_writedata <= avalon_io_writedata_to_reg;
|
92 |
|
|
end
|
93 |
|
|
always @(posedge clk or negedge rst_n) begin
|
94 |
|
|
if(rst_n == 1'b0) avalon_io_address <= 16'd0;
|
95 |
|
|
else avalon_io_address <= avalon_io_address_to_reg;
|
96 |
|
|
end
|
97 |
|
|
always @(posedge clk or negedge rst_n) begin
|
98 |
|
|
if(rst_n == 1'b0) avalon_io_write_reg <= 1'd0;
|
99 |
|
|
else avalon_io_write_reg <= avalon_io_write_reg_to_reg;
|
100 |
|
|
end
|
101 |
|
|
always @(posedge clk or negedge rst_n) begin
|
102 |
|
|
if(rst_n == 1'b0) avalon_io_byteenable <= 4'd0;
|
103 |
|
|
else avalon_io_byteenable <= avalon_io_byteenable_to_reg;
|
104 |
|
|
end
|
105 |
|
|
always @(posedge clk or negedge rst_n) begin
|
106 |
|
|
if(rst_n == 1'b0) avalon_io_read_reg <= 1'd0;
|
107 |
|
|
else avalon_io_read_reg <= avalon_io_read_reg_to_reg;
|
108 |
|
|
end
|
109 |
|
|
always @(posedge clk or negedge rst_n) begin
|
110 |
|
|
if(rst_n == 1'b0) io_write_done <= 1'd0;
|
111 |
|
|
else io_write_done <= io_write_done_to_reg;
|
112 |
|
|
end
|
113 |
|
|
//======================================================== sets
|