Commit c262324a by Zachary Snow

removed Unique dependency

- made stream conversion pure
- type param conversion uses Set for instance uniqueness
- updated NOTICE and resolutions
parent 409f80ea
...@@ -35,41 +35,6 @@ Dependency: Cabal-2.4.1.0 ...@@ -35,41 +35,6 @@ Dependency: Cabal-2.4.1.0
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================ ================================================================================
Dependency: Unique-0.4.7.6
================================================================================
Copyright (c) 2014, Volodymyr Yaschenko
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Volodymyr Yaschenko nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
Dependency: alex-3.2.4 Dependency: alex-3.2.4
================================================================================ ================================================================================
...@@ -351,43 +316,6 @@ Dependency: bytestring-0.10.8.2 ...@@ -351,43 +316,6 @@ Dependency: bytestring-0.10.8.2
SUCH DAMAGE. SUCH DAMAGE.
================================================================================ ================================================================================
Dependency: clock-0.7.2
================================================================================
Copyright (c) 2009-2012, Cetin Sert
Copyright (c) 2010, Eugene Kirpichov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* The names of contributors may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
Dependency: cmdargs-0.10.20 Dependency: cmdargs-0.10.20
================================================================================ ================================================================================
...@@ -571,41 +499,6 @@ Dependency: directory-1.3.3.0 ...@@ -571,41 +499,6 @@ Dependency: directory-1.3.3.0
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
================================================================================ ================================================================================
Dependency: extra-1.6.14
================================================================================
Copyright Neil Mitchell 2014-2018.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Neil Mitchell nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
Dependency: filepath-1.4.2.1 Dependency: filepath-1.4.2.1
================================================================================ ================================================================================
...@@ -1211,38 +1104,3 @@ Dependency: unix-2.7.2.2 ...@@ -1211,38 +1104,3 @@ Dependency: unix-2.7.2.2
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
================================================================================
Dependency: unordered-containers-0.2.9.0
================================================================================
Copyright (c) 2010, Johan Tibell
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Johan Tibell nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...@@ -8,7 +8,6 @@ module Convert.ParamType (convert) where ...@@ -8,7 +8,6 @@ module Convert.ParamType (convert) where
import Control.Monad.Writer import Control.Monad.Writer
import Data.Either (isLeft) import Data.Either (isLeft)
import Data.List.Unique (complex)
import Data.Maybe (isJust, isNothing, fromJust) import Data.Maybe (isJust, isNothing, fromJust)
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
...@@ -20,7 +19,7 @@ type MaybeTypeMap = Map.Map Identifier (Maybe Type) ...@@ -20,7 +19,7 @@ type MaybeTypeMap = Map.Map Identifier (Maybe Type)
type Info = Map.Map Identifier ([Identifier], MaybeTypeMap) type Info = Map.Map Identifier ([Identifier], MaybeTypeMap)
type Instance = Map.Map Identifier Type type Instance = Map.Map Identifier Type
type Instances = [(Identifier, Instance)] type Instances = Set.Set (Identifier, Instance)
type IdentSet = Set.Set Identifier type IdentSet = Set.Set Identifier
type UsageMap = [(Identifier, Set.Set Identifier)] type UsageMap = [(Identifier, Set.Set Identifier)]
...@@ -33,8 +32,7 @@ convert files = ...@@ -33,8 +32,7 @@ convert files =
mapM (collectDescriptionsM collectDescriptionM) files mapM (collectDescriptionsM collectDescriptionM) files
(files', instancesRaw) = runWriter $ mapM (files', instancesRaw) = runWriter $ mapM
(mapM $ traverseModuleItemsM $ convertModuleItemM info) files (mapM $ traverseModuleItemsM $ convertModuleItemM info) files
instances = uniq instancesRaw instances = Set.toList instancesRaw
uniq l = l' where (l', _, _) = complex l
-- add type parameter instantiations -- add type parameter instantiations
files'' = map (concatMap explodeDescription) files' files'' = map (concatMap explodeDescription) files'
...@@ -241,7 +239,7 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) = ...@@ -241,7 +239,7 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) =
then return $ Instance m bindingsNamed x r p then return $ Instance m bindingsNamed x r p
else return $ Instance (moduleDefaultName m) bindingsDefaulted x r p else return $ Instance (moduleDefaultName m) bindingsDefaulted x r p
else do else do
tell [(m, resolvedTypes)] tell $ Set.singleton (m, resolvedTypes)
let m' = moduleInstanceName m resolvedTypes let m' = moduleInstanceName m resolvedTypes
return $ Instance m' bindings' x r p return $ Instance m' bindings' x r p
where where
......
...@@ -6,25 +6,15 @@ ...@@ -6,25 +6,15 @@
module Convert.Stream (convert) where module Convert.Stream (convert) where
import Control.Monad.Writer
import Data.List.Unique (complex)
import Convert.Traverse import Convert.Traverse
import Language.SystemVerilog.AST import Language.SystemVerilog.AST
type Funcs = [ModuleItem]
convert :: [AST] -> [AST] convert :: [AST] -> [AST]
convert = map $ traverseDescriptions convertDescription convert = map $ traverseDescriptions convertDescription
convertDescription :: Description -> Description convertDescription :: Description -> Description
convertDescription (description @ Part{}) = convertDescription (description @ Part{}) =
Part attrs extern kw lifetime name ports (items ++ funcs) traverseModuleItems (traverseStmts traverseStmt) description
where
(description', funcSet) =
runWriter $ traverseModuleItemsM (traverseStmtsM traverseStmtM) description
Part attrs extern kw lifetime name ports items = description'
(funcs, _, _) = complex funcSet
convertDescription other = other convertDescription other = other
streamerBlock :: Expr -> Expr -> (LHS -> Expr -> Stmt) -> LHS -> Expr -> Stmt streamerBlock :: Expr -> Expr -> (LHS -> Expr -> Stmt) -> LHS -> Expr -> Stmt
...@@ -67,32 +57,32 @@ streamerBlockName :: Expr -> Expr -> Identifier ...@@ -67,32 +57,32 @@ streamerBlockName :: Expr -> Expr -> Identifier
streamerBlockName chunk size = streamerBlockName chunk size =
"_sv2v_strm_" ++ shortHash (chunk, size) "_sv2v_strm_" ++ shortHash (chunk, size)
traverseStmtM :: Stmt -> Writer Funcs Stmt traverseStmt :: Stmt -> Stmt
traverseStmtM (Asgn op mt lhs expr) = traverseStmt (Asgn op mt lhs expr) =
traverseAsgnM (lhs, expr) (Asgn op mt) traverseAsgn (lhs, expr) (Asgn op mt)
traverseStmtM other = return other traverseStmt other = other
traverseAsgnM :: (LHS, Expr) -> (LHS -> Expr -> Stmt) -> Writer Funcs Stmt traverseAsgn :: (LHS, Expr) -> (LHS -> Expr -> Stmt) -> Stmt
traverseAsgnM (lhs, Stream StreamR _ exprs) constructor = traverseAsgn (lhs, Stream StreamR _ exprs) constructor =
return $ constructor lhs expr constructor lhs expr
where where
expr = Concat $ exprs ++ [Repeat delta [Number "1'b0"]] expr = Concat $ exprs ++ [Repeat delta [Number "1'b0"]]
size = DimsFn FnBits $ Right $ lhsToExpr lhs size = DimsFn FnBits $ Right $ lhsToExpr lhs
exprSize = DimsFn FnBits $ Right (Concat exprs) exprSize = DimsFn FnBits $ Right (Concat exprs)
delta = BinOp Sub size exprSize delta = BinOp Sub size exprSize
traverseAsgnM (LHSStream StreamR _ lhss, expr) constructor = traverseAsgn (LHSStream StreamR _ lhss, expr) constructor =
return $ constructor (LHSConcat lhss) expr constructor (LHSConcat lhss) expr
traverseAsgnM (lhs, Stream StreamL chunk exprs) constructor = do traverseAsgn (lhs, Stream StreamL chunk exprs) constructor = do
return $ streamerBlock chunk size constructor lhs expr streamerBlock chunk size constructor lhs expr
where where
expr = Concat $ Repeat delta [Number "1'b0"] : exprs expr = Concat $ Repeat delta [Number "1'b0"] : exprs
size = DimsFn FnBits $ Right $ lhsToExpr lhs size = DimsFn FnBits $ Right $ lhsToExpr lhs
exprSize = DimsFn FnBits $ Right (Concat exprs) exprSize = DimsFn FnBits $ Right (Concat exprs)
delta = BinOp Sub size exprSize delta = BinOp Sub size exprSize
traverseAsgnM (LHSStream StreamL chunk lhss, expr) constructor = do traverseAsgn (LHSStream StreamL chunk lhss, expr) constructor = do
return $ streamerBlock chunk size constructor lhs expr streamerBlock chunk size constructor lhs expr
where where
lhs = LHSConcat lhss lhs = LHSConcat lhss
size = DimsFn FnBits $ Right expr size = DimsFn FnBits $ Right expr
traverseAsgnM (lhs, expr) constructor = traverseAsgn (lhs, expr) constructor =
return $ constructor lhs expr constructor lhs expr
resolver: lts-13.17 resolver: lts-13.17
extra-deps:
- Unique-0.4.7.6
packages: packages:
- . - .
...@@ -3,14 +3,7 @@ ...@@ -3,14 +3,7 @@
# For more information, please see the documentation at: # For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files # https://docs.haskellstack.org/en/stable/lock_files
packages: packages: []
- completed:
hackage: Unique-0.4.7.6@sha256:a1ff411f4d68c756e01e8d532fbe8e57f1ac77f2cc0ee8a999770be2bca185c5,2723
pantry-tree:
size: 1366
sha256: 587d279ff94e8d6f43da3710634ca3611fa4f6886b1e541a73c69303c00297b9
original:
hackage: Unique-0.4.7.6
snapshots: snapshots:
- completed: - completed:
size: 497508 size: 497508
......
...@@ -32,8 +32,7 @@ executable sv2v ...@@ -32,8 +32,7 @@ executable sv2v
filepath, filepath,
githash, githash,
hashable, hashable,
mtl, mtl
Unique
other-modules: other-modules:
-- SystemVerilog modules -- SystemVerilog modules
Language.SystemVerilog Language.SystemVerilog
......
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