verilog_parser.y 116.9 KB
Newer Older
饶先宏's avatar
饶先宏 已提交
1 2 3 4 5 6
%require  "3.0"
%defines 
%define parse.trace
%verbose

%define parse.error verbose
7
 
饶先宏's avatar
饶先宏 已提交
8
%{
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/*
** HDL4SE: 软件Verilog综合仿真平台
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** LCOM: 轻量级组件对象模型
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
**   this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
**   this list of conditions and the following disclaimer in the documentation
**   and/or other materials provided with the distribution.
** * The name of the author may be used to endorse or promote products
**   derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
** THE POSSIBILITY OF SUCH DAMAGE.
*/

/*
* verilog_parser.y
  修改记录:
    202105280612: rxh, initial version
饶先宏's avatar
饶先宏 已提交
44
    202106291739: rxh, 表达式运算符优先级的语法实现,规范中没有给出运算符优先级的语法表达
45 46
*/

47
    #include <stdio.h> 
饶先宏's avatar
饶先宏 已提交
48 49
    #include <string.h>
    #include <assert.h>
50 51
    #include "object.h"
    #include "dlist.h"
52
    #include "conststring.h"
53
    #include "verilog_keyword.h"
饶先宏's avatar
饶先宏 已提交
54 55 56
    #include "bignumber.h"
    #include "mapstr2ptr.h"
    #include "verilog_parsetree.h"
饶先宏's avatar
饶先宏 已提交
57 58 59 60 61

    extern int yylex();
    extern int yylineno;
    extern char * yytext;

饶先宏's avatar
饶先宏 已提交
62 63
    HOBJECT lastport = NULL;
    HOBJECT lastparameter = NULL;
饶先宏's avatar
饶先宏 已提交
64
    HOBJECT currentmodule = NULL;
65
    static char logbuf[2048];
饶先宏's avatar
饶先宏 已提交
66
    void yyerror(const char *msg){
67
        IConstStringVar *pfilename;
68 69 70
        int lineno;
        int linepos;
        int filepos;
71 72 73 74 75 76 77
        pfilename = NULL;
        if (0 == hdl4se_parser_GetCurrentFile(&pfilename, &lineno, &linepos, &filepos)) {
            if (pfilename != NULL) {
                sprintf(logbuf, "file %s line %d - ERROR: %s\n - '%s'", pfilename->string, lineno, msg, yytext);
                hdl4se_parser_AddLog(logbuf);
            }
        }
饶先宏's avatar
饶先宏 已提交
78
    }
79 80
%} 
 
饶先宏's avatar
饶先宏 已提交
81 82 83 84
%code requires{
#include "stdio.h"
#include "object.h"
#include "dlist.h"
85
#include "bignumber.h"
86
#include "conststring.h"
饶先宏's avatar
饶先宏 已提交
87
#include "mapstr2ptr.h"
饶先宏's avatar
饶先宏 已提交
88 89 90
#include "verilog_parsetree.h"
#include "verilog_root.h"
#include "verilog_module.h"
91
#include "verilog_keyword.h"
92
#include "verilog_attrspec.h"
饶先宏's avatar
饶先宏 已提交
93
#include "verilog_parameter.h"
饶先宏's avatar
饶先宏 已提交
94
#include "verilog_expr.h"
饶先宏's avatar
饶先宏 已提交
95
#include "verilog_port.h"
饶先宏's avatar
饶先宏 已提交
96
#include "verilog_vardecl.h"
97
#include "verilog_varsel.h"
饶先宏's avatar
饶先宏 已提交
98 99
#include "verilog_paraminst.h"
#include "verilog_moduleinst.h"
饶先宏's avatar
饶先宏 已提交
100
#include "verilog_assignment.h"
饶先宏's avatar
饶先宏 已提交
101
#include "verilog_statement.h"
饶先宏's avatar
饶先宏 已提交
102 103 104 105 106
}

/* token types */
%union {
	HOBJECT treenode;
饶先宏's avatar
饶先宏 已提交
107
    HOBJECT obj;
饶先宏's avatar
饶先宏 已提交
108 109 110 111 112
    struct _mul_obj {
      int type;
      int objcount;
      HOBJECT obj[16];
    }mul_obj;
113
    struct _str_bind_obj {
饶先宏's avatar
饶先宏 已提交
114
        IConstStringVar * key;
115 116
        HOBJECT obj;
    }str_bind_obj;
饶先宏's avatar
饶先宏 已提交
117
	IConstStringVar * string;
饶先宏's avatar
饶先宏 已提交
118 119
	int token;
	int operator;
120
	int ival;
饶先宏's avatar
饶先宏 已提交
121
	IDListVar* list;
饶先宏's avatar
饶先宏 已提交
122 123 124 125 126 127 128 129 130 131 132
}

%token <string> END  ANY  NEWLINE  SPACE  TAB

%token <string> BIN_VALUE  OCT_VALUE  HEX_VALUE  DEC_VALUE  
				DEC_BASE  BIN_BASE  OCT_BASE  HEX_BASE  
				NUM_REAL  NUM_SIZE  UNSIGNED_NUMBER  
				SYSTEM_ID  SIMPLE_ID  ESCAPED_ID  DEFINE_ID  
				STRING

/* Operators Precedence */
133
%token <token> '@' ',' '#' '.' '=' ':' ';' '(' ')' '[' ']' '{' '}' '+' '-' '*' '/' '%' '>' '<' '!' '&' '|' '^' '~' '?' 
饶先宏's avatar
饶先宏 已提交
134

饶先宏's avatar
饶先宏 已提交
135
%token <token> ATTRIBUTE_START ATTRIBUTE_END ASL ASR LSL LSR GTE LTE L_AND L_OR L_EQ C_EQ L_NEQ C_NEQ B_EQU B_NAND B_NOR IDX_PRT_SEL POW  T_AND
饶先宏's avatar
饶先宏 已提交
136
               STARTPLUSWIDTH STARTMINUSWIDTH MINUSGT EQGT STARGT
饶先宏's avatar
饶先宏 已提交
137

138
%token <token>  KW_ALWAYS  KW_AND  KW_ASSIGN  KW_AUTOMATIC  KW_BEGIN  KW_BUF  KW_BUFIF0  KW_BUFIF1  KW_CASE  KW_CASEX  
饶先宏's avatar
饶先宏 已提交
139 140 141 142 143 144 145 146 147 148 149 150
				KW_CASEZ  KW_CELL  KW_CMOS  KW_CONFIG  KW_DEASSIGN  KW_DEFAULT  KW_DEFPARAM  KW_DESIGN  KW_DISABLE  
				KW_EDGE  KW_ELSE  KW_END  KW_ENDCASE  KW_ENDCONFIG  KW_ENDFUNCTION  KW_ENDGENERATE  KW_ENDMODULE  
				KW_ENDPRIMITIVE  KW_ENDSPECIFY  KW_ENDTABLE  KW_ENDTASK  KW_EVENT  KW_FOR  KW_FORCE  KW_FOREVER  KW_FORK  
				KW_FUNCTION  KW_GENERATE  KW_GENVAR  KW_HIGHZ0  KW_HIGHZ1  KW_IF  KW_IFNONE  KW_INCDIR  KW_INCLUDE  
				KW_INITIAL  KW_INOUT  KW_INPUT  KW_INSTANCE  KW_INTEGER  KW_JOIN  KW_LARGE  KW_LIBLIST  KW_LIBRARY  
				KW_LOCALPARAM  KW_MACROMODULE  KW_MEDIUM  KW_MODULE  KW_NAN  KW_NEGEDGE  KW_NMOS  KW_NOR  KW_NOSHOWCANCELLED  
				KW_NOT  KW_NOTIF0  KW_NOTIF1  KW_OR  KW_OUTPUT  KW_PARAMETER  KW_PATHPULSE  KW_PMOS  KW_POSEDGE  KW_PRIMITIVE  
				KW_PULL0  KW_PULL1  KW_PULLDOWN  KW_PULLUP  KW_PULSESTYLE_ONEVENT  KW_PULSESTYLE_ONDETECT  KW_RCMOS  
				KW_REAL  KW_REALTIME  KW_REG  KW_RELEASE  KW_REPEAT  KW_RNMOS  KW_RPMOS  KW_RTRAN  KW_RTRANIF0  KW_RTRANIF1  
				KW_SCALARED  KW_SHOWCANCELLED  KW_SIGNED  KW_SMALL  KW_SPECIFY  KW_SPECPARAM  KW_STRONG0  KW_STRONG1  
				KW_SUPPLY0  KW_SUPPLY1  KW_TABLE  KW_TASK  KW_TIME  KW_TRAN  KW_TRANIF0  KW_TRANIF1  KW_TRI  KW_TRI0  
				KW_TRI1  KW_TRIAND  KW_TRIOR  KW_TRIREG  KW_UNSIGNED  KW_USE  KW_VECTORED  KW_WAIT  KW_WAND  KW_WEAK0  
饶先宏's avatar
饶先宏 已提交
151 152 153
				KW_WEAK1  KW_WHILE  KW_WIRE  KW_WOR  KW_XNOR  KW_XOR KW_NAND KW_UWIRE 
                KW_SYS_SETUP KW_SYS_HOLD KW_SYS_SETUPHOLD KW_SYS_RECOVERY KW_SYS_REMOVAL KW_SYS_RECREM KW_SYS_SKEW 
                KW_SYS_TIMESKEW KW_SYS_FULLSKEW KW_SYS_PERIOD KW_SYS_WIDTH KW_SYS_NOCHANGE 
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170

/* Operator Precedence */


%right  '?'                 /* Lowest Precedence */
%left   L_OR
%left   L_AND
%left   '|' B_NOR
%left   B_EQU '^'
%left   B_NAND '&'
%left   L_EQ C_EQ L_NEQ C_NEQ
%left   '>' '<' GTE LTE
%left   LSL LSR ASR ASL
%left   '+' '-'
%left   '*' '/' '%'
%left   POW
%right  '!' '~'    /* Highest Precedence. */
饶先宏's avatar
饶先宏 已提交
171 172 173
				
%start grammar_begin

174 175
%type <string> attr_name identifier module_identifier 
               topmodule_identifier parameter_identifier
饶先宏's avatar
饶先宏 已提交
176
               port_identifier net_identifier
饶先宏's avatar
饶先宏 已提交
177
               module_instance_identifier
饶先宏's avatar
饶先宏 已提交
178
               number string unsigned_number 
179

180 181 182
%type <ival> parameter_type 
             unary_operator 
             binary_operator 
饶先宏's avatar
饶先宏 已提交
183 184 185 186
             signed_option
             unary_module_path_operator 
             binary_module_path_operator
             net_type net_type_option output_variable_type
饶先宏's avatar
饶先宏 已提交
187
             vectored_or_scalared_option vectored_option scalared_option
饶先宏's avatar
饶先宏 已提交
188

饶先宏's avatar
饶先宏 已提交
189 190
%type <mul_obj> range range_option constant_range_expression dimension  
                mintypmax_expression mintypmax_expression_option var
饶先宏's avatar
饶先宏 已提交
191
%type <str_bind_obj> port_ident param_assignment net_decl_assignment
饶先宏's avatar
饶先宏 已提交
192
                   
193

194
%type <treenode>  attr_spec 
195
%type <treenode>  constant_mintypmax_expression constant_primary
饶先宏's avatar
饶先宏 已提交
196 197 198 199 200 201 202
                  port parameter_declaration
                  port_declaration inout_declaration input_declaration output_declaration
                  port_reference
                  constant_base_expression
                  width_constant_expression
                  msb_constant_expression 
                  lsb_constant_expression
饶先宏's avatar
饶先宏 已提交
203
                  dimension_constant_expression
饶先宏's avatar
饶先宏 已提交
204 205 206 207
                  primary unary_expression pow_expression multiplicative_expression
                  additive_expression shift_expression relational_expression equality_expression
                  and_expression exclusive_or_expression inclusive_or_expression
                  logical_and_expression logical_or_expression conditional_expression 
饶先宏's avatar
饶先宏 已提交
208
                  expression expression_option
209 210 211 212 213
                  unary_constant_expression pow_constant_expression multiplicative_constant_expression
                  additive_constant_expression shift_constant_expression relational_constant_expression equality_constant_expression
                  and_constant_expression exclusive_or_constant_expression inclusive_or_constant_expression
                  logical_and_constant_expression logical_or_constant_expression conditional_constant_expression 
                  constant_expression
饶先宏's avatar
饶先宏 已提交
214
                  base_expression
饶先宏's avatar
饶先宏 已提交
215 216 217
                  module_instance
                  ordered_parameter_assignment named_parameter_assignment
                  named_port_connection ordered_port_connection
饶先宏's avatar
饶先宏 已提交
218
                  net_assignment
饶先宏's avatar
饶先宏 已提交
219
                  hierarchical_identifier_part
饶先宏's avatar
饶先宏 已提交
220
                  statement statement_or_null blocking_assignment  nonblocking_assignment
221

饶先宏's avatar
饶先宏 已提交
222 223
%type <list> attribute_instance_list attribute_instance attribute_instance_spec_list
             hierarchical_identifier 
饶先宏's avatar
饶先宏 已提交
224 225 226 227
%type <list> list_of_net list_of_net_identifiers list_of_net_decl_assignments

%type <list> dimension_list

饶先宏's avatar
饶先宏 已提交
228
%type <list> module_parameter_port_list module_param_list  
饶先宏's avatar
饶先宏 已提交
229
             list_of_param_assignments port_declaration_list
饶先宏's avatar
饶先宏 已提交
230 231 232 233 234
             list_of_port_connections_option

%type <list> module_instance_list parameter_value_assignment_option parameter_value_assignment
             list_of_parameter_assignments ordered_parameter_assignment_list named_parameter_assignment_list
             list_of_port_connections ordered_port_connection_list named_port_connection_list
235 236 237

%type <list> list_of_port_declarations
             list_of_ports module_item_list non_port_module_item_list 
饶先宏's avatar
饶先宏 已提交
238
             ports port_declarations port_expression
239

饶先宏's avatar
饶先宏 已提交
240 241
%type <list> list_of_net_assignments

饶先宏's avatar
饶先宏 已提交
242

饶先宏's avatar
饶先宏 已提交
243 244
%%

245
/* Start variables */
饶先宏's avatar
饶先宏 已提交
246
grammar_begin : 
247 248
  library_text {}
| source_text {}
249 250
| %empty {
}
饶先宏's avatar
饶先宏 已提交
251 252 253 254 255
;

/* A.1.1 Library Source Text */

library_text : 
256 257
  library_descriptions {}
| library_text library_descriptions{}
饶先宏's avatar
饶先宏 已提交
258 259 260
;

library_descriptions : 
261 262 263
  library_declaration{}
| include_statement{}
| config_declaration{}
饶先宏's avatar
饶先宏 已提交
264 265 266
;

library_declaration : 
267 268
  KW_LIBRARY library_identifier file_path_specs ';'{}
| KW_LIBRARY library_identifier file_path_specs KW_INCDIR file_path_specs ';'{}
饶先宏's avatar
饶先宏 已提交
269 270 271
;

file_path_specs : 
272 273
  file_path_spec{}
| file_path_specs ',' file_path_spec{}
饶先宏's avatar
饶先宏 已提交
274 275
;

276
file_path_spec : file_path{}
饶先宏's avatar
饶先宏 已提交
277 278
;

279
file_path : string {}
饶先宏's avatar
饶先宏 已提交
280 281
;

282
include_statement : KW_INCLUDE file_path_spec ';'{}
饶先宏's avatar
饶先宏 已提交
283
;
284 285
   
/* A.1.2  Verilog source text. */
饶先宏's avatar
饶先宏 已提交
286 287 288

source_text : 
  description {
289
  }
饶先宏's avatar
饶先宏 已提交
290 291 292 293 294 295
| source_text description{
}
;

description : 
  module_declaration {
296 297
  }
| udp_declaration {
饶先宏's avatar
饶先宏 已提交
298
}
299
| config_declaration {
饶先宏's avatar
饶先宏 已提交
300 301 302
}
;

饶先宏's avatar
饶先宏 已提交
303
module_item_list :
304
    %empty {
饶先宏's avatar
饶先宏 已提交
305 306 307 308 309 310 311 312
    }
|   module_item {
    }
|   module_item_list module_item {
    }
  ;

non_port_module_item_list :
313
    %empty {
饶先宏's avatar
饶先宏 已提交
314 315 316 317 318 319 320
    }
|   non_port_module_item {
    }
|   non_port_module_item_list non_port_module_item {
    }
  ;

饶先宏's avatar
饶先宏 已提交
321
module_declaration : 
322
  attribute_instance_list
饶先宏's avatar
饶先宏 已提交
323 324 325
  module_keyword
  module_identifier
  module_parameter_port_list
326 327
  list_of_ports
  ';'
饶先宏's avatar
饶先宏 已提交
328 329 330
  {
    IVerilogRoot ** ppRoot = getVerilogRoot();
	(*ppRoot)->add_module(ppRoot, $3, currentmodule = verilogparseCreateModuleDeclaration($1,$3,$4,$5));
饶先宏's avatar
饶先宏 已提交
331
    objectRelease($3);
饶先宏's avatar
饶先宏 已提交
332 333 334
    lastport = NULL;
    lastparameter = NULL;
  }
335
  module_item_list
饶先宏's avatar
饶先宏 已提交
336
  KW_ENDMODULE
337
{
饶先宏's avatar
饶先宏 已提交
338
/*
饶先宏's avatar
饶先宏 已提交
339
	IVerilogRoot ** ppRoot = getVerilogRoot();
饶先宏's avatar
饶先宏 已提交
340
	(*ppRoot)->add_module(ppRoot, $3, verilogparseCreateModuleDeclaration($1,$3,$4,$5));
饶先宏's avatar
饶先宏 已提交
341
    objectRelease($3);
饶先宏's avatar
饶先宏 已提交
342 343
    lastport = NULL;
    lastparameter = NULL;
饶先宏's avatar
饶先宏 已提交
344 345
*/
    currentmodule = NULL;
346 347 348
}  

| attribute_instance_list
饶先宏's avatar
饶先宏 已提交
349 350 351
  module_keyword
  module_identifier
  module_parameter_port_list
352 353
  list_of_port_declarations
  ';'
饶先宏's avatar
饶先宏 已提交
354 355 356
  {
	IVerilogRoot ** ppRoot = getVerilogRoot();
	(*ppRoot)->add_module(ppRoot, $3, currentmodule = verilogparseCreateModuleDeclaration($1,$3,$4,$5));
饶先宏's avatar
饶先宏 已提交
357
    objectRelease($3);
饶先宏's avatar
饶先宏 已提交
358 359 360 361
    lastport = NULL;
    lastparameter = NULL;

  }
362 363 364
  non_port_module_item_list
  KW_ENDMODULE
  {
饶先宏's avatar
饶先宏 已提交
365
/*
饶先宏's avatar
饶先宏 已提交
366
	IVerilogRoot ** ppRoot = getVerilogRoot();
饶先宏's avatar
饶先宏 已提交
367
	(*ppRoot)->add_module(ppRoot, $3, verilogparseCreateModuleDeclaration($1,$3,$4,$5));
饶先宏's avatar
饶先宏 已提交
368
    objectRelease($3);
饶先宏's avatar
饶先宏 已提交
369 370
    lastport = NULL;
    lastparameter = NULL;
饶先宏's avatar
饶先宏 已提交
371 372
    */
    currentmodule = NULL;
饶先宏's avatar
饶先宏 已提交
373
  }
饶先宏's avatar
饶先宏 已提交
374 375
;

376 377 378 379 380 381 382
module_keyword :
  KW_MODULE {
  }
| KW_MACROMODULE {
  }
  ;

饶先宏's avatar
饶先宏 已提交
383

384 385 386
/*
A.1.3 Module parameters and ports
*/
饶先宏's avatar
饶先宏 已提交
387

388
module_parameter_port_list  : 
389
   %empty {
饶先宏's avatar
饶先宏 已提交
390
    $$ = dlistCreate();
饶先宏's avatar
饶先宏 已提交
391
    lastparameter = NULL;
392 393
    }
|   '#' '(' module_param_list ')'{
饶先宏's avatar
饶先宏 已提交
394
    $$ = $3;
饶先宏's avatar
饶先宏 已提交
395
    lastparameter = NULL;
饶先宏's avatar
饶先宏 已提交
396 397 398
}
;

399 400
module_param_list : 
  parameter_declaration {
饶先宏's avatar
饶先宏 已提交
401 402
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
403
  }
404 405
| module_param_list ',' parameter_declaration{
	$$ = $1;
饶先宏's avatar
饶先宏 已提交
406
	dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
407 408 409
}
;

410 411
list_of_ports :
    %empty {
饶先宏's avatar
饶先宏 已提交
412
    $$ = dlistCreate();
饶先宏's avatar
饶先宏 已提交
413
}
414
| '(' ports ')' {
饶先宏's avatar
饶先宏 已提交
415 416 417 418
    $$ = $2;
}
;

饶先宏's avatar
饶先宏 已提交
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
/*
我们不支持复杂端口定义 
*/
ports : 
    %empty {
	$$ = dlistCreate();
}
| ports ',' port_identifier{
    $$ = $1;
    dlistAppendItem($$,
        verilogparseCreatePort(
            NULL, /* IDListVarPtr attributes, */
            PORT_DIRECT_UNKNOW, /* int port_direct, */
            0, /* int port_type, */
            0, /* int port_issigned, */
            RANGE_TYPE_NONE, /*int range_type*/
            NULL, /* HOBJECT param_range_msb,  expression */
            NULL, /* HOBJECT param_range_lsb,  expression */
            $3, /* const char * name, */
            NULL /* HOBJECT expr */
        )
    );
}
| port_identifier {
    $$ = dlistCreate();
    dlistAppendItem($$,
        verilogparseCreatePort(
            NULL, /* IDListVarPtr attributes, */
            PORT_DIRECT_UNKNOW, /* int port_direct, */
饶先宏's avatar
饶先宏 已提交
448
            VAR_TYPE_NONE, /* int port_type, */
饶先宏's avatar
饶先宏 已提交
449 450 451 452 453 454 455 456 457 458 459 460
            0, /* int port_issigned, */
            RANGE_TYPE_NONE, /*int range_type*/
            NULL, /* HOBJECT param_range_msb,  expression */
            NULL, /* HOBJECT param_range_lsb,  expression */
            $1, /* const char * name, */
            NULL /* HOBJECT expr */
        )
    );
}
;

/*
461 462
ports : 
    %empty {
饶先宏's avatar
饶先宏 已提交
463
	$$ = dlistCreate();
饶先宏's avatar
饶先宏 已提交
464
}
465
| ports ',' port{
饶先宏's avatar
饶先宏 已提交
466
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
467
    dlistAppendItem($$,$3);
饶先宏's avatar
饶先宏 已提交
468
}
469
| port {
饶先宏's avatar
饶先宏 已提交
470 471
    $$ = dlistCreate();
	dlistAppendItem($$,$1);
饶先宏's avatar
饶先宏 已提交
472 473
}
;
饶先宏's avatar
饶先宏 已提交
474
*/
饶先宏's avatar
饶先宏 已提交
475

476
list_of_port_declarations   : 
477
 '(' port_declarations ')'{
478
    $$ = $2;
饶先宏's avatar
饶先宏 已提交
479 480 481
}
;

482
port_declarations : 
483
  %empty { 
饶先宏's avatar
饶先宏 已提交
484
    $$ = dlistCreate();
485 486
  }
