OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [rtl/] [twoway/] [FT64_BranchPredicator.v] - Diff between revs 57 and 58

Show entire file | Details | Blame | View Log

Rev 57 Rev 58
Line 23... Line 23...
//                                                                          
//                                                                          
//
//
//=============================================================================
//=============================================================================
//
//
module FT64_BranchPredictor(rst, clk, en,
module FT64_BranchPredictor(rst, clk, en,
    xisBranch0, xisBranch1,
    xisBranch0, xisBranch1, xisBranch2,
    pcA, pcB, pcC, pcD, pcE, pcF, xpc0, xpc1, takb0, takb1,
    pcA, pcB, pcC, pcD, pcE, pcF, xpc0, xpc1, xpc2, takb0, takb1, takb2,
    predict_takenA, predict_takenB, predict_takenC, predict_takenD,
    predict_takenA, predict_takenB, predict_takenC, predict_takenD,
    predict_takenE, predict_takenF);
    predict_takenE, predict_takenF);
parameter DBW=32;
parameter DBW=32;
input rst;
input rst;
input clk;
input clk;
input en;
input en;
input xisBranch0;
input xisBranch0;
input xisBranch1;
input xisBranch1;
 
input xisBranch2;
input [DBW-1:0] pcA;
input [DBW-1:0] pcA;
input [DBW-1:0] pcB;
input [DBW-1:0] pcB;
input [DBW-1:0] pcC;
input [DBW-1:0] pcC;
input [DBW-1:0] pcD;
input [DBW-1:0] pcD;
input [DBW-1:0] pcE;
input [DBW-1:0] pcE;
input [DBW-1:0] pcF;
input [DBW-1:0] pcF;
input [DBW-1:0] xpc0;
input [DBW-1:0] xpc0;
input [DBW-1:0] xpc1;
input [DBW-1:0] xpc1;
 
input [DBW-1:0] xpc2;
input takb0;
input takb0;
input takb1;
input takb1;
 
input takb2;
output predict_takenA;
output predict_takenA;
output predict_takenB;
output predict_takenB;
output predict_takenC;
output predict_takenC;
output predict_takenD;
output predict_takenD;
output predict_takenE;
output predict_takenE;
Line 65... Line 68...
initial begin
initial begin
    gbl_branch_hist = 3'b000;
    gbl_branch_hist = 3'b000;
        for (n = 0; n < 512; n = n + 1)
        for (n = 0; n < 512; n = n + 1)
                branch_history_table[n] = 3;
                branch_history_table[n] = 3;
end
end
wire [8:0] bht_wa = {pc[8:2],gbl_branch_hist[2:1]};              // write address
wire [8:0] bht_wa = {pc[7:1],gbl_branch_hist[2:1]};              // write address
wire [8:0] bht_raA = {pcA[8:2],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raA = {pcA[7:1],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raB = {pcB[8:2],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raB = {pcB[7:1],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raC = {pcC[8:2],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raC = {pcC[7:1],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raD = {pcD[8:2],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raD = {pcD[7:1],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raE = {pcE[8:2],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raE = {pcE[7:1],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raF = {pcF[8:2],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [8:0] bht_raF = {pcF[7:1],gbl_branch_hist[2:1]};    // read address (IF stage)
wire [1:0] bht_xbits = branch_history_table[bht_wa];
wire [1:0] bht_xbits = branch_history_table[bht_wa];
wire [1:0] bht_ibitsA = branch_history_table[bht_raA];
wire [1:0] bht_ibitsA = branch_history_table[bht_raA];
wire [1:0] bht_ibitsB = branch_history_table[bht_raB];
wire [1:0] bht_ibitsB = branch_history_table[bht_raB];
wire [1:0] bht_ibitsC = branch_history_table[bht_raC];
wire [1:0] bht_ibitsC = branch_history_table[bht_raC];
wire [1:0] bht_ibitsD = branch_history_table[bht_raD];
wire [1:0] bht_ibitsD = branch_history_table[bht_raD];
Line 90... Line 93...
 
 
always @(posedge clk)
always @(posedge clk)
if (rst)
if (rst)
        pcstail <= 5'd0;
        pcstail <= 5'd0;
else begin
else begin
        if (xisBranch0 & xisBranch1) begin
        case({xisBranch0,xisBranch1,xisBranch2})
                pcs[pcstail] <= {xpc0[31:1],takb0};
        3'b000: ;
                pcs[pcstail+1] <= {xpc1[31:1],takb1};
        3'b001:
                pcstail <= pcstail + 5'd2;
                begin
 
                pcs[pcstail] <= {xpc2[31:1],takb2};
 
                pcstail <= pcstail + 5'd1;
        end
        end
        else if (xisBranch0) begin
        3'b010:
                pcs[pcstail] <= {xpc0[31:1],takb0};
                begin
 
                pcs[pcstail] <= {xpc1[31:1],takb1};
                pcstail <= pcstail + 5'd1;
                pcstail <= pcstail + 5'd1;
        end
        end
        else if (xisBranch1) begin
        3'b011:
 
                begin
                pcs[pcstail] <= {xpc1[31:1],takb1};
                pcs[pcstail] <= {xpc1[31:1],takb1};
 
                pcs[pcstail+1] <= {xpc2[31:1],takb2};
 
                pcstail <= pcstail + 5'd2;
 
                end
 
        3'b100:
 
                begin
 
                pcs[pcstail] <= {xpc0[31:1],takb0};
                pcstail <= pcstail + 5'd1;
                pcstail <= pcstail + 5'd1;
        end
        end
 
        3'b101:
 
                begin
 
                pcs[pcstail] <= {xpc0[31:1],takb0};
 
                pcs[pcstail+1] <= {xpc2[31:1],takb2};
 
                pcstail <= pcstail + 5'd2;
 
                end
 
        3'b110:
 
                begin
 
                pcs[pcstail] <= {xpc0[31:1],takb0};
 
                pcs[pcstail+1] <= {xpc1[31:1],takb1};
 
                pcstail <= pcstail + 5'd2;
 
                end
 
        3'b111:
 
                begin
 
                pcs[pcstail] <= {xpc0[31:1],takb0};
 
                pcs[pcstail+1] <= {xpc1[31:1],takb1};
 
                pcs[pcstail+2] <= {xpc2[31:1],takb2};
 
                pcstail <= pcstail + 5'd3;
 
                end
 
        endcase
end
end
 
 
always @(posedge clk)
always @(posedge clk)
if (rst)
if (rst)
        pcshead <= 5'd0;
        pcshead <= 5'd0;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.