Commit 64f3067d by Zachary Snow

allow dimension shorthand for instance arrays

parent 3cfd368b
...@@ -182,6 +182,7 @@ parseDTsAsIntantiations (DTIdent _ name : tokens) = ...@@ -182,6 +182,7 @@ parseDTsAsIntantiations (DTIdent _ name : tokens) =
follow = if null toks' then [] else step (tail toks') follow = if null toks' then [] else step (tail toks')
asRange :: DeclToken -> Range asRange :: DeclToken -> Range
asRange (DTRange _ (NonIndexed, s)) = s asRange (DTRange _ (NonIndexed, s)) = s
asRange (DTBit _ s) = (Number "0", BinOp Sub s (Number "1"))
asRange _ = failure asRange _ = failure
failure = error $ "unrecognized instantiation of " ++ name failure = error $ "unrecognized instantiation of " ++ name
++ ": " ++ show inst ++ ": " ++ show inst
...@@ -192,6 +193,7 @@ parseDTsAsIntantiations (DTIdent _ name : tokens) = ...@@ -192,6 +193,7 @@ parseDTsAsIntantiations (DTIdent _ name : tokens) =
isInstanceToken :: DeclToken -> Bool isInstanceToken :: DeclToken -> Bool
isInstanceToken (DTInstance{}) = True isInstanceToken (DTInstance{}) = True
isInstanceToken (DTRange{}) = True isInstanceToken (DTRange{}) = True
isInstanceToken (DTBit{}) = True
isInstanceToken (DTIdent{}) = True isInstanceToken (DTIdent{}) = True
isInstanceToken (DTComma{}) = True isInstanceToken (DTComma{}) = True
isInstanceToken _ = False isInstanceToken _ = False
......
...@@ -4,11 +4,11 @@ module Example; ...@@ -4,11 +4,11 @@ module Example;
endmodule endmodule
module top; module top;
Example e[2:0][4:5](); Example e[3][4:5]();
defparam e[0][5].FOO = 1; defparam e[2][5].FOO = 1;
defparam e[0][4].FOO = 2; defparam e[2][4].FOO = 2;
defparam e[1][5].FOO = 4; defparam e[1][5].FOO = 4;
defparam e[1][4].FOO = 8; defparam e[1][4].FOO = 8;
defparam e[2][5].FOO = 16; defparam e[0][5].FOO = 16;
defparam e[2][4].FOO = 32; defparam e[0][4].FOO = 32;
endmodule 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