Reputation: 1368
I have a custom Record type which represents a matrix. The Record.elements value contains the entries of the matrix is indexed with a key string which consists of the row number, an underscore, and the column number; i.e. s"${row}_${col}".
I also have a second custom Record type which represents an array of matrices, which do not all have to be the same size (which is why I can't use Vec). For this type, Record.elements contains the matrices and is simply indexed with an int, similar to other array types.
Something is causing the Firrtl parser to barf up syntax errors, which look like this:
line 8:30 no viable alternative at input '_0@[Matrix.scala 53:19]'
and this:
line 376:22 no viable alternative at input 'MatMul_1.io.in.1.3_0'
Some quick searching seems to indicate that this error is bubbling up from ANTLR, but at this point I concede that I am out of my depth.
Here is the stack trace, not including user code
Exception in thread "main" firrtl.SyntaxErrorsException: 77 syntax error(s) detected
at firrtl.Parser$$anonfun$1.apply(Parser.scala:45)
at firrtl.Parser$$anonfun$1.apply(Parser.scala:33)
at firrtl.Utils$.time(Utils.scala:182)
at firrtl.Parser$.parseCharStream(Parser.scala:33)
at firrtl.Parser$.parseString(Parser.scala:29)
at firrtl.Driver$$anonfun$getCircuit$1$$anonfun$apply$3$$anonfun$apply$4.apply(Driver.scala:172)
at firrtl.Driver$$anonfun$getCircuit$1$$anonfun$apply$3$$anonfun$apply$4.apply(Driver.scala:172)
at scala.Option.map(Option.scala:146)
at firrtl.Driver$$anonfun$getCircuit$1$$anonfun$apply$3.apply(Driver.scala:172)
at firrtl.Driver$$anonfun$getCircuit$1$$anonfun$apply$3.apply(Driver.scala:172)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$$anonfun$getCircuit$1.apply(Driver.scala:171)
at firrtl.Driver$$anonfun$getCircuit$1.apply(Driver.scala:160)
at scala.util.Try$.apply(Try.scala:192)
at firrtl.Driver$.getCircuit(Driver.scala:160)
at firrtl.Driver$$anonfun$execute$1.apply(Driver.scala:212)
at firrtl.Driver$$anonfun$execute$1.apply(Driver.scala:209)
at logger.Logger$$anonfun$makeScope$1.apply(Logger.scala:129)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at logger.Logger$.makeScope(Logger.scala:127)
at firrtl.Driver$.execute(Driver.scala:209)
at chisel3.Driver$.execute(Driver.scala:182)
at chisel3.Driver$.execute(Driver.scala:202)
Upvotes: 2
Views: 63
Reputation: 1368
After some head scratching, I figured it out: the Firrtl grammar (like many others) places restrictions on variable and field identifiers: they cannot begin with a number. Since the keys of my custom Record types all began with numbers, and Chisel uses the Record keys directly as Firrtl identifiers, the Firrtl parser was reporting the error.
tl;dr The keys that you use to index your custom Record.elements must be valid Firrtl identifiers (e.g. they cannot begin with a numeric).
Upvotes: 2