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
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2008-01-15 14:29:08 +00:00
|
|
|
// Copyright 2003-2008 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
|
|
|
|
// General Public License or the Perl Artistic License.
|
|
|
|
//
|
|
|
|
// 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
|
2007-05-17 16:15:24 +00:00
|
|
|
#define YYMAXDEPTH 1000
|
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
|
|
|
|
static bool s_trace; // Tracing is turned on
|
|
|
|
|
|
|
|
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;
|
|
|
|
bool V3Parse::s_trace = false; // Set on first module creation
|
|
|
|
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;
|
|
|
|
|
|
|
|
AstNode* nodep;
|
|
|
|
|
|
|
|
AstAssignW* assignwp;
|
|
|
|
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;
|
|
|
|
AstSenItem* senitemp;
|
|
|
|
AstSenTree* sentreep;
|
|
|
|
AstVar* varp;
|
|
|
|
AstVarRef* varrefp;
|
|
|
|
}
|
|
|
|
|
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"
|
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"
|
|
|
|
// 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"
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
%token<fileline> yCASE "case"
|
|
|
|
%token<fileline> yCASEX "casex"
|
|
|
|
%token<fileline> yCASEZ "casez"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yCLOCK "clock"
|
|
|
|
%token<fileline> yCOVER "cover"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yDEFAULT "default"
|
|
|
|
%token<fileline> yDEFPARAM "defparam"
|
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"
|
|
|
|
%token<fileline> yENDFUNCTION "endfunction"
|
|
|
|
%token<fileline> yENDGENERATE "endgenerate"
|
|
|
|
%token<fileline> yENDMODULE "endmodule"
|
|
|
|
%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"
|
|
|
|
%token<fileline> yFUNCTION "function"
|
|
|
|
%token<fileline> yGENERATE "generate"
|
|
|
|
%token<fileline> yGENVAR "genvar"
|
|
|
|
%token<fileline> yIF "if"
|
|
|
|
%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"
|
|
|
|
%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"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yPSL "psl"
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yREG "reg"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yREPORT "report"
|
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"
|
|
|
|
%token<fileline> yTRI "tri"
|
2006-12-19 14:09:57 +00:00
|
|
|
%token<fileline> yTRUE "true"
|
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
|
|
|
|
2007-05-12 16:29:25 +00:00
|
|
|
%token<fileline> yPSL_ASSERT "PSL assert"
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
%token<fileline> yVL_CLOCK "/*verilator sc_clock*/"
|
|
|
|
%token<fileline> yVL_CLOCK_ENABLE "/*verilator clock_enable*/"
|
|
|
|
%token<fileline> yVL_COVER_OFF "/*verilator coverage_block_off*/"
|
|
|
|
%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*/"
|
|
|
|
%token<fileline> yVL_TRACING_OFF "/*verilator tracing_off*/"
|
|
|
|
%token<fileline> yVL_TRACING_ON "/*verilator tracing_on*/"
|
|
|
|
|
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
|
|
|
|
|
|
|
|
%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> '~'
|
2006-08-26 11:35:28 +00:00
|
|
|
|
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
|
|
|
|
// '{ could be an operator. More research needed.
|
|
|
|
|
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
|
2007-11-05 21:38:20 +00:00
|
|
|
%left ':'
|
|
|
|
%left '?'
|
|
|
|
%left yP_OROR
|
|
|
|
%left yP_ANDAND
|
|
|
|
%left '|' yP_NOR
|
|
|
|
%left '^'
|
|
|
|
%left yP_XNOR
|
|
|
|
%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
|
|
|
|
%left '{' '}'
|
|
|
|
%left<fileline> prUNARYARITH
|
|
|
|
%left<fileline> prREDUCTION
|
|
|
|
%left<fileline> 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
|
|
|
|
|
|
|
|
// Types are in same order as declarations.
|
|
|
|
// Naming:
|
|
|
|
// Trailing E indicates this type may have empty match
|
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
|
|
|
|
2008-03-25 13:42:48 +00:00
|
|
|
%start fileE
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
%%
|
|
|
|
//**********************************************************************
|
|
|
|
// Feedback to the Lexer
|
|
|
|
|
2007-05-16 12:55:25 +00:00
|
|
|
stateExitPsl: /* empty */ { V3Read::stateExitPsl(); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2007-05-16 12:55:25 +00:00
|
|
|
statePushVlg: /* empty */ { V3Read::statePushVlg(); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
2007-05-16 12:55:25 +00:00
|
|
|
statePop: /* 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
|
|
|
|
2008-03-25 13:42:48 +00:00
|
|
|
fileE: /* empty */ { }
|
|
|
|
| file { }
|
|
|
|
;
|
|
|
|
|
|
|
|
file: description { }
|
|
|
|
| file description { }
|
2007-10-31 20:11:59 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
// IEEE: description
|
|
|
|
description: moduleDecl { }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
//**********************************************************************
|
|
|
|
// Module headers
|
|
|
|
|
2007-10-31 20:11:59 +00:00
|
|
|
// IEEE: module_declaration:
|
|
|
|
moduleDecl: modHdr modParE modPortsE ';' modItemListE yENDMODULE endLabelE
|
2006-08-26 11:35:28 +00:00
|
|
|
{ $1->modTrace(V3Parse::s_trace); // Stash for implicit wires, etc
|
|
|
|
if ($2) $1->addStmtp($2); if ($3) $1->addStmtp($3); if ($5) $1->addStmtp($5); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modHdr<modulep>:
|
|
|
|
yMODULE { V3Parse::s_trace=v3Global.opt.trace();}
|
2007-05-16 12:55:25 +00:00
|
|
|
yaID { $$ = new AstModule($1,*$3); $$->inLibrary(V3Read::inLibrary()||V3Read::inCellDefine());
|
2006-08-26 11:35:28 +00:00
|
|
|
$$->modTrace(v3Global.opt.trace());
|
|
|
|
V3Read::rootp()->addModulep($$); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modParE<nodep>:
|
|
|
|
/* 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
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modPortsE<nodep>:
|
|
|
|
/* 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>:
|
|
|
|
varRESET portDirection v2kVarDeclE signingE regrangeE portV2kInit { $$ = $6; }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
2007-10-31 20:11:59 +00:00
|
|
|
// IEEE: port_declaration - plus ';'
|
2008-08-06 16:35:34 +00:00
|
|
|
portDecl<nodep>:
|
|
|
|
varRESET portDirection 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; }
|
|
|
|
| varRESET varNet signingE delayrange netSigList ';' { $$ = $5; }
|
|
|
|
| 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
|
|
|
|
|
|
|
varRESET: /* empty */ { VARRESET(); }
|
|
|
|
;
|
|
|
|
|
|
|
|
varNet: ySUPPLY0 { VARDECL(SUPPLY0); }
|
|
|
|
| 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
|
|
|
|
|
|
|
//IEEE: port_direction
|
|
|
|
portDirection: yINPUT { VARIO(INPUT); }
|
|
|
|
| yOUTPUT { VARIO(OUTPUT); }
|
|
|
|
| yINOUT { VARIO(INOUT); }
|
|
|
|
// | yREF { VARIO(REF); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: signing - plus empty
|
|
|
|
signingE: /*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
|
|
|
;
|
|
|
|
|
2008-04-04 18:29:33 +00:00
|
|
|
v2kVarDeclE: /*empty*/ { }
|
2006-08-26 11:35:28 +00:00
|
|
|
| varNet { }
|
|
|
|
| varReg { }
|
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
2007-05-14 20:59:58 +00:00
|
|
|
// Module Items
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modItemListE<nodep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| modItemList { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modItemList<nodep>:
|
|
|
|
modItem { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| modItemList modItem { $$ = $1->addNextNull($2); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modItem<nodep>:
|
|
|
|
modOrGenItem { $$ = $1; }
|
2007-10-31 20:11:59 +00:00
|
|
|
| generateRegion { $$ = $1; }
|
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); }
|
|
|
|
| yVL_TRACING_OFF { $$ = NULL; V3Parse::s_trace=false; }
|
|
|
|
| yVL_TRACING_ON { $$ = NULL; V3Parse::s_trace=v3Global.opt.trace(); }
|
|
|
|
| ySPECIFY specifyJunkList yENDSPECIFY { $$ = NULL; }
|
|
|
|
| ySPECIFY yENDSPECIFY { $$ = NULL; }
|
|
|
|
;
|
|
|
|
|
2007-10-31 20:11:59 +00:00
|
|
|
// IEEE: generate_region
|
2008-08-06 16:35:34 +00:00
|
|
|
generateRegion<nodep>:
|
|
|
|
yGENERATE genTopBlock yENDGENERATE { $$ = new AstGenerate($1, $2); }
|
2007-10-31 20:11:59 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
modOrGenItem<nodep>:
|
|
|
|
yALWAYS eventControlE stmtBlock { $$ = new AstAlways($1,$2,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yFINAL stmtBlock { $$ = new AstFinal($1,$2); }
|
|
|
|
| yINITIAL stmtBlock { $$ = new AstInitial($1,$2); }
|
|
|
|
| yASSIGN delayE assignList ';' { $$ = $3; }
|
|
|
|
| yDEFPARAM defpList ';' { $$ = $2; }
|
2007-05-16 12:55:25 +00:00
|
|
|
| instDecl { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| taskDecl { $$ = $1; }
|
|
|
|
| funcDecl { $$ = $1; }
|
|
|
|
| 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; }
|
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
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
|
2008-08-06 16:35:34 +00:00
|
|
|
genItemBlock<nodep>:
|
|
|
|
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; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
genItemBegin<nodep>:
|
|
|
|
yBEGIN genItemList yEND { $$ = new AstBegin($1,"genblk",$2); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yBEGIN yEND { $$ = 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); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
genItem<nodep>:
|
|
|
|
modOrGenItem { $$ = $1; }
|
2007-05-18 14:03:50 +00:00
|
|
|
| yCASE '(' expr ')' genCaseListE yENDCASE { $$ = new AstGenCase($1,$3,$5); }
|
2008-06-05 20:49:52 +00:00
|
|
|
| yIF '(' expr ')' genItemBlock %prec prLOWER_THAN_ELSE { $$ = new AstGenIf($1,$3,$5,NULL); }
|
|
|
|
| yIF '(' expr ')' genItemBlock yELSE genItemBlock { $$ = new AstGenIf($1,$3,$5,$7); }
|
2006-12-21 16:29:10 +00:00
|
|
|
| yFOR '(' varRefBase '=' expr ';' expr ';' varRefBase '=' expr ')' genItemBlock
|
2006-08-26 11:35:28 +00:00
|
|
|
{ $$ = new AstGenFor($1, new AstAssign($4,$3,$5)
|
|
|
|
,$7, new AstAssign($10,$9,$11)
|
|
|
|
,$13);}
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
genCaseListE<nodep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2007-05-18 14:03:50 +00:00
|
|
|
| genCaseList { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
genCaseList<nodep>:
|
|
|
|
caseCondList ':' genItemBlock { $$ = new AstCaseItem($2,$1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yDEFAULT ':' genItemBlock { $$ = new AstCaseItem($2,NULL,$3); }
|
|
|
|
| yDEFAULT genItemBlock { $$ = new AstCaseItem($1,NULL,$2); }
|
2007-05-14 20:59:58 +00:00
|
|
|
| genCaseList caseCondList ':' genItemBlock { $$ = $1;$1->addNext(new AstCaseItem($3,$2,$4)); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| genCaseList yDEFAULT genItemBlock { $$ = $1;$1->addNext(new AstCaseItem($2,NULL,$3)); }
|
|
|
|
| genCaseList yDEFAULT ':' genItemBlock { $$ = $1;$1->addNext(new AstCaseItem($3,NULL,$4)); }
|
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
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); }
|
2006-12-21 14:35:19 +00:00
|
|
|
| '{' concIdList '}' '=' expr { $$ = new AstAssignW($1,$2,$5); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-05-16 18:19:23 +00:00
|
|
|
delayE: /* empty */ { }
|
|
|
|
| delay { } /* ignored */
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
delay<fileline>:
|
|
|
|
'#' 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; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-03-31 21:03:56 +00:00
|
|
|
// IEEE: mintypmax_expression and constant_mintypmax_expression
|
2008-08-06 16:35:34 +00:00
|
|
|
minTypMax<nodep>:
|
|
|
|
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);
|
2006-08-26 11:35:28 +00:00
|
|
|
$$->addNext(new AstInitial($3,new AstAssign($3, new AstVarRef($3, $$, true), $4))); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
sigId<varp>: yaID { $$ = V3Parse::createVariable(CRELINE(), *$1, NULL); }
|
2007-05-14 20:59:58 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
regsig<varp>: regSigId sigAttrListE {}
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-05-16 12:55:25 +00:00
|
|
|
sigAttrListE: /* empty */ {}
|
2006-08-26 11:35:28 +00:00
|
|
|
| sigAttrList {}
|
|
|
|
;
|
|
|
|
|
|
|
|
sigAttrList: sigAttr {}
|
|
|
|
| sigAttrList sigAttr {}
|
|
|
|
;
|
|
|
|
|
|
|
|
sigAttr: yVL_CLOCK { V3Parse::s_varAttrp->attrScClocked(true); }
|
|
|
|
| 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; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
rangeList<rangep>:
|
|
|
|
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); }
|
|
|
|
;
|
|
|
|
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: list_of_defparam_assignments
|
2008-08-06 16:35:34 +00:00
|
|
|
defpList<nodep>:
|
|
|
|
defpOne { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| defpList ',' defpOne { $$ = $1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
defpOne<nodep>:
|
|
|
|
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;}
|
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
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
eventControlE<sentreep>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2007-10-26 14:58:26 +00:00
|
|
|
| eventControl { $$ = $1; }
|
2007-05-16 19:27:29 +00:00
|
|
|
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: event_control
|
2008-08-06 16:35:34 +00:00
|
|
|
eventControl<sentreep>:
|
|
|
|
'@' '(' senList ')' { $$ = new AstSenTree($1,$3); }
|
2007-05-18 18:48:22 +00:00
|
|
|
| '@' senitemVar { $$ = new AstSenTree($1,$2); } /* For events only */
|
2008-02-14 02:08:10 +00:00
|
|
|
| '@' '(' '*' ')' { $$ = NULL; } /* Verilog 2001 */
|
2006-08-26 11:35:28 +00:00
|
|
|
| '@' '*' { $$ = NULL; } /* Verilog 2001 */
|
|
|
|
;
|
|
|
|
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: event_expression - split over several
|
2008-08-06 16:35:34 +00:00
|
|
|
senList<senitemp>:
|
|
|
|
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
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
senitemEdge<senitemp>:
|
|
|
|
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
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
stmtBlock<nodep>:
|
|
|
|
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)); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
stmt<nodep>:
|
|
|
|
';' { $$ = 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*/
|
2007-03-06 21:43:38 +00:00
|
|
|
|
2007-10-31 20:29:07 +00:00
|
|
|
| delay stmtBlock { $$ = $2; $1->v3warn(STMTDLY,"Ignoring delay on this delayed statement.\n"); }
|
|
|
|
|
2007-05-12 16:29:25 +00:00
|
|
|
| varRefDotBit yP_LTE delayE expr ';' { $$ = new AstAssignDly($2,$1,$4); }
|
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); }
|
|
|
|
| yASSIGN varRefDotBit '=' delayE expr ';' { $$ = new AstAssign($1,$2,$5); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| '{' concIdList '}' yP_LTE delayE expr ';' { $$ = new AstAssignDly($4,$2,$6); }
|
2006-12-21 14:35:19 +00:00
|
|
|
| '{' concIdList '}' '=' delayE expr ';' { $$ = new AstAssign($4,$2,$6); }
|
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); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yVL_COVER_OFF { $$ = new AstPragma($1,AstPragmaType::COVERAGE_BLOCK_OFF); }
|
|
|
|
| stateCaseForIf { $$ = $1; }
|
|
|
|
| taskRef ';' { $$ = $1; }
|
|
|
|
|
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(); }
|
2007-03-06 21:43:38 +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); }
|
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
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
stateCaseForIf<nodep>:
|
|
|
|
caseStmt caseAttrE caseListE yENDCASE { $$ = $1; if ($3) $1->addItemsp($3); }
|
2008-06-05 20:49:52 +00:00
|
|
|
| yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstIf($1,$3,$5,NULL); }
|
|
|
|
| yIF '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstIf($1,$3,$5,$7); }
|
2006-12-21 16:29:10 +00:00
|
|
|
| yFOR '(' varRefBase '=' expr ';' expr ';' varRefBase '=' expr ')' stmtBlock
|
2006-08-26 11:35:28 +00:00
|
|
|
{ $$ = new AstFor($1, new AstAssign($4,$3,$5)
|
|
|
|
,$7, new AstAssign($10,$9,$11)
|
|
|
|
,$13);}
|
2007-03-13 18:21:23 +00:00
|
|
|
| yWHILE '(' expr ')' stmtBlock { $$ = new AstWhile($1,$3,$5);}
|
|
|
|
| yDO stmtBlock yWHILE '(' expr ')' { $$ = $2->cloneTree(true); $$->addNext(new AstWhile($1,$5,$2));}
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
caseStmt<casep>:
|
|
|
|
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"); }
|
|
|
|
| yCASEZ '(' expr ')' { $$ = V3Parse::s_caseAttrp = new AstCase($1,AstCaseType::CASEZ,$3,NULL); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
caseAttrE: /*empty*/ { }
|
|
|
|
| caseAttrE yVL_FULL_CASE { V3Parse::s_caseAttrp->fullPragma(true); }
|
|
|
|
| caseAttrE yVL_PARALLEL_CASE { V3Parse::s_caseAttrp->parallelPragma(true); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
caseListE<caseitemp>:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2007-05-18 14:03:50 +00:00
|
|
|
| caseList { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
caseList<caseitemp>:
|
|
|
|
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); }
|
2007-05-14 20:59:58 +00:00
|
|
|
| caseList caseCondList ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,$2,$4)); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| caseList yDEFAULT stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($2,NULL,$3)); }
|
|
|
|
| caseList yDEFAULT ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,NULL,$4)); }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
caseCondList<nodep>:
|
|
|
|
expr { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| caseCondList ',' expr { $$ = $1;$1->addNext($3); }
|
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
|
|
|
// Functions/tasks
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
taskRef<nodep>:
|
|
|
|
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);}
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
funcRef<nodep>:
|
|
|
|
idDotted '(' exprList ')' { $$ = new AstFuncRef($2,new AstParseRef($1->fileline(), AstParseRefExp::FUNC, $1), $3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
taskDecl<nodep>:
|
|
|
|
yTASK lifetimeE yaID funcGuts yENDTASK endLabelE
|
2007-07-18 17:58:53 +00:00
|
|
|
{ $$ = new AstTask ($1,*$3,$4);}
|
2007-05-16 19:27:29 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
funcDecl<funcp>:
|
|
|
|
yFUNCTION lifetimeE funcTypeE yaID funcGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$4,$5,$3); }
|
2007-10-26 14:58:26 +00:00
|
|
|
| yFUNCTION lifetimeE ySIGNED funcTypeE yaID funcGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$5,$6,$4); $$->isSigned(true); }
|
|
|
|
| yFUNCTION lifetimeE funcTypeE yaID yVL_ISOLATE_ASSIGNMENTS funcGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$4,$6,$3); $$->attrIsolateAssign(true);}
|
|
|
|
| yFUNCTION lifetimeE ySIGNED funcTypeE yaID yVL_ISOLATE_ASSIGNMENTS funcGuts yENDFUNCTION endLabelE { $$ = new AstFunc ($1,*$5,$7,$4); $$->attrIsolateAssign(true); $$->isSigned(true); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-10-26 14:58:26 +00:00
|
|
|
// IEEE: lifetime - plus empty
|
|
|
|
lifetimeE: /* empty */ { }
|
|
|
|
| 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
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
funcGuts<nodep>:
|
|
|
|
'(' {V3Parse::s_pinNum=1;} portV2kArgs ')' ';' funcBody { $$ = $3->addNextNull($6); }
|
2007-06-19 23:43:14 +00:00
|
|
|
| ';' funcBody { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
funcBody<nodep>:
|
|
|
|
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
|
|
|
;
|
|
|
|
|
2007-09-17 17:54:02 +00:00
|
|
|
parenE: /* empty */ { }
|
|
|
|
| '(' ')' { }
|
|
|
|
;
|
|
|
|
|
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); }
|
|
|
|
|
|
|
|
| '-' 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); }
|
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
|
|
|
|
| '{' cateList '}' { $$ = $2; }
|
|
|
|
| '{' constExpr '{' cateList '}' '}' { $$ = new AstReplicate($1,$4,$2); }
|
|
|
|
|
|
|
|
| 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); }
|
|
|
|
|
2006-12-20 16:10:47 +00:00
|
|
|
| funcRef { $$ = $1; }
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2007-05-12 16:29:25 +00:00
|
|
|
| yaINTNUM { $$ = new AstConst(CRELINE(),*$1); }
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2006-12-21 16:29:10 +00:00
|
|
|
| varRefDotBit { $$ = $1; }
|
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>:
|
|
|
|
yBUF delayE gateBufList ';' { $$ = $3; }
|
2008-04-01 19:26:06 +00:00
|
|
|
| yNOT delayE gateNotList ';' { $$ = $3; }
|
|
|
|
| yAND delayE gateAndList ';' { $$ = $3; }
|
|
|
|
| yNAND delayE gateNandList ';' { $$ = $3; }
|
|
|
|
| yOR delayE gateOrList ';' { $$ = $3; }
|
|
|
|
| yNOR delayE gateNorList ';' { $$ = $3; }
|
|
|
|
| yXOR delayE gateXorList ';' { $$ = $3; }
|
|
|
|
| yXNOR delayE gateXnorList ';' { $$ = $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
|
|
|
;
|
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
|
|
|
;
|
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
|
|
|
;
|
|
|
|
|
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
|
|
|
;
|
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
|
|
|
;
|
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
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
gateIdE: /*empty*/ {}
|
|
|
|
| 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
|
|
|
|
2007-05-16 12:55:25 +00:00
|
|
|
specifyJunkList: specifyJunk {} /* ignored */
|
|
|
|
| specifyJunkList specifyJunk {} /* ignored */
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-05-14 20:59:58 +00:00
|
|
|
specifyJunk: dlyTerm {} /* ignored */
|
2006-08-26 11:35:28 +00:00
|
|
|
| ';' {}
|
|
|
|
| '!' {}
|
|
|
|
| '&' {}
|
|
|
|
| '(' {}
|
|
|
|
| ')' {}
|
2007-05-18 14:03:50 +00:00
|
|
|
| '*' {} | '/' {} | '%' {}
|
2006-08-26 11:35:28 +00:00
|
|
|
| '+' {} | '-' {}
|
|
|
|
| ',' {}
|
|
|
|
| ':' {}
|
|
|
|
| '$' {}
|
|
|
|
| '=' {}
|
|
|
|
| '>' {} | '<' {}
|
|
|
|
| '?' {}
|
|
|
|
| '^' {}
|
|
|
|
| '{' {} | '}' {}
|
|
|
|
| '[' {} | ']' {}
|
|
|
|
| '|' {}
|
|
|
|
| '~' {}
|
2007-11-05 21:38:20 +00:00
|
|
|
| '@' {}
|
2007-05-12 16:29:25 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
| yIF {}
|
|
|
|
| yNEGEDGE {}
|
|
|
|
| yPOSEDGE {}
|
2007-05-12 16:29:25 +00:00
|
|
|
|
|
|
|
| yaSTRING {}
|
|
|
|
| yaTIMINGSPEC {}
|
|
|
|
|
|
|
|
| yP_ANDAND {} | yP_GTE {} | yP_LTE {}
|
|
|
|
| yP_EQUAL {} | yP_NOTEQUAL {}
|
2007-05-18 14:03:50 +00:00
|
|
|
| yP_CASEEQUAL {} | yP_CASENOTEQUAL {}
|
2007-07-18 15:01:39 +00:00
|
|
|
| yP_WILDEQUAL {} | yP_WILDNOTEQUAL {}
|
2007-05-12 16:29:25 +00:00
|
|
|
| yP_XNOR {} | yP_NOR {} | yP_NAND {}
|
|
|
|
| yP_OROR {}
|
|
|
|
| yP_SLEFT {} | yP_SRIGHT {} | yP_SSRIGHT {}
|
|
|
|
| yP_PLUSCOLON {} | yP_MINUSCOLON {}
|
2007-05-18 14:03:50 +00:00
|
|
|
| yP_POW {}
|
2007-05-12 16:29:25 +00:00
|
|
|
|
2007-07-18 17:26:12 +00:00
|
|
|
| yP_MINUSGT {}
|
2007-05-12 16:29:25 +00:00
|
|
|
| yP_LOGIFF {}
|
2006-08-26 11:35:28 +00:00
|
|
|
| yPSL_BRA {}
|
|
|
|
| yPSL_KET {}
|
2007-10-23 20:54:29 +00:00
|
|
|
| yP_ORMINUSGT {}
|
|
|
|
| yP_OREQGT {}
|
2007-10-18 16:29:19 +00:00
|
|
|
| yP_EQGT {} | yP_ASTGT {}
|
2007-10-23 20:54:29 +00:00
|
|
|
| yP_ANDANDAND {}
|
|
|
|
| yP_MINUSGTGT {}
|
|
|
|
| yP_POUNDPOUND {}
|
|
|
|
| yP_DOTSTAR {}
|
|
|
|
| yP_ATAT {}
|
|
|
|
| yP_COLONCOLON {}
|
|
|
|
| yP_COLONEQ {}
|
|
|
|
| yP_COLONDIV {}
|
|
|
|
|
|
|
|
| yP_PLUSEQ {} | yP_MINUSEQ {}
|
|
|
|
| yP_TIMESEQ {}
|
|
|
|
| yP_DIVEQ {} | yP_MODEQ {}
|
|
|
|
| yP_ANDEQ {} | yP_OREQ {}
|
|
|
|
| yP_XOREQ {}
|
|
|
|
| yP_SLEFTEQ {} | yP_SRIGHTEQ {} | yP_SSRIGHTEQ {}
|
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); }
|
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); }
|
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
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
concIdList<nodep>:
|
|
|
|
varRefDotBit { $$ = $1; }
|
2007-05-14 20:59:58 +00:00
|
|
|
| concIdList ',' varRefDotBit { $$ = new AstConcat($2,$1,$3); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2007-07-18 17:58:53 +00:00
|
|
|
endLabelE: /* empty */ { }
|
|
|
|
| ':' 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: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>:
|
|
|
|
yaID ':' pslDirOne { $$ = $3; } // ADD: Create label on $1
|
2006-08-26 11:35:28 +00:00
|
|
|
| pslDirOne { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
//ADD: | yRESTRICT pslSequence ';' { $$ = PSLUNSUP(new AstPslRestrict($1,$2)); }
|
2008-08-06 16:35:34 +00:00
|
|
|
pslDirOne<nodep>:
|
|
|
|
yPSL_ASSERT pslProp ';' { $$ = new AstPslAssert($1,$2); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yPSL_ASSERT pslProp yREPORT yaSTRING ';' { $$ = new AstPslAssert($1,$2,*$4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yCOVER pslProp ';' { $$ = new AstPslCover($1,$2); }
|
2007-05-12 16:29:25 +00:00
|
|
|
| yCOVER pslProp yREPORT yaSTRING ';' { $$ = new AstPslCover($1,$2,*$4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
2008-08-06 16:35:34 +00:00
|
|
|
pslDecl<nodep>:
|
|
|
|
yDEFAULT yCLOCK '=' senitemEdge ';' { $$ = new AstPslDefClock($3, $4); }
|
2006-08-26 11:35:28 +00:00
|
|
|
| yDEFAULT yCLOCK '=' '(' senitemEdge ')' ';' { $$ = new AstPslDefClock($3, $5); }
|
|
|
|
;
|
|
|
|
|
|
|
|
//************************************************
|
|
|
|
// 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; }
|
2006-08-26 11:35:28 +00:00
|
|
|
| pslSequence '@' %prec prPSLCLK '(' senitemEdge ')' { $$ = new AstPslClocked($2, $4, $1); } // or pslSequence @ ...?
|
|
|
|
;
|
|
|
|
|
|
|
|
//ADD: | pslCallSeq { $$ = PSLUNSUP($1); }
|
|
|
|
//ADD: | pslRepeat { $$ = PSLUNSUP($1); }
|
2008-08-06 16:35:34 +00:00
|
|
|
pslSequence<nodep>:
|
|
|
|
yPSL_BRA pslSere yPSL_KET { $$ = $2; }
|
2006-08-26 11:35:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
//ADD: | pslSere ';' pslSere %prec prPSLCONC { $$ = PSLUNSUP(new AstPslSeqConcat($2, $1, $3)); }
|
|
|
|
//ADD: | pslSere ':' pslSere %prec prPSLFUS { $$ = PSLUNSUP(new AstPslSeqFusion($2, $1, $3)); }
|
|
|
|
//ADD: | pslSereCpnd { $$ = $1; }
|
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.
|
|
|
|
//ADD: | pslFunc { $$ = UNSUP($1); }
|
|
|
|
//ADD: | pslExpr yUNION pslExpr { $$ = UNSUP(new AstPslUnion($2, $1, $3)); }
|
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);
|
|
|
|
else nodep->trace(V3Parse::s_trace);
|
|
|
|
|
|
|
|
// 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:
|