Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Branch Instruction misaligned can't trigger exception #72

Description

@SeddonShen

When one branch inst tries to jump to a misaligned address,
such as:

  jal x1, 2 // misaligned
  beq x1,x2, 2 // misaligned but not trigger a exception

I find in the source code decode unit that only JAL and JARL is "PC_ALU" type insts:

    JAL   -> List(PC_ALU, A_PC,   B_IMM, IMM_J, ALU_ADD   , BR_XXX, Y, ST_XXX, LD_XXX, WB_PC4, Y, CSR.N, N),
    JALR  -> List(PC_ALU, A_RS1,  B_IMM, IMM_I, ALU_ADD   , BR_XXX, Y, ST_XXX, LD_XXX, WB_PC4, Y, CSR.N, N),

And in Datapath.scala, Line 167:

     pc_check := io.ctrl.pc_sel === PC_ALU

I think it should be change to

     pc_check := (io.ctrl.pc_sel === PC_ALU) || (brCond.io.taken)

And then the Branch Instruction misaligned can be triggered

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions