分支预测以及错误回滚

构建 32 位全局历史记录移位寄存器,包括支持回滚状态以响应由分支错误预测引起的管道刷新。

进行分支预测 ( = 1) 时,从 LSB 端移入以更新预测分支的分支历史记录。(是最年轻的分支的方向。predict_validpredict_takenpredict_history[0]

当发生分支错误预测 ( = 1) 时,在完成错误预测的分支后,将分支历史记录寄存器与历史记录一起加载。这是错误预测的分支 () 与分支 () 的实际结果连接之前的历史记录。train_mispredictedtrain_historytrain_taken

如果预测和错误预测同时发生,则错误预测优先,因为管道刷新也会清除当前正在进行预测的分支。

predict_history是分支历史记录寄存器的值。

areset是将历史记录计数器重置为零的异步重置。

module top_module(
    input clk,
    input areset,

    input predict_valid,
    input predict_taken,
    output [31:0] predict_history,

    input train_mispredicted,
    input train_taken,
    input [31:0] train_history
);
    always @ (posedge clk or posedge areset) begin
        if (areset)
            predict_history = 32'd0;
        else if (train_mispredicted)
            predict_history = {train_history[30:0],train_taken};
        else if (predict_valid)
            predict_history = {predict_history[30:0],predict_taken};
        else
            predict_history = predict_history;
    end
endmodule

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值