svstuff / systemverilog

SystemVerilog stuff and stuff.
http://svstuff.github.io/systemverilog
MIT License
12 stars 4 forks source link

Multi-dimensional input/output declarations #10

Open eymre opened 9 years ago

eymre commented 9 years ago

I guess the grammar file needs update to the following lines to support multi-dimensional ports.

SVParser.g4:

Old:

inout_declaration
  : KW_INOUT ( net_type )? ( KW_SIGNED )? ( range )? list_of_port_identifiers
  ;
input_declaration
  : KW_INPUT ( net_type )? ( KW_SIGNED )? ( range )? list_of_port_identifiers
  | KW_INPUT variable_port_type list_of_variable_identifiers
  ;
output_declaration
  : KW_OUTPUT ( net_type )? ( KW_SIGNED )? ( range )? list_of_port_identifiers
  | KW_OUTPUT variable_port_type list_of_variable_identifiers
  ;

New:

// I/O declaration may have multi-dimensional range
inout_declaration
  : KW_INOUT ( net_type )? ( KW_SIGNED )? ( range )* list_of_port_identifiers
  ;
input_declaration
  : KW_INPUT ( net_type )? ( KW_SIGNED )? ( range )* list_of_port_identifiers
  | KW_INPUT variable_port_type list_of_variable_identifiers
  ;
output_declaration
  : KW_OUTPUT ( net_type )? ( KW_SIGNED )? ( range )* list_of_port_identifiers
  | KW_OUTPUT variable_port_type list_of_variable_identifiers
  ;

Thanks,

Edit: Formatting

eymre commented 9 years ago

Sample code:

module multi_dimension (
    input logic  [3:0] [4:0] i 
);
endmodule
svstuff commented 9 years ago

This example parses for me. The rules applied in my run are:

It's possible there's an ambiguity that causes your input to go down another route. Could you post the output from run.sh (if it's not sensitive)?