@@ -90,10 +90,9 @@ yosysIRModgraph ir =
9090
9191-- | Given a Yosys IR, construct a map from module names to SAWCore terms alongside SAWCore and Cryptol types
9292convertYosysIR ::
93- MonadIO m =>
9493 SC. SharedContext ->
9594 YosysIR ->
96- m (Map Text ConvertedModule )
95+ IO (Map Text ConvertedModule )
9796convertYosysIR sc ir = do
9897 let mg = yosysIRModgraph ir
9998 let sorted = reverseTopSort $ mg ^. modgraphGraph
@@ -102,7 +101,7 @@ convertYosysIR sc ir = do
102101 let (m, nm, _) = mg ^. modgraphNodeFromVertex $ v
103102 cm <- convertModule sc env m
104103 _ <- validateTerm sc (" translating the combinational circuit \" " <> nm <> " \" " ) $ cm ^. convertedModuleTerm
105- n <- liftIO $ Nonce. freshNonce Nonce. globalNonceGenerator
104+ n <- Nonce. freshNonce Nonce. globalNonceGenerator
106105 let frag = Text. pack . show $ Nonce. indexValue n
107106 let uri = URI. URI
108107 { URI. uriScheme = URI. mkScheme " yosys"
@@ -112,7 +111,7 @@ convertYosysIR sc ir = do
112111 , URI. uriFragment = URI. mkFragment frag
113112 }
114113 let ni = SC. ImportedName uri [nm]
115- tc <- liftIO $ SC. scDefineConstant sc ni (cm ^. convertedModuleTerm) (cm ^. convertedModuleType)
114+ tc <- SC. scDefineConstant sc ni (cm ^. convertedModuleTerm) (cm ^. convertedModuleType)
116115 let cm' = cm { _convertedModuleTerm = tc }
117116 pure $ Map. insert nm cm' env
118117 )
@@ -121,10 +120,9 @@ convertYosysIR sc ir = do
121120
122121-- | Given a Yosys IR, construct a map from module names to TypedTerms
123122yosysIRToTypedTerms ::
124- MonadIO m =>
125123 SC. SharedContext ->
126124 YosysIR ->
127- m (Map Text SC. TypedTerm )
125+ IO (Map Text SC. TypedTerm )
128126yosysIRToTypedTerms sc ir = do
129127 env <- convertYosysIR sc ir
130128 pure . flip fmap env $ \ cm ->
@@ -134,10 +132,9 @@ yosysIRToTypedTerms sc ir = do
134132
135133-- | Given a Yosys IR, construct a SAWCore record containing terms for each module
136134yosysIRToRecordTerm ::
137- MonadIO m =>
138135 SC. SharedContext ->
139136 YosysIR ->
140- m SC. TypedTerm
137+ IO SC. TypedTerm
141138yosysIRToRecordTerm sc ir = do
142139 env <- convertYosysIR sc ir
143140 record <- cryptolRecord sc $ view convertedModuleTerm <$> env
@@ -147,11 +144,10 @@ yosysIRToRecordTerm sc ir = do
147144
148145-- | Given a Yosys IR, construct a value representing a specific module with all submodules inlined
149146yosysIRToSequential ::
150- MonadIO m =>
151147 SC. SharedContext ->
152148 YosysIR ->
153149 Text ->
154- m YosysSequential
150+ IO YosysSequential
155151yosysIRToSequential sc ir nm = do
156152 case Map. lookup nm $ ir ^. yosysModules of
157153 Nothing -> throw . YosysError $ mconcat
@@ -173,9 +169,9 @@ yosysIRToSequential sc ir nm = do
173169yosys_import :: FilePath -> TopLevel SC. TypedTerm
174170yosys_import path = do
175171 sc <- getSharedContext
176- ir <- loadYosysIR path
177- tt <- yosysIRToRecordTerm sc ir
178- _ <- validateTerm sc " translating combinational circuits" $ SC. ttTerm tt
172+ ir <- liftIO $ loadYosysIR path
173+ tt <- liftIO $ yosysIRToRecordTerm sc ir
174+ _ <- liftIO $ validateTerm sc " translating combinational circuits" $ SC. ttTerm tt
179175 pure tt
180176
181177-- | Proves equality between a combinational HDL module and a
@@ -193,16 +189,16 @@ yosys_verify ::
193189 TopLevel YosysTheorem
194190yosys_verify ymod preconds other specs tactic = do
195191 sc <- getSharedContext
196- newmod <- foldM (flip $ applyOverride sc)
192+ newmod <- liftIO $ foldM (flip $ applyOverride sc)
197193 (SC. ttTerm ymod)
198194 specs
199195 mpc <- case preconds of
200196 [] -> pure Nothing
201197 (pc: pcs) -> do
202198 t <- foldM (\ a b -> liftIO $ SC. scAnd sc a b) (SC. ttTerm pc) (SC. ttTerm <$> pcs)
203199 pure . Just $ SC. TypedTerm (SC. ttType pc) t
204- thm <- buildTheorem sc ymod newmod mpc other
205- prop <- theoremProp sc thm
200+ thm <- liftIO $ buildTheorem sc ymod newmod mpc other
201+ prop <- liftIO $ theoremProp sc thm
206202 _ <- Builtins. provePrintPrim tactic prop
207203 pure thm
208204
@@ -214,8 +210,8 @@ yosys_import_sequential ::
214210 TopLevel YosysSequential
215211yosys_import_sequential nm path = do
216212 sc <- getSharedContext
217- ir <- loadYosysIR path
218- yosysIRToSequential sc ir nm
213+ ir <- liftIO $ loadYosysIR path
214+ liftIO $ yosysIRToSequential sc ir nm
219215
220216-- | Extracts a term from the given sequential module with the state
221217-- eliminated by iterating the term over the given concrete number of
@@ -229,8 +225,8 @@ yosys_extract_sequential ::
229225 TopLevel SC. TypedTerm
230226yosys_extract_sequential s n = do
231227 sc <- getSharedContext
232- tt <- composeYosysSequential sc s n
233- _ <- validateTerm sc " composing a sequential term" $ SC. ttTerm tt
228+ tt <- liftIO $ composeYosysSequential sc s n
229+ _ <- liftIO $ validateTerm sc " composing a sequential term" $ SC. ttTerm tt
234230 pure tt
235231
236232-- | Like `yosys_extract_sequential`, but the resulting term has an
@@ -241,8 +237,8 @@ yosys_extract_sequential_with_state ::
241237 TopLevel SC. TypedTerm
242238yosys_extract_sequential_with_state s n = do
243239 sc <- getSharedContext
244- tt <- composeYosysSequentialWithState sc s n
245- _ <- validateTerm sc " composing a sequential term with state" $ SC. ttTerm tt
240+ tt <- liftIO $ composeYosysSequentialWithState sc s n
241+ _ <- liftIO $ validateTerm sc " composing a sequential term with state" $ SC. ttTerm tt
246242 pure tt
247243
248244-- | Extracts a term from the given sequential module. This term has
@@ -261,4 +257,4 @@ yosys_verify_sequential_sally ::
261257yosys_verify_sequential_sally s path q fixed = do
262258 sc <- getSharedContext
263259 sym <- liftIO $ Common. newSAWCoreExprBuilder sc False
264- queryModelChecker sym sc s path q $ Set. fromList fixed
260+ liftIO $ queryModelChecker sym sc s path q $ Set. fromList fixed
0 commit comments