| port_declarations ',' port_declaration {
饶先宏's avatar
饶先宏 已提交
487
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
488
    dlistAppendItem($$,$3);
489 490
  }
| port_declaration {
饶先宏's avatar
饶先宏 已提交
491 492
    $$ = dlistCreate();
	dlistAppendItem($$,$1);
493 494
  }
  ;
饶先宏's avatar
饶先宏 已提交
495 496 497

port            : 
  port_expression{
498
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
499
  }
500
| '.' port_identifier '(' port_expression ')'{
饶先宏's avatar
饶先宏 已提交
501
   // $$ = verilogparserCreatePort($2, $4);
饶先宏's avatar
饶先宏 已提交
502 503 504 505
}
;

port_expression : 
506 507
   %empty {
	$$ = dlistCreate();
508 509
	}
| port_reference {
饶先宏's avatar
饶先宏 已提交
510 511
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
512
  }
513
| port_expression ',' port_reference{
饶先宏's avatar
饶先宏 已提交
514
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
515
    dlistAppendItem($$,$3);
饶先宏's avatar
饶先宏 已提交
516 517 518 519 520
}
;

port_reference  : 
  port_identifier{
饶先宏's avatar
饶先宏 已提交
521
  $$ = NULL;
饶先宏's avatar
饶先宏 已提交
522
}
523
| port_identifier '[' ']' {
饶先宏's avatar
饶先宏 已提交
524
  $$ = NULL;
饶先宏's avatar
饶先宏 已提交
525
}
526
| port_identifier '[' constant_range_expression ']' {
饶先宏's avatar
饶先宏 已提交
527
  $$ = NULL;
饶先宏's avatar
饶先宏 已提交
528 529 530
}
;

531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
/*
port_declaration : 
    attribute_instance_list inout_declaration {
    }
|   attribute_instance_list input_declaration {
    }
|   attribute_instance_list output_declaration {
    }
  ;
*/
/*
  IEEE. 1364-2005的这种格式端口定义不满足LALR(1),
  module test (
    input [7:0] a,
    input signed [7:0] b, c, d, 
    output [7:0] e, 
    output reg signed [7:0] f, g,
    output signed [7:0] h) ;
  endmodule
  原来的语法是分组描述的,然而注意每一组定义后面用逗号,
  与组内的标识符后的逗号冲突了,这样不满足LALR(1)的要求,
  现在改为为每个端口都是单独声明的,声明可以带属性也可以
  不带属性,不带属性的声明使用前面最近一个带属性的声明的
  属性。导致的问题有二:1.第一个端口必须是带属性的,这个
  应该由动作函数来做检查,2.output端口类型可以设置REG等属
  性并设置初始值,这是其他端口不能有的,这个也由动作函数
  来做检查吧。
  注意后面的input_declaration,input_declaration和
  output_declaration也做了相应的调整,每个后面不是跟一系列
  标识符,而是只跟一个port_ident了,这样就消除了冲突,满足
  LALR(1)的要求。
*/
563
port_declaration : 
饶先宏's avatar
饶先宏 已提交
564 565
    inout_declaration {
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
566
    lastport = $1;
567
    }
饶先宏's avatar
饶先宏 已提交
568 569
|   input_declaration {
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
570
    lastport = $1;
571
    }
饶先宏's avatar
饶先宏 已提交
572 573
|   output_declaration {
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
574
    lastport = $1;
575 576
    }
|   port_ident {
饶先宏's avatar
饶先宏 已提交
577 578 579
       $$ = verilogparseCreatePort(
            NULL, /* IDListVarPtr attributes, */
            PORT_DIRECT_ASPRE, /* int port_direct, */
饶先宏's avatar
饶先宏 已提交
580
            VAR_TYPE_NONE, /* int port_type, */
饶先宏's avatar
饶先宏 已提交
581 582 583 584 585 586 587
            0, /* int port_issigned, */
            RANGE_TYPE_NONE, /*int range_type*/
            lastport, /* HOBJECT param_range_msb,  expression */
            NULL, /* HOBJECT param_range_lsb,  expression */
            $1.key, /* const char * name, */
            $1.obj /* HOBJECT expr */
        );
588
    }
饶先宏's avatar
饶先宏 已提交
589 590
;

591 592 593 594
/*
下面修改过的语法从A.2.1.2过来的
*/
inout_declaration :
饶先宏's avatar
饶先宏 已提交
595
    attribute_instance_list KW_INOUT net_type_option signed_option range_option 
596
    port_ident {
饶先宏's avatar
饶先宏 已提交
597 598 599 600 601 602 603 604 605 606 607
    $$ = verilogparseCreatePort(
            $1, /* IDListVarPtr attributes, */
            PORT_DIRECT_INOUT, /* int port_direct, */
            $3, /* int port_type, */
            $4, /* int port_issigned, */
            $5.type, /*int range_type*/
            $5.obj[0], /* HOBJECT param_range_msb,  expression */
            $5.obj[1], /* HOBJECT param_range_lsb,  expression */
            $6.key, /* const char * name, */
            $6.obj /* HOBJECT expr */
        );
608 609 610 611
    }
  ;

input_declaration :
饶先宏's avatar
饶先宏 已提交
612
    attribute_instance_list KW_INPUT net_type_option signed_option range_option 
613
    port_ident {
饶先宏's avatar
饶先宏 已提交
614 615 616 617 618 619 620 621 622 623 624
    $$ = verilogparseCreatePort(
            $1, /* IDListVarPtr attributes, */
            PORT_DIRECT_INPUT, /* int port_direct, */
            $3, /* int port_type, */
            $4, /* int port_issigned, */
            $5.type, /*int range_type*/
            $5.obj[0], /* HOBJECT param_range_msb,  expression */
            $5.obj[1], /* HOBJECT param_range_lsb,  expression */
            $6.key, /* const char * name, */
            $6.obj /* HOBJECT expr */
        );
625 626 627 628
    }
  ;

output_declaration :
饶先宏's avatar
饶先宏 已提交
629
    attribute_instance_list KW_OUTPUT net_type_option signed_option range_option 
630
    port_ident {
饶先宏's avatar
饶先宏 已提交
631 632 633 634 635 636 637 638 639 640 641 642
    $$ = verilogparseCreatePort(
            $1, /* IDListVarPtr attributes, */
            PORT_DIRECT_OUTPUT, /* int port_direct, */
            $3, /* int port_type, */
            $4, /* int port_issigned, */
            $5.type, /*int range_type*/
            $5.obj[0], /* HOBJECT param_range_msb,  expression */
            $5.obj[1], /* HOBJECT param_range_lsb,  expression */
            $6.key, /* const char * name, */
            $6.obj /* HOBJECT expr */
        );

643
    }
饶先宏's avatar
饶先宏 已提交
644
|   attribute_instance_list KW_OUTPUT KW_REG signed_option range_option
645
    port_ident {
饶先宏's avatar
饶先宏 已提交
646 647
    $$ = verilogparseCreatePort(
            $1, /* IDListVarPtr attributes, */
饶先宏's avatar
饶先宏 已提交
648
            PORT_DIRECT_OUTPUT, /* int port_direct, */
饶先宏's avatar
饶先宏 已提交
649
            VAR_TYPE_REG, /* int port_type, */
饶先宏's avatar
饶先宏 已提交
650 651 652 653 654 655 656 657
            $4, /* int port_issigned, */
            $5.type, /*int range_type*/
            $5.obj[0], /* HOBJECT param_range_msb,  expression */
            $5.obj[1], /* HOBJECT param_range_lsb,  expression */
            $6.key, /* const char * name, */
            $6.obj /* HOBJECT expr */
        );

658
    }
饶先宏's avatar
饶先宏 已提交
659
|   attribute_instance_list KW_OUTPUT output_variable_type 
660
    port_ident {
饶先宏's avatar
饶先宏 已提交
661 662
    $$ = verilogparseCreatePort(
            $1, /* IDListVarPtr attributes, */
饶先宏's avatar
饶先宏 已提交
663
            PORT_DIRECT_OUTPUT, /* int port_direct, */
饶先宏's avatar
饶先宏 已提交
664 665 666 667 668 669 670 671
            $3, /* int port_type, */
            0, /* int port_issigned, */
            RANGE_TYPE_NONE, /*int range_type*/
            NULL, /* HOBJECT param_range_msb,  expression */
            NULL, /* HOBJECT param_range_lsb,  expression */
            $4.key, /* const char * name, */
            $4.obj /* HOBJECT expr */
        );
672 673 674 675
    }
  ;


676 677 678
/* 
A.1.4 Module Items 
*/
饶先宏's avatar
饶先宏 已提交
679

饶先宏's avatar
饶先宏 已提交
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
port_declaration_list :
    inout_declaration {
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
    lastport = $1;
    }
|   input_declaration {
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
    lastport = $1;
    }
|   output_declaration {
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
    lastport = $1;
    }
|   port_declaration_list ',' port_ident {
    $$ = $1;
698 699 700
    dlistAppendItem($$, verilogparseCreatePort(
            NULL, /* IDListVarPtr attributes, */
            PORT_DIRECT_ASPRE, /* int port_direct, */
饶先宏's avatar
饶先宏 已提交
701
            VAR_TYPE_NONE, /* int port_type, */
702 703 704 705 706 707 708
            0, /* int port_issigned, */
            RANGE_TYPE_NONE, /*int range_type*/
            lastport, /* HOBJECT param_range_msb,  expression */
            NULL, /* HOBJECT param_range_lsb,  expression */
            $3.key, /* const char * name, */
            $3.obj /* HOBJECT expr */
        ));
饶先宏's avatar
饶先宏 已提交
709 710
    }

711
module_item :
饶先宏's avatar
饶先宏 已提交
712
    port_declaration_list {
713 714 715
    }
|   non_port_module_item {
    }
饶先宏's avatar
饶先宏 已提交
716 717
 ;

718
module_or_generate_item :
饶先宏's avatar
饶先宏 已提交
719
  module_or_generate_item_declaration {
饶先宏's avatar
饶先宏 已提交
720
  }
721
| attribute_instance_list local_parameter_declaration ';' {
饶先宏's avatar
饶先宏 已提交
722
  }
723
| attribute_instance_list parameter_override {
饶先宏's avatar
饶先宏 已提交
724
  }
饶先宏's avatar
饶先宏 已提交
725
| continuous_assign {
饶先宏's avatar
饶先宏 已提交
726
  }
727
| attribute_instance_list gate_instantiation {
饶先宏's avatar
饶先宏 已提交
728
  }
729
| attribute_instance_list udp_instantiation {
饶先宏's avatar
饶先宏 已提交
730
  }
饶先宏's avatar
饶先宏 已提交
731
| module_instantiation {
饶先宏's avatar
饶先宏 已提交
732
  }
733
| attribute_instance_list initial_construct {
饶先宏's avatar
饶先宏 已提交
734
  }
饶先宏's avatar
饶先宏 已提交
735
| always_construct {
736 737 738 739 740 741
  }
| attribute_instance_list loop_generate_construct {
  }
| attribute_instance_list conditional_generate_construct {
  }
  ;
饶先宏's avatar
饶先宏 已提交
742

743
module_or_generate_item_declaration :
饶先宏's avatar
饶先宏 已提交
744
  net_declaration {
745
    }
饶先宏's avatar
饶先宏 已提交
746
|  attribute_instance_list reg_declaration {
747
    }
饶先宏's avatar
饶先宏 已提交
748
|  attribute_instance_list integer_declaration {
749
    }
饶先宏's avatar
饶先宏 已提交
750
| attribute_instance_list real_declaration {
751
    }
饶先宏's avatar
饶先宏 已提交
752
| attribute_instance_list time_declaration {
753
    }
饶先宏's avatar
饶先宏 已提交
754
| attribute_instance_list realtime_declaration {
755
    }
饶先宏's avatar
饶先宏 已提交
756
| attribute_instance_list event_declaration {
757
    }
饶先宏's avatar
饶先宏 已提交
758
| attribute_instance_list genvar_declaration {
759
    }
饶先宏's avatar
饶先宏 已提交
760
| attribute_instance_list task_declaration {
761
    }
饶先宏's avatar
饶先宏 已提交
762
| attribute_instance_list function_declaration {
763
    }
饶先宏's avatar
饶先宏 已提交
764 765
 ;

766 767 768 769 770
non_port_module_item :
    module_or_generate_item {
    }
|   generate_region {
    }
饶先宏's avatar
饶先宏 已提交
771
|   specify_block {
772 773 774 775 776 777
    }
|   attribute_instance_list parameter_declaration ';' {
    }
|   attribute_instance_list specparam_declaration {
    }
   ;
饶先宏's avatar
饶先宏 已提交
778

779
parameter_override :
饶先宏's avatar
饶先宏 已提交
780
    KW_DEFPARAM list_of_defparam_assignments ';' {
781 782
    }
    ;
饶先宏's avatar
饶先宏 已提交
783

784 785 786 787
/*
A.1.5 Configuration source text
*/
config_declaration :
饶先宏's avatar
饶先宏 已提交
788 789
    KW_CONFIG config_identifier ';' 
    design_statement KW_ENDCONFIG {
790
    }
饶先宏's avatar
饶先宏 已提交
791 792
|   KW_CONFIG config_identifier ';' 
    design_statement config_rule_statement KW_ENDCONFIG {
793 794
    }
 ;
饶先宏's avatar
饶先宏 已提交
795

796 797 798
design_statement : 
    KW_DESIGN design_cell_list ';' {
    }
799
;
饶先宏's avatar
饶先宏 已提交
800

801
design_cell_list :
802
   %empty   {
饶先宏's avatar
饶先宏 已提交
803
  }
804 805 806 807 808 809 810 811
|  design_cell_list design_cell {
  } 
|  design_cell {
 }
 ;
 
design_cell :
  cell_identifier {
饶先宏's avatar
饶先宏 已提交
812
  }
813
| library_identifier '.' cell_identifier {
饶先宏's avatar
饶先宏 已提交
814
  }
815
  ;
饶先宏's avatar
饶先宏 已提交
816

817 818 819 820 821 822 823 824 825 826 827 828 829 830
config_rule_statement :
    default_clause liblist_clause ';' {
    }
|   inst_clause liblist_clause ';' {
    }
|   inst_clause use_clause ';' {
    }
|   cell_clause liblist_clause ';' {
    }
|   cell_clause use_clause ';' {
    }
 ;

default_clause :
饶先宏's avatar
饶先宏 已提交
831
  KW_DEFAULT {
饶先宏's avatar
饶先宏 已提交
832
  }
833 834 835
  ;

inst_clause :
饶先宏's avatar
饶先宏 已提交
836
    KW_INSTANCE inst_name {
837 838 839 840
    }
  ;

inst_name :
饶先宏's avatar
饶先宏 已提交
841 842 843 844
    topmodule_identifier {
    }
|   inst_name '.' instance_identifier {
    }
845
  ;
饶先宏's avatar
饶先宏 已提交
846

847
cell_clause : 
饶先宏's avatar
饶先宏 已提交
848
    KW_CELL cell_identifier {
849
    }
饶先宏's avatar
饶先宏 已提交
850
|   KW_CELL library_identifier '.' cell_identifier {
851 852
    }
 ;
饶先宏's avatar
饶先宏 已提交
853

854
liblist_clause :
饶先宏's avatar
饶先宏 已提交
855
    KW_LIBLIST {
856
    }
饶先宏's avatar
饶先宏 已提交
857
|   KW_LIBLIST library_identifier {
858 859
    }
 ;
饶先宏's avatar
饶先宏 已提交
860

861
use_clause :
饶先宏's avatar
饶先宏 已提交
862
    KW_USE cell_identifier {
863
    }
饶先宏's avatar
饶先宏 已提交
864
|   KW_USE cell_identifier ':' KW_CONFIG {
865
    }
饶先宏's avatar
饶先宏 已提交
866
|   KW_USE library_identifier '.' cell_identifier {
867
    }
饶先宏's avatar
饶先宏 已提交
868
|   KW_USE library_identifier '.' cell_identifier ':' KW_CONFIG {
869 870
    }
  ;
饶先宏's avatar
饶先宏 已提交
871

872 873 874 875 876
/*
A.2 Declarations
A.2.1 Declaration types
A.2.1.1 Module parameter declarations
*/
饶先宏's avatar
饶先宏 已提交
877

878
signed_option: 
879
   %empty  {
饶先宏's avatar
饶先宏 已提交
880
   $$ = 0;
881 882
 }
| KW_SIGNED {
饶先宏's avatar
饶先宏 已提交
883
   $$ = 1;
884
}
饶先宏's avatar
饶先宏 已提交
885 886
;

887
range_option: 
888
   %empty  {
饶先宏's avatar
饶先宏 已提交
889
  $$.type = RANGE_TYPE_NONE;
饶先宏's avatar
饶先宏 已提交
890 891
  $$.obj[0] = NULL;
  $$.obj[1] = NULL;
892 893
 }
| range {
饶先宏's avatar
饶先宏 已提交
894
 $$ = $1;
895
}
饶先宏's avatar
饶先宏 已提交
896 897
;

898
local_parameter_declaration :
饶先宏's avatar
饶先宏 已提交
899
    KW_LOCALPARAM signed_option range_option list_of_param_assignments {
900
    }
饶先宏's avatar
饶先宏 已提交
901
|   KW_LOCALPARAM parameter_type list_of_param_assignments{
902 903
    }
 ;
饶先宏's avatar
饶先宏 已提交
904

饶先宏's avatar
饶先宏 已提交
905 906
/*
  因不满足LALR(1)而修改。
907
parameter_declaration :
饶先宏's avatar
饶先宏 已提交
908
    KW_PARAMETER signed_option range_option list_of_param_assignments {
909
    }
饶先宏's avatar
饶先宏 已提交
910
|   KW_PARAMETER parameter_type list_of_param_assignments {
饶先宏's avatar
饶先宏 已提交
911 912 913 914 915 916 917
    }
;
*/

parameter_declaration :
    KW_PARAMETER signed_option range_option param_assignment {
        $$ = verilogparseCreateParameter(PARAM_TYPE_PARAM, PARAM_DATA_TYPE_INTEGER, 
饶先宏's avatar
饶先宏 已提交
918 919
                $2, 
                $3.type, $3.obj[0], $3.obj[1], 
饶先宏's avatar
饶先宏 已提交
920
                $4.key, $4.obj);
饶先宏's avatar
饶先宏 已提交
921
        lastparameter = $$;
饶先宏's avatar
饶先宏 已提交
922 923 924
    }
|   KW_PARAMETER parameter_type param_assignment {
        $$ = verilogparseCreateParameter(PARAM_TYPE_PARAM, $2, 
饶先宏's avatar
饶先宏 已提交
925 926
                0, 
                RANGE_TYPE_NONE, NULL, NULL, 
饶先宏's avatar
饶先宏 已提交
927
                $3.key, $3.obj);
饶先宏's avatar
饶先宏 已提交
928
        lastparameter = $$;
饶先宏's avatar
饶先宏 已提交
929 930 931
    }
|   param_assignment {
        $$ = verilogparseCreateParameter(PARAM_TYPE_ASPRE, 0, 
饶先宏's avatar
饶先宏 已提交
932
                0, 
饶先宏's avatar
饶先宏 已提交
933
                RANGE_TYPE_NONE, lastparameter, NULL, 
饶先宏's avatar
饶先宏 已提交
934
                $1.key, $1.obj);
935
    }
饶先宏's avatar
饶先宏 已提交
936 937
;

饶先宏's avatar
饶先宏 已提交
938

939
specparam_declaration : 
饶先宏's avatar
饶先宏 已提交
940
    KW_SPECPARAM range_option list_of_specparam_assignments ';' {
941 942
    }
   ;
饶先宏's avatar
饶先宏 已提交
943

944
parameter_type :
饶先宏's avatar
饶先宏 已提交
945
    KW_INTEGER {
饶先宏's avatar
饶先宏 已提交
946
    $$ = PARAM_DATA_TYPE_INTEGER;
947
    }
饶先宏's avatar
饶先宏 已提交
948
|   KW_REAL {
饶先宏's avatar
饶先宏 已提交
949
    $$ = PARAM_DATA_TYPE_REAL;
950
    } 
饶先宏's avatar
饶先宏 已提交
951
|   KW_REALTIME {
饶先宏's avatar
饶先宏 已提交
952
    $$ = PARAM_DATA_TYPE_REALTIME;
953
    }
饶先宏's avatar
饶先宏 已提交
954
|   KW_TIME {
饶先宏's avatar
饶先宏 已提交
955
    $$ = PARAM_DATA_TYPE_TIME;
956 957
    }
 ;
饶先宏's avatar
饶先宏 已提交
958

959 960 961
/*
A.2.1.2 Port declarations
*/
饶先宏's avatar
饶先宏 已提交
962

963
net_type_option :
964
   %empty   {
饶先宏's avatar
饶先宏 已提交
965
   $$ = VAR_TYPE_NONE;
饶先宏's avatar
饶先宏 已提交
966
  }
967
| net_type {
饶先宏's avatar
饶先宏 已提交
968
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
969 970 971
  }
;

972
/*
973
inout_declaration :
饶先宏's avatar
饶先宏 已提交
974
    KW_INOUT net_type_option signed_option range_option 
975 976 977
    list_of_port_identifiers {
    }
  ;
饶先宏's avatar
饶先宏 已提交
978

979
input_declaration :
饶先宏's avatar
饶先宏 已提交
980
    KW_INPUT net_type_option signed_option range_option 
981 982 983
    list_of_port_identifiers {
    }
  ;
饶先宏's avatar
饶先宏 已提交
984

985
output_declaration :
饶先宏's avatar
饶先宏 已提交
986
    KW_OUTPUT net_type_option signed_option range_option 
987 988
    list_of_port_identifiers {
    }
饶先宏's avatar
饶先宏 已提交
989
|   KW_OUTPUT KW_REG signed_option range_option
990 991
    list_of_variable_port_identifiers {
    }
饶先宏's avatar
饶先宏 已提交
992
|   KW_OUTPUT output_variable_type 
993 994 995
    list_of_variable_port_identifiers {
    }
  ;
996 997
*/

饶先宏's avatar
饶先宏 已提交
998

999 1000 1001 1002
/*
A.2.1.3 Type declarations
*/
event_declaration :
饶先宏's avatar
饶先宏 已提交
1003
    KW_EVENT list_of_event_identifiers ';' {
1004 1005
    }
 ;
饶先宏's avatar
饶先宏 已提交
1006

饶先宏's avatar
饶先宏 已提交
1007
integer_declaration : KW_INTEGER list_of_variable_identifiers ';' {
1008 1009 1010
    }
  ;
delay3_option: 
1011
    %empty {
1012 1013
    }
|   delay3 {
饶先宏's avatar
饶先宏 已提交
1014

1015 1016
    }
  ;
饶先宏's avatar
饶先宏 已提交
1017

1018
drive_strength_option :
1019
    %empty    {
1020 1021 1022 1023
    }
