From 07b64bd1f2e92239892b096df8bc30fda52666c5 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Wed, 17 Apr 2019 01:44:03 -0400 Subject: [PATCH] clearer messaging surrounding unsupported interface conversion features --- src/Convert/Interface.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Convert/Interface.hs b/src/Convert/Interface.hs index 9adbd80..389e1c7 100644 --- a/src/Convert/Interface.hs +++ b/src/Convert/Interface.hs @@ -70,7 +70,6 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it else return () collectInterface _ = return () - -- TODO: We don't yet handle interfaces with parameter bindings. mapInterface :: ModuleItem -> ModuleItem mapInterface (orig @ (MIDecl (Variable Local t ident _ _))) = case Map.lookup ident modports of @@ -86,8 +85,13 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it mapInterface (Instance part params ident Nothing instancePorts) = case Map.lookup part interfaces of Just interface -> - Generate $ map GenModuleItem $ - inlineInterface interface (ident, expandedPorts) + -- TODO: Add support for interfaces with parameter bindings. + if not $ null params + then error $ "interface instantiations with parameter " + ++ "bindings are not yet supported: " + ++ show (part, params, ident) + else Generate $ map GenModuleItem $ + inlineInterface interface (ident, expandedPorts) Nothing -> Instance part params ident Nothing expandedPorts where expandedPorts = concatMap (expandPortBinding part) instancePorts mapInterface (orig @ (MIPackageItem (Function _ _ _ decls _))) = @@ -197,8 +201,6 @@ prefixModuleItems prefix = prefixLHS (LHSIdent x) = LHSIdent (prefix ++ x) prefixLHS other = other --- TODO: this is an incomplete attempt at looking up the type of an expression; --- there is definitely some overlap here with the Struct conversion lookupType :: [ModuleItem] -> Expr -> Type lookupType items (Ident ident) = head $ mapMaybe findType items @@ -207,7 +209,10 @@ lookupType items (Ident ident) = findType (MIDecl (Variable _ t x [] Nothing)) = if x == ident then Just t else Nothing findType _ = Nothing -lookupType _ expr = error $ "lookupType on fancy expr: " ++ show expr +lookupType _ expr = + -- TODO: Add support for non-Ident modport expressions. + error $ "interface conversion does not support modport expressions that " + ++ " are not identifiers: " ++ show expr -- convert an interface instantiation into a series of equivalent module items inlineInterface :: Interface -> (Identifier, [PortBinding]) -> [ModuleItem]