2021-03-31 10:00:19 +00:00
|
|
|
/*
|
|
|
|
Copyright 2019 Blue Liang, liangkangnan@163.com
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
`include "defines.sv"
|
|
|
|
|
|
|
|
// 流水线控制模块
|
|
|
|
// 发出暂停、冲刷流水线信号
|
|
|
|
module pipe_ctrl(
|
|
|
|
|
2021-07-01 01:46:56 +00:00
|
|
|
input wire clk,
|
|
|
|
input wire rst_n,
|
2021-03-31 10:00:19 +00:00
|
|
|
|
2021-07-01 01:46:56 +00:00
|
|
|
input wire stall_from_id_i,
|
|
|
|
input wire stall_from_ex_i,
|
|
|
|
input wire stall_from_jtag_i,
|
|
|
|
input wire stall_from_clint_i,
|
|
|
|
input wire jump_assert_i,
|
|
|
|
input wire[31:0] jump_addr_i,
|
2021-03-31 10:00:19 +00:00
|
|
|
|
2021-07-01 01:46:56 +00:00
|
|
|
output wire flush_o, // 冲刷标志
|
|
|
|
output wire[`STALL_WIDTH-1:0] stall_o, // 暂停标志
|
|
|
|
output wire[31:0] flush_addr_o // 冲刷地址
|
2021-03-31 10:00:19 +00:00
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
assign flush_addr_o = jump_addr_i;
|
2021-07-01 01:46:56 +00:00
|
|
|
assign flush_o = jump_assert_i;
|
2021-03-31 10:00:19 +00:00
|
|
|
|
|
|
|
reg[`STALL_WIDTH-1:0] stall;
|
|
|
|
|
|
|
|
always @ (*) begin
|
2021-07-01 01:46:56 +00:00
|
|
|
stall[`STALL_EX] = 1'b0;
|
|
|
|
stall[`STALL_ID] = 1'b0;
|
|
|
|
stall[`STALL_IF] = 1'b0;
|
|
|
|
stall[`STALL_PC] = 1'b0;
|
|
|
|
|
|
|
|
if (stall_from_clint_i) begin
|
2021-03-31 10:00:19 +00:00
|
|
|
stall[`STALL_EX] = 1'b1;
|
|
|
|
stall[`STALL_ID] = 1'b1;
|
|
|
|
stall[`STALL_IF] = 1'b1;
|
|
|
|
stall[`STALL_PC] = 1'b1;
|
2021-07-01 01:46:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if (stall_from_ex_i) begin
|
|
|
|
stall[`STALL_EX] = 1'b1;
|
|
|
|
stall[`STALL_ID] = 1'b1;
|
|
|
|
stall[`STALL_IF] = 1'b1;
|
|
|
|
stall[`STALL_PC] = 1'b1;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (stall_from_id_i) begin
|
2021-03-31 10:00:19 +00:00
|
|
|
stall[`STALL_IF] = 1'b1;
|
|
|
|
stall[`STALL_PC] = 1'b1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
assign stall_o = stall;
|
|
|
|
|
|
|
|
endmodule
|