|   drive_strength {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1024

1025
vectored_option :
1026
    %empty    {
饶先宏's avatar
饶先宏 已提交
1027
    $$ = VS_NONE;
1028
    }
饶先宏's avatar
饶先宏 已提交
1029
|   KW_VECTORED {
饶先宏's avatar
饶先宏 已提交
1030
    $$ = VS_VECTORED;
1031 1032
    }
  ;
饶先宏's avatar
饶先宏 已提交
1033

1034
scalared_option :
1035
   %empty     {
饶先宏's avatar
饶先宏 已提交
1036
   $$ = VS_NONE;
1037
    }
饶先宏's avatar
饶先宏 已提交
1038
|   KW_SCALARED {
饶先宏's avatar
饶先宏 已提交
1039
    $$ = VS_SCALARED;
1040 1041
    }
 ;
饶先宏's avatar
饶先宏 已提交
1042

1043
charge_strength_option :
1044
    %empty    {
1045 1046 1047
    }
|   charge_strength {
    }
饶先宏's avatar
饶先宏 已提交
1048 1049
 ;

1050
vectored_or_scalared_option : 
1051
    %empty    {
饶先宏's avatar
饶先宏 已提交
1052
    $$ = VS_NONE;
1053
    } 
饶先宏's avatar
饶先宏 已提交
1054
|   KW_VECTORED {
饶先宏's avatar
饶先宏 已提交
1055
    $$ = VS_VECTORED;
1056
    }
饶先宏's avatar
饶先宏 已提交
1057
|   KW_SCALARED {
饶先宏's avatar
饶先宏 已提交
1058
    $$ = VS_SCALARED;
1059 1060
    }
 ;
饶先宏's avatar
饶先宏 已提交
1061

饶先宏's avatar
饶先宏 已提交
1062 1063 1064 1065 1066 1067 1068 1069 1070
list_of_net :
    list_of_net_identifiers {
        $$ = $1;
    }
|   list_of_net_decl_assignments {
        $$ = $1;
    }
  ;

1071
net_declaration :
饶先宏's avatar
饶先宏 已提交
1072
/*    attribute_instance_list net_type signed_option
1073 1074
    delay3_option list_of_net_identifiers ';' {
    }
饶先宏's avatar
饶先宏 已提交
1075
|   attribute_instance_list net_type drive_strength_option signed_option
1076 1077
    delay3_option list_of_net_decl_assignments ';' {
    }
饶先宏's avatar
饶先宏 已提交
1078 1079
|*/
    attribute_instance_list net_type drive_strength_option vectored_or_scalared_option signed_option
饶先宏's avatar
饶先宏 已提交
1080
    range_option delay3_option list_of_net ';' {
饶先宏's avatar
饶先宏 已提交
1081 1082 1083 1084
        if (currentmodule == NULL) {
            yyerror("no current module");
        } else {
            IDListVar* list;
饶先宏's avatar
饶先宏 已提交
1085
            IDListVarPtr pitem, pitemtemp;
饶先宏's avatar
饶先宏 已提交
1086
            list = dlistCreate();
饶先宏's avatar
饶先宏 已提交
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
	        pitem = $8->__dlist_pNext; 
	        while (!IsDListHeader(pitem)) {
		        pitemtemp = pitem->__dlist_pNext;
                dlistDetach(pitem);               
                verilogparseVarDeclSetOptions(pitem, 
                    $2,  //int type,
                    $1,  //IDListVar* attributes,
                    $4,  //int vectored_or_scalared,
                    $5, //int issigned,
                    $6.type, //int range_type,
                    $6.obj[0], //HOBJECT range_msb,
饶先宏's avatar
饶先宏 已提交
1098
                    $6.obj[1] //HOBJECT range_lsb
饶先宏's avatar
饶先宏 已提交
1099 1100 1101 1102 1103
                    );
                dlistAppendItem(list, pitem);
		        pitem = pitemtemp;
	        }
            objectRelease($8);
饶先宏's avatar
饶先宏 已提交
1104 1105
            verilogparseAddModuleItems(currentmodule, list, MODULE_ITEM_TYPE_NET_DECLARATION);
        }
1106
    }
饶先宏's avatar
饶先宏 已提交
1107 1108
/*
|   attribute_instance_list net_type scalared_option signed_option
1109 1110
    range delay3_option list_of_net_identifiers ';' {
    }
饶先宏's avatar
饶先宏 已提交
1111 1112

|   attribute_instance_list net_type drive_strength_option vectored_option 
1113 1114 1115
    scalared_option signed_option
    range delay3_option list_of_net_decl_assignments ';' {
    }
饶先宏's avatar
饶先宏 已提交
1116 1117
*/
|   attribute_instance_list KW_TRIREG charge_strength_option signed_option
1118
    delay3_option list_of_net_identifiers ';'
饶先宏's avatar
饶先宏 已提交
1119
|   attribute_instance_list KW_TRIREG drive_strength_option signed_option
1120 1121
    delay3_option list_of_net_decl_assignments ';' {
    }
饶先宏's avatar
饶先宏 已提交
1122
|   attribute_instance_list KW_TRIREG charge_strength_option vectored_or_scalared_option signed_option
1123 1124
    range delay3_option list_of_net_identifiers ';' {
    }
饶先宏's avatar
饶先宏 已提交
1125
|   attribute_instance_list KW_TRIREG drive_strength_option vectored_or_scalared_option signed_option
1126 1127 1128
    range delay3_option list_of_net_decl_assignments ';' {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1129

1130
real_declaration :
饶先宏's avatar
饶先宏 已提交
1131
    KW_REAL list_of_real_identifiers ';' {
1132 1133
    }
  ;
饶先宏's avatar
饶先宏 已提交
1134

1135
realtime_declaration : 
饶先宏's avatar
饶先宏 已提交
1136
    KW_REALTIME list_of_real_identifiers ';' {
1137 1138
    }
  ;
饶先宏's avatar
饶先宏 已提交
1139

1140
reg_declaration :
饶先宏's avatar
饶先宏 已提交
1141
    KW_REG signed_option range_option
1142 1143 1144
    list_of_variable_identifiers ';' {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1145

1146
time_declaration : 
饶先宏's avatar
饶先宏 已提交
1147
    KW_TIME list_of_variable_identifiers ';' {
1148 1149
    }
  ;
饶先宏's avatar
饶先宏 已提交
1150

1151 1152 1153 1154 1155
/*
A.2.2 Declaration data types
A.2.2.1 Net and variable types
*/
net_type :
饶先宏's avatar
饶先宏 已提交
1156
    KW_SUPPLY0 {
饶先宏's avatar
饶先宏 已提交
1157
    $$ = VAR_TYPE_SUPPLY0;
1158
    }
饶先宏's avatar
饶先宏 已提交
1159
|   KW_SUPPLY1 {
饶先宏's avatar
饶先宏 已提交
1160
    $$ = VAR_TYPE_SUPPLY1;
1161
    }
饶先宏's avatar
饶先宏 已提交
1162
|   KW_TRI {
饶先宏's avatar
饶先宏 已提交
1163
    $$ = VAR_TYPE_TRI;
1164
    } 
饶先宏's avatar
饶先宏 已提交
1165
|   KW_TRIAND  {
饶先宏's avatar
饶先宏 已提交
1166
    $$ = VAR_TYPE_TRIAND;
1167
    }
饶先宏's avatar
饶先宏 已提交
1168
|   KW_TRIOR  {
饶先宏's avatar
饶先宏 已提交
1169
    $$ = VAR_TYPE_TRIOR;
1170
    }
饶先宏's avatar
饶先宏 已提交
1171
|   KW_TRI0  {
饶先宏's avatar
饶先宏 已提交
1172
    $$ = VAR_TYPE_TRI0;
1173
    }
饶先宏's avatar
饶先宏 已提交
1174
|   KW_TRI1 {
饶先宏's avatar
饶先宏 已提交
1175
    $$ = VAR_TYPE_TRI1;
1176
    }
饶先宏's avatar
饶先宏 已提交
1177
|   KW_UWIRE  {
饶先宏's avatar
饶先宏 已提交
1178
    $$ = VAR_TYPE_UWIRE;
1179
    }
饶先宏's avatar
饶先宏 已提交
1180
|   KW_WIRE  {
饶先宏's avatar
饶先宏 已提交
1181
    $$ = VAR_TYPE_WIRE;
1182
    }
饶先宏's avatar
饶先宏 已提交
1183
|   KW_WAND  {
饶先宏's avatar
饶先宏 已提交
1184
    $$ = VAR_TYPE_WAND;
1185
    }
饶先宏's avatar
饶先宏 已提交
1186
|   KW_WOR {
饶先宏's avatar
饶先宏 已提交
1187
    $$ = VAR_TYPE_WOR;
1188 1189
    }
  ;
饶先宏's avatar
饶先宏 已提交
1190

1191
output_variable_type : 
饶先宏's avatar
饶先宏 已提交
1192
    KW_INTEGER  {
饶先宏's avatar
饶先宏 已提交
1193
    $$ = VAR_TYPE_INTEGER;
1194
    }
饶先宏's avatar
饶先宏 已提交
1195
|   KW_TIME {
饶先宏's avatar
饶先宏 已提交
1196
    $$ = VAR_TYPE_TIME;
1197 1198
    }
 ;
饶先宏's avatar
饶先宏 已提交
1199

1200
dimension_list :
1201
     %empty   {
饶先宏's avatar
饶先宏 已提交
1202
     $$ = dlistCreate();
1203 1204
    }
| dimension_list dimension {
饶先宏's avatar
饶先宏 已提交
1205 1206 1207
     $$ = $1;
     dlistAppendItem($$, $2.obj[0]);
     dlistAppendItem($$, $2.obj[1]);
1208 1209
    }
| dimension {
饶先宏's avatar
饶先宏 已提交
1210 1211 1212
     $$ = dlistCreate();
     dlistAppendItem($$, $1.obj[0]);
     dlistAppendItem($$, $1.obj[1]);
饶先宏's avatar
饶先宏 已提交
1213 1214 1215
}
;

1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
real_type :
    real_identifier dimension_list {
    }
|   real_identifier '=' constant_expression {
    }
 ;
variable_type :
    variable_identifier dimension_list {
    }
|   variable_identifier '=' constant_expression {
    }
 ;
 
/*
A.2.2.2 Strengths 
*/
饶先宏's avatar
饶先宏 已提交
1232

1233 1234 1235 1236 1237
drive_strength :
    '(' strength0 ',' strength1 ')' {
    }
|   '(' strength1 ',' strength0 ')' {
    }
饶先宏's avatar
饶先宏 已提交
1238
|   '(' strength0 ',' KW_HIGHZ1 ')' {
1239
    }
饶先宏's avatar
饶先宏 已提交
1240
|   '(' strength1 ',' KW_HIGHZ0 ')' {
1241
    }
饶先宏's avatar
饶先宏 已提交
1242
|   '(' KW_HIGHZ0 ',' strength1 ')' {
1243
    }
饶先宏's avatar
饶先宏 已提交
1244
|   '(' KW_HIGHZ1 ',' strength0 ')' {
1245 1246 1247
    }
  ;
strength0 : 
饶先宏's avatar
饶先宏 已提交
1248
    KW_SUPPLY0  {
1249
    }
饶先宏's avatar
饶先宏 已提交
1250
|   KW_STRONG0  {
1251
    }
饶先宏's avatar
饶先宏 已提交
1252
|   KW_PULL0  {
1253
    }
饶先宏's avatar
饶先宏 已提交
1254
|   KW_WEAK0 {
1255 1256
    }
 ;
饶先宏's avatar
饶先宏 已提交
1257

1258
strength1 : 
饶先宏's avatar
饶先宏 已提交
1259
    KW_SUPPLY1  {
1260
    }
饶先宏's avatar
饶先宏 已提交
1261
|   KW_STRONG1  {
1262
    }
饶先宏's avatar
饶先宏 已提交
1263
|   KW_PULL1  {
1264
    }
饶先宏's avatar
饶先宏 已提交
1265
|   KW_WEAK1 {
1266 1267
    }
  ;
饶先宏's avatar
饶先宏 已提交
1268

1269
charge_strength : 
饶先宏's avatar
饶先宏 已提交
1270
    '(' KW_SMALL ')' {
1271
    } 
饶先宏's avatar
饶先宏 已提交
1272
|   '(' KW_MEDIUM ')'  {
1273
    }
饶先宏's avatar
饶先宏 已提交
1274
|   '(' KW_LARGE ')' {
1275 1276
    }
 ;
饶先宏's avatar
饶先宏 已提交
1277

1278 1279 1280
/*
A.2.2.3 Delays
*/
饶先宏's avatar
饶先宏 已提交
1281

1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
delay3 :
    '#' delay_value {
    }
|   '#' '(' mintypmax_expression ')' {
    }
|   '#' '(' mintypmax_expression ',' mintypmax_expression ')' {
    }
|   '#' '(' mintypmax_expression ',' mintypmax_expression ',' mintypmax_expression ')' {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1292

1293
delay2 :
饶先宏's avatar
饶先宏 已提交
1294 1295
    '#' delay_value {
    }
1296 1297 1298 1299 1300
|   '#' '(' mintypmax_expression ')' {
    }
|   '#' '(' mintypmax_expression ',' mintypmax_expression ')' {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1301

1302 1303 1304
delay_value :
    unsigned_number {
    }
饶先宏's avatar
饶先宏 已提交
1305
|   NUM_REAL {
1306 1307 1308
    }
|   identifier {
    }
饶先宏's avatar
饶先宏 已提交
1309 1310
 ;

1311 1312 1313 1314 1315 1316 1317 1318 1319
/*
A.2.3 Declaration lists
*/
list_of_defparam_assignments :
    defparam_assignment {
    }
|   list_of_defparam_assignments  ',' defparam_assignment {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1320

1321 1322 1323 1324 1325 1326
list_of_dimensions:
    dimension {
    }
|   list_of_dimensions  ',' dimension {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1327

1328 1329 1330 1331 1332 1333
list_of_event_identifiers : 
    event_identifier list_of_dimensions {
    }
|   list_of_event_identifiers ',' event_identifier list_of_dimensions {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1334

1335 1336
list_of_net_decl_assignments :
    net_decl_assignment {
饶先宏's avatar
饶先宏 已提交
1337 1338
    HOBJECT vardecl;
    vardecl = verilogparseCreateVarDecl($1.key);
饶先宏's avatar
饶先宏 已提交
1339
    objectRelease($1.key);
饶先宏's avatar
饶先宏 已提交
1340 1341 1342 1343
    verilogparseVarDeclSetAssignExpr(vardecl, $1.obj);
    objectRelease($1.obj);
    $$ = dlistCreate();
    dlistAppendItem($$, vardecl);
1344 1345
    }
|   list_of_net_decl_assignments  ',' net_decl_assignment {
饶先宏's avatar
饶先宏 已提交
1346 1347
    HOBJECT vardecl;
    vardecl = verilogparseCreateVarDecl($3.key);
饶先宏's avatar
饶先宏 已提交
1348
    objectRelease($3.key);
饶先宏's avatar
饶先宏 已提交
1349 1350 1351 1352
    verilogparseVarDeclSetAssignExpr(vardecl, $3.obj);
    objectRelease($3.obj);
    $$ = $1;
    dlistAppendItem($$, vardecl);
1353
    }
饶先宏's avatar
饶先宏 已提交
1354
 ;
饶先宏's avatar
饶先宏 已提交
1355 1356 1357

list_of_net_identifiers : 
    net_identifier dimension_list {
饶先宏's avatar
饶先宏 已提交
1358 1359 1360 1361
    HOBJECT vardecl;
    $$ = dlistCreate();
    dlistAppendItem($$, vardecl = verilogparseCreateVarDecl($1));
    verilogparseVarDeclSetDimensions(vardecl, $2);
饶先宏's avatar
饶先宏 已提交
1362
    objectRelease($1);
饶先宏's avatar
饶先宏 已提交
1363 1364
    }
|   list_of_net_identifiers  ',' net_identifier dimension_list {
饶先宏's avatar
饶先宏 已提交
1365 1366 1367 1368 1369
    HOBJECT vardecl;
    $$ = $1;
    dlistAppendItem($$, vardecl = verilogparseCreateVarDecl($3));
    verilogparseVarDeclSetDimensions(vardecl, $4);
    objectRelease($4);
饶先宏's avatar
饶先宏 已提交
1370
    objectRelease($3);
饶先宏's avatar
饶先宏 已提交
1371 1372 1373
    }
  ;

1374 1375 1376 1377 1378 1379
list_of_event_identifiers : 
    net_identifier list_of_dimensions {
    }
|   list_of_event_identifiers ',' net_identifier list_of_dimensions {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1380

1381 1382
list_of_param_assignments :
    param_assignment {
饶先宏's avatar
饶先宏 已提交
1383
    $$ = NULL;
1384 1385
    }
|   list_of_param_assignments  ',' param_assignment {
饶先宏's avatar
饶先宏 已提交
1386
    $$ = NULL;
1387 1388 1389
    }
 ;
 
1390
 
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404
list_of_port_identifiers :
    port_identifier {
    }
|   list_of_port_identifiers  ',' port_identifier {
    }
 ;
 
list_of_real_identifiers :
    real_type {
    }
|   list_of_real_identifiers  ',' real_type {
    }
 ;
 
饶先宏's avatar
饶先宏 已提交
1405

1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421
list_of_specparam_assignments :
    specparam_assignment {
    }
|   list_of_specparam_assignments  ',' specparam_assignment {
    }
 ;
 
list_of_variable_identifiers :
    variable_type {
    }
|   list_of_variable_identifiers  ',' variable_type {
    }
 ;
 
port_ident :
    port_identifier {
饶先宏's avatar
饶先宏 已提交
1422 1423
    $$.key = $1;
    $$.obj = NULL;
1424 1425
    }
|   port_identifier '=' constant_expression {
饶先宏's avatar
饶先宏 已提交
1426 1427
    $$.key = $1;
    $$.obj = $3;
1428 1429
    }
 ;
饶先宏's avatar
饶先宏 已提交
1430

1431 1432 1433 1434 1435 1436
list_of_variable_port_identifiers :
    port_ident {
    }
|   list_of_variable_port_identifiers  ',' port_ident {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1437

1438 1439 1440
/*
A.2.4 Declaration assignments
*/
饶先宏's avatar
饶先宏 已提交
1441

1442 1443 1444 1445
defparam_assignment : 
    hierarchical_parameter_identifier '=' constant_mintypmax_expression {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1446

1447 1448
net_decl_assignment : 
    net_identifier '=' expression {
饶先宏's avatar
饶先宏 已提交
1449 1450
    $$.key = $1;
    $$.obj = $3;
1451
    }
饶先宏's avatar
饶先宏 已提交
1452
|   net_identifier {
饶先宏's avatar
饶先宏 已提交
1453 1454
    $$.key = $1;
    $$.obj = NULL;
饶先宏's avatar
饶先宏 已提交
1455
    }
1456
  ;
饶先宏's avatar
饶先宏 已提交
1457

1458 1459
param_assignment : 
    parameter_identifier '=' constant_mintypmax_expression {
饶先宏's avatar
饶先宏 已提交
1460 1461
    $$.key = $1;
    $$.obj = $3;
1462 1463
    }
  ;
饶先宏's avatar
饶先宏 已提交
1464

1465 1466 1467 1468 1469
specparam_assignment :
    specparam_identifier '=' constant_mintypmax_expression {
    }
|    pulse_control_specparam {
    }
饶先宏's avatar
饶先宏 已提交
1470 1471
 ;

饶先宏's avatar
饶先宏 已提交
1472 1473 1474 1475 1476 1477 1478 1479
/* 
    PATHPULSE$specify_input_terminal_descriptor$specify_output_terminal_descriptor 
    must be:
    1.PATHPULSE$identinput$identoutput
    1.PATHPULSE$identinput$identoutput '[' constant_range_expression ']'
    1.PATHPULSE$identinput '[' constant_range_expression ']' $identoutput
    1.PATHPULSE$identinput '[' constant_range_expression ']' $identoutput '[' constant_range_expression ']'
*/
饶先宏's avatar
饶先宏 已提交
1480

饶先宏's avatar
饶先宏 已提交
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
pulse_control_specparam_lvalue :
    SIMPLE_ID /* PATHPULSE$identinput$identoutput */ {
    }
|   SIMPLE_ID /* PATHPULSE$identinput$identoutput  '[' constant_range_expression ']' */
    '[' constant_range_expression ']'  {
    }
|   SIMPLE_ID /* PATHPULSE$identinput '[' constant_range_expression ']' $identoutput*/
    '[' constant_range_expression ']' 
    SYSTEM_ID {
    }
|   SIMPLE_ID /* PATHPULSE$identinput '[' constant_range_expression ']'  $identoutput '[' constant_range_expression ']'*/
    '[' constant_range_expression ']' 
    SYSTEM_ID
    '[' constant_range_expression ']' {
    }
  ;
    
pulse_control_specparam : 
    KW_PATHPULSE '=' '(' reject_limit_value ')' {
1500
    }
饶先宏's avatar
饶先宏 已提交
1501
|   KW_PATHPULSE '=' '(' reject_limit_value ',' error_limit_value ')' {
1502
    }
饶先宏's avatar
饶先宏 已提交
1503
|   pulse_control_specparam_lvalue
1504 1505
    '=' '(' reject_limit_value ')' {
    }
饶先宏's avatar
饶先宏 已提交
1506 1507
|   pulse_control_specparam_lvalue
     '=' '(' reject_limit_value ',' error_limit_value ')' {
1508
    }
饶先宏's avatar
饶先宏 已提交
1509 1510
  ;

饶先宏's avatar
饶先宏 已提交
1511

1512 1513 1514 1515
error_limit_value : 
    limit_value {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1516

1517 1518 1519 1520
reject_limit_value : 
    limit_value {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1521

1522 1523 1524 1525
limit_value : 
    constant_mintypmax_expression {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1526

1527 1528 1529 1530 1531
/*
A.2.5 Declaration ranges
*/
dimension : 
    '[' dimension_constant_expression ':' dimension_constant_expression ']' {
饶先宏's avatar
饶先宏 已提交
1532 1533
        $$.obj[0] = $2;
        $$.obj[1] = $4;
1534 1535
    }
 ;
饶先宏's avatar
饶先宏 已提交
1536

1537
range : '[' msb_constant_expression ':' lsb_constant_expression ']' {
饶先宏's avatar
饶先宏 已提交
1538
      $$.type = RANGE_TYPE_PARTSELECT;
1539 1540
      $$.obj[0] = $2;
      $$.obj[1] = $4;
1541 1542
    }
  ;
饶先宏's avatar
饶先宏 已提交
1543

1544 1545 1546 1547
/*
A.2.6 Function declarations
*/
automatic_option :
1548
     %empty   {
1549
    }
饶先宏's avatar
饶先宏 已提交
1550
|   KW_AUTOMATIC { 
1551 1552
    }
  ;
饶先宏's avatar
饶先宏 已提交
1553

1554
function_range_or_type_option:
1555
     %empty   {
1556 1557 1558 1559
    }
|   function_range_or_type {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1560

1561 1562 1563 1564 1565 1566
function_item_declaration_list:
    function_item_declaration {
    }
|   function_item_declaration_list function_item_declaration {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1567

1568
block_item_declaration_list:
1569
    %empty    {
1570 1571 1572 1573 1574 1575
    }
|   block_item_declaration {
    }
|   block_item_declaration_list block_item_declaration {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1576

饶先宏's avatar
饶先宏 已提交
1577
function_range_or_type_option :
1578
     %empty   {
饶先宏's avatar
饶先宏 已提交
1579 1580 1581 1582 1583
    }
|   function_range_or_type {
    }
  ;

1584
function_declaration :
饶先宏's avatar
饶先宏 已提交
1585
    KW_FUNCTION automatic_option function_range_or_type_option function_identifier ';'
1586 1587
    function_item_declaration_list
    function_statement
饶先宏's avatar
饶先宏 已提交
1588
    KW_ENDFUNCTION {
1589
    }
饶先宏's avatar
饶先宏 已提交
1590
|   KW_FUNCTION automatic_option function_range_or_type_option function_identifier '(' function_port_list ')' ';'
1591 1592
    block_item_declaration_list   
    function_statement
饶先宏's avatar
饶先宏 已提交
1593
    KW_ENDFUNCTION {
1594 1595
    }
 ;
饶先宏's avatar
饶先宏 已提交
1596

1597 1598
function_item_declaration :
    block_item_declaration
饶先宏's avatar
饶先宏 已提交
1599
|   attribute_instance_list tf_input_declaration ';' {
1600 1601
    }
 ;
饶先宏's avatar
饶先宏 已提交
1602

1603 1604 1605 1606 1607 1608
function_port_list :
    attribute_instance_list tf_input_declaration {
    }
|   function_port_list attribute_instance_list tf_input_declaration {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1609

1610 1611 1612
function_range_or_type :
    signed_option range_option {
    }
饶先宏's avatar
饶先宏 已提交
1613
|   KW_INTEGER {
1614
    }
饶先宏's avatar
饶先宏 已提交
1615
|   KW_REAL {
1616
    }
饶先宏's avatar
饶先宏 已提交
1617
|   KW_REALTIME {
1618
    }
饶先宏's avatar
饶先宏 已提交
1619
| KW_TIME {
1620 1621
    }
  ;
饶先宏's avatar
饶先宏 已提交
1622

1623 1624 1625 1626
/*
A.2.7 Task declarations
*/
task_item_declaration_list :
1627
     %empty   {
1628 1629 1630 1631 1632 1633
    }
|   task_item_declaration_list task_item_declaration {
    }
|   task_item_declaration {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1634

1635
task_port_list_option:
1636
     %empty   {
1637 1638 1639 1640
    }
|   task_port_list {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1641

1642
task_declaration :
饶先宏's avatar
饶先宏 已提交
1643
    KW_TASK automatic_option task_identifier ';'
1644 1645
    task_item_declaration_list
    statement_or_null
饶先宏's avatar
饶先宏 已提交
1646
    KW_ENDTASK {
1647
    }
饶先宏's avatar
饶先宏 已提交
1648
|   KW_TASK automatic_option task_identifier '(' task_port_list_option ')' ';'
1649 1650
    block_item_declaration_list
    statement_or_null
饶先宏's avatar
饶先宏 已提交
1651
    KW_ENDTASK {
1652 1653
    }
 ;
饶先宏's avatar
饶先宏 已提交
1654

1655 1656 1657 1658 1659 1660 1661 1662 1663 1664
task_item_declaration :
    block_item_declaration {
    }
|   attribute_instance_list tf_input_declaration ';' {
    }
|   attribute_instance_list tf_output_declaration ';' {
    }
|   attribute_instance_list tf_inout_declaration ';' {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1665

1666 1667 1668 1669 1670 1671
task_port_list :
    task_port_item {
    }
|   task_port_list ',' task_port_item {
    }
 ;
饶先宏's avatar
饶先宏 已提交
1672

1673 1674 1675 1676 1677 1678 1679 1680
task_port_item :
    attribute_instance_list tf_input_declaration {
    }
|   attribute_instance_list tf_output_declaration {
    }
|   attribute_instance_list tf_inout_declaration {
    }
  ;
饶先宏's avatar
饶先宏 已提交
1681

饶先宏's avatar
饶先宏 已提交
1682
reg_option :
1683
    %empty    {
饶先宏's avatar
饶先宏 已提交
1684 1685 1686 1687 1688
    }
|   KW_REG {
    }
  ;   

1689
tf_input_declaration :
饶先宏's avatar
饶先宏 已提交
1690
    KW_INPUT reg_option signed_option range_option list_of_port_identifiers {
1691
    }
饶先宏's avatar
饶先宏 已提交
1692
|   KW_INPUT task_port_type list_of_port_identifiers {
1693 1694
    }
  ;
饶先宏's avatar
饶先宏 已提交
1695

1696
tf_output_declaration :
饶先宏's avatar
饶先宏 已提交
1697
    KW_OUTPUT reg_option signed_option range_option list_of_port_identifiers {
饶先宏's avatar
饶先宏 已提交
1698
    }
饶先宏's avatar
饶先宏 已提交
1699
|   KW_OUTPUT task_port_type list_of_port_identifiers {
1700 1701
    }
  ;
饶先宏's avatar
饶先宏 已提交
1702

1703
tf_inout_declaration :
饶先宏's avatar
饶先宏 已提交
1704
    KW_INOUT reg_option signed_option range_option list_of_port_identifiers {
1705
    }
饶先宏's avatar
饶先宏 已提交
1706
|   KW_INOUT task_port_type list_of_port_identifiers {
1707 1708
    }
  ;
饶先宏's avatar
饶先宏 已提交
1709

1710
task_port_type :
饶先宏's avatar
饶先宏 已提交
1711
    KW_INTEGER  {
1712
    }
饶先宏's avatar
饶先宏 已提交
1713
|   KW_REAL {
1714
    }
饶先宏's avatar
饶先宏 已提交
1715
|   KW_REALTIME {
1716
    }
饶先宏's avatar
饶先宏 已提交
1717
|   KW_TIME{
1718 1719
    }
  ;
饶先宏's avatar
饶先宏 已提交
1720

1721 1722 1723
/*
A.2.8 Block item declarations
*/
饶先宏's avatar
饶先宏 已提交
1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766
block_item_declaration :
    attribute_instance_list  KW_REG signed_option range_option list_of_block_variable_identifiers ';' {
    }
|   attribute_instance_list  KW_INTEGER list_of_block_variable_identifiers ';' {
    }
|   attribute_instance_list  KW_TIME list_of_block_variable_identifiers ';' {
    }
|   attribute_instance_list  KW_REAL list_of_block_real_identifiers ';' {
    }
|   attribute_instance_list  KW_REALTIME list_of_block_real_identifiers ';' {
    }
|   attribute_instance_list  event_declaration {
    }
|   attribute_instance_list  local_parameter_declaration ';' {
    }
|   attribute_instance_list  parameter_declaration ';' {
    }
  ;

list_of_block_variable_identifiers :
    block_variable_type {
    }
|   list_of_block_variable_identifiers  ',' block_variable_type {
    }
  ;

list_of_block_real_identifiers : 
    block_real_type {
    } 
|   list_of_block_real_identifiers ',' block_real_type {
    }
  ;

block_variable_type : 
    variable_identifier dimension_list {
    }
 ;

block_real_type : 
    real_identifier dimension_list {
    }
  ;

1767 1768 1769 1770
/*
A.3 Primitive instances
A.3.1 Primitive instantiation and instances
*/
饶先宏's avatar
饶先宏 已提交
1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821

cmos_switch_instance_list:
    cmos_switch_instance {
    }
|   cmos_switch_instance_list ',' cmos_switch_instance {
    }
  ;

enable_gate_instance_list:
    enable_gate_instance {
    }
|   enable_gate_instance_list ',' enable_gate_instance {
    }
  ;

mos_switch_instance_list:
    mos_switch_instance {
    }
|   mos_switch_instance_list ',' mos_switch_instance {
    }
  ;

n_input_gate_instance_list:
    n_input_gate_instance {
    }
|   n_input_gate_instance_list ',' n_input_gate_instance {
    }
  ;

n_output_gate_instance_list:
    n_output_gate_instance {
    }
|   n_output_gate_instance_list ',' n_output_gate_instance {
    }
  ;

pass_enable_switch_instance_list:
    pass_enable_switch_instance {
    }
|   pass_enable_switch_instance_list ',' pass_enable_switch_instance {
    }
  ;

pass_switch_instance_list:
    pass_switch_instance {
    }
|   pass_switch_instance_list ',' pass_switch_instance {
    }
  ;

pulldown_strength_option :
1822
     %empty   {
饶先宏's avatar
饶先宏 已提交
1823 1824 1825 1826 1827 1828
    }
|   pulldown_strength {
    }
  ;

pullup_strength_option :
1829
     %empty   {
饶先宏's avatar
饶先宏 已提交
1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842
    }
|   pullup_strength {
    }
  ;

pull_gate_instance_list:
    pull_gate_instance {
    }
|   pull_gate_instance_list ',' pull_gate_instance {
    }
  ;

delay2_option :
1843
     %empty   {
饶先宏's avatar
饶先宏 已提交
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870
    }
|   delay2 {
    }
  ;

gate_instantiation :
    cmos_switchtype delay3_option cmos_switch_instance_list ';' {
    }
|   enable_gatetype drive_strength_option delay3_option enable_gate_instance_list ';' {
    }
|   mos_switchtype delay3_option mos_switch_instance_list ';' {
    }
|   n_input_gatetype drive_strength_option delay2_option n_input_gate_instance_list ';' {
    }
|   n_output_gatetype drive_strength_option delay2_option n_output_gate_instance_list ';' { 
    }
|   pass_en_switchtype delay2_option pass_enable_switch_instance_list ';' {
    }
|   pass_switchtype pass_switch_instance_list ';' {
    }
|   KW_PULLDOWN pulldown_strength_option pull_gate_instance_list ';' {
    }
|   KW_PULLUP pullup_strength_option pull_gate_instance_list ';' {
    }
 ;

name_of_gate_instance_option :
1871
    %empty    {
饶先宏's avatar
饶先宏 已提交
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936
    }
|   name_of_gate_instance {
    }
  ;


input_terminal_list:
    input_terminal {
    }
|   input_terminal_list ',' input_terminal {
    }
  ;

output_terminal_list:
    output_terminal {
    }
|   output_terminal_list ',' output_terminal {
    }
  ;

cmos_switch_instance : 
    name_of_gate_instance_option '(' output_terminal ',' input_terminal ',' ncontrol_terminal ',' pcontrol_terminal ')' {
    }
 ;

enable_gate_instance : 
    name_of_gate_instance_option '(' output_terminal ',' input_terminal ',' enable_terminal ')' {
    }
  ;

mos_switch_instance : 
    name_of_gate_instance_option '(' output_terminal ',' input_terminal ',' enable_terminal ')' {
    }
  ;

n_input_gate_instance : 
    name_of_gate_instance_option '(' output_terminal ',' input_terminal_list ')' {
    }
  ;

n_output_gate_instance : 
    name_of_gate_instance_option '(' output_terminal_list ',' input_terminal ')' {
    }
  ;

pass_switch_instance : 
    name_of_gate_instance_option '(' inout_terminal ',' inout_terminal ')' {
    }
  ;

pass_enable_switch_instance : 
    name_of_gate_instance_option '(' inout_terminal ',' inout_terminal ',' enable_terminal ')' {
    }
  ;

pull_gate_instance : 
    name_of_gate_instance_option '(' output_terminal ')' {
    }
  ;

name_of_gate_instance : 
    gate_instance_identifier range_option {
    }
  ;

1937 1938 1939
/*
A.3.2 Primitive strengths
*/
饶先宏's avatar
饶先宏 已提交
1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958

pulldown_strength :
    '(' strength0 ',' strength1 ')' {
    }
|   '(' strength1 ',' strength0 ')' {
    }
|   '(' strength0 ')' {
    }
  ;

pullup_strength :
    '(' strength0 ',' strength1 ')' {
    }
|   '(' strength1 ',' strength0 ')' {
    }
|   '(' strength1 ')' {
    }
  ;

1959 1960 1961
/*
A.3.3 Primitive terminals
*/
饶先宏's avatar
饶先宏 已提交
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991
enable_terminal : 
    expression {
    }
  ;

inout_terminal : 
    net_lvalue {
    }
  ;

input_terminal : 
    expression {
    }
  ;

ncontrol_terminal : 
    expression {
    }
  ;

output_terminal : 
    net_lvalue {
    }
  ;

pcontrol_terminal : 
    expression {
    }
  ;

1992 1993 1994
/*
A.3.4 Primitive gate and switch types
*/
饶先宏's avatar
饶先宏 已提交
1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062
cmos_switchtype : 
    KW_CMOS  {
    }
|   KW_RCMOS {
    }
  ;
enable_gatetype : 
    KW_BUFIF0  {
    }
|   KW_BUFIF1 {
    }
|   KW_NOTIF0  {
    }
|   KW_NOTIF1 {
    }
  ;

mos_switchtype : 
    KW_NMOS  {
    }
|   KW_PMOS  {
    }
|   KW_RNMOS  {
    }
|   KW_RPMOS {
    }
  ;

n_input_gatetype : 
    KW_AND  {
    }
|   KW_NAND  {
    }
|   KW_OR  {
    }
|   KW_NOR  {
    }
|   KW_XOR  {
    }
|   KW_XNOR {
    }
  ;

n_output_gatetype : 
    KW_BUF {
    } 
|   KW_NOT {
    }
  ;

pass_en_switchtype : 
    KW_TRANIF0 {
    }
|   KW_TRANIF1 {
    }
|   KW_RTRANIF1 {
    }
|   KW_RTRANIF0 {
    }
  ;

pass_switchtype : 
    KW_TRAN  {
    }
|   KW_RTRAN {
    }
  ;

2063 2064 2065 2066
/*
A.4 Module instantiation and generate construct
A.4.1 Module instantiation
*/
饶先宏's avatar
饶先宏 已提交
2067
parameter_value_assignment_option :
2068
     %empty   {
饶先宏's avatar
饶先宏 已提交
2069
     $$ = dlistCreate();
饶先宏's avatar
饶先宏 已提交
2070 2071
    }
| parameter_value_assignment {
饶先宏's avatar
饶先宏 已提交
2072
     $$ = $1;
饶先宏's avatar
饶先宏 已提交
2073 2074 2075 2076 2077
    }
 ;

module_instance_list:
    module_instance {
饶先宏's avatar
饶先宏 已提交
2078 2079
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
2080 2081
    }
|   module_instance_list ',' module_instance {
饶先宏's avatar
饶先宏 已提交
2082 2083
    $$ = $1;
    dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
2084 2085 2086 2087
    }
  ;

module_instantiation :
饶先宏's avatar
饶先宏 已提交
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103
    attribute_instance_list module_identifier parameter_value_assignment_option module_instance_list ';' {
    	IDListVarPtr pitem, pitemtemp;
	    if (dlistItemCount($4) > 0) {
	        pitem = $4->__dlist_pNext; 
	        while (pitem != $4) {
		        pitemtemp = pitem->__dlist_pNext;
                verilogparseSetModuleInstanceOption(
                    pitem, //HOBJECT inst,
                    $1, //IDListVarPtr attributes,
                    $2, //const char * modulename,
                    $3  //IDListVarPtr parameter_value_assignment
                );
		        pitem = pitemtemp;
	        }
            verilogparseAddModuleItems(currentmodule, $4, MODULE_ITEM_TYPE_MODULE_INSTANCE);
        }
饶先宏's avatar
饶先宏 已提交
2104 2105 2106 2107 2108
    }
 ;

parameter_value_assignment : 
    '#' '(' list_of_parameter_assignments ')' {
饶先宏's avatar
饶先宏 已提交
2109
    $$ = $3;
饶先宏's avatar
饶先宏 已提交
2110 2111 2112 2113 2114
    }
  ;

ordered_parameter_assignment_list:
    ordered_parameter_assignment {
饶先宏's avatar
饶先宏 已提交
2115 2116
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
2117 2118
    }
|   ordered_parameter_assignment_list ',' ordered_parameter_assignment {
饶先宏's avatar
饶先宏 已提交
2119 2120
    $$ = $1;
    dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
2121 2122 2123 2124 2125
    }
  ;

named_parameter_assignment_list:
    named_parameter_assignment {
饶先宏's avatar
饶先宏 已提交
2126 2127
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
2128 2129
    }
|   named_parameter_assignment_list ',' named_parameter_assignment {
饶先宏's avatar
饶先宏 已提交
2130 2131
    $$ = $1;
    dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
2132 2133 2134 2135 2136
    }
  ;

list_of_parameter_assignments :
    ordered_parameter_assignment_list {
饶先宏's avatar
饶先宏 已提交
2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149
        int index; 
        IDListVarPtr pitem, pitemtemp;
        $$ = $1;
        index = 0;
	    if ($$ != NULL) {
	        pitem = $$->__dlist_pNext; 
	        while (pitem != $$) {
		        pitemtemp = pitem->__dlist_pNext;
                verilogparseSetParamInstanceIndex(pitem, index);
                index++;
		        pitem = pitemtemp;
	        }
        }
饶先宏's avatar
饶先宏 已提交
2150 2151
    }
|   named_parameter_assignment_list {
饶先宏's avatar
饶先宏 已提交
2152
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
2153 2154 2155 2156 2157
    }
  ;

ordered_parameter_assignment : 
    expression {
饶先宏's avatar
饶先宏 已提交
2158 2159 2160 2161 2162 2163 2164 2165
        $$ = verilogparseCreateParamInstance(
            NULL, //const char* name,
            1, //int exprcount,
            $1, //HOBJECT expr0,
            NULL, //HOBJECT expr1,
            NULL, //HOBJECT expr2,
            NULL //IDListVarPtr attributes
            );
饶先宏's avatar
饶先宏 已提交
2166 2167 2168 2169
    }
  ;

mintypmax_expression_option:
2170
      %empty  {
饶先宏's avatar
饶先宏 已提交
2171
      $$.objcount = 0;
饶先宏's avatar
饶先宏 已提交
2172 2173
    }
|   mintypmax_expression {
饶先宏's avatar
饶先宏 已提交
2174
      $$ = $1;
饶先宏's avatar
饶先宏 已提交
2175 2176 2177 2178 2179
    }
  ;

named_parameter_assignment : 
    '.' parameter_identifier '(' mintypmax_expression_option ')' {
饶先宏's avatar
饶先宏 已提交
2180 2181 2182
        $$ = verilogparseCreateParamInstance(
            $2, //const char* name,
            $4.objcount, //int exprcount,
饶先宏's avatar
饶先宏 已提交
2183
            $4.obj[0], //HOBJECT expr0, /*用mintymax方式传参数,估计只有用在delay中才用得上了*/
饶先宏's avatar
饶先宏 已提交
2184 2185 2186 2187
            $4.obj[1], //HOBJECT expr1,
            $4.obj[2], //HOBJECT expr2,
            NULL //IDListVarPtr attributes
            );
饶先宏's avatar
饶先宏 已提交
2188 2189 2190 2191
    }
  ;

list_of_port_connections_option:
饶先宏's avatar
饶先宏 已提交
2192 2193
    %empty  {
    $$ = dlistCreate();
饶先宏's avatar
饶先宏 已提交
2194 2195
    }
|   list_of_port_connections {
饶先宏's avatar
饶先宏 已提交
2196
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
2197 2198 2199
    }
  ;

饶先宏's avatar
饶先宏 已提交
2200
/*
饶先宏's avatar
饶先宏 已提交
2201 2202 2203 2204
module_instance : 
    name_of_module_instance '(' list_of_port_connections_option ')' {
    }
  ;
饶先宏's avatar
饶先宏 已提交
2205 2206 2207 2208 2209 2210
*/
module_instance : 
    module_instance_identifier range_option '(' list_of_port_connections_option ')' {
    $$ = verilogparseCreateModuleInstance(
            $1, //const char * instname,
            $2.type, // int range_type,
饶先宏's avatar
饶先宏 已提交
2211
            $2.obj[0], //HOBJECT range_msb,这个range很奇怪,不知道如何使用
饶先宏's avatar
饶先宏 已提交
2212 2213 2214 2215 2216
            $2.obj[1], //HOBJECT range_lsb,
            $4 //IDListVarPtr port_connections
        );
    }
  ;
饶先宏's avatar
饶先宏 已提交
2217

饶先宏's avatar
饶先宏 已提交
2218
/*
饶先宏's avatar
饶先宏 已提交
2219 2220 2221 2222
name_of_module_instance : 
    module_instance_identifier range_option {
    }
  ;
饶先宏's avatar
饶先宏 已提交
2223
*/
饶先宏's avatar
饶先宏 已提交
2224 2225 2226

ordered_port_connection_list:
    ordered_port_connection {
饶先宏's avatar
饶先宏 已提交
2227 2228
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
2229 2230
    }
|   ordered_port_connection_list ',' ordered_port_connection {
饶先宏's avatar
饶先宏 已提交
2231 2232
    $$ = $1;
    dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
2233 2234 2235 2236 2237
    }
  ;

named_port_connection_list:
    named_port_connection {
饶先宏's avatar
饶先宏 已提交
2238 2239
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
2240 2241
    }
|   named_port_connection_list ',' named_port_connection {
饶先宏's avatar
饶先宏 已提交
2242 2243
    $$ = $1;
    dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
2244 2245 2246 2247 2248 2249
    }
  ;


list_of_port_connections :
    ordered_port_connection_list {
饶先宏's avatar
饶先宏 已提交
2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262
        int index; 
        IDListVarPtr pitem, pitemtemp;
        $$ = $1;
        index = 0;
	    if ($$ != NULL) {
	        pitem = $$->__dlist_pNext; 
	        while (pitem != $$) {
		        pitemtemp = pitem->__dlist_pNext;
                verilogparseSetParamInstanceIndex(pitem, index);
                index++;
		        pitem = pitemtemp;
	        }
        }
饶先宏's avatar
饶先宏 已提交
2263 2264
    }
|   named_port_connection_list {
饶先宏's avatar
饶先宏 已提交
2265
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
2266 2267 2268 2269
    }
  ;

expression_option:
2270
    %empty    {
饶先宏's avatar
饶先宏 已提交
2271
    $$ = NULL;
饶先宏's avatar
饶先宏 已提交
2272 2273
    }
|   expression {
饶先宏's avatar
饶先宏 已提交
2274
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
2275 2276 2277 2278 2279
    }
  ;

ordered_port_connection : 
    attribute_instance_list expression_option {
饶先宏's avatar
饶先宏 已提交
2280 2281 2282 2283 2284 2285 2286 2287
    $$ = verilogparseCreateParamInstance(
            NULL, //const char* name,
            1, //int exprcount,
            $2, //HOBJECT expr0,
            NULL, //HOBJECT expr1,
            NULL, //HOBJECT expr2,
            $1 //IDListVarPtr attributes
            );
饶先宏's avatar
饶先宏 已提交
2288 2289 2290 2291 2292
    }
  ;

named_port_connection : 
    attribute_instance_list '.' port_identifier '(' expression_option ')' {
饶先宏's avatar
饶先宏 已提交
2293 2294 2295 2296 2297 2298 2299 2300 2301
    $$ = verilogparseCreateParamInstance(
            $3, //const char* name,
            1, //int exprcount,
            $5, //HOBJECT expr0,
            NULL, //HOBJECT expr1,
            NULL, //HOBJECT expr2,
            $1 //IDListVarPtr attributes
            );

饶先宏's avatar
饶先宏 已提交
2302 2303 2304 2305 2306
    }
  ;

/*
A.4.2 Generate construct
2307
*/
饶先宏's avatar
饶先宏 已提交
2308 2309

module_or_generate_item_list:
2310
     %empty   {
饶先宏's avatar
饶先宏 已提交
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413
    }
|   module_or_generate_item {
    }
|   module_or_generate_item_list  module_or_generate_item {
    }
  ;


generate_region :
    KW_GENERATE module_or_generate_item_list KW_ENDGENERATE {
    }
  ;

genvar_declaration : 
    KW_GENVAR list_of_genvar_identifiers ';' {
    }
  ;

list_of_genvar_identifiers :
    genvar_identifier  {
    }
|   list_of_genvar_identifiers ',' genvar_identifier {
    }
  ;

loop_generate_construct :
    KW_FOR '(' genvar_initialization ';' genvar_expression ';' genvar_iteration ')'
    generate_block {
    }
  ;

genvar_initialization :
    genvar_identifier '=' constant_expression {
    }
  ;

genvar_expression :
    genvar_primary {
    }
|   unary_operator attribute_instance_list genvar_primary {
    }
|   genvar_expression binary_operator attribute_instance_list genvar_expression {
    }
|   genvar_expression '?' attribute_instance_list genvar_expression ':' genvar_expression {
    }
  ;

genvar_iteration :
    genvar_identifier '=' genvar_expression {
    }
  ;

genvar_primary :
    constant_primary {
    }
|   genvar_identifier {
    }
  ;

conditional_generate_construct :
    if_generate_construct {
    }
|   case_generate_construct {
    }
  ;

if_generate_construct :
    KW_IF '(' constant_expression ')' generate_block_or_null {
    }
|   KW_IF '(' constant_expression ')' generate_block_or_null KW_ELSE generate_block_or_null {
    }
  ;


case_generate_item_list:
    case_generate_item {
    }
|   case_generate_item_list  case_generate_item {
    }
  ;

case_generate_construct :
    KW_CASE '(' constant_expression ')' case_generate_item_list KW_ENDCASE {
    }
  ;

constant_expression_list:
    constant_expression {
    }
|   constant_expression_list  constant_expression {
    }
  ;

case_generate_item :
    constant_expression_list ':' generate_block_or_null {
    }
|   KW_DEFAULT generate_block_or_null {
    }
|   KW_DEFAULT ':' generate_block_or_null {
    }
  ;

module_or_generate_item_list :
2414
     %empty   {
饶先宏's avatar
饶先宏 已提交
2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437
    }
|   module_or_generate_item_list module_or_generate_item {
    }
|   module_or_generate_item {   
    }
  ;

generate_block :
    module_or_generate_item {
    }
|   KW_BEGIN  ':' generate_block_identifier module_or_generate_item_list KW_END {
    }
|   KW_BEGIN module_or_generate_item_list KW_END {
    }
  ;

generate_block_or_null :
    generate_block {
    }
|   ';' {
    }
  ;

2438 2439 2440 2441
/*
A.5 UDP declaration and instantiation
A.5.1 UDP declaration
*/
饶先宏's avatar
饶先宏 已提交
2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461

udp_port_declaration_list :
    udp_port_declaration_list udp_port_declaration {
    }
|   udp_port_declaration {   
    }
  ;

udp_declaration :
    attribute_instance_list KW_PRIMITIVE udp_identifier '(' udp_port_list ')' ';'
    udp_port_declaration_list 
    udp_body
    KW_ENDPRIMITIVE {
    }
|   attribute_instance_list KW_PRIMITIVE udp_identifier '(' udp_declaration_port_list ')' ';'
    udp_body
    KW_ENDPRIMITIVE {
    }
  ;

2462 2463 2464
/*
A.5.2 UDP ports
*/
饶先宏's avatar
饶先宏 已提交
2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507

udp_port_list : 
    output_port_identifier ',' input_port_identifier {
    }
|   udp_port_list ',' input_port_identifier {
    }
  ;

udp_declaration_port_list :
    udp_output_declaration ',' udp_input_declaration{
    } 
|   udp_declaration_port_list ',' udp_input_declaration {
    }
  ;

udp_port_declaration :
    udp_output_declaration ';' {
    }
|   udp_input_declaration ';' {
    }
|   udp_reg_declaration ';' {
    }
  ;

udp_output_declaration :
    attribute_instance_list KW_OUTPUT port_identifier {
    }
|   attribute_instance_list KW_OUTPUT KW_REG port_identifier {
    }
|   attribute_instance_list KW_OUTPUT KW_REG port_identifier '=' constant_expression {
    }
  ;

udp_input_declaration : 
    attribute_instance_list KW_INPUT list_of_port_identifiers {
    }
  ;

udp_reg_declaration : 
    attribute_instance_list KW_REG variable_identifier {
    }
  ;

2508 2509 2510
/*
A.5.3 UDP body
*/
饶先宏's avatar
饶先宏 已提交
2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579

udp_body :
    combinational_body  {
    }
|   sequential_body {
    }
  ;

combinational_entry_list :
    combinational_entry {
    } 
|   combinational_entry_list  combinational_entry {
    }
  ;

combinational_body : 
    KW_TABLE combinational_entry_list KW_ENDTABLE {
    }
  ;

combinational_entry : 
    level_input_list ':' output_symbol ';' {
    }
  ;

sequential_entry_list :
    sequential_entry {
    } 
|   sequential_entry_list  sequential_entry {
    }
  ;

sequential_body : 
    KW_TABLE sequential_entry_list KW_ENDTABLE {
    }
|   udp_initial_statement KW_TABLE sequential_entry_list KW_ENDTABLE {
    }
  ;

udp_initial_statement : 
    KW_INITIAL output_port_identifier '=' init_val ';' {
    }
  ;

init_val : 
    number {
    }
  ;
  /* 1'b0 | 1'b1 | 1'bx | 1'bX | 1'B0 | 1'B1 | 1'Bx | 1'BX | 1 | 0 */

sequential_entry : 
    seq_input_list ':' current_state ':' next_state ';' {
    }
  ;
seq_input_list : 
    level_input_list {
    }
|   edge_input_list {
    }
  ;

level_input_list : 
    level_symbol {
    }
| level_input_list level_symbol {
    }
  ;

level_symbol_list :
2580
    %empty    {
饶先宏's avatar
饶先宏 已提交
2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639
    }
|   level_symbol {
    }
|   level_symbol_list level_symbol {
    }
  ;

edge_input_list : 
    level_symbol_list edge_indicator level_symbol_list {
    }
  ;

edge_indicator : 
    '(' level_symbol level_symbol ')'  {
    }
| edge_symbol {
    }
  ;

current_state : 
    level_symbol {
    }
  ;

next_state : 
    output_symbol  {
    }
|   '-' {
    }
  ;


output_symbol : 
    unsigned_number {
    }
|   '?'   {
    }
|   SIMPLE_ID {
    }
  ;

level_symbol :
    unsigned_number {
    }
|   '?' {
    }
|   SIMPLE_ID {
    }
 ;

edge_symbol : /* can be r,f,p,n or star in any case. */
    SIMPLE_ID {
    }
|   '*' {
    }
  ;

/*
fixed me!
2640 2641 2642
output_symbol ::= 0 | 1 | x | X
level_symbol ::= 0 | 1 | x | X | ? | b | B
edge_symbol ::= r | R | f | F | p | P | n | N | *
饶先宏's avatar
饶先宏 已提交
2643 2644
*/

2645 2646 2647
/*
A.5.4 UDP instantiation
*/
饶先宏's avatar
饶先宏 已提交
2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682

udp_instance_list :
    udp_instance {
    }
|   udp_instance_list ',' udp_instance {
    }
  ;


udp_instantiation : 
    udp_identifier drive_strength_option delay2_option
    udp_instance_list ';' {
    }
  ;

input_terminal_list :
    input_terminal {
    }
|   input_terminal_list ',' input_terminal {
    }
  ;


udp_instance : 
    name_of_udp_instance '(' output_terminal ',' input_terminal_list ')' {
    }
|   '(' output_terminal ',' input_terminal_list ')' {
    }
  ;

name_of_udp_instance : 
    udp_instance_identifier range_option {
    }
  ;

2683 2684 2685 2686
/*
A.6 Behavioral statements
A.6.1 Continuous assignment statements
*/
饶先宏's avatar
饶先宏 已提交
2687
continuous_assign : 
饶先宏's avatar
饶先宏 已提交
2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699
    attribute_instance_list KW_ASSIGN drive_strength_option delay3_option list_of_net_assignments ';' {
        if (currentmodule == NULL) {
            yyerror("no current module");
        } else {
            IDListVarPtr pitem, pitemtemp;
	        pitem = $5->__dlist_pNext; 
	        while (!IsDListHeader(pitem)) {
		        pitemtemp = pitem->__dlist_pNext;
                verilog_Assignment* assignment = verilogAssignmentGetData(pitem);
                assignment->attributes = $1;
		        pitem = pitemtemp;
	        }
饶先宏's avatar
饶先宏 已提交
2700
            verilogparseAddModuleItems(currentmodule, $5, MODULE_ITEM_TYPE_CONTINUOUS_ASSIGNMENT);
饶先宏's avatar
饶先宏 已提交
2701
        }
饶先宏's avatar
饶先宏 已提交
2702 2703 2704 2705 2706
    }
  ;

list_of_net_assignments : 
    net_assignment {
饶先宏's avatar
饶先宏 已提交
2707 2708
        $$ = dlistCreate();
        dlistAppendItem($$, $1);
饶先宏's avatar
饶先宏 已提交
2709 2710
    }
|   list_of_net_assignments ',' net_assignment {
饶先宏's avatar
饶先宏 已提交
2711 2712
        $$ = $1;
        dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
2713 2714 2715
    }
  ;

饶先宏's avatar
饶先宏 已提交
2716
/*
饶先宏's avatar
饶先宏 已提交
2717 2718 2719 2720
net_assignment : 
    net_lvalue '=' expression {
    }
  ;
饶先宏's avatar
饶先宏 已提交
2721 2722 2723 2724 2725
*/

net_assignment : 
    var '=' expression {
        $$ = verilogparseCreateAssignment(
饶先宏's avatar
饶先宏 已提交
2726
            0,
饶先宏's avatar
饶先宏 已提交
2727 2728 2729
	        $1.obj[0], /* IDListVarPtr hierarchical_identifier */
	        $1.obj[1], /* IDListVarPtr element_select */
            $1.type, //int range_type,
饶先宏's avatar
饶先宏 已提交
2730 2731 2732 2733 2734 2735 2736
	        1, /* int constelementsel */
	        $3, /* HOBJECT expr */
	        NULL /* IDListVarPtr attributes */
        );
    }
  ;

饶先宏's avatar
饶先宏 已提交
2737

2738 2739 2740
/*
A.6.2 Procedural blocks and assignments
*/
饶先宏's avatar
饶先宏 已提交
2741 2742 2743 2744 2745 2746
initial_construct :
    KW_INITIAL statement {
    }
  ;

always_construct : 
饶先宏's avatar
饶先宏 已提交
2747 2748
    attribute_instance_list KW_ALWAYS statement {
    verilogparseAddModuleItems(currentmodule, $3, MODULE_ITEM_TYPE_ALWAYS_CONSTRUCT);
饶先宏's avatar
饶先宏 已提交
2749 2750 2751 2752
    }
  ;

delay_or_event_control_option :
2753
     %empty   {
饶先宏's avatar
饶先宏 已提交
2754 2755 2756 2757 2758 2759
    }
|   delay_or_event_control {
    }
  ;

blocking_assignment : 
饶先宏's avatar
饶先宏 已提交
2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773
    attribute_instance_list var '=' delay_or_event_control_option expression {
        $$ = verilogparseCreateAssignmentStatement(
            TIMECONTROL_NONE,
            STATEMENT_BLOCKING_ASSIGNMENT,
            verilogparseCreateAssignment(
                0,
	            $2.obj[0], /* IDListVarPtr hierarchical_identifier */
	            $2.obj[1], /* IDListVarPtr element_select */
                $2.type, //int range_type,
	            1, /* int constelementsel */
	            $5, /* HOBJECT expr */
	            $1 /* IDListVarPtr attributes */
            )
        );
饶先宏's avatar
饶先宏 已提交
2774
    }
饶先宏's avatar
饶先宏 已提交
2775 2776
/* 
    variable_lvalue '=' expression
饶先宏's avatar
饶先宏 已提交
2777 2778
|   variable_lvalue '=' delay_or_event_control_option  expression {
    }
饶先宏's avatar
饶先宏 已提交
2779
*/
饶先宏's avatar
饶先宏 已提交
2780 2781 2782
  ;

nonblocking_assignment : 
饶先宏's avatar
饶先宏 已提交
2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798
    attribute_instance_list var LTE delay_or_event_control_option expression {
        $$ = verilogparseCreateAssignmentStatement(
            TIMECONTROL_NONE,
            STATEMENT_NONBLOCKING_ASSIGNMENT,
            verilogparseCreateAssignment (
                1,
	            $2.obj[0], /* IDListVarPtr hierarchical_identifier */
	            $2.obj[1], /* IDListVarPtr element_select */
                $2.type, //int range_type,
	            1, /* int constelementsel */
	            $5, /* HOBJECT expr */
	            $1 /* IDListVarPtr attributes */
            )
        );
    }
/*
饶先宏's avatar
饶先宏 已提交
2799 2800
    variable_lvalue LTE delay_or_event_control_option expression {
    }
饶先宏's avatar
饶先宏 已提交
2801
*/
饶先宏's avatar
饶先宏 已提交
2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822
  ;
procedural_continuous_assignments :
    KW_ASSIGN variable_assignment {
    }
|   KW_DEASSIGN variable_lvalue {
    }
|   KW_FORCE variable_assignment {
    }
|   KW_FORCE net_assignment {
    }
|   KW_RELEASE variable_lvalue {
    }
|   KW_RELEASE net_lvalue {
    }
  ;

variable_assignment : 
    variable_lvalue '=' expression {
    }
  ;

2823 2824 2825
/*
A.6.3 Parallel and sequential blocks
*/
饶先宏's avatar
饶先宏 已提交
2826
block_item_declaration_list:
2827
    %empty    {
饶先宏's avatar
饶先宏 已提交
2828 2829 2830 2831 2832 2833 2834 2835
    }
|   block_item_declaration {
    }
|   block_item_declaration_list block_item_declaration {
    }
  ;

statement_list:
2836
    %empty    {
饶先宏's avatar
饶先宏 已提交
2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857
    }
|   statement {
    }
|   statement_list statement {
    }
  ;

par_block : 
    KW_FORK statement_list KW_JOIN {
    }
|   KW_FORK ':' block_identifier block_item_declaration_list statement_list KW_JOIN {
    }
  ;

seq_block : 
    KW_BEGIN statement_list KW_END {
    }
|   KW_BEGIN  ':' block_identifier block_item_declaration_list statement_list KW_END {
    }
  ;

2858 2859 2860
/*
A.6.4 Statements
*/
饶先宏's avatar
饶先宏 已提交
2861
statement :
饶先宏's avatar
饶先宏 已提交
2862 2863
    blocking_assignment ';' {
    $$ = 1;
饶先宏's avatar
饶先宏 已提交
2864 2865 2866
    }
|   attribute_instance_list case_statement {
    }
饶先宏's avatar
饶先宏 已提交
2867
|   conditional_statement {
饶先宏's avatar
饶先宏 已提交
2868 2869 2870 2871 2872 2873 2874
    }
|   attribute_instance_list disable_statement {
    }
|   attribute_instance_list event_trigger {
    }
|   attribute_instance_list loop_statement {
    }
饶先宏's avatar
饶先宏 已提交
2875 2876
|   nonblocking_assignment ';' {
    $$ = 1;
饶先宏's avatar
饶先宏 已提交
2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895
    }
|   attribute_instance_list par_block {
    }
|   attribute_instance_list procedural_continuous_assignments ';' {
    }
|   attribute_instance_list procedural_timing_control_statement {
    }
|   attribute_instance_list seq_block {
    }
|   attribute_instance_list system_task_enable {
    }
|   attribute_instance_list task_enable {
    }
|   attribute_instance_list wait_statement {
    }
  ;

statement_or_null :
    statement {
饶先宏's avatar
饶先宏 已提交
2896
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
2897 2898
    }
|   attribute_instance_list ';' {
饶先宏's avatar
饶先宏 已提交
2899
    /*$$ = NULL*/
饶先宏's avatar
饶先宏 已提交
2900 2901 2902 2903 2904 2905 2906 2907
    }
  ;

function_statement : 
    statement {
    }
  ;

2908 2909 2910
/*
A.6.5 Timing control statements
*/
饶先宏's avatar
饶先宏 已提交
2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938
delay_control :
    '#' delay_value {
    }
|   '#' '(' mintypmax_expression ')' {
    }
  ;

delay_or_event_control :
    delay_control {
    }
|   event_control {
    }
|   KW_REPEAT '(' expression ')' event_control {
    }
  ;

disable_statement :
    KW_DISABLE hierarchical_task_identifier ';' {
    }
|   KW_DISABLE hierarchical_block_identifier ';' {
    }
  ;

event_control :
    '@' hierarchical_event_identifier {
    }
|   '@' '(' event_expression ')' {
    }
饶先宏's avatar
饶先宏 已提交
2939
|   '@' '*' {
饶先宏's avatar
饶先宏 已提交
2940 2941 2942 2943 2944 2945
    }
|   '@' '(' '*' ')' {
    }
  ;

script_list :
2946
     %empty   {
饶先宏's avatar
饶先宏 已提交
2947 2948 2949 2950 2951 2952 2953 2954
    }
| '['expression ']' {
    }
|script_list '['expression ']' {
    }
  ;

event_trigger :
饶先宏's avatar
饶先宏 已提交
2955
    MINUSGT hierarchical_event_identifier script_list ';' {
饶先宏's avatar
饶先宏 已提交
2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988
    }
  ;

event_expression :
    expression {
    }
|   KW_POSEDGE expression {
    }
|   KW_NEGEDGE expression {
    }
|   event_expression KW_OR event_expression {
    }
|   event_expression ',' event_expression {
    }
  ;

procedural_timing_control :
    delay_control {
    }
|   event_control {
    }
  ;

procedural_timing_control_statement :
    procedural_timing_control statement_or_null {
    }
  ;

wait_statement :
    KW_WAIT '(' expression ')' statement_or_null {
    }
  ;

2989 2990 2991
/*
A.6.6 Conditional statements
*/
饶先宏's avatar
饶先宏 已提交
2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003
conditional_statement :
    KW_IF '(' expression ')'
    statement_or_null KW_ELSE statement_or_null {
    }
|   KW_IF '(' expression ')'
    statement_or_null {
    }
|   if_else_if_statement {
    }
  ;

else_if_list:
3004
     %empty   {
饶先宏's avatar
饶先宏 已提交
3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021
    } 
|   KW_ELSE KW_IF '(' expression ')' statement_or_null {
    }
|   else_if_list KW_ELSE KW_IF '(' expression ')' statement_or_null {
    }
  ;

if_else_if_statement :
    KW_IF '(' expression ')' statement_or_null
    else_if_list
    KW_ELSE statement_or_null {
    }
|   KW_IF '(' expression ')' statement_or_null
    else_if_list {
    }
  ;

3022 3023 3024
/*
A.6.7 Case statements
*/
饶先宏's avatar
饶先宏 已提交
3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061
case_item_list :
    case_item {
    }
|   case_item_list case_item {
    }
  ;

case_type:
    KW_CASE {
    }
|   KW_CASEZ {
    }
|   KW_CASEX {
    }
  ;

case_statement :
    case_type '(' expression ')' case_item_list KW_ENDCASE {
    }
  ;

expression_list :
    expression {
    }
|   expression_list ',' expression {
    }
  ;

case_item :
    expression_list ':' statement_or_null {
    }
|   KW_DEFAULT ':' statement_or_null {
    }
|   KW_DEFAULT statement_or_null {
    }
  ;

3062 3063 3064
/*
A.6.8 Looping statements
*/
饶先宏's avatar
饶先宏 已提交
3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075
loop_statement :
    KW_FOREVER statement {
    }
|   KW_REPEAT '(' expression ')' statement {
    }
|   KW_WHILE '(' expression ')' statement {    
    }
|   KW_FOR '(' variable_assignment ';' expression ';' variable_assignment ')' statement {
    }
  ;

3076 3077 3078
/*
A.6.9 Task enable statements
*/
饶先宏's avatar
饶先宏 已提交
3079
expression_or_null_list :
3080
     %empty   {
饶先宏's avatar
饶先宏 已提交
3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103
    }
|   expression {
    }
|   expression_or_null_list ',' {
    }
|   expression_or_null_list ',' expression {
    }
  ;

system_task_enable : 
    SYSTEM_ID ';' {
    }
|   SYSTEM_ID '(' expression_or_null_list ')' ';' {
    }
  ;

task_enable : 
    hierarchical_task_identifier ';' {
    }
|   hierarchical_task_identifier '(' expression_list ')' ';' {
    }
  ;

3104 3105 3106 3107
/*
A.7 Specify section
A.7.1 Specify block declaration
*/
饶先宏's avatar
饶先宏 已提交
3108
specify_item_list :
3109
     %empty   {
饶先宏's avatar
饶先宏 已提交
3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148
    }
|   specify_item {
    }
|   specify_item_list specify_item {
    }
  ;

specify_block : 
    KW_SPECIFY specify_item_list KW_ENDSPECIFY {
    }
  ;

specify_item :
    specparam_declaration {
    }
|   pulsestyle_declaration {
    }
|   showcancelled_declaration {
    }
|   path_declaration {
    }
|   system_timing_check {
    }
  ;

pulsestyle_declaration :
    KW_PULSESTYLE_ONEVENT list_of_path_outputs ';' {
    }
|   KW_PULSESTYLE_ONDETECT list_of_path_outputs ';' {
    }
  ;

showcancelled_declaration :
    KW_SHOWCANCELLED list_of_path_outputs ';' {
    }
|   KW_NOSHOWCANCELLED list_of_path_outputs ';' {
    }
  ;

3149 3150 3151
/*
A.7.2 Specify path declarations
*/
饶先宏's avatar
饶先宏 已提交
3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168
path_declaration :
    simple_path_declaration ';' {
    }
|   edge_sensitive_path_declaration ';' {
    }
|   state_dependent_path_declaration ';' {
    }
  ;

simple_path_declaration : 
    parallel_path_description '=' path_delay_value {
    }
|   full_path_description '=' path_delay_value {
    }
  ;

polarity_operator_option:
3169
     %empty   {
饶先宏's avatar
饶先宏 已提交
3170 3171 3172 3173 3174 3175
    }
|   polarity_operator {
    }
  ;

parallel_path_description :
饶先宏's avatar
饶先宏 已提交
3176
    '(' specify_input_terminal_descriptor polarity_operator_option EQGT specify_output_terminal_descriptor ')' {
饶先宏's avatar
饶先宏 已提交
3177 3178 3179 3180
    }
  ;

full_path_description :
饶先宏's avatar
饶先宏 已提交
3181
    '(' list_of_path_inputs polarity_operator_option STARGT list_of_path_outputs ')' {
饶先宏's avatar
饶先宏 已提交
3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198
    }
  ;

list_of_path_inputs :
    specify_input_terminal_descriptor {
    } 
|   list_of_path_inputs ',' specify_input_terminal_descriptor {
    }
  ;

list_of_path_outputs :
    specify_output_terminal_descriptor {
    }
|   list_of_path_outputs ',' specify_output_terminal_descriptor {
    }
  ;

3199 3200 3201
/*
A.7.3 Specify block terminals
*/
饶先宏's avatar
饶先宏 已提交
3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229
specify_input_terminal_descriptor :
    input_identifier {
    }
|   input_identifier '[' constant_range_expression ']' {
    }
  ;

specify_output_terminal_descriptor :
    output_identifier {
    }
|   output_identifier '[' constant_range_expression ']' {
    }
  ;

input_identifier : 
    input_port_identifier  {
    }
|   inout_port_identifier {
    }
  ;

output_identifier : 
    output_port_identifier  {
    }
|   inout_port_identifier {
    }
  ;

3230 3231 3232
/*
A.7.4 Specify path delays
*/
饶先宏's avatar
饶先宏 已提交
3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347
path_delay_value :
    list_of_path_delay_expressions {
    }
|   '(' list_of_path_delay_expressions ')' {
    }
  ;

list_of_path_delay_expressions :
    t_path_delay_expression {
    }
|   trise_path_delay_expression ',' tfall_path_delay_expression {
    }
|   trise_path_delay_expression ',' tfall_path_delay_expression ',' tz_path_delay_expression {
    }
|   t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ','
    tz1_path_delay_expression ',' t1z_path_delay_expression ',' tz0_path_delay_expression {
    }
|   t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ','
    tz1_path_delay_expression ',' t1z_path_delay_expression ',' tz0_path_delay_expression ','
    t0x_path_delay_expression ',' tx1_path_delay_expression ',' t1x_path_delay_expression ','
    tx0_path_delay_expression ',' txz_path_delay_expression ',' tzx_path_delay_expression {
    }
  ;

t_path_delay_expression : 
    path_delay_expression {
    }
  ;

trise_path_delay_expression : 
	path_delay_expression {
	}
  ;

tfall_path_delay_expression : 
	path_delay_expression {
	}
  ;

tz_path_delay_expression : 
	path_delay_expression {
	}
  ;

t01_path_delay_expression : 
	path_delay_expression {
	}
  ;

t10_path_delay_expression : 
	path_delay_expression {
	}
  ;

t0z_path_delay_expression : 
	path_delay_expression {
	}
  ;

tz1_path_delay_expression : 
	path_delay_expression {
	}
  ;

t1z_path_delay_expression : 
	path_delay_expression {
	}
  ;

tz0_path_delay_expression : 
	path_delay_expression {
	}
  ;
t0x_path_delay_expression : 
	path_delay_expression {
	}
  ;

tx1_path_delay_expression : 
	path_delay_expression {
	}
  ;

t1x_path_delay_expression : 
	path_delay_expression {
	}
  ;
tx0_path_delay_expression : 
	path_delay_expression {
	}
  ;

txz_path_delay_expression : 
	path_delay_expression {
	}
  ;

tzx_path_delay_expression : 
	path_delay_expression {
	}
  ;

path_delay_expression : 
    constant_mintypmax_expression {
    }
  ;

edge_sensitive_path_declaration :
    parallel_edge_sensitive_path_description '=' path_delay_value {
    }
|   full_edge_sensitive_path_description '=' path_delay_value {
    }
  ;

edge_identifier_option :
3348
     %empty   {
饶先宏's avatar
饶先宏 已提交
3349 3350 3351 3352 3353 3354
    }
|   edge_identifier {
    }
  ;

polarity_operator_option :
3355
     %empty   {
饶先宏's avatar
饶先宏 已提交
3356 3357 3358 3359 3360
    }
|   polarity_operator {
    }
  ;
parallel_edge_sensitive_path_description :
饶先宏's avatar
饶先宏 已提交
3361
    '(' edge_identifier_option specify_input_terminal_descriptor EQGT 
饶先宏's avatar
饶先宏 已提交
3362 3363 3364 3365 3366
    '(' specify_output_terminal_descriptor polarity_operator_option ':' data_source_expression ')' ')' {
    }
  ;

full_edge_sensitive_path_description :
饶先宏's avatar
饶先宏 已提交
3367
    '(' edge_identifier_option list_of_path_inputs STARGT
饶先宏's avatar
饶先宏 已提交
3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399
    '(' list_of_path_outputs polarity_operator_option ':' data_source_expression ')' ')' {
    }
  ;

data_source_expression : 
    expression {
    }
  ;

edge_identifier : 
    KW_POSEDGE {
    }
|   KW_NEGEDGE {
    }
  ;

state_dependent_path_declaration :
    KW_IF '(' module_path_expression ')' simple_path_declaration {
    }
|   KW_IF '(' module_path_expression ')' edge_sensitive_path_declaration {
    }
|   KW_IFNONE simple_path_declaration {
    }
  ;

polarity_operator : 
    '+'  {
    }
|   '-' {
    }
  ;

3400 3401 3402 3403
/*
A.7.5 System timing checks
A.7.5.1 System timing check commands
*/
饶先宏's avatar
饶先宏 已提交
3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432

system_timing_check :
    setup_timing_check {
    }
|   hold_timing_check{
    }
|   setuphold_timing_check {
    }
|   recovery_timing_check {
    }
|   removal_timing_check {
    }
|   recrem_timing_check {
    }
|   skew_timing_check {
    }
|   timeskew_timing_check {
    }
|   fullskew_timing_check {
    }
|   period_timing_check {
    }
|   width_timing_check {
    }
|   nochange_timing_check {
    }
  ;

notifier_or_null :
3433
    %empty    {
饶先宏's avatar
饶先宏 已提交
3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451
    }
|   ',' {
    }
|   ',' notifier {
    }
  ;

setup_timing_check :
    KW_SYS_SETUP '(' data_event ',' reference_event ',' timing_check_limit notifier_or_null ')' ';' {
    }
  ;

hold_timing_check :
    KW_SYS_HOLD '(' reference_event ',' data_event ',' timing_check_limit notifier_or_null ')' ';' {
    }
  ;

notifier_option :
3452
     %empty  {
饶先宏's avatar
饶先宏 已提交
3453 3454 3455 3456 3457 3458
    }
|   notifier {
    }
  ;

stamptime_condition_option :
3459
     %empty   {
饶先宏's avatar
饶先宏 已提交
3460 3461 3462 3463 3464 3465
    }
|   stamptime_condition {
    }
  ;

checktime_condition_option :
3466
    %empty    {
饶先宏's avatar
饶先宏 已提交
3467 3468 3469 3470 3471 3472
    }
|   checktime_condition {
    }
  ;

delayed_reference_option :
3473
     %empty   {
饶先宏's avatar
饶先宏 已提交
3474 3475 3476 3477 3478 3479
    }
|   delayed_reference {
    }
  ;

delayed_data_option :
3480
    %empty    {
饶先宏's avatar
饶先宏 已提交
3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594
    }
|   delayed_data {
    }
  ;

setuphold_timing_check :
    KW_SYS_SETUPHOLD '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ')' ';' {
    }
|   KW_SYS_SETUPHOLD '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ')' ';' {
    }
|   KW_SYS_SETUPHOLD '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option 
    ')' ';' {
    }
|   KW_SYS_SETUPHOLD '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option 
    ',' checktime_condition_option
     ')' ';' {
    }
|   KW_SYS_SETUPHOLD '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option 
    ',' checktime_condition_option
    ',' delayed_reference_option 
    ')' ';' {
    }
|   KW_SYS_SETUPHOLD '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option 
    ',' checktime_condition_option
    ',' delayed_reference_option 
    ',' delayed_data_option
    ')' ';' {
    }
  ;

recovery_timing_check :
    KW_SYS_RECOVERY '(' reference_event ',' data_event ',' timing_check_limit notifier_or_null ')' ';' {
    }
  ;

removal_timing_check :
    KW_SYS_REMOVAL '(' reference_event ',' data_event ',' timing_check_limit notifier_or_null ')' ';' {
    }
  ;

recrem_timing_check :
    KW_SYS_RECREM '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ')' ';' {
    }
|   KW_SYS_RECREM '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option
    ')' ';' {
    }
|   KW_SYS_RECREM '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option
    ')' ';' {
    }
|   KW_SYS_RECREM '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option 
    ',' checktime_condition_option
    ')' ';' {
    }
|   KW_SYS_RECREM '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option 
    ',' checktime_condition_option
    ',' delayed_reference_option
    ')' ';' {
    }
|   KW_SYS_RECREM '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option 
    ',' stamptime_condition_option 
    ',' checktime_condition_option
    ',' delayed_reference_option  
    ',' delayed_data_option
    ')' ';' {
    }
  ;

skew_timing_check :
    KW_SYS_SKEW '(' reference_event ',' data_event ',' timing_check_limit notifier_or_null ')' ';' {
    }
  ;

timeskew_timing_check :
    KW_SYS_TIMESKEW '(' reference_event ',' data_event ',' timing_check_limit
    ')' ';' {
    }
|   KW_SYS_TIMESKEW '(' reference_event ',' data_event ',' timing_check_limit
    ',' notifier_option 
    ')' ';' {
    }
|   KW_SYS_TIMESKEW '(' reference_event ',' data_event ',' timing_check_limit
    ',' notifier_option 
    ',' event_based_flag_option
    ')' ';' {
    }
|   KW_SYS_TIMESKEW '(' reference_event ',' data_event ',' timing_check_limit
    ',' notifier_option 
    ',' event_based_flag_option
    ',' remain_active_flag_option
    ')' ';' {
    }
  ;

event_based_flag_option :
3595
     %empty   {
饶先宏's avatar
饶先宏 已提交
3596 3597 3598 3599 3600 3601
    }
|   event_based_flag {
    }
  ;

remain_active_flag_option :
3602
     %empty   {
饶先宏's avatar
饶先宏 已提交
3603 3604 3605 3606 3607 3608
    }
|   remain_active_flag {
    }
  ;

threshold_option :
3609
     %empty   {
饶先宏's avatar
饶先宏 已提交
3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663
    }
|   threshold {
    }
  ;

fullskew_timing_check :
    KW_SYS_FULLSKEW '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ')' ';' {
    }
|   KW_SYS_FULLSKEW '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option
    ')' ';' {
    }

|   KW_SYS_FULLSKEW '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option
    ',' event_based_flag_option
    ')' ';' {
    }
|   KW_SYS_FULLSKEW '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit
    ',' notifier_option
    ',' event_based_flag_option
    ',' remain_active_flag_option 
    ')' ';' {
    }
  ;

period_timing_check :
    KW_SYS_PERIOD '(' controlled_reference_event ',' timing_check_limit notifier_or_null ')' ';' {
    }
  ;


width_timing_check :
    KW_SYS_WIDTH '(' controlled_reference_event ',' timing_check_limit
    ')' ';' {
    }
|   KW_SYS_WIDTH '(' controlled_reference_event ',' timing_check_limit
    ',' threshold_option 
    ')' ';' {
    }
|   KW_SYS_WIDTH '(' controlled_reference_event ',' timing_check_limit
    ',' threshold_option 
    ',' notifier_option 
    ')' ';' {
    }
  ;

nochange_timing_check :
    KW_SYS_NOCHANGE '(' reference_event ',' data_event ',' start_edge_offset ','
    end_edge_offset notifier_or_null ')' ';' {
    }
  ;

3664 3665 3666
/*
A.7.5.2 System timing check command arguments
*/
饶先宏's avatar
饶先宏 已提交
3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743

checktime_condition : 
    mintypmax_expression {
    }
  ;

controlled_reference_event : 
    controlled_timing_check_event {
    }
  ;

data_event : 
    timing_check_event {
    }
  ;

delayed_data :
    terminal_identifier {
    }
|   terminal_identifier '[' constant_mintypmax_expression ']' {
    }
  ;

delayed_reference :
    terminal_identifier {
    }
|   terminal_identifier '[' constant_mintypmax_expression ']' {
    }
  ;

end_edge_offset :
    mintypmax_expression {
    }
 ;

event_based_flag : 
    constant_expression {
    }
  ;

notifier : 
    variable_identifier {
    }
  ;

reference_event : 
    timing_check_event {
    }
  ;

remain_active_flag : 
    constant_expression {
    }
  ;

stamptime_condition : 
    mintypmax_expression {
    }
  ;

start_edge_offset : 
    mintypmax_expression {
    }
  ;

threshold : 
    constant_expression {
    }
  ;

timing_check_limit : 
    expression {
    }
  ;



3744 3745 3746
/*
A.7.5.3 System timing check event definitions
*/
饶先宏's avatar
饶先宏 已提交
3747 3748

timing_check_event_control_option :
3749
     %empty   {
饶先宏's avatar
饶先宏 已提交
3750 3751 3752 3753 3754 3755 3756 3757
    }
|   timing_check_event_control {
    }
  ;

timing_check_event :
    timing_check_event_control_option specify_terminal_descriptor {
    }
饶先宏's avatar
饶先宏 已提交
3758
|   timing_check_event_control_option specify_terminal_descriptor T_AND timing_check_condition {
饶先宏's avatar
饶先宏 已提交
3759 3760 3761 3762 3763 3764
    }
  ;

controlled_timing_check_event :
    timing_check_event_control specify_terminal_descriptor {
    }
饶先宏's avatar
饶先宏 已提交
3765
|   timing_check_event_control specify_terminal_descriptor T_AND timing_check_condition {
饶先宏's avatar
饶先宏 已提交
3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785
    }
  ;

timing_check_event_control :
    KW_POSEDGE {
    }
|   KW_NEGEDGE {
    }
|   edge_control_specifier {
    }
  ;

specify_terminal_descriptor :
    specify_input_terminal_descriptor {
    }
|   specify_output_terminal_descriptor {
    }
  ;

edge_descriptor_list:
3786
      %empty  {
饶先宏's avatar
饶先宏 已提交
3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817
    }
| edge_descriptor {
    }
| edge_descriptor_list ',' edge_descriptor {
    }
  ;

edge_control_specifier : 
    KW_EDGE edge_descriptor_list {
    }
  ;

edge_descriptor :
    number {
    }
  ;

/*
fixed me
edge_descriptor :
    01 {
    }
|   10 {
    }
|   z_or_x zero_or_one {
    }
|   zero_or_one z_or_x {
    }
  ;

zero_or_one : 0 | 1
3818
z_or_x ::= x | X | z | Z
饶先宏's avatar
饶先宏 已提交
3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848
*/

timing_check_condition :
    scalar_timing_check_condition {
    }
|   '(' scalar_timing_check_condition ')' {
    }
  ;

scalar_timing_check_condition :
    expression {
    }
|   '~' expression {
    }
|   expression L_EQ scalar_constant {
    }
|   expression C_EQ scalar_constant {
    }
|   expression L_NEQ scalar_constant {
    }
|   expression C_NEQ scalar_constant {
    }
  ;

scalar_constant :
    number {
    }
  ;
/*
fixedme
3849
1'b0 | 1'b1 | 1'B0 | 1'B1 | 'b0 | 'b1 | 'B0 | 'B1 | 1 | 0
饶先宏's avatar
饶先宏 已提交
3850 3851
*/

3852 3853 3854 3855
/*
A.8 Expressions
A.8.1 Concatenations
*/
饶先宏's avatar
饶先宏 已提交
3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900
concatenation : 
    '{' expression_list '}' {
    }
  ;

constant_expression_list :
    constant_expression {
    }
|   constant_expression_list ',' constant_expression {
    }
  ;

constant_concatenation : 
    '{' constant_expression_list '}' {
    }
  ;

constant_multiple_concatenation : 
    '{' constant_expression constant_concatenation '}' {
    }
  ;

module_path_expression_list :
    module_path_expression {
    }
|   module_path_expression_list ',' module_path_expression {
    }
  ;


module_path_concatenation : 
    '{' module_path_expression_list '}' {
    }
  ;

module_path_multiple_concatenation : 
    '{' constant_expression module_path_concatenation '}' {
    }
  ;

multiple_concatenation : 
    '{' constant_expression concatenation '}' {
    }
  ;

3901 3902 3903
/*
A.8.2 Function calls
*/
饶先宏's avatar
饶先宏 已提交
3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920
constant_function_call : 
    function_identifier attribute_instance_list
    '(' constant_expression_list ')' {
    }
  ;

system_function_identifier :
    SYSTEM_ID {
    }
  ;

constant_system_function_call : 
    system_function_identifier
    '(' constant_expression_list ')' {
    }
  ;

3921
/*
饶先宏's avatar
饶先宏 已提交
3922 3923 3924 3925 3926
function_call : 
    hierarchical_function_identifier attribute_instance_list
    '(' expression_list ')' {
    }
  ;
3927 3928
*/
function_call : 
饶先宏's avatar
饶先宏 已提交
3929
    hierarchical_identifier attribute_instance_list
3930 3931 3932 3933
    '(' expression_list ')' {
    }
  ;

饶先宏's avatar
饶先宏 已提交
3934 3935 3936 3937 3938 3939 3940 3941 3942

system_function_call : 
    system_function_identifier {
    }
|   system_function_identifier
    '(' expression_list ')' {
    }
  ;

3943 3944 3945
/*
A.8.3 Expressions
*/
饶先宏's avatar
饶先宏 已提交
3946 3947
base_expression : 
    expression {
饶先宏's avatar
饶先宏 已提交
3948
        $$ = $1;
饶先宏's avatar
饶先宏 已提交
3949 3950 3951 3952 3953
    }
  ;

conditional_expression : 
    expression '?' attribute_instance_list expression ':' expression {
饶先宏's avatar
饶先宏 已提交
3954 3955 3956 3957 3958
        $$ = verilogparseCreateIfopExpr(
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $6, //HOBJECT expr2,
        $3 //IDListVarPtr attributes
饶先宏's avatar
饶先宏 已提交
3959
        );
饶先宏's avatar
饶先宏 已提交
3960 3961 3962 3963 3964
    }
  ;

constant_base_expression : 
    constant_expression {
饶先宏's avatar
饶先宏 已提交
3965
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
3966 3967 3968
    }
  ;

3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275
unary_constant_expression :
    constant_primary {
        $$ = $1;
    }
|   unary_operator attribute_instance_list unary_constant_expression { 
    /*规范中是unary_operator attribute_instance_list primary, 似乎有点不大对啊 */
    $$ = verilogparseCreateUnopConstantExpr(
         $1,//int op,
         $3,//HOBJECT expr,
         $2 //IDListVarPtr attributes
        );
    }
 ;

pow_constant_expression :
    unary_constant_expression {
        $$ = $1;
    }
|  pow_constant_expression POW attribute_instance_list unary_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_POW, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
 ;

multiplicative_constant_expression :
    pow_constant_expression {
        $$ = $1;
    }
|  multiplicative_constant_expression '*' attribute_instance_list pow_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_MUL, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  multiplicative_constant_expression '/' attribute_instance_list pow_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_DIV, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  multiplicative_constant_expression '%' attribute_instance_list pow_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_MOD, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
    ;


additive_constant_expression :
    multiplicative_constant_expression {
        $$ = $1;
    }
|  additive_constant_expression '+' attribute_instance_list multiplicative_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_PLUS, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  additive_constant_expression '-' attribute_instance_list multiplicative_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_MINUS, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
    ;

shift_constant_expression :
    additive_constant_expression {
        $$ = $1;
    }
|  shift_constant_expression LSL attribute_instance_list additive_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_LSL, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  shift_constant_expression LSR attribute_instance_list additive_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_LSR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  shift_constant_expression ASL attribute_instance_list additive_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_ASL, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  shift_constant_expression ASR attribute_instance_list additive_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_ASR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

relational_constant_expression :
    shift_constant_expression {
        $$ = $1;
    }
|  relational_constant_expression '>' attribute_instance_list shift_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_GT, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  relational_constant_expression '<' attribute_instance_list shift_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_LT, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  relational_constant_expression GTE attribute_instance_list shift_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_GTE, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  relational_constant_expression LTE attribute_instance_list shift_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_LTE, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

equality_constant_expression :
    relational_constant_expression {
        $$ = $1;
    }
|  equality_constant_expression L_EQ attribute_instance_list relational_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_L_EQ, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  equality_constant_expression C_EQ attribute_instance_list relational_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_C_EQ, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  equality_constant_expression L_NEQ attribute_instance_list relational_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_L_NEQ, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  equality_constant_expression C_NEQ attribute_instance_list relational_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_C_NEQ, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

and_constant_expression :
    equality_constant_expression {
        $$ = $1;
    }
|  and_constant_expression '&' attribute_instance_list equality_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_B_AND, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  and_constant_expression B_NAND attribute_instance_list equality_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_B_NAND, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;


exclusive_or_constant_expression :
    and_constant_expression {
        $$ = $1;
    }
|  exclusive_or_constant_expression '^' attribute_instance_list and_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_B_XOR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  exclusive_or_constant_expression B_EQU attribute_instance_list and_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_B_EQU, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;


inclusive_or_constant_expression :
    exclusive_or_constant_expression {
        $$ = $1;
    }
|  inclusive_or_constant_expression '|' attribute_instance_list exclusive_or_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_B_OR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  inclusive_or_constant_expression B_NOR attribute_instance_list exclusive_or_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_B_NOR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

logical_and_constant_expression :
    inclusive_or_constant_expression {
        $$ = $1;
    }
|  logical_and_constant_expression L_AND attribute_instance_list inclusive_or_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_L_AND, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

logical_or_constant_expression :
    logical_and_constant_expression {
        $$ = $1;
    }
|   logical_or_constant_expression L_OR attribute_instance_list logical_and_constant_expression {
    $$ = verilogparseCreateBinopConstantExpr(
        OP_L_OR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
    ;

constant_expression : 
    logical_or_constant_expression {
        $$ = $1;
    }
| constant_expression '?' attribute_instance_list constant_expression ':' constant_expression {
    $$ = verilogparseCreateIfopConstantExpr(
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $6, //HOBJECT expr2,
        $3 //IDListVarPtr attributes
        );
    }

   ;

/*
饶先宏's avatar
饶先宏 已提交
4276 4277
constant_expression :
    constant_primary {
4278
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
4279 4280
    }
|   unary_operator attribute_instance_list constant_primary {
饶先宏's avatar
饶先宏 已提交
4281 4282 4283 4284
    $$ = verilogparseCreateUnopExpr(
         $1,//int op,
         $3,//HOBJECT expr,
         $2 //IDListVarPtr attributes
4285
        );
饶先宏's avatar
饶先宏 已提交
4286 4287
    }
|   constant_expression binary_operator attribute_instance_list constant_expression {
饶先宏's avatar
饶先宏 已提交
4288 4289 4290 4291 4292
    $$ = verilogparseCreateBinopExpr(
        $2, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
4293
        );
饶先宏's avatar
饶先宏 已提交
4294 4295
    }
|   constant_expression '?' attribute_instance_list constant_expression ':' constant_expression {
饶先宏's avatar
饶先宏 已提交
4296 4297 4298 4299 4300
    $$ = verilogparseCreateIfopExpr(
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $6, //HOBJECT expr2,
        $3 //IDListVarPtr attributes
4301
        );
饶先宏's avatar
饶先宏 已提交
4302 4303
    }
  ;
4304
*/
饶先宏's avatar
饶先宏 已提交
4305 4306 4307

constant_mintypmax_expression :
    constant_expression {
饶先宏's avatar
饶先宏 已提交
4308
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
4309 4310
    }
|   constant_expression ':' constant_expression ':' constant_expression {
饶先宏's avatar
饶先宏 已提交
4311
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
4312 4313 4314 4315 4316
    }
  ;

constant_range_expression :
    constant_expression {
饶先宏's avatar
饶先宏 已提交
4317
    $$.type = RANGE_TYPE_BITSELECT;
饶先宏's avatar
饶先宏 已提交
4318 4319
    $$.obj[0] = $1;
    $$.obj[1] = NULL;
饶先宏's avatar
饶先宏 已提交
4320 4321
    }
|   msb_constant_expression ':' lsb_constant_expression {
饶先宏's avatar
饶先宏 已提交
4322
    $$.type = RANGE_TYPE_PARTSELECT;
饶先宏's avatar
饶先宏 已提交
4323 4324
    $$.obj[0] = $1;
    $$.obj[1] = $3;
饶先宏's avatar
饶先宏 已提交
4325
    }
饶先宏's avatar
饶先宏 已提交
4326 4327
|   constant_base_expression STARTPLUSWIDTH width_constant_expression {
    $$.type = RANGE_TYPE_STARTPLUSWIDTH;
饶先宏's avatar
饶先宏 已提交
4328
    $$.obj[0] = $1;
饶先宏's avatar
饶先宏 已提交
4329
    $$.obj[1] = $3;
饶先宏's avatar
饶先宏 已提交
4330
    }
饶先宏's avatar
饶先宏 已提交
4331 4332
|   constant_base_expression STARTMINUSWIDTH width_constant_expression {
    $$.type = RANGE_TYPE_STARTMINUSWIDTH;
饶先宏's avatar
饶先宏 已提交
4333
    $$.obj[0] = $1;
饶先宏's avatar
饶先宏 已提交
4334
    $$.obj[1] = $3;
饶先宏's avatar
饶先宏 已提交
4335 4336 4337 4338 4339
    }
  ;

dimension_constant_expression :
    constant_expression {
饶先宏's avatar
饶先宏 已提交
4340
     $$ = $1;
饶先宏's avatar
饶先宏 已提交
4341 4342 4343
    }
  ;

饶先宏's avatar
饶先宏 已提交
4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363
unary_expression :
    primary {
        $$ = $1;
    }
|   unary_operator attribute_instance_list unary_expression { 
    /*规范中是unary_operator attribute_instance_list primary, 似乎有点不大对啊 */
    $$ = verilogparseCreateUnopExpr(
         $1,//int op,
         $3,//HOBJECT expr,
         $2 //IDListVarPtr attributes
        );
    }
 ;

pow_expression :
    unary_expression {
        $$ = $1;
    }
|  pow_expression POW attribute_instance_list unary_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4364
        OP_POW, //int op,
饶先宏's avatar
饶先宏 已提交
4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
 ;

multiplicative_expression :
    pow_expression {
        $$ = $1;
    }
|  multiplicative_expression '*' attribute_instance_list pow_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4378
        OP_MUL, //int op,
饶先宏's avatar
饶先宏 已提交
4379 4380 4381 4382 4383 4384 4385
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  multiplicative_expression '/' attribute_instance_list pow_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4386
        OP_DIV, //int op,
饶先宏's avatar
饶先宏 已提交
4387 4388 4389 4390 4391 4392 4393
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  multiplicative_expression '%' attribute_instance_list pow_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4394
        OP_MOD, //int op,
饶先宏's avatar
饶先宏 已提交
4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
    ;


additive_expression :
    multiplicative_expression {
        $$ = $1;
    }
|  additive_expression '+' attribute_instance_list multiplicative_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4409
        OP_PLUS, //int op,
饶先宏's avatar
饶先宏 已提交
4410 4411 4412 4413 4414 4415 4416
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  additive_expression '-' attribute_instance_list multiplicative_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4417
        OP_MINUS, //int op,
饶先宏's avatar
饶先宏 已提交
4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
    ;

shift_expression :
    additive_expression {
        $$ = $1;
    }
|  shift_expression LSL attribute_instance_list additive_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4431
        OP_LSL, //int op,
饶先宏's avatar
饶先宏 已提交
4432 4433 4434 4435 4436 4437 4438
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  shift_expression LSR attribute_instance_list additive_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4439
        OP_LSR, //int op,
饶先宏's avatar
饶先宏 已提交
4440 4441 4442 4443 4444 4445 4446
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  shift_expression ASL attribute_instance_list additive_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4447
        OP_ASL, //int op,
饶先宏's avatar
饶先宏 已提交
4448 4449 4450 4451 4452 4453 4454
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  shift_expression ASR attribute_instance_list additive_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4455
        OP_ASR, //int op,
饶先宏's avatar
饶先宏 已提交
4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

relational_expression :
    shift_expression {
        $$ = $1;
    }
|  relational_expression '>' attribute_instance_list shift_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4469
        OP_GT, //int op,
饶先宏's avatar
饶先宏 已提交
4470 4471 4472 4473 4474 4475 4476
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  relational_expression '<' attribute_instance_list shift_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4477
        OP_LT, //int op,
饶先宏's avatar
饶先宏 已提交
4478 4479 4480 4481 4482 4483 4484
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  relational_expression GTE attribute_instance_list shift_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4485
        OP_GTE, //int op,
饶先宏's avatar
饶先宏 已提交
4486 4487 4488 4489 4490 4491 4492
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  relational_expression LTE attribute_instance_list shift_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4493
        OP_LTE, //int op,
饶先宏's avatar
饶先宏 已提交
4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

equality_expression :
    relational_expression {
        $$ = $1;
    }
|  equality_expression L_EQ attribute_instance_list relational_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4507
        OP_L_EQ, //int op,
饶先宏's avatar
饶先宏 已提交
4508 4509 4510 4511 4512 4513 4514
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  equality_expression C_EQ attribute_instance_list relational_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4515
        OP_C_EQ, //int op,
饶先宏's avatar
饶先宏 已提交
4516 4517 4518 4519 4520 4521 4522
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  equality_expression L_NEQ attribute_instance_list relational_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4523
        OP_L_NEQ, //int op,
饶先宏's avatar
饶先宏 已提交
4524 4525 4526 4527 4528 4529 4530
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  equality_expression C_NEQ attribute_instance_list relational_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4531
        OP_C_NEQ, //int op,
饶先宏's avatar
饶先宏 已提交
4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

and_expression :
    equality_expression {
        $$ = $1;
    }
|  and_expression '&' attribute_instance_list equality_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4545
        OP_B_AND, //int op,
饶先宏's avatar
饶先宏 已提交
4546 4547 4548 4549 4550 4551 4552
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  and_expression B_NAND attribute_instance_list equality_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4553
        OP_B_NAND, //int op,
饶先宏's avatar
饶先宏 已提交
4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;


exclusive_or_expression :
    and_expression {
        $$ = $1;
    }
|  exclusive_or_expression '^' attribute_instance_list and_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4568
        OP_B_XOR, //int op,
饶先宏's avatar
饶先宏 已提交
4569 4570 4571 4572 4573 4574 4575
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  exclusive_or_expression B_EQU attribute_instance_list and_expression {
    $$ = verilogparseCreateBinopExpr(
饶先宏's avatar
饶先宏 已提交
4576
        OP_B_EQU, //int op,
饶先宏's avatar
饶先宏 已提交
4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;


inclusive_or_expression :
    exclusive_or_expression {
        $$ = $1;
    }
|  inclusive_or_expression '|' attribute_instance_list exclusive_or_expression {
    $$ = verilogparseCreateBinopExpr(
        OP_B_OR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
|  inclusive_or_expression B_NOR attribute_instance_list exclusive_or_expression {
    $$ = verilogparseCreateBinopExpr(
        OP_B_NOR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

logical_and_expression :
    inclusive_or_expression {
        $$ = $1;
    }
|  logical_and_expression L_AND attribute_instance_list inclusive_or_expression {
    $$ = verilogparseCreateBinopExpr(
        OP_L_AND, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
  ;

logical_or_expression :
    logical_and_expression {
        $$ = $1;
    }
|   logical_or_expression L_OR attribute_instance_list logical_and_expression {
    $$ = verilogparseCreateBinopExpr(
        OP_L_OR, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
        );
    }
    ;

expression : 
    logical_or_expression {
        $$ = $1;
    }
饶先宏's avatar
饶先宏 已提交
4639
|   conditional_expression {
饶先宏's avatar
饶先宏 已提交
4640 4641 4642 4643
        $$ = $1;
    }
   ;
/*
饶先宏's avatar
饶先宏 已提交
4644 4645
expression :
    primary {
饶先宏's avatar
饶先宏 已提交
4646
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
4647 4648
    }
|   unary_operator attribute_instance_list primary {
饶先宏's avatar
饶先宏 已提交
4649 4650 4651 4652
    $$ = verilogparseCreateUnopExpr(
         $1,//int op,
         $3,//HOBJECT expr,
         $2 //IDListVarPtr attributes
饶先宏's avatar
饶先宏 已提交
4653
        );
饶先宏's avatar
饶先宏 已提交
4654 4655
    }
|   expression binary_operator attribute_instance_list expression {
饶先宏's avatar
饶先宏 已提交
4656 4657 4658 4659 4660
    $$ = verilogparseCreateBinopExpr(
        $2, //int op,
        $1, //HOBJECT expr0,
        $4, //HOBJECT expr1,
        $3  //IDListVarPtr attributes
饶先宏's avatar
饶先宏 已提交
4661
        );
饶先宏's avatar
饶先宏 已提交
4662 4663
    }
|   conditional_expression {
饶先宏's avatar
饶先宏 已提交
4664
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
4665 4666
    }
  ;
饶先宏's avatar
饶先宏 已提交
4667
*/
饶先宏's avatar
饶先宏 已提交
4668 4669

/*
4670 4671 4672
expression1 ::= expression
expression2 ::= expression
expression3 ::= expression
饶先宏's avatar
饶先宏 已提交
4673 4674 4675 4676
*/

lsb_constant_expression : 
    constant_expression {
4677
      $$ = $1;
饶先宏's avatar
饶先宏 已提交
4678 4679 4680 4681 4682
    }
  ;

mintypmax_expression :
    expression {
饶先宏's avatar
饶先宏 已提交
4683 4684
      $$.objcount = 1;
      $$.obj[0] = $1;
饶先宏's avatar
饶先宏 已提交
4685 4686
    }
|   expression ':' expression ':' expression {
饶先宏's avatar
饶先宏 已提交
4687 4688 4689 4690
      $$.objcount = 3;
      $$.obj[0] = $1;
      $$.obj[1] = $3;
      $$.obj[2] = $5;
饶先宏's avatar
饶先宏 已提交
4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720
    }
  ;

module_path_conditional_expression : 
    module_path_expression '?' attribute_instance_list
    module_path_expression ':' module_path_expression {
    }
  ;

module_path_expression :
    module_path_primary {
    }
|   unary_module_path_operator attribute_instance_list module_path_primary {
    }
|   module_path_expression binary_module_path_operator 
    attribute_instance_list module_path_expression {
    }
|   module_path_conditional_expression {
    }
  ;

module_path_mintypmax_expression :
    module_path_expression {
    }
|   module_path_expression ':' module_path_expression ':' module_path_expression {
    }
  ;

msb_constant_expression : 
    constant_expression {
4721
        $$ = $1;
饶先宏's avatar
饶先宏 已提交
4722 4723 4724 4725 4726 4727
    }
  ;

range_expression :
    expression {
    }
饶先宏's avatar
饶先宏 已提交
4728
|   constant_expression ':' lsb_constant_expression {
饶先宏's avatar
饶先宏 已提交
4729
    }
饶先宏's avatar
饶先宏 已提交
4730
|   expression STARTPLUSWIDTH width_constant_expression {
饶先宏's avatar
饶先宏 已提交
4731
    }
饶先宏's avatar
饶先宏 已提交
4732
|   expression STARTMINUSWIDTH width_constant_expression {
饶先宏's avatar
饶先宏 已提交
4733 4734 4735 4736 4737
    }
  ;

width_constant_expression : 
    constant_expression {
饶先宏's avatar
饶先宏 已提交
4738
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
4739 4740 4741
    }
  ;

4742 4743 4744
/*
A.8.4 Primaries
*/
饶先宏's avatar
饶先宏 已提交
4745 4746
constant_primary :
    number {
饶先宏's avatar
饶先宏 已提交
4747 4748 4749 4750
        $$ = verilogparseCreateValueExpr(
            EXPRTYPE_NUMBER, //int exprtype,
            $1, //IConstStringVar* value,
            NULL //IDListVarPtr attributes
4751
        );
饶先宏's avatar
饶先宏 已提交
4752 4753
    }
|   parameter_identifier {
饶先宏's avatar
饶先宏 已提交
4754 4755 4756 4757 4758 4759 4760
        $$ = verilogparseCreateParamExpr(
            EXPRTYPE_PARAM, //int exprtype,
            $1, //IConstStringVar* name,
            RANGE_TYPE_NONE, //int range_type,
            NULL, //HOBJECT range_msb,
            NULL, //HOBJECT range_lsb,
            NULL //IDListVarPtr attributes
4761
        );
饶先宏's avatar
饶先宏 已提交
4762 4763
    }
|   parameter_identifier '[' constant_range_expression ']' {
饶先宏's avatar
饶先宏 已提交
4764 4765 4766 4767 4768 4769 4770 4771
        $$ = verilogparseCreateParamExpr(
            EXPRTYPE_PARAM, //int exprtype,
            $1, //IConstStringVar* name,
            $3.type, //int range_type,
            $3.obj[0], //HOBJECT range_msb,
            $3.obj[1], //HOBJECT range_lsb,
            NULL //IDListVarPtr attributes
        );
饶先宏's avatar
饶先宏 已提交
4772 4773
    }
|   specparam_identifier  {
饶先宏's avatar
饶先宏 已提交
4774
        $$ = NULL;
饶先宏's avatar
饶先宏 已提交
4775 4776
    }
|   specparam_identifier '[' constant_range_expression ']' {
饶先宏's avatar
饶先宏 已提交
4777
        $$ = NULL;
饶先宏's avatar
饶先宏 已提交
4778 4779
    }
|   constant_concatenation {
饶先宏's avatar
饶先宏 已提交
4780
        $$ = NULL;
饶先宏's avatar
饶先宏 已提交
4781 4782
    }
|   constant_multiple_concatenation {
饶先宏's avatar
饶先宏 已提交
4783
        $$ = NULL;
饶先宏's avatar
饶先宏 已提交
4784 4785
    }
|   constant_function_call {
饶先宏's avatar
饶先宏 已提交
4786
        $$ = NULL;
饶先宏's avatar
饶先宏 已提交
4787 4788
    }
|   constant_system_function_call {
饶先宏's avatar
饶先宏 已提交
4789
        $$ = NULL;
饶先宏's avatar
饶先宏 已提交
4790 4791
    }
|   '(' constant_mintypmax_expression ')' {
饶先宏's avatar
饶先宏 已提交
4792
        $$ = $2;
饶先宏's avatar
饶先宏 已提交
4793 4794
    }
|   string {
饶先宏's avatar
饶先宏 已提交
4795 4796 4797 4798
        $$ = verilogparseCreateValueExpr(
            EXPRTYPE_STRING, //int exprtype,
            $1, //IConstStringVar* value,
            NULL //IDListVarPtr attributes
4799
        );
饶先宏's avatar
饶先宏 已提交
4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820
    }
  ;

module_path_primary :
    number {
    }
|   identifier {
    }
|   module_path_concatenation {
    }
|   module_path_multiple_concatenation {
    }
|   function_call {
    }
|   system_function_call {
    }
|   '(' module_path_mintypmax_expression ')' {
    }
  ;

array_element_select :
4821
     %empty   {
饶先宏's avatar
饶先宏 已提交
4822 4823 4824 4825 4826 4827 4828 4829
    }
|   '[' expression ']' {
    }
|   array_element_select '[' expression ']' {
    }
  ;

range_expression_option :
4830
      %empty  {
饶先宏's avatar
饶先宏 已提交
4831
    }
饶先宏's avatar
饶先宏 已提交
4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845
| '[' range_expression ']' {
    }
  ;

range_expression_list :
      %empty  {
    }
| '[' range_expression ']' {
    }
| range_expression_list '[' range_expression ']' {
     /*
     此时要判断前面的作为array_element_select只能由一个表达式组成,
     不能是两个表达式表示的段选择
     */
饶先宏's avatar
饶先宏 已提交
4846 4847 4848
    }
  ;

饶先宏's avatar
饶先宏 已提交
4849 4850 4851 4852
/*
  不满足LALR(1)的文法,只能够由后期判断了
|   hierarchical_identifier array_element_select range_expression_option {
    }
饶先宏's avatar
饶先宏 已提交
4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872

    hierachical_header:
    identifier '.' {
    }
|   identifier '[' constant_expression ']' '.' {
    }
|   hierachical_header identifier '.' {
    }
|   hierachical_header identifier '[' constant_expression ']' '.' {
    }
 ;
    
hierarchical_identifier : 
  hierachical_header identifier {
  }
| identifier {
  }
 ;
*/

饶先宏's avatar
饶先宏 已提交
4873
hierarchical_identifier_part :
饶先宏's avatar
饶先宏 已提交
4874
    identifier {
饶先宏's avatar
饶先宏 已提交
4875
    $$ = verilogparseCreateVarSel(
4876 4877 4878 4879 4880
        $1, //const char * name,
        RANGE_TYPE_NONE, //int range_type,
        NULL, //HOBJECT range_msb,
        NULL  //HOBJECT range_lsb
       );
饶先宏's avatar
饶先宏 已提交
4881 4882
    }
|   identifier '[' expression ']' {
饶先宏's avatar
饶先宏 已提交
4883
    $$ = verilogparseCreateVarSel(
4884 4885 4886 4887 4888
        $1, //const char * name,
        RANGE_TYPE_BITSELECT, //int range_type,
        $3,  // HOBJECT range_msb,
        NULL //HOBJECT range_lsb
       );
饶先宏's avatar
饶先宏 已提交
4889 4890
    }
|   identifier '[' expression ':' expression ']' {
饶先宏's avatar
饶先宏 已提交
4891
    $$ = verilogparseCreateVarSel(
4892 4893 4894 4895 4896
        $1, //const char * name,
        RANGE_TYPE_PARTSELECT, //int range_type,
        $3,  // HOBJECT range_msb,
        $5   //HOBJECT range_lsb
       );
饶先宏's avatar
饶先宏 已提交
4897 4898
    }
|   identifier '[' expression STARTPLUSWIDTH expression ']' {
饶先宏's avatar
饶先宏 已提交
4899
    $$ = verilogparseCreateVarSel(
4900 4901 4902 4903 4904
        $1, //const char * name,
        RANGE_TYPE_STARTPLUSWIDTH, //int range_type,
        $3,  // HOBJECT range_msb,
        $5   //HOBJECT range_lsb
       );
饶先宏's avatar
饶先宏 已提交
4905 4906
    }
|   identifier '[' expression STARTMINUSWIDTH expression ']' {
饶先宏's avatar
饶先宏 已提交
4907
    $$ = verilogparseCreateVarSel(
4908 4909 4910 4911 4912
        $1, //const char * name,
        RANGE_TYPE_STARTMINUSWIDTH, //int range_type,
        $3,  // HOBJECT range_msb,
        $5   //HOBJECT range_lsb
       );
饶先宏's avatar
饶先宏 已提交
4913 4914 4915 4916
    }
  ;

var :
饶先宏's avatar
饶先宏 已提交
4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932
  hierarchical_identifier {
    $$.type = RANGE_TYPE_NONE;
    $$.obj[0] = $1;
    $$.obj[1] = dlistCreate();
  }
|  var '[' expression ']' {
    $$ = $1;
    $$.type = RANGE_TYPE_BITSELECT;
    dlistAppendItem($$.obj[1], $3);
    dlistAppendItem($$.obj[1], $3);
  }
|  var '[' expression ':' expression ']' {
    $$ = $1;
    $$.type = RANGE_TYPE_PARTSELECT; /*只记录最后一次的类型,反正这种情况只有最后一次才会出现*/
    dlistAppendItem($$.obj[1], $3);
    dlistAppendItem($$.obj[1], $5);
饶先宏's avatar
饶先宏 已提交
4933
    }
饶先宏's avatar
饶先宏 已提交
4934
|  var '[' expression STARTPLUSWIDTH expression ']' {
饶先宏's avatar
饶先宏 已提交
4935
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955
    $$.type = RANGE_TYPE_STARTPLUSWIDTH;
    dlistAppendItem($$.obj[1], $3);
    dlistAppendItem($$.obj[1], $5);
    }
|  var '[' expression STARTMINUSWIDTH expression ']' {
    $$ = $1;
    $$.type = RANGE_TYPE_STARTMINUSWIDTH;
    dlistAppendItem($$.obj[1], $3);
    dlistAppendItem($$.obj[1], $5);
    }
  ;

hierarchical_identifier :
    hierarchical_identifier_part {
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
    }
|   hierarchical_identifier '.' hierarchical_identifier_part {
    $$ = $1;
    dlistAppendItem($$, $3);
饶先宏's avatar
饶先宏 已提交
4956 4957
    }
  ;
饶先宏's avatar
饶先宏 已提交
4958

饶先宏's avatar
饶先宏 已提交
4959 4960
/*
    hierarchical_identifier array_element_select range_expression_option
饶先宏's avatar
饶先宏 已提交
4961
*/
饶先宏's avatar
饶先宏 已提交
4962

饶先宏's avatar
饶先宏 已提交
4963 4964
primary :
    number {
饶先宏's avatar
饶先宏 已提交
4965 4966 4967 4968
        $$ = verilogparseCreateValueExpr(
            EXPRTYPE_NUMBER, //int exprtype,
            $1, //IConstStringVar* value,
            NULL //IDListVarPtr attributes
饶先宏's avatar
饶先宏 已提交
4969
        );
饶先宏's avatar
饶先宏 已提交
4970
    }
饶先宏's avatar
饶先宏 已提交
4971
|   var {
饶先宏's avatar
饶先宏 已提交
4972 4973 4974 4975 4976 4977 4978 4979
        $$ = verilogparseCreateVariableExpr(
            EXPRTYPE_HIERARCHICAL_IDENT,
            $1.obj[0], //IDListVarPtr hierarchical_identifier,
            $1.obj[1], //IDListVarPtr elementselect,
            $1.type, //int range_type,
            NULL, //HOBJECT range_msb,
            NULL, //HOBJECT range_lsb,
            NULL //IDListVarPtr attributes
饶先宏's avatar
饶先宏 已提交
4980
        );
饶先宏's avatar
饶先宏 已提交
4981 4982
    }
|   concatenation {
饶先宏's avatar
饶先宏 已提交
4983 4984
    $$ = NULL;
    yyerror("no support for concatenation");
饶先宏's avatar
饶先宏 已提交
4985 4986
    }
|   multiple_concatenation {
饶先宏's avatar
饶先宏 已提交
4987 4988
    $$ = NULL;
    yyerror("no support for multiple_concatenation");
饶先宏's avatar
饶先宏 已提交
4989
    }
4990 4991

|   function_call{ 
饶先宏's avatar
饶先宏 已提交
4992 4993
    $$ = NULL;
    yyerror("no support for function_call");
饶先宏's avatar
饶先宏 已提交
4994 4995
    }
|   system_function_call {
饶先宏's avatar
饶先宏 已提交
4996 4997
    $$ = NULL;
    yyerror("no support for system_function_call");
饶先宏's avatar
饶先宏 已提交
4998
    }
4999

饶先宏's avatar
饶先宏 已提交
5000
|   '(' mintypmax_expression ')' {
饶先宏's avatar
饶先宏 已提交
5001 5002 5003 5004
    $$ = $2.obj[0];
    if ($2.objcount > 1) {
        yyerror("no supprot for mintypmax_expression when objcount > 1");
    }
饶先宏's avatar
饶先宏 已提交
5005 5006
    }
|   string {
饶先宏's avatar
饶先宏 已提交
5007 5008 5009 5010
        $$ = verilogparseCreateValueExpr(
            EXPRTYPE_STRING, //int exprtype,
            $1, //IConstStringVar* value,
            NULL //IDListVarPtr attributes
饶先宏's avatar
饶先宏 已提交
5011
        );
饶先宏's avatar
饶先宏 已提交
5012 5013 5014
    }
  ;

5015 5016 5017
/*
A.8.5 Expression left-side values
*/
饶先宏's avatar
饶先宏 已提交
5018
const_array_element_select :
5019
     %empty   {
饶先宏's avatar
饶先宏 已提交
5020 5021 5022 5023 5024 5025 5026 5027
    }
|   '[' constant_expression ']' {
    }
|   const_array_element_select '[' constant_expression ']' {
    }
  ;

constant_range_expression_option :
5028
     %empty   {
饶先宏's avatar
饶先宏 已提交
5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061
    }
| range_expression {
    }
  ;

net_lvalue_list :
    net_lvalue {
    }
|   net_lvalue_list ',' net_lvalue {
    }
  ;

net_lvalue :
    hierarchical_net_identifier const_array_element_select constant_range_expression_option {
    }
|   '{' net_lvalue_list '}' {
    }
  ;

variable_lvalue_list :
    variable_lvalue {
    }
|   variable_lvalue_list ',' variable_lvalue {
    }
  ;

variable_lvalue :
    hierarchical_variable_identifier array_element_select range_expression_option {
    }
|   '{' variable_lvalue_list '}' {
    }
  ;

5062 5063 5064
/*
A.8.6 Operators
*/
饶先宏's avatar
饶先宏 已提交
5065

5066
unary_operator :
饶先宏's avatar
饶先宏 已提交
5067
    '+'  {
饶先宏's avatar
饶先宏 已提交
5068
    $$ = OP_PLUS;
饶先宏's avatar
饶先宏 已提交
5069 5070
    }
|   '-'  {
饶先宏's avatar
饶先宏 已提交
5071
    $$ = OP_MINUS;
饶先宏's avatar
饶先宏 已提交
5072 5073
    }
|   '!'  {
饶先宏's avatar
饶先宏 已提交
5074
    $$ = OP_L_NOT;
饶先宏's avatar
饶先宏 已提交
5075 5076
    }
|   '~'  {
饶先宏's avatar
饶先宏 已提交
5077
    $$ = OP_B_NOT;
饶先宏's avatar
饶先宏 已提交
5078 5079
    }
|   '&'  {
饶先宏's avatar
饶先宏 已提交
5080
    $$ = OP_B_AND;
饶先宏's avatar
饶先宏 已提交
5081 5082
    }
|   B_NAND {
饶先宏's avatar
饶先宏 已提交
5083
    $$ = OP_B_NAND;
饶先宏's avatar
饶先宏 已提交
5084 5085
    } 
|   '|' {
饶先宏's avatar
饶先宏 已提交
5086
    $$ = OP_B_OR;
饶先宏's avatar
饶先宏 已提交
5087 5088
    } 
|   B_NOR {
饶先宏's avatar
饶先宏 已提交
5089
    $$ = OP_B_NOR;
饶先宏's avatar
饶先宏 已提交
5090 5091
    } 
|   '^' {
饶先宏's avatar
饶先宏 已提交
5092
    $$ = OP_B_XOR;
饶先宏's avatar
饶先宏 已提交
5093 5094
    } 
|   B_EQU  {
饶先宏's avatar
饶先宏 已提交
5095
    $$ = OP_B_EQU;
饶先宏's avatar
饶先宏 已提交
5096 5097
    }
  ;
饶先宏's avatar
饶先宏 已提交
5098

5099
binary_operator :
饶先宏's avatar
饶先宏 已提交
5100
    '+' {
饶先宏's avatar
饶先宏 已提交
5101
    $$ = OP_PLUS;
饶先宏's avatar
饶先宏 已提交
5102 5103
    }
|   '-' {
饶先宏's avatar
饶先宏 已提交
5104
    $$ = OP_MINUS;
饶先宏's avatar
饶先宏 已提交
5105 5106
    }
|   '*'  {
饶先宏's avatar
饶先宏 已提交
5107
    $$ = OP_MUL;
饶先宏's avatar
饶先宏 已提交
5108 5109
    }
|   '/' {
饶先宏's avatar
饶先宏 已提交
5110
    $$ = OP_DIV;
饶先宏's avatar
饶先宏 已提交
5111 5112
    } 
|   '%' {
饶先宏's avatar
饶先宏 已提交
5113
    $$ = OP_MOD;
饶先宏's avatar
饶先宏 已提交
5114 5115
    } 
|   L_EQ {
饶先宏's avatar
饶先宏 已提交
5116
    $$ = OP_L_EQ;
饶先宏's avatar
饶先宏 已提交
5117 5118
    }
|   L_NEQ {
饶先宏's avatar
饶先宏 已提交
5119
    $$ = OP_L_NEQ;
饶先宏's avatar
饶先宏 已提交
5120 5121
    }
|   C_EQ {
饶先宏's avatar
饶先宏 已提交
5122
    $$ = OP_C_EQ;
饶先宏's avatar
饶先宏 已提交
5123 5124
    } 
|   C_NEQ {
饶先宏's avatar
饶先宏 已提交
5125
    $$ = OP_C_NEQ;
饶先宏's avatar
饶先宏 已提交
5126 5127
    } 
|   L_AND  {
饶先宏's avatar
饶先宏 已提交
5128
    $$ = OP_L_AND;
饶先宏's avatar
饶先宏 已提交
5129 5130
    }
|   L_OR  {
饶先宏's avatar
饶先宏 已提交
5131
    $$ = OP_L_OR;
饶先宏's avatar
饶先宏 已提交
5132 5133
    }
|   POW {
饶先宏's avatar
饶先宏 已提交
5134
    $$ = OP_POW;
饶先宏's avatar
饶先宏 已提交
5135 5136
    }
|   '<' {
饶先宏's avatar
饶先宏 已提交
5137
    $$ = OP_LT;
饶先宏's avatar
饶先宏 已提交
5138 5139
    } 
|   LTE  {
饶先宏's avatar
饶先宏 已提交
5140
    $$ = OP_LTE;
饶先宏's avatar
饶先宏 已提交
5141 5142
    }
|   '>' {
饶先宏's avatar
饶先宏 已提交
5143
    $$ = OP_GT;
饶先宏's avatar
饶先宏 已提交
5144 5145
    } 
|   GTE  {
饶先宏's avatar
饶先宏 已提交
5146
    $$ = OP_GTE;
饶先宏's avatar
饶先宏 已提交
5147 5148
    }
|   '&' {
饶先宏's avatar
饶先宏 已提交
5149
    $$ = OP_B_AND;
饶先宏's avatar
饶先宏 已提交
5150 5151
    } 
|   '|' {
饶先宏's avatar
饶先宏 已提交
5152
    $$ = OP_B_OR;
饶先宏's avatar
饶先宏 已提交
5153 5154
    } 
|   '^' {
饶先宏's avatar
饶先宏 已提交
5155
    $$ = OP_B_XOR;
饶先宏's avatar
饶先宏 已提交
5156 5157
    } 
|   B_EQU {
饶先宏's avatar
饶先宏 已提交
5158
    $$ = OP_B_EQU;
饶先宏's avatar
饶先宏 已提交
5159 5160
    }
|   LSR  {
饶先宏's avatar
饶先宏 已提交
5161
    $$ = OP_LSR;
饶先宏's avatar
饶先宏 已提交
5162 5163
    }
|   LSL  {
饶先宏's avatar
饶先宏 已提交
5164
    $$ = OP_LSL;
饶先宏's avatar
饶先宏 已提交
5165 5166
    }
|   ASR {
饶先宏's avatar
饶先宏 已提交
5167
    $$ = OP_ASR;
饶先宏's avatar
饶先宏 已提交
5168 5169
    } 
|   ASL {
饶先宏's avatar
饶先宏 已提交
5170
    $$ = OP_ASL;
饶先宏's avatar
饶先宏 已提交
5171
    }
5172
  ;
饶先宏's avatar
饶先宏 已提交
5173

5174
unary_module_path_operator :
饶先宏's avatar
饶先宏 已提交
5175
    '!'  {
饶先宏's avatar
饶先宏 已提交
5176
    $$ = OP_L_NOT;
饶先宏's avatar
饶先宏 已提交
5177 5178
    }
|   '~'  {
饶先宏's avatar
饶先宏 已提交
5179
    $$ = OP_B_NOT;
饶先宏's avatar
饶先宏 已提交
5180 5181
    }
|   '&'  {
饶先宏's avatar
饶先宏 已提交
5182
    $$ = OP_B_AND;
饶先宏's avatar
饶先宏 已提交
5183 5184
    }
|   B_NAND  {
饶先宏's avatar
饶先宏 已提交
5185
    $$ = OP_B_NAND;
饶先宏's avatar
饶先宏 已提交
5186 5187
    }
|   '|'  {
饶先宏's avatar
饶先宏 已提交
5188
    $$ = OP_B_OR;
饶先宏's avatar
饶先宏 已提交
5189 5190
    }
|   B_NOR  {
饶先宏's avatar
饶先宏 已提交
5191
    $$ = OP_B_NOR;
饶先宏's avatar
饶先宏 已提交
5192 5193
    }
|   '^'  {
饶先宏's avatar
饶先宏 已提交
5194
    $$ = OP_B_XOR;
饶先宏's avatar
饶先宏 已提交
5195 5196
    }
|   B_EQU  {
饶先宏's avatar
饶先宏 已提交
5197
    $$ = OP_B_EQU;
饶先宏's avatar
饶先宏 已提交
5198
    }
5199
  ;
饶先宏's avatar
饶先宏 已提交
5200

5201
binary_module_path_operator :
饶先宏's avatar
饶先宏 已提交
5202
    L_EQ  {
饶先宏's avatar
饶先宏 已提交
5203
    $$ = OP_L_EQ;
饶先宏's avatar
饶先宏 已提交
5204 5205
    }
|   L_NEQ {
饶先宏's avatar
饶先宏 已提交
5206
    $$ = OP_L_NEQ;
饶先宏's avatar
饶先宏 已提交
5207 5208
    } 
|   L_AND {
饶先宏's avatar
饶先宏 已提交
5209
    $$ = OP_L_AND;
饶先宏's avatar
饶先宏 已提交
5210 5211
    } 
|   L_OR {
饶先宏's avatar
饶先宏 已提交
5212
    $$ = OP_L_OR;
饶先宏's avatar
饶先宏 已提交
5213 5214
    } 
|   '&' {
饶先宏's avatar
饶先宏 已提交
5215
    $$ = OP_B_AND;
饶先宏's avatar
饶先宏 已提交
5216 5217
    }
|   '|'  {
饶先宏's avatar
饶先宏 已提交
5218
    $$ = OP_B_OR;
饶先宏's avatar
饶先宏 已提交
5219 5220
    }
|   '^'  {
饶先宏's avatar
饶先宏 已提交
5221
    $$ = OP_B_XOR;
饶先宏's avatar
饶先宏 已提交
5222 5223
    }
|   B_EQU  {
饶先宏's avatar
饶先宏 已提交
5224
    $$ = OP_B_EQU;
饶先宏's avatar
饶先宏 已提交
5225
    }
5226
 ;
饶先宏's avatar
饶先宏 已提交
5227

5228 5229 5230
/*
A.8.7 Numbers
*/
饶先宏's avatar
饶先宏 已提交
5231
/*
5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269
number ::=
decimal_number
| octal_number
| binary_number
| hex_number
| real_number
real_number ::=
unsigned_number . unsigned_number
| unsigned_number [ . unsigned_number ] exp [ sign ] unsigned_number
exp ::= e | E
decimal_number ::=
unsigned_number
| [ size ] decimal_base unsigned_number
| [ size ] decimal_base x_digit { _ }
| [ size ] decimal_base z_digit { _ }
binary_number ::= [ size ] binary_base binary_value
octal_number ::= [ size ] octal_base octal_value
hex_number ::= [ size ] hex_base hex_value
sign ::= + | -
size ::= non_zero_unsigned_number
non_zero_unsigned_number2 ::= non_zero_decimal_digit { _ | decimal_digit}
unsigned_number2 ::= decimal_digit { _ | decimal_digit }
binary_value2 ::= binary_digit { _ | binary_digit }
octal_value2 ::= octal_digit { _ | octal_digit }
hex_value2 ::= hex_digit { _ | hex_digit }
decimal_base2 ::= '[s|S]d | '[s|S]D
binary_base2 ::= '[s|S]b | '[s|S]B
octal_base2 ::= '[s|S]o | '[s|S]O
hex_base2 ::= '[s|S]h | '[s|S]H
non_zero_decimal_digit ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
decimal_digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
binary_digit ::= x_digit | z_digit | 0 | 1
octal_digit ::= x_digit | z_digit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
hex_digit ::=
x_digit | z_digit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
| a | b | c | d | e | f | A | B | C | D | E | F
x_digit ::= x | X
z_digit ::= z | Z | ?
饶先宏's avatar
饶先宏 已提交
5270 5271 5272 5273
*/

unsigned_number :
  UNSIGNED_NUMBER {
5274
  $$ = $1;
饶先宏's avatar
饶先宏 已提交
5275 5276 5277 5278 5279
  }
;

number :
    NUM_REAL{
5280
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
5281
    }
5282 5283 5284
|   unsigned_number {
    $$ = $1;
    }
饶先宏's avatar
饶先宏 已提交
5285
|   BIN_BASE BIN_VALUE {
饶先宏's avatar
饶先宏 已提交
5286 5287 5288
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        objectRelease($2);
饶先宏's avatar
饶先宏 已提交
5289 5290
    }
|   HEX_BASE HEX_VALUE {
饶先宏's avatar
饶先宏 已提交
5291 5292 5293
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        objectRelease($2);
饶先宏's avatar
饶先宏 已提交
5294 5295
    }
|   OCT_BASE OCT_VALUE {
饶先宏's avatar
饶先宏 已提交
5296 5297 5298
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        objectRelease($2);
饶先宏's avatar
饶先宏 已提交
5299
    }
饶先宏's avatar
饶先宏 已提交
5300
|   DEC_BASE DEC_VALUE {
饶先宏's avatar
饶先宏 已提交
5301 5302 5303
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        objectRelease($2);
饶先宏's avatar
饶先宏 已提交
5304 5305
    }
|   UNSIGNED_NUMBER BIN_BASE BIN_VALUE {
饶先宏's avatar
饶先宏 已提交
5306 5307 5308 5309 5310
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        hdl4seConstStringAppend($$, conststringFromVar($3));
        objectRelease($2);
        objectRelease($3);
饶先宏's avatar
饶先宏 已提交
5311 5312
    }
|   UNSIGNED_NUMBER HEX_BASE HEX_VALUE {
饶先宏's avatar
饶先宏 已提交
5313 5314 5315 5316 5317
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        hdl4seConstStringAppend($$, conststringFromVar($3));
        objectRelease($2);
        objectRelease($3);
饶先宏's avatar
饶先宏 已提交
5318 5319
    }
|   UNSIGNED_NUMBER OCT_BASE OCT_VALUE {
饶先宏's avatar
饶先宏 已提交
5320 5321 5322 5323 5324
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        hdl4seConstStringAppend($$, conststringFromVar($3));
        objectRelease($2);
        objectRelease($3);
饶先宏's avatar
饶先宏 已提交
5325
    }
饶先宏's avatar
饶先宏 已提交
5326
|   UNSIGNED_NUMBER DEC_BASE DEC_VALUE{
饶先宏's avatar
饶先宏 已提交
5327 5328 5329 5330 5331
        $$ = $1;
        hdl4seConstStringAppend($$, conststringFromVar($2));
        hdl4seConstStringAppend($$, conststringFromVar($3));
        objectRelease($2);
        objectRelease($3);
饶先宏's avatar
饶先宏 已提交
5332 5333 5334
    }
;

饶先宏's avatar
饶先宏 已提交
5335

5336 5337 5338
/*
A.8.8 Strings
*/
饶先宏's avatar
饶先宏 已提交
5339 5340
string : 
    STRING {
5341
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
5342 5343 5344
    }
  ;

5345 5346 5347 5348 5349 5350
/* string ::= " { Any_ASCII_Characters_except_new_line } " */
/*
A.9 General
A.9.1 Attributes
*/
attribute_instance_list :
5351
     %empty   {
饶先宏's avatar
饶先宏 已提交
5352
        $$ = dlistCreate();
5353 5354
    }
|   attribute_instance_list attribute_instance {
5355
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
5356
    dlistConcat($$, $2);
5357 5358
    }
|   attribute_instance {
5359
        $$ = $1;
5360 5361
    }
 ;
饶先宏's avatar
饶先宏 已提交
5362

5363 5364
attribute_instance : 
    ATTRIBUTE_START attribute_instance_spec_list ATTRIBUTE_END {
5365
    $$ = $2;
5366 5367 5368 5369
    }
 ;
attribute_instance_spec_list : 
    attribute_instance_spec_list ',' attr_spec {
5370
    $$ = $1;
饶先宏's avatar
饶先宏 已提交
5371
    dlistAppendItem($$, $3);
5372 5373
    }
|   attr_spec {
饶先宏's avatar
饶先宏 已提交
5374 5375
    $$ = dlistCreate();
    dlistAppendItem($$, $1);
5376 5377
    }
 ;
饶先宏's avatar
饶先宏 已提交
5378

5379 5380
attr_spec :
    attr_name {
5381
    $$ = verilogparseCreateAttrSpec($1, NULL);
饶先宏's avatar
饶先宏 已提交
5382
    objectRelease($1);
5383 5384
    }
|   attr_name  '=' constant_expression {
5385
    $$ = verilogparseCreateAttrSpec($1, $3);
饶先宏's avatar
饶先宏 已提交
5386
    objectRelease($1);
5387
    objectRelease($3);
5388 5389
    }
  ;
饶先宏's avatar
饶先宏 已提交
5390

5391 5392
attr_name : 
    identifier {
5393
        $$ = $1;
5394 5395 5396 5397 5398
    }
 ;
/*
A.9.2 Comments
*/
饶先宏's avatar
饶先宏 已提交
5399

5400 5401 5402 5403 5404 5405 5406 5407
/*
comment ::=
one_line_comment
| block_comment
one_line_comment ::= // comment_text \n
block_comment ::= / * comment_text * /
comment_text ::= { Any_ASCII_character }
*/
饶先宏's avatar
饶先宏 已提交
5408

5409 5410 5411
/*
A.9.3 Identifiers
*/
饶先宏's avatar
饶先宏 已提交
5412

5413 5414 5415 5416
block_identifier : 
    identifier {
    }
 ;
饶先宏's avatar
饶先宏 已提交
5417

5418 5419 5420 5421
cell_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5422

5423 5424 5425
config_identifier :
    identifier {
    }
饶先宏's avatar
饶先宏 已提交
5426
  ;
饶先宏's avatar
饶先宏 已提交
5427

5428 5429 5430 5431
event_identifier : 
    identifier  {
    }
 ;
饶先宏's avatar
饶先宏 已提交
5432

5433 5434 5435 5436
function_identifier :  
    identifier {
    }
 ;
饶先宏's avatar
饶先宏 已提交
5437

5438 5439 5440 5441
gate_instance_identifier : 
    identifier  {
    }
 ;
饶先宏's avatar
饶先宏 已提交
5442

5443 5444 5445 5446
generate_block_identifier : 
    identifier {
    }
 ;
饶先宏's avatar
饶先宏 已提交
5447

5448 5449
genvar_identifier : 
    identifier {
饶先宏's avatar
饶先宏 已提交
5450
    }
5451
 ;
饶先宏's avatar
饶先宏 已提交
5452

5453 5454 5455 5456
hierarchical_block_identifier : 
    hierarchical_identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5457

5458 5459 5460 5461
hierarchical_event_identifier : 
    hierarchical_identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5462

5463 5464 5465 5466
hierarchical_function_identifier : 
    hierarchical_identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5467

饶先宏's avatar
饶先宏 已提交
5468
/*
5469
hierachical_header:
饶先宏's avatar
饶先宏 已提交
5470
    identifier '.' {
5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482
    }
|   identifier '[' constant_expression ']' '.' {
    }
|   hierachical_header identifier '.' {
    }
|   hierachical_header identifier '[' constant_expression ']' '.' {
    }
 ;
    
hierarchical_identifier : 
  hierachical_header identifier {
  }
饶先宏's avatar
饶先宏 已提交
5483 5484
| identifier {
  }
5485
 ;
饶先宏's avatar
饶先宏 已提交
5486
*/
饶先宏's avatar
饶先宏 已提交
5487

5488 5489 5490 5491
hierarchical_net_identifier : 
    hierarchical_identifier {
    }
 ;
饶先宏's avatar
饶先宏 已提交
5492

5493 5494 5495 5496
hierarchical_parameter_identifier : 
    hierarchical_identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5497

5498 5499 5500 5501
hierarchical_variable_identifier : 
    hierarchical_identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5502

5503 5504 5505 5506
hierarchical_task_identifier : 
    hierarchical_identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5507

5508
identifier :
饶先宏's avatar
饶先宏 已提交
5509
    SIMPLE_ID {
5510
        $$ = $1;
5511
    }
饶先宏's avatar
饶先宏 已提交
5512
|   ESCAPED_ID {
5513
        $$ = $1;
饶先宏's avatar
饶先宏 已提交
5514
    }
5515
  ;
饶先宏's avatar
饶先宏 已提交
5516

5517 5518 5519 5520
inout_port_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5521

5522 5523 5524 5525
input_port_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5526

5527 5528 5529 5530
instance_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5531

5532 5533 5534 5535
library_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5536

5537 5538
module_identifier : 
    identifier {
5539
    $$ = $1;
5540 5541
    }
  ;
饶先宏's avatar
饶先宏 已提交
5542

5543 5544
module_instance_identifier : 
    identifier {
饶先宏's avatar
饶先宏 已提交
5545
    $$ = $1;
5546 5547 5548
    }
 ;
net_identifier : identifier {
饶先宏's avatar
饶先宏 已提交
5549
    $$ = $1;
5550 5551
    }
  ;
饶先宏's avatar
饶先宏 已提交
5552

5553 5554 5555 5556
output_port_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5557

5558 5559
parameter_identifier : 
    identifier {
5560
      $$ = $1;
饶先宏's avatar
饶先宏 已提交
5561
    }
5562
  ;
饶先宏's avatar
饶先宏 已提交
5563

5564 5565
port_identifier : 
    identifier {
饶先宏's avatar
饶先宏 已提交
5566
    $$ = $1;
5567 5568
    }
  ;
饶先宏's avatar
饶先宏 已提交
5569

5570 5571 5572 5573
real_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5574

5575 5576 5577 5578
specparam_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5579

5580 5581 5582 5583
task_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5584

5585 5586 5587 5588
terminal_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5589

饶先宏's avatar
饶先宏 已提交
5590
/* handle by preprocess
5591 5592 5593 5594
text_macro_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5595
*/
饶先宏's avatar
饶先宏 已提交
5596

5597 5598
topmodule_identifier : 
    identifier {
5599
    $$ = $1;
5600 5601
    }
  ;
饶先宏's avatar
饶先宏 已提交
5602

5603 5604 5605 5606
udp_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5607

5608 5609 5610 5611 5612 5613 5614 5615
udp_instance_identifier : 
    identifier {
    }
  ;
variable_identifier : 
    identifier {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5616

5617 5618 5619
/*
A.9.4 White space
*/
饶先宏's avatar
饶先宏 已提交
5620
/*
5621 5622 5623 5624 5625 5626 5627 5628 5629 5630
white_space : 
    space  {
    }
|   tab {
    }
|   newline {
    }
|   eof {
    }
  ;
饶先宏's avatar
饶先宏 已提交
5631
*/
饶先宏's avatar
饶先宏 已提交
5632
%%