Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pipeline follower for PC #6

Merged
merged 3 commits into from
Oct 14, 2024
Merged

Implement pipeline follower for PC #6

merged 3 commits into from
Oct 14, 2024

Conversation

fennecJ
Copy link
Owner

@fennecJ fennecJ commented Oct 14, 2024

This commit basically implement pipeline follower for PC.
This commit also refactors the original data field in "pipeline_info_t". The previous definition was:

typedef struct packed {
    logic [31:0] inst;
    logic bubble;
} pipeline_info_t;

The updated structure is:

typedef struct packed {
    inst_pc_t inst_pc;  // {inst, pc}
    logic bubble;
} pipeline_info_t;

Here, inst_pc_t is a new packed type defined as:

typedef struct packed {
    logic [31:0] inst;
    logic [31:0] pc;
} inst_pc_t;  // {inst, pc}

Following best coding practices, separating modified code from unchanged logic helps maximize code reusability. The PC's follower logic is identical to that for the instruction, while it differs from the bubble field. Therefore, we can reuse the original logic for handling the instruction and apply it to the PC. The only modification required is changing:

xx.inst <= pre_xx_stage.inst
to
xx.inst_pc <= pre_xx_stage.inst_pc

For the instruction follower assertion, we just need to update it from 'xx.inst' to 'xx.inst_pc.inst'.
This can be easily done using the find-and-replace function provided by editors.

close #4

@fennecJ fennecJ changed the title Implemented pipeline follower for PC Implement pipeline follower for PC Oct 14, 2024
This commit basically implement pipeline follower for PC.
This commit also refactors the original data field in "pipeline_info_t".
The previous definition was:

typedef struct packed {
    logic [31:0] inst;
    logic bubble;
} pipeline_info_t;

The updated structure is:

typedef struct packed {
    inst_pc_t inst_pc;  // {inst, pc}
    logic bubble;
} pipeline_info_t;

Here, 'inst_pc_t' is a new packed type defined as:

typedef struct packed {
    logic [31:0] inst;
    logic [31:0] pc;
} inst_pc_t;  // {inst, pc}

Following best coding practices, separating modified code from
unchanged logic helps maximize code reusability. The PC's follower
logic is identical to that for the instruction, while it differs from
the bubble field. Therefore, we can reuse the original logic for
handling the instruction and apply it to the PC. The only modification
required is changing:

xx.inst <= pre_xx_stage.inst
to
xx.inst_pc <= pre_xx_stage.inst_pc

For the instruction follower assertion, we just need to update it from
'xx.inst' to 'xx.inst_pc.inst'.
This can be easily done using the find-and-replace function provided by
editors.

close #4
We should follow right hand side of if_pc_o in module "riscv_if" instead
of follow if_pc_o directly. Because if_pc_o is assigned non-blocking,
which introduce 1 cycle delay, and cause followed PC misaligned with
followed instruction.
The localparam PC_INIT is defined as 'h200 instead of 32'h0 inside dut
@fennecJ fennecJ merged commit 83eaac0 into master Oct 14, 2024
2 checks passed
@fennecJ fennecJ deleted the PC_follower branch October 14, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement pipeline follower for PC
1 participant