Commit 4178751b by Zachary Snow

interface conversion handles decls with unpacked dimensions

parent 4e342174
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
module Convert.Interface (convert) where module Convert.Interface (convert) where
import Data.Maybe (mapMaybe) import Data.Maybe (fromJust, mapMaybe)
import Control.Monad.Writer import Control.Monad.Writer
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import qualified Data.Set as Set import qualified Data.Set as Set
...@@ -79,9 +79,9 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it ...@@ -79,9 +79,9 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it
where where
InterfaceT interfaceName (Just _) [] = t InterfaceT interfaceName (Just _) [] = t
interfaceItems = snd $ interfaces Map.! interfaceName interfaceItems = snd $ interfaces Map.! interfaceName
mapper = \(dir, port, Just expr) -> mapper (dir, port, expr) =
Variable dir (lookupType interfaceItems expr) Variable dir mpt (ident ++ "_" ++ port) mprs Nothing
(ident ++ "_" ++ port) [] Nothing where (mpt, mprs) = lookupType interfaceItems (fromJust expr)
mapInterface (Instance part params ident Nothing instancePorts) = mapInterface (Instance part params ident Nothing instancePorts) =
case Map.lookup part interfaces of case Map.lookup part interfaces of
Just interface -> Just interface ->
...@@ -201,13 +201,15 @@ prefixModuleItems prefix = ...@@ -201,13 +201,15 @@ prefixModuleItems prefix =
prefixLHS (LHSIdent x) = LHSIdent (prefix ++ x) prefixLHS (LHSIdent x) = LHSIdent (prefix ++ x)
prefixLHS other = other prefixLHS other = other
lookupType :: [ModuleItem] -> Expr -> Type lookupType :: [ModuleItem] -> Expr -> (Type, [Range])
lookupType items (Ident ident) = lookupType items (Ident ident) =
head $ mapMaybe findType items case mapMaybe findType items of
[] -> error $ "unable to locate type of " ++ ident
ts -> head ts
where where
findType :: ModuleItem -> Maybe Type findType :: ModuleItem -> Maybe (Type, [Range])
findType (MIDecl (Variable _ t x [] Nothing)) = findType (MIDecl (Variable _ t x rs Nothing)) =
if x == ident then Just t else Nothing if x == ident then Just (t, rs) else Nothing
findType _ = Nothing findType _ = Nothing
lookupType _ expr = lookupType _ expr =
-- TODO: Add support for non-Ident modport expressions. -- TODO: Add support for non-Ident modport expressions.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment