Skip to content

Commit

Permalink
Make sure opInterrupt doesn't return undefined when arg == 0b11
Browse files Browse the repository at this point in the history
  • Loading branch information
gergoerdi committed Aug 11, 2015
1 parent ed2034f commit acecf52
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/MOS6502/Decoder.hs
Expand Up @@ -64,16 +64,12 @@ instance BitRep ALUOp where
]

aluBinOp :: forall clk. Signal clk ALUOp -> Signal clk (Enabled BinOp)
aluBinOp s = muxN [ (sel .==. [b|00|], enabledS bin)
, (high, disabledS)
]
aluBinOp s = packEnabled (sel .==. [b|00|]) bin
where
(sel :: Signal clk X4, bin) = unappendS $ s

aluUnOp :: forall clk. Signal clk ALUOp -> Signal clk (Enabled UnOp)
aluUnOp s = muxN [ (sel .==. [b|01|], enabledS un)
, (high, disabledS)
]
aluUnOp s = packEnabled (sel .==. [b|01|]) un
where
(sel :: Signal clk X4, un) = unappendS $ s

Expand Down Expand Up @@ -143,9 +139,9 @@ opPop op = packEnabled (sel .==. 0x4 .&&. dir .==. pureS Pop) arg
(dir, arg) = unpack val

opInterrupt :: forall clk. Signal clk OpClass -> Signal clk (Enabled Interrupt)
opInterrupt op = packEnabled (sel .==. 0x7) arg
opInterrupt op = packEnabled (sel .==. 0x7) (bitwise arg)
where
(sel :: Signal clk U6, arg) = unappendS op
(sel :: Signal clk U6, arg :: Signal clk U2) = unappendS op

data Decoded clk = Decoded{ dAddrMode :: Signal clk AddrMode
, dAddrOffset :: Signal clk AddrOffset
Expand Down

0 comments on commit acecf52

Please sign in to comment.