Commit 07caba64 by Zachary Snow

simplify non-ANSI style port declaration dimensions

parent 19b479d8
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
### Bug Fixes ### Bug Fixes
* Fixed an issue that prevented parsing tasks and functions with `inout` ports * Fixed an issue that prevented parsing tasks and functions with `inout` ports
* Fixed certain non-ANSI style port declarations being incorrectly reported as
incompatible
## v0.0.11 ## v0.0.11
......
...@@ -14,6 +14,8 @@ module Convert.ExprUtils ...@@ -14,6 +14,8 @@ module Convert.ExprUtils
, endianCondRange , endianCondRange
, dimensionsSize , dimensionsSize
, stringToNumber , stringToNumber
, simplifyRange
, simplifyDimensions
) where ) where
import Data.Bits ((.&.), (.|.), shiftL, shiftR) import Data.Bits ((.&.), (.|.), shiftL, shiftR)
...@@ -319,3 +321,9 @@ pattern ConvertedUU :: Integer -> Integer -> Integer -> Expr ...@@ -319,3 +321,9 @@ pattern ConvertedUU :: Integer -> Integer -> Integer -> Expr
pattern ConvertedUU sz v k <- Repeat pattern ConvertedUU sz v k <- Repeat
(RawNum sz) (RawNum sz)
[Number (Based 1 True Binary v k)] [Number (Based 1 True Binary v k)]
simplifyRange :: Range -> Range
simplifyRange (e1, e2) = (simplify e1, simplify e2)
simplifyDimensions :: [Range] -> [Range]
simplifyDimensions = map simplifyRange
...@@ -18,6 +18,7 @@ module Convert.PortDecl (convert) where ...@@ -18,6 +18,7 @@ module Convert.PortDecl (convert) where
import Data.List (intercalate, (\\)) import Data.List (intercalate, (\\))
import Data.Maybe (mapMaybe) import Data.Maybe (mapMaybe)
import Convert.ExprUtils (simplifyDimensions)
import Convert.Traverse import Convert.Traverse
import Language.SystemVerilog.AST import Language.SystemVerilog.AST
...@@ -102,9 +103,9 @@ combineDecls :: Decl -> Decl -> Decl ...@@ -102,9 +103,9 @@ combineDecls :: Decl -> Decl -> Decl
combineDecls portDecl dataDecl combineDecls portDecl dataDecl
| eP /= Nil = | eP /= Nil =
mismatch "invalid initialization at port declaration" mismatch "invalid initialization at port declaration"
| aP /= aD = | simplifyDimensions aP /= simplifyDimensions aD =
mismatch "different unpacked dimensions" mismatch "different unpacked dimensions"
| rsP /= rsD = | simplifyDimensions rsP /= simplifyDimensions rsD =
mismatch "different packed dimensions" mismatch "different packed dimensions"
| otherwise = | otherwise =
base (tf rsD) ident aD Nil base (tf rsD) ident aD Nil
......
module top(out);
output [32 - 1:0] out;
reg [31:0] out;
endmodule
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