forked from Yehowshua/RiscV-Formal
clean up warnings a bit
This commit is contained in:
parent
30650b870c
commit
67b44dedc0
|
@ -18,10 +18,8 @@ import BusTypes(
|
||||||
ReadRequest(..),
|
ReadRequest(..),
|
||||||
BusVal(..),
|
BusVal(..),
|
||||||
)
|
)
|
||||||
import Types(Addr,
|
import Types(Addr)
|
||||||
Byte, HalfWord, FullWord, DoubleWord, QuadWord)
|
import Peripherals.Ram(write, bytesInRam)
|
||||||
import Peripherals.Ram(read, write, bytesInRam)
|
|
||||||
import Distribution.Types.UnitId (DefUnitId(unDefUnitId))
|
|
||||||
|
|
||||||
data Peripherals = Peripherals
|
data Peripherals = Peripherals
|
||||||
{
|
{
|
||||||
|
@ -40,7 +38,7 @@ busValToTransactionSize (BusDoubleWord _) = SizeDoubleWord
|
||||||
busValToTransactionSize (BusQuadWord _) = SizeQuadWord
|
busValToTransactionSize (BusQuadWord _) = SizeQuadWord
|
||||||
|
|
||||||
alignCheck :: Addr -> TransactionSize -> Bool
|
alignCheck :: Addr -> TransactionSize -> Bool
|
||||||
alignCheck addr SizeByte = True
|
alignCheck _ SizeByte = True
|
||||||
alignCheck addr SizeHalfWord = addr `mod` 2 == 0
|
alignCheck addr SizeHalfWord = addr `mod` 2 == 0
|
||||||
alignCheck addr SizeFullWord = addr `mod` 4 == 0
|
alignCheck addr SizeFullWord = addr `mod` 4 == 0
|
||||||
alignCheck addr SizeDoubleWord = addr `mod` 8 == 0
|
alignCheck addr SizeDoubleWord = addr `mod` 8 == 0
|
||||||
|
|
|
@ -7,9 +7,8 @@ module Cpu(
|
||||||
riscvCPUInit) where
|
riscvCPUInit) where
|
||||||
|
|
||||||
import Clash.Prelude
|
import Clash.Prelude
|
||||||
import Types(Pc, Mem)
|
import Types(Pc)
|
||||||
import RegFiles(GPR, FPR, CSR, gprInit, fprInit, csrInit)
|
import RegFiles(GPR, FPR, CSR, gprInit, fprInit, csrInit)
|
||||||
import Peripherals.Ram(Ram)
|
|
||||||
|
|
||||||
data Endian = Big | Little
|
data Endian = Big | Little
|
||||||
deriving (Generic, Show, Eq, NFDataX)
|
deriving (Generic, Show, Eq, NFDataX)
|
||||||
|
|
|
@ -30,7 +30,6 @@ data Exception =
|
||||||
| EnvironmentCallFromMMode
|
| EnvironmentCallFromMMode
|
||||||
| InstructionPageFault
|
| InstructionPageFault
|
||||||
| LoadPageFault
|
| LoadPageFault
|
||||||
| Reserved
|
|
||||||
| StoreAMOPageFault
|
| StoreAMOPageFault
|
||||||
| DoubleTrap
|
| DoubleTrap
|
||||||
| SoftwareCheck
|
| SoftwareCheck
|
||||||
|
@ -84,7 +83,6 @@ isSynchronousException EnvironmentCallFromSMode = True
|
||||||
isSynchronousException EnvironmentCallFromMMode = True
|
isSynchronousException EnvironmentCallFromMMode = True
|
||||||
isSynchronousException InstructionPageFault = True
|
isSynchronousException InstructionPageFault = True
|
||||||
isSynchronousException LoadPageFault = True
|
isSynchronousException LoadPageFault = True
|
||||||
isSynchronousException Reserved = True
|
|
||||||
isSynchronousException StoreAMOPageFault = True
|
isSynchronousException StoreAMOPageFault = True
|
||||||
isSynchronousException DoubleTrap = True
|
isSynchronousException DoubleTrap = True
|
||||||
isSynchronousException SoftwareCheck = True
|
isSynchronousException SoftwareCheck = True
|
||||||
|
|
|
@ -7,18 +7,15 @@ module Fetch(
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Clash.Prelude
|
import Clash.Prelude
|
||||||
import Types(Mem, Addr, Insn)
|
import Types(Addr, Insn)
|
||||||
import Bus(ReadResponse, WriteResponse, read)
|
import Bus(read)
|
||||||
import Bus(Peripherals(..))
|
import Bus(Peripherals(..))
|
||||||
import BusTypes(
|
import BusTypes(
|
||||||
ReadRequest(..),
|
ReadRequest(..),
|
||||||
TransactionSize(..),
|
TransactionSize(..),
|
||||||
BusVal(..),
|
BusVal(..),
|
||||||
BusError(..))
|
BusError(..))
|
||||||
import Exceptions(Exception(..), exceptionCode, isSynchronousException)
|
import Exceptions(Exception(..))
|
||||||
|
|
||||||
import GHC.IO (IO)
|
|
||||||
import GHC.Base (Applicative(pure))
|
|
||||||
|
|
||||||
data FetchResult = Instruction Insn
|
data FetchResult = Instruction Insn
|
||||||
| InstructionException Exception
|
| InstructionException Exception
|
||||||
|
|
|
@ -13,14 +13,13 @@ module Peripherals.Ram(
|
||||||
write,
|
write,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Clash.Prelude hiding (read)
|
import Clash.Prelude hiding (empty, read)
|
||||||
import qualified Prelude as P
|
import qualified Prelude as P
|
||||||
import qualified Data.ByteString.Lazy as BL
|
import qualified Data.ByteString.Lazy as BL
|
||||||
import Data.Binary.Get
|
import Data.Binary.Get
|
||||||
import Data.Int (Int32)
|
import Data.Int (Int32)
|
||||||
import qualified Clash.Sized.Vector as Vec
|
import qualified Clash.Sized.Vector as Vec
|
||||||
import Types(Addr,
|
import Types(Addr, FullWord, DoubleWord)
|
||||||
Byte, HalfWord, FullWord, DoubleWord, QuadWord)
|
|
||||||
import BusTypes(
|
import BusTypes(
|
||||||
TransactionSize(..),
|
TransactionSize(..),
|
||||||
BusVal(..),
|
BusVal(..),
|
||||||
|
|
|
@ -5,20 +5,15 @@ import Types (Byte)
|
||||||
import Data.Char (ord, chr)
|
import Data.Char (ord, chr)
|
||||||
|
|
||||||
import Peripherals.UartCFFI (
|
import Peripherals.UartCFFI (
|
||||||
initTerminal,
|
|
||||||
restoreTerminal,
|
|
||||||
getCharFromTerminal,
|
getCharFromTerminal,
|
||||||
writeCharToTerminal,
|
writeCharToTerminal,
|
||||||
isCharAvailable,
|
isCharAvailable,
|
||||||
setupSigintHandler,
|
|
||||||
wasCtrlCReceived
|
|
||||||
)
|
)
|
||||||
|
|
||||||
import BusTypes (
|
import BusTypes (
|
||||||
TransactionSize(..),
|
TransactionSize(..),
|
||||||
BusVal(..),
|
BusVal(..),
|
||||||
)
|
)
|
||||||
import GHC.Generics (URec(UAddr), Generic (from))
|
|
||||||
|
|
||||||
-- based on a 16550 UART which has an address space of 8 bytes
|
-- based on a 16550 UART which has an address space of 8 bytes
|
||||||
type UartAddr = Unsigned 3
|
type UartAddr = Unsigned 3
|
||||||
|
|
|
@ -7,13 +7,11 @@ module Peripherals.UartCFFI (
|
||||||
writeCharToTerminal,
|
writeCharToTerminal,
|
||||||
isCharAvailable,
|
isCharAvailable,
|
||||||
setupSigintHandler,
|
setupSigintHandler,
|
||||||
wasCtrlCReceived
|
ctrlCReceived
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
import Foreign.C.Types
|
import Foreign.C.Types
|
||||||
import Foreign.C.String
|
|
||||||
import Foreign.Ptr
|
|
||||||
import Data.Char (chr, ord)
|
import Data.Char (chr, ord)
|
||||||
|
|
||||||
-- Foreign imports directly corresponding to the C functions
|
-- Foreign imports directly corresponding to the C functions
|
||||||
|
|
|
@ -22,10 +22,6 @@ import Cpu(
|
||||||
import Fetch(fetchInstruction, FetchResult (..))
|
import Fetch(fetchInstruction, FetchResult (..))
|
||||||
import Isa.Decode(decode)
|
import Isa.Decode(decode)
|
||||||
|
|
||||||
import Debug.Trace
|
|
||||||
import Types (Insn)
|
|
||||||
import Control.Monad.RWS (MonadState(put))
|
|
||||||
|
|
||||||
data Args = Args {
|
data Args = Args {
|
||||||
firmware :: FilePath
|
firmware :: FilePath
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
@ -71,12 +67,12 @@ simulation args = do
|
||||||
initializedPeripherals <- setupPeripherals (firmware args)
|
initializedPeripherals <- setupPeripherals (firmware args)
|
||||||
case initializedPeripherals of
|
case initializedPeripherals of
|
||||||
InitializationError e -> return $ Failure e
|
InitializationError e -> return $ Failure e
|
||||||
InitializedPeripherals ram -> do
|
InitializedPeripherals ramDevice -> do
|
||||||
|
|
||||||
let initState =
|
let initState =
|
||||||
Machine {
|
Machine {
|
||||||
cpu = riscvCPUInit,
|
cpu = riscvCPUInit,
|
||||||
peripherals = Bus.Peripherals ram
|
peripherals = Bus.Peripherals ramDevice
|
||||||
}
|
}
|
||||||
sim <- simulationLoop 15 initState
|
sim <- simulationLoop 15 initState
|
||||||
teardownPeripherals
|
teardownPeripherals
|
||||||
|
|
Loading…
Reference in a new issue