@@ -9,7 +9,6 @@ import Data.Bits (complement)
9
9
import Data.List (intercalate , zip5 )
10
10
import Control.Exception (SomeException , try )
11
11
import Control.Monad (void )
12
- import Control.Monad.IO.Class (liftIO )
13
12
import Foreign.C.String (newCString )
14
13
import Foreign.Marshal.Alloc (free )
15
14
@@ -20,7 +19,6 @@ import Clash.Prelude
20
19
, low , high , pack , unpack , resize
21
20
)
22
21
23
- import Clash.FFI.Monad
24
22
import Clash.FFI.VPI.Info
25
23
import Clash.FFI.VPI.IO
26
24
import Clash.FFI.VPI.Callback
@@ -49,7 +47,7 @@ foreign export ccall "clash_ffi_main"
49
47
ffiMain :: IO ()
50
48
51
49
ffiMain :: IO ()
52
- ffiMain = runSimAction $ do
50
+ ffiMain = do
53
51
--------------------------
54
52
-- print simulator info --
55
53
--------------------------
@@ -122,7 +120,7 @@ ffiMain = runSimAction $ do
122
120
4 -> " <=>" -- mixed input-output
123
121
_ -> " x" -- no direction
124
122
125
- assignInputs :: (? state :: State ) => SimAction ()
123
+ assignInputs :: (? state :: State ) => IO ()
126
124
assignInputs = do
127
125
SimTime time <- receiveTime Sim $ Just top
128
126
@@ -163,7 +161,7 @@ assignInputs = do
163
161
sendValue port (BitVectorVal SNat $ pack v) $ InertialDelay $ SimTime 0
164
162
return $ Just v
165
163
166
- readOutputs :: (? state :: State ) => SimAction ()
164
+ readOutputs :: (? state :: State ) => IO ()
167
165
readOutputs = do
168
166
SimTime time <- receiveTime Sim $ Just top
169
167
receiveValue VectorFmt dataOut >>= \ case
@@ -174,14 +172,14 @@ readOutputs = do
174
172
}
175
173
_ -> return ()
176
174
177
- if ( steps > 0 ) then do
175
+ if steps > 0 then do
178
176
let ? state = ? state { steps = steps - 1 }
179
177
nextCB ReadWriteSynch 1 assignInputs
180
178
else do
181
179
putStrLn " "
182
180
putStrLn " [ Simulation done ]"
183
181
184
- liftIO $ void $ try @ SomeException $ runSimAction
182
+ void $ try @ SomeException
185
183
$ controlSimulator $ Finish NoDiagnostics
186
184
187
185
where
@@ -226,31 +224,31 @@ updates = Updates 0 Nothing Nothing Nothing Nothing Nothing
226
224
nextCB ::
227
225
(Maybe Object -> Time -> CallbackReason ) ->
228
226
Int64 ->
229
- SimAction () ->
230
- SimAction ()
227
+ IO () ->
228
+ IO ()
231
229
nextCB reason time action =
232
230
void $ registerCallback
233
231
CallbackInfo
234
232
{ cbReason = reason Nothing (SimTime time)
235
- , cbRoutine = const (runSimAction action >> return 0 )
233
+ , cbRoutine = const (action >> return 0 )
236
234
, cbIndex = 0
237
235
, cbData = B. empty
238
236
}
239
237
240
238
getByName ::
241
239
(Coercible a Object , Show a , Typeable a , Coercible Object b ) =>
242
- Maybe a -> B. ByteString -> SimCont o b
240
+ Maybe a -> B. ByteString -> IO b
243
241
getByName m name = do
244
- ref <- liftIO $ newCString $ B. unpack name
242
+ ref <- newCString $ B. unpack name
245
243
obj <- getChild ref m
246
- liftIO $ free ref
244
+ free ref
247
245
return obj
248
246
249
- putStr :: String -> SimAction ()
247
+ putStr :: String -> IO ()
250
248
putStr = simPutStr . B. pack
251
249
252
- putStrLn :: String -> SimAction ()
250
+ putStrLn :: String -> IO ()
253
251
putStrLn = simPutStrLn . B. pack
254
252
255
- print :: Show a => a -> SimAction ()
253
+ print :: Show a => a -> IO ()
256
254
print = simPutStrLn . B. pack . show
0 commit comments