packages feed

copilot-bluespec 4.3 → 4.3.1

raw patch · 6 files changed

+136/−67 lines, 6 filesdep ~filepathPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: filepath

API changes (from Hackage documentation)

Files

CHANGELOG view
@@ -1,3 +1,8 @@+2025-05-05+        * Version bump (4.3.1). (#41)+        * Move Copilot.Compile.Bluespec.External out of shared directory. (#36)+        * Allow building with filepath-1.5.*. (#39)+ 2025-03-10         * Version bump (4.3). (#34) 
copilot-bluespec.cabal view
@@ -1,6 +1,6 @@ cabal-version             : >= 1.10 name                      : copilot-bluespec-version                   : 4.3+version                   : 4.3.1 synopsis                  : A compiler for Copilot targeting FPGAs. description               :   This package is a back-end from Copilot to FPGAs in Bluespec.@@ -36,12 +36,12 @@  library   default-language        : Haskell2010-  hs-source-dirs          : src, shared+  hs-source-dirs          : src    ghc-options             : -Wall   build-depends           : base              >= 4.9    && < 5                           , directory         >= 1.3    && < 1.4-                          , filepath          >= 1.4    && < 1.5+                          , filepath          >= 1.4    && < 1.6                           , pretty            >= 1.1.2  && < 1.2                            , copilot-core      >= 4.3    && < 4.4@@ -70,7 +70,7 @@   other-modules:    Test.Copilot.Compile.Bluespec -   Copilot.Compile.Bluespec.External+   Test.Copilot.Compile.Bluespec.External    build-depends:       base@@ -91,7 +91,7 @@     , copilot-bluespec    hs-source-dirs:-    tests, shared+    tests    default-language:     Haskell2010
− shared/Copilot/Compile/Bluespec/External.hs
@@ -1,57 +0,0 @@-{-# LANGUAGE ExistentialQuantification #-}---- | Represent information about externs needed in the generation of Bluespec--- code for stream declarations and triggers.-module Copilot.Compile.Bluespec.External-  ( External(..)-  , gatherExts-  ) where---- External imports-import Data.List (unionBy)---- Internal imports: Copilot-import Copilot.Core ( Expr (..), Stream (..), Trigger (..), Type, UExpr (..) )---- | Representation of external variables.-data External = forall a. External-  { extName :: String-  , extType :: Type a-  }---- | Collect all external variables from the streams and triggers.------ Although Copilot specifications can contain also properties and theorems,--- the C99 backend currently only generates code for streams and triggers.-gatherExts :: [Stream] -> [Trigger] -> [External]-gatherExts streams triggers = streamsExts `extUnion` triggersExts-  where-    streamsExts  = foldr (extUnion . streamExts) mempty streams-    triggersExts = foldr (extUnion . triggerExts) mempty triggers--    streamExts :: Stream -> [External]-    streamExts (Stream _ _ expr _) = exprExts expr--    triggerExts :: Trigger -> [External]-    triggerExts (Trigger _ guard args) = guardExts `extUnion` argExts-      where-        guardExts = exprExts guard-        argExts   = concatMap uExprExts args--    uExprExts :: UExpr -> [External]-    uExprExts (UExpr _ expr) = exprExts expr--    exprExts :: Expr a -> [External]-    exprExts (Local _ _ _ e1 e2)   = exprExts e1 `extUnion` exprExts e2-    exprExts (ExternVar ty name _) = [External name ty]-    exprExts (Op1 _ e)             = exprExts e-    exprExts (Op2 _ e1 e2)         = exprExts e1 `extUnion` exprExts e2-    exprExts (Op3 _ e1 e2 e3)      = exprExts e1 `extUnion` exprExts e2-                                       `extUnion` exprExts e3-    exprExts (Label _ _ e)         = exprExts e-    exprExts _                     = []--    -- | Union over lists of External, we solely base the equality on the-    -- extName's.-    extUnion :: [External] -> [External] -> [External]-    extUnion = unionBy (\a b -> extName a == extName b)
+ src/Copilot/Compile/Bluespec/External.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE ExistentialQuantification #-}++-- | Represent information about externs needed in the generation of Bluespec+-- code for stream declarations and triggers.+module Copilot.Compile.Bluespec.External+  ( External(..)+  , gatherExts+  ) where++-- External imports+import Data.List (unionBy)++-- Internal imports: Copilot+import Copilot.Core ( Expr (..), Stream (..), Trigger (..), Type, UExpr (..) )++-- | Representation of external variables.+data External = forall a. External+  { extName :: String+  , extType :: Type a+  }++-- | Collect all external variables from the streams and triggers.+--+-- Although Copilot specifications can contain also properties and theorems,+-- the Bluespec backend currently only generates code for streams and triggers.+gatherExts :: [Stream] -> [Trigger] -> [External]+gatherExts streams triggers = streamsExts `extUnion` triggersExts+  where+    streamsExts  = foldr (extUnion . streamExts) mempty streams+    triggersExts = foldr (extUnion . triggerExts) mempty triggers++    streamExts :: Stream -> [External]+    streamExts (Stream _ _ expr _) = exprExts expr++    triggerExts :: Trigger -> [External]+    triggerExts (Trigger _ guard args) = guardExts `extUnion` argExts+      where+        guardExts = exprExts guard+        argExts   = concatMap uExprExts args++    uExprExts :: UExpr -> [External]+    uExprExts (UExpr _ expr) = exprExts expr++    exprExts :: Expr a -> [External]+    exprExts (Local _ _ _ e1 e2)   = exprExts e1 `extUnion` exprExts e2+    exprExts (ExternVar ty name _) = [External name ty]+    exprExts (Op1 _ e)             = exprExts e+    exprExts (Op2 _ e1 e2)         = exprExts e1 `extUnion` exprExts e2+    exprExts (Op3 _ e1 e2 e3)      = exprExts e1 `extUnion` exprExts e2+                                       `extUnion` exprExts e3+    exprExts (Label _ _ e)         = exprExts e+    exprExts _                     = []++    -- | Union over lists of External, we solely base the equality on the+    -- extName's.+    extUnion :: [External] -> [External] -> [External]+    extUnion = unionBy (\a b -> extName a == extName b)
tests/Test/Copilot/Compile/Bluespec.hs view
@@ -47,11 +47,12 @@ -- External imports: Copilot import Copilot.Core hiding (Property) --- External imports: Modules being tested-import Copilot.Compile.Bluespec          (bluespecSettingsOutputDirectory,-                                          compile, compileWith,-                                          mkDefaultBluespecSettings)-import Copilot.Compile.Bluespec.External (External (extName), gatherExts)+-- External imports+import Copilot.Compile.Bluespec (bluespecSettingsOutputDirectory, compile,+                                 compileWith, mkDefaultBluespecSettings)++-- Internal imports+import Test.Copilot.Compile.Bluespec.External (External (extName), gatherExts)  -- * Constants 
+ tests/Test/Copilot/Compile/Bluespec/External.hs view
@@ -0,0 +1,63 @@+{-# LANGUAGE ExistentialQuantification #-}++-- | This is a duplicate version of @Copilot.Compile.Bluespec.External@ that is+-- specific to the test suite. Ideally, we would move this into a common library+-- that is shared between both @copilot-bluespec@ and @copilot-c99@ so that we+-- can avoid this duplication. See+-- https://github.com/Copilot-Language/copilot-bluespec/issues/3.+--+-- Represent information about externs needed in the generation of Bluespec+-- code for stream declarations and triggers.+module Test.Copilot.Compile.Bluespec.External+  ( External(..)+  , gatherExts+  ) where++-- External imports+import Data.List (unionBy)++-- External imports: Copilot+import Copilot.Core ( Expr (..), Stream (..), Trigger (..), Type, UExpr (..) )++-- | Representation of external variables.+data External = forall a. External+  { extName :: String+  , extType :: Type a+  }++-- | Collect all external variables from the streams and triggers.+--+-- Although Copilot specifications can contain also properties and theorems,+-- the Bluespec backend currently only generates code for streams and triggers.+gatherExts :: [Stream] -> [Trigger] -> [External]+gatherExts streams triggers = streamsExts `extUnion` triggersExts+  where+    streamsExts  = foldr (extUnion . streamExts) mempty streams+    triggersExts = foldr (extUnion . triggerExts) mempty triggers++    streamExts :: Stream -> [External]+    streamExts (Stream _ _ expr _) = exprExts expr++    triggerExts :: Trigger -> [External]+    triggerExts (Trigger _ guard args) = guardExts `extUnion` argExts+      where+        guardExts = exprExts guard+        argExts   = concatMap uExprExts args++    uExprExts :: UExpr -> [External]+    uExprExts (UExpr _ expr) = exprExts expr++    exprExts :: Expr a -> [External]+    exprExts (Local _ _ _ e1 e2)   = exprExts e1 `extUnion` exprExts e2+    exprExts (ExternVar ty name _) = [External name ty]+    exprExts (Op1 _ e)             = exprExts e+    exprExts (Op2 _ e1 e2)         = exprExts e1 `extUnion` exprExts e2+    exprExts (Op3 _ e1 e2 e3)      = exprExts e1 `extUnion` exprExts e2+                                       `extUnion` exprExts e3+    exprExts (Label _ _ e)         = exprExts e+    exprExts _                     = []++    -- | Union over lists of External, we solely base the equality on the+    -- extName's.+    extUnion :: [External] -> [External] -> [External]+    extUnion = unionBy (\a b -> extName a == extName b)