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

Add RVC HINT/RES/NSE encs & rework disassembly #56

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/QuickCheckVEngine/RVFI_DII/RVFI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ instance Show RVFI_Packet where
(rvfi_insn tok)
(privString (rvfi_mode tok))
(xlenString (rvfi_ixl tok))
(rv_pretty (MkInstruction (toInteger (rvfi_insn tok)))) -- Inst
(rv_pretty (MkInstruction (toInteger (rvfi_insn tok))) (rvfi_ixl tok)) -- Inst

-- | Return 'True' for halt 'RVFI_Packet's
rvfiIsHalt :: RVFI_Packet -> Bool
Expand Down
16 changes: 16 additions & 0 deletions src/RISCV/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module RISCV.Helpers (
, prettyCSS
, prettyCSS_F
, prettyCIW
, prettyCIW_reg
, prettyCL
, prettyCL_F
, prettyCS
Expand All @@ -94,6 +95,9 @@ module RISCV.Helpers (
, prettyCB_sig
, prettyCB_reg
, prettyCJ
, prettyIgnr1
, prettyIgnr2
, prettyIgnr3
-- * Others
, reg
, int
Expand Down Expand Up @@ -406,6 +410,9 @@ prettyCSS_F instr imm rs2 =
-- | CIW-type 'Wide-Immediate' compressed instruction pretty printer
prettyCIW instr imm rd' =
concat [instr, " ", reg' rd', ", ", int imm]
-- | CIW-type (register-only variant)
prettyCIW_reg instr rd' =
concat [instr, " ", reg' rd']

-- | CL-type 'Load' compressed instruction pretty printer
prettyCL instr imm rd' rs1' =
Expand Down Expand Up @@ -439,6 +446,15 @@ prettyCB_reg instr rs1' =
prettyCJ instr imm =
concat [instr, " ", int $ toSigned 12 imm]

-- | Operand-swallowing instruction pretty printers.
-- | Useful for special cases, such as reserved or overlapping encodings.
prettyIgnr1 :: String -> Integer -> String
prettyIgnr1 instr _ = instr
prettyIgnr2 :: String -> Integer -> Integer -> String
prettyIgnr2 instr _ _ = instr
prettyIgnr3 :: String -> Integer -> Integer -> Integer-> String
prettyIgnr3 instr _ _ _ = instr

type ExtractedRegs = ( Bool -- ^ is_bypass
, Maybe Integer -- ^ rs2
, Maybe Integer -- ^ rs1
Expand Down
8 changes: 4 additions & 4 deletions src/RISCV/InstInspect.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ import RISCV.Helpers
import Text.Printf

-- | RISC-V instruction pretty printer
rv_pretty :: Instruction -> String
rv_pretty instr = case decode 32 instr instList of
rv_pretty :: Instruction -> Maybe XLen-> String
rv_pretty instr ixl = case decode 32 instr instList of
Nothing -> "Unknown instruction"
Just i -> i
where instList = rv32_i_disass ++ rv64_i_disass
Expand All @@ -86,10 +86,10 @@ rv_pretty instr = case decode 32 instr instList of
++ rv32_zicsr_disass
++ rv32_zifencei_disass
++ rv32_xcheri_disass
++ rv_c_disass
++ rv_c_disass ixl

instance Show Instruction where
show i@(MkInstruction v) = printf ".4byte 0x%08x # %s" v (rv_pretty i)
show i@(MkInstruction v) = printf ".4byte 0x%08x # %s" v (rv_pretty i Nothing)

rv_extract :: Instruction -> ExtractedRegs
rv_extract instr = case decode 32 instr extractList of
Expand Down
Loading
Loading