2008-06-10 01:25:10 +00:00
|
|
|
// -*- C++ -*-
|
2006-08-26 11:35:28 +00:00
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: Verilator: Bison grammer file
|
|
|
|
//
|
2008-04-25 12:14:27 +00:00
|
|
|
// Code available from: http://www.veripool.org/verilator
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2009-01-02 16:47:39 +00:00
|
|
|
// Copyright 2003-2009 by Wilson Snyder. This program is free software; you can
|
2006-08-26 11:35:28 +00:00
|
|
|
// redistribute it and/or modify it under the terms of either the GNU
|
2009-05-04 21:07:57 +00:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
// Verilator is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
// Original code here by Paul Wasson and Duane Galbi
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
%{
|
2008-06-30 17:11:25 +00:00
|
|
|
#include <cstdio>
|
2008-05-28 19:58:18 +00:00
|
|
|
#include <cstdlib>
|
2006-08-26 11:35:28 +00:00
|
|
|
#include <cstdarg>
|
2008-05-28 19:58:18 +00:00
|
|
|
#include <cstring>
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
#include "V3Read.h"
|
|
|
|
#include "V3Ast.h"
|
|
|
|
#include "V3Global.h"
|
|
|
|
|
2007-05-16 12:55:25 +00:00
|
|
|
#define YYERROR_VERBOSE 1
|
2008-09-17 15:11:09 +00:00
|
|
|
#define YYINITDEPTH 10000 // Older bisons ignore YYMAXDEPTH
|
2008-08-20 19:59:10 +00:00
|
|
|
#define YYMAXDEPTH 10000
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
// Pick up new lexer
|
|
|
|
#define yylex V3Read::yylex
|
2008-04-29 14:14:20 +00:00
|
|
|
#define PSLUNSUP(what) NULL; yyerrorf("Unsupported: PSL language feature not implemented");
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
extern void yyerror(char* errmsg);
|
|
|
|
extern void yyerrorf(const char* format, ...);
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
// Statics (for here only)
|
|
|
|
|
|
|
|
class V3Parse {
|
|
|
|
public:
|
|
|
|
static bool s_impliedDecl; // Allow implied wire declarations
|
|
|
|
static AstVarType s_varDecl; // Type for next signal declaration (reg/wire/etc)
|
|
|
|
static AstVarType s_varIO; // Type for next signal declaration (input/output/etc)
|
|
|
|
static bool s_varSigned; // Signed state for next signal declaration
|
|
|
|
static AstVar* s_varAttrp; // Current variable for attribute adding
|
|
|
|
static AstCase* s_caseAttrp; // Current case statement for attribute adding
|
|
|
|
static AstRange* s_varRangep; // Pointer to range for next signal declaration
|
|
|
|
static int s_pinNum; // Pin number currently parsing
|
2007-03-14 13:06:08 +00:00
|
|
|
static bool s_pinStar; // Encountered SystemVerilog .*
|
2006-08-26 11:35:28 +00:00
|
|
|
static string s_instModule; // Name of module referenced for instantiations
|
|
|
|
static AstPin* s_instParamp; // Parameters for instantiations
|
2008-10-10 23:02:27 +00:00
|
|
|
static int s_uniqueAttr; // Bitmask of unique/priority keywords
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
static AstVar* createVariable(FileLine* fileline, string name, AstRange* arrayp);
|
|
|
|
static AstNode* createSupplyExpr(FileLine* fileline, string name, int value);
|
|
|
|
static AstText* createTextQuoted(FileLine* fileline, string text);
|
2007-03-06 21:43:38 +00:00
|
|
|
static AstDisplay* createDisplayError(FileLine* fileline) {
|
|
|
|
AstDisplay* nodep = new AstDisplay(fileline,AstDisplayType::ERROR, "", NULL,NULL);
|
2007-05-12 16:29:25 +00:00
|
|
|
nodep->addNext(new AstStop(fileline));
|
2007-03-06 21:43:38 +00:00
|
|
|
return nodep;
|
|
|
|
}
|
2007-11-02 11:23:03 +00:00
|
|
|
static void setRange(AstRange* rangep) {
|
|
|
|
if (s_varRangep) { s_varRangep->deleteTree(); s_varRangep=NULL; } // It was cloned, so this is safe.
|
|
|
|
s_varRangep = rangep;
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
static string deQuote(FileLine* fileline, string text);
|
|
|
|
};
|
|
|
|
|
|
|
|
bool V3Parse::s_impliedDecl = false;
|
|
|
|
AstVarType V3Parse::s_varDecl = AstVarType::UNKNOWN;
|
|
|
|
AstVarType V3Parse::s_varIO = AstVarType::UNKNOWN;
|
|
|
|
bool V3Parse::s_varSigned = false;
|
|
|
|
AstRange* V3Parse::s_varRangep = NULL;
|
|
|
|
int V3Parse::s_pinNum = -1;
|
2007-03-14 13:06:08 +00:00
|
|
|
bool V3Parse::s_pinStar = false;
|
2006-08-26 11:35:28 +00:00
|
|
|
string V3Parse::s_instModule;
|
|
|
|
AstPin* V3Parse::s_instParamp = NULL;
|
|
|
|
AstVar* V3Parse::s_varAttrp = NULL;
|
|
|
|
AstCase* V3Parse::s_caseAttrp = NULL;
|
|
|
|
|
|
|
|
#define CRELINE() (V3Read::copyOrSameFileLine())
|
2007-05-16 12:55:25 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
#define VARRESET() { VARDECL(UNKNOWN); VARIO(UNKNOWN); VARSIGNED(false); VARRANGE(NULL); }
|
|
|
|
#define VARDECL(type) { V3Parse::s_varDecl = AstVarType::type; }
|
|
|
|
#define VARIO(type) { V3Parse::s_varIO = AstVarType::type; }
|
|
|
|
#define VARSIGNED(value) { V3Parse::s_varSigned = value; }
|
2007-11-02 11:23:03 +00:00
|
|
|
#define VARRANGE(rangep) { V3Parse::setRange(rangep); }
|
2007-05-16 12:55:25 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
#define INSTPREP(modname,paramsp) { V3Parse::s_impliedDecl = true; V3Parse::s_instModule = modname; V3Parse::s_instParamp = paramsp; }
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
|
|
|
class AstSenTree;
|
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
FileLine* fileline;
|
|
|
|
V3Number* nump;
|
|
|
|
string* strp;
|
|
|
|
int cint;
|
|
|
|
double cdouble;
|
2008-10-10 23:02:27 +00:00
|
|
|
V3UniqState uniqstate;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
AstNode* nodep;
|
|
|
|
|
|
|
|
AstAssignW* assignwp;
|
2009-01-06 16:03:57 +00:00
|
|
|
AstPull* pullp;
|
2006-08-26 11:35:28 +00:00
|
|
|
AstBegin* beginp;
|
|
|
|
AstCase* casep;
|
|
|
|
AstCaseItem* caseitemp;
|
2007-03-14 13:06:08 +00:00
|
|
|
AstCell* cellp;
|
2006-08-26 11:35:28 +00:00
|
|
|
AstConst* constp;
|
2007-01-30 15:51:16 +00:00
|
|
|
AstFunc* funcp;
|
2006-08-26 11:35:28 +00:00
|
|
|
AstModule* modulep;
|
2007-05-12 15:31:04 +00:00
|
|
|
AstNodeVarRef* varnodep;
|
|
|
|
AstParseRef* parserefp;
|
2006-08-26 11:35:28 +00:00
|
|
|
AstPin* pinp;
|
|
|
|
AstRange* rangep;
|
2008-11-20 12:55:54 +00:00
|
|
|
AstNodeSenItem* senitemp;
|
2006-08-26 11:35:28 +00:00
|
|
|
AstSenTree* sentreep;
|
|
|
|
AstVar* varp;
|
|
|
|
AstVarRef* varrefp;
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
// When writing Bison patterns we use yTOKEN instead of "token",
|
|
|
|
// so Bison will error out on unknown "token"s.
|
|
|
|
|
2007-05-12 16:29:25 +00:00
|
|
|
// Generic lexer tokens, for example a number
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: real_number
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<cdouble> yaFLOATNUM "FLOATING-POINT NUMBER"
|
2009-01-28 20:27:41 +00:00
|
|
|
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: identifier, class_identifier, class_variable_identifier,
|
|
|
|
// covergroup_variable_identifier, dynamic_array_variable_identifier,
|
|
|
|
// enum_identifier, interface_identifier, interface_instance_identifier,
|
|
|
|
// package_identifier, type_identifier, variable_identifier,
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<strp> yaID "IDENTIFIER"
|
2007-10-26 14:58:26 +00:00
|
|
|
|
|
|
|
// IEEE: integral_number
|
|
|
|
%token<nump> yaINTNUM "INTEGER NUMBER"
|
2008-10-14 18:49:54 +00:00
|
|
|
// IEEE: time_literal + time_unit
|
|
|
|
%token<cdouble> yaTIMENUM "TIME NUMBER"
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: string_literal
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<strp> yaSTRING "STRING"
|
2007-10-26 14:58:26 +00:00
|
|
|
%token<fileline> yaTIMINGSPEC "TIMING SPEC ELEMENT"
|
2007-05-12 16:29:25 +00:00
|
|
|
|
|
|
|
%token<strp> yaSCHDR "`systemc_header BLOCK"
|
|
|
|
%token<strp> yaSCINT "`systemc_ctor BLOCK"
|
|
|
|
%token<strp> yaSCIMP "`systemc_dtor BLOCK"
|
|
|
|
%token<strp> yaSCIMPH "`systemc_interface BLOCK"
|
|
|
|
%token<strp> yaSCCTOR "`systemc_implementation BLOCK"
|
|
|
|
%token<strp> yaSCDTOR "`systemc_imp_header BLOCK"
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
%token<fileline> '!'
|
|
|
|
%token<fileline> '#'
|
|
|
|
%token<fileline> '%'
|
|
|
|
%token<fileline> '&'
|
|
|
|
%token<fileline> '('
|
|
|
|
%token<fileline> ')'
|
|
|
|
%token<fileline> '*'
|
|
|
|
%token<fileline> '+'
|
|
|
|
%token<fileline> ','
|
|
|
|
%token<fileline> '-'
|
|
|
|
%token<fileline> '.'
|
|
|
|
%token<fileline> '/'
|
|
|
|
%token<fileline> ':'
|
|
|
|
%token<fileline> ';'
|
|
|
|
%token<fileline> '<'
|
|
|
|
%token<fileline> '='
|
|
|
|
%token<fileline> '>'
|
|
|
|
%token<fileline> '?'
|
|
|
|
%token<fileline> '@'
|
|
|
|
%token<fileline> '['
|
|
|
|
%token<fileline> ']'
|
|
|
|
%token<fileline> '^'
|
|
|
|
%token<fileline> '{'
|
|
|
|
%token<fileline> '|'
|
|
|
|
%token<fileline> '}'
|
|
|
|
%token<fileline> '~'
|
|
|
|
|
2007-05-12 16:29:25 +00:00
|
|
|
// Specific keywords
|
|
|
|
// yKEYWORD means match "keyword"
|
|
|
|
// Other cases are yXX_KEYWORD where XX makes it unique,
|
|
|
|
// for example yP_ for punctuation based operators.
|
|
|
|
%token<fileline> yALWAYS "always"
|
|
|
|
%token<fileline> yAND "and"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yASSERT "assert"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yASSIGN "assign"
|
2007-05-16 19:27:29 +00:00
|
|
|
%token<fileline> yAUTOMATIC "automatic"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yBEGIN "begin"
|
|
|
|
%token<fileline> yBUF "buf"
|
2009-01-06 16:57:25 +00:00
|
|
|
%token<fileline> yBUFIF0 "bufif0"
|
|
|
|
%token<fileline> yBUFIF1 "bufif1"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yCASE "case"
|
|
|
|
%token<fileline> yCASEX "casex"
|
|
|
|
%token<fileline> yCASEZ "casez"
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yCLOCKING "clocking"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yCOVER "cover"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yDEFAULT "default"
|
|
|
|
%token<fileline> yDEFPARAM "defparam"
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yDISABLE "disable"
|
2007-03-13 18:21:23 +00:00
|
|
|
%token<fileline> yDO "do"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yELSE "else"
|
2007-05-16 12:55:25 +00:00
|
|
|
%token<fileline> yEND "end"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yENDCASE "endcase"
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yENDCLOCKING "endclocking"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yENDFUNCTION "endfunction"
|
|
|
|
%token<fileline> yENDGENERATE "endgenerate"
|
|
|
|
%token<fileline> yENDMODULE "endmodule"
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yENDPROPERTY "endproperty"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yENDSPECIFY "endspecify"
|
|
|
|
%token<fileline> yENDTASK "endtask"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yFINAL "final"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yFOR "for"
|
2009-02-26 03:06:59 +00:00
|
|
|
%token<fileline> yFOREVER "forever"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yFUNCTION "function"
|
|
|
|
%token<fileline> yGENERATE "generate"
|
|
|
|
%token<fileline> yGENVAR "genvar"
|
|
|
|
%token<fileline> yIF "if"
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yIFF "iff"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yINITIAL "initial"
|
|
|
|
%token<fileline> yINOUT "inout"
|
|
|
|
%token<fileline> yINPUT "input"
|
|
|
|
%token<fileline> yINTEGER "integer"
|
|
|
|
%token<fileline> yLOCALPARAM "localparam"
|
|
|
|
%token<fileline> yMODULE "module"
|
|
|
|
%token<fileline> yNAND "nand"
|
|
|
|
%token<fileline> yNEGEDGE "negedge"
|
|
|
|
%token<fileline> yNOR "nor"
|
|
|
|
%token<fileline> yNOT "not"
|
2009-01-06 16:57:25 +00:00
|
|
|
%token<fileline> yNOTIF0 "notif0"
|
|
|
|
%token<fileline> yNOTIF1 "notif1"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yOR "or"
|
|
|
|
%token<fileline> yOUTPUT "output"
|
2007-05-16 12:55:25 +00:00
|
|
|
%token<fileline> yPARAMETER "parameter"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yPOSEDGE "posedge"
|
2008-10-10 23:02:27 +00:00
|
|
|
%token<fileline> yPRIORITY "priority"
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yPROPERTY "property"
|
2009-01-06 16:03:57 +00:00
|
|
|
%token<fileline> yPULLDOWN "pulldown"
|
|
|
|
%token<fileline> yPULLUP "pullup"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yREG "reg"
|
2009-02-26 03:06:59 +00:00
|
|
|
%token<fileline> yREPEAT "repeat"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> ySCALARED "scalared"
|
|
|
|
%token<fileline> ySIGNED "signed"
|
|
|
|
%token<fileline> ySPECIFY "specify"
|
2007-10-26 14:58:26 +00:00
|
|
|
%token<fileline> ySTATIC "static"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> ySUPPLY0 "supply0"
|
|
|
|
%token<fileline> ySUPPLY1 "supply1"
|
|
|
|
%token<fileline> yTASK "task"
|
2008-10-14 18:49:54 +00:00
|
|
|
%token<fileline> yTIMEPRECISION "timeprecision"
|
|
|
|
%token<fileline> yTIMEUNIT "timeunit"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yTRI "tri"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yTRUE "true"
|
2008-10-10 23:02:27 +00:00
|
|
|
%token<fileline> yUNIQUE "unique"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yUNSIGNED "unsigned"
|
|
|
|
%token<fileline> yVECTORED "vectored"
|
2007-03-13 18:21:23 +00:00
|
|
|
%token<fileline> yWHILE "while"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yWIRE "wire"
|
|
|
|
%token<fileline> yXNOR "xnor"
|
|
|
|
%token<fileline> yXOR "xor"
|
2007-03-06 21:43:38 +00:00
|
|
|
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_BITS "$bits"
|
|
|
|
%token<fileline> yD_C "$c"
|
2008-04-24 13:52:51 +00:00
|
|
|
%token<fileline> yD_CLOG2 "$clog2"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_COUNTONES "$countones"
|
|
|
|
%token<fileline> yD_DISPLAY "$display"
|
2007-03-06 21:43:38 +00:00
|
|
|
%token<fileline> yD_ERROR "$error"
|
|
|
|
%token<fileline> yD_FATAL "$fatal"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_FCLOSE "$fclose"
|
|
|
|
%token<fileline> yD_FDISPLAY "$fdisplay"
|
2008-06-26 12:52:02 +00:00
|
|
|
%token<fileline> yD_FEOF "$feof"
|
2008-06-27 12:45:05 +00:00
|
|
|
%token<fileline> yD_FFLUSH "$fflush"
|
2008-06-28 00:04:20 +00:00
|
|
|
%token<fileline> yD_FGETC "$fgetc"
|
|
|
|
%token<fileline> yD_FGETS "$fgets"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_FINISH "$finish"
|
|
|
|
%token<fileline> yD_FOPEN "$fopen"
|
2008-07-01 18:15:10 +00:00
|
|
|
%token<fileline> yD_FSCANF "$fscanf"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_FWRITE "$fwrite"
|
2007-03-06 21:43:38 +00:00
|
|
|
%token<fileline> yD_INFO "$info"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_ISUNKNOWN "$isunknown"
|
|
|
|
%token<fileline> yD_ONEHOT "$onehot"
|
|
|
|
%token<fileline> yD_ONEHOT0 "$onehot0"
|
2008-06-27 15:36:25 +00:00
|
|
|
%token<fileline> yD_RANDOM "$random"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_READMEMB "$readmemb"
|
|
|
|
%token<fileline> yD_READMEMH "$readmemh"
|
|
|
|
%token<fileline> yD_SIGNED "$signed"
|
2008-07-01 18:15:10 +00:00
|
|
|
%token<fileline> yD_SSCANF "$sscanf"
|
2008-07-14 17:16:05 +00:00
|
|
|
%token<fileline> yD_STIME "$stime"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_STOP "$stop"
|
|
|
|
%token<fileline> yD_TIME "$time"
|
|
|
|
%token<fileline> yD_UNSIGNED "$unsigned"
|
2007-03-06 21:43:38 +00:00
|
|
|
%token<fileline> yD_WARNING "$warning"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yD_WRITE "$write"
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yPSL "psl"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yPSL_ASSERT "PSL assert"
|
2008-08-06 16:52:39 +00:00
|
|
|
%token<fileline> yPSL_CLOCK "PSL clock"
|
|
|
|
%token<fileline> yPSL_COVER "PSL cover"
|
|
|
|
%token<fileline> yPSL_REPORT "PSL report"
|
2007-05-12 16:29:25 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
%token<fileline> yVL_CLOCK "/*verilator sc_clock*/"
|
|
|
|
%token<fileline> yVL_CLOCK_ENABLE "/*verilator clock_enable*/"
|
2008-12-10 22:10:03 +00:00
|
|
|
%token<fileline> yVL_COVERAGE_BLOCK_OFF "/*verilator coverage_block_off*/"
|
2006-08-26 11:35:28 +00:00
|
|
|
%token<fileline> yVL_FULL_CASE "/*verilator full_case*/"
|
|
|
|
%token<fileline> yVL_INLINE_MODULE "/*verilator inline_module*/"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yVL_ISOLATE_ASSIGNMENTS "/*verilator isolate_assignments*/"
|
2006-08-26 11:35:28 +00:00
|
|
|
%token<fileline> yVL_NO_INLINE_MODULE "/*verilator no_inline_module*/"
|
2006-10-11 15:41:42 +00:00
|
|
|
%token<fileline> yVL_NO_INLINE_TASK "/*verilator no_inline_task*/"
|
2006-08-26 11:35:28 +00:00
|
|
|
%token<fileline> yVL_PARALLEL_CASE "/*verilator parallel_case*/"
|
|
|
|
%token<fileline> yVL_PUBLIC "/*verilator public*/"
|
2007-03-02 22:24:51 +00:00
|
|
|
%token<fileline> yVL_PUBLIC_FLAT "/*verilator public_flat*/"
|
2006-08-26 11:35:28 +00:00
|
|
|
%token<fileline> yVL_PUBLIC_MODULE "/*verilator public_module*/"
|
|
|
|
|
2007-11-05 21:38:20 +00:00
|
|
|
%token<fileline> yP_OROR "||"
|
|
|
|
%token<fileline> yP_ANDAND "&&"
|
|
|
|
%token<fileline> yP_NOR "~|"
|
|
|
|
%token<fileline> yP_XNOR "^~"
|
|
|
|
%token<fileline> yP_NAND "~&"
|
|
|
|
%token<fileline> yP_EQUAL "=="
|
|
|
|
%token<fileline> yP_NOTEQUAL "!="
|
|
|
|
%token<fileline> yP_CASEEQUAL "==="
|
|
|
|
%token<fileline> yP_CASENOTEQUAL "!=="
|
|
|
|
%token<fileline> yP_WILDEQUAL "==?"
|
|
|
|
%token<fileline> yP_WILDNOTEQUAL "!=?"
|
|
|
|
%token<fileline> yP_GTE ">="
|
|
|
|
%token<fileline> yP_LTE "<="
|
|
|
|
%token<fileline> yP_SLEFT "<<"
|
|
|
|
%token<fileline> yP_SRIGHT ">>"
|
|
|
|
%token<fileline> yP_SSRIGHT ">>>"
|
|
|
|
%token<fileline> yP_POW "**"
|
|
|
|
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yP_PLUSCOLON "+:"
|
|
|
|
%token<fileline> yP_MINUSCOLON "-:"
|
2007-11-05 21:38:20 +00:00
|
|
|
%token<fileline> yP_MINUSGT "->"
|
2007-10-23 20:54:29 +00:00
|
|
|
%token<fileline> yP_MINUSGTGT "->>"
|
2007-10-18 16:29:19 +00:00
|
|
|
%token<fileline> yP_EQGT "=>"
|
|
|
|
%token<fileline> yP_ASTGT "*>"
|
2007-10-23 20:54:29 +00:00
|
|
|
%token<fileline> yP_ANDANDAND "&&&"
|
|
|
|
%token<fileline> yP_POUNDPOUND "##"
|
|
|
|
%token<fileline> yP_DOTSTAR ".*"
|
|
|
|
|
|
|
|
%token<fileline> yP_ATAT "@@"
|
|
|
|
%token<fileline> yP_COLONCOLON "::"
|
|
|
|
%token<fileline> yP_COLONEQ ":="
|
|
|
|
%token<fileline> yP_COLONDIV ":/"
|
2007-11-05 21:38:20 +00:00
|
|
|
%token<fileline> yP_ORMINUSGT "|->"
|
|
|
|
%token<fileline> yP_OREQGT "|=>"
|
2007-10-23 20:54:29 +00:00
|
|
|
|
|
|
|
%token<fileline> yP_PLUSEQ "+="
|
|
|
|
%token<fileline> yP_MINUSEQ "-="
|
|
|
|
%token<fileline> yP_TIMESEQ "*="
|
|
|
|
%token<fileline> yP_DIVEQ "/="
|
|
|
|
%token<fileline> yP_MODEQ "%="
|
|
|
|
%token<fileline> yP_ANDEQ "&="
|
|
|
|
%token<fileline> yP_OREQ "|="
|
|
|
|
%token<fileline> yP_XOREQ "^="
|
|
|
|
%token<fileline> yP_SLEFTEQ "<<="
|
|
|
|
%token<fileline> yP_SRIGHTEQ ">>="
|
|
|
|
%token<fileline> yP_SSRIGHTEQ ">>>="
|
2007-05-12 16:29:25 +00:00
|
|
|
|
|
|
|
%token<fileline> yPSL_BRA "{"
|
|
|
|
%token<fileline> yPSL_KET "}"
|
2007-11-05 21:38:20 +00:00
|
|
|
%token<fileline> yP_LOGIFF
|
|
|
|
|
2007-10-23 20:54:29 +00:00
|
|
|
// [* is not a operator, as "[ * ]" is legal
|
|
|
|
// [= and [-> could be repitition operators, but to match [* we don't add them.
|
|
|
|
// '( is not a operator, as "' (" is legal
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
//********************
|
|
|
|
// PSL op precedence
|
2007-11-05 21:38:20 +00:00
|
|
|
%right yP_MINUSGT yP_LOGIFF
|
|
|
|
%right yP_ORMINUSGT yP_OREQGT
|
|
|
|
%left<fileline> prPSLCLK
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
// Verilog op precedence
|
2009-02-08 01:54:09 +00:00
|
|
|
%right '?' ':'
|
2007-11-05 21:38:20 +00:00
|
|
|
%left yP_OROR
|
|
|
|
%left yP_ANDAND
|
|
|
|
%left '|' yP_NOR
|
2009-02-08 01:54:09 +00:00
|
|
|
%left '^' yP_XNOR
|
2007-11-05 21:38:20 +00:00
|
|
|
%left '&' yP_NAND
|
|
|
|
%left yP_EQUAL yP_NOTEQUAL yP_CASEEQUAL yP_CASENOTEQUAL yP_WILDEQUAL yP_WILDNOTEQUAL
|
|
|
|
%left '>' '<' yP_GTE yP_LTE
|
|
|
|
%left yP_SLEFT yP_SRIGHT yP_SSRIGHT
|
|
|
|
%left '+' '-'
|
|
|
|
%left '*' '/' '%'
|
|
|
|
%left yP_POW
|
2009-02-08 01:54:09 +00:00
|
|
|
%left prUNARYARITH prREDUCTION prNEGATION
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2007-05-12 16:29:25 +00:00
|
|
|
%nonassoc prLOWER_THAN_ELSE
|
2006-08-26 11:35:28 +00:00
|
|
|
%nonassoc yELSE
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
//BISONPRE_TYPES
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
|
|
|
// Blank lines for type insertion
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
%start source_text
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
%%
|
|
|
|
//**********************************************************************
|
|
|
|
// Feedback to the Lexer
|
2009-01-25 02:36:14 +00:00
|
|
|
// Note we read a parenthesis ahead, so this may not change the lexer at the right point.
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2009-02-25 22:16:51 +00:00
|
|
|
stateExitPsl: // For PSL lexing, return from PSL state
|
|
|
|
/* empty */ { V3Read::stateExitPsl(); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-02-25 22:16:51 +00:00
|
|
|
statePushVlg: // For PSL lexing, escape current state into Verilog state
|
|
|
|
/* empty */ { V3Read::statePushVlg(); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-02-25 22:16:51 +00:00
|
|
|
statePop: // Return to previous lexing state
|
|
|
|
/* empty */ { V3Read::statePop(); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//**********************************************************************
|
2007-05-14 20:59:58 +00:00
|
|
|
// Files
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
source_text: // ==IEEE: source_text
|
|
|
|
/* empty */ { }
|
|
|
|
| timeunits_declarationE descriptionList { }
|
2008-03-25 13:42:48 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
descriptionList: // IEEE: part of source_text
|
|
|
|
description { }
|
|
|
|
| descriptionList description { }
|
2007-10-31 20:11:59 +00:00
|
|
|
;
|
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
description: // ==IEEE: description
|
|
|
|
module_declaration { }
|
2009-01-28 20:27:41 +00:00
|
|
|
// | interface_declaration { }
|
2009-01-25 02:36:14 +00:00
|
|
|
// | program_declaration { }
|
2009-01-28 20:27:41 +00:00
|
|
|
// | package_declaration { }
|
2009-01-25 02:36:14 +00:00
|
|
|
// | package_item { }
|
|
|
|
// | bind_directive { }
|
2009-01-28 20:27:41 +00:00
|
|
|
// unsupported // IEEE: config_declaration
|
2009-01-25 02:36:14 +00:00
|
|
|
| error { }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
timeunits_declarationE: // IEEE: timeunits_declaration + empty
|
|
|
|
/*empty*/ { }
|
2009-01-25 02:36:14 +00:00
|
|
|
| yTIMEUNIT yaTIMENUM ';' { }
|
2008-10-14 18:49:54 +00:00
|
|
|
| yTIMEPRECISION yaTIMENUM ';' { }
|
2009-01-15 18:58:43 +00:00
|
|
|
| yTIMEUNIT yaTIMENUM ';' yTIMEPRECISION yaTIMENUM ';' { }
|
|
|
|
| yTIMEPRECISION yaTIMENUM ';' yTIMEUNIT yaTIMENUM ';' { }
|
2008-10-14 18:49:54 +00:00
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//**********************************************************************
|
|
|
|
// Module headers
|
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
module_declaration: // ==IEEE: module_declaration (incomplete)
|
2009-01-25 02:36:14 +00:00
|
|
|
modHeader timeunits_declarationE module_itemListE yENDMODULE endLabelE
|
2008-10-14 18:49:54 +00:00
|
|
|
{ if ($3) $1->addStmtp($3); }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
modHeader<modulep>: // IEEE: module_nonansi_header + module_ansi_header
|
2009-01-28 20:27:41 +00:00
|
|
|
modHdr parameter_port_listE modPortsStarE ';'
|
2008-12-11 21:01:41 +00:00
|
|
|
{ $1->modTrace(v3Global.opt.trace() && $1->fileline()->tracingOn()); // Stash for implicit wires, etc
|
2008-10-14 18:49:54 +00:00
|
|
|
if ($2) $1->addStmtp($2); if ($3) $1->addStmtp($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modHdr<modulep>:
|
2009-02-25 22:16:51 +00:00
|
|
|
yMODULE lifetimeE yaID
|
|
|
|
{ $$ = new AstModule($1,*$3); $$->inLibrary(V3Read::inLibrary()||V3Read::inCellDefine());
|
2009-01-25 02:36:14 +00:00
|
|
|
$$->modTrace(v3Global.opt.trace());
|
|
|
|
V3Read::rootp()->addModulep($$); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
parameter_port_listE<nodep>: // IEEE: parameter_port_list + empty == parameter_value_assignment
|
2008-08-06 16:35:34 +00:00
|
|
|
/* empty */ { $$ = NULL; }
|
2007-05-16 12:55:25 +00:00
|
|
|
| '#' '(' ')' { $$ = NULL; }
|
2007-09-11 13:35:02 +00:00
|
|
|
| '#' '(' modParArgs ')' { $$ = $3; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modParArgs<nodep>:
|
|
|
|
modParDecl { $$ = $1; }
|
2007-09-11 13:35:02 +00:00
|
|
|
| modParDecl ',' modParList { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modParList<nodep>:
|
|
|
|
modParSecond { $$ = $1; }
|
2007-09-11 13:35:02 +00:00
|
|
|
| modParList ',' modParSecond { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
|
|
|
// Called only after a comma in a v2k list, to allow parsing "parameter a,b, parameter x"
|
2008-08-06 16:35:34 +00:00
|
|
|
modParSecond<nodep>:
|
|
|
|
modParDecl { $$ = $1; }
|
2007-09-11 13:35:02 +00:00
|
|
|
| param { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
modPortsStarE<nodep>:
|
2008-08-06 16:35:34 +00:00
|
|
|
/* empty */ { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| '(' ')' { $$ = NULL; }
|
|
|
|
| '(' {V3Parse::s_pinNum=1;} portList ')' { $$ = $3; }
|
2007-06-12 13:58:56 +00:00
|
|
|
| '(' {V3Parse::s_pinNum=1;} portV2kArgs ')' { $$ = $3; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
portList<nodep>:
|
|
|
|
port { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| portList ',' port { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
port<nodep>:
|
|
|
|
yaID portRangeE { $$ = new AstPort(CRELINE(),V3Parse::s_pinNum++,*$1); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
portV2kArgs<nodep>:
|
|
|
|
portV2kDecl { $$ = $1; }
|
2007-06-12 13:58:56 +00:00
|
|
|
| portV2kDecl ',' portV2kList { $$ = $1->addNext($3); }
|
2008-06-12 16:03:47 +00:00
|
|
|
;
|
2007-06-12 13:58:56 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
portV2kList<nodep>:
|
|
|
|
portV2kSecond { $$ = $1; }
|
2007-06-12 13:58:56 +00:00
|
|
|
| portV2kList ',' portV2kSecond { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
|
|
|
// Called only after a comma in a v2k list, to allow parsing "input a,b"
|
2008-08-06 16:35:34 +00:00
|
|
|
portV2kSecond<nodep>:
|
|
|
|
portV2kDecl { $$ = $1; }
|
2008-04-14 21:10:34 +00:00
|
|
|
| portV2kInit { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
portV2kInit<nodep>:
|
|
|
|
portV2kSig { $$=$1; }
|
2008-06-10 01:25:10 +00:00
|
|
|
| portV2kSig '=' expr
|
2008-04-14 21:10:34 +00:00
|
|
|
{ $$=$1; $$->addNext(new AstInitial($2,new AstAssign($2, new AstVarRef($2,V3Parse::s_varAttrp->name(),true), $3))); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
portV2kSig<nodep>:
|
|
|
|
sigAndAttr { $$=$1; $$->addNext(new AstPort(CRELINE(),V3Parse::s_pinNum++, V3Parse::s_varAttrp->name())); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
2007-05-14 20:59:58 +00:00
|
|
|
// Variable Declarations
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
varDeclList<nodep>:
|
|
|
|
varDecl { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| varDecl varDeclList { $$ = $1->addNext($2); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
regsigList<varp>:
|
|
|
|
regsig { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| regsigList ',' regsig { $$ = $1;$1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
portV2kDecl<nodep>:
|
2009-01-15 18:58:43 +00:00
|
|
|
varRESET port_direction v2kVarDeclE signingE regrangeE portV2kInit { $$ = $6; }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
portDecl<nodep>: // IEEE: port_declaration - plus ';'
|
|
|
|
varRESET port_direction v2kVarDeclE signingE regrangeE regsigList ';' { $$ = $6; }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
varDecl<nodep>:
|
|
|
|
varRESET varReg signingE regrangeE regsigList ';' { $$ = $5; }
|
2007-10-26 14:58:26 +00:00
|
|
|
| varRESET varGParam signingE regrangeE paramList ';' { $$ = $5; }
|
|
|
|
| varRESET varLParam signingE regrangeE paramList ';' { $$ = $5; }
|
2009-01-15 18:58:43 +00:00
|
|
|
| varRESET net_type signingE delayrange netSigList ';' { $$ = $5; }
|
2007-10-26 14:58:26 +00:00
|
|
|
| varRESET varGenVar signingE regsigList ';' { $$ = $4; }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modParDecl<nodep>:
|
|
|
|
varRESET varGParam signingE regrangeE param { $$ = $5; }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
varRESET:
|
|
|
|
/* empty */ { VARRESET(); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
net_type: // ==IEEE: net_type
|
2009-01-15 18:58:43 +00:00
|
|
|
ySUPPLY0 { VARDECL(SUPPLY0); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| ySUPPLY1 { VARDECL(SUPPLY1); }
|
|
|
|
| yWIRE { VARDECL(WIRE); }
|
|
|
|
| yTRI { VARDECL(TRIWIRE); }
|
|
|
|
;
|
2007-05-16 12:55:25 +00:00
|
|
|
varGParam: yPARAMETER { VARDECL(GPARAM); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
varLParam: yLOCALPARAM { VARDECL(LPARAM); }
|
|
|
|
;
|
|
|
|
varGenVar: yGENVAR { VARDECL(GENVAR); }
|
|
|
|
;
|
|
|
|
varReg: yREG { VARDECL(REG); }
|
|
|
|
| yINTEGER { VARDECL(INTEGER); }
|
|
|
|
;
|
2008-04-14 21:10:34 +00:00
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
port_direction: // ==IEEE: port_direction
|
|
|
|
yINPUT { VARIO(INPUT); }
|
2008-04-14 21:10:34 +00:00
|
|
|
| yOUTPUT { VARIO(OUTPUT); }
|
|
|
|
| yINOUT { VARIO(INOUT); }
|
|
|
|
// | yREF { VARIO(REF); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
signingE: // IEEE: signing - plus empty
|
2009-01-15 18:58:43 +00:00
|
|
|
/*empty*/ { }
|
2006-08-26 11:35:28 +00:00
|
|
|
| ySIGNED { VARSIGNED(true); }
|
2007-05-12 15:31:04 +00:00
|
|
|
| yUNSIGNED { VARSIGNED(false); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
v2kVarDeclE:
|
|
|
|
/*empty*/ { }
|
2009-01-15 18:58:43 +00:00
|
|
|
| net_type { }
|
2006-08-26 11:35:28 +00:00
|
|
|
| varReg { }
|
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
2007-05-14 20:59:58 +00:00
|
|
|
// Module Items
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
module_itemListE<nodep>: // IEEE: Part of module_declaration
|
2008-08-06 16:35:34 +00:00
|
|
|
/* empty */ { $$ = NULL; }
|
2009-01-25 02:36:14 +00:00
|
|
|
| module_itemList { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
module_itemList<nodep>: // IEEE: Part of module_declaration
|
|
|
|
module_item { $$ = $1; }
|
|
|
|
| module_itemList module_item { $$ = $1->addNextNull($2); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
module_item<nodep>: // ==IEEE: module_item
|
|
|
|
// // IEEE: non_port_module_item
|
|
|
|
generate_region { $$ = $1; }
|
2009-01-28 20:27:41 +00:00
|
|
|
| module_or_generate_item { $$ = $1; }
|
|
|
|
| specify_block { $$ = $1; }
|
2009-01-25 02:36:14 +00:00
|
|
|
// // Verilator specific
|
2007-05-12 16:29:25 +00:00
|
|
|
| yaSCHDR { $$ = new AstScHdr(CRELINE(),*$1); }
|
|
|
|
| yaSCINT { $$ = new AstScInt(CRELINE(),*$1); }
|
|
|
|
| yaSCIMP { $$ = new AstScImp(CRELINE(),*$1); }
|
|
|
|
| yaSCIMPH { $$ = new AstScImpHdr(CRELINE(),*$1); }
|
|
|
|
| yaSCCTOR { $$ = new AstScCtor(CRELINE(),*$1); }
|
|
|
|
| yaSCDTOR { $$ = new AstScDtor(CRELINE(),*$1); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yVL_INLINE_MODULE { $$ = new AstPragma($1,AstPragmaType::INLINE_MODULE); }
|
|
|
|
| yVL_NO_INLINE_MODULE { $$ = new AstPragma($1,AstPragmaType::NO_INLINE_MODULE); }
|
|
|
|
| yVL_PUBLIC_MODULE { $$ = new AstPragma($1,AstPragmaType::PUBLIC_MODULE); }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
generate_region<nodep>: // ==IEEE: generate_region
|
2008-08-06 16:35:34 +00:00
|
|
|
yGENERATE genTopBlock yENDGENERATE { $$ = new AstGenerate($1, $2); }
|
2007-10-31 20:11:59 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
// IEEE: module_or_generate_item + module_common_item + parameter_override
|
2009-01-28 20:27:41 +00:00
|
|
|
module_or_generate_item<nodep>:
|
2009-01-25 02:36:14 +00:00
|
|
|
// // IEEE: always_construct
|
2009-01-15 18:58:43 +00:00
|
|
|
yALWAYS event_controlE stmtBlock { $$ = new AstAlways($1,$2,$3); }
|
2009-01-28 20:27:41 +00:00
|
|
|
| continuous_assign { $$ = $1; }
|
|
|
|
| initial_construct { $$ = $1; }
|
|
|
|
| final_construct { $$ = $1; }
|
2009-01-15 18:58:43 +00:00
|
|
|
| yDEFPARAM list_of_defparam_assignments ';' { $$ = $2; }
|
2007-05-16 12:55:25 +00:00
|
|
|
| instDecl { $$ = $1; }
|
2009-01-28 20:27:41 +00:00
|
|
|
| task_declaration { $$ = $1; }
|
2009-01-25 02:36:14 +00:00
|
|
|
| function_declaration { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| gateDecl { $$ = $1; }
|
2007-10-31 20:11:59 +00:00
|
|
|
| portDecl { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| varDecl { $$ = $1; }
|
2007-05-16 12:55:25 +00:00
|
|
|
//No: | tableDecl // Unsupported
|
2006-08-26 11:35:28 +00:00
|
|
|
| pslStmt { $$ = $1; }
|
2009-01-25 02:36:14 +00:00
|
|
|
| concurrent_assertion_item { $$ = $1; } // IEEE puts in module_item; seems silly
|
2008-08-06 16:52:39 +00:00
|
|
|
| clocking_declaration { $$ = $1; }
|
2009-01-28 20:27:41 +00:00
|
|
|
;
|
2009-01-25 02:36:14 +00:00
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
continuous_assign<nodep>: // IEEE: continuous_assign
|
|
|
|
yASSIGN delayE assignList ';' { $$ = $3; }
|
|
|
|
;
|
|
|
|
|
|
|
|
initial_construct<nodep>: // IEEE: initial_construct
|
|
|
|
yINITIAL stmtBlock { $$ = new AstInitial($1,$2); }
|
|
|
|
;
|
|
|
|
|
|
|
|
final_construct<nodep>: // IEEE: final_construct
|
|
|
|
yFINAL stmtBlock { $$ = new AstFinal($1,$2); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
2007-05-14 20:59:58 +00:00
|
|
|
// Generates
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
// Because genItemList includes variable declarations, we don't need beginNamed
|
2009-01-28 20:27:41 +00:00
|
|
|
generate_block_or_null<nodep>: // IEEE: generate_block_or_null
|
2008-08-06 16:35:34 +00:00
|
|
|
genItem { $$ = new AstBegin(CRELINE(),"genblk",$1); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| genItemBegin { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
genTopBlock<nodep>:
|
|
|
|
genItemList { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| genItemBegin { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
genItemBegin<nodep>: // IEEE: part of generate_block
|
2008-08-06 16:35:34 +00:00
|
|
|
yBEGIN genItemList yEND { $$ = new AstBegin($1,"genblk",$2); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yBEGIN yEND { $$ = NULL; }
|
2009-01-28 20:27:41 +00:00
|
|
|
| yaID ':' yBEGIN genItemList yEND endLabelE { $$ = new AstBegin($2,*$1,$4); }
|
|
|
|
| yaID ':' yBEGIN yEND endLabelE { $$ = NULL; }
|
2007-07-18 17:58:53 +00:00
|
|
|
| yBEGIN ':' yaID genItemList yEND endLabelE { $$ = new AstBegin($2,*$3,$4); }
|
|
|
|
| yBEGIN ':' yaID yEND endLabelE { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
genItemList<nodep>:
|
|
|
|
genItem { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| genItemList genItem { $$ = $1->addNextNull($2); }
|
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
genItem<nodep>: // IEEE: module_or_interface_or_generate_item (INCOMPLETE)
|
|
|
|
module_or_generate_item { $$ = $1; }
|
|
|
|
| conditional_generate_construct {}
|
|
|
|
| loop_generate_construct {}
|
|
|
|
;
|
|
|
|
|
|
|
|
conditional_generate_construct<nodep>: // ==IEEE: conditional_generate_construct
|
|
|
|
yCASE '(' expr ')' case_generate_itemListE yENDCASE { $$ = new AstGenCase($1,$3,$5); }
|
|
|
|
| yIF '(' expr ')' generate_block_or_null %prec prLOWER_THAN_ELSE { $$ = new AstGenIf($1,$3,$5,NULL); }
|
|
|
|
| yIF '(' expr ')' generate_block_or_null yELSE generate_block_or_null { $$ = new AstGenIf($1,$3,$5,$7); }
|
|
|
|
;
|
|
|
|
|
|
|
|
loop_generate_construct<nodep>: // ==IEEE: loop_generate_construct
|
|
|
|
yFOR '(' varRefBase '=' expr ';' expr ';' varRefBase '=' expr ')' generate_block_or_null
|
|
|
|
{ $$ = new AstGenFor($1, new AstAssign($4,$3,$5)
|
|
|
|
,$7, new AstAssign($10,$9,$11)
|
|
|
|
,$13);}
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
case_generate_itemListE<nodep>: // IEEE: [{ case_generate_itemList }]
|
2008-08-06 16:35:34 +00:00
|
|
|
/* empty */ { $$ = NULL; }
|
2009-01-28 20:27:41 +00:00
|
|
|
| case_generate_itemList { $$ = $1; }
|
2007-05-18 14:03:50 +00:00
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
case_generate_itemList<nodep>: // IEEE: { case_generate_itemList }
|
|
|
|
case_generate_item { $$=$1; }
|
|
|
|
| case_generate_itemList case_generate_item { $$=$1; $1->addNext($2); }
|
|
|
|
;
|
|
|
|
|
|
|
|
case_generate_item<nodep>: // ==IEEE: case_generate_item
|
|
|
|
caseCondList ':' generate_block_or_null { $$ = new AstCaseItem($2,$1,$3); }
|
|
|
|
| yDEFAULT ':' generate_block_or_null { $$ = new AstCaseItem($2,NULL,$3); }
|
|
|
|
| yDEFAULT generate_block_or_null { $$ = new AstCaseItem($1,NULL,$2); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
2007-05-14 20:59:58 +00:00
|
|
|
// Assignments and register declarations
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
assignList<nodep>:
|
|
|
|
assignOne { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| assignList ',' assignOne { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
assignOne<nodep>:
|
|
|
|
varRefDotBit '=' expr { $$ = new AstAssignW($2,$1,$3); }
|
2009-01-25 02:36:14 +00:00
|
|
|
| '{' identifier_listLvalue '}' '=' expr { $$ = new AstAssignW($1,$2,$5); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
delayE:
|
|
|
|
/* empty */ { }
|
2009-01-15 18:58:43 +00:00
|
|
|
| delay_control { } /* ignored */
|
2007-05-16 18:19:23 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
delay_control<fileline>: //== IEEE: delay_control
|
2008-08-06 16:35:34 +00:00
|
|
|
'#' dlyTerm { $$ = $1; } /* ignored */
|
2008-03-31 21:03:56 +00:00
|
|
|
| '#' '(' minTypMax ')' { $$ = $1; } /* ignored */
|
|
|
|
| '#' '(' minTypMax ',' minTypMax ')' { $$ = $1; } /* ignored */
|
|
|
|
| '#' '(' minTypMax ',' minTypMax ',' minTypMax ')' { $$ = $1; } /* ignored */
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
dlyTerm<nodep>:
|
|
|
|
yaID { $$ = NULL; }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yaINTNUM { $$ = NULL; }
|
|
|
|
| yaFLOATNUM { $$ = NULL; }
|
2008-10-14 18:49:54 +00:00
|
|
|
| yaTIMENUM { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
minTypMax<nodep>: // IEEE: mintypmax_expression and constant_mintypmax_expression
|
2008-08-06 16:35:34 +00:00
|
|
|
dlyTerm { $$ = $1; } /* ignored */
|
2008-04-01 19:26:06 +00:00
|
|
|
| dlyTerm ':' dlyTerm ':' dlyTerm { $$ = $1; } /* ignored */
|
2007-05-16 18:19:23 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
sigAndAttr<varp>:
|
|
|
|
sigId sigAttrListE { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
netSigList<varp>:
|
|
|
|
netSig { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| netSigList ',' netSig { $$ = $1; $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
netSig<varp>:
|
|
|
|
sigId sigAttrListE { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| sigId sigAttrListE '=' expr { $$ = $1; $1->addNext(new AstAssignW($3,new AstVarRef($3,$1->name(),true),$4)); }
|
|
|
|
| sigIdRange sigAttrListE { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
sigIdRange<varp>:
|
|
|
|
yaID rangeList { $$ = V3Parse::createVariable(CRELINE(), *$1, $2); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
regSigId<varp>:
|
|
|
|
yaID rangeListE { $$ = V3Parse::createVariable(CRELINE(), *$1, $2); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yaID rangeListE '=' constExpr { $$ = V3Parse::createVariable(CRELINE(), *$1, $2);
|
2008-12-30 19:34:01 +00:00
|
|
|
$$->addNext(new AstInitial($3,new AstAssign($3, new AstVarRef($3, *$1, true), $4))); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
sigId<varp>:
|
|
|
|
yaID { $$ = V3Parse::createVariable(CRELINE(), *$1, NULL); }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
regsig<varp>:
|
|
|
|
regSigId sigAttrListE {}
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
sigAttrListE:
|
|
|
|
/* empty */ {}
|
2006-08-26 11:35:28 +00:00
|
|
|
| sigAttrList {}
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
sigAttrList:
|
|
|
|
sigAttr {}
|
2006-08-26 11:35:28 +00:00
|
|
|
| sigAttrList sigAttr {}
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
sigAttr:
|
|
|
|
yVL_CLOCK { V3Parse::s_varAttrp->attrScClocked(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yVL_CLOCK_ENABLE { V3Parse::s_varAttrp->attrClockEn(true); }
|
2007-03-02 22:24:51 +00:00
|
|
|
| yVL_PUBLIC { V3Parse::s_varAttrp->sigPublic(true); V3Parse::s_varAttrp->sigModPublic(true); }
|
|
|
|
| yVL_PUBLIC_FLAT { V3Parse::s_varAttrp->sigPublic(true); }
|
2007-01-18 00:51:26 +00:00
|
|
|
| yVL_ISOLATE_ASSIGNMENTS { V3Parse::s_varAttrp->attrIsolateAssign(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
rangeListE<rangep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| rangeList { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
rangeList<rangep>: // IEEE: packed_dimension + ...
|
2008-08-06 16:35:34 +00:00
|
|
|
anyrange { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| rangeList anyrange { $$ = $1; $1->addNext($2); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
regrangeE<rangep>:
|
|
|
|
/* empty */ { $$ = NULL; VARRANGE($$); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| anyrange { $$ = $1; VARRANGE($$); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
anyrange<rangep>:
|
|
|
|
'[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
delayrange<rangep>:
|
|
|
|
regrangeE delayE { $$ = $1; }
|
2007-05-18 14:03:50 +00:00
|
|
|
| ySCALARED regrangeE delayE { $$ = $2; }
|
|
|
|
| yVECTORED regrangeE delayE { $$ = $2; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
portRangeE<rangep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| '[' constExpr ']' { $$ = NULL; $1->v3error("Ranges ignored on port-list.\n"); }
|
|
|
|
| '[' constExpr ':' constExpr ']' { $$ = NULL; $1->v3error("Ranges ignored on port-list.\n"); }
|
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
2006-08-26 11:35:28 +00:00
|
|
|
// Parameters
|
2007-05-14 20:59:58 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
param<varp>:
|
|
|
|
sigId sigAttrListE '=' expr { $$ = $1; $$->initp($4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
paramList<varp>:
|
|
|
|
param { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| paramList ',' param { $$ = $1; $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
list_of_defparam_assignments<nodep>: //== IEEE: list_of_defparam_assignments
|
2009-01-15 18:58:43 +00:00
|
|
|
defparam_assignment { $$ = $1; }
|
|
|
|
| list_of_defparam_assignments ',' defparam_assignment { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
defparam_assignment<nodep>: // ==IEEE: defparam_assignment
|
2008-08-06 16:35:34 +00:00
|
|
|
yaID '.' yaID '=' expr { $$ = new AstDefParam($4,*$1,*$3,$5); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
2006-08-26 11:35:28 +00:00
|
|
|
// Instances
|
2007-05-14 20:59:58 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
instDecl<nodep>:
|
|
|
|
yaID instparamListE {INSTPREP(*$1,$2);} instnameList ';' { $$ = $4; V3Parse::s_impliedDecl=false;}
|
2009-01-15 18:58:43 +00:00
|
|
|
;
|
2007-05-16 12:55:25 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
instparamListE<pinp>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| '#' '(' cellpinList ')' { $$ = $3; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
instnameList<nodep>:
|
|
|
|
instnameParen { $$ = $1; }
|
2007-05-16 12:55:25 +00:00
|
|
|
| instnameList ',' instnameParen { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
instnameParen<cellp>:
|
|
|
|
yaID instRangeE '(' cellpinList ')' { $$ = new AstCell($3, *$1,V3Parse::s_instModule,$4, V3Parse::s_instParamp,$2); $$->pinStar(V3Parse::s_pinStar); }
|
2007-05-18 18:48:22 +00:00
|
|
|
| yaID instRangeE { $$ = new AstCell(CRELINE(),*$1,V3Parse::s_instModule,NULL,V3Parse::s_instParamp,$2); $$->pinStar(V3Parse::s_pinStar); }
|
2007-05-16 18:19:23 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
instRangeE<rangep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2007-05-16 18:19:23 +00:00
|
|
|
| '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
cellpinList<pinp>:
|
|
|
|
{V3Parse::s_pinNum=1; V3Parse::s_pinStar=false; } cellpinItList { $$ = $2; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
cellpinItList<pinp>:
|
|
|
|
cellpinItemE { $$ = $1; }
|
2007-05-16 12:55:25 +00:00
|
|
|
| cellpinItList ',' cellpinItemE { $$ = $1->addNextNull($3)->castPin(); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
cellpinItemE<pinp>:
|
|
|
|
/* empty: ',,' is legal */ { $$ = NULL; V3Parse::s_pinNum++; }
|
2007-10-23 20:54:29 +00:00
|
|
|
| yP_DOTSTAR { $$ = NULL; if (V3Parse::s_pinStar) $1->v3error("Duplicate .* in a cell"); V3Parse::s_pinStar=true; }
|
2007-05-12 16:29:25 +00:00
|
|
|
| '.' yaID { $$ = new AstPin($1,V3Parse::s_pinNum++,*$2,new AstVarRef($1,*$2,false)); $$->svImplicit(true);}
|
|
|
|
| '.' yaID '(' ')' { $$ = NULL; V3Parse::s_pinNum++; }
|
|
|
|
| '.' yaID '(' expr ')' { $$ = new AstPin($1,V3Parse::s_pinNum++,*$2,$4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| expr { $$ = new AstPin(CRELINE(),V3Parse::s_pinNum++,"",$1); }
|
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
2007-10-26 14:58:26 +00:00
|
|
|
// EventControl lists
|
2007-05-14 20:59:58 +00:00
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
event_controlE<sentreep>:
|
2008-08-06 16:35:34 +00:00
|
|
|
/* empty */ { $$ = NULL; }
|
2009-01-15 18:58:43 +00:00
|
|
|
| event_control { $$ = $1; }
|
2009-01-25 02:36:14 +00:00
|
|
|
;
|
2007-05-16 19:27:29 +00:00
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
event_control<sentreep>: // ==IEEE: event_control
|
2008-08-06 16:35:34 +00:00
|
|
|
'@' '(' senList ')' { $$ = new AstSenTree($1,$3); }
|
2007-05-18 18:48:22 +00:00
|
|
|
| '@' senitemVar { $$ = new AstSenTree($1,$2); } /* For events only */
|
2009-01-28 20:27:41 +00:00
|
|
|
| '@' '(' '*' ')' { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| '@' '*' { $$ = NULL; } /* Verilog 2001 */
|
|
|
|
;
|
|
|
|
|
2009-01-15 18:58:43 +00:00
|
|
|
senList<senitemp>: // IEEE: event_expression - split over several
|
2008-08-06 16:35:34 +00:00
|
|
|
senitem { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| senList yOR senitem { $$ = $1;$1->addNext($3); }
|
|
|
|
| senList ',' senitem { $$ = $1;$1->addNext($3); } /* Verilog 2001 */
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
senitem<senitemp>:
|
|
|
|
senitemEdge { $$ = $1; }
|
2007-05-18 18:48:22 +00:00
|
|
|
| senitemVar { $$ = $1; }
|
2008-04-14 21:47:39 +00:00
|
|
|
| '(' senitemVar ')' { $$ = $2; }
|
2007-05-18 18:48:22 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
senitemVar<senitemp>:
|
|
|
|
varRefDotBit { $$ = new AstSenItem(CRELINE(),AstEdgeType::ANYEDGE,$1); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
senitemEdge<senitemp>: // IEEE: part of event_expression
|
2008-08-06 16:35:34 +00:00
|
|
|
yPOSEDGE varRefDotBit { $$ = new AstSenItem($1,AstEdgeType::POSEDGE,$2); }
|
2006-12-21 21:53:51 +00:00
|
|
|
| yNEGEDGE varRefDotBit { $$ = new AstSenItem($1,AstEdgeType::NEGEDGE,$2); }
|
2008-04-14 21:47:39 +00:00
|
|
|
| yPOSEDGE '(' varRefDotBit ')' { $$ = new AstSenItem($1,AstEdgeType::POSEDGE,$3); }
|
|
|
|
| yNEGEDGE '(' varRefDotBit ')' { $$ = new AstSenItem($1,AstEdgeType::NEGEDGE,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
|
|
|
// Statements
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
stmtBlock<nodep>: // IEEE: statement + seq_block + par_block
|
2008-08-06 16:35:34 +00:00
|
|
|
stmt { $$ = $1; }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yBEGIN stmtList yEND { $$ = $2; }
|
|
|
|
| yBEGIN yEND { $$ = NULL; }
|
2007-07-18 17:58:53 +00:00
|
|
|
| beginNamed stmtList yEND endLabelE { $$ = $1; $1->addStmtp($2); }
|
|
|
|
| beginNamed yEND endLabelE { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
beginNamed<beginp>:
|
|
|
|
yBEGIN ':' yaID varDeclList { $$ = new AstBegin($2,*$3,$4); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yBEGIN ':' yaID { $$ = new AstBegin($2,*$3,NULL); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
stmtList<nodep>:
|
|
|
|
stmtBlock { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| stmtList stmtBlock { $$ = ($2==NULL)?($1):($1->addNext($2)); }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
// IEEE: statement_or_null (may include more stuff, not analyzed)
|
|
|
|
// == function_statement_or_null
|
2008-08-06 16:35:34 +00:00
|
|
|
stmt<nodep>:
|
2009-01-28 20:27:41 +00:00
|
|
|
// // from _or_null
|
2008-08-06 16:35:34 +00:00
|
|
|
';' { $$ = NULL; }
|
2007-03-06 21:43:38 +00:00
|
|
|
| labeledStmt { $$ = $1; }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yaID ':' labeledStmt { $$ = new AstBegin($2, *$1, $3); } /*S05 block creation rule*/
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-15 18:58:43 +00:00
|
|
|
| delay_control stmtBlock { $$ = $2; $1->v3warn(STMTDLY,"Ignoring delay on this delayed statement.\n"); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: operator_assignment
|
2006-12-21 16:29:10 +00:00
|
|
|
| varRefDotBit '=' delayE expr ';' { $$ = new AstAssign($2,$1,$4); }
|
|
|
|
| varRefDotBit '=' yD_FOPEN '(' expr ',' expr ')' ';' { $$ = new AstFOpen($3,$1,$5,$7); }
|
2009-01-25 02:36:14 +00:00
|
|
|
| '{' identifier_listLvalue '}' '=' delayE expr ';' { $$ = new AstAssign($4,$2,$6); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: nonblocking_assignment
|
|
|
|
| varRefDotBit yP_LTE delayE expr ';' { $$ = new AstAssignDly($2,$1,$4); }
|
|
|
|
| '{' identifier_listLvalue '}' yP_LTE delayE expr ';' { $$ = new AstAssignDly($4,$2,$6); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: procedural_continuous_assignment
|
|
|
|
| yASSIGN varRefDotBit '=' delayE expr ';' { $$ = new AstAssign($1,$2,$5); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: case_statement
|
|
|
|
| unique_priorityE caseStart caseAttrE case_itemListE yENDCASE { $$ = $2; if ($4) $2->addItemsp($4);
|
|
|
|
if ($1 == uniq_UNIQUE) $2->parallelPragma(true);
|
|
|
|
if ($1 == uniq_PRIORITY) $2->fullPragma(true); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: conditional_statement
|
|
|
|
| unique_priorityE yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE
|
|
|
|
{ $$ = new AstIf($2,$4,$6,NULL); }
|
|
|
|
| unique_priorityE yIF '(' expr ')' stmtBlock yELSE stmtBlock
|
|
|
|
{ $$ = new AstIf($2,$4,$6,$8); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: subroutine_call_statement (INCOMPLETE)
|
|
|
|
| taskRef ';' { $$ = $1; }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2006-08-26 11:35:28 +00:00
|
|
|
| yD_C '(' cStrList ')' ';' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCStmt($1,$3)); }
|
2006-12-21 21:53:51 +00:00
|
|
|
| yD_FCLOSE '(' varRefDotBit ')' ';' { $$ = new AstFClose($1, $3); }
|
2008-06-27 12:45:05 +00:00
|
|
|
| yD_FFLUSH ';' { $1->v3error("Unsupported: $fflush of all handles does not map to C++.\n"); }
|
|
|
|
| yD_FFLUSH '(' ')' ';' { $1->v3error("Unsupported: $fflush of all handles does not map to C++.\n"); }
|
|
|
|
| yD_FFLUSH '(' varRefDotBit ')' ';' { $$ = new AstFClose($1, $3); }
|
2007-09-17 17:54:02 +00:00
|
|
|
| yD_FINISH parenE ';' { $$ = new AstFinish($1); }
|
2008-04-24 14:32:39 +00:00
|
|
|
| yD_FINISH '(' expr ')' ';' { $$ = new AstFinish($1); }
|
2007-09-17 17:54:02 +00:00
|
|
|
| yD_STOP parenE ';' { $$ = new AstStop($1); }
|
2008-04-24 14:32:39 +00:00
|
|
|
| yD_STOP '(' expr ')' ';' { $$ = new AstStop($1); }
|
2008-12-10 22:10:03 +00:00
|
|
|
| yVL_COVERAGE_BLOCK_OFF { $$ = new AstPragma($1,AstPragmaType::COVERAGE_BLOCK_OFF); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2007-09-17 17:54:02 +00:00
|
|
|
| yD_DISPLAY parenE ';' { $$ = new AstDisplay($1,AstDisplayType::DISPLAY,"", NULL,NULL); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yD_DISPLAY '(' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::DISPLAY,*$3,NULL,$4); }
|
|
|
|
| yD_WRITE '(' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::WRITE, *$3,NULL,$4); }
|
|
|
|
| yD_FDISPLAY '(' varRefDotBit ',' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::DISPLAY,*$5,$3,$6); }
|
|
|
|
| yD_FWRITE '(' varRefDotBit ',' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::WRITE, *$5,$3,$6); }
|
2007-09-17 17:54:02 +00:00
|
|
|
| yD_INFO parenE ';' { $$ = new AstDisplay($1,AstDisplayType::INFO, "", NULL,NULL); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yD_INFO '(' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::INFO, *$3,NULL,$4); }
|
2007-09-17 17:54:02 +00:00
|
|
|
| yD_WARNING parenE ';' { $$ = new AstDisplay($1,AstDisplayType::WARNING,"", NULL,NULL); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yD_WARNING '(' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::WARNING,*$3,NULL,$4); }
|
2007-09-17 17:54:02 +00:00
|
|
|
| yD_ERROR parenE ';' { $$ = V3Parse::createDisplayError($1); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yD_ERROR '(' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::ERROR, *$3,NULL,$4); $$->addNext(new AstStop($1)); }
|
2007-09-17 17:54:02 +00:00
|
|
|
| yD_FATAL parenE ';' { $$ = new AstDisplay($1,AstDisplayType::FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); }
|
2007-11-02 11:23:03 +00:00
|
|
|
| yD_FATAL '(' expr ')' ';' { $$ = new AstDisplay($1,AstDisplayType::FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); }
|
|
|
|
| yD_FATAL '(' expr ',' yaSTRING commaEListE ')' ';' { $$ = new AstDisplay($1,AstDisplayType::FATAL, *$5,NULL,$6); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2006-12-21 21:53:51 +00:00
|
|
|
| yD_READMEMB '(' expr ',' varRefMem ')' ';' { $$ = new AstReadMem($1,false,$3,$5,NULL,NULL); }
|
|
|
|
| yD_READMEMB '(' expr ',' varRefMem ',' expr ')' ';' { $$ = new AstReadMem($1,false,$3,$5,$7,NULL); }
|
|
|
|
| yD_READMEMB '(' expr ',' varRefMem ',' expr ',' expr ')' ';' { $$ = new AstReadMem($1,false,$3,$5,$7,$9); }
|
|
|
|
| yD_READMEMH '(' expr ',' varRefMem ')' ';' { $$ = new AstReadMem($1,true, $3,$5,NULL,NULL); }
|
|
|
|
| yD_READMEMH '(' expr ',' varRefMem ',' expr ')' ';' { $$ = new AstReadMem($1,true, $3,$5,$7,NULL); }
|
|
|
|
| yD_READMEMH '(' expr ',' varRefMem ',' expr ',' expr ')' ';' { $$ = new AstReadMem($1,true, $3,$5,$7,$9); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: loop_statement (INCOMPLETE)
|
2009-02-26 03:06:59 +00:00
|
|
|
| yFOREVER stmtBlock { $$ = new AstWhile($1,new AstConst($1,V3Number($1,1,1)),$2); }
|
|
|
|
| yREPEAT '(' expr ')' stmtBlock { $$ = new AstRepeat($1,$3,$5);}
|
2009-01-28 20:27:41 +00:00
|
|
|
| yWHILE '(' expr ')' stmtBlock { $$ = new AstWhile($1,$3,$5);}
|
|
|
|
| yFOR '(' varRefBase '=' expr ';' expr ';' varRefBase '=' expr ')' stmtBlock
|
|
|
|
{ $$ = new AstFor($1, new AstAssign($4,$3,$5)
|
|
|
|
,$7, new AstAssign($10,$9,$11)
|
|
|
|
,$13);}
|
|
|
|
| yDO stmtBlock yWHILE '(' expr ')' { $$ = $2->cloneTree(true); $$->addNext(new AstWhile($1,$5,$2));}
|
2007-03-06 21:43:38 +00:00
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
|
|
|
// Case/If
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
unique_priorityE<uniqstate>: // IEEE: unique_priority + empty
|
2008-10-10 23:02:27 +00:00
|
|
|
/*empty*/ { $$ = uniq_NONE; }
|
|
|
|
| yPRIORITY { $$ = uniq_PRIORITY; }
|
|
|
|
| yUNIQUE { $$ = uniq_UNIQUE; }
|
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
caseStart<casep>: // IEEE: part of case_statement
|
2008-08-06 16:35:34 +00:00
|
|
|
yCASE '(' expr ')' { $$ = V3Parse::s_caseAttrp = new AstCase($1,AstCaseType::CASE,$3,NULL); }
|
2008-07-22 17:07:19 +00:00
|
|
|
| yCASEX '(' expr ')' { $$ = V3Parse::s_caseAttrp = new AstCase($1,AstCaseType::CASEX,$3,NULL); $1->v3warn(CASEX,"Suggest casez (with ?'s) in place of casex (with X's)\n"); }
|
2009-01-25 02:36:14 +00:00
|
|
|
| yCASEZ '(' expr ')' { $$ = V3Parse::s_caseAttrp = new AstCase($1,AstCaseType::CASEZ,$3,NULL); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
caseAttrE:
|
|
|
|
/*empty*/ { }
|
2006-08-26 11:35:28 +00:00
|
|
|
| caseAttrE yVL_FULL_CASE { V3Parse::s_caseAttrp->fullPragma(true); }
|
|
|
|
| caseAttrE yVL_PARALLEL_CASE { V3Parse::s_caseAttrp->parallelPragma(true); }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
case_itemListE<caseitemp>: // IEEE: [ { case_item } ]
|
2008-08-06 16:35:34 +00:00
|
|
|
/* empty */ { $$ = NULL; }
|
2009-01-25 02:36:14 +00:00
|
|
|
| case_itemList { $$ = $1; }
|
2007-05-18 14:03:50 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
case_itemList<caseitemp>: // IEEE: { case_item + ... }
|
2008-08-06 16:35:34 +00:00
|
|
|
caseCondList ':' stmtBlock { $$ = new AstCaseItem($2,$1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yDEFAULT ':' stmtBlock { $$ = new AstCaseItem($2,NULL,$3); }
|
|
|
|
| yDEFAULT stmtBlock { $$ = new AstCaseItem($1,NULL,$2); }
|
2009-01-25 02:36:14 +00:00
|
|
|
| case_itemList caseCondList ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,$2,$4)); }
|
|
|
|
| case_itemList yDEFAULT stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($2,NULL,$3)); }
|
|
|
|
| case_itemList yDEFAULT ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,NULL,$4)); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
caseCondList<nodep>: // IEEE: part of case_item
|
2008-08-06 16:35:34 +00:00
|
|
|
expr { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| caseCondList ',' expr { $$ = $1;$1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
|
|
|
// Functions/tasks
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
taskRef<nodep>: // IEEE: part of tf_call
|
2008-08-06 16:35:34 +00:00
|
|
|
idDotted { $$ = new AstTaskRef(CRELINE(),new AstParseRef($1->fileline(), AstParseRefExp::TASK, $1),NULL);}
|
2007-05-14 20:59:58 +00:00
|
|
|
| idDotted '(' exprList ')' { $$ = new AstTaskRef(CRELINE(),new AstParseRef($1->fileline(), AstParseRefExp::TASK, $1),$3);}
|
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
funcRef<nodep>: // IEEE: part of tf_call
|
2008-08-06 16:35:34 +00:00
|
|
|
idDotted '(' exprList ')' { $$ = new AstFuncRef($2,new AstParseRef($1->fileline(), AstParseRefExp::FUNC, $1), $3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
task_declaration<nodep>: // ==IEEE: task_declaration
|
|
|
|
yTASK lifetimeE yaID tfGuts yENDTASK endLabelE
|
2007-07-18 17:58:53 +00:00
|
|
|
{ $$ = new AstTask ($1,*$3,$4);}
|
2007-05-16 19:27:29 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
function_declaration<funcp>: // IEEE: function_declaration + function_body_declaration
|
2009-01-28 20:27:41 +00:00
|
|
|
yFUNCTION lifetimeE funcTypeE yaID tfGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$4,$5,$3); }
|
|
|
|
| yFUNCTION lifetimeE ySIGNED funcTypeE yaID tfGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$5,$6,$4); $$->isSigned(true); }
|
|
|
|
| yFUNCTION lifetimeE funcTypeE yaID yVL_ISOLATE_ASSIGNMENTS tfGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$4,$6,$3); $$->attrIsolateAssign(true);}
|
|
|
|
| yFUNCTION lifetimeE ySIGNED funcTypeE yaID yVL_ISOLATE_ASSIGNMENTS tfGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$5,$7,$4); $$->attrIsolateAssign(true); $$->isSigned(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
lifetimeE: // IEEE: lifetime - plus empty
|
2009-01-15 18:58:43 +00:00
|
|
|
/* empty */ { }
|
2007-10-26 14:58:26 +00:00
|
|
|
| ySTATIC { $1->v3error("Unsupported: Static in this context\n"); }
|
2007-05-16 19:27:29 +00:00
|
|
|
| yAUTOMATIC { }
|
2007-01-30 15:51:16 +00:00
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
tfGuts<nodep>:
|
|
|
|
'(' {V3Parse::s_pinNum=1;} portV2kArgs ')' ';' tfBody { $$ = $3->addNextNull($6); }
|
|
|
|
| ';' tfBody { $$ = $2; }
|
2007-06-19 23:43:14 +00:00
|
|
|
;
|
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
tfBody<nodep>: // IEEE: part of function_body_declaration/task_body_declaration
|
2008-08-06 16:35:34 +00:00
|
|
|
funcVarList stmtBlock { $$ = $1;$1->addNextNull($2); }
|
2007-06-19 23:43:14 +00:00
|
|
|
| stmtBlock { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
funcTypeE<rangep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2007-05-16 18:19:23 +00:00
|
|
|
| yINTEGER { $$ = new AstRange($1,31,0); }
|
2007-05-14 20:59:58 +00:00
|
|
|
| '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
funcVarList<nodep>:
|
|
|
|
funcVar { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| funcVarList funcVar { $$ = $1;$1->addNext($2); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
funcVar<nodep>:
|
|
|
|
portDecl { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| varDecl { $$ = $1; }
|
2006-10-11 15:41:42 +00:00
|
|
|
| yVL_PUBLIC { $$ = new AstPragma($1,AstPragmaType::PUBLIC_TASK); }
|
|
|
|
| yVL_NO_INLINE_TASK { $$ = new AstPragma($1,AstPragmaType::NO_INLINE_TASK); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
parenE:
|
|
|
|
/* empty */ { }
|
2007-09-17 17:54:02 +00:00
|
|
|
| '(' ')' { }
|
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
|
|
|
// Expressions
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
constExpr<nodep>:
|
|
|
|
expr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
exprNoStr<nodep>:
|
|
|
|
expr yP_OROR expr { $$ = new AstLogOr ($2,$1,$3); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| expr yP_ANDAND expr { $$ = new AstLogAnd ($2,$1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| expr '&' expr { $$ = new AstAnd ($2,$1,$3); }
|
|
|
|
| expr '|' expr { $$ = new AstOr ($2,$1,$3); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| expr yP_NAND expr { $$ = new AstNot($2,new AstAnd ($2,$1,$3)); }
|
|
|
|
| expr yP_NOR expr { $$ = new AstNot($2,new AstOr ($2,$1,$3)); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| expr '^' expr { $$ = new AstXor ($2,$1,$3); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| expr yP_XNOR expr { $$ = new AstXnor ($2,$1,$3); }
|
|
|
|
| expr yP_EQUAL expr { $$ = new AstEq ($2,$1,$3); }
|
|
|
|
| expr yP_NOTEQUAL expr { $$ = new AstNeq ($2,$1,$3); }
|
|
|
|
| expr yP_CASEEQUAL expr { $$ = new AstEqCase ($2,$1,$3); }
|
|
|
|
| expr yP_CASENOTEQUAL expr { $$ = new AstNeqCase ($2,$1,$3); }
|
2007-07-18 15:01:39 +00:00
|
|
|
| expr yP_WILDEQUAL expr { $$ = new AstEqWild ($2,$1,$3); }
|
|
|
|
| expr yP_WILDNOTEQUAL expr { $$ = new AstNeqWild ($2,$1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| expr '>' expr { $$ = new AstGt ($2,$1,$3); }
|
|
|
|
| expr '<' expr { $$ = new AstLt ($2,$1,$3); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| expr yP_GTE expr { $$ = new AstGte ($2,$1,$3); }
|
|
|
|
| expr yP_LTE expr { $$ = new AstLte ($2,$1,$3); }
|
|
|
|
| expr yP_SLEFT expr { $$ = new AstShiftL ($2,$1,$3); }
|
|
|
|
| expr yP_SRIGHT expr { $$ = new AstShiftR ($2,$1,$3); }
|
|
|
|
| expr yP_SSRIGHT expr { $$ = new AstShiftRS ($2,$1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| expr '+' expr { $$ = new AstAdd ($2,$1,$3); }
|
|
|
|
| expr '-' expr { $$ = new AstSub ($2,$1,$3); }
|
|
|
|
| expr '*' expr { $$ = new AstMul ($2,$1,$3); }
|
|
|
|
| expr '/' expr { $$ = new AstDiv ($2,$1,$3); }
|
|
|
|
| expr '%' expr { $$ = new AstModDiv ($2,$1,$3); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| expr yP_POW expr { $$ = new AstPow ($2,$1,$3); }
|
2007-07-18 17:26:12 +00:00
|
|
|
| expr yP_MINUSGT expr { $$ = new AstLogIf ($2,$1,$3); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| expr yP_LOGIFF expr { $$ = new AstLogIff ($2,$1,$3); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2007-05-12 16:29:25 +00:00
|
|
|
| '-' expr %prec prUNARYARITH { $$ = new AstUnaryMin ($1,$2); }
|
|
|
|
| '+' expr %prec prUNARYARITH { $$ = $2; }
|
|
|
|
| '&' expr %prec prREDUCTION { $$ = new AstRedAnd ($1,$2); }
|
|
|
|
| '|' expr %prec prREDUCTION { $$ = new AstRedOr ($1,$2); }
|
|
|
|
| '^' expr %prec prREDUCTION { $$ = new AstRedXor ($1,$2); }
|
|
|
|
| yP_XNOR expr %prec prREDUCTION { $$ = new AstRedXnor ($1,$2); }
|
|
|
|
| yP_NAND expr %prec prREDUCTION { $$ = new AstNot($1,new AstRedAnd($1,$2)); }
|
|
|
|
| yP_NOR expr %prec prREDUCTION { $$ = new AstNot($1,new AstRedOr ($1,$2)); }
|
|
|
|
| '!' expr %prec prNEGATION { $$ = new AstLogNot ($1,$2); }
|
|
|
|
| '~' expr %prec prNEGATION { $$ = new AstNot ($1,$2); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2006-08-26 11:35:28 +00:00
|
|
|
| expr '?' expr ':' expr { $$ = new AstCond($2,$1,$3,$5); }
|
|
|
|
| '(' expr ')' { $$ = $2; }
|
|
|
|
| '_' '(' statePushVlg expr statePop ')' { $$ = $4; } // Arbitrary Verilog inside PSL
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
// // IEEE: concatenation/constant_concatenation
|
2006-08-26 11:35:28 +00:00
|
|
|
| '{' cateList '}' { $$ = $2; }
|
|
|
|
| '{' constExpr '{' cateList '}' '}' { $$ = new AstReplicate($1,$4,$2); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2006-08-26 11:35:28 +00:00
|
|
|
| yD_BITS '(' expr ')' { $$ = new AstAttrOf($1,AstAttrType::BITS,$3); }
|
|
|
|
| yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCFunc($1,$3)); }
|
2008-04-24 13:52:51 +00:00
|
|
|
| yD_CLOG2 '(' expr ')' { $$ = new AstCLog2($1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yD_COUNTONES '(' expr ')' { $$ = new AstCountOnes($1,$3); }
|
2008-06-26 12:52:02 +00:00
|
|
|
| yD_FEOF '(' expr ')' { $$ = new AstFEof($1,$3); }
|
2008-06-28 00:04:20 +00:00
|
|
|
| yD_FGETC '(' expr ')' { $$ = new AstFGetC($1,$3); }
|
|
|
|
| yD_FGETS '(' varRefDotBit ',' expr ')' { $$ = new AstFGetS($1,$3,$5); }
|
2008-07-01 18:15:10 +00:00
|
|
|
| yD_FSCANF '(' expr ',' yaSTRING commaVRDListE ')' { $$ = new AstFScanF($1,*$5,$3,$6); }
|
|
|
|
| yD_SSCANF '(' expr ',' yaSTRING commaVRDListE ')' { $$ = new AstSScanF($1,*$5,$3,$6); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yD_ISUNKNOWN '(' expr ')' { $$ = new AstIsUnknown($1,$3); }
|
|
|
|
| yD_ONEHOT '(' expr ')' { $$ = new AstOneHot($1,$3); }
|
|
|
|
| yD_ONEHOT0 '(' expr ')' { $$ = new AstOneHot0($1,$3); }
|
2008-06-27 15:36:25 +00:00
|
|
|
| yD_RANDOM '(' expr ')' { $1->v3error("Unsupported: Seeding $random doesn't map to C++, use $c(\"srand\")\n"); }
|
|
|
|
| yD_RANDOM '(' ')' { $$ = new AstRand($1); }
|
|
|
|
| yD_RANDOM { $$ = new AstRand($1); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yD_SIGNED '(' expr ')' { $$ = new AstSigned($1,$3); }
|
2008-07-14 17:16:05 +00:00
|
|
|
| yD_STIME { $$ = new AstSel($1,new AstTime($1),0,32); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yD_TIME { $$ = new AstTime($1); }
|
|
|
|
| yD_UNSIGNED '(' expr ')' { $$ = new AstUnsigned($1,$3); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2006-12-20 16:10:47 +00:00
|
|
|
| funcRef { $$ = $1; }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2007-05-12 16:29:25 +00:00
|
|
|
| yaINTNUM { $$ = new AstConst(CRELINE(),*$1); }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2006-12-21 16:29:10 +00:00
|
|
|
| varRefDotBit { $$ = $1; }
|
2009-02-25 22:16:51 +00:00
|
|
|
//
|
2009-01-28 20:27:41 +00:00
|
|
|
| error ';' { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
// Generic expressions
|
2008-08-06 16:35:34 +00:00
|
|
|
expr<nodep>:
|
|
|
|
exprNoStr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| strAsInt { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
// Psl excludes {}'s by lexer converting to different token
|
2008-08-06 16:35:34 +00:00
|
|
|
exprPsl<nodep>:
|
|
|
|
exprNoStr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| strAsInt { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
// PLI calls exclude "" as integers, they're strings
|
|
|
|
// For $c("foo","bar") we want "bar" as a string, not a Verilog integer.
|
2008-08-06 16:35:34 +00:00
|
|
|
exprStrText<nodep>:
|
|
|
|
exprNoStr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| strAsText { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
cStrList<nodep>:
|
|
|
|
exprStrText { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| exprStrText ',' cStrList { $$ = $1;$1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
cateList<nodep>:
|
|
|
|
expr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| cateList ',' expr { $$ = new AstConcat($2,$1,$3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
exprList<nodep>:
|
|
|
|
expr { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| exprList ',' expr { $$ = $1;$1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
commaEListE<nodep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| ',' exprList { $$ = $2; }
|
2007-03-06 21:43:38 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
vrdList<nodep>:
|
|
|
|
varRefDotBit { $$ = $1; }
|
2008-07-01 18:15:10 +00:00
|
|
|
| vrdList ',' varRefDotBit { $$ = $1;$1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
commaVRDListE<nodep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2008-07-01 18:15:10 +00:00
|
|
|
| ',' vrdList { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
2006-08-26 11:35:28 +00:00
|
|
|
// Gate declarations
|
2007-05-14 20:59:58 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
gateDecl<nodep>:
|
2009-01-06 16:57:25 +00:00
|
|
|
yBUF delayE gateBufList ';' { $$ = $3; }
|
|
|
|
| yBUFIF0 delayE gateBufif0List ';' { $$ = $3; }
|
|
|
|
| yBUFIF1 delayE gateBufif1List ';' { $$ = $3; }
|
|
|
|
| yNOT delayE gateNotList ';' { $$ = $3; }
|
|
|
|
| yNOTIF0 delayE gateNotif0List ';' { $$ = $3; }
|
|
|
|
| yNOTIF1 delayE gateNotif1List ';' { $$ = $3; }
|
2008-04-01 19:26:06 +00:00
|
|
|
| yAND delayE gateAndList ';' { $$ = $3; }
|
|
|
|
| yNAND delayE gateNandList ';' { $$ = $3; }
|
|
|
|
| yOR delayE gateOrList ';' { $$ = $3; }
|
|
|
|
| yNOR delayE gateNorList ';' { $$ = $3; }
|
|
|
|
| yXOR delayE gateXorList ';' { $$ = $3; }
|
|
|
|
| yXNOR delayE gateXnorList ';' { $$ = $3; }
|
2009-01-06 16:03:57 +00:00
|
|
|
| yPULLUP delayE gatePullupList ';' { $$ = $3; }
|
|
|
|
| yPULLDOWN delayE gatePulldownList ';' { $$ = $3; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
gateBufList<nodep>:
|
|
|
|
gateBuf { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateBufList ',' gateBuf { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-01-06 16:57:25 +00:00
|
|
|
gateBufif0List<nodep>:
|
|
|
|
gateBufif0 { $$ = $1; }
|
|
|
|
| gateBufif0List ',' gateBufif0 { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
gateBufif1List<nodep>:
|
|
|
|
gateBufif1 { $$ = $1; }
|
|
|
|
| gateBufif1List ',' gateBufif1 { $$ = $1->addNext($3); }
|
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateNotList<nodep>:
|
|
|
|
gateNot { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateNotList ',' gateNot { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-01-06 16:57:25 +00:00
|
|
|
gateNotif0List<nodep>:
|
|
|
|
gateNotif0 { $$ = $1; }
|
|
|
|
| gateNotif0List ',' gateNotif0 { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
gateNotif1List<nodep>:
|
|
|
|
gateNotif1 { $$ = $1; }
|
|
|
|
| gateNotif1List ',' gateNotif1 { $$ = $1->addNext($3); }
|
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateAndList<nodep>:
|
|
|
|
gateAnd { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateAndList ',' gateAnd { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateNandList<nodep>:
|
|
|
|
gateNand { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateNandList ',' gateNand { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateOrList<nodep>:
|
|
|
|
gateOr { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateOrList ',' gateOr { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateNorList<nodep>:
|
|
|
|
gateNor { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateNorList ',' gateNor { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateXorList<nodep>:
|
|
|
|
gateXor { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateXorList ',' gateXor { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateXnorList<nodep>:
|
|
|
|
gateXnor { $$ = $1; }
|
2008-05-06 14:52:53 +00:00
|
|
|
| gateXnorList ',' gateXnor { $$ = $1->addNext($3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-01-06 16:03:57 +00:00
|
|
|
gatePullupList<nodep>:
|
|
|
|
gatePullup { $$ = $1; }
|
|
|
|
| gatePullupList ',' gatePullup { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
gatePulldownList<nodep>:
|
|
|
|
gatePulldown { $$ = $1; }
|
|
|
|
| gatePulldownList ',' gatePulldown { $$ = $1->addNext($3); }
|
|
|
|
;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
gateBuf<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' expr ')' { $$ = new AstAssignW ($3,$4,$6); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-01-06 16:57:25 +00:00
|
|
|
gateBufif0<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' expr ',' expr ')' { $$ = new AstAssignW ($3,$4,new AstCond($3,$8, new AstConst($3,V3Number($3,"1'bz")), $6)); }
|
|
|
|
;
|
|
|
|
gateBufif1<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' expr ',' expr ')' { $$ = new AstAssignW ($3,$4,new AstCond($3,$8, $6, new AstConst($3,V3Number($3,"1'bz")))); }
|
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateNot<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' expr ')' { $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-01-06 16:57:25 +00:00
|
|
|
gateNotif0<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' expr ',' expr ')' { $$ = new AstAssignW ($3,$4,new AstCond($3,$8, new AstConst($3,V3Number($3,"1'bz")), new AstNot($3, $6))); }
|
|
|
|
;
|
|
|
|
gateNotif1<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' expr ',' expr ')' { $$ = new AstAssignW ($3,$4,new AstCond($3,$8, new AstNot($3,$6), new AstConst($3,V3Number($3,"1'bz")))); }
|
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateAnd<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' gateAndPinList ')' { $$ = new AstAssignW ($3,$4,$6); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateNand<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' gateAndPinList ')' { $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateOr<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' gateOrPinList ')' { $$ = new AstAssignW ($3,$4,$6); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateNor<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' gateOrPinList ')' { $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateXor<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' gateXorPinList ')' { $$ = new AstAssignW ($3,$4,$6); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateXnor<assignwp>: gateIdE instRangeE '(' varRefDotBit ',' gateXorPinList ')' { $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); $$->allowImplicit(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2009-01-06 16:03:57 +00:00
|
|
|
gatePullup<pullp>: gateIdE instRangeE '(' varRefDotBit ')' { $$ = new AstPull ($3, $4, true); }
|
|
|
|
;
|
|
|
|
gatePulldown<pullp>: gateIdE instRangeE '(' varRefDotBit ')' { $$ = new AstPull ($3, $4, false); }
|
|
|
|
;
|
2009-01-25 02:36:14 +00:00
|
|
|
gateIdE:
|
|
|
|
/*empty*/ {}
|
2007-05-14 20:59:58 +00:00
|
|
|
| yaID {}
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
gateAndPinList<nodep>:
|
|
|
|
expr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| gateAndPinList ',' expr { $$ = new AstAnd($2,$1,$3); }
|
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateOrPinList<nodep>:
|
|
|
|
expr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| gateOrPinList ',' expr { $$ = new AstOr($2,$1,$3); }
|
|
|
|
;
|
2008-08-06 16:35:34 +00:00
|
|
|
gateXorPinList<nodep>:
|
|
|
|
expr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| gateXorPinList ',' expr { $$ = new AstXor($2,$1,$3); }
|
|
|
|
;
|
|
|
|
|
2007-05-16 12:55:25 +00:00
|
|
|
//************************************************
|
|
|
|
// Tables
|
|
|
|
// Not supported
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
//************************************************
|
|
|
|
// Specify
|
2007-05-14 20:59:58 +00:00
|
|
|
|
2009-01-28 20:27:41 +00:00
|
|
|
specify_block<nodep>: // ==IEEE: specify_block
|
|
|
|
ySPECIFY specifyJunkList yENDSPECIFY { $$ = NULL; }
|
|
|
|
| ySPECIFY yENDSPECIFY { $$ = NULL; }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
specifyJunkList:
|
|
|
|
specifyJunk { } /* ignored */
|
|
|
|
| specifyJunkList specifyJunk { } /* ignored */
|
|
|
|
;
|
2007-05-18 18:48:22 +00:00
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
specifyJunk:
|
|
|
|
BISONPRE_NOT(ySPECIFY,yENDSPECIFY) { }
|
|
|
|
| ySPECIFY specifyJunk yENDSPECIFY { }
|
2007-05-18 18:48:22 +00:00
|
|
|
| error {}
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
|
|
|
// IDs
|
2006-12-21 21:53:51 +00:00
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
// VarRef to a Memory
|
2008-08-06 16:35:34 +00:00
|
|
|
varRefMem<parserefp>:
|
|
|
|
idDotted { $$ = new AstParseRef($1->fileline(), AstParseRefExp::VAR_MEM, $1); }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
// VarRef to dotted, and/or arrayed, and/or bit-ranged variable
|
2008-08-06 16:35:34 +00:00
|
|
|
varRefDotBit<parserefp>:
|
|
|
|
idDotted { $$ = new AstParseRef($1->fileline(), AstParseRefExp::VAR_ANY, $1); }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
idDotted<nodep>:
|
|
|
|
idArrayed { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| idDotted '.' idArrayed { $$ = new AstDot($2,$1,$3); }
|
|
|
|
;
|
|
|
|
|
2006-12-21 21:53:51 +00:00
|
|
|
// Single component of dotted path, maybe [#].
|
|
|
|
// Due to lookahead constraints, we can't know if [:] or [+:] are valid (last dotted part),
|
|
|
|
// we'll assume so and cleanup later.
|
2008-08-06 16:35:34 +00:00
|
|
|
idArrayed<nodep>:
|
|
|
|
yaID { $$ = new AstText(CRELINE(),*$1); }
|
2009-02-25 22:16:51 +00:00
|
|
|
// // IEEE: id + part_select_range/constant_part_select_range
|
2006-12-21 21:53:51 +00:00
|
|
|
| idArrayed '[' expr ']' { $$ = new AstSelBit($2,$1,$3); } // Or AstArraySel, don't know yet.
|
|
|
|
| idArrayed '[' constExpr ':' constExpr ']' { $$ = new AstSelExtract($2,$1,$3,$5); }
|
2009-02-25 22:16:51 +00:00
|
|
|
// // IEEE: id + indexed_range/constant_indexed_range
|
2007-05-14 20:59:58 +00:00
|
|
|
| idArrayed '[' expr yP_PLUSCOLON constExpr ']' { $$ = new AstSelPlus($2,$1,$3,$5); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| idArrayed '[' expr yP_MINUSCOLON constExpr ']' { $$ = new AstSelMinus($2,$1,$3,$5); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2006-12-21 21:53:51 +00:00
|
|
|
// VarRef without any dots or vectorizaion
|
2008-08-06 16:35:34 +00:00
|
|
|
varRefBase<varrefp>:
|
|
|
|
yaID { $$ = new AstVarRef(CRELINE(),*$1,false);}
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
strAsInt<nodep>:
|
|
|
|
yaSTRING { $$ = new AstConst(CRELINE(),V3Number(V3Number::VerilogString(),CRELINE(),V3Parse::deQuote(CRELINE(),*$1)));}
|
2006-12-20 16:10:47 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
strAsText<nodep>:
|
|
|
|
yaSTRING { $$ = V3Parse::createTextQuoted(CRELINE(),*$1);}
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
identifier_listLvalue<nodep>: // IEEE: identifier_list for lvalue only
|
2008-08-06 16:35:34 +00:00
|
|
|
varRefDotBit { $$ = $1; }
|
2009-01-25 02:36:14 +00:00
|
|
|
| identifier_listLvalue ',' varRefDotBit { $$ = new AstConcat($2,$1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
endLabelE:
|
|
|
|
/* empty */ { }
|
2007-07-18 17:58:53 +00:00
|
|
|
| ':' yaID { }
|
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//************************************************
|
|
|
|
// Asserts
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
labeledStmt<nodep>:
|
|
|
|
assertStmt { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:52:39 +00:00
|
|
|
clocking_declaration<nodep>: // IEEE: clocking_declaration (INCOMPLETE)
|
2008-08-06 21:51:36 +00:00
|
|
|
yDEFAULT yCLOCKING '@' '(' senitemEdge ')' ';' yENDCLOCKING
|
|
|
|
{ $$ = new AstClocking($1, $5, NULL); }
|
2008-08-06 16:52:39 +00:00
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
concurrent_assertion_item<nodep>: // IEEE: concurrent_assertion_item
|
2008-08-06 16:52:39 +00:00
|
|
|
concurrent_assertion_statement { $$ = $1; }
|
|
|
|
| yaID ':' concurrent_assertion_statement { $$ = new AstBegin($2,*$1,$3); }
|
|
|
|
;
|
|
|
|
|
|
|
|
concurrent_assertion_statement<nodep>: // IEEE: concurrent_assertion_statement (INCOMPLETE)
|
|
|
|
cover_property_statement { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2009-01-25 02:36:14 +00:00
|
|
|
cover_property_statement<nodep>: // IEEE: cover_property_statement
|
2008-08-06 16:52:39 +00:00
|
|
|
yCOVER yPROPERTY '(' property_spec ')' stmtBlock { $$ = new AstPslCover($1,$4,$6); }
|
|
|
|
;
|
|
|
|
|
|
|
|
property_spec<nodep>: // IEEE: property_spec
|
|
|
|
'@' '(' senitemEdge ')' property_spec_disable expr { $$ = new AstPslClocked($1,$3,$5,$6); }
|
|
|
|
| property_spec_disable expr { $$ = new AstPslClocked(CRELINE(),NULL,$1,$2); }
|
|
|
|
;
|
|
|
|
|
|
|
|
property_spec_disable<nodep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| yDISABLE yIFF '(' expr ')' { $$ = $4; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
assertStmt<nodep>:
|
|
|
|
yASSERT '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstVAssert($1,$3,$5, V3Parse::createDisplayError($1)); }
|
2007-05-14 20:59:58 +00:00
|
|
|
| yASSERT '(' expr ')' yELSE stmtBlock { $$ = new AstVAssert($1,$3,NULL,$6); }
|
|
|
|
| yASSERT '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstVAssert($1,$3,$5,$7); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
|
|
|
// PSL Statements
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslStmt<nodep>:
|
|
|
|
yPSL pslDir stateExitPsl { $$ = $2; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yPSL pslDecl stateExitPsl { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslDir<nodep>:
|
2008-08-06 16:52:39 +00:00
|
|
|
yaID ':' pslDirOne { $$ = $3; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| pslDirOne { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslDirOne<nodep>:
|
2008-08-06 16:52:39 +00:00
|
|
|
yPSL_ASSERT pslProp ';' { $$ = new AstPslAssert($1,$2); }
|
|
|
|
| yPSL_ASSERT pslProp yPSL_REPORT yaSTRING ';' { $$ = new AstPslAssert($1,$2,*$4); }
|
|
|
|
| yPSL_COVER pslProp ';' { $$ = new AstPslCover($1,$2,NULL); }
|
|
|
|
| yPSL_COVER pslProp yPSL_REPORT yaSTRING ';' { $$ = new AstPslCover($1,$2,NULL,*$4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslDecl<nodep>:
|
2008-09-23 00:10:10 +00:00
|
|
|
yDEFAULT yPSL_CLOCK '=' senitemEdge ';' { $$ = new AstPslDefClock($3, $4); }
|
2008-08-06 16:52:39 +00:00
|
|
|
| yDEFAULT yPSL_CLOCK '=' '(' senitemEdge ')' ';' { $$ = new AstPslDefClock($3, $5); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
|
|
|
// PSL Properties, Sequences and SEREs
|
|
|
|
// Don't use '{' or '}'; in PSL they're yPSL_BRA and yPSL_KET to avoid expr concatenates
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslProp<nodep>:
|
|
|
|
pslSequence { $$ = $1; }
|
2008-08-06 16:52:39 +00:00
|
|
|
| pslSequence '@' %prec prPSLCLK '(' senitemEdge ')' { $$ = new AstPslClocked($2,$4,NULL,$1); } // or pslSequence @ ...?
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslSequence<nodep>:
|
|
|
|
yPSL_BRA pslSere yPSL_KET { $$ = $2; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslSere<nodep>:
|
|
|
|
pslExpr { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| pslSequence { $$ = $1; } // Sequence containing sequence
|
|
|
|
;
|
|
|
|
|
|
|
|
// Undocumented PSL rule is that {} is always a SERE; concatenation is not allowed.
|
|
|
|
// This can be bypassed with the _(...) embedding of any arbitrary expression.
|
2008-08-06 16:35:34 +00:00
|
|
|
pslExpr<nodep>:
|
|
|
|
exprPsl { $$ = new AstPslBool($1->fileline(), $1); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yTRUE { $$ = new AstPslBool($1, new AstConst($1, V3Number($1,1,1))); }
|
|
|
|
;
|
|
|
|
|
|
|
|
//**********************************************************************
|
|
|
|
%%
|
|
|
|
|
2007-11-02 11:23:03 +00:00
|
|
|
void V3Read::parserClear() {
|
|
|
|
// Clear up any dynamic memory V3Parser required
|
|
|
|
V3Parse::setRange(NULL);
|
|
|
|
}
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
AstNode* V3Parse::createSupplyExpr(FileLine* fileline, string name, int value) {
|
|
|
|
FileLine* newfl = new FileLine (fileline);
|
|
|
|
newfl->warnOff(V3ErrorCode::WIDTH, true);
|
|
|
|
AstNode* nodep = new AstConst(newfl, V3Number(fileline));
|
2007-11-30 22:12:53 +00:00
|
|
|
// Adding a NOT is less work than figuring out how wide to make it
|
2006-08-26 11:35:28 +00:00
|
|
|
if (value) nodep = new AstNot(newfl, nodep);
|
|
|
|
nodep = new AstAssignW(newfl, new AstVarRef(fileline, name, true),
|
|
|
|
nodep);
|
|
|
|
return nodep;
|
|
|
|
}
|
|
|
|
|
|
|
|
AstVar* V3Parse::createVariable(FileLine* fileline, string name, AstRange* arrayp) {
|
|
|
|
AstVarType type = V3Parse::s_varIO;
|
|
|
|
AstRange* rangep = V3Parse::s_varRangep;
|
2007-11-02 11:23:03 +00:00
|
|
|
AstRange* cleanup_rangep = NULL;
|
2007-05-16 18:19:23 +00:00
|
|
|
//UINFO(0,"CREVAR "<<fileline->ascii()<<" decl="<<V3Parse::s_varDecl.ascii()<<" io="<<V3Parse::s_varIO.ascii()<<endl);
|
2006-08-26 11:35:28 +00:00
|
|
|
if (type == AstVarType::UNKNOWN) type = V3Parse::s_varDecl;
|
|
|
|
if (type == AstVarType::UNKNOWN) fileline->v3fatalSrc("Unknown signal type declared");
|
|
|
|
// Linting, because we allow parsing of a superset of the language
|
2007-05-16 18:19:23 +00:00
|
|
|
if (type == AstVarType::INTEGER || V3Parse::s_varDecl == AstVarType::INTEGER
|
|
|
|
|| type == AstVarType::GENVAR) {
|
2006-08-26 11:35:28 +00:00
|
|
|
if (rangep) fileline->v3error("Integers may not be ranged: "<<name);
|
2007-11-02 11:23:03 +00:00
|
|
|
cleanup_rangep = new AstRange(fileline, 31, 0); // Integer == REG[31:0]
|
|
|
|
rangep = cleanup_rangep;
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
|
|
|
if (type == AstVarType::GENVAR) {
|
|
|
|
if (arrayp) fileline->v3error("Genvars may not be arrayed: "<<name);
|
|
|
|
}
|
|
|
|
AstVar* nodep = new AstVar(fileline, type, name,
|
|
|
|
rangep->cloneTree(false),
|
|
|
|
arrayp);
|
|
|
|
nodep->isSigned(V3Parse::s_varSigned);
|
2008-03-17 20:58:43 +00:00
|
|
|
if (type == AstVarType::INTEGER || V3Parse::s_varDecl == AstVarType::INTEGER
|
|
|
|
|| type == AstVarType::GENVAR) {
|
|
|
|
nodep->isSigned(true);
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
if (V3Parse::s_varDecl != AstVarType::UNKNOWN) nodep->combineType(V3Parse::s_varDecl);
|
|
|
|
if (V3Parse::s_varIO != AstVarType::UNKNOWN) nodep->combineType(V3Parse::s_varIO);
|
|
|
|
|
|
|
|
if (V3Parse::s_varDecl == AstVarType::SUPPLY0) {
|
|
|
|
nodep->addNext(V3Parse::createSupplyExpr(fileline, nodep->name(), 0));
|
|
|
|
}
|
|
|
|
if (V3Parse::s_varDecl == AstVarType::SUPPLY1) {
|
|
|
|
nodep->addNext(V3Parse::createSupplyExpr(fileline, nodep->name(), 1));
|
|
|
|
}
|
|
|
|
// Clear any widths that got presumed by the ranging;
|
|
|
|
// We need to autosize parameters and integers separately
|
|
|
|
nodep->width(0,0);
|
|
|
|
// Propagate from current module tracing state
|
|
|
|
if (nodep->isGenVar() || nodep->isParam()) nodep->trace(false);
|
2008-12-11 21:01:41 +00:00
|
|
|
else nodep->trace(v3Global.opt.trace() && nodep->fileline()->tracingOn());
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
// Remember the last variable created, so we can attach attributes to it in later parsing
|
|
|
|
V3Parse::s_varAttrp = nodep;
|
2007-11-02 11:23:03 +00:00
|
|
|
if (cleanup_rangep) { cleanup_rangep->deleteTree(); cleanup_rangep=NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
return nodep;
|
|
|
|
}
|
|
|
|
|
|
|
|
string V3Parse::deQuote(FileLine* fileline, string text) {
|
|
|
|
// Fix up the quoted strings the user put in, for example "\"" becomes "
|
|
|
|
bool quoted = false;
|
|
|
|
string newtext;
|
|
|
|
unsigned char octal_val = 0;
|
|
|
|
int octal_digits = 0;
|
|
|
|
for (const char* cp=text.c_str(); *cp; ++cp) {
|
|
|
|
if (quoted) {
|
|
|
|
if (isdigit(*cp)) {
|
|
|
|
octal_val = octal_val*8 + (*cp-'0');
|
|
|
|
if (++octal_digits == 3) {
|
|
|
|
octal_digits = 0;
|
|
|
|
quoted = false;
|
|
|
|
newtext += octal_val;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (octal_digits) {
|
2008-06-27 21:52:45 +00:00
|
|
|
// Spec allows 1-3 digits
|
2006-08-26 11:35:28 +00:00
|
|
|
octal_digits = 0;
|
2008-06-27 21:52:45 +00:00
|
|
|
quoted = false;
|
|
|
|
newtext += octal_val;
|
|
|
|
--cp; // Backup to reprocess terminating character as non-escaped
|
|
|
|
continue;
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
|
|
|
quoted = false;
|
|
|
|
if (*cp == 'n') newtext += '\n';
|
|
|
|
else if (*cp == 'a') newtext += '\a'; // SystemVerilog 3.1
|
|
|
|
else if (*cp == 'f') newtext += '\f'; // SystemVerilog 3.1
|
|
|
|
else if (*cp == 'r') newtext += '\r';
|
|
|
|
else if (*cp == 't') newtext += '\t';
|
|
|
|
else if (*cp == 'v') newtext += '\v'; // SystemVerilog 3.1
|
|
|
|
else if (*cp == 'x' && isxdigit(cp[1]) && isxdigit(cp[2])) { // SystemVerilog 3.1
|
|
|
|
#define vl_decodexdigit(c) ((isdigit(c)?((c)-'0'):(tolower((c))-'a'+10)))
|
|
|
|
newtext += (char)(16*vl_decodexdigit(cp[1]) + vl_decodexdigit(cp[2]));
|
|
|
|
cp += 2;
|
|
|
|
}
|
|
|
|
else if (isalnum(*cp)) {
|
|
|
|
fileline->v3error("Unknown escape sequence: \\"<<*cp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else newtext += *cp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*cp == '\\') {
|
|
|
|
quoted = true;
|
|
|
|
octal_digits = 0;
|
|
|
|
}
|
|
|
|
else if (*cp != '"') {
|
|
|
|
newtext += *cp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newtext;
|
|
|
|
}
|
|
|
|
|
|
|
|
AstText* V3Parse::createTextQuoted(FileLine* fileline, string text) {
|
|
|
|
string newtext = deQuote(fileline, text);
|
|
|
|
return new AstText(fileline, newtext);
|
|
|
|
}
|
2006-12-21 14:35:19 +00:00
|
|
|
|
|
|
|
// Local Variables:
|
|
|
|
// compile-command: "cd obj_dbg ; /usr/bin/bison -y -d -v ../verilog.y ; cat y.output"
|
|
|
|
// End:
|