mirror of https://github.com/zachjs/sv2v.git
standardized, shorter hash generation
This commit is contained in:
parent
9435c9d9d1
commit
92feef8759
|
|
@ -70,10 +70,7 @@ streamerBlock chunk size asgn output input =
|
|||
|
||||
streamerBlockName :: Expr -> Expr -> Identifier
|
||||
streamerBlockName chunk size =
|
||||
"_sv2v_strm_" ++ take 5 str
|
||||
where
|
||||
val = hash $ show (chunk, size)
|
||||
str = tail $ show val
|
||||
"_sv2v_strm_" ++ shortHash (chunk, size)
|
||||
|
||||
traverseStmtM :: Stmt -> Writer Funcs Stmt
|
||||
traverseStmtM (AsgnBlk op lhs expr) =
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ module Convert.Struct (convert) where
|
|||
|
||||
import Control.Monad.State
|
||||
import Control.Monad.Writer
|
||||
import Data.Hashable (hash)
|
||||
import Data.List (elemIndex, sortOn)
|
||||
import Data.Maybe (fromJust, isJust)
|
||||
import Data.Tuple (swap)
|
||||
|
|
@ -207,10 +206,7 @@ packerFn structTf =
|
|||
-- returns a "unique" name for the packer for a given struct type
|
||||
packerFnName :: TypeFunc -> Identifier
|
||||
packerFnName structTf =
|
||||
"sv2v_pack_struct_" ++ str
|
||||
where
|
||||
val = hash $ show structTf
|
||||
str = tail $ show val
|
||||
"sv2v_struct_" ++ shortHash structTf
|
||||
|
||||
-- This is where the magic happens. This is responsible for converting struct
|
||||
-- accesses, assignments, and literals, given appropriate information about the
|
||||
|
|
|
|||
|
|
@ -27,8 +27,12 @@ module Language.SystemVerilog.AST
|
|||
, module Type
|
||||
, exprToLHS
|
||||
, lhsToExpr
|
||||
, shortHash
|
||||
) where
|
||||
|
||||
import Text.Printf (printf)
|
||||
import Data.Hashable (hash)
|
||||
|
||||
import Language.SystemVerilog.AST.Attr as Attr
|
||||
import Language.SystemVerilog.AST.Decl as Decl
|
||||
import Language.SystemVerilog.AST.Description as Description
|
||||
|
|
@ -68,3 +72,8 @@ lhsToExpr (LHSRange l m r ) = Range (lhsToExpr l) m r
|
|||
lhsToExpr (LHSDot l x ) = Dot (lhsToExpr l) x
|
||||
lhsToExpr (LHSConcat ls) = Concat $ map lhsToExpr ls
|
||||
lhsToExpr (LHSStream o e ls) = Stream o e $ map lhsToExpr ls
|
||||
|
||||
shortHash :: (Show a) => a -> String
|
||||
shortHash x =
|
||||
take 5 $ printf "%05X" val
|
||||
where val = hash $ show x
|
||||
|
|
|
|||
Loading…
Reference in New Issue