From 4b8a0d2af52ceeb3ff5d05082af53bac76744361 Mon Sep 17 00:00:00 2001 From: jackkoenig Date: Thu, 22 Sep 2016 19:10:40 -0700 Subject: Add Support for Parameterized ExtModules and Name Override Adds support for Integer, Double/Real, and String parameters in external modules. Also add name field to extmodules so that emitted name can be different from Firrtl name. This is important because parameterized extmodules will frequently have differing IO even though they need to be emitted as instantiating the same Verilog module. --- src/main/antlr4/FIRRTL.g4 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/main/antlr4') diff --git a/src/main/antlr4/FIRRTL.g4 b/src/main/antlr4/FIRRTL.g4 index 4ceed9f0..f4d9d3f8 100644 --- a/src/main/antlr4/FIRRTL.g4 +++ b/src/main/antlr4/FIRRTL.g4 @@ -63,7 +63,7 @@ circuit module : 'module' id ':' info? INDENT port* moduleBlock DEDENT - | 'extmodule' id ':' info? INDENT port* DEDENT + | 'extmodule' id ':' info? INDENT port* defname? parameter* DEDENT ; port @@ -89,6 +89,16 @@ field : 'flip'? id ':' type ; +defname + : 'defname' '=' id NEWLINE + ; + +parameter + : 'parameter' id '=' IntLit NEWLINE + | 'parameter' id '=' StringLit NEWLINE + | 'parameter' id '=' DoubleLit NEWLINE + ; + moduleBlock : simple_stmt* ; @@ -291,6 +301,10 @@ IntLit | '"' 'h' ( HexDigit )+ '"' ; +DoubleLit + : ( '+' | '-' )? Digit+ '.' Digit+ ( 'E' Digit+ )? + ; + fragment Nondigit : [a-zA-Z_] -- cgit v1.2.3