rsd-devel / rsd

RSD: RISC-V Out-of-Order Superscalar Processor
Apache License 2.0
934 stars 95 forks source link

wrong pointer used for poping btb queue #70

Open robert-g-liu opened 10 months ago

robert-g-liu commented 10 months ago

Literally in the btbQueuePointer the comment pointes out The "tailPtr" points the address of a next pushed entry.

BTB used headPtr for pushing entry. See code line below.

    else if (pushBtbQueue) begin
        btbQueue[headPtr].btbWA <= btbWA[INT_ISSUE_WIDTH-1];
        btbQueue[headPtr].btbWV <= btbWV[INT_ISSUE_WIDTH-1];
    end 

Similarly, to pop the queue, tailPtr was used so stale/invalid data was fetched:

    // Pop btb Queue
    if (!empty && !updateBtb) begin
        popBtbQueue = TRUE;
        btbWE[0] = TRUE;
        btbWA[0] = btbQueue[tailPtr].btbWA;
        btbWV[0] = btbQueue[tailPtr].btbWV;
    end 
robert-g-liu commented 10 months ago

Gshare branch predicator has the same issue. After local fix, improvement on both Num of branch prediction misses and IPC could be seen.

reo-pon commented 10 months ago

Thank you for reporting the issue. What you pointed out is indeed correct. I have confirmed that the number of branch mispredictions and IPC improved after the fix.

I will push the fix to the repository soon.