Search is not available for this dataset
content
stringlengths 0
376M
|
---|
<gh_stars>10-100
/* $Id: parse.y,v 1.4 2004-10-18 12:16:32 vak Exp $ */
/*
* Copyright (c) 2004 <NAME>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
%{
static const char rcsid[] = "$Id: parse.y,v 1.4 2004-10-18 12:16:32 vak Exp $";
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libmilter/mfapi.h>
#include "eval.h"
int yyerror(char *, ...);
static int yyparse(void);
static int define_macro(const char *, struct expr *);
static struct expr *find_macro(const char *);
static char *err_str = NULL;
static size_t err_len = 0;
static const char *infile = NULL;
static FILE *fin = NULL;
static int lineno = 1;
static int errors = 0;
static struct ruleset *rs = NULL;
struct macro {
char *name;
struct expr *expr;
struct macro *next;
} *macros = NULL;
typedef struct {
union {
char *string;
struct expr *expr;
struct expr_list *expr_list;
struct action *action;
} v;
int lineno;
} YYSTYPE;
%}
%token ERROR STRING
%token ACCEPT REJECT TEMPFAIL DISCARD CONTINUE
%token CONNECT HELO ENVFROM ENVRCPT HEADER BODY
%token AND OR NOT
%type <v.string> STRING
%type <v.expr> expr term
%type <v.expr_list> expr_l
%type <v.action> action
%%
file : /* empty */
| macro file { }
| rule file { }
;
rule : action expr_l {
struct expr_list *el = $2, *eln;
while (el != NULL) {
eln = el->next;
el->expr->action = $1;
free(el);
el = eln;
}
}
;
macro : STRING '=' expr {
if (define_macro($1, $3))
YYERROR;
free($1);
}
;
action : REJECT STRING {
$$ = create_action(rs, SMFIS_REJECT, $2);
if ($$ == NULL) {
yyerror("yyparse: create_action");
YYERROR;
}
free($2);
}
| TEMPFAIL STRING {
$$ = create_action(rs, SMFIS_TEMPFAIL, $2);
if ($$ == NULL) {
yyerror("yyparse: create_action");
YYERROR;
}
free($2);
}
| DISCARD {
$$ = create_action(rs, SMFIS_DISCARD, "");
if ($$ == NULL) {
yyerror("yyparse: create_action");
YYERROR;
}
}
| CONTINUE {
$$ = create_action(rs, SMFIS_CONTINUE, "");
if ($$ == NULL) {
yyerror("yyparse: create_action");
YYERROR;
}
}
| ACCEPT {
$$ = create_action(rs, SMFIS_ACCEPT, "");
if ($$ == NULL) {
yyerror("yyparse: create_action");
YYERROR;
}
}
;
expr_l : expr {
$$ = calloc(1, sizeof(struct expr_list));
if ($$ == NULL) {
yyerror("yyparse: calloc: %s", strerror(errno));
YYERROR;
}
$$->expr = $1;
}
| expr_l expr {
$$ = calloc(1, sizeof(struct expr_list));
if ($$ == NULL) {
yyerror("yyparse: calloc: %s", strerror(errno));
YYERROR;
}
$$->expr = $2;
$$->next = $1;
}
;
expr : term {
$$ = $1;
}
| term AND expr {
$$ = create_expr(rs, EXPR_AND, $1, $3);
if ($$ == NULL) {
yyerror("yyparse: create_expr");
YYERROR;
}
}
| term OR expr {
$$ = create_expr(rs, EXPR_OR, $1, $3);
if ($$ == NULL) {
yyerror("yyparse: create_expr");
YYERROR;
}
}
| NOT term {
$$ = create_expr(rs, EXPR_NOT, $2, NULL);
if ($$ == NULL) {
yyerror("yyparse: create_expr");
YYERROR;
}
}
;
term : CONNECT STRING STRING {
$$ = create_cond(rs, COND_CONNECT, $2, $3, 0);
if ($$ == NULL)
YYERROR;
free($2);
free($3);
}
| HELO STRING {
$$ = create_cond(rs, COND_HELO, $2, NULL, 0);
if ($$ == NULL)
YYERROR;
free($2);
}
| ENVFROM STRING {
$$ = create_cond(rs, COND_ENVFROM, $2, NULL, 0);
if ($$ == NULL)
YYERROR;
free($2);
}
| ENVRCPT STRING {
$$ = create_cond(rs, COND_ENVRCPT, $2, NULL, 0);
if ($$ == NULL)
YYERROR;
free($2);
}
| '*' ENVRCPT STRING {
$$ = create_cond(rs, COND_ENVRCPT, $3, NULL, 1);
if ($$ == NULL)
YYERROR;
free($3);
}
| HEADER STRING STRING {
$$ = create_cond(rs, COND_HEADER, $2, $3, 0);
if ($$ == NULL)
YYERROR;
free($2);
free($3);
}
| '*' HEADER STRING STRING {
$$ = create_cond(rs, COND_HEADER, $3, $4, 1);
if ($$ == NULL)
YYERROR;
free($3);
free($4);
}
| BODY STRING {
$$ = create_cond(rs, COND_BODY, $2, NULL, 0);
if ($$ == NULL)
YYERROR;
free($2);
}
| '(' expr ')' {
$$ = $2;
}
| '$' STRING {
$$ = find_macro($2);
if ($$ == NULL) {
yyerror("yyparse: undefined macro '%s'", $2);
YYERROR;
}
free($2);
}
;
%%
int
yyerror(char *fmt, ...)
{
va_list ap;
errors = 1;
if (err_str == NULL || err_len <= 0)
return (0);
va_start(ap, fmt);
snprintf(err_str, err_len, "%s:%d: ", infile, yylval.lineno);
vsnprintf(err_str + strlen(err_str), err_len - strlen(err_str),
fmt, ap);
va_end(ap);
return (0);
}
struct keywords {
const char *k_name;
int k_val;
};
static int
kw_cmp(const void *k, const void *e)
{
return (strcmp(k, ((struct keywords *)e)->k_name));
}
static int
lookup(char *s)
{
/* keep sorted */
static const struct keywords keywords[] = {
{ "accept", ACCEPT },
{ "and", AND },
{ "body", BODY },
{ "connect", CONNECT },
{ "continue", CONTINUE },
{ "discard", DISCARD },
{ "envfrom", ENVFROM },
{ "envrcpt", ENVRCPT },
{ "header", HEADER },
{ "helo", HELO },
{ "not", NOT },
{ "or", OR },
{ "reject", REJECT },
{ "tempfail", TEMPFAIL },
};
const struct keywords *p;
p = bsearch(s, keywords, sizeof(keywords) / sizeof(keywords[0]),
sizeof(keywords[0]), &kw_cmp);
if (p)
return (p->k_val);
else
return (STRING);
}
static char *
expand_string (char **dst, int *len, char *tail, int n)
{
/* Make enough space. */
if (tail + n >= *dst + *len) {
/* Allocate by 128 bytes. */
*len = (tail + n - *dst + 128) / 128 * 128;
*dst = realloc (*dst, *len);
if (! *dst)
return 0;
tail = *dst + strlen (*dst);
}
return tail;
}
/*
* Append file contents to the string.
* Rellocate the string when needed.
* 1) Remove comments "# test", ignore blank lines.
* 2) Remove leading and trailing spaces.
* 4) Insert '|' between lines.
* 5) Mask dots - replace by '\.'
* 6) Replace quastion marks by dots.
*/
static void
append_file (char **dst, int *len, char *filename)
{
FILE *fd;
char line [256], *p, *tail;
/*printf ("%d - %s\n", *len, filename);*/
fd = fopen (filename, "r");
if (! fd) {
perror (filename);
return;
}
/* Add '('. */
tail = expand_string (dst, len, *dst + strlen (*dst), 1);
if (! tail)
return;
*tail++ = '(';
*tail = 0;
while (fgets (line, sizeof(line), fd)) {
/* Remove trailing comment or newline. */
p = line;
strsep (&p, "#\n");
/* Remove trailing spaces. */
p = line + strlen (line) - 1;
while (p>=line && (*p==' ' || *p == '\t' || *p == '\r'))
*p-- = 0;
if (p < line)
continue;
/* Remove spaces at line beginning. */
p = line;
while (*p==' ' || *p == '\t' || *p == '\r' || *p == '\n')
++p;
if (*p == 0)
continue;
/* Make enough space. */
tail = expand_string (dst, len, tail, 2 * strlen (p) + 1);
if (! tail)
return;
/*printf ("%d/%d>\t[%d] `%s'\n", tail - *dst, *len, strlen (p), p);*/
/* Copy line. Escape dots - replace by '\.'
* Question marks replace by dots. */
for (; *p; ++p) {
if (*p == '.') {
*tail++ = '\\';
*tail++ = '.';
} else if (*p == '?')
*tail++ = '.';
else
*tail++ = *p;
}
/* Add '|'. */
*tail++ = '|';
*tail = 0;
}
/* Remove trailing '('. */
if (*(tail-1) == '(')
*--tail = 0;
/* Replace trailing '|' by ')'. */
else if (*(tail-1) == '|')
*(tail-1) = ')';
fclose (fd);
}
/*
* Scan string, searching for file name. Replace the file name by
* file contents. Return the copy of string, allocated by malloc().
*/
static char *
scan_file_ref (char *str)
{
char *dst, *p, *q;
int len;
len = strlen (str) + 1;
dst = malloc (len);
if (! dst)
return 0;
for (p=dst; p<dst+len-1; ) {
if (*str != '=' || str[1] != '(') {
if (*str == '\\' && str[1] == '=') {
/* Translate '\=' to '='. */
++str;
}
*p++ = *str++;
continue;
}
/* Got '=(', search for ')'. */
q = strchr (str, ')');
if (! q)
continue;
*q = 0;
/* Got file name, append file contents. */
*p = 0;
append_file (&dst, &len, str+2);
if (! dst)
return 0;
/* Scan the rest of string. */
p = dst + strlen (dst);
str = q+1;
}
*p = 0;
return dst;
}
static int
lgetc(FILE *fin)
{
int c, next;
restart:
c = getc(fin);
if (c == '\\') {
next = getc(fin);
if (next != '\n') {
ungetc(next, fin);
return (c);
}
yylval.lineno = lineno;
lineno++;
goto restart;
}
return (c);
}
static int
lungetc(int c, FILE *fin)
{
return ungetc(c, fin);
}
int
yylex(void)
{
int c;
top:
yylval.lineno = lineno;
while ((c = lgetc(fin)) == ' ' || c == '\t')
;
if (c == '#')
while ((c = lgetc(fin)) != '\n' && c != EOF)
;
if (c == '\"' || c == '\'') {
char del = c;
char buf[8192], *p = buf;
while ((c = lgetc(fin)) != EOF && c != del) {
*p++ = c;
if (p - buf >= sizeof(buf) - 1) {
yyerror("yylex: message too long");
return (ERROR);
}
}
*p = 0;
yylval.v.string = scan_file_ref(buf);
if (yylval.v.string == NULL) {
yyerror("yylex: out of memory on string");
return (ERROR);
}
return (STRING);
}
if (isalpha(c)) {
char buf[8192], *p = buf;
int token;
do {
*p++ = c;
if (p - buf >= sizeof(buf)) {
yyerror("yylex: token too long");
return (ERROR);
}
} while ((c = lgetc(fin)) != EOF &&
(isalpha(c) || isdigit(c) || ispunct(c)));
lungetc(c, fin);
*p = 0;
token = lookup(buf);
if (token == STRING) {
yylval.v.string = scan_file_ref(buf);
if (yylval.v.string == NULL) {
yyerror("yylex: out of memory on string");
return (ERROR);
}
}
return (token);
}
if (c != '\n' && c != '(' && c != ')' && c != '=' && c != '$' &&
c != '*' && c != EOF) {
char del = c;
char buf[8192], *p = buf;
*p++ = del;
while ((c = lgetc(fin)) != EOF && c != '\n' && c != del) {
*p++ = c;
if (p - buf >= sizeof(buf) - 1) {
yyerror("yylex: argument too long");
return (ERROR);
}
}
if (c != EOF && c != '\n') {
*p++ = del;
while ((c = lgetc(fin)) != EOF && isalpha(c)) {
*p++ = c;
if (p - buf >= sizeof(buf)) {
yyerror("yylex: argument too long");
return (ERROR);
}
}
}
if (c != EOF)
lungetc(c, fin);
*p = 0;
yylval.v.string = scan_file_ref(buf);
if (yylval.v.string == NULL) {
yyerror("yylex: out of memory on string");
return (ERROR);
}
return (STRING);
}
if (c == '\n') {
lineno++;
goto top;
}
if (c == EOF)
return (0);
return (c);
}
int
parse_ruleset(const char *f, struct ruleset **r, char *err, size_t len)
{
*r = NULL;
err_str = err;
err_len = len;
rs = create_ruleset();
if (rs == NULL) {
if (err_str != NULL && err_len > 0)
snprintf(err_str, err_len, "create_ruleset");
return (1);
}
infile = f;
fin = fopen(infile, "rb");
if (fin == NULL) {
if (err_str != NULL && err_len > 0)
snprintf(err_str, err_len, "fopen: %s: %s",
infile, strerror(errno));
return (1);
}
lineno = 1;
errors = 0;
yyparse();
fclose(fin);
while (macros != NULL) {
struct macro *m = macros->next;
free(macros->name);
free(macros);
macros = m;
}
if (errors) {
free_ruleset(rs);
return (1);
} else {
*r = rs;
return (0);
}
#ifdef __linux__
(void)&yyrcsid; /* warning about yyrcsid declared but unused */
#endif
}
static int
define_macro(const char *name, struct expr *e)
{
struct macro *m = macros;
while (m != NULL && strcmp(m->name, name))
m = m->next;
if (m != NULL) {
yyerror("define_macro: macro '%s' already defined", name);
return (1);
}
m = calloc(1, sizeof(struct macro));
if (m == NULL) {
yyerror("define_macro: calloc: %s", strerror(errno));
return (1);
}
m->name = strdup(name);
if (m->name == NULL) {
yyerror("define_macro: strdup: %s", strerror(errno));
free(m);
return (1);
}
m->expr = e;
m->next = macros;
macros = m;
return (0);
}
static struct expr *
find_macro(const char *name)
{
struct macro *m = macros;
while (m != NULL && strcmp(m->name, name))
m = m->next;
if (m == NULL)
return (NULL);
return (m->expr);
}
|
<reponame>chadhamre/NightWolfTheme
%{
#include <stdio.h>
#define FOO_BAR(x,y) printf ("x, y")
%}
%name-prefix="foolala"
%error-verbose
%lex-param {FooLaLa *lala}
%parse-param {FooLaLa *lala}
/* %expect 1 */
%union {
int ival;
const char *str;
}
%token <str> ATOKEN
%token <str> ATOKEN2
%type <ival> program stmt
%type <str> if_stmt
%token IF THEN ELSE ELIF FI
%token WHILE DO OD FOR IN
%token CONTINUE BREAK RETURN
%token EQ NEQ LE GE
%token AND OR NOT
%token UMINUS
%token TWODOTS
%left '-' '+'
%left '*' '/'
%left '%'
%left EQ NEQ '<' '>' GE LE
%left OR
%left AND
%left NOT
%left '#'
%left UMINUS
%%
script: program { _ms_parser_set_top_node (parser, $1); }
;
program: stmt_or_error { $$ = node_list_add (parser, NULL, $1234); }
| program stmt_or_error { $$ = node_list_add (parser, MS_NODE_LIST ($1), $2); }
;
stmt_or_error:
error ';' { $$ = NULL; }
| stmt ';' { $$ = ; }
;
variable: IDENTIFIER { $$ = node_var (parser, $1); }
;
%%
|
<reponame>dk00/old-stuff
%{
#include<stdio.h>
int lineno = 1,error = 0;
%}
%token ID
%token NUM
%token INT
%token IF
%token ELSE
%token WHILE
%token CNTL
%token SCAN
%token PRINT
%token SIGN
%token OP
%token BOP
%token CMP
%%
blockStmt : '{' varDecl stmts '}'
;
varDecl :
| varDecl type list ';'
;
type : INT
| INT '[' NUM ']'
;
list : ID
| list ',' ID
;
var : ID
| ID '[' arithExpr ']'
;
stmts :
| stmts stmt
;
stmt : blockStmt
| var '=' arithExpr ';'
| IF '(' boolExpr ')' blockStmt
| IF '(' boolExpr ')' blockStmt ELSE blockStmt
| WHILE '(' boolExpr ')' blockStmt
| CNTL ';'
| SCAN '(' varList ')' ';'
| PRINT '(' expList ')' ';'
;
varList : var
| varList ',' var
;
expList : arithExpr
| expList ',' arithExpr
;
arithExpr : var
| NUM
| '(' arithExpr ')'
| SIGN arithExpr
| arithExpr OP arithExpr
| arithExpr SIGN arithExpr
;
boolExpr : arithExpr CMP arithExpr
| boolExpr BOP boolExpr
| '!' boolExpr
;
%%
extern void yyerror(char *msg) {
error = lineno;
}
int main() {
yyparse();
if (error > 0)
printf("Fail (around line %d)\n",error);
else
puts("Pass");
}
|
<reponame>yrrapt/cacd
%{
/*
* ISC License
*
* Copyright (C) 1990-2018 by
* <NAME>
* <NAME>
* <NAME>
* Delft University of Technology
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Parser for designrules in sea-of-gates system.
*/
#include "src/ocean/nelsea/def.h"
#include "src/ocean/nelsea/nelsis.h"
#include "src/ocean/nelsea/typedef.h"
#include "src/ocean/nelsea/prototypes.h"
/* Work around a bug in flex-2.4.6 which assumes that "#if __STDC__" works
#ifdef __STDC__
#undef __STDC__
#define __STDC__ 1
#endif
*/
/*
* export
*/
extern long
Chip_num_layer, /* number of metal layers to be used */
*LayerOrient, /* orientationtable of layers */
*LayerWidth, /* array with wire width in each layer */
NumViaName, /* number of indices in the array ViaCellName */
***ViaIndex, /* Viaindex[x][y][z]: */
/* if z == 0: Index of via to core image in array ViaCellName (-1 if nonex) */
/* if z > 0: -1 if via between z and z-1 is not allowed, 1 otherwise */
ChipSize[2], /* size for empty array */
*GridMapping[2], /* mapping of gridpoints on layout coordinates
this is an array of size GridRepetition */
*OverlayGridMapping[2], /* overlaymapping of gridpoints to layout coordinates */
OverlayBounds[2][2], /* boundaries of overlaymapping, index 1 = orient, index2 = L/R */
GridRepitition[2], /* repitionvector (dx, dy) of grid image (in grid points) */
LayoutRepitition[2]; /* repitionvector (dx, dy) of LAYOUT image (in lambda) */
extern char
ImageName[],
*ThisImage, /* name identifier of image */
**LayerMaskName, /* array with mask names of each layer */
**ViaMaskName, /* array with mask name of via to layer+1 */
*DummyMaskName, /* name of dummy (harmless) mask */
**ViaCellName; /* array with cell names of these vias */
extern int
Verbose_parse, /* print unknown keywords during parsing */
ydlineno;
extern PARAM_TYPE *SpiceParameters;
/*
* LOCAL
*/
static long orient, counter;
static long sometoken, bracecount; /* used for skipping unknown keywords */
int yderror (char *s);
int ydlex (void);
int ydwrap (void)
{
return 1;
}
%}
%union {
int itg;
char str[200];
PARAM_TYPE *parameter;
}
%token <str> STRINGTOKEN
%token <str> NUMBER
%token LBR RBR
%token SEADIFTOKEN
%token LIBRARYTOKEN
%token CHIPDESCRIPTION
%token CHIPIMAGEREF
%token CHIPSIZE
%token TECHNOLOGY
%token TECHDESIGNRULES
%token TECHNROFLAYERS
%token TECHWIREORIENT
%token TECHWIREWIDTH
%token TECHWIREMASKNAME
%token TECHDUMMYMASKNAME
%token TECHVIAMASKNAME
%token TECHVIACELLNAME
%token IMAGEDESCRIPTION
%token CIRCUITIMAGE
%token LAYOUTIMAGE
%token LAYOUTMODELCALL
%token LAYOUTIMAGEREPETITION
%token LAYOUTIMAGEPATTERN
%token LAYOUTIMAGEPATTERNLAYER
%token RECTANGLE
%token GRIDIMAGE
%token GRIDSIZE
%token GRIDMAPPING
%token OVERLAYMAPPING
%token GRIDCONNECTLIST
%token GRIDBLOCK
%token RESTRICTEDFEED
%token UNIVERSALFEED
%token FEED
%token GRIDCOST
%token GRIDCOSTLIST
%token STATUSTOKEN
%token WRITTEN
%token TIMESTAMP
%token AUTHOR
%token PROGRAM
%token COMMENT
%token SPICEPARAMETERS
%token MODEL
%token PARAMETER
%type <parameter> Parameter _Spiceparameters Spiceparameters Model Models
%start Seadif
%%
Seadif : LBR SEADIFTOKEN SeadifFileName _Seadif RBR /* EdifVersion, EdifLevel and KeywordMap skipped */
;
SeadifFileName : STRINGTOKEN { }
;
_Seadif : /* nothing */
| _Seadif Library
| _Seadif Image
| _Seadif Chip
| _Seadif Status
| _Seadif Comment
| _Seadif UserData
;
/*
* Chipdescription (junk)
*/
Chip : LBR CHIPDESCRIPTION ChipNameDef _Chip RBR
;
/*
* ascii name of chip
*/
ChipNameDef : STRINGTOKEN
{ /* store Chip name */
/* STRINGSAVE (ChipName, $1); */
}
;
_Chip :
| _Chip Status
| _Chip ChipImageRef
| _Chip ChipSize
| _Chip Comment
| _Chip UserData
;
ChipImageRef : LBR CHIPIMAGEREF STRINGTOKEN RBR /* currently not implemented */
;
ChipSize : LBR CHIPSIZE NUMBER NUMBER RBR
{ /* store chip size */
ChipSize[X] = atol ($3);
ChipSize[Y] = atol ($4);
}
;
/*
* Imagedescription
*/
Image : LBR IMAGEDESCRIPTION ImageNameDef _Image RBR
;
/*
* ImageDescription/ImageNameDef
* ascii name of image
*/
ImageNameDef : STRINGTOKEN
{
ThisImage = cs($1);
}
;
_Image :
| _Image Technology
| _Image Status
| _Image CircuitImage
| _Image GridImage
| _Image LayoutImage
| _Image Comment
| _Image UserData
;
/*
* (library or Image)/technology description
*/
Technology : LBR TECHNOLOGY _Technology RBR
;
_Technology : STRINGTOKEN { } /* currently not used */
| _Technology DesignRules
| _Technology Spiceparameters
{ SpiceParameters = $2; } /* initialize global */
| _Technology Comment
| _Technology UserData
;
/*
* Technology/designrules
*/
DesignRules : LBR TECHDESIGNRULES _DesignRules RBR
;
_DesignRules : TechNumLayer /* number of layers before others */
| _DesignRules TechLayOrient
| _DesignRules TechWireWidth
| _DesignRules TechWireMask
| _DesignRules TechDummyMask
| _DesignRules TechViaMask
| _DesignRules TechViaCellName
| _DesignRules Comment
| _DesignRules UserData
;
/*
* Designrules/numlayer: number of metal layers,
* In this routine a number of arrays are allocated
*/
TechNumLayer : LBR TECHNROFLAYERS NUMBER RBR
{
Chip_num_layer = atol ($3);
allocate_layer_arrays (Chip_num_layer);
}
;
/*
* declares the orientation of a layer
*/
TechLayOrient : LBR TECHWIREORIENT NUMBER STRINGTOKEN RBR
{
long num = atol ($3);
if (num < 0 || num >= Chip_num_layer)
yderror ("Illegal layer index for orient");
else
switch ($4[0]) {
case 'h': case 'H': case 'x': case 'X':
LayerOrient[num] = HORIZONTAL;
break;
case 'v': case 'V': case 'y': case 'Y':
LayerOrient[num] = VERTICAL;
break;
default:
yderror ("warning: Unknown orientation for layerorient");
}
}
;
/*
* declares wire width in a layer
*/
TechWireWidth : LBR TECHWIREWIDTH NUMBER NUMBER RBR
{
long num = atol ($3);
if (num < 0 || num >= Chip_num_layer)
yderror ("Illegal layer index for WireWidth");
else {
long width = atol ($4);
if (LayerWidth[num] >= 0) yderror ("WARNING: redeclaration of WireWidth");
LayerWidth[num] = width < 0 ? 0 : width;
}
}
;
/*
* declares mask name of a layer
*/
TechWireMask : LBR TECHWIREMASKNAME NUMBER STRINGTOKEN RBR
{
long num = atol ($3);
if (num < 0 || num >= Chip_num_layer)
yderror ("Illegal layer index for WireMaskName");
else {
if (LayerMaskName[num]) yderror ("WARNING: redeclaration of LayerMaskName");
STRINGSAVE (LayerMaskName[num], $4);
}
}
;
/*
* declares mask name of the dummy mask
*/
TechDummyMask : LBR TECHDUMMYMASKNAME STRINGTOKEN RBR
{
if (DummyMaskName)
yderror ("WARNING: redeclaration of DummyMaskName");
STRINGSAVE (DummyMaskName, $3);
}
;
/*
* declares the mask name of a via
*/
TechViaMask : LBR TECHVIAMASKNAME NUMBER NUMBER STRINGTOKEN RBR
{
long low3 = atol ($3);
long low4 = atol ($4);
if (low3 >= Chip_num_layer || low4 >= Chip_num_layer ||
(low3 < 0 && low4 < 0) || ABS (low3 - low4) != 1)
yderror ("Illegal layer index for ViaMaskName");
else
{
long lowest = MIN (low3, low4);
if (lowest < 0)
{ /* to poly/diff: store in higest layer */
lowest = NumViaName - 1;
if (ViaMaskName[lowest] || NumViaName == Chip_num_layer)
{ /* make arrays ViaMaskName and ViaCellName longer */
lowest++;
NumViaName++;
if (!(ViaCellName = (char **) realloc ((char *) ViaCellName,
(unsigned)(NumViaName * sizeof(char *)))))
error (FATAL_ERROR, "realloc for ViaCellName failed");
if (!(ViaMaskName = (char **) realloc ((char *) ViaMaskName,
(unsigned)(NumViaName * sizeof(char *)))))
error (FATAL_ERROR, "realloc for ViaMaskName failed");
ViaCellName[lowest] = NULL;
ViaMaskName[lowest] = NULL;
}
}
if (ViaMaskName[lowest]) yderror ("WARNING: redeclaration of ViaMaskName");
ViaMaskName[lowest] = canonicstring ($5);
}
}
;
/*
* declares the cell name of a via
*/
TechViaCellName : LBR TECHVIACELLNAME NUMBER NUMBER STRINGTOKEN RBR
{
long low3 = atol ($3);
long low4 = atol ($4);
if (low3 >= Chip_num_layer || low4 >= Chip_num_layer ||
(low3 < 0 && low4 < 0) || ABS (low3 - low4) != 1)
yderror ("Illegal layer index for ViaCellName");
else
{
long lowest = MIN (low3, low4);
if (lowest < 0)
{ /* to poly/diff: possibly a new index must be allocated */
lowest = NumViaName - 1;
if (ViaCellName[lowest] || NumViaName == Chip_num_layer)
{ /* make arrays ViaMaskName and ViaCellName longer */
lowest++;
NumViaName++;
if (!(ViaCellName = (char **) realloc ((char *) ViaCellName,
(unsigned)(NumViaName * sizeof(char *)))))
error (FATAL_ERROR, "realloc for ViaCellName failed");
if (!(ViaMaskName = (char **) realloc ((char *) ViaMaskName,
(unsigned)(NumViaName * sizeof(char *)))))
error (FATAL_ERROR, "realloc for ViaMaskName failed");
ViaCellName[lowest] = NULL;
ViaMaskName[lowest] = NULL;
}
}
if (ViaCellName[lowest]) yderror ("WARNING: redeclaration of ViaCellName");
ViaCellName[lowest] = canonicstring ($5);
}
}
;
Spiceparameters: LBR SPICEPARAMETERS Models RBR
{ $<parameter>$ = $3; }
;
Models : /* empty */
{ $<parameter>$ = (PARAM_TYPE*) NULL; }
| Model Models
{
PARAM_TYPE *last = $1;
for (; last && last->next; last = last->next) ;
if (last) last->next = $2; /* link Model list in front of Models */
$<parameter>$ = $1;
}
;
Model : LBR MODEL STRINGTOKEN _Spiceparameters RBR
{
PARAM_TYPE *param = $4;
for (; param; param = param->next) param->model = cs($3); /* init "model" field */
$<parameter>$ = $4;
}
;
_Spiceparameters:
/* empty */
{ $<parameter>$ = (PARAM_TYPE*) NULL; }
| Parameter _Spiceparameters
{
($1)->next = $2; /* link new parameter in front of list */
$<parameter>$ = $1; /* return new list */
}
;
Parameter : LBR PARAMETER STRINGTOKEN STRINGTOKEN RBR
{
PARAM_TYPE *p;
NewParam(p);
p->name = cs($3);
p->value = cs($4);
$<parameter>$ = p;
}
;
/*
* Image/CircuitImage
* Currently not implemented
*
CircuitImage : LBR CIRCUITIMAGE anything RBR
{ printf ("CircuitImage\n"); }
;
*/
CircuitImage : LBR CIRCUITIMAGE
{
bracecount = 1;
while (bracecount > 0)
if ((sometoken = ydlex()) == LBR)
++bracecount;
else if (sometoken == RBR)
--bracecount;
/* printf ("CircuitImage\n"); */
}
;
/*
* Image/LayoutImage
*/
LayoutImage : LBR LAYOUTIMAGE _LayoutImage RBR
;
_LayoutImage :
| _LayoutImage LayModelCall
| _LayoutImage LayImageRep
| _LayoutImage LayImagePat
| _LayoutImage Comment
| _LayoutImage UserData
;
LayModelCall : LBR LAYOUTMODELCALL STRINGTOKEN RBR
{ /* store image name */
strNcpy (ImageName, $3, DM_MAXNAME);
}
;
LayImageRep : LBR LAYOUTIMAGEREPETITION NUMBER NUMBER RBR
{ /* store repetitions */
LayoutRepitition[X] = atol ($3);
LayoutRepitition[Y] = atol ($4);
}
;
LayImagePat : LBR LAYOUTIMAGEPATTERN _LayImagePat RBR
;
_LayImagePat :
| _LayImagePat LayImPatLay
| _LayImagePat Comment
| _LayImagePat UserData
;
LayImPatLay : LBR LAYOUTIMAGEPATTERNLAYER STRINGTOKEN _LayImPatLay RBR
;
_LayImPatLay :
| _LayImPatLay Rectangle
| _LayImPatLay Comment
| _LayImPatLay UserData
;
Rectangle : LBR RECTANGLE NUMBER NUMBER NUMBER NUMBER RBR
;
/*
* Image/GridImage
* Interesting
*/
GridImage : LBR GRIDIMAGE _GridImage RBR
;
_GridImage : GridSize
| _GridImage GridConnectList
| _GridImage GridCostList
| _GridImage Comment
| _GridImage UserData
;
/*
* specifies size of the basic grid
*/
GridSize : LBR GRIDSIZE GridBbx _GridSize RBR
;
/* dimensions to allocate */
GridBbx : NUMBER NUMBER
{
if (GridRepitition[X] > 0) {
yderror ("redeclaration of GridSize");
error (FATAL_ERROR, "parser");
}
GridRepitition[X] = atol ($1);
GridRepitition[Y] = atol ($2);
/* allocate lots of global array related to the image size */
allocate_core_image();
orient = -1;
}
;
_GridSize :
| _GridSize GridMapping
| _GridSize OverlayMapping
| _GridSize Comment
| _GridSize UserData
;
/* mapping of gridpositions to layoutpositions */
GridMapping : LBR GRIDMAPPING GridMapOrient _GridMapping RBR
{
if (counter != GridRepitition[orient] && counter >= 0)
{
yderror ("warning: incomplete gridmapping list");
fprintf (stderr, "%ld of the %ld points found\n", counter, GridRepitition[orient]);
}
}
;
GridMapOrient : STRINGTOKEN /* should specify horizontal of vertical */
{ /* set index */
switch ($1[0])
{
case 'h': case 'H': case 'x': case 'X':
orient = X;
break;
case 'v': case 'V': case 'y': case 'Y':
orient = Y;
break;
default:
yderror ("warning: Unknown orientation");
orient = X;
break;
}
counter = 0;
}
;
_GridMapping :
| _GridMapping NUMBER /* read in number */
{ /* add number to array */
if (counter >= 0) { /* negative indicates out of bounds */
if (counter < GridRepitition[orient])
GridMapping[orient][counter++] = atol ($2);
else {
yderror ("warning: Too many grid mapping points specified");
fprintf (stderr, "should be %ld points; points starting from '%s' ignored\n",
GridRepitition[orient], $2);
counter = -1; /* disables further errors */
}
}
}
;
/* mapping of gridpositions to layoutpositions */
OverlayMapping : LBR OVERLAYMAPPING GridMapOrient NUMBER NUMBER
{ /* allocate that array */
CALLOC (OverlayGridMapping[orient], long, GridRepitition[orient]);
OverlayBounds[opposite(orient)][L] = atol ($4);
OverlayBounds[opposite(orient)][R] = atol ($5);
}
_OverlayMapping RBR
{
if (counter != GridRepitition[orient] && counter >= 0) {
yderror ("warning: incomplete OverlayMapping list");
fprintf (stderr, "%ld of the %ld points found\n", counter, GridRepitition[orient]);
}
}
;
_OverlayMapping :
| _OverlayMapping NUMBER /* read in number */
{ /* add number to array */
if (counter >= 0) { /* negative indicates out of bounds */
if (counter < GridRepitition[orient])
OverlayGridMapping[orient][counter++] = atol ($2);
else {
yderror ("warning: Too many grid mapping points specified");
fprintf (stderr, "should be %ld points; points starting from '%s' ignored\n",
GridRepitition[orient], $2);
counter = -1; /* disables further errors */
}
}
}
;
/*
* Define connections/neighbours of grid points
*/
GridConnectList : LBR GRIDCONNECTLIST _GridConnectList RBR
{
/* if ready: link offset arrays */
/* link_feeds_to_offsets(); */
}
;
_GridConnectList :
| _GridConnectList Block
| _GridConnectList RestrictedFeed
| _GridConnectList UniversalFeed
| _GridConnectList Comment
| _GridConnectList UserData
;
Block : LBR GRIDBLOCK NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RBR
{
if (!add_grid_block (atol($3), atol($4), atol($5), atol($6), atol($7), atol($8)))
yderror ("grid block position outside image");
}
;
UniversalFeed : LBR UNIVERSALFEED
{
/*
Feedlist = NULL;
*/
}
_GridFeed RBR
{
/*
if (process_feeds (Feedlist, CoreFeed) == FALSE)
fprintf (stderr, "error was on line %d\n", ydlineno);
*/
}
;
RestrictedFeed : LBR RESTRICTEDFEED
{
/*
Feedlist = NULL;
*/
}
_GridFeed RBR
{
/*
if (process_feeds (Feedlist, RestrictedCoreFeed) == FALSE)
fprintf (stderr, "error was on line %d\n", ydlineno);
*/
}
;
_GridFeed :
| _GridFeed GridFeedRef
| _GridFeed Comment
| _GridFeed UserData
;
/*
* store kind of via in array ViaIndex
*/
GridFeedRef : LBR FEED STRINGTOKEN NUMBER NUMBER RBR
{ /* MODIFIED: only stores viaindex */
long viaindex;
/* find the via in the via list */
for (viaindex = Chip_num_layer; viaindex != NumViaName; viaindex++)
if (strcmp ($3, ViaCellName[viaindex]) == 0) break;
if (viaindex == NumViaName)
fprintf (stderr, "WARNING (parser, line %d): via name '%s' not declared\n", ydlineno, $3);
else {
long x = atol ($4);
long y = atol ($5);
if (x < 0 || x >= GridRepitition[X] || y < 0 || y >= GridRepitition[Y]) {
if (Verbose_parse)
fprintf (stderr, "WARNING (parser, line %d): feed position %ld %ld outside image\n", ydlineno, x, y);
}
else {
if (ViaIndex[x][y][0] >= 0)
fprintf (stderr, "WARNING (parser, line %d): feed position %ld %ld multiple declared\n", ydlineno, x, y);
ViaIndex[x][y][0] = viaindex;
}
}
}
;
/*
* declares costs of point
* should be called after GridCOnnectList
*/
GridCostList : LBR GRIDCOSTLIST _GridCostList RBR
;
_GridCostList :
| _GridCostList GridCost
| _GridCostList Comment
| _GridCostList UserData
;
GridCost : LBR GRIDCOST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RBR
{ /* <cost> <vector> <startpoint_range> <endpoint_range> */
#if 0
if (!set_grid_cost (atol($3), atol($4), atol($5), atol($6),
atol($7), atol($8), atol($9), atol($10), atol($11), atol($12)))
yderror ("WARNING: GridCost has no effect");
#endif
}
;
/*
* Library module
*/
Library : LBR LIBRARYTOKEN anything RBR
;
/*
* BASIC functions
*/
/* status block called on many levels */
Status : LBR STATUSTOKEN _Status RBR
{
/* printf ("Status detected on line %d\n", ydlineno); */
}
;
_Status :
| _Status Written
| _Status Comment
| _Status UserData
;
Written : LBR WRITTEN _Written RBR
;
_Written : TimeStamp
| _Written Author
| _Written Program
/* | _Written DataOrigin not implemented */
/* | _Written Property not implemented */
| _Written Comment
| _Written UserData
;
/* year month day hour minute second */
TimeStamp : LBR TIMESTAMP NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RBR
{
#if 0
printf ("Timestamp detected on line %d: %d %d %d %d %d %d\n",
ydlineno, atoi($3), atoi($4), atoi($5), atoi($6), atoi($7), atoi($8));
#endif
}
;
Author : LBR AUTHOR anything RBR /* anything should be a string */
{
/* printf ("Author detected on line %d\n", ydlineno); */
}
;
Program : LBR PROGRAM anything RBR /* anything should be a string, followed by a version */
{
/* printf ("Program signature detected on line %d\n", ydlineno); */
}
;
UserData : LBR
{
if (Verbose_parse) printf ("unknown keyword in line %d:", ydlineno);
}
STRINGTOKEN
{
bracecount = 1;
while (bracecount > 0)
if ((sometoken = ydlex()) == LBR)
++bracecount;
else if (sometoken == RBR)
--bracecount;
if (Verbose_parse) printf (" %s (skipped until line %d)\n", $3, ydlineno);
}
;
Comment : LBR COMMENT
{
bracecount = 1;
while (bracecount > 0)
if ((sometoken = ydlex()) == LBR)
++bracecount;
else if (sometoken == RBR)
--bracecount;
/* printf ("Comment detected on line %d\n", ydlineno); */
}
;
anything : /* empty */
| anything something
;
something : STRINGTOKEN { }
| NUMBER { }
| LBR anything RBR
;
%%
/* Work around a bug in flex-2.4.6 which assumes that "#if __STDC__" works
#ifdef __STDC__
#undef __STDC__
#define __STDC__ 1
#endif
*/
#include "imagelex.h"
int yderror (char *s)
{
fflush (stdout);
fprintf (stderr, "ERROR (Seadif image description parser): %s. Try line %d.\n", s, ydlineno);
return 0;
}
|
%{
/*
Copyright (c) 2009 <NAME> (<EMAIL>)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "odin_types.h"
#include "odin_globals.h"
#include "odin_error.h"
#include "ast_util.h"
#include "odin_util.h"
#include "parse_making_ast.h"
#include "vtr_memory.h"
#include "scope_util.h"
extern loc_t my_location;
void yyerror(const char *str){ delayed_error_message(PARSER, my_location, "error in parsing: (%s)\n",str);}
int ieee_filter(int ieee_version, int return_type);
std::string ieee_string(int return_type);
int yywrap(){ return 1;}
int yylex(void);
%}
/* give detailed errors */
%define parse.error verbose
%locations
%union{
char *id_name;
char *num_value;
char *str_value;
ast_node_t *node;
ids id;
operation_list op;
}
/* base types */
%token <id_name> vSYMBOL_ID
%token <num_value> vNUMBER vINT_NUMBER
%token <str_value> vSTRING
/********************
* Restricted keywords
*/
/* Unlabeled */
%token vAUTOMATIC
%token vDEFAULT
%token vDESIGN
%token vDISABLE
%token vEVENT
%token vFORCE
%token vINCDIR
%token vINCLUDE
%token vINITIAL
%token vINSTANCE
%token vLIBLIST
%token vLIBRARY
%token vNOSHOWCANCELLED
%token vPULSESTYLE_ONDETECT
%token vPULSESTYLE_ONEVENT
%token vRELEASE
%token vSHOWCANCELLED
%token vCELL
%token vUSE
/* interconnect */
%token vINOUT vINPUT vOUTPUT
/* vars */
%token vDEFPARAM vLOCALPARAM vPARAMETER vREALTIME vSPECPARAM vTIME
/* control flow */
%token vELSE vFOR vFOREVER vFORK vJOIN vIF vIFNONE vREPEAT vWAIT vWHILE
/* logic gates */
%token vAND vBUF vBUFIF0 vBUFIF1 vNAND vNOR vNOT vNOTIF0 vNOTIF1 vOR vXOR vXNOR
/* data types */
%token vINTEGER vREAL vSCALARED vSIGNED vVECTORED vUNSIGNED
/* power level */
%token vSMALL vMEDIUM vLARGE vHIGHZ0 vHIGHZ1 vPULL0 vPULL1 vPULLDOWN vPULLUP vSTRONG0 vSTRONG1 vSUPPLY0 vSUPPLY1 vWEAK0 vWEAK1
/* Transistor level logic */
%token vCMOS vNMOS vPMOS vRCMOS vRNMOS vRPMOS vRTRAN vRTRANIF0 vRTRANIF1 vTRAN vTRANIF0 vTRANIF1
/* net types */
%token vWIRE vWAND vWOR vTRI vTRI0 vTRI1 vTRIAND vTRIOR vTRIREG vUWIRE vNONE vREG
/* Timing Related */
%token vALWAYS vEDGE vNEGEDGE vPOSEDGE
/* statements */
%token vASSIGN vDEASSIGN
/* Blocks */
%token vBEGIN vEND
%token vCASE vENDCASE /* related */ vCASEX vCASEZ
%token vCONFIG vENDCONFIG
%token vFUNCTION vENDFUNCTION
%token vGENERATE vENDGENERATE /* related */ vGENVAR
%token vMODULE vMACROMODULE vENDMODULE
%token vPRIMITIVE vENDPRIMITIVE
%token vSPECIFY vENDSPECIFY
%token vTABLE vENDTABLE
%token vTASK vENDTASK
/* logical operators */
%token voNOTEQUAL voEQUAL voCASEEQUAL voOROR voLTE voGTE voANDAND voANDANDAND voCASENOTEQUAL '!'
/* bitwise operators */
%token voXNOR voNAND voNOR '|' '^' '&' '~'
/* arithmetic operators */
%token voSLEFT voSRIGHT voASLEFT voASRIGHT '+' '-' '*' '/' '%'
/* unclassified operator */
%token voEGT voPLUSCOLON voMINUSCOLON '='
/* catch special characters */
%token '?' ':' '<' '>' '(' ')' '{' '}' '[' ']' ';' '#' ',' '.' '@'
/* C functions */
%token vsFINISH vsDISPLAY vsCLOG2 vsUNSIGNED vsSIGNED vsFUNCTION
/* preprocessor directives */
%token preDEFAULT_NETTYPE
%right '?' ':'
%left voOROR
%left voANDAND voANDANDAND
%left '|'
%left '^' voXNOR voNOR
%left '&' voNAND
%left voEQUAL voNOTEQUAL voCASEEQUAL voCASENOTEQUAL
%left voGTE voLTE '<' '>'
%left voSLEFT voSRIGHT voASLEFT voASRIGHT
%left '+' '-'
%left '*' '/' '%'
%right voPOWER
%left '~' '!'
%left '{' '}'
%left UOR
%left UAND
%left UNOT
%left UNAND
%left UNOR
%left UXNOR
%left UXOR
%left ULNOT
%left UADD
%left UMINUS
%nonassoc LOWER_THAN_ELSE
%nonassoc vELSE
%type <id> wire_types reg_types net_types net_direction
%type <str_value> stringify
%type <node> source_text item items module list_of_module_items list_of_task_items list_of_function_items module_item function_item task_item module_parameters module_ports
%type <node> list_of_parameter_declaration parameter_declaration task_parameter_declaration specparam_declaration list_of_port_declaration port_declaration
%type <node> defparam_declaration defparam_variable_list defparam_variable function_declaration function_port_list list_of_function_inputs function_input_declaration
%type <node> task_declaration task_input_declaration task_output_declaration task_inout_declaration
%type <node> io_declaration variable_list function_return list_of_function_return_variable function_return_variable function_integer_declaration
%type <node> integer_type_variable_list variable integer_type_variable
%type <node> net_declaration integer_declaration function_instantiation task_instantiation genvar_declaration
%type <node> procedural_continuous_assignment multiple_inputs_gate_instance list_of_single_input_gate_declaration_instance
%type <node> list_of_multiple_inputs_gate_declaration_instance list_of_module_instance
%type <node> gate_declaration single_input_gate_instance
%type <node> module_instantiation module_instance function_instance task_instance list_of_module_connections list_of_function_connections list_of_task_connections
%type <node> list_of_multiple_inputs_gate_connections
%type <node> module_connection tf_connection always statement function_statement function_statement_items task_statement blocking_assignment
%type <node> non_blocking_assignment conditional_statement function_conditional_statement case_statement function_case_statement case_item_list function_case_item_list case_items function_case_items seq_block function_seq_block
%type <node> stmt_list function_stmt_list timing_control delay_control event_expression_list event_expression loop_statement function_loop_statement
%type <node> expression primary expression_list module_parameter
%type <node> list_of_module_parameters localparam_declaration
%type <node> specify_block list_of_specify_items
%type <node> c_function_expression_list c_function
%type <node> initial_block list_of_blocking_assignment
%type <node> list_of_generate_block_items generate_item generate_block_item generate loop_generate_construct if_generate_construct
%type <node> case_generate_construct case_generate_item_list case_generate_items generate_block generate_localparam_declaration generate_defparam_declaration
/* capture wether an operation is signed or not */
%type <op> var_signedness
%%
source_text:
items { next_parsed_verilog_file($1);}
;
items:
items item { ($2 == NULL)? $$ = $1 : ( ($1 == NULL)? $$ = newList(FILE_ITEMS, $2, my_location): newList_entry($1, $2) ); }
| item { ($1 == NULL)? $$ = $1 : $$ = newList(FILE_ITEMS, $1, my_location); }
;
item:
module { $$ = $1; }
| preDEFAULT_NETTYPE wire_types { default_net_type = $2; $$ = NULL; }
;
module:
vMODULE vSYMBOL_ID module_parameters module_ports ';' list_of_module_items vENDMODULE {$$ = newModule($2, $3, $4, $6, my_location);}
| vMODULE vSYMBOL_ID module_parameters ';' list_of_module_items vENDMODULE {$$ = newModule($2, $3, NULL, $5, my_location);}
| vMODULE vSYMBOL_ID module_ports ';' list_of_module_items vENDMODULE {$$ = newModule($2, NULL, $3, $5, my_location);}
| vMODULE vSYMBOL_ID ';' list_of_module_items vENDMODULE {$$ = newModule($2, NULL, NULL, $4, my_location);}
;
module_parameters:
'#' '(' list_of_parameter_declaration ')' {$$ = $3;}
| '#' '(' list_of_parameter_declaration ',' ')' {$$ = $3;}
| '#' '(' ')' {$$ = NULL;}
;
list_of_parameter_declaration:
list_of_parameter_declaration ',' vPARAMETER var_signedness variable {$$ = newList_entry($1, markAndProcessParameterWith(PARAMETER, $5, $4));}
| list_of_parameter_declaration ',' vPARAMETER variable {$$ = newList_entry($1, markAndProcessParameterWith(PARAMETER, $4, UNSIGNED));}
| list_of_parameter_declaration ',' variable {$$ = newList_entry($1, markAndProcessParameterWith(PARAMETER, $3, UNSIGNED));}
| vPARAMETER var_signedness variable {$$ = newList(VAR_DECLARE_LIST, markAndProcessParameterWith(PARAMETER, $3, $2), my_location);}
| vPARAMETER variable {$$ = newList(VAR_DECLARE_LIST, markAndProcessParameterWith(PARAMETER, $2, UNSIGNED), my_location);}
;
module_ports:
'(' list_of_port_declaration ')' {$$ = $2;}
| '(' list_of_port_declaration ',' ')' {$$ = $2;}
| '(' ')' {$$ = NULL;}
;
list_of_port_declaration:
list_of_port_declaration ',' port_declaration {$$ = newList_entry($1, $3);}
| port_declaration {$$ = newList(VAR_DECLARE_LIST, $1, my_location);}
;
port_declaration:
net_direction net_types var_signedness variable {$$ = markAndProcessPortWith(MODULE, $1, $2, $4, $3);}
| net_direction net_types variable {$$ = markAndProcessPortWith(MODULE, $1, $2, $3, UNSIGNED);}
| net_direction variable {$$ = markAndProcessPortWith(MODULE, $1, NO_ID, $2, UNSIGNED);}
| net_direction vINTEGER integer_type_variable {$$ = markAndProcessPortWith(MODULE, $1, REG, $3, SIGNED);}
| net_direction var_signedness variable {$$ = markAndProcessPortWith(MODULE, $1, NO_ID, $3, $2);}
| variable {$$ = $1;}
;
list_of_module_items:
list_of_module_items module_item {$$ = newList_entry($1, $2);}
| module_item {$$ = newList(MODULE_ITEMS, $1, my_location);}
;
module_item:
parameter_declaration {$$ = $1;}
| io_declaration {$$ = $1;}
| specify_block {$$ = $1;}
| generate_item {$$ = $1;}
| generate {$$ = $1;}
| error ';' {$$ = NULL;}
;
list_of_generate_block_items:
list_of_generate_block_items generate_block_item {$$ = newList_entry($1, $2);}
| generate_block_item {$$ = newList(BLOCK, $1, my_location);}
;
generate_item:
localparam_declaration {$$ = $1;}
| net_declaration {$$ = $1;}
| genvar_declaration {$$ = $1;}
| integer_declaration {$$ = $1;}
| procedural_continuous_assignment {$$ = $1;}
| gate_declaration {$$ = $1;}
| module_instantiation {$$ = $1;}
| function_declaration {$$ = $1;}
| task_declaration {$$ = $1;}
| initial_block {$$ = $1;}
| always {$$ = $1;}
| defparam_declaration {$$ = $1;}
| c_function ';' {$$ = $1;}
| if_generate_construct {$$ = $1;}
| case_generate_construct {$$ = $1;}
| loop_generate_construct {$$ = $1;}
;
generate_block_item:
generate_localparam_declaration {$$ = $1;}
| net_declaration {$$ = $1;}
| genvar_declaration {$$ = $1;}
| integer_declaration {$$ = $1;}
| procedural_continuous_assignment {$$ = $1;}
| gate_declaration {$$ = $1;}
| module_instantiation {$$ = $1;}
| function_declaration {$$ = $1;}
| task_declaration {$$ = $1;}
| initial_block {$$ = $1;}
| always {$$ = $1;}
| generate_defparam_declaration {$$ = $1;}
| c_function ';' {$$ = $1;}
| if_generate_construct {$$ = $1;}
| case_generate_construct {$$ = $1;}
| loop_generate_construct {$$ = $1;}
;
function_declaration:
vFUNCTION function_return ';' list_of_function_items vENDFUNCTION {$$ = newFunction($2, NULL, $4, my_location, false);}
| vFUNCTION vAUTOMATIC function_return ';' list_of_function_items vENDFUNCTION {$$ = newFunction($3, NULL, $5, my_location, true);}
| vFUNCTION function_return function_port_list ';' list_of_function_items vENDFUNCTION {$$ = newFunction($2, $3, $5, my_location, false);}
| vFUNCTION vAUTOMATIC function_return function_port_list ';' list_of_function_items vENDFUNCTION {$$ = newFunction($3, $4, $6, my_location, true);}
;
task_declaration:
vTASK vSYMBOL_ID ';' list_of_task_items vENDTASK {$$ = newTask($2, NULL, $4, my_location, false);}
| vTASK vSYMBOL_ID module_ports ';' list_of_task_items vENDTASK {$$ = newTask($2, $3, $5, my_location, false);}
| vTASK vAUTOMATIC vSYMBOL_ID ';' list_of_task_items vENDTASK {$$ = newTask($3, NULL, $5, my_location, true);}
| vTASK vAUTOMATIC vSYMBOL_ID module_ports ';' list_of_task_items vENDTASK {$$ = newTask($3, $4, $6, my_location, true);}
;
initial_block:
vINITIAL statement {$$ = newInitial($2, my_location); }
;
/* Specify is unsynthesizable, we discard everything within */
specify_block:
vSPECIFY list_of_specify_items vENDSPECIFY {$$ = $2;}
;
list_of_specify_items:
list_of_specify_items specparam_declaration {$$ = $2;}
| specparam_declaration {$$ = $1;}
;
specparam_declaration:
'(' primary voEGT expression ')' '=' expression ';' {free_whole_tree($2); free_whole_tree($4); free_whole_tree($7); $$ = NULL;}
| vSPECPARAM variable_list ';' {free_whole_tree($2); $$ = NULL;}
;
list_of_function_items:
list_of_function_items function_item {$$ = newList_entry($1, $2);}
| function_item {$$ = newList(FUNCTION_ITEMS, $1, my_location);}
;
task_input_declaration:
vINPUT net_declaration {$$ = markAndProcessSymbolListWith(TASK,INPUT, $2, UNSIGNED);}
| vINPUT integer_declaration {$$ = markAndProcessSymbolListWith(TASK,INPUT, $2, SIGNED);}
| vINPUT var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,INPUT, $3, $2);}
| vINPUT variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,INPUT, $2, UNSIGNED);}
;
task_output_declaration:
vOUTPUT net_declaration {$$ = markAndProcessSymbolListWith(TASK,OUTPUT, $2, UNSIGNED);}
| vOUTPUT integer_declaration {$$ = markAndProcessSymbolListWith(TASK,OUTPUT, $2, SIGNED);}
| vOUTPUT var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,OUTPUT, $3, $2);}
| vOUTPUT variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,OUTPUT, $2, UNSIGNED);}
;
task_inout_declaration:
vINOUT net_declaration {$$ = markAndProcessSymbolListWith(TASK,INOUT, $2, UNSIGNED);}
| vINOUT integer_declaration {$$ = markAndProcessSymbolListWith(TASK,INOUT, $2, SIGNED);}
| vINOUT var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,INOUT, $3, $2);}
| vINOUT variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,INOUT, $2, UNSIGNED);}
;
list_of_task_items:
list_of_task_items task_item {$$ = newList_entry($1, $2); }
| task_item {$$ = newList(TASK_ITEMS, $1, my_location); }
;
function_item:
parameter_declaration {$$ = $1;}
| function_input_declaration {$$ = $1;}
| net_declaration {$$ = $1;}
| function_integer_declaration ';' {$$ = $1;}
| defparam_declaration {$$ = $1;}
| function_statement {$$ = $1;}
| error ';' {$$ = NULL;}
;
task_item:
task_parameter_declaration {$$ = $1;}
| task_input_declaration {$$ = $1;}
| task_output_declaration {$$ = $1;}
| task_inout_declaration {$$ = $1;}
| net_declaration {$$ = $1;}
| integer_declaration {$$ = $1;}
| defparam_declaration {$$ = $1;}
| task_statement {$$ = $1;}
;
function_input_declaration:
vINPUT var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(FUNCTION, INPUT, $3, $2);}
| vINPUT variable_list ';' {$$ = markAndProcessSymbolListWith(FUNCTION, INPUT, $2, UNSIGNED);}
| vINPUT function_integer_declaration ';' {$$ = markAndProcessSymbolListWith(FUNCTION, INPUT, $2, UNSIGNED);}
;
parameter_declaration:
vPARAMETER var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,PARAMETER, $3, $2);}
| vPARAMETER variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,PARAMETER, $2, UNSIGNED);}
;
task_parameter_declaration:
vPARAMETER var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,PARAMETER, $3, $2);}
| vPARAMETER variable_list ';' {$$ = markAndProcessSymbolListWith(TASK,PARAMETER, $2, UNSIGNED);}
;
localparam_declaration:
vLOCALPARAM var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,LOCALPARAM, $3, $2);}
| vLOCALPARAM variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,LOCALPARAM, $2, UNSIGNED);}
;
generate_localparam_declaration:
vLOCALPARAM var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(BLOCK,LOCALPARAM, $3, $2);}
| vLOCALPARAM variable_list ';' {$$ = markAndProcessSymbolListWith(BLOCK,LOCALPARAM, $2, UNSIGNED);}
;
defparam_declaration:
vDEFPARAM defparam_variable_list ';' {$$ = newDefparam(MODULE, $2, my_location);}
;
generate_defparam_declaration:
vDEFPARAM defparam_variable_list ';' {$$ = newDefparam(BLOCK, $2, my_location);}
;
io_declaration:
net_direction net_declaration {$$ = markAndProcessSymbolListWith(MODULE,$1, $2, UNSIGNED);}
| net_direction integer_declaration {$$ = markAndProcessSymbolListWith(MODULE,$1, $2, SIGNED);}
| net_direction var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,$1, $3, $2);}
| net_direction variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,$1, $2, UNSIGNED);}
;
net_declaration:
net_types var_signedness variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE, $1, $3, $2);}
| net_types variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE, $1, $2, UNSIGNED);}
;
integer_declaration:
vINTEGER integer_type_variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,REG, $2, SIGNED);}
;
genvar_declaration:
vGENVAR integer_type_variable_list ';' {$$ = markAndProcessSymbolListWith(MODULE,GENVAR, $2, SIGNED);}
;
function_return:
list_of_function_return_variable {$$ = markAndProcessSymbolListWith(FUNCTION, OUTPUT, $1, UNSIGNED);}
| var_signedness list_of_function_return_variable {$$ = markAndProcessSymbolListWith(FUNCTION, OUTPUT, $2, $1);}
| function_integer_declaration {$$ = markAndProcessSymbolListWith(FUNCTION, OUTPUT, $1, UNSIGNED);}
;
list_of_function_return_variable:
function_return_variable {$$ = newList(VAR_DECLARE_LIST, $1, my_location);}
;
function_return_variable:
vSYMBOL_ID {$$ = newVarDeclare($1, NULL, NULL, NULL, NULL, NULL, my_location);}
| '[' expression ':' expression ']' vSYMBOL_ID {$$ = newVarDeclare($6, $2, $4, NULL, NULL, NULL, my_location);}
;
function_integer_declaration:
vINTEGER integer_type_variable_list {$$ = markAndProcessSymbolListWith(FUNCTION, REG, $2, SIGNED);}
;
function_port_list:
'(' list_of_function_inputs ')' {$$ = $2;}
| '(' list_of_function_inputs ',' ')' {$$ = $2;}
| '(' ')' {$$ = NULL;}
;
list_of_function_inputs:
list_of_function_inputs ',' function_input_declaration {$$ = newList_entry($1, $3);}
| function_input_declaration {$$ = newList(VAR_DECLARE_LIST, $1, my_location);}
;
variable_list:
variable_list ',' variable {$$ = newList_entry($1, $3);}
| variable {$$ = newList(VAR_DECLARE_LIST, $1, my_location);}
;
defparam_variable_list:
defparam_variable_list ',' defparam_variable {$$ = newList_entry($1, $3);}
| defparam_variable {$$ = newList(VAR_DECLARE_LIST, $1, my_location);}
;
integer_type_variable_list:
integer_type_variable_list ',' integer_type_variable {$$ = newList_entry($1, $3);}
| integer_type_variable {$$ = newList(VAR_DECLARE_LIST, $1, my_location);}
;
variable:
vSYMBOL_ID {$$ = newVarDeclare($1, NULL, NULL, NULL, NULL, NULL, my_location);}
| '[' expression ':' expression ']' vSYMBOL_ID {$$ = newVarDeclare($6, $2, $4, NULL, NULL, NULL, my_location);}
| '[' expression ':' expression ']' vSYMBOL_ID '[' expression ':' expression ']' {$$ = newVarDeclare($6, $2, $4, $8, $10, NULL, my_location);}
| '[' expression ':' expression ']' vSYMBOL_ID '[' expression ':' expression ']' '[' expression ':' expression ']' {$$ = newVarDeclare2D($6, $2, $4, $8, $10,$13,$15, NULL, my_location);}
| '[' expression ':' expression ']' vSYMBOL_ID '=' expression {$$ = newVarDeclare($6, $2, $4, NULL, NULL, $8, my_location);}
| vSYMBOL_ID '=' expression {$$ = newVarDeclare($1, NULL, NULL, NULL, NULL, $3, my_location);}
;
defparam_variable:
vSYMBOL_ID '=' expression {$$ = newDefparamVarDeclare($1, NULL, NULL, NULL, NULL, $3, my_location);}
;
integer_type_variable:
vSYMBOL_ID {$$ = newIntegerTypeVarDeclare($1, NULL, NULL, NULL, NULL, NULL, my_location);}
| vSYMBOL_ID '[' expression ':' expression ']' {$$ = newIntegerTypeVarDeclare($1, NULL, NULL, $3, $5, NULL, my_location);}
| vSYMBOL_ID '=' primary {$$ = newIntegerTypeVarDeclare($1, NULL, NULL, NULL, NULL, $3, my_location);}
;
procedural_continuous_assignment:
vASSIGN list_of_blocking_assignment ';' {$$ = $2;}
;
list_of_blocking_assignment:
list_of_blocking_assignment ',' blocking_assignment {$$ = newList_entry($1, $3);}
| blocking_assignment {$$ = newList(ASSIGN, $1, my_location);}
;
gate_declaration:
vAND list_of_multiple_inputs_gate_declaration_instance ';' {$$ = newGate(BITWISE_AND, $2, my_location);}
| vNAND list_of_multiple_inputs_gate_declaration_instance ';' {$$ = newGate(BITWISE_NAND, $2, my_location);}
| vNOR list_of_multiple_inputs_gate_declaration_instance ';' {$$ = newGate(BITWISE_NOR, $2, my_location);}
| vNOT list_of_single_input_gate_declaration_instance ';' {$$ = newGate(BITWISE_NOT, $2, my_location);}
| vOR list_of_multiple_inputs_gate_declaration_instance ';' {$$ = newGate(BITWISE_OR, $2, my_location);}
| vXNOR list_of_multiple_inputs_gate_declaration_instance ';' {$$ = newGate(BITWISE_XNOR, $2, my_location);}
| vXOR list_of_multiple_inputs_gate_declaration_instance ';' {$$ = newGate(BITWISE_XOR, $2, my_location);}
| vBUF list_of_single_input_gate_declaration_instance ';' {$$ = newGate(BUF_NODE, $2, my_location);}
;
list_of_multiple_inputs_gate_declaration_instance:
list_of_multiple_inputs_gate_declaration_instance ',' multiple_inputs_gate_instance {$$ = newList_entry($1, $3);}
| multiple_inputs_gate_instance {$$ = newList(ONE_GATE_INSTANCE, $1, my_location);}
;
list_of_single_input_gate_declaration_instance:
list_of_single_input_gate_declaration_instance ',' single_input_gate_instance {$$ = newList_entry($1, $3);}
| single_input_gate_instance {$$ = newList(ONE_GATE_INSTANCE, $1, my_location);}
;
single_input_gate_instance:
vSYMBOL_ID '(' expression ',' expression ')' {$$ = newGateInstance($1, $3, $5, NULL, my_location);}
| '(' expression ',' expression ')' {$$ = newGateInstance(NULL, $2, $4, NULL, my_location);}
;
multiple_inputs_gate_instance:
vSYMBOL_ID '(' expression ',' expression ',' list_of_multiple_inputs_gate_connections ')' {$$ = newMultipleInputsGateInstance($1, $3, $5, $7, my_location);}
| '(' expression ',' expression ',' list_of_multiple_inputs_gate_connections ')' {$$ = newMultipleInputsGateInstance(NULL, $2, $4, $6, my_location);}
;
list_of_multiple_inputs_gate_connections: list_of_multiple_inputs_gate_connections ',' expression {$$ = newList_entry($1, $3);}
| expression {$$ = newModuleConnection(NULL, $1, my_location);}
;
module_instantiation:
vSYMBOL_ID list_of_module_instance ';' {$$ = newModuleInstance($1, $2, my_location);}
;
task_instantiation:
vSYMBOL_ID '(' task_instance ')' ';' {$$ = newTaskInstance($1, $3, NULL, my_location);}
| vSYMBOL_ID '(' ')' ';' {$$ = newTaskInstance($1, NULL, NULL, my_location);}
| '#' '(' list_of_module_parameters ')' vSYMBOL_ID '(' task_instance ')' ';' {$$ = newTaskInstance($5, $7, $3, my_location);}
| '#' '(' list_of_module_parameters ')' vSYMBOL_ID '(' ')' ';' {$$ = newTaskInstance($5, NULL, $3, my_location);}
;
list_of_module_instance:
list_of_module_instance ',' module_instance {$$ = newList_entry($1, $3);}
| module_instance {$$ = newList(ONE_MODULE_INSTANCE, $1, my_location);}
;
function_instantiation:
vSYMBOL_ID function_instance {$$ = newFunctionInstance($1, $2, my_location);}
;
task_instance:
list_of_task_connections {$$ = newTaskNamedInstance($1, my_location);}
;
function_instance:
'(' list_of_function_connections ')' {$$ = newFunctionNamedInstance($2, NULL, my_location);}
;
module_instance:
vSYMBOL_ID '(' list_of_module_connections ')' {$$ = newModuleNamedInstance($1, $3, NULL, my_location);}
| '#' '(' list_of_module_parameters ')' vSYMBOL_ID '(' list_of_module_connections ')' {$$ = newModuleNamedInstance($5, $7, $3, my_location); }
| vSYMBOL_ID '(' ')' {$$ = newModuleNamedInstance($1, NULL, NULL, my_location);}
| '#' '(' list_of_module_parameters ')' vSYMBOL_ID '(' ')' {$$ = newModuleNamedInstance($5, NULL, $3, my_location);}
;
list_of_function_connections:
list_of_function_connections ',' tf_connection {$$ = newList_entry($1, $3);}
| tf_connection {$$ = newfunctionList(MODULE_CONNECT_LIST, $1, my_location);}
;
list_of_task_connections:
list_of_task_connections ',' tf_connection {$$ = newList_entry($1, $3);}
| tf_connection {$$ = newList(MODULE_CONNECT_LIST, $1, my_location);}
;
list_of_module_connections:
list_of_module_connections ',' module_connection {$$ = newList_entry($1, $3);}
| list_of_module_connections ',' {$$ = newList_entry($1, newModuleConnection(NULL, NULL, my_location));}
| module_connection {$$ = newList(MODULE_CONNECT_LIST, $1, my_location);}
;
tf_connection:
'.' vSYMBOL_ID '(' expression ')' {$$ = newModuleConnection($2, $4, my_location);}
| expression {$$ = newModuleConnection(NULL, $1, my_location);}
;
module_connection:
'.' vSYMBOL_ID '(' expression ')' {$$ = newModuleConnection($2, $4, my_location);}
| '.' vSYMBOL_ID '(' ')' {$$ = newModuleConnection($2, NULL, my_location);}
| expression {$$ = newModuleConnection(NULL, $1, my_location);}
;
list_of_module_parameters:
list_of_module_parameters ',' module_parameter {$$ = newList_entry($1, $3);}
| module_parameter {$$ = newList(MODULE_PARAMETER_LIST, $1, my_location);}
;
module_parameter:
'.' vSYMBOL_ID '(' expression ')' {$$ = newModuleParameter($2, $4, my_location);}
| '.' vSYMBOL_ID '(' ')' {$$ = newModuleParameter($2, NULL, my_location);}
| expression {$$ = newModuleParameter(NULL, $1, my_location);}
;
always:
vALWAYS timing_control statement {$$ = newAlways($2, $3, my_location);}
| vALWAYS statement {$$ = newAlways(NULL, $2, my_location);}
;
generate:
vGENERATE generate_item vENDGENERATE {$$ = $2;}
;
loop_generate_construct:
vFOR '(' blocking_assignment ';' expression ';' blocking_assignment ')' generate_block {$$ = newFor($3, $5, $7, $9, my_location);}
;
if_generate_construct:
vIF '(' expression ')' generate_block %prec LOWER_THAN_ELSE {$$ = newIf($3, $5, NULL, my_location);}
| vIF '(' expression ')' generate_block vELSE generate_block {$$ = newIf($3, $5, $7, my_location);}
;
case_generate_construct:
vCASE '(' expression ')' case_generate_item_list vENDCASE {$$ = newCase($3, $5, my_location);}
;
case_generate_item_list:
case_generate_item_list case_generate_items {$$ = newList_entry($1, $2);}
| case_generate_items {$$ = newList(CASE_LIST, $1, my_location);}
;
case_generate_items:
expression ':' generate_block {$$ = newCaseItem($1, $3, my_location);}
| vDEFAULT ':' generate_block {$$ = newDefaultCase($3, my_location);}
;
generate_block:
vBEGIN ':' vSYMBOL_ID list_of_generate_block_items vEND {$$ = newBlock($3, $4);}
| vBEGIN list_of_generate_block_items vEND {$$ = newBlock(NULL, $2);}
| generate_block_item {$$ = newBlock(NULL, newList(BLOCK, $1, my_location));}
;
function_statement:
function_statement_items {$$ = newStatement($1, my_location);}
;
task_statement:
statement {$$ = newStatement($1, my_location);}
;
statement:
seq_block {$$ = $1;}
| task_instantiation {$$ = $1;}
| c_function ';' {$$ = $1;}
| blocking_assignment ';' {$$ = $1;}
| non_blocking_assignment ';' {$$ = $1;}
| procedural_continuous_assignment {$$ = $1;}
| conditional_statement {$$ = $1;}
| case_statement {$$ = $1;}
| loop_statement {$$ = newList(BLOCK, $1, my_location);}
| ';' {$$ = NULL;}
;
function_statement_items:
function_seq_block {$$ = $1;}
| c_function ';' {$$ = $1;}
| blocking_assignment ';' {$$ = $1;}
| function_conditional_statement {$$ = $1;}
| function_case_statement {$$ = $1;}
| function_loop_statement {$$ = newList(BLOCK, $1, my_location);}
| ';' {$$ = NULL;}
;
function_seq_block:
vBEGIN function_stmt_list vEND {$$ = newBlock(NULL, $2);}
| vBEGIN ':' vSYMBOL_ID function_stmt_list vEND {$$ = newBlock($3, $4);}
;
function_stmt_list:
function_stmt_list function_statement_items {$$ = newList_entry($1, $2);}
| function_statement_items {$$ = newList(BLOCK, $1, my_location);}
;
function_loop_statement:
vFOR '(' blocking_assignment ';' expression ';' blocking_assignment ')' function_statement_items {$$ = newFor($3, $5, $7, $9, my_location);}
| vWHILE '(' expression ')' function_statement_items {$$ = newWhile($3, $5, my_location);}
;
loop_statement:
vFOR '(' blocking_assignment ';' expression ';' blocking_assignment ')' statement {$$ = newFor($3, $5, $7, $9, my_location);}
| vWHILE '(' expression ')' statement {$$ = newWhile($3, $5, my_location);}
;
case_statement:
vCASE '(' expression ')' case_item_list vENDCASE {$$ = newCase($3, $5, my_location);}
;
function_case_statement:
vCASE '(' expression ')' function_case_item_list vENDCASE {$$ = newCase($3, $5, my_location);}
;
function_conditional_statement:
vIF '(' expression ')' function_statement_items %prec LOWER_THAN_ELSE {$$ = newIf($3, $5, NULL, my_location);}
| vIF '(' expression ')' function_statement_items vELSE function_statement_items {$$ = newIf($3, $5, $7, my_location);}
;
conditional_statement:
vIF '(' expression ')' statement %prec LOWER_THAN_ELSE {$$ = newIf($3, $5, NULL, my_location);}
| vIF '(' expression ')' statement vELSE statement {$$ = newIf($3, $5, $7, my_location);}
;
blocking_assignment:
primary '=' expression {$$ = newBlocking($1, $3, my_location);}
| delay_control primary '=' expression {$$ = newBlocking($2, $4, my_location);}
| primary '=' delay_control expression {$$ = newBlocking($1, $4, my_location);}
;
non_blocking_assignment:
primary voLTE expression {$$ = newNonBlocking($1, $3, my_location);}
| delay_control primary voLTE expression {$$ = newNonBlocking($2, $4, my_location);}
| primary voLTE delay_control expression {$$ = newNonBlocking($1, $4, my_location);}
;
case_item_list:
case_item_list case_items {$$ = newList_entry($1, $2);}
| case_items {$$ = newList(CASE_LIST, $1, my_location);}
;
function_case_item_list:
function_case_item_list function_case_items {$$ = newList_entry($1, $2);}
| function_case_items {$$ = newList(CASE_LIST, $1, my_location);}
;
function_case_items:
expression ':' function_statement_items {$$ = newCaseItem($1, $3, my_location);}
| vDEFAULT ':' function_statement_items {$$ = newDefaultCase($3, my_location);}
;
case_items:
expression ':' statement {$$ = newCaseItem($1, $3, my_location);}
| vDEFAULT ':' statement {$$ = newDefaultCase($3, my_location);}
;
seq_block:
vBEGIN stmt_list vEND {$$ = newBlock(NULL, $2);}
| vBEGIN ':' vSYMBOL_ID stmt_list vEND {$$ = newBlock($3, $4);}
;
stmt_list:
stmt_list statement {$$ = newList_entry($1, $2);}
| statement {$$ = newList(BLOCK, $1, my_location);}
;
timing_control:
'@' '(' event_expression_list ')' {$$ = $3;}
| '@' '*' {$$ = NULL;}
| '@' '(' '*' ')' {$$ = NULL;}
;
delay_control:
'#' vINT_NUMBER {vtr::free($2); $$ = NULL;}
| '#' '(' vINT_NUMBER ')' {vtr::free($3); $$ = NULL;}
| '#' '(' vINT_NUMBER ',' vINT_NUMBER ')' {vtr::free($3); vtr::free($5); $$ = NULL;}
| '#' '(' vINT_NUMBER ',' vINT_NUMBER ',' vINT_NUMBER ')' {vtr::free($3); vtr::free($5); vtr::free($7); $$ = NULL;}
;
event_expression_list:
event_expression_list vOR event_expression {$$ = newList_entry($1, $3);}
| event_expression_list ',' event_expression {$$ = newList_entry($1, $3);}
| event_expression {$$ = newList(DELAY_CONTROL, $1, my_location);}
;
event_expression:
primary {$$ = $1;}
| vPOSEDGE primary {$$ = newPosedge($2, my_location);}
| vNEGEDGE primary {$$ = newNegedge($2, my_location);}
;
stringify:
stringify vSTRING {$$ = str_collate($1, $2);}
| vSTRING {$$ = $1;}
;
expression:
vINT_NUMBER {$$ = newNumberNode($1, my_location);}
| vNUMBER {$$ = newNumberNode($1, my_location);}
| stringify {$$ = newStringNode($1, my_location);}
| primary {$$ = $1;}
| '+' expression %prec UADD {$$ = newUnaryOperation(ADD, $2, my_location);}
| '-' expression %prec UMINUS {$$ = newUnaryOperation(MINUS, $2, my_location);}
| '~' expression %prec UNOT {$$ = newUnaryOperation(BITWISE_NOT, $2, my_location);}
| '&' expression %prec UAND {$$ = newUnaryOperation(BITWISE_AND, $2, my_location);}
| '|' expression %prec UOR {$$ = newUnaryOperation(BITWISE_OR, $2, my_location);}
| voNAND expression %prec UNAND {$$ = newUnaryOperation(BITWISE_NAND, $2, my_location);}
| voNOR expression %prec UNOR {$$ = newUnaryOperation(BITWISE_NOR, $2, my_location);}
| voXNOR expression %prec UXNOR {$$ = newUnaryOperation(BITWISE_XNOR, $2, my_location);}
| '!' expression %prec ULNOT {$$ = newUnaryOperation(LOGICAL_NOT, $2, my_location);}
| '^' expression %prec UXOR {$$ = newUnaryOperation(BITWISE_XOR, $2, my_location);}
| vsCLOG2 '(' expression ')' {$$ = newUnaryOperation(CLOG2, $3, my_location);}
| vsUNSIGNED '(' expression ')' {$$ = newUnaryOperation(UNSIGNED, $3, my_location);}
| vsSIGNED '(' expression ')' {$$ = newUnaryOperation(SIGNED, $3, my_location);}
| expression voPOWER expression {$$ = newBinaryOperation(POWER,$1, $3, my_location);}
| expression '*' expression {$$ = newBinaryOperation(MULTIPLY, $1, $3, my_location);}
| expression '/' expression {$$ = newBinaryOperation(DIVIDE, $1, $3, my_location);}
| expression '%' expression {$$ = newBinaryOperation(MODULO, $1, $3, my_location);}
| expression '+' expression {$$ = newBinaryOperation(ADD, $1, $3, my_location);}
| expression '-' expression {$$ = newBinaryOperation(MINUS, $1, $3, my_location);}
| expression voSRIGHT expression {$$ = newBinaryOperation(SR, $1, $3, my_location);}
| expression voASRIGHT expression {$$ = newBinaryOperation(ASR, $1, $3, my_location);}
| expression voSLEFT expression {$$ = newBinaryOperation(SL, $1, $3, my_location);}
| expression voASLEFT expression {$$ = newBinaryOperation(ASL, $1, $3, my_location);}
| expression '<' expression {$$ = newBinaryOperation(LT, $1, $3, my_location);}
| expression '>' expression {$$ = newBinaryOperation(GT, $1, $3, my_location);}
| expression voLTE expression {$$ = newBinaryOperation(LTE, $1, $3, my_location);}
| expression voGTE expression {$$ = newBinaryOperation(GTE, $1, $3, my_location);}
| expression voEQUAL expression {$$ = newBinaryOperation(LOGICAL_EQUAL, $1, $3, my_location);}
| expression voNOTEQUAL expression {$$ = newBinaryOperation(NOT_EQUAL, $1, $3, my_location);}
| expression voCASEEQUAL expression {$$ = newBinaryOperation(CASE_EQUAL, $1, $3, my_location);}
| expression voCASENOTEQUAL expression {$$ = newBinaryOperation(CASE_NOT_EQUAL, $1, $3, my_location);}
| expression '&' expression {$$ = newBinaryOperation(BITWISE_AND, $1, $3, my_location);}
| expression voNAND expression {$$ = newBinaryOperation(BITWISE_NAND, $1, $3, my_location);}
| expression '^' expression {$$ = newBinaryOperation(BITWISE_XOR, $1, $3, my_location);}
| expression voXNOR expression {$$ = newBinaryOperation(BITWISE_XNOR, $1, $3, my_location);}
| expression '|' expression {$$ = newBinaryOperation(BITWISE_OR, $1, $3, my_location);}
| expression voNOR expression {$$ = newBinaryOperation(BITWISE_NOR, $1, $3, my_location);}
| expression voANDAND expression {$$ = newBinaryOperation(LOGICAL_AND, $1, $3, my_location);}
| expression voOROR expression {$$ = newBinaryOperation(LOGICAL_OR, $1, $3, my_location);}
| expression '?' expression ':' expression {$$ = newIfQuestion($1, $3, $5, my_location);}
| function_instantiation {$$ = $1;}
| '(' expression ')' {$$ = $2;}
| '{' expression '{' expression_list '}' '}' {$$ = newListReplicate( $2, $4, my_location); }
;
primary:
vSYMBOL_ID {$$ = newSymbolNode($1, my_location);}
| vSYMBOL_ID '[' expression ']' {$$ = newArrayRef($1, $3, my_location);}
| vSYMBOL_ID '[' expression ']' '[' expression ']' {$$ = newArrayRef2D($1, $3, $6, my_location);}
| vSYMBOL_ID '[' expression voPLUSCOLON expression ']' {$$ = newPlusColonRangeRef($1, $3, $5, my_location);}
| vSYMBOL_ID '[' expression voMINUSCOLON expression ']' {$$ = newMinusColonRangeRef($1, $3, $5, my_location);}
| vSYMBOL_ID '[' expression ':' expression ']' {$$ = newRangeRef($1, $3, $5, my_location);}
| vSYMBOL_ID '[' expression ':' expression ']' '[' expression ':' expression ']' {$$ = newRangeRef2D($1, $3, $5, $8, $10, my_location);}
| '{' expression_list '}' {$$ = $2; ($2)->types.concat.num_bit_strings = -1;}
;
expression_list:
expression_list ',' expression {$$ = newList_entry($1, $3); /* order is left to right as is given */ }
| expression {$$ = newList(CONCATENATE, $1, my_location);}
;
c_function:
vsFINISH '(' expression ')' {$$ = newCFunction(FINISH, $3, NULL, my_location);}
| vsDISPLAY '(' expression ')' {$$ = newCFunction(DISPLAY, $3, NULL, my_location);}
| vsDISPLAY '(' expression ',' c_function_expression_list ')' {$$ = newCFunction(DISPLAY, $3, $5, my_location); /* this fails for now */}
| vsFUNCTION '(' c_function_expression_list ')' {$$ = free_whole_tree($3);}
| vsFUNCTION '(' ')' {$$ = NULL;}
| vsFUNCTION {$$ = NULL;}
;
c_function_expression_list:
c_function_expression_list ',' expression {$$ = newList_entry($1, $3);}
| expression {$$ = newList(C_ARG_LIST, $1, my_location);}
;
wire_types:
vWIRE { $$ = WIRE; }
| vTRI { $$ = WIRE; }
| vTRI0 { $$ = WIRE; }
| vTRI1 { $$ = WIRE; }
| vWAND { $$ = WIRE; }
| vTRIAND { $$ = WIRE; }
| vWOR { $$ = WIRE; }
| vTRIOR { $$ = WIRE; }
| vTRIREG { $$ = WIRE; }
| vUWIRE { $$ = WIRE; }
| vNONE { $$ = NO_ID; /* no type here to force an error */ }
;
reg_types:
vREG { $$ = REG; }
;
net_types:
wire_types { $$ = $1; }
| reg_types { $$ = $1; }
;
net_direction:
vINPUT { $$ = INPUT; }
| vOUTPUT { $$ = OUTPUT; }
| vINOUT { $$ = INOUT; }
;
var_signedness:
vUNSIGNED { $$ = UNSIGNED; }
| vSIGNED { $$ = SIGNED; }
;
%%
/**
* This functions filters types based on the standard defined,
*/
int ieee_filter(int ieee_version, int return_type) {
switch(return_type) {
case voANDANDAND: //fallthrough
case voPOWER: //fallthrough
case voANDAND: //fallthrough
case voOROR: //fallthrough
case voLTE: //fallthrough
case voEGT: //fallthrough
case voGTE: //fallthrough
case voSLEFT: //fallthrough
case voSRIGHT: //fallthrough
case voEQUAL: //fallthrough
case voNOTEQUAL: //fallthrough
case voCASEEQUAL: //fallthrough
case voCASENOTEQUAL: //fallthrough
case voXNOR: //fallthrough
case voNAND: //fallthrough
case voNOR: //fallthrough
case vALWAYS: //fallthrough
case vAND: //fallthrough
case vASSIGN: //fallthrough
case vBEGIN: //fallthrough
case vBUF: //fallthrough
case vBUFIF0: //fallthrough
case vBUFIF1: //fallthrough
case vCASE: //fallthrough
case vCASEX: //fallthrough
case vCASEZ: //fallthrough
case vCMOS: //fallthrough
case vDEASSIGN: //fallthrough
case vDEFAULT: //fallthrough
case vDEFPARAM: //fallthrough
case vDISABLE: //fallthrough
case vEDGE: //fallthrough
case vELSE: //fallthrough
case vEND: //fallthrough
case vENDCASE: //fallthrough
case vENDFUNCTION: //fallthrough
case vENDMODULE: //fallthrough
case vENDPRIMITIVE: //fallthrough
case vENDSPECIFY: //fallthrough
case vENDTABLE: //fallthrough
case vENDTASK: //fallthrough
case vEVENT: //fallthrough
case vFOR: //fallthrough
case vFORCE: //fallthrough
case vFOREVER: //fallthrough
case vFORK: //fallthrough
case vFUNCTION: //fallthrough
case vHIGHZ0: //fallthrough
case vHIGHZ1: //fallthrough
case vIF: //fallthrough
case vIFNONE: //fallthrough
case vINITIAL: //fallthrough
case vINOUT: //fallthrough
case vINPUT: //fallthrough
case vINTEGER: //fallthrough
case vJOIN: //fallthrough
case vLARGE: //fallthrough
case vMACROMODULE: //fallthrough
case vMEDIUM: //fallthrough
case vMODULE: //fallthrough
case vNAND: //fallthrough
case vNEGEDGE: //fallthrough
case vNMOS: //fallthrough
case vNOR: //fallthrough
case vNOT: //fallthrough
case vNOTIF0: //fallthrough
case vNOTIF1: //fallthrough
case vOR: //fallthrough
case vOUTPUT: //fallthrough
case vPARAMETER: //fallthrough
case vPMOS: //fallthrough
case vPOSEDGE: //fallthrough
case vPRIMITIVE: //fallthrough
case vPULL0: //fallthrough
case vPULL1: //fallthrough
case vPULLDOWN: //fallthrough
case vPULLUP: //fallthrough
case vRCMOS: //fallthrough
case vREAL: //fallthrough
case vREALTIME: //fallthrough
case vREG: //fallthrough
case vRELEASE: //fallthrough
case vREPEAT: //fallthrough
case vRNMOS: //fallthrough
case vRPMOS: //fallthrough
case vRTRAN: //fallthrough
case vRTRANIF0: //fallthrough
case vRTRANIF1: //fallthrough
case vSCALARED: //fallthrough
case vSMALL: //fallthrough
case vSPECIFY: //fallthrough
case vSPECPARAM: //fallthrough
case vSTRONG0: //fallthrough
case vSTRONG1: //fallthrough
case vSUPPLY0: //fallthrough
case vSUPPLY1: //fallthrough
case vTABLE: //fallthrough
case vTASK: //fallthrough
case vTIME: //fallthrough
case vTRAN: //fallthrough
case vTRANIF0: //fallthrough
case vTRANIF1: //fallthrough
case vTRI: //fallthrough
case vTRI0: //fallthrough
case vTRI1: //fallthrough
case vTRIAND: //fallthrough
case vTRIOR: //fallthrough
case vTRIREG: //fallthrough
case vVECTORED: //fallthrough
case vWAIT: //fallthrough
case vWAND: //fallthrough
case vWEAK0: //fallthrough
case vWEAK1: //fallthrough
case vWHILE: //fallthrough
case vWIRE: //fallthrough
case vWOR: //fallthrough
case vXNOR: //fallthrough
case vXOR: {
if(ieee_version < ieee_1995)
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 1995 or newer\n",ieee_string(return_type).c_str())
break;
}
case voASLEFT: //fallthrough
case voASRIGHT: //fallthrough
case voPLUSCOLON: //fallthrough
case voMINUSCOLON: //fallthrough
case vAUTOMATIC: //fallthrough
case vENDGENERATE: //fallthrough
case vGENERATE: //fallthrough
case vGENVAR: //fallthrough
case vLOCALPARAM: //fallthrough
case vNOSHOWCANCELLED: //fallthrough
case vPULSESTYLE_ONDETECT: //fallthrough
case vPULSESTYLE_ONEVENT: //fallthrough
case vSHOWCANCELLED: //fallthrough
case vSIGNED: //fallthrough
case vUNSIGNED: {
if(ieee_version < ieee_2001_noconfig)
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2001-noconfig or newer\n",ieee_string(return_type).c_str())
break;
}
case vCELL: //fallthrough
case vCONFIG: //fallthrough
case vDESIGN: //fallthrough
case vENDCONFIG: //fallthrough
case vINCDIR: //fallthrough
case vINCLUDE: //fallthrough
case vINSTANCE: //fallthrough
case vLIBLIST: //fallthrough
case vLIBRARY: //fallthrough
case vUSE: {
if(ieee_version < ieee_2001)
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2001 or newer\n",ieee_string(return_type).c_str())
break;
}
case vUWIRE: {
if(ieee_version < ieee_2005)
delayed_error_message(PARSER, my_location, "error in parsing: (%s) only exists in ieee 2005 or newer\n",ieee_string(return_type).c_str())
break;
}
case vsCLOG2:
case vsUNSIGNED: //fallthrough
case vsSIGNED: //fallthrough
case vsFINISH: //fallthrough
case vsDISPLAY: //fallthrough
case vsFUNCTION: //fallthrough
/* unsorted. TODO: actually sort these */
break;
default: {
delayed_error_message(PARSER, my_location, "error in parsing: keyword index: %d is not a supported keyword.\n",return_type)
break;
}
}
return return_type;
}
std::string ieee_string(int return_type) {
switch(return_type) {
case vALWAYS: return "vALWAYS";
case vAND: return "vAND";
case vASSIGN: return "vASSIGN";
case vAUTOMATIC: return "vAUTOMATIC";
case vBEGIN: return "vBEGIN";
case vBUF: return "vBUF";
case vBUFIF0: return "vBUFIF0";
case vBUFIF1: return "vBUFIF1";
case vCASE: return "vCASE";
case vCASEX: return "vCASEX";
case vCASEZ: return "vCASEZ";
case vCELL: return "vCELL";
case vCMOS: return "vCMOS";
case vCONFIG: return "vCONFIG";
case vDEASSIGN: return "vDEASSIGN";
case vDEFAULT: return "vDEFAULT";
case vDEFPARAM: return "vDEFPARAM";
case vDESIGN: return "vDESIGN";
case vDISABLE: return "vDISABLE";
case vEDGE: return "vEDGE";
case vELSE: return "vELSE";
case vEND: return "vEND";
case vENDCASE: return "vENDCASE";
case vENDCONFIG: return "vENDCONFIG";
case vENDFUNCTION: return "vENDFUNCTION";
case vENDGENERATE: return "vENDGENERATE";
case vENDMODULE: return "vENDMODULE";
case vENDPRIMITIVE: return "vENDPRIMITIVE";
case vENDSPECIFY: return "vENDSPECIFY";
case vENDTABLE: return "vENDTABLE";
case vENDTASK: return "vENDTASK";
case vEVENT: return "vEVENT";
case vFOR: return "vFOR";
case vFORCE: return "vFORCE";
case vFOREVER: return "vFOREVER";
case vFORK: return "vFORK";
case vFUNCTION: return "vFUNCTION";
case vGENERATE: return "vGENERATE";
case vGENVAR: return "vGENVAR";
case vHIGHZ0: return "vHIGHZ0";
case vHIGHZ1: return "vHIGHZ1";
case vIF: return "vIF";
case vINCDIR: return "vINCDIR";
case vINCLUDE: return "vINCLUDE";
case vINITIAL: return "vINITIAL";
case vINOUT: return "vINOUT";
case vINPUT: return "vINPUT";
case vINSTANCE: return "vINSTANCE";
case vINTEGER: return "vINTEGER";
case vJOIN: return "vJOIN";
case vLARGE: return "vLARGE";
case vLIBLIST: return "vLIBLIST";
case vLIBRARY: return "vLIBRARY";
case vLOCALPARAM: return "vLOCALPARAM";
case vMEDIUM: return "vMEDIUM";
case vMODULE: return "vMODULE";
case vNAND: return "vNAND";
case vNEGEDGE: return "vNEGEDGE";
case vNMOS: return "vNMOS";
case vNONE: return "vNONE";
case vNOR: return "vNOR";
case vNOSHOWCANCELLED: return "vNOSHOWCANCELLED";
case vNOT: return "vNOT";
case vNOTIF0: return "vNOTIF0";
case vNOTIF1: return "vNOTIF1";
case vOR: return "vOR";
case vOUTPUT: return "vOUTPUT";
case vPARAMETER: return "vPARAMETER";
case vPMOS: return "vPMOS";
case vPOSEDGE: return "vPOSEDGE";
case vPRIMITIVE: return "vPRIMITIVE";
case vPULL0: return "vPULL0";
case vPULL1: return "vPULL1";
case vPULLDOWN: return "vPULLDOWN";
case vPULLUP: return "vPULLUP";
case vPULSESTYLE_ONDETECT: return "vPULSESTYLE_ONDETECT";
case vPULSESTYLE_ONEVENT: return "vPULSESTYLE_ONEVENT";
case vRCMOS: return "vRCMOS";
case vREG: return "vREG";
case vRELEASE: return "vRELEASE";
case vREPEAT: return "vREPEAT";
case vRNMOS: return "vRNMOS";
case vRPMOS: return "vRPMOS";
case vRTRAN: return "vRTRAN";
case vRTRANIF0: return "vRTRANIF0";
case vRTRANIF1: return "vRTRANIF1";
case vSCALARED: return "vSCALARED";
case vSHOWCANCELLED: return "vSHOWCANCELLED";
case vSIGNED: return "vSIGNED";
case vSMALL: return "vSMALL";
case vSPECIFY: return "vSPECIFY";
case vSPECPARAM: return "vSPECPARAM";
case vSTRONG0: return "vSTRONG0";
case vSTRONG1: return "vSTRONG1";
case vSUPPLY0: return "vSUPPLY0";
case vSUPPLY1: return "vSUPPLY1";
case vTABLE: return "vTABLE";
case vTASK: return "vTASK";
case vTIME: return "vTIME";
case vTRAN: return "vTRAN";
case vTRANIF0: return "vTRANIF0";
case vTRANIF1: return "vTRANIF1";
case vTRI0: return "vTRI0";
case vTRI1: return "vTRI1";
case vTRI: return "vTRI";
case vTRIAND: return "vTRIAND";
case vTRIOR: return "vTRIOR";
case vTRIREG: return "vTRIREG";
case vUNSIGNED: return "vUNSIGNED";
case vUSE: return "vUSE";
case vUWIRE: return "vUWIRE";
case vVECTORED: return "vVECTORED";
case vWAIT: return "vWAIT";
case vWAND: return "vWAND";
case vWEAK0: return "vWEAK0";
case vWEAK1: return "vWEAK1";
case vWHILE: return "vWHILE";
case vWIRE: return "vWIRE";
case vWOR: return "vWOR";
case vXNOR: return "vXNOR";
case vXOR: return "vXOR";
case voANDAND: return "voANDAND";
case voANDANDAND: return "voANDANDAND";
case voASLEFT: return "voASLEFT";
case voASRIGHT: return "voASRIGHT";
case voCASEEQUAL: return "voCASEEQUAL";
case voCASENOTEQUAL: return "voCASENOTEQUAL";
case voEGT: return "voEGT";
case voEQUAL: return "voEQUAL";
case voGTE: return "voGTE";
case voLTE: return "voLTE";
case voMINUSCOLON: return "voMINUSCOLON";
case voNAND: return "voNAND";
case voNOR: return "voNOR";
case voNOTEQUAL: return "voNOTEQUAL";
case voOROR: return "voOROR";
case voPLUSCOLON: return "voPLUSCOLON";
case voPOWER: return "voPOWER";
case voSLEFT: return "voSLEFT";
case voSRIGHT: return "voSRIGHT";
case voXNOR: return "voXNOR";
case vsCLOG2: return "vsCLOG2";
case vsDISPLAY: return "vsDISPLAY";
case vsFINISH: return "vsFINISH";
case vsFUNCTION: return "vsFUNCTION";
case vsSIGNED: return "vsSIGNED";
case vsUNSIGNED: return "vsUNSIGNED";
default: break;
}
return "";
}
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Bison grammer file
//
// Code available from: http://www.veripool.org/verilator
//
//*************************************************************************
//
// Copyright 2003-2019 by <NAME>. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
//
// 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 <NAME> and <NAME>
//*************************************************************************
%{
#include "V3Ast.h"
#include "V3Global.h"
#include "V3Config.h"
#include "V3ParseImp.h" // Defines YYTYPE; before including bison header
#include <cstdlib>
#include <cstdarg>
#define YYERROR_VERBOSE 1
#define YYINITDEPTH 10000 // Older bisons ignore YYMAXDEPTH
#define YYMAXDEPTH 10000
// Pick up new lexer
#define yylex PARSEP->lexToBison
#define BBUNSUP(fl,msg) { if (!v3Global.opt.bboxUnsup()) { (fl)->v3error(msg); } }
#define GATEUNSUP(fl,tok) { BBUNSUP((fl), "Unsupported: Verilog 1995 gate primitive: "<<(tok)); }
extern void yyerror(const char* errmsg);
extern void yyerrorf(const char* format, ...);
//======================================================================
// Statics (for here only)
#define PARSEP V3ParseImp::parsep()
#define SYMP PARSEP->symp()
#define GRAMMARP V3ParseGrammar::singletonp()
class V3ParseGrammar {
public:
bool m_impliedDecl; // Allow implied wire declarations
AstVarType m_varDecl; // Type for next signal declaration (reg/wire/etc)
VDirection m_varIO; // Direction for next signal declaration (reg/wire/etc)
AstVar* m_varAttrp; // Current variable for attribute adding
AstRange* m_gateRangep; // Current range for gate declarations
AstCase* m_caseAttrp; // Current case statement for attribute adding
AstNodeDType* m_varDTypep; // Pointer to data type for next signal declaration
AstNodeDType* m_memDTypep; // Pointer to data type for next member declaration
int m_pinNum; // Pin number currently parsing
string m_instModule; // Name of module referenced for instantiations
AstPin* m_instParamp; // Parameters for instantiations
bool m_tracingParse; // Tracing disable for parser
static int s_modTypeImpNum; // Implicit type number, incremented each module
// CONSTRUCTORS
V3ParseGrammar() {
m_impliedDecl = false;
m_varDecl = AstVarType::UNKNOWN;
m_varIO = VDirection::NONE;
m_varDTypep = NULL;
m_gateRangep = NULL;
m_memDTypep = NULL;
m_pinNum = -1;
m_instModule = "";
m_instParamp = NULL;
m_varAttrp = NULL;
m_caseAttrp = NULL;
m_tracingParse = true;
}
static V3ParseGrammar* singletonp() {
static V3ParseGrammar singleton;
return &singleton;
}
// METHODS
void argWrapList(AstNodeFTaskRef* nodep);
bool allTracingOn(FileLine* fl) {
return v3Global.opt.trace() && m_tracingParse && fl->tracingOn();
}
AstRange* scrubRange(AstNodeRange* rangep);
AstNodeDType* createArray(AstNodeDType* basep, AstNodeRange* rangep, bool isPacked);
AstVar* createVariable(FileLine* fileline, string name, AstNodeRange* arrayp, AstNode* attrsp);
AstNode* createSupplyExpr(FileLine* fileline, string name, int value);
AstText* createTextQuoted(FileLine* fileline, string text) {
string newtext = deQuote(fileline, text);
return new AstText(fileline, newtext);
}
AstDisplay* createDisplayError(FileLine* fileline) {
AstDisplay* nodep = new AstDisplay(fileline,AstDisplayType::DT_ERROR, "", NULL,NULL);
nodep->addNext(new AstStop(fileline));
return nodep;
}
AstNode* createGatePin(AstNode* exprp) {
AstRange* rangep = m_gateRangep;
if (!rangep) return exprp;
else return new AstGatePin(rangep->fileline(), exprp, rangep->cloneTree(true));
}
void endLabel(FileLine* fl, AstNode* nodep, string* endnamep) { endLabel(fl, nodep->prettyName(), endnamep); }
void endLabel(FileLine* fl, string name, string* endnamep) {
if (fl && endnamep && *endnamep != "" && name != *endnamep
&& name != AstNode::prettyName(*endnamep)) {
fl->v3warn(ENDLABEL,"End label '"<<*endnamep<<"' does not match begin label '"<<name<<"'");
}
}
void setDType(AstNodeDType* dtypep) {
if (m_varDTypep) { m_varDTypep->deleteTree(); m_varDTypep=NULL; } // It was cloned, so this is safe.
m_varDTypep = dtypep;
}
AstPackage* unitPackage(FileLine* fl) {
// Find one made earlier?
VSymEnt* symp = SYMP->symRootp()->findIdFlat(AstPackage::dollarUnitName());
AstPackage* pkgp;
if (!symp) {
pkgp = PARSEP->rootp()->dollarUnitPkgAddp();
SYMP->reinsert(pkgp, SYMP->symRootp()); // Don't push/pop scope as they're global
} else {
pkgp = VN_CAST(symp->nodep(), Package);
}
return pkgp;
}
AstNodeDType* addRange(AstBasicDType* dtypep, AstNodeRange* rangesp, bool isPacked) {
// If dtypep isn't basic, don't use this, call createArray() instead
if (!rangesp) {
return dtypep;
} else {
// If rangesp is "wire [3:3][2:2][1:1] foo [5:5][4:4]"
// then [1:1] becomes the basicdtype range; everything else is arraying
// the final [5:5][4:4] will be passed in another call to createArray
AstNodeRange* rangearraysp = NULL;
if (dtypep->isRanged()) {
rangearraysp = rangesp; // Already a range; everything is an array
} else {
AstNodeRange* finalp = rangesp;
while (finalp->nextp()) finalp = VN_CAST(finalp->nextp(), Range);
if (finalp != rangesp) {
finalp->unlinkFrBack();
rangearraysp = rangesp;
}
if (AstRange* finalRangep = VN_CAST(finalp, Range)) { // not an UnsizedRange
if (dtypep->implicit()) {
// It's no longer implicit but a real logic type
AstBasicDType* newp = new AstBasicDType(dtypep->fileline(), AstBasicDTypeKwd::LOGIC,
dtypep->numeric(), dtypep->width(), dtypep->widthMin());
dtypep->deleteTree(); VL_DANGLING(dtypep);
dtypep = newp;
}
dtypep->rangep(finalRangep);
}
}
return createArray(dtypep, rangearraysp, isPacked);
}
}
string deQuote(FileLine* fileline, string text);
void checkDpiVer(FileLine* fileline, const string& str) {
if (str != "DPI-C" && !v3Global.opt.bboxSys()) {
fileline->v3error("Unsupported DPI type '"<<str<<"': Use 'DPI-C'");
}
}
};
const AstBasicDTypeKwd LOGIC = AstBasicDTypeKwd::LOGIC; // Shorthand "LOGIC"
const AstBasicDTypeKwd LOGIC_IMPLICIT = AstBasicDTypeKwd::LOGIC_IMPLICIT;
int V3ParseGrammar::s_modTypeImpNum = 0;
//======================================================================
// Macro functions
#define CRELINE() (PARSEP->copyOrSameFileLine()) // Only use in empty rules, so lines point at beginnings
#define VARRESET_LIST(decl) { GRAMMARP->m_pinNum=1; VARRESET(); VARDECL(decl); } // Start of pinlist
#define VARRESET_NONLIST(decl) { GRAMMARP->m_pinNum=0; VARRESET(); VARDECL(decl); } // Not in a pinlist
#define VARRESET() { VARDECL(UNKNOWN); VARIO(NONE); VARDTYPE(NULL); }
#define VARDECL(type) { GRAMMARP->m_varDecl = AstVarType::type; }
#define VARIO(type) { GRAMMARP->m_varIO = VDirection::type; }
#define VARDTYPE(dtypep) { GRAMMARP->setDType(dtypep); }
#define VARDONEA(fl,name,array,attrs) GRAMMARP->createVariable((fl),(name),(array),(attrs))
#define VARDONEP(portp,array,attrs) GRAMMARP->createVariable((portp)->fileline(),(portp)->name(),(array),(attrs))
#define PINNUMINC() (GRAMMARP->m_pinNum++)
#define GATERANGE(rangep) { GRAMMARP->m_gateRangep = rangep; }
#define INSTPREP(modname,paramsp) { GRAMMARP->m_impliedDecl = true; GRAMMARP->m_instModule = modname; GRAMMARP->m_instParamp = paramsp; }
#define DEL(nodep) { if (nodep) nodep->deleteTree(); }
static void ERRSVKWD(FileLine* fileline, const string& tokname) {
static int toldonce = 0;
fileline->v3error(string("Unexpected \"")+tokname+"\": \""+tokname
+"\" is a SystemVerilog keyword misused as an identifier."
+(!toldonce++
? "\n"+V3Error::warnMore()
+"... Modify the Verilog-2001 code to avoid SV keywords,"
+" or use `begin_keywords or --language."
: ""));
}
//======================================================================
class AstSenTree;
%}
// When writing Bison patterns we use yTOKEN instead of "token",
// so Bison will error out on unknown "token"s.
// Generic lexer tokens, for example a number
// IEEE: real_number
%token<cdouble> yaFLOATNUM "FLOATING-POINT NUMBER"
// 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,
%token<strp> yaID__ETC "IDENTIFIER"
%token<strp> yaID__LEX "IDENTIFIER-in-lex"
%token<strp> yaID__aPACKAGE "PACKAGE-IDENTIFIER"
%token<strp> yaID__aTYPE "TYPE-IDENTIFIER"
// Can't predecode aFUNCTION, can declare after use
// Can't predecode aINTERFACE, can declare after use
// Can't predecode aTASK, can declare after use
// IEEE: integral_number
%token<nump> yaINTNUM "INTEGER NUMBER"
// IEEE: time_literal + time_unit
%token<cdouble> yaTIMENUM "TIME NUMBER"
// IEEE: string_literal
%token<strp> yaSTRING "STRING"
%token<strp> yaSTRING__IGNORE "STRING-ignored" // Used when expr:string not allowed
%token<fl> yaTIMINGSPEC "TIMING SPEC ELEMENT"
%token<fl> ygenSTRENGTH "STRENGTH keyword (strong1/etc)"
%token<strp> yaTABLELINE "TABLE LINE"
%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"
%token<fl> yVLT_COVERAGE_OFF "coverage_off"
%token<fl> yVLT_COVERAGE_ON "coverage_on"
%token<fl> yVLT_LINT_OFF "lint_off"
%token<fl> yVLT_LINT_ON "lint_on"
%token<fl> yVLT_TRACING_OFF "tracing_off"
%token<fl> yVLT_TRACING_ON "tracing_on"
%token<fl> yVLT_D_FILE "--file"
%token<fl> yVLT_D_LINES "--lines"
%token<fl> yVLT_D_MSG "--msg"
%token<strp> yaD_IGNORE "${ignored-bbox-sys}"
%token<strp> yaD_DPI "${dpi-sys}"
// <fl> is the fileline, abbreviated to shorten "$<fl>1" references
%token<fl> '!'
%token<fl> '#'
%token<fl> '%'
%token<fl> '&'
%token<fl> '('
%token<fl> ')'
%token<fl> '*'
%token<fl> '+'
%token<fl> ','
%token<fl> '-'
%token<fl> '.'
%token<fl> '/'
%token<fl> ':'
%token<fl> ';'
%token<fl> '<'
%token<fl> '='
%token<fl> '>'
%token<fl> '?'
%token<fl> '@'
%token<fl> '['
%token<fl> ']'
%token<fl> '^'
%token<fl> '{'
%token<fl> '|'
%token<fl> '}'
%token<fl> '~'
// Specific keywords
// yKEYWORD means match "keyword"
// Other cases are yXX_KEYWORD where XX makes it unique,
// for example yP_ for punctuation based operators.
// Double underscores "yX__Y" means token X followed by Y,
// and "yX__ETC" means X folled by everything but Y(s).
%token<fl> yALIAS "alias"
%token<fl> yALWAYS "always"
%token<fl> yALWAYS_COMB "always_comb"
%token<fl> yALWAYS_FF "always_ff"
%token<fl> yALWAYS_LATCH "always_latch"
%token<fl> yAND "and"
%token<fl> yASSERT "assert"
%token<fl> yASSIGN "assign"
%token<fl> yASSUME "assume"
%token<fl> yAUTOMATIC "automatic"
%token<fl> yBEGIN "begin"
%token<fl> yBIND "bind"
%token<fl> yBIT "bit"
%token<fl> yBREAK "break"
%token<fl> yBUF "buf"
%token<fl> yBUFIF0 "bufif0"
%token<fl> yBUFIF1 "bufif1"
%token<fl> yBYTE "byte"
%token<fl> yCASE "case"
%token<fl> yCASEX "casex"
%token<fl> yCASEZ "casez"
%token<fl> yCHANDLE "chandle"
%token<fl> yCLOCKING "clocking"
%token<fl> yCMOS "cmos"
%token<fl> yCONST__ETC "const"
%token<fl> yCONST__LEX "const-in-lex"
%token<fl> yCONST__REF "const-then-ref"
%token<fl> yCONTEXT "context"
%token<fl> yCONTINUE "continue"
%token<fl> yCOVER "cover"
%token<fl> yDEASSIGN "deassign"
%token<fl> yDEFAULT "default"
%token<fl> yDEFPARAM "defparam"
%token<fl> yDISABLE "disable"
%token<fl> yDO "do"
%token<fl> yEDGE "edge"
%token<fl> yELSE "else"
%token<fl> yEND "end"
%token<fl> yENDCASE "endcase"
%token<fl> yENDCLOCKING "endclocking"
%token<fl> yENDFUNCTION "endfunction"
%token<fl> yENDGENERATE "endgenerate"
%token<fl> yENDINTERFACE "endinterface"
%token<fl> yENDMODULE "endmodule"
%token<fl> yENDPACKAGE "endpackage"
%token<fl> yENDPRIMITIVE "endprimitive"
%token<fl> yENDPROGRAM "endprogram"
%token<fl> yENDPROPERTY "endproperty"
%token<fl> yENDSPECIFY "endspecify"
%token<fl> yENDTABLE "endtable"
%token<fl> yENDTASK "endtask"
%token<fl> yENUM "enum"
%token<fl> yEVENT "event"
%token<fl> yEXPORT "export"
%token<fl> yEXTERN "extern"
%token<fl> yFINAL "final"
%token<fl> yFOR "for"
%token<fl> yFORCE "force"
%token<fl> yFOREACH "foreach"
%token<fl> yFOREVER "forever"
%token<fl> yFORK "fork"
%token<fl> yFORKJOIN "forkjoin"
%token<fl> yFUNCTION "function"
%token<fl> yGENERATE "generate"
%token<fl> yGENVAR "genvar"
%token<fl> yGLOBAL__CLOCKING "global-then-clocking"
%token<fl> yGLOBAL__LEX "global-in-lex"
%token<fl> yIF "if"
%token<fl> yIFF "iff"
%token<fl> yIMPORT "import"
%token<fl> yINITIAL "initial"
%token<fl> yINOUT "inout"
%token<fl> yINPUT "input"
%token<fl> yINSIDE "inside"
%token<fl> yINT "int"
%token<fl> yINTEGER "integer"
%token<fl> yINTERFACE "interface"
%token<fl> yJOIN "join"
%token<fl> yLOCALPARAM "localparam"
%token<fl> yLOGIC "logic"
%token<fl> yLONGINT "longint"
%token<fl> yMODPORT "modport"
%token<fl> yMODULE "module"
%token<fl> yNAND "nand"
%token<fl> yNEGEDGE "negedge"
%token<fl> yNMOS "nmos"
%token<fl> yNOR "nor"
%token<fl> yNOT "not"
%token<fl> yNOTIF0 "notif0"
%token<fl> yNOTIF1 "notif1"
%token<fl> yNULL "null"
%token<fl> yOR "or"
%token<fl> yOUTPUT "output"
%token<fl> yPACKAGE "package"
%token<fl> yPACKED "packed"
%token<fl> yPARAMETER "parameter"
%token<fl> yPMOS "pmos"
%token<fl> yPOSEDGE "posedge"
%token<fl> yPRIMITIVE "primitive"
%token<fl> yPRIORITY "priority"
%token<fl> yPROGRAM "program"
%token<fl> yPROPERTY "property"
%token<fl> yPULLDOWN "pulldown"
%token<fl> yPULLUP "pullup"
%token<fl> yPURE "pure"
%token<fl> yRAND "rand"
%token<fl> yRANDC "randc"
%token<fl> yRANDCASE "randcase"
%token<fl> yRCMOS "rcmos"
%token<fl> yREAL "real"
%token<fl> yREALTIME "realtime"
%token<fl> yREF "ref"
%token<fl> yREG "reg"
%token<fl> yRELEASE "release"
%token<fl> yREPEAT "repeat"
%token<fl> yRESTRICT "restrict"
%token<fl> yRETURN "return"
%token<fl> yRNMOS "rnmos"
%token<fl> yRPMOS "rpmos"
%token<fl> yRTRAN "rtran"
%token<fl> yRTRANIF0 "rtranif0"
%token<fl> yRTRANIF1 "rtranif1"
%token<fl> ySCALARED "scalared"
%token<fl> ySHORTINT "shortint"
%token<fl> ySHORTREAL "shortreal"
%token<fl> ySIGNED "signed"
%token<fl> ySPECIFY "specify"
%token<fl> ySPECPARAM "specparam"
%token<fl> ySTATIC "static"
%token<fl> ySTRING "string"
%token<fl> ySTRUCT "struct"
%token<fl> ySUPPLY0 "supply0"
%token<fl> ySUPPLY1 "supply1"
%token<fl> yTABLE "table"
%token<fl> yTASK "task"
%token<fl> yTIME "time"
%token<fl> yTIMEPRECISION "timeprecision"
%token<fl> yTIMEUNIT "timeunit"
%token<fl> yTRAN "tran"
%token<fl> yTRANIF0 "tranif0"
%token<fl> yTRANIF1 "tranif1"
%token<fl> yTRI "tri"
%token<fl> yTRI0 "tri0"
%token<fl> yTRI1 "tri1"
%token<fl> yTRIAND "triand"
%token<fl> yTRIOR "trior"
%token<fl> yTRIREG "trireg"
%token<fl> yTRUE "true"
%token<fl> yTYPE "type"
%token<fl> yTYPEDEF "typedef"
%token<fl> yUNION "union"
%token<fl> yUNIQUE "unique"
%token<fl> yUNIQUE0 "unique0"
%token<fl> yUNSIGNED "unsigned"
%token<fl> yVAR "var"
%token<fl> yVECTORED "vectored"
%token<fl> yVOID "void"
%token<fl> yWAIT "wait"
%token<fl> yWAND "wand"
%token<fl> yWHILE "while"
%token<fl> yWIRE "wire"
%token<fl> yWOR "wor"
%token<fl> yWREAL "wreal"
%token<fl> yXNOR "xnor"
%token<fl> yXOR "xor"
%token<fl> yD_ACOS "$acos"
%token<fl> yD_ACOSH "$acosh"
%token<fl> yD_ASIN "$asin"
%token<fl> yD_ASINH "$asinh"
%token<fl> yD_ATAN "$atan"
%token<fl> yD_ATAN2 "$atan2"
%token<fl> yD_ATANH "$atanh"
%token<fl> yD_BITS "$bits"
%token<fl> yD_BITSTOREAL "$bitstoreal"
%token<fl> yD_C "$c"
%token<fl> yD_CEIL "$ceil"
%token<fl> yD_CLOG2 "$clog2"
%token<fl> yD_COS "$cos"
%token<fl> yD_COSH "$cosh"
%token<fl> yD_COUNTONES "$countones"
%token<fl> yD_DIMENSIONS "$dimensions"
%token<fl> yD_DISPLAY "$display"
%token<fl> yD_ERROR "$error"
%token<fl> yD_EXP "$exp"
%token<fl> yD_FATAL "$fatal"
%token<fl> yD_FCLOSE "$fclose"
%token<fl> yD_FDISPLAY "$fdisplay"
%token<fl> yD_FEOF "$feof"
%token<fl> yD_FFLUSH "$fflush"
%token<fl> yD_FGETC "$fgetc"
%token<fl> yD_FGETS "$fgets"
%token<fl> yD_FINISH "$finish"
%token<fl> yD_FLOOR "$floor"
%token<fl> yD_FOPEN "$fopen"
%token<fl> yD_FREAD "$fread"
%token<fl> yD_FSCANF "$fscanf"
%token<fl> yD_FWRITE "$fwrite"
%token<fl> yD_HIGH "$high"
%token<fl> yD_HYPOT "$hypot"
%token<fl> yD_INCREMENT "$increment"
%token<fl> yD_INFO "$info"
%token<fl> yD_ISUNKNOWN "$isunknown"
%token<fl> yD_ITOR "$itor"
%token<fl> yD_LEFT "$left"
%token<fl> yD_LN "$ln"
%token<fl> yD_LOG10 "$log10"
%token<fl> yD_LOW "$low"
%token<fl> yD_ONEHOT "$onehot"
%token<fl> yD_ONEHOT0 "$onehot0"
%token<fl> yD_PAST "$past"
%token<fl> yD_POW "$pow"
%token<fl> yD_RANDOM "$random"
%token<fl> yD_READMEMB "$readmemb"
%token<fl> yD_READMEMH "$readmemh"
%token<fl> yD_REALTIME "$realtime"
%token<fl> yD_REALTOBITS "$realtobits"
%token<fl> yD_RIGHT "$right"
%token<fl> yD_RTOI "$rtoi"
%token<fl> yD_SFORMAT "$sformat"
%token<fl> yD_SFORMATF "$sformatf"
%token<fl> yD_SIGNED "$signed"
%token<fl> yD_SIN "$sin"
%token<fl> yD_SINH "$sinh"
%token<fl> yD_SIZE "$size"
%token<fl> yD_SQRT "$sqrt"
%token<fl> yD_SSCANF "$sscanf"
%token<fl> yD_STIME "$stime"
%token<fl> yD_STOP "$stop"
%token<fl> yD_SWRITE "$swrite"
%token<fl> yD_SYSTEM "$system"
%token<fl> yD_TAN "$tan"
%token<fl> yD_TANH "$tanh"
%token<fl> yD_TESTPLUSARGS "$test$plusargs"
%token<fl> yD_TIME "$time"
%token<fl> yD_UNIT "$unit"
%token<fl> yD_UNPACKED_DIMENSIONS "$unpacked_dimensions"
%token<fl> yD_UNSIGNED "$unsigned"
%token<fl> yD_VALUEPLUSARGS "$value$plusargs"
%token<fl> yD_WARNING "$warning"
%token<fl> yD_WRITE "$write"
%token<fl> yD_WRITEMEMH "$writememh"
%token<fl> yVL_CLOCK "/*verilator sc_clock*/"
%token<fl> yVL_CLOCKER "/*verilator clocker*/"
%token<fl> yVL_NO_CLOCKER "/*verilator no_clocker*/"
%token<fl> yVL_CLOCK_ENABLE "/*verilator clock_enable*/"
%token<fl> yVL_COVERAGE_BLOCK_OFF "/*verilator coverage_block_off*/"
%token<fl> yVL_FULL_CASE "/*verilator full_case*/"
%token<fl> yVL_INLINE_MODULE "/*verilator inline_module*/"
%token<fl> yVL_ISOLATE_ASSIGNMENTS "/*verilator isolate_assignments*/"
%token<fl> yVL_NO_INLINE_MODULE "/*verilator no_inline_module*/"
%token<fl> yVL_NO_INLINE_TASK "/*verilator no_inline_task*/"
%token<fl> yVL_SC_BV "/*verilator sc_bv*/"
%token<fl> yVL_SFORMAT "/*verilator sformat*/"
%token<fl> yVL_PARALLEL_CASE "/*verilator parallel_case*/"
%token<fl> yVL_PUBLIC "/*verilator public*/"
%token<fl> yVL_PUBLIC_FLAT "/*verilator public_flat*/"
%token<fl> yVL_PUBLIC_FLAT_RD "/*verilator public_flat_rd*/"
%token<fl> yVL_PUBLIC_FLAT_RW "/*verilator public_flat_rw*/"
%token<fl> yVL_PUBLIC_MODULE "/*verilator public_module*/"
%token<fl> yP_TICK "'"
%token<fl> yP_TICKBRA "'{"
%token<fl> yP_OROR "||"
%token<fl> yP_ANDAND "&&"
%token<fl> yP_NOR "~|"
%token<fl> yP_XNOR "^~"
%token<fl> yP_NAND "~&"
%token<fl> yP_EQUAL "=="
%token<fl> yP_NOTEQUAL "!="
%token<fl> yP_CASEEQUAL "==="
%token<fl> yP_CASENOTEQUAL "!=="
%token<fl> yP_WILDEQUAL "==?"
%token<fl> yP_WILDNOTEQUAL "!=?"
%token<fl> yP_GTE ">="
%token<fl> yP_LTE "<="
%token<fl> yP_LTE__IGNORE "<=-ignored" // Used when expr:<= means assignment
%token<fl> yP_SLEFT "<<"
%token<fl> yP_SRIGHT ">>"
%token<fl> yP_SSRIGHT ">>>"
%token<fl> yP_POW "**"
%token<fl> yP_PAR__STRENGTH "(-for-strength"
%token<fl> yP_LTMINUSGT "<->"
%token<fl> yP_PLUSCOLON "+:"
%token<fl> yP_MINUSCOLON "-:"
%token<fl> yP_MINUSGT "->"
%token<fl> yP_MINUSGTGT "->>"
%token<fl> yP_EQGT "=>"
%token<fl> yP_ASTGT "*>"
%token<fl> yP_ANDANDAND "&&&"
%token<fl> yP_POUNDPOUND "##"
%token<fl> yP_DOTSTAR ".*"
%token<fl> yP_ATAT "@@"
%token<fl> yP_COLONCOLON "::"
%token<fl> yP_COLONEQ ":="
%token<fl> yP_COLONDIV ":/"
%token<fl> yP_ORMINUSGT "|->"
%token<fl> yP_OREQGT "|=>"
%token<fl> yP_BRASTAR "[*"
%token<fl> yP_BRAEQ "[="
%token<fl> yP_BRAMINUSGT "[->"
%token<fl> yP_PLUSPLUS "++"
%token<fl> yP_MINUSMINUS "--"
%token<fl> yP_PLUSEQ "+="
%token<fl> yP_MINUSEQ "-="
%token<fl> yP_TIMESEQ "*="
%token<fl> yP_DIVEQ "/="
%token<fl> yP_MODEQ "%="
%token<fl> yP_ANDEQ "&="
%token<fl> yP_OREQ "|="
%token<fl> yP_XOREQ "^="
%token<fl> yP_SLEFTEQ "<<="
%token<fl> yP_SRIGHTEQ ">>="
%token<fl> yP_SSRIGHTEQ ">>>="
// [* 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
//********************
// These prevent other conflicts
%left yP_ANDANDAND
// PSL op precedence
%right yP_ORMINUSGT yP_OREQGT
// Verilog op precedence
%right yP_MINUSGT yP_LTMINUSGT
%right '?' ':'
%left yP_OROR
%left yP_ANDAND
%left '|' yP_NOR
%left '^' yP_XNOR
%left '&' yP_NAND
%left yP_EQUAL yP_NOTEQUAL yP_CASEEQUAL yP_CASENOTEQUAL yP_WILDEQUAL yP_WILDNOTEQUAL
%left '>' '<' yP_GTE yP_LTE yP_LTE__IGNORE yINSIDE
%left yP_SLEFT yP_SRIGHT yP_SSRIGHT
%left '+' '-'
%left '*' '/' '%'
%left yP_POW
%left prUNARYARITH yP_MINUSMINUS yP_PLUSPLUS prREDUCTION prNEGATION
%left '.'
// Not in IEEE, but need to avoid conflicts; TICK should bind tightly just lower than COLONCOLON
%left yP_TICK
//%left '(' ')' '[' ']' yP_COLONCOLON '.'
%nonassoc prLOWER_THAN_ELSE
%nonassoc yELSE
//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
// 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
%start source_text
%%
//**********************************************************************
// Files
source_text: // ==IEEE: source_text
/* empty */ { }
// // timeunits_declaration moved into description:package_item
| descriptionList { }
;
descriptionList: // IEEE: part of source_text
description { }
| descriptionList description { }
;
description: // ==IEEE: description
module_declaration { }
// // udp_declaration moved into module_declaration
| interface_declaration { }
| program_declaration { }
| package_declaration { }
| package_item { if ($1) GRAMMARP->unitPackage($1->fileline())->addStmtp($1); }
| bind_directive { if ($1) GRAMMARP->unitPackage($1->fileline())->addStmtp($1); }
// unsupported // IEEE: config_declaration
// // Verilator only
| vltItem { }
| error { }
;
timeunits_declaration<nodep>: // ==IEEE: timeunits_declaration
yTIMEUNIT yaTIMENUM ';' { $$ = NULL; }
| yTIMEUNIT yaTIMENUM '/' yaTIMENUM ';' { $$ = NULL; }
| yTIMEPRECISION yaTIMENUM ';' { $$ = NULL; }
;
//**********************************************************************
// Packages
package_declaration: // ==IEEE: package_declaration
packageFront package_itemListE yENDPACKAGE endLabelE
{ $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
if ($2) $1->addStmtp($2);
SYMP->popScope($1);
GRAMMARP->endLabel($<fl>4,$1,$4); }
;
packageFront<modulep>:
yPACKAGE lifetimeE idAny ';'
{ $$ = new AstPackage($1,*$3);
$$->inLibrary(true); // packages are always libraries; don't want to make them a "top"
$$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
PARSEP->rootp()->addModulep($$);
SYMP->pushNew($$); }
;
package_itemListE<nodep>: // IEEE: [{ package_item }]
/* empty */ { $$ = NULL; }
| package_itemList { $$ = $1; }
;
package_itemList<nodep>: // IEEE: { package_item }
package_item { $$ = $1; }
| package_itemList package_item { $$ = $1->addNextNull($2); }
;
package_item<nodep>: // ==IEEE: package_item
package_or_generate_item_declaration { $$ = $1; }
| anonymous_program { $$ = $1; }
| package_export_declaration { $$ = $1; }
| timeunits_declaration { $$ = $1; }
;
package_or_generate_item_declaration<nodep>: // ==IEEE: package_or_generate_item_declaration
net_declaration { $$ = $1; }
| data_declaration { $$ = $1; }
| task_declaration { $$ = $1; }
| function_declaration { $$ = $1; }
//UNSUP checker_declaration { $$ = $1; }
| dpi_import_export { $$ = $1; }
//UNSUP extern_constraint_declaration { $$ = $1; }
//UNSUP class_declaration { $$ = $1; }
// // class_constructor_declaration is part of function_declaration
| local_parameter_declaration ';' { $$ = $1; }
| parameter_declaration ';' { $$ = $1; }
//UNSUP covergroup_declaration { $$ = $1; }
//UNSUP assertion_item_declaration { $$ = $1; }
| ';' { $$ = NULL; }
;
package_import_declarationList<nodep>:
package_import_declaration { $$ = $1; }
| package_import_declarationList package_import_declaration { $$ = $1->addNextNull($2); }
;
package_import_declaration<nodep>: // ==IEEE: package_import_declaration
yIMPORT package_import_itemList ';' { $$ = $2; }
;
package_import_itemList<nodep>:
package_import_item { $$ = $1; }
| package_import_itemList ',' package_import_item { $$ = $1->addNextNull($3); }
;
package_import_item<nodep>: // ==IEEE: package_import_item
yaID__aPACKAGE yP_COLONCOLON package_import_itemObj
{ $$ = new AstPackageImport($<fl>1, VN_CAST($<scp>1, Package), *$3);
SYMP->importItem($<scp>1,*$3); }
;
package_import_itemObj<strp>: // IEEE: part of package_import_item
idAny { $<fl>$=$<fl>1; $$=$1; }
| '*' { $<fl>$=$<fl>1; static string star="*"; $$=☆ }
;
package_export_declaration<nodep>: // IEEE: package_export_declaration
yEXPORT '*' yP_COLONCOLON '*' ';' { $$ = new AstPackageExportStarStar($<fl>1); SYMP->exportStarStar($<scp>1); }
| yEXPORT package_export_itemList ';' { $$ = $2; }
;
package_export_itemList<nodep>:
package_export_item { $$ = $1; }
| package_export_itemList ',' package_export_item { $$ = $1->addNextNull($3); }
;
package_export_item<nodep>: // ==IEEE: package_export_item
yaID__aPACKAGE yP_COLONCOLON package_import_itemObj
{ $$ = new AstPackageExport($<fl>1, VN_CAST($<scp>1, Package), *$3);
SYMP->exportItem($<scp>1,*$3); }
;
//**********************************************************************
// Module headers
module_declaration: // ==IEEE: module_declaration
// // timeunits_declaration instead in module_item
// // IEEE: module_nonansi_header + module_ansi_header
modFront importsAndParametersE portsStarE ';'
module_itemListE yENDMODULE endLabelE
{ $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
if ($2) $1->addStmtp($2); if ($3) $1->addStmtp($3);
if ($5) $1->addStmtp($5);
SYMP->popScope($1);
GRAMMARP->endLabel($<fl>7,$1,$7); }
| udpFront parameter_port_listE portsStarE ';'
module_itemListE yENDPRIMITIVE endLabelE
{ $1->modTrace(false); // Stash for implicit wires, etc
if ($2) $1->addStmtp($2); if ($3) $1->addStmtp($3);
if ($5) $1->addStmtp($5);
GRAMMARP->m_tracingParse = true;
SYMP->popScope($1);
GRAMMARP->endLabel($<fl>7,$1,$7); }
//
| yEXTERN modFront parameter_port_listE portsStarE ';'
{ BBUNSUP($<fl>1, "Unsupported: extern module"); }
;
modFront<modulep>:
// // General note: all *Front functions must call symPushNew before
// // any formal arguments, as the arguments must land in the new scope.
yMODULE lifetimeE idAny
{ $$ = new AstModule($1,*$3); $$->inLibrary(PARSEP->inLibrary()||PARSEP->inCellDefine());
$$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
PARSEP->rootp()->addModulep($$);
SYMP->pushNew($$); }
;
importsAndParametersE<nodep>: // IEEE: common part of module_declaration, interface_declaration, program_declaration
// // { package_import_declaration } [ parameter_port_list ]
parameter_port_listE { $$ = $1; }
| package_import_declarationList parameter_port_listE { $$ = $1->addNextNull($2); }
;
udpFront<modulep>:
yPRIMITIVE lifetimeE idAny
{ $$ = new AstPrimitive($1,*$3); $$->inLibrary(true);
$$->modTrace(false);
$$->addStmtp(new AstPragma($1,AstPragmaType::INLINE_MODULE));
GRAMMARP->m_tracingParse = false;
PARSEP->rootp()->addModulep($$);
SYMP->pushNew($$); }
;
parameter_value_assignmentE<pinp>: // IEEE: [ parameter_value_assignment ]
/* empty */ { $$ = NULL; }
| '#' '(' cellparamList ')' { $$ = $3; }
// // Parentheses are optional around a single parameter
| '#' yaINTNUM { $$ = new AstPin($1,1,"",new AstConst($1,*$2)); }
| '#' yaFLOATNUM { $$ = new AstPin($1,1,"",new AstConst($1,AstConst::Unsized32(),(int)(($2<0)?($2-0.5):($2+0.5)))); }
| '#' idClassSel { $$ = new AstPin($1,1,"",$2); }
// // Not needed in Verilator:
// // Side effect of combining *_instantiations
// // '#' delay_value { UNSUP }
;
parameter_port_listE<nodep>: // IEEE: parameter_port_list + empty == parameter_value_assignment
/* empty */ { $$ = NULL; }
| '#' '(' ')' { $$ = NULL; }
// // IEEE: '#' '(' list_of_param_assignments { ',' parameter_port_declaration } ')'
// // IEEE: '#' '(' parameter_port_declaration { ',' parameter_port_declaration } ')'
// // Can't just do that as "," conflicts with between vars and between stmts, so
// // split into pre-comma and post-comma parts
| '#' '(' {VARRESET_LIST(GPARAM);} paramPortDeclOrArgList ')' { $$ = $4; VARRESET_NONLIST(UNKNOWN); }
// // Note legal to start with "a=b" with no parameter statement
;
paramPortDeclOrArgList<nodep>: // IEEE: list_of_param_assignments + { parameter_port_declaration }
paramPortDeclOrArg { $$ = $1; }
| paramPortDeclOrArgList ',' paramPortDeclOrArg { $$ = $1->addNext($3); }
;
paramPortDeclOrArg<nodep>: // IEEE: param_assignment + parameter_port_declaration
// // We combine the two as we can't tell which follows a comma
parameter_port_declarationFrontE param_assignment { $$ = $2; }
;
portsStarE<nodep>: // IEEE: .* + list_of_ports + list_of_port_declarations + empty
/* empty */ { $$ = NULL; }
| '(' ')' { $$ = NULL; }
// // .* expanded from module_declaration
//UNSUP '(' yP_DOTSTAR ')' { UNSUP }
| '(' {VARRESET_LIST(PORT);} list_of_ports ')' { $$ = $3; VARRESET_NONLIST(UNKNOWN); }
;
list_of_ports<nodep>: // IEEE: list_of_ports + list_of_port_declarations
port { $$ = $1; }
| list_of_ports ',' port { $$ = $1->addNextNull($3); }
;
port<nodep>: // ==IEEE: port
// // Though not type for interfaces, we factor out the port direction and type
// // so we can simply handle it in one place
//
// // IEEE: interface_port_header port_identifier { unpacked_dimension }
// // Expanded interface_port_header
// // We use instantCb here because the non-port form looks just like a module instantiation
portDirNetE id/*interface*/ portSig variable_dimensionListE sigAttrListE
{ $$ = $3; VARDECL(AstVarType::IFACEREF); VARIO(NONE);
VARDTYPE(new AstIfaceRefDType($<fl>2,"",*$2));
$$->addNextNull(VARDONEP($$,$4,$5)); }
| portDirNetE id/*interface*/ '.' idAny/*modport*/ portSig variable_dimensionListE sigAttrListE
{ $$ = $5; VARDECL(AstVarType::IFACEREF); VARIO(NONE);
VARDTYPE(new AstIfaceRefDType($<fl>2,"",*$2,*$4));
$$->addNextNull(VARDONEP($$,$6,$7)); }
| portDirNetE yINTERFACE portSig rangeListE sigAttrListE
{ $$ = NULL; BBUNSUP($<fl>2, "Unsupported: virtual or generic interfaces"); }
| portDirNetE yINTERFACE '.' idAny/*modport*/ portSig rangeListE sigAttrListE
{ $$ = NULL; BBUNSUP($<fl>2, "Unsupported: virtual or generic interfaces"); }
//
// // IEEE: ansi_port_declaration, with [port_direction] removed
// // IEEE: [ net_port_header | interface_port_header ] port_identifier { unpacked_dimension } [ '=' constant_expression ]
// // IEEE: [ net_port_header | variable_port_header ] '.' port_identifier '(' [ expression ] ')'
// // IEEE: [ variable_port_header ] port_identifier { variable_dimension } [ '=' constant_expression ]
// // Substitute net_port_header = [ port_direction ] net_port_type
// // Substitute variable_port_header = [ port_direction ] variable_port_type
// // Substitute net_port_type = [ net_type ] data_type_or_implicit
// // Substitute variable_port_type = var_data_type
// // Substitute var_data_type = data_type | yVAR data_type_or_implicit
// // [ [ port_direction ] net_port_type | interface_port_header ] port_identifier { unpacked_dimension }
// // [ [ port_direction ] var_data_type ] port_identifier variable_dimensionListE [ '=' constant_expression ]
// // [ [ port_direction ] net_port_type | [ port_direction ] var_data_type ] '.' port_identifier '(' [ expression ] ')'
//
// // Remove optional '[...] id' is in portAssignment
// // Remove optional '[port_direction]' is in port
// // net_port_type | interface_port_header port_identifier { unpacked_dimension }
// // net_port_type | interface_port_header port_identifier { unpacked_dimension }
// // var_data_type port_identifier variable_dimensionListE [ '=' constExpr ]
// // net_port_type | [ port_direction ] var_data_type '.' port_identifier '(' [ expr ] ')'
// // Expand implicit_type
//
// // variable_dimensionListE instead of rangeListE to avoid conflicts
//
// // Note implicit rules looks just line declaring additional followon port
// // No VARDECL("port") for implicit, as we don't want to declare variables for them
//UNSUP portDirNetE data_type '.' portSig '(' portAssignExprE ')' sigAttrListE
//UNSUP { UNSUP }
//UNSUP portDirNetE yVAR data_type '.' portSig '(' portAssignExprE ')' sigAttrListE
//UNSUP { UNSUP }
//UNSUP portDirNetE yVAR implicit_type '.' portSig '(' portAssignExprE ')' sigAttrListE
//UNSUP { UNSUP }
//UNSUP portDirNetE signingE rangeList '.' portSig '(' portAssignExprE ')' sigAttrListE
//UNSUP { UNSUP }
//UNSUP portDirNetE /*implicit*/ '.' portSig '(' portAssignExprE ')' sigAttrListE
//UNSUP { UNSUP }
//
| portDirNetE data_type portSig variable_dimensionListE sigAttrListE
{ $$=$3; VARDTYPE($2); $$->addNextNull(VARDONEP($$,$4,$5)); }
| portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE
{ $$=$4; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); }
| portDirNetE yVAR implicit_typeE portSig variable_dimensionListE sigAttrListE
{ $$=$4; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); }
| portDirNetE signing portSig variable_dimensionListE sigAttrListE
{ $$=$3; VARDTYPE(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2)); $$->addNextNull(VARDONEP($$,$4,$5)); }
| portDirNetE signingE rangeList portSig variable_dimensionListE sigAttrListE
{ $$=$4; VARDTYPE(GRAMMARP->addRange(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2), $3,true)); $$->addNextNull(VARDONEP($$,$5,$6)); }
| portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE
{ $$=$2; /*VARDTYPE-same*/ $$->addNextNull(VARDONEP($$,$3,$4)); }
//
| portDirNetE data_type portSig variable_dimensionListE sigAttrListE '=' constExpr
{ $$=$3; VARDTYPE($2); if (AstVar* vp=VARDONEP($$,$4,$5)) { $$->addNextNull(vp); vp->valuep($7); } }
| portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE '=' constExpr
{ $$=$4; VARDTYPE($3); if (AstVar* vp=VARDONEP($$,$5,$6)) { $$->addNextNull(vp); vp->valuep($8); } }
| portDirNetE yVAR implicit_typeE portSig variable_dimensionListE sigAttrListE '=' constExpr
{ $$=$4; VARDTYPE($3); if (AstVar* vp=VARDONEP($$,$5,$6)) { $$->addNextNull(vp); vp->valuep($8); } }
| portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE '=' constExpr
{ $$=$2; /*VARDTYPE-same*/ if (AstVar* vp=VARDONEP($$,$3,$4)) { $$->addNextNull(vp); vp->valuep($6); } }
;
portDirNetE: // IEEE: part of port, optional net type and/or direction
/* empty */ { }
// // Per spec, if direction given default the nettype.
// // The higher level rule may override this VARDTYPE with one later in the parse.
| port_direction { VARDECL(PORT); VARDTYPE(NULL/*default_nettype*/); }
| port_direction { VARDECL(PORT); } net_type { VARDTYPE(NULL/*default_nettype*/); } // net_type calls VARDECL
| net_type { } // net_type calls VARDECL
;
port_declNetE: // IEEE: part of port_declaration, optional net type
/* empty */ { }
| net_type { } // net_type calls VARDECL
;
portSig<nodep>:
id/*port*/ { $$ = new AstPort($<fl>1,PINNUMINC(),*$1); }
| idSVKwd { $$ = new AstPort($<fl>1,PINNUMINC(),*$1); }
;
//**********************************************************************
// Interface headers
interface_declaration: // IEEE: interface_declaration + interface_nonansi_header + interface_ansi_header:
// // timeunits_delcarationE is instead in interface_item
intFront parameter_port_listE portsStarE ';'
interface_itemListE yENDINTERFACE endLabelE
{ if ($2) $1->addStmtp($2);
if ($3) $1->addStmtp($3);
if ($5) $1->addStmtp($5);
SYMP->popScope($1); }
| yEXTERN intFront parameter_port_listE portsStarE ';'
{ BBUNSUP($<fl>1, "Unsupported: extern interface"); }
;
intFront<modulep>:
yINTERFACE lifetimeE idAny/*new_interface*/
{ $$ = new AstIface($1,*$3);
$$->inLibrary(true);
PARSEP->rootp()->addModulep($$);
SYMP->pushNew($$); }
;
interface_itemListE<nodep>:
/* empty */ { $$ = NULL; }
| interface_itemList { $$ = $1; }
;
interface_itemList<nodep>:
interface_item { $$ = $1; }
| interface_itemList interface_item { $$ = $1->addNextNull($2); }
;
interface_item<nodep>: // IEEE: interface_item + non_port_interface_item
port_declaration ';' { $$ = $1; }
// // IEEE: non_port_interface_item
// // IEEE: generate_region
| interface_generate_region { $$ = $1; }
| interface_or_generate_item { $$ = $1; }
| program_declaration { $$ = NULL; v3error("Unsupported: program decls within interface decls"); }
// // IEEE 1800-2017: modport_item
// // See instead old 2012 position in interface_or_generate_item
| interface_declaration { $$ = NULL; v3error("Unsupported: interface decls within interface decls"); }
| timeunits_declaration { $$ = $1; }
// // See note in interface_or_generate item
| module_common_item { $$ = $1; }
;
interface_generate_region<nodep>: // ==IEEE: generate_region
yGENERATE interface_itemList yENDGENERATE { $$ = new AstGenerate($1, $2); }
| yGENERATE yENDGENERATE { $$ = NULL; }
;
interface_or_generate_item<nodep>: // ==IEEE: interface_or_generate_item
// // module_common_item in interface_item, as otherwise duplicated
// // with module_or_generate_item's module_common_item
modport_declaration { $$ = $1; }
| extern_tf_declaration { $$ = $1; }
;
//**********************************************************************
// Program headers
anonymous_program<nodep>: // ==IEEE: anonymous_program
// // See the spec - this doesn't change the scope, items still go up "top"
yPROGRAM ';' anonymous_program_itemListE yENDPROGRAM { $<fl>1->v3error("Unsupported: Anonymous programs"); $$ = NULL; }
;
anonymous_program_itemListE<nodep>: // IEEE: { anonymous_program_item }
/* empty */ { $$ = NULL; }
| anonymous_program_itemList { $$ = $1; }
;
anonymous_program_itemList<nodep>: // IEEE: { anonymous_program_item }
anonymous_program_item { $$ = $1; }
| anonymous_program_itemList anonymous_program_item { $$ = $1->addNextNull($2); }
;
anonymous_program_item<nodep>: // ==IEEE: anonymous_program_item
task_declaration { $$ = $1; }
| function_declaration { $$ = $1; }
//UNSUP class_declaration { $$ = $1; }
//UNSUP covergroup_declaration { $$ = $1; }
// // class_constructor_declaration is part of function_declaration
| ';' { }
;
program_declaration: // IEEE: program_declaration + program_nonansi_header + program_ansi_header:
// // timeunits_delcarationE is instead in program_item
pgmFront parameter_port_listE portsStarE ';'
program_itemListE yENDPROGRAM endLabelE
{ $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
if ($2) $1->addStmtp($2); if ($3) $1->addStmtp($3);
if ($5) $1->addStmtp($5);
SYMP->popScope($1);
GRAMMARP->endLabel($<fl>7,$1,$7); }
| yEXTERN pgmFront parameter_port_listE portsStarE ';'
{ BBUNSUP($<fl>1, "Unsupported: extern program");
SYMP->popScope($2); }
;
pgmFront<modulep>:
yPROGRAM lifetimeE idAny/*new_program*/
{ $$ = new AstModule($1,*$3); $$->inLibrary(PARSEP->inLibrary()||PARSEP->inCellDefine());
$$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
PARSEP->rootp()->addModulep($$);
SYMP->pushNew($$); }
;
program_itemListE<nodep>: // ==IEEE: [{ program_item }]
/* empty */ { $$ = NULL; }
| program_itemList { $$ = $1; }
;
program_itemList<nodep>: // ==IEEE: { program_item }
program_item { $$ = $1; }
| program_itemList program_item { $$ = $1->addNextNull($2); }
;
program_item<nodep>: // ==IEEE: program_item
port_declaration ';' { $$ = $1; }
| non_port_program_item { $$ = $1; }
;
non_port_program_item<nodep>: // ==IEEE: non_port_program_item
continuous_assign { $$ = $1; }
| module_or_generate_item_declaration { $$ = $1; }
| initial_construct { $$ = $1; }
| final_construct { $$ = $1; }
| concurrent_assertion_item { $$ = $1; }
| timeunits_declaration { $$ = $1; }
| program_generate_item { $$ = $1; }
;
program_generate_item<nodep>: // ==IEEE: program_generate_item
loop_generate_construct { $$ = $1; }
| conditional_generate_construct { $$ = $1; }
| generate_region { $$ = $1; }
| elaboration_system_task { $$ = $1; }
;
extern_tf_declaration<nodep>: // ==IEEE: extern_tf_declaration
yEXTERN task_prototype ';' { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: extern task"); }
| yEXTERN function_prototype ';' { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: extern function"); }
| yEXTERN yFORKJOIN task_prototype ';' { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: extern forkjoin"); }
;
modport_declaration<nodep>: // ==IEEE: modport_declaration
yMODPORT modport_itemList ';' { $$ = $2; }
;
modport_itemList<nodep>: // IEEE: part of modport_declaration
modport_item { $$ = $1; }
| modport_itemList ',' modport_item { $$ = $1->addNextNull($3); }
;
modport_item<nodep>: // ==IEEE: modport_item
id/*new-modport*/ '(' { VARRESET_NONLIST(UNKNOWN); VARIO(INOUT); }
/*cont*/ modportPortsDeclList ')' { $$ = new AstModport($2,*$1,$4); }
;
modportPortsDeclList<nodep>:
modportPortsDecl { $$ = $1; }
| modportPortsDeclList ',' modportPortsDecl { $$ = $1->addNextNull($3); }
;
// IEEE: modport_ports_declaration + modport_simple_ports_declaration
// + (modport_tf_ports_declaration+import_export) + modport_clocking_declaration
// We've expanded the lists each take to instead just have standalone ID ports.
// We track the type as with the V2k series of defines, then create as each ID is seen.
modportPortsDecl<nodep>:
// // IEEE: modport_simple_ports_declaration
port_direction modportSimplePort { $$ = new AstModportVarRef($<fl>1,*$2,GRAMMARP->m_varIO); }
// // IEEE: modport_clocking_declaration
| yCLOCKING idAny/*clocking_identifier*/ { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: Modport clocking"); }
// // IEEE: yIMPORT modport_tf_port
// // IEEE: yEXPORT modport_tf_port
// // modport_tf_port expanded here
| yIMPORT id/*tf_identifier*/ { $$ = new AstModportFTaskRef($<fl>1,*$2,false); }
| yEXPORT id/*tf_identifier*/ { $$ = new AstModportFTaskRef($<fl>1,*$2,true); }
| yIMPORT method_prototype { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: Modport import with prototype"); }
| yEXPORT method_prototype { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: Modport export with prototype"); }
// Continuations of above after a comma.
// // IEEE: modport_simple_ports_declaration
| modportSimplePort { $$ = new AstModportVarRef($<fl>1,*$1,GRAMMARP->m_varIO); }
;
modportSimplePort<strp>: // IEEE: modport_simple_port or modport_tf_port, depending what keyword was earlier
id { $$ = $1; }
//UNSUP '.' idAny '(' ')' { }
//UNSUP '.' idAny '(' expr ')' { }
;
//************************************************
// Variable Declarations
genvar_declaration<nodep>: // ==IEEE: genvar_declaration
yGENVAR list_of_genvar_identifiers ';' { $$ = $2; }
;
list_of_genvar_identifiers<nodep>: // IEEE: list_of_genvar_identifiers (for declaration)
genvar_identifierDecl { $$ = $1; }
| list_of_genvar_identifiers ',' genvar_identifierDecl { $$ = $1->addNext($3); }
;
genvar_identifierDecl<varp>: // IEEE: genvar_identifier (for declaration)
id/*new-genvar_identifier*/ sigAttrListE
{ VARRESET_NONLIST(GENVAR); VARDTYPE(new AstBasicDType($<fl>1,AstBasicDTypeKwd::INTEGER));
$$ = VARDONEA($<fl>1, *$1, NULL, $2); }
;
local_parameter_declaration<nodep>: // IEEE: local_parameter_declaration
// // See notes in parameter_declaration
// // Front must execute first so VARDTYPE is ready before list of vars
local_parameter_declarationFront list_of_param_assignments { $$ = $2; }
;
parameter_declaration<nodep>: // IEEE: parameter_declaration
// // IEEE: yPARAMETER yTYPE list_of_type_assignments ';'
// // Instead of list_of_type_assignments
// // we use list_of_param_assignments because for port handling
// // it already must accept types, so simpler to have code only one place
// // Front must execute first so VARDTYPE is ready before list of vars
parameter_declarationFront list_of_param_assignments { $$ = $2; }
;
local_parameter_declarationFront: // IEEE: local_parameter_declaration w/o assignment
// // Front must execute first so VARDTYPE is ready before list of vars
varLParamReset implicit_typeE { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
| varLParamReset data_type { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
| varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE(new AstParseTypeDType($2)); }
;
parameter_declarationFront: // IEEE: parameter_declaration w/o assignment
// // Front must execute first so VARDTYPE is ready before list of vars
varGParamReset implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
| varGParamReset data_type { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
| varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($2)); }
;
parameter_port_declarationFrontE: // IEEE: parameter_port_declaration w/o assignment
// // IEEE: parameter_declaration (minus assignment)
// // IEEE: local_parameter_declaration (minus assignment)
// // Front must execute first so VARDTYPE is ready before list of vars
varGParamReset implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
| varGParamReset data_type { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
| varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($2)); }
| varLParamReset implicit_typeE { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
| varLParamReset data_type { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
| varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE(new AstParseTypeDType($2)); }
| implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($1); }
| data_type { /*VARRESET-in-varGParam*/ VARDTYPE($1); }
| yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($1)); }
;
net_declaration<nodep>: // IEEE: net_declaration - excluding implict
net_declarationFront netSigList ';' { $$ = $2; }
;
net_declarationFront: // IEEE: beginning of net_declaration
net_declRESET net_type strengthSpecE net_scalaredE net_dataType { VARDTYPE($5); }
//UNSUP net_declRESET yINTERCONNECT signingE rangeListE { VARNET($2); VARDTYPE(x); }
;
net_declRESET:
/* empty */ { VARRESET_NONLIST(UNKNOWN); }
;
net_scalaredE:
/* empty */ { }
// //UNSUP: ySCALARED/yVECTORED ignored
| ySCALARED { }
| yVECTORED { }
;
net_dataType<dtypep>:
// // If there's a SV data type there shouldn't be a delay on this wire
// // Otherwise #(...) can't be determined to be a delay or parameters
// // Submit this as a footnote to the committee
var_data_type { $$ = $1; }
| signingE rangeList delayE { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC, $1),$2,true); } // not implicit
| signing { $$ = new AstBasicDType($<fl>1, LOGIC, $1); } // not implicit
| /*implicit*/ delayE { $$ = new AstBasicDType(CRELINE(), LOGIC); } // not implicit
;
net_type: // ==IEEE: net_type
ySUPPLY0 { VARDECL(SUPPLY0); }
| ySUPPLY1 { VARDECL(SUPPLY1); }
| yTRI { VARDECL(TRIWIRE); }
| yTRI0 { VARDECL(TRI0); }
| yTRI1 { VARDECL(TRI1); }
| yTRIAND { VARDECL(WIRE); BBUNSUP($1, "Unsupported: triand"); }
| yTRIOR { VARDECL(WIRE); BBUNSUP($1, "Unsupported: trior"); }
| yTRIREG { VARDECL(WIRE); BBUNSUP($1, "Unsupported: trireg"); }
| yWAND { VARDECL(WIRE); BBUNSUP($1, "Unsupported: wand"); }
| yWIRE { VARDECL(WIRE); }
| yWOR { VARDECL(WIRE); BBUNSUP($1, "Unsupported: wor"); }
// // VAMS - somewhat hackish
| yWREAL { VARDECL(WREAL); }
;
varGParamReset:
yPARAMETER { VARRESET_NONLIST(GPARAM); }
;
varLParamReset:
yLOCALPARAM { VARRESET_NONLIST(LPARAM); }
;
port_direction: // ==IEEE: port_direction + tf_port_direction
// // IEEE 19.8 just "input" FIRST forces type to wire - we'll ignore that here
yINPUT { VARIO(INPUT); }
| yOUTPUT { VARIO(OUTPUT); }
| yINOUT { VARIO(INOUT); }
| yREF { VARIO(REF); }
| yCONST__REF yREF { VARIO(CONSTREF); }
;
port_directionReset: // IEEE: port_direction that starts a port_declaraiton
// // Used only for declarations outside the port list
yINPUT { VARRESET_NONLIST(UNKNOWN); VARIO(INPUT); }
| yOUTPUT { VARRESET_NONLIST(UNKNOWN); VARIO(OUTPUT); }
| yINOUT { VARRESET_NONLIST(UNKNOWN); VARIO(INOUT); }
| yREF { VARRESET_NONLIST(UNKNOWN); VARIO(REF); }
| yCONST__REF yREF { VARRESET_NONLIST(UNKNOWN); VARIO(CONSTREF); }
;
port_declaration<nodep>: // ==IEEE: port_declaration
// // Used inside block; followed by ';'
// // SIMILAR to tf_port_declaration
//
// // IEEE: inout_declaration
// // IEEE: input_declaration
// // IEEE: output_declaration
// // IEEE: ref_declaration
port_directionReset port_declNetE data_type { VARDTYPE($3); }
list_of_variable_decl_assignments { $$ = $5; }
| port_directionReset port_declNetE yVAR data_type { VARDTYPE($4); }
list_of_variable_decl_assignments { $$ = $6; }
| port_directionReset port_declNetE yVAR implicit_typeE { VARDTYPE($4); }
list_of_variable_decl_assignments { $$ = $6; }
| port_directionReset port_declNetE signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($4->fileline(), LOGIC_IMPLICIT, $3),$4,true)); }
list_of_variable_decl_assignments { $$ = $6; }
| port_directionReset port_declNetE signing { VARDTYPE(new AstBasicDType($<fl>3, LOGIC_IMPLICIT, $3)); }
list_of_variable_decl_assignments { $$ = $5; }
| port_directionReset port_declNetE /*implicit*/ { VARDTYPE(NULL);/*default_nettype*/}
list_of_variable_decl_assignments { $$ = $4; }
// // IEEE: interface_declaration
// // Looks just like variable declaration unless has a period
// // See etcInst
;
tf_port_declaration<nodep>: // ==IEEE: tf_port_declaration
// // Used inside function; followed by ';'
// // SIMILAR to port_declaration
//
port_directionReset data_type { VARDTYPE($2); } list_of_tf_variable_identifiers ';' { $$ = $4; }
| port_directionReset implicit_typeE { VARDTYPE($2); } list_of_tf_variable_identifiers ';' { $$ = $4; }
| port_directionReset yVAR data_type { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; }
| port_directionReset yVAR implicit_typeE { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; }
;
integer_atom_type<bdtypep>: // ==IEEE: integer_atom_type
yBYTE { $$ = new AstBasicDType($1,AstBasicDTypeKwd::BYTE); }
| ySHORTINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::SHORTINT); }
| yINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::INT); }
| yLONGINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LONGINT); }
| yINTEGER { $$ = new AstBasicDType($1,AstBasicDTypeKwd::INTEGER); }
| yTIME { $$ = new AstBasicDType($1,AstBasicDTypeKwd::TIME); }
;
integer_vector_type<bdtypep>: // ==IEEE: integer_atom_type
yBIT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::BIT); }
| yLOGIC { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LOGIC); }
| yREG { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LOGIC); } // logic==reg
;
non_integer_type<bdtypep>: // ==IEEE: non_integer_type
yREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); }
| yREALTIME { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); }
| ySHORTREAL { BBUNSUP($1, "Unsupported: shortreal (use real instead)");
$$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); }
;
signingE<signstate>: // IEEE: signing - plus empty
/*empty*/ { $$ = signedst_NOSIGN; }
| signing { $$ = $1; }
;
signing<signstate>: // ==IEEE: signing
ySIGNED { $<fl>$ = $<fl>1; $$ = signedst_SIGNED; }
| yUNSIGNED { $<fl>$ = $<fl>1; $$ = signedst_UNSIGNED; }
;
//************************************************
// Data Types
casting_type<dtypep>: // IEEE: casting_type
simple_type { $$ = $1; }
// // IEEE: constant_primary
// // In expr:cast this is expanded to just "expr"
//
// // IEEE: signing
//See where casting_type used
//^^ ySIGNED { $$ = new AstSigned($1,$3); }
//^^ yUNSIGNED { $$ = new AstUnsigned($1,$3); }
//UNSUP ySTRING { $$ = $1; }
//UNSUP yCONST__ETC/*then `*/ { $$ = $1; }
;
simple_type<dtypep>: // ==IEEE: simple_type
// // IEEE: integer_type
integer_atom_type { $$ = $1; }
| integer_vector_type { $$ = $1; }
| non_integer_type { $$ = $1; }
// // IEEE: ps_type_identifier
// // IEEE: ps_parameter_identifier (presumably a PARAMETER TYPE)
| ps_type { $$ = $1; }
// // { generate_block_identifer ... } '.'
// // Need to determine if generate_block_identifier can be lex-detected
;
data_type<dtypep>: // ==IEEE: data_type
// // This expansion also replicated elsewhere, IE data_type__AndID
data_typeNoRef { $$ = $1; }
// // IEEE: [ class_scope | package_scope ] type_identifier { packed_dimension }
| ps_type packed_dimensionListE { $$ = GRAMMARP->createArray($1,$2,true); }
//UNSUP class_scope_type packed_dimensionListE { UNSUP }
// // IEEE: class_type
//UNSUP class_typeWithoutId { $$ = $1; }
// // IEEE: ps_covergroup_identifier
// // we put covergroups under ps_type, so can ignore this
;
data_typeBasic<dtypep>: // IEEE: part of data_type
integer_vector_type signingE rangeListE { $1->setSignedState($2); $$ = GRAMMARP->addRange($1,$3,true); }
| integer_atom_type signingE { $1->setSignedState($2); $$ = $1; }
| non_integer_type { $$ = $1; }
;
data_typeNoRef<dtypep>: // ==IEEE: data_type, excluding class_type etc references
data_typeBasic { $$ = $1; }
| struct_unionDecl packed_dimensionListE { $$ = GRAMMARP->createArray(new AstDefImplicitDType($1->fileline(),"__typeimpsu"+cvtToStr(GRAMMARP->s_modTypeImpNum++),
SYMP,VFlagChildDType(),$1),$2,true); }
| enumDecl { $$ = new AstDefImplicitDType($1->fileline(),"__typeimpenum"+cvtToStr(GRAMMARP->s_modTypeImpNum++),
SYMP,VFlagChildDType(),$1); }
| ySTRING { $$ = new AstBasicDType($1,AstBasicDTypeKwd::STRING); }
| yCHANDLE { $$ = new AstBasicDType($1,AstBasicDTypeKwd::CHANDLE); }
| yEVENT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::BIT); BBUNSUP($1, "Unsupported: event data types"); }
//UNSUP yVIRTUAL__INTERFACE yINTERFACE id/*interface*/ { UNSUP }
//UNSUP yVIRTUAL__anyID id/*interface*/ { UNSUP }
//UNSUP type_reference { UNSUP }
// // IEEE: class_scope: see data_type above
// // IEEE: class_type: see data_type above
// // IEEE: ps_covergroup: see data_type above
;
data_type_or_void<dtypep>: // ==IEEE: data_type_or_void
data_type { $$ = $1; }
//UNSUP yVOID { UNSUP } // No yTAGGED structures
;
var_data_type<dtypep>: // ==IEEE: var_data_type
data_type { $$ = $1; }
| yVAR data_type { $$ = $2; }
| yVAR implicit_typeE { $$ = $2; }
;
struct_unionDecl<classp>: // IEEE: part of data_type
// // packedSigningE is NOP for unpacked
ySTRUCT packedSigningE '{' { $<classp>$ = new AstStructDType($1, $2); SYMP->pushNew($<classp>$); }
/*cont*/ struct_union_memberList '}'
{ $$=$<classp>4; $$->addMembersp($5); SYMP->popScope($$); }
| yUNION taggedE packedSigningE '{' { $<classp>$ = new AstUnionDType($1, $3); SYMP->pushNew($<classp>$); }
/*cont*/ struct_union_memberList '}'
{ $$=$<classp>5; $$->addMembersp($6); SYMP->popScope($$); }
;
struct_union_memberList<nodep>: // IEEE: { struct_union_member }
struct_union_member { $$ = $1; }
| struct_union_memberList struct_union_member { $$ = $1->addNextNull($2); }
;
struct_union_member<nodep>: // ==IEEE: struct_union_member
random_qualifierE data_type_or_void
{ GRAMMARP->m_memDTypep = $2; } // As a list follows, need to attach this dtype to each member.
/*cont*/ list_of_member_decl_assignments ';' { $$ = $4; GRAMMARP->m_memDTypep = NULL; }
;
list_of_member_decl_assignments<nodep>: // Derived from IEEE: list_of_variable_decl_assignments
member_decl_assignment { $$ = $1; }
| list_of_member_decl_assignments ',' member_decl_assignment { $$ = $1->addNextNull($3); }
;
member_decl_assignment<memberp>: // Derived from IEEE: variable_decl_assignment
// // At present we allow only packed structures/unions. So this is different from variable_decl_assignment
id variable_dimensionListE
{ if ($2) $2->v3error("Unsupported: Unpacked array in packed struct/union");
$$ = new AstMemberDType($<fl>1, *$1, VFlagChildDType(),
AstNodeDType::cloneTreeNull(GRAMMARP->m_memDTypep, true));
PARSEP->tagNodep($$);
}
| id variable_dimensionListE '=' variable_declExpr
{ $4->v3error("Unsupported: Initial values in struct/union members."); }
| idSVKwd { $$ = NULL; }
//
// // IEEE: "dynamic_array_variable_identifier '[' ']' [ '=' dynamic_array_new ]"
// // Matches above with variable_dimensionE = "[]"
// // IEEE: "class_variable_identifier [ '=' class_new ]"
// // variable_dimensionE must be empty
// // Pushed into variable_declExpr:dynamic_array_new
//
// // IEEE: "[ covergroup_variable_identifier ] '=' class_new
// // Pushed into variable_declExpr:class_new
//UNSUP '=' class_new { UNSUP }
;
list_of_variable_decl_assignments<nodep>: // ==IEEE: list_of_variable_decl_assignments
variable_decl_assignment { $$ = $1; }
| list_of_variable_decl_assignments ',' variable_decl_assignment { $$ = $1->addNextNull($3); }
;
variable_decl_assignment<varp>: // ==IEEE: variable_decl_assignment
id variable_dimensionListE sigAttrListE
{ $$ = VARDONEA($<fl>1,*$1,$2,$3); }
| id variable_dimensionListE sigAttrListE '=' variable_declExpr
{ $$ = VARDONEA($<fl>1,*$1,$2,$3); $$->valuep($5); }
| idSVKwd { $$ = NULL; }
//
// // IEEE: "dynamic_array_variable_identifier '[' ']' [ '=' dynamic_array_new ]"
// // Matches above with variable_dimensionE = "[]"
// // IEEE: "class_variable_identifier [ '=' class_new ]"
// // variable_dimensionE must be empty
// // Pushed into variable_declExpr:dynamic_array_new
//
// // IEEE: "[ covergroup_variable_identifier ] '=' class_new
// // Pushed into variable_declExpr:class_new
//UNSUP '=' class_new { UNSUP }
;
list_of_tf_variable_identifiers<nodep>: // ==IEEE: list_of_tf_variable_identifiers
tf_variable_identifier { $$ = $1; }
| list_of_tf_variable_identifiers ',' tf_variable_identifier { $$ = $1->addNext($3); }
;
tf_variable_identifier<varp>: // IEEE: part of list_of_tf_variable_identifiers
id variable_dimensionListE sigAttrListE
{ $$ = VARDONEA($<fl>1,*$1, $2, $3); }
| id variable_dimensionListE sigAttrListE '=' expr
{ $$ = VARDONEA($<fl>1,*$1, $2, $3);
$$->addNext(new AstAssign($4, new AstVarRef($4, *$1, true), $5)); }
;
variable_declExpr<nodep>: // IEEE: part of variable_decl_assignment - rhs of expr
expr { $$ = $1; }
//UNSUP dynamic_array_new { $$ = $1; }
//UNSUP class_new { $$ = $1; }
;
variable_dimensionListE<rangep>: // IEEE: variable_dimension + empty
/*empty*/ { $$ = NULL; }
| variable_dimensionList { $$ = $1; }
;
variable_dimensionList<rangep>: // IEEE: variable_dimension + empty
variable_dimension { $$ = $1; }
| variable_dimensionList variable_dimension { $$ = VN_CAST($1->addNext($2), NodeRange); }
;
variable_dimension<rangep>: // ==IEEE: variable_dimension
// // IEEE: unsized_dimension
'[' ']' { $$ = new AstUnsizedRange($1); }
// // IEEE: unpacked_dimension
| anyrange { $$ = $1; }
| '[' constExpr ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstSub($1, $2, new AstConst($1, 1))); }
// // IEEE: associative_dimension
//UNSUP '[' data_type ']' { UNSUP }
//UNSUP yP_BRASTAR ']' { UNSUP }
//UNSUP '[' '*' ']' { UNSUP }
// // IEEE: queue_dimension
// // '[' '$' ']' -- $ is part of expr
// // '[' '$' ':' expr ']' -- anyrange:expr:$
;
random_qualifierE: // IEEE: random_qualifier + empty
/*empty*/ { }
| random_qualifier { }
;
random_qualifier: // ==IEEE: random_qualifier
yRAND { } // Ignored until we support randomize()
| yRANDC { } // Ignored until we support randomize()
;
taggedE:
/*empty*/ { }
//UNSUP yTAGGED { UNSUP }
;
packedSigningE<signstate>:
// // AstNumeric::NOSIGN overloaded to indicate not packed
/*empty*/ { $$ = signedst_NOSIGN; }
| yPACKED signingE { $$ = $2; if ($$ == signedst_NOSIGN) $$ = signedst_UNSIGNED; }
;
//************************************************
// enum
// IEEE: part of data_type
enumDecl<dtypep>:
yENUM enum_base_typeE '{' enum_nameList '}' { $$ = new AstEnumDType($1,VFlagChildDType(),$2,$4); }
;
enum_base_typeE<dtypep>: // IEEE: enum_base_type
/* empty */ { $$ = new AstBasicDType(CRELINE(), AstBasicDTypeKwd::INT); }
// // Not in spec, but obviously "enum [1:0]" should work
// // implicit_type expanded, without empty
// // Note enum base types are always packed data types
| signingE rangeList { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1),$2,true); }
| signing { $$ = new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $1); }
//
| integer_atom_type signingE { $1->setSignedState($2); $$ = $1; }
| integer_vector_type signingE rangeListE { $1->setSignedState($2); $$ = GRAMMARP->addRange($1,$3,true); }
// // below can be idAny or yaID__aTYPE
// // IEEE requires a type, though no shift conflict if idAny
| idAny rangeListE { $$ = GRAMMARP->createArray(new AstRefDType($<fl>1, *$1), $2, true); }
;
enum_nameList<nodep>:
enum_name_declaration { $$ = $1; }
| enum_nameList ',' enum_name_declaration { $$ = $1->addNextNull($3); }
;
enum_name_declaration<nodep>: // ==IEEE: enum_name_declaration
idAny/*enum_identifier*/ enumNameRangeE enumNameStartE { $$ = new AstEnumItem($<fl>1, *$1, $2, $3); }
;
enumNameRangeE<nodep>: // IEEE: second part of enum_name_declaration
/* empty */ { $$ = NULL; }
| '[' intnumAsConst ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstConst($1, $2->toSInt()-1)); }
| '[' intnumAsConst ':' intnumAsConst ']' { $$ = new AstRange($1,$2,$4); }
;
enumNameStartE<nodep>: // IEEE: third part of enum_name_declaration
/* empty */ { $$ = NULL; }
| '=' constExpr { $$ = $2; }
;
intnumAsConst<constp>:
yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
;
//************************************************
// Typedef
data_declaration<nodep>: // ==IEEE: data_declaration
// // VARRESET can't be called here - conflicts
data_declarationVar { $$ = $1; }
| type_declaration { $$ = $1; }
| package_import_declaration { $$ = $1; }
// // IEEE: virtual_interface_declaration
// // "yVIRTUAL yID yID" looks just like a data_declaration
// // Therefore the virtual_interface_declaration term isn't used
;
data_declarationVar<nodep>: // IEEE: part of data_declaration
// // The first declaration has complications between assuming what's the type vs ID declaring
data_declarationVarFront list_of_variable_decl_assignments ';' { $$ = $2; }
;
data_declarationVarFront: // IEEE: part of data_declaration
// // Expanded: "constE yVAR lifetimeE data_type"
// // implicit_type expanded into /*empty*/ or "signingE rangeList"
/**/ yVAR lifetimeE data_type { VARRESET_NONLIST(VAR); VARDTYPE($3); }
| /**/ yVAR lifetimeE { VARRESET_NONLIST(VAR); VARDTYPE(new AstBasicDType($<fl>1, LOGIC_IMPLICIT)); }
| /**/ yVAR lifetimeE signingE rangeList { /*VARRESET-in-ddVar*/ VARDTYPE(GRAMMARP->addRange(new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $3), $4,true)); }
//
// // implicit_type expanded into /*empty*/ or "signingE rangeList"
| yCONST__ETC yVAR lifetimeE data_type { VARRESET_NONLIST(VAR); VARDTYPE(new AstConstDType($<fl>1, VFlagChildDType(), $4)); }
| yCONST__ETC yVAR lifetimeE { VARRESET_NONLIST(VAR); VARDTYPE(new AstConstDType($<fl>1, VFlagChildDType(), new AstBasicDType($<fl>2, LOGIC_IMPLICIT))); }
| yCONST__ETC yVAR lifetimeE signingE rangeList { VARRESET_NONLIST(VAR); VARDTYPE(new AstConstDType($<fl>1, VFlagChildDType(), GRAMMARP->addRange(new AstBasicDType($<fl>2, LOGIC_IMPLICIT, $4), $5,true))); }
//
// // Expanded: "constE lifetimeE data_type"
| /**/ data_type { VARRESET_NONLIST(VAR); VARDTYPE($1); }
| /**/ lifetime data_type { VARRESET_NONLIST(VAR); VARDTYPE($2); }
| yCONST__ETC lifetimeE data_type { VARRESET_NONLIST(VAR); VARDTYPE(new AstConstDType($<fl>1, VFlagChildDType(), $3)); }
// // = class_new is in variable_decl_assignment
;
implicit_typeE<dtypep>: // IEEE: part of *data_type_or_implicit
// // Also expanded in data_declaration
/* empty */ { $$ = NULL; }
| signingE rangeList { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1),$2,true); }
| signing { $$ = new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $1); }
;
type_declaration<nodep>: // ==IEEE: type_declaration
// // Use idAny, as we can redeclare a typedef on an existing typedef
yTYPEDEF data_type idAny variable_dimensionListE dtypeAttrListE ';'
/**/ { $$ = new AstTypedef($<fl>1, *$3, $5, VFlagChildDType(), GRAMMARP->createArray($2,$4,false));
SYMP->reinsert($$); PARSEP->tagNodep($$); }
//UNSUP yTYPEDEF id/*interface*/ '.' idAny/*type*/ idAny/*type*/ ';' { $$ = NULL; $1->v3error("Unsupported: SystemVerilog 2005 typedef in this context"); } //UNSUP
// // Combines into above "data_type id" rule
// // Verilator: Not important what it is in the AST, just need to make sure the yaID__aTYPE gets returned
| yTYPEDEF id ';' { $$ = NULL; $$ = new AstTypedefFwd($<fl>1, *$2); SYMP->reinsert($$); PARSEP->tagNodep($$); }
| yTYPEDEF yENUM idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($<fl>1, *$3); SYMP->reinsert($$); PARSEP->tagNodep($$); }
| yTYPEDEF ySTRUCT idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($<fl>1, *$3); SYMP->reinsert($$); PARSEP->tagNodep($$); }
| yTYPEDEF yUNION idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($<fl>1, *$3); SYMP->reinsert($$); PARSEP->tagNodep($$); }
//UNSUP yTYPEDEF yCLASS idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($<fl>1, *$3); SYMP->reinsert($$); PARSEP->tagNodep($$); }
//UNSUP yTYPEDEF yINTERFACE yCLASS idAny ';' { ... }
;
dtypeAttrListE<nodep>:
/* empty */ { $$ = NULL; }
| dtypeAttrList { $$ = $1; }
;
dtypeAttrList<nodep>:
dtypeAttr { $$ = $1; }
| dtypeAttrList dtypeAttr { $$ = $1->addNextNull($2); }
;
dtypeAttr<nodep>:
yVL_PUBLIC { $$ = new AstAttrOf($1,AstAttrType::DT_PUBLIC); }
;
//************************************************
// Module Items
module_itemListE<nodep>: // IEEE: Part of module_declaration
/* empty */ { $$ = NULL; }
| module_itemList { $$ = $1; }
;
module_itemList<nodep>: // IEEE: Part of module_declaration
module_item { $$ = $1; }
| module_itemList module_item { $$ = $1->addNextNull($2); }
;
module_item<nodep>: // ==IEEE: module_item
port_declaration ';' { $$ = $1; }
| non_port_module_item { $$ = $1; }
;
non_port_module_item<nodep>: // ==IEEE: non_port_module_item
generate_region { $$ = $1; }
| module_or_generate_item { $$ = $1; }
| specify_block { $$ = $1; }
| specparam_declaration { $$ = $1; }
| program_declaration { $$ = NULL; v3error("Unsupported: program decls within module decls"); }
| module_declaration { $$ = NULL; v3error("Unsupported: module decls within module decls"); }
| interface_declaration { $$ = NULL; v3error("Unsupported: interface decls within module decls"); }
| timeunits_declaration { $$ = $1; }
// // Verilator specific
| yaSCHDR { $$ = new AstScHdr($<fl>1,*$1); }
| yaSCINT { $$ = new AstScInt($<fl>1,*$1); }
| yaSCIMP { $$ = new AstScImp($<fl>1,*$1); }
| yaSCIMPH { $$ = new AstScImpHdr($<fl>1,*$1); }
| yaSCCTOR { $$ = new AstScCtor($<fl>1,*$1); }
| yaSCDTOR { $$ = new AstScDtor($<fl>1,*$1); }
| 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); v3Global.dpi(true); }
;
module_or_generate_item<nodep>: // ==IEEE: module_or_generate_item
// // IEEE: parameter_override
yDEFPARAM list_of_defparam_assignments ';' { $$ = $2; }
// // IEEE: gate_instantiation + udp_instantiation + module_instantiation
// // not here, see etcInst in module_common_item
// // We joined udp & module definitions, so this goes here
| combinational_body { $$ = $1; }
// // This module_common_item shared with interface_or_generate_item:module_common_item
| module_common_item { $$ = $1; }
;
module_common_item<nodep>: // ==IEEE: module_common_item
module_or_generate_item_declaration { $$ = $1; }
// // IEEE: interface_instantiation
// // + IEEE: program_instantiation
// // + module_instantiation from module_or_generate_item
| etcInst { $$ = $1; }
| assertion_item { $$ = $1; }
| bind_directive { $$ = $1; }
| continuous_assign { $$ = $1; }
// // IEEE: net_alias
| yALIAS variable_lvalue aliasEqList ';' { $$ = NULL; BBUNSUP($1, "Unsupported: alias statements"); }
| initial_construct { $$ = $1; }
| final_construct { $$ = $1; }
// // IEEE: always_construct
// // Verilator only - event_control attached to always
| yALWAYS event_controlE stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS, $2,$3); }
| yALWAYS_FF event_controlE stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS_FF, $2,$3); }
| yALWAYS_LATCH event_controlE stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS_LATCH, $2,$3); }
| yALWAYS_COMB stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS_COMB, NULL, $2); }
//
| loop_generate_construct { $$ = $1; }
| conditional_generate_construct { $$ = $1; }
| elaboration_system_task { $$ = $1; }
//
| error ';' { $$ = NULL; }
;
continuous_assign<nodep>: // IEEE: continuous_assign
yASSIGN strengthSpecE delayE assignList ';' { $$ = $4; }
;
initial_construct<nodep>: // IEEE: initial_construct
yINITIAL stmtBlock { $$ = new AstInitial($1,$2); }
;
final_construct<nodep>: // IEEE: final_construct
yFINAL stmtBlock { $$ = new AstFinal($1,$2); }
;
module_or_generate_item_declaration<nodep>: // ==IEEE: module_or_generate_item_declaration
package_or_generate_item_declaration { $$ = $1; }
| genvar_declaration { $$ = $1; }
| clocking_declaration { $$ = $1; }
| yDEFAULT yCLOCKING idAny/*new-clocking_identifier*/ ';' { $$ = NULL; BBUNSUP($1, "Unsupported: default clocking identifier"); }
//UNSUP yDEFAULT yDISABLE yIFF expr/*expression_or_dist*/ ';' { }
;
aliasEqList: // IEEE: part of net_alias
'=' variable_lvalue { }
| aliasEqList '=' variable_lvalue { }
;
bind_directive<nodep>: // ==IEEE: bind_directive + bind_target_scope
// // ';' - Note IEEE grammar is wrong, includes extra ';' - it's already in module_instantiation
// // We merged the rules - id may be a bind_target_instance or module_identifier or interface_identifier
yBIND bind_target_instance bind_instantiation { $$ = new AstBind($<fl>1,*$2,$3); }
| yBIND bind_target_instance ':' bind_target_instance_list bind_instantiation {
$$=NULL; BBUNSUP($1, "Unsupported: Bind with instance list"); }
;
bind_target_instance_list: // ==IEEE: bind_target_instance_list
bind_target_instance { }
| bind_target_instance_list ',' bind_target_instance { }
;
bind_target_instance<strp>: // ==IEEE: bind_target_instance
//UNSUP hierarchical_identifierBit { }
idAny { $$ = $1; }
;
bind_instantiation<nodep>: // ==IEEE: bind_instantiation
// // IEEE: program_instantiation
// // IEEE: + module_instantiation
// // IEEE: + interface_instantiation
// // Need to get an AstBind instead of AstCell, so have special rules
instDecl { $$ = $1; }
;
//************************************************
// Generates
//
// Way down in generate_item is speced a difference between module,
// interface and checker generates. modules and interfaces are almost
// identical (minus DEFPARAMs) so we overlap them. Checkers are too
// different, so we copy all rules for checkers.
generate_region<nodep>: // ==IEEE: generate_region
yGENERATE genItemList yENDGENERATE { $$ = new AstGenerate($1, $2); }
| yGENERATE yENDGENERATE { $$ = NULL; }
;
generate_block_or_null<nodep>: // IEEE: generate_block_or_null
// ';' // is included in
// // IEEE: generate_block
// // Must always return a BEGIN node, or NULL - see GenFor construction
generate_item { $$ = $1 ? (new AstBegin($1->fileline(),"genblk",$1,true)) : NULL; }
| genItemBegin { $$ = $1; }
;
genItemBegin<nodep>: // IEEE: part of generate_block
yBEGIN genItemList yEND { $$ = new AstBegin($1,"genblk",$2,true); }
| yBEGIN yEND { $$ = NULL; }
| id ':' yBEGIN genItemList yEND endLabelE { $$ = new AstBegin($2,*$1,$4,true); GRAMMARP->endLabel($<fl>6,*$1,$6); }
| id ':' yBEGIN yEND endLabelE { $$ = NULL; GRAMMARP->endLabel($<fl>5,*$1,$5); }
| yBEGIN ':' idAny genItemList yEND endLabelE { $$ = new AstBegin($2,*$3,$4,true); GRAMMARP->endLabel($<fl>6,*$3,$6); }
| yBEGIN ':' idAny yEND endLabelE { $$ = NULL; GRAMMARP->endLabel($<fl>5,*$3,$5); }
;
genItemOrBegin<nodep>: // Not in IEEE, but our begin isn't under generate_item
~c~generate_item { $$ = $1; }
| ~c~genItemBegin { $$ = $1; }
;
genItemList<nodep>:
~c~genItemOrBegin { $$ = $1; }
| ~c~genItemList ~c~genItemOrBegin { $$ = $1->addNextNull($2); }
;
generate_item<nodep>: // IEEE: module_or_interface_or_generate_item
// // Only legal when in a generate under a module (or interface under a module)
module_or_generate_item { $$ = $1; }
// // Only legal when in a generate under an interface
//UNSUP interface_or_generate_item { $$ = $1; }
// // IEEE: checker_or_generate_item
// // Only legal when in a generate under a checker
// // so below in c_generate_item
;
conditional_generate_construct<nodep>: // ==IEEE: conditional_generate_construct
yCASE '(' expr ')' ~c~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 '(' genvar_initialization ';' expr ';' genvar_iteration ')' ~c~generate_block_or_null
{ // Convert BEGIN(...) to BEGIN(GENFOR(...)), as we need the BEGIN to hide the local genvar
AstBegin* lowerBegp = VN_CAST($9, Begin);
if ($9 && !lowerBegp) $9->v3fatalSrc("Child of GENFOR should have been begin");
if (!lowerBegp) lowerBegp = new AstBegin($1,"genblk",NULL,true); // Empty body
AstNode* lowerNoBegp = lowerBegp->stmtsp();
if (lowerNoBegp) lowerNoBegp->unlinkFrBackWithNext();
//
AstBegin* blkp = new AstBegin($1,lowerBegp->name(),NULL,true);
// V3LinkDot detects BEGIN(GENFOR(...)) as a special case
AstNode* initp = $3; AstNode* varp = $3;
if (VN_IS(varp, Var)) { // Genvar
initp = varp->nextp();
initp->unlinkFrBackWithNext(); // Detach 2nd from varp, make 1st init
blkp->addStmtsp(varp);
}
// Statements are under 'genforp' as cells under this
// for loop won't get an extra layer of hierarchy tacked on
blkp->addGenforp(new AstGenFor($1,initp,$5,$7,lowerNoBegp));
$$ = blkp;
lowerBegp->deleteTree(); VL_DANGLING(lowerBegp);
}
;
genvar_initialization<nodep>: // ==IEEE: genvar_initalization
varRefBase '=' expr { $$ = new AstAssign($2,$1,$3); }
| yGENVAR genvar_identifierDecl '=' constExpr { $$ = $2; $2->addNext(new AstAssign($3,new AstVarRef($3,$2,true), $4)); }
;
genvar_iteration<nodep>: // ==IEEE: genvar_iteration
varRefBase '=' expr { $$ = new AstAssign($2,$1,$3); }
| varRefBase yP_PLUSEQ expr { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_MINUSEQ expr { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_TIMESEQ expr { $$ = new AstAssign($2,$1,new AstMul ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_DIVEQ expr { $$ = new AstAssign($2,$1,new AstDiv ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_MODEQ expr { $$ = new AstAssign($2,$1,new AstModDiv ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_ANDEQ expr { $$ = new AstAssign($2,$1,new AstAnd ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_OREQ expr { $$ = new AstAssign($2,$1,new AstOr ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_XOREQ expr { $$ = new AstAssign($2,$1,new AstXor ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_SLEFTEQ expr { $$ = new AstAssign($2,$1,new AstShiftL ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_SRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftR ($2,$1->cloneTree(true),$3)); }
| varRefBase yP_SSRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftRS($2,$1->cloneTree(true),$3)); }
// // inc_or_dec_operator
// When support ++ as a real AST type, maybe AstWhile::precondsp() becomes generic AstNodeMathStmt?
| yP_PLUSPLUS varRefBase { $$ = new AstAssign($1,$2,new AstAdd ($1,$2->cloneTree(true), new AstConst($1, AstConst::StringToParse(), "'b1"))); }
| yP_MINUSMINUS varRefBase { $$ = new AstAssign($1,$2,new AstSub ($1,$2->cloneTree(true), new AstConst($1, AstConst::StringToParse(), "'b1"))); }
| varRefBase yP_PLUSPLUS { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true), new AstConst($2, AstConst::StringToParse(), "'b1"))); }
| varRefBase yP_MINUSMINUS { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true), new AstConst($2, AstConst::StringToParse(), "'b1"))); }
;
case_generate_itemListE<nodep>: // IEEE: [{ case_generate_itemList }]
/* empty */ { $$ = NULL; }
| case_generate_itemList { $$ = $1; }
;
case_generate_itemList<nodep>: // IEEE: { case_generate_itemList }
~c~case_generate_item { $$=$1; }
| ~c~case_generate_itemList ~c~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); }
;
//************************************************
// Assignments and register declarations
assignList<nodep>:
assignOne { $$ = $1; }
| assignList ',' assignOne { $$ = $1->addNext($3); }
;
assignOne<nodep>:
variable_lvalue '=' expr { $$ = new AstAssignW($2,$1,$3); }
;
delayE:
/* empty */ { }
| delay_control { $1->v3warn(ASSIGNDLY,"Unsupported: Ignoring delay on this assignment/primitive."); } /* ignored */
;
delay_control<fl>: //== IEEE: delay_control
'#' delay_value { $$ = $1; } /* ignored */
| '#' '(' minTypMax ')' { $$ = $1; } /* ignored */
| '#' '(' minTypMax ',' minTypMax ')' { $$ = $1; } /* ignored */
| '#' '(' minTypMax ',' minTypMax ',' minTypMax ')' { $$ = $1; } /* ignored */
;
delay_value: // ==IEEE:delay_value
// // IEEE: ps_identifier
ps_id_etc { }
| yaINTNUM { }
| yaFLOATNUM { }
| yaTIMENUM { }
;
delayExpr:
expr { DEL($1); }
// // Verilator doesn't support yaTIMENUM, so not in expr
| yaTIMENUM { }
;
minTypMax: // IEEE: mintypmax_expression and constant_mintypmax_expression
delayExpr { }
| delayExpr ':' delayExpr ':' delayExpr { }
;
netSigList<varp>: // IEEE: list_of_port_identifiers
netSig { $$ = $1; }
| netSigList ',' netSig { $$ = $1; $1->addNext($3); }
;
netSig<varp>: // IEEE: net_decl_assignment - one element from list_of_port_identifiers
netId sigAttrListE { $$ = VARDONEA($<fl>1,*$1, NULL, $2); }
| netId sigAttrListE '=' expr { $$ = VARDONEA($<fl>1,*$1, NULL, $2); $$->addNext(new AstAssignW($3,new AstVarRef($3,$$->name(),true),$4)); }
| netId variable_dimensionList sigAttrListE { $$ = VARDONEA($<fl>1,*$1, $2, $3); }
;
netId<strp>:
id/*new-net*/ { $$ = $1; $<fl>$=$<fl>1; }
| idSVKwd { $$ = $1; $<fl>$=$<fl>1; }
;
sigAttrListE<nodep>:
/* empty */ { $$ = NULL; }
| sigAttrList { $$ = $1; }
;
sigAttrList<nodep>:
sigAttr { $$ = $1; }
| sigAttrList sigAttr { $$ = $1->addNextNull($2); }
;
sigAttr<nodep>:
yVL_CLOCK { $$ = new AstAttrOf($1,AstAttrType::VAR_CLOCK); }
| yVL_CLOCKER { $$ = new AstAttrOf($1,AstAttrType::VAR_CLOCKER); }
| yVL_NO_CLOCKER { $$ = new AstAttrOf($1,AstAttrType::VAR_NO_CLOCKER); }
| yVL_CLOCK_ENABLE { $$ = new AstAttrOf($1,AstAttrType::VAR_CLOCK_ENABLE); }
| yVL_PUBLIC { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC); v3Global.dpi(true); }
| yVL_PUBLIC_FLAT { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT); v3Global.dpi(true); }
| yVL_PUBLIC_FLAT_RD { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT_RD); v3Global.dpi(true); }
| yVL_PUBLIC_FLAT_RW { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT_RW); v3Global.dpi(true); }
| yVL_PUBLIC_FLAT_RW attr_event_control { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT_RW); v3Global.dpi(true);
$$ = $$->addNext(new AstAlwaysPublic($1,$2,NULL)); }
| yVL_ISOLATE_ASSIGNMENTS { $$ = new AstAttrOf($1,AstAttrType::VAR_ISOLATE_ASSIGNMENTS); }
| yVL_SC_BV { $$ = new AstAttrOf($1,AstAttrType::VAR_SC_BV); }
| yVL_SFORMAT { $$ = new AstAttrOf($1,AstAttrType::VAR_SFORMAT); }
;
rangeListE<rangep>: // IEEE: [{packed_dimension}]
/* empty */ { $$ = NULL; }
| rangeList { $$ = $1; }
;
rangeList<rangep>: // IEEE: {packed_dimension}
anyrange { $$ = $1; }
| rangeList anyrange { $$ = $1; $1->addNext($2); }
;
// IEEE: select
// Merged into more general idArray
anyrange<rangep>:
'[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
;
packed_dimensionListE<rangep>: // IEEE: [{ packed_dimension }]
/* empty */ { $$ = NULL; }
| packed_dimensionList { $$ = $1; }
;
packed_dimensionList<rangep>: // IEEE: { packed_dimension }
packed_dimension { $$ = $1; }
| packed_dimensionList packed_dimension { $$ = VN_CAST($1->addNext($2), NodeRange); }
;
packed_dimension<rangep>: // ==IEEE: packed_dimension
anyrange { $$ = $1; }
| '[' ']' { $$ = NULL; $<fl>1->v3error("Unsupported: [] dimensions"); }
;
//************************************************
// Parameters
param_assignment<varp>: // ==IEEE: param_assignment
// // IEEE: constant_param_expression
// // constant_param_expression: '$' is in expr
// // note exptOrDataType being a data_type is only for yPARAMETER yTYPE
id/*new-parameter*/ variable_dimensionListE sigAttrListE '=' exprOrDataType
/**/ { $$ = VARDONEA($<fl>1,*$1, $2, $3); $$->valuep($5); }
| id/*new-parameter*/ variable_dimensionListE sigAttrListE
/**/ { $$ = VARDONEA($<fl>1,*$1, $2, $3);
if ($<fl>1->language() < V3LangCode::L1800_2009) {
$<fl>1->v3error("Parameter requires default value, or use IEEE 1800-2009 or later."); } }
;
list_of_param_assignments<varp>: // ==IEEE: list_of_param_assignments
param_assignment { $$ = $1; }
| list_of_param_assignments ',' param_assignment { $$ = $1; $1->addNext($3); }
;
list_of_defparam_assignments<nodep>: //== IEEE: list_of_defparam_assignments
defparam_assignment { $$ = $1; }
| list_of_defparam_assignments ',' defparam_assignment { $$ = $1->addNext($3); }
;
defparam_assignment<nodep>: // ==IEEE: defparam_assignment
id '.' id '=' expr { $$ = new AstDefParam($4,*$1,*$3,$5); }
//UNSUP More general dotted identifiers
;
//************************************************
// Instances
// We don't know identifier types, so this matches all module,udp,etc instantiation
// module_id [#(params)] name (pins) [, name ...] ; // module_instantiation
// gate (strong0) [#(delay)] [name] (pins) [, (pins)...] ; // gate_instantiation
// program_id [#(params}] name ; // program_instantiation
// interface_id [#(params}] name ; // interface_instantiation
// checker_id name (pins) ; // checker_instantiation
etcInst<nodep>: // IEEE: module_instantiation + gate_instantiation + udp_instantiation
instDecl { $$ = $1; }
| gateDecl { $$ = $1; }
;
instDecl<nodep>:
id parameter_value_assignmentE {INSTPREP(*$1,$2);} instnameList ';'
{ $$ = $4; GRAMMARP->m_impliedDecl=false;
if (GRAMMARP->m_instParamp) { GRAMMARP->m_instParamp->deleteTree(); GRAMMARP->m_instParamp = NULL; } }
// // IEEE: interface_identifier' .' modport_identifier list_of_interface_identifiers
| id/*interface*/ '.' id/*modport*/
{ VARRESET_NONLIST(AstVarType::IFACEREF);
VARDTYPE(new AstIfaceRefDType($<fl>1,"",*$1,*$3)); }
mpInstnameList ';'
{ $$ = VARDONEP($5,NULL,NULL); }
//UNSUP: strengthSpecE for udp_instantiations
;
mpInstnameList<nodep>: // Similar to instnameList, but for modport instantiations which have no parenthesis
mpInstnameParen { $$ = $1; }
| mpInstnameList ',' mpInstnameParen { $$ = $1->addNext($3); }
;
mpInstnameParen<nodep>: // Similar to instnameParen, but for modport instantiations which have no parenthesis
id instRangeE sigAttrListE { $$ = VARDONEA($<fl>1,*$1,$2,$3); }
;
instnameList<nodep>:
instnameParen { $$ = $1; }
| instnameList ',' instnameParen { $$ = $1->addNext($3); }
;
instnameParen<cellp>:
// // Must clone m_instParamp as may be comma'ed list of instances
id instRangeE '(' cellpinList ')' { $$ = new AstCell($<fl>1, *$1, GRAMMARP->m_instModule, $4,
AstPin::cloneTreeNull(GRAMMARP->m_instParamp, true),
GRAMMARP->scrubRange($2));
$$->trace(GRAMMARP->allTracingOn($<fl>1)); }
| id instRangeE { $$ = new AstCell($<fl>1, *$1, GRAMMARP->m_instModule, NULL,
AstPin::cloneTreeNull(GRAMMARP->m_instParamp, true),
GRAMMARP->scrubRange($2));
$$->trace(GRAMMARP->allTracingOn($<fl>1)); }
//UNSUP instRangeE '(' cellpinList ')' { UNSUP } // UDP
// // Adding above and switching to the Verilog-Perl syntax
// // causes a shift conflict due to use of idClassSel inside exprScope.
// // It also breaks allowing "id foo;" instantiation syntax.
;
instRangeE<rangep>:
/* empty */ { $$ = NULL; }
| '[' constExpr ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstSub($1, $2, new AstConst($1, 1))); }
| '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
;
cellparamList<pinp>:
{VARRESET_LIST(UNKNOWN);} cellparamItList { $$ = $2; VARRESET_NONLIST(UNKNOWN); }
;
cellpinList<pinp>:
{VARRESET_LIST(UNKNOWN);} cellpinItList { $$ = $2; VARRESET_NONLIST(UNKNOWN); }
;
cellparamItList<pinp>: // IEEE: list_of_parameter_assignmente
cellparamItemE { $$ = $1; }
| cellparamItList ',' cellparamItemE { $$ = VN_CAST($1->addNextNull($3), Pin); }
;
cellpinItList<pinp>: // IEEE: list_of_port_connections
cellpinItemE { $$ = $1; }
| cellpinItList ',' cellpinItemE { $$ = VN_CAST($1->addNextNull($3), Pin); }
;
cellparamItemE<pinp>: // IEEE: named_parameter_assignment + empty
// Note empty can match either () or (,); V3LinkCells cleans up ()
/* empty: ',,' is legal */ { $$ = new AstPin(CRELINE(), PINNUMINC(), "", NULL); }
| yP_DOTSTAR { $$ = new AstPin($1,PINNUMINC(),".*",NULL); }
| '.' idSVKwd { $$ = new AstPin($1,PINNUMINC(),*$2,new AstParseRef($1,AstParseRefExp::PX_TEXT,*$2,NULL,NULL)); $$->svImplicit(true);}
| '.' idAny { $$ = new AstPin($1,PINNUMINC(),*$2,new AstParseRef($1,AstParseRefExp::PX_TEXT,*$2,NULL,NULL)); $$->svImplicit(true);}
| '.' idAny '(' ')' { $$ = new AstPin($1,PINNUMINC(),*$2,NULL); }
// // mintypmax is expanded here, as it might be a UDP or gate primitive
| '.' idAny '(' expr ')' { $$ = new AstPin($1,PINNUMINC(),*$2,$4); }
//UNSUP '.' idAny '(' expr ':' expr ')' { }
//UNSUP '.' idAny '(' expr ':' expr ':' expr ')' { }
// // For parameters
| '.' idAny '(' data_type ')' { $$ = new AstPin($1,PINNUMINC(),*$2,$4); }
// // For parameters
| data_type { $$ = new AstPin($1->fileline(),PINNUMINC(),"",$1); }
//
| expr { $$ = new AstPin($1->fileline(),PINNUMINC(),"",$1); }
//UNSUP expr ':' expr { }
//UNSUP expr ':' expr ':' expr { }
;
cellpinItemE<pinp>: // IEEE: named_port_connection + empty
// Note empty can match either () or (,); V3LinkCells cleans up ()
/* empty: ',,' is legal */ { $$ = new AstPin(CRELINE(), PINNUMINC(), "", NULL); }
| yP_DOTSTAR { $$ = new AstPin($1,PINNUMINC(),".*",NULL); }
| '.' idSVKwd { $$ = new AstPin($1,PINNUMINC(),*$2,new AstParseRef($1,AstParseRefExp::PX_TEXT,*$2,NULL,NULL)); $$->svImplicit(true);}
| '.' idAny { $$ = new AstPin($1,PINNUMINC(),*$2,new AstParseRef($1,AstParseRefExp::PX_TEXT,*$2,NULL,NULL)); $$->svImplicit(true);}
| '.' idAny '(' ')' { $$ = new AstPin($1,PINNUMINC(),*$2,NULL); }
// // mintypmax is expanded here, as it might be a UDP or gate primitive
| '.' idAny '(' expr ')' { $$ = new AstPin($1,PINNUMINC(),*$2,$4); }
//UNSUP '.' idAny '(' expr ':' expr ')' { }
//UNSUP '.' idAny '(' expr ':' expr ':' expr ')' { }
//
| expr { $$ = new AstPin($1->fileline(),PINNUMINC(),"",$1); }
//UNSUP expr ':' expr { }
//UNSUP expr ':' expr ':' expr { }
;
//************************************************
// EventControl lists
attr_event_control<sentreep>: // ==IEEE: event_control
'@' '(' event_expression ')' { $$ = new AstSenTree($1,$3); }
| '@' '(' '*' ')' { $$ = NULL; }
| '@' '*' { $$ = NULL; }
;
event_controlE<sentreep>:
/* empty */ { $$ = NULL; }
| event_control { $$ = $1; }
;
event_control<sentreep>: // ==IEEE: event_control
'@' '(' event_expression ')' { $$ = new AstSenTree($1,$3); }
| '@' '(' '*' ')' { $$ = NULL; }
| '@' '*' { $$ = NULL; }
// // IEEE: hierarchical_event_identifier
| '@' senitemVar { $$ = new AstSenTree($1,$2); } /* For events only */
// // IEEE: sequence_instance
// // sequence_instance without parens matches idClassSel above.
// // Ambiguity: "'@' sequence (-for-sequence" versus expr:delay_or_event_controlE "'@' id (-for-expr
// // For now we avoid this, as it's very unlikely someone would mix
// // 1995 delay with a sequence with parameters.
// // Alternatively split this out of event_control, and delay_or_event_controlE
// // and anywhere delay_or_event_controlE is called allow two expressions
//| '@' idClassSel '(' list_of_argumentsE ')' { }
;
event_expression<senitemp>: // IEEE: event_expression - split over several
senitem { $$ = $1; }
| event_expression yOR senitem { $$ = VN_CAST($1->addNextNull($3), NodeSenItem); }
| event_expression ',' senitem { $$ = VN_CAST($1->addNextNull($3), NodeSenItem); } /* Verilog 2001 */
;
senitem<senitemp>: // IEEE: part of event_expression, non-'OR' ',' terms
senitemEdge { $$ = $1; }
| senitemVar { $$ = $1; }
| '(' senitem ')' { $$ = $2; }
//UNSUP expr { UNSUP }
| '{' event_expression '}' { $$ = $2; }
| senitem yP_ANDAND senitem { $$ = new AstSenItem($2, AstSenItem::Illegal()); }
//UNSUP expr yIFF expr { UNSUP }
// Since expr is unsupported we allow and ignore constants (removed in V3Const)
| yaINTNUM { $$ = NULL; }
| yaFLOATNUM { $$ = NULL; }
;
senitemVar<senitemp>:
idClassSel { $$ = new AstSenItem($1->fileline(),AstEdgeType::ET_ANYEDGE,$1); }
;
senitemEdge<senitemp>: // IEEE: part of event_expression
yPOSEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::ET_POSEDGE,$2); }
| yNEGEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::ET_NEGEDGE,$2); }
| yEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::ET_BOTHEDGE,$2); }
| yPOSEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::ET_POSEDGE,$3); }
| yNEGEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::ET_NEGEDGE,$3); }
| yEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::ET_BOTHEDGE,$3); }
//UNSUP yIFF...
;
//************************************************
// Statements
stmtBlock<nodep>: // IEEE: statement + seq_block + par_block
stmt { $$ = $1; }
;
seq_block<nodep>: // ==IEEE: seq_block
// // IEEE doesn't allow declarations in unnamed blocks, but several simulators do.
// // So need AstBegin's even if unnamed to scope variables down
seq_blockFront blockDeclStmtList yEND endLabelE { $$=$1; $1->addStmtsp($2); SYMP->popScope($1); GRAMMARP->endLabel($<fl>4,$1,$4); }
| seq_blockFront /**/ yEND endLabelE { $$=$1; SYMP->popScope($1); GRAMMARP->endLabel($<fl>3,$1,$3); }
;
par_block<nodep>: // ==IEEE: par_block
par_blockFront blockDeclStmtList yJOIN endLabelE { $$=$1; $1->addStmtsp($2); SYMP->popScope($1); GRAMMARP->endLabel($<fl>4,$1,$4); }
| par_blockFront /**/ yJOIN endLabelE { $$=$1; SYMP->popScope($1); GRAMMARP->endLabel($<fl>3,$1,$3); }
;
seq_blockFront<beginp>: // IEEE: part of seq_block
yBEGIN { $$ = new AstBegin($1,"",NULL); SYMP->pushNew($$); }
| yBEGIN ':' idAny/*new-block_identifier*/ { $$ = new AstBegin($1,*$3,NULL); SYMP->pushNew($$); }
;
par_blockFront<beginp>: // IEEE: part of par_block
yFORK { $$ = new AstBegin($1, "", NULL); SYMP->pushNew($$);
BBUNSUP($1, "Unsupported: fork statements"); }
| yFORK ':' idAny/*new-block_identifier*/ { $$ = new AstBegin($1,*$3,NULL); SYMP->pushNew($$);
BBUNSUP($1, "Unsupported: fork statements"); }
;
blockDeclStmtList<nodep>: // IEEE: { block_item_declaration } { statement or null }
// // The spec seems to suggest a empty declaration isn't ok, but most simulators take it
block_item_declarationList { $$ = $1; }
| block_item_declarationList stmtList { $$ = $1->addNextNull($2); }
| stmtList { $$ = $1; }
;
block_item_declarationList<nodep>: // IEEE: [ block_item_declaration ]
block_item_declaration { $$ = $1; }
| block_item_declarationList block_item_declaration { $$ = $1->addNextNull($2); }
;
block_item_declaration<nodep>: // ==IEEE: block_item_declaration
data_declaration { $$ = $1; }
| local_parameter_declaration ';' { $$ = $1; }
| parameter_declaration ';' { $$ = $1; }
//UNSUP let_declaration { $$ = $1; }
;
stmtList<nodep>:
stmtBlock { $$ = $1; }
| stmtList stmtBlock { $$ = ($2==NULL)?($1):($1->addNext($2)); }
;
stmt<nodep>: // IEEE: statement_or_null == function_statement_or_null
statement_item { $$ = $1; }
// // S05 block creation rule
| id/*block_identifier*/ ':' statement_item { $$ = new AstBegin($2, *$1, $3); }
// // from _or_null
| ';' { $$ = NULL; }
;
statement_item<nodep>: // IEEE: statement_item
// // IEEE: operator_assignment
foperator_assignment ';' { $$ = $1; }
//
// // IEEE: blocking_assignment
// // 1800-2009 restricts LHS of assignment to new to not have a range
// // This is ignored to avoid conflicts
//UNSUP fexprLvalue '=' class_new ';' { UNSUP }
//UNSUP fexprLvalue '=' dynamic_array_new ';' { UNSUP }
//
// // IEEE: nonblocking_assignment
| fexprLvalue yP_LTE delayE expr ';' { $$ = new AstAssignDly($2,$1,$4); }
//UNSUP fexprLvalue yP_LTE delay_or_event_controlE expr ';' { UNSUP }
//
// // IEEE: procedural_continuous_assignment
| yASSIGN idClassSel '=' delayE expr ';' { $$ = new AstAssign($1,$2,$5); }
//UNSUP: delay_or_event_controlE above
| yDEASSIGN variable_lvalue ';' { $$ = NULL; BBUNSUP($1, "Unsupported: Verilog 1995 deassign"); }
| yFORCE expr '=' expr ';' { $$ = NULL; BBUNSUP($1, "Unsupported: Verilog 1995 force"); }
| yRELEASE variable_lvalue ';' { $$ = NULL; BBUNSUP($1, "Unsupported: Verilog 1995 release"); }
//
// // IEEE: case_statement
| unique_priorityE caseStart caseAttrE case_itemListE yENDCASE { $$ = $2; if ($4) $2->addItemsp($4);
if ($1 == uniq_UNIQUE) $2->uniquePragma(true);
if ($1 == uniq_UNIQUE0) $2->unique0Pragma(true);
if ($1 == uniq_PRIORITY) $2->priorityPragma(true); }
//UNSUP caseStart caseAttrE yMATCHES case_patternListE yENDCASE { }
| unique_priorityE caseStart caseAttrE yINSIDE case_insideListE yENDCASE { $$ = $2; if ($5) $2->addItemsp($5);
if (!$2->caseSimple()) $2->v3error("Illegal to have inside on a casex/casez");
$2->caseInsideSet();
if ($1 == uniq_UNIQUE) $2->uniquePragma(true);
if ($1 == uniq_UNIQUE0) $2->unique0Pragma(true);
if ($1 == uniq_PRIORITY) $2->priorityPragma(true); }
//
// // IEEE: conditional_statement
| unique_priorityE yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE
{ AstIf* newp = new AstIf($2,$4,$6,NULL);
$$ = newp;
if ($1 == uniq_UNIQUE) newp->uniquePragma(true);
if ($1 == uniq_UNIQUE0) newp->unique0Pragma(true);
if ($1 == uniq_PRIORITY) newp->priorityPragma(true); }
| unique_priorityE yIF '(' expr ')' stmtBlock yELSE stmtBlock
{ AstIf* newp = new AstIf($2,$4,$6,$8);
$$ = newp;
if ($1 == uniq_UNIQUE) newp->uniquePragma(true);
if ($1 == uniq_UNIQUE0) newp->unique0Pragma(true);
if ($1 == uniq_PRIORITY) newp->priorityPragma(true); }
//
| finc_or_dec_expression ';' { $$ = $1; }
// // IEEE: inc_or_dec_expression
// // Below under expr
//
// // IEEE: subroutine_call_statement
// // IEEE says we then expect a function call
// // (function_subroutine_callNoMethod), but rest of
// // the code expects an AstTask when used as a statement,
// // so parse as if task
// // Alternative would be shim with new AstVoidStmt.
| yVOID yP_TICK '(' task_subroutine_callNoMethod ')' ';'
{ $$ = $4;
FileLine* newfl = new FileLine($$->fileline());
newfl->warnOff(V3ErrorCode::IGNOREDRETURN, true);
$$->fileline(newfl); }
| yVOID yP_TICK '(' expr '.' task_subroutine_callNoMethod ')' ';'
{ $$ = new AstDot($5, $4, $6);
FileLine* newfl = new FileLine($6->fileline());
newfl->warnOff(V3ErrorCode::IGNOREDRETURN, true);
$6->fileline(newfl); }
// // Expr included here to resolve our not knowing what is a method call
// // Expr here must result in a subroutine_call
| task_subroutine_callNoMethod ';' { $$ = $1; }
//UNSUP fexpr '.' array_methodNoRoot ';' { UNSUP }
| fexpr '.' task_subroutine_callNoMethod ';' { $$ = new AstDot($<fl>2,$1,$3); }
//UNSUP fexprScope ';' { UNSUP }
// // Not here in IEEE; from class_constructor_declaration
// // Because we've joined class_constructor_declaration into generic functions
// // Way over-permissive;
// // IEEE: [ ySUPER '.' yNEW [ '(' list_of_arguments ')' ] ';' ]
//UNSUP fexpr '.' class_new ';' { }
//
| statementVerilatorPragmas { $$ = $1; }
//
// // IEEE: disable_statement
| yDISABLE idAny/*hierarchical_identifier-task_or_block*/ ';' { $$ = new AstDisable($1,*$2); }
| yDISABLE yFORK ';' { $$ = NULL; BBUNSUP($1, "Unsupported: disable fork statements"); }
// // IEEE: event_trigger
//UNSUP yP_MINUSGT hierarchical_identifier/*event*/ ';' { UNSUP }
//UNSUP yP_MINUSGTGT delay_or_event_controlE hierarchical_identifier/*event*/ ';' { UNSUP }
// // IEEE: loop_statement
| yFOREVER stmtBlock { $$ = new AstWhile($1,new AstConst($1,AstConst::LogicTrue()),$2); }
| yREPEAT '(' expr ')' stmtBlock { $$ = new AstRepeat($1,$3,$5);}
| yWHILE '(' expr ')' stmtBlock { $$ = new AstWhile($1,$3,$5);}
// // for's first ';' is in for_initalization
| statementFor { $$ = $1; }
| yDO stmtBlock yWHILE '(' expr ')' ';' { if ($2) {
$$ = $2->cloneTree(true);
$$->addNext(new AstWhile($1,$5,$2));
}
else $$ = new AstWhile($1,$5,NULL); }
// // IEEE says array_identifier here, but dotted accepted in VMM and 1800-2009
| yFOREACH '(' idClassForeach '[' loop_variables ']' ')' stmtBlock { $$ = new AstForeach($1,$3,$5,$8); }
//
// // IEEE: jump_statement
| yRETURN ';' { $$ = new AstReturn($1); }
| yRETURN expr ';' { $$ = new AstReturn($1,$2); }
| yBREAK ';' { $$ = new AstBreak($1); }
| yCONTINUE ';' { $$ = new AstContinue($1); }
//
| par_block { $$ = $1; }
// // IEEE: procedural_timing_control_statement + procedural_timing_control
| delay_control stmtBlock { $$ = $2; $1->v3warn(STMTDLY,"Unsupported: Ignoring delay on this delayed statement."); }
//UNSUP event_control stmtBlock { UNSUP }
//UNSUP cycle_delay stmtBlock { UNSUP }
//
| seq_block { $$ = $1; }
//
// // IEEE: wait_statement
| yWAIT '(' expr ')' stmtBlock { $$ = NULL; BBUNSUP($1, "Unsupported: wait statements"); }
| yWAIT yFORK ';' { $$ = NULL; BBUNSUP($1, "Unsupported: wait fork statements"); }
//UNSUP yWAIT_ORDER '(' hierarchical_identifierList ')' action_block { UNSUP }
//
// // IEEE: procedural_assertion_statement
| procedural_assertion_statement { $$ = $1; }
//
// // IEEE: clocking_drive ';'
// // Pattern w/o cycle_delay handled by nonblocking_assign above
// // clockvar_expression made to fexprLvalue to prevent reduce conflict
// // Note LTE in this context is highest precedence, so first on left wins
//UNSUP cycle_delay fexprLvalue yP_LTE ';' { UNSUP }
//UNSUP fexprLvalue yP_LTE cycle_delay expr ';' { UNSUP }
//
//UNSUP randsequence_statement { $$ = $1; }
//
// // IEEE: randcase_statement
| yRANDCASE case_itemList yENDCASE { $$ = NULL; BBUNSUP($1, "Unsupported: SystemVerilog 2005 randcase statements"); }
//
//UNSUP expect_property_statement { $$ = $1; }
//
| error ';' { $$ = NULL; }
;
statementFor<beginp>: // IEEE: part of statement
yFOR '(' for_initialization expr ';' for_stepE ')' stmtBlock
{ $$ = new AstBegin($1,"",$3);
$$->addStmtsp(new AstWhile($1, $4,$8,$6)); }
| yFOR '(' for_initialization ';' for_stepE ')' stmtBlock
{ $$ = new AstBegin($1,"",$3);
$$->addStmtsp(new AstWhile($1, new AstConst($1,AstConst::LogicTrue()),$7,$5)); }
;
statementVerilatorPragmas<nodep>:
yVL_COVERAGE_BLOCK_OFF { $$ = new AstPragma($1,AstPragmaType::COVERAGE_BLOCK_OFF); }
;
foperator_assignment<nodep>: // IEEE: operator_assignment (for first part of expression)
fexprLvalue '=' delayE expr { $$ = new AstAssign($2,$1,$4); }
| fexprLvalue '=' yD_FOPEN '(' expr ')' { $$ = NULL; $3->v3error("Unsupported: $fopen with multichannel descriptor. Add ,\"w\" as second argument to open a file descriptor."); }
| fexprLvalue '=' yD_FOPEN '(' expr ',' expr ')' { $$ = new AstFOpen($3,$1,$5,$7); }
//
//UNSUP ~f~exprLvalue '=' delay_or_event_controlE expr { UNSUP }
//UNSUP ~f~exprLvalue yP_PLUS(etc) expr { UNSUP }
| fexprLvalue yP_PLUSEQ expr { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_MINUSEQ expr { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_TIMESEQ expr { $$ = new AstAssign($2,$1,new AstMul ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_DIVEQ expr { $$ = new AstAssign($2,$1,new AstDiv ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_MODEQ expr { $$ = new AstAssign($2,$1,new AstModDiv ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_ANDEQ expr { $$ = new AstAssign($2,$1,new AstAnd ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_OREQ expr { $$ = new AstAssign($2,$1,new AstOr ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_XOREQ expr { $$ = new AstAssign($2,$1,new AstXor ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_SLEFTEQ expr { $$ = new AstAssign($2,$1,new AstShiftL ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_SRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftR ($2,$1->cloneTree(true),$3)); }
| fexprLvalue yP_SSRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftRS($2,$1->cloneTree(true),$3)); }
;
finc_or_dec_expression<nodep>: // ==IEEE: inc_or_dec_expression
//UNSUP: Generic scopes in incrementes
fexprLvalue yP_PLUSPLUS { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true),new AstConst($2, AstConst::StringToParse(), "'b1"))); }
| fexprLvalue yP_MINUSMINUS { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true),new AstConst($2, AstConst::StringToParse(), "'b1"))); }
| yP_PLUSPLUS fexprLvalue { $$ = new AstAssign($1,$2,new AstAdd ($1,$2->cloneTree(true),new AstConst($1, AstConst::StringToParse(), "'b1"))); }
| yP_MINUSMINUS fexprLvalue { $$ = new AstAssign($1,$2,new AstSub ($1,$2->cloneTree(true),new AstConst($1, AstConst::StringToParse(), "'b1"))); }
;
//************************************************
// Case/If
unique_priorityE<uniqstate>: // IEEE: unique_priority + empty
/*empty*/ { $$ = uniq_NONE; }
| yPRIORITY { $$ = uniq_PRIORITY; }
| yUNIQUE { $$ = uniq_UNIQUE; }
| yUNIQUE0 { $$ = uniq_UNIQUE0; }
;
caseStart<casep>: // IEEE: part of case_statement
yCASE '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,VCaseType::CT_CASE,$3,NULL); }
| yCASEX '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,VCaseType::CT_CASEX,$3,NULL); }
| yCASEZ '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,VCaseType::CT_CASEZ,$3,NULL); }
;
caseAttrE:
/*empty*/ { }
| caseAttrE yVL_FULL_CASE { GRAMMARP->m_caseAttrp->fullPragma(true); }
| caseAttrE yVL_PARALLEL_CASE { GRAMMARP->m_caseAttrp->parallelPragma(true); }
;
case_itemListE<caseitemp>: // IEEE: [ { case_item } ]
/* empty */ { $$ = NULL; }
| case_itemList { $$ = $1; }
;
case_insideListE<caseitemp>: // IEEE: [ { case_inside_item } ]
/* empty */ { $$ = NULL; }
| case_inside_itemList { $$ = $1; }
;
case_itemList<caseitemp>: // IEEE: { case_item + ... }
caseCondList ':' stmtBlock { $$ = new AstCaseItem($2,$1,$3); }
| yDEFAULT ':' stmtBlock { $$ = new AstCaseItem($2,NULL,$3); }
| yDEFAULT stmtBlock { $$ = new AstCaseItem($1,NULL,$2); }
| 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)); }
;
case_inside_itemList<caseitemp>: // IEEE: { case_inside_item + open_range_list ... }
open_range_list ':' stmtBlock { $$ = new AstCaseItem($2,$1,$3); }
| yDEFAULT ':' stmtBlock { $$ = new AstCaseItem($2,NULL,$3); }
| yDEFAULT stmtBlock { $$ = new AstCaseItem($1,NULL,$2); }
| case_inside_itemList open_range_list ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,$2,$4)); }
| case_inside_itemList yDEFAULT stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($2,NULL,$3)); }
| case_inside_itemList yDEFAULT ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,NULL,$4)); }
;
open_range_list<nodep>: // ==IEEE: open_range_list + open_value_range
open_value_range { $$ = $1; }
| open_range_list ',' open_value_range { $$ = $1;$1->addNext($3); }
;
open_value_range<nodep>: // ==IEEE: open_value_range
value_range { $$ = $1; }
;
value_range<nodep>: // ==IEEE: value_range
expr { $$ = $1; }
| '[' expr ':' expr ']' { $$ = new AstInsideRange($3,$2,$4); }
;
caseCondList<nodep>: // IEEE: part of case_item
expr { $$ = $1; }
| caseCondList ',' expr { $$ = $1;$1->addNext($3); }
;
patternNoExpr<nodep>: // IEEE: pattern **Excluding Expr*
'.' id/*variable*/ { $$ = NULL; $1->v3error("Unsupported: '{} tagged patterns"); }
| yP_DOTSTAR { $$ = NULL; $1->v3error("Unsupported: '{} tagged patterns"); }
// // IEEE: "expr" excluded; expand in callers
// // "yTAGGED id [expr]" Already part of expr
//UNSUP yTAGGED id/*member_identifier*/ patternNoExpr { $$ = NULL; $1->v3error("Unsupported: '{} tagged patterns"); }
// // "yP_TICKBRA patternList '}'" part of expr under assignment_pattern
;
patternList<nodep>: // IEEE: part of pattern
patternOne { $$ = $1; }
| patternList ',' patternOne { $$ = $1->addNextNull($3); }
;
patternOne<nodep>: // IEEE: part of pattern
expr { $$ = new AstPatMember($1->fileline(),$1,NULL,NULL); }
| expr '{' argsExprList '}' { $$ = new AstPatMember($2,$3,NULL,$1); }
| patternNoExpr { $$ = $1; }
;
patternMemberList<nodep>: // IEEE: part of pattern and assignment_pattern
patternMemberOne { $$ = $1; }
| patternMemberList ',' patternMemberOne { $$ = $1->addNextNull($3); }
;
patternMemberOne<patmemberp>: // IEEE: part of pattern and assignment_pattern
patternKey ':' expr { $$ = new AstPatMember($2,$3,$1,NULL); }
| patternKey ':' patternNoExpr { $$ = NULL; $2->v3error("Unsupported: '{} .* patterns"); }
// // From assignment_pattern_key
| yDEFAULT ':' expr { $$ = new AstPatMember($2,$3,NULL,NULL); $$->isDefault(true); }
| yDEFAULT ':' patternNoExpr { $$ = NULL; $2->v3error("Unsupported: '{} .* patterns"); }
;
patternKey<nodep>: // IEEE: merge structure_pattern_key, array_pattern_key, assignment_pattern_key
// // IEEE: structure_pattern_key
// // id/*member*/ is part of constExpr below
//UNSUP constExpr { $$ = $1; }
// // IEEE: assignment_pattern_key
//UNSUP simple_type { $1->v3error("Unsupported: '{} with data type as key"); $$=$1; }
// // simple_type reference looks like constExpr
// // Verilator:
// // The above expressions cause problems because "foo" may be a constant identifier
// // (if array) or a reference to the "foo"member (if structure)
// // So for now we only allow a true constant number, or a identifier which we treat as a structure member name
yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
| yaFLOATNUM { $$ = new AstConst($<fl>1,AstConst::RealDouble(),$1); }
| yaID__ETC { $$ = new AstText($<fl>1,*$1); }
;
assignment_pattern<patternp>: // ==IEEE: assignment_pattern
// This doesn't match the text of the spec. I think a : is missing, or example code needed
// yP_TICKBRA constExpr exprList '}' { $$="'{"+$2+" "+$3"}"; }
// // "'{ const_expression }" is same as patternList with one entry
// // From patternNoExpr
// // also IEEE: "''{' expression { ',' expression } '}'"
// // matches since patternList includes expr
yP_TICKBRA patternList '}' { $$ = new AstPattern($1,$2); }
// // From patternNoExpr
// // also IEEE "''{' structure_pattern_key ':' ...
// // also IEEE "''{' array_pattern_key ':' ...
| yP_TICKBRA patternMemberList '}' { $$ = new AstPattern($1,$2); }
// // IEEE: Not in grammar, but in VMM
| yP_TICKBRA '}' { $$ = NULL; $1->v3error("Unsupported: Empty '{}"); }
;
// "datatype id = x {, id = x }" | "yaId = x {, id=x}" is legal
for_initialization<nodep>: // ==IEEE: for_initialization + for_variable_declaration + extra terminating ";"
// // IEEE: for_variable_declaration
for_initializationItemList ';' { $$ = $1; }
// // IEEE: 1800-2017 empty initialization
| ';' { $$ = NULL; }
;
for_initializationItemList<nodep>: // IEEE: [for_variable_declaration...]
for_initializationItem { $$ = $1; }
| for_initializationItemList ',' for_initializationItem { $$ = $1; $<fl>2->v3error("Unsupported: for loop initialization after the first comma"); }
;
for_initializationItem<nodep>: // IEEE: variable_assignment + for_variable_declaration
// // IEEE: for_variable_declaration
data_type idAny/*new*/ '=' expr
{ VARRESET_NONLIST(VAR); VARDTYPE($1);
$$ = VARDONEA($<fl>2,*$2,NULL,NULL);
$$->addNext(new AstAssign($3, new AstVarRef($3,*$2,true), $4));}
// // IEEE-2012:
| yVAR data_type idAny/*new*/ '=' expr
{ VARRESET_NONLIST(VAR); VARDTYPE($2);
$$ = VARDONEA($<fl>3,*$3,NULL,NULL);
$$->addNext(new AstAssign($4, new AstVarRef($4,*$3,true), $5));}
// // IEEE: variable_assignment
| varRefBase '=' expr { $$ = new AstAssign($2, $1, $3); }
;
for_stepE<nodep>: // IEEE: for_step + empty
/* empty */ { $$ = NULL; }
| for_step { $$ = $1; }
;
for_step<nodep>: // IEEE: for_step
genvar_iteration { $$ = $1; }
| for_step ',' genvar_iteration { $$ = $1; $<fl>1->v3error("Unsupported: for loop step after the first comma"); }
;
loop_variables<nodep>: // IEEE: loop_variables
varRefBase { $$ = $1; }
| loop_variables ',' varRefBase { $$ = $1;$1->addNext($3); }
;
//************************************************
// Functions/tasks
taskRef<nodep>: // IEEE: part of tf_call
id { $$ = new AstTaskRef($<fl>1,*$1,NULL); }
| id '(' list_of_argumentsE ')' { $$ = new AstTaskRef($<fl>1,*$1,$3); }
| package_scopeIdFollows id '(' list_of_argumentsE ')' { $$ = AstDot::newIfPkg($<fl>2, $1, new AstTaskRef($<fl>2,*$2,$4)); }
;
funcRef<nodep>: // IEEE: part of tf_call
// // package_scope/hierarchical_... is part of expr, so just need ID
// // making-a id-is-a
// // ----------------- ------------------
// // tf_call tf_identifier expr (list_of_arguments)
// // method_call(post .) function_identifier expr (list_of_arguments)
// // property_instance property_identifier property_actual_arg
// // sequence_instance sequence_identifier sequence_actual_arg
// // let_expression let_identifier let_actual_arg
//
id '(' list_of_argumentsE ')' { $$ = new AstFuncRef($2, *$1, $3); }
| package_scopeIdFollows id '(' list_of_argumentsE ')' { $$ = AstDot::newIfPkg($<fl>2, $1, new AstFuncRef($<fl>2,*$2,$4)); }
//UNSUP: idDotted is really just id to allow dotted method calls
;
task_subroutine_callNoMethod<nodep>: // function_subroutine_callNoMethod (as task)
// // IEEE: tf_call
taskRef { $$ = $1; }
| system_t_call { $$ = $1; }
// // IEEE: method_call requires a "." so is in expr
//UNSUP randomize_call { $$ = $1; }
;
function_subroutine_callNoMethod<nodep>: // IEEE: function_subroutine_call (as function)
// // IEEE: tf_call
funcRef { $$ = $1; }
| system_f_call { $$ = $1; }
// // IEEE: method_call requires a "." so is in expr
//UNSUP randomize_call { $$ = $1; }
;
system_t_call<nodep>: // IEEE: system_tf_call (as task)
//
yaD_IGNORE parenE { $$ = new AstSysIgnore($<fl>1,NULL); }
| yaD_IGNORE '(' exprList ')' { $$ = new AstSysIgnore($<fl>1,$3); }
//
| yaD_DPI parenE { $$ = new AstTaskRef($<fl>1,*$1,NULL); }
| yaD_DPI '(' exprList ')' { $$ = new AstTaskRef($2,*$1,$3); GRAMMARP->argWrapList(VN_CAST($$, TaskRef)); }
//
| yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCStmt($1,$3)); }
| yD_SYSTEM '(' expr ')' { $$ = new AstSystemT($1,$3); }
//
| yD_FCLOSE '(' idClassSel ')' { $$ = new AstFClose($1, $3); }
| yD_FFLUSH parenE { $$ = NULL; BBUNSUP($1, "Unsupported: $fflush of all handles does not map to C++."); }
| yD_FFLUSH '(' expr ')' { $$ = new AstFFlush($1, $3); }
| yD_FINISH parenE { $$ = new AstFinish($1); }
| yD_FINISH '(' expr ')' { $$ = new AstFinish($1); DEL($3); }
| yD_STOP parenE { $$ = new AstStop($1); }
| yD_STOP '(' expr ')' { $$ = new AstStop($1); DEL($3); }
//
| yD_SFORMAT '(' expr ',' str commaEListE ')' { $$ = new AstSFormat($1,$3,*$5,$6); }
| yD_SWRITE '(' expr ',' str commaEListE ')' { $$ = new AstSFormat($1,$3,*$5,$6); }
//
| yD_DISPLAY parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,NULL,NULL); }
| yD_DISPLAY '(' exprList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,NULL,$3); }
| yD_WRITE parenE { $$ = NULL; } // NOP
| yD_WRITE '(' exprList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, NULL,$3); }
| yD_FDISPLAY '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,$3,NULL); }
| yD_FDISPLAY '(' expr ',' exprListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,$3,$5); }
| yD_FWRITE '(' expr ',' exprListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, $3,$5); }
| yD_INFO parenE { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, "", NULL,NULL); }
| yD_INFO '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, *$3,NULL,$4); }
| yD_WARNING parenE { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING,"", NULL,NULL); }
| yD_WARNING '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING,*$3,NULL,$4); }
| yD_ERROR parenE { $$ = GRAMMARP->createDisplayError($1); }
| yD_ERROR '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_ERROR, *$3,NULL,$4); $$->addNext(new AstStop($1)); }
| yD_FATAL parenE { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); }
| yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); DEL($3); }
| yD_FATAL '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, *$5,NULL,$6); $$->addNext(new AstStop($1)); DEL($3); }
//
| yD_READMEMB '(' expr ',' idClassSel ')' { $$ = new AstReadMem($1,false,$3,$5,NULL,NULL); }
| yD_READMEMB '(' expr ',' idClassSel ',' expr ')' { $$ = new AstReadMem($1,false,$3,$5,$7,NULL); }
| yD_READMEMB '(' expr ',' idClassSel ',' expr ',' expr ')' { $$ = new AstReadMem($1,false,$3,$5,$7,$9); }
| yD_READMEMH '(' expr ',' idClassSel ')' { $$ = new AstReadMem($1,true, $3,$5,NULL,NULL); }
| yD_READMEMH '(' expr ',' idClassSel ',' expr ')' { $$ = new AstReadMem($1,true, $3,$5,$7,NULL); }
| yD_READMEMH '(' expr ',' idClassSel ',' expr ',' expr ')' { $$ = new AstReadMem($1,true, $3,$5,$7,$9); }
//
| yD_WRITEMEMH '(' expr ',' idClassSel ')' { $$ = new AstWriteMem($1,$3,$5,NULL,NULL); }
| yD_WRITEMEMH '(' expr ',' idClassSel ',' expr ')' { $$ = new AstWriteMem($1,$3,$5,$7,NULL); }
| yD_WRITEMEMH '(' expr ',' idClassSel ',' expr ',' expr ')' { $$ = new AstWriteMem($1,$3,$5,$7,$9); }
//
// Any system function as a task
| system_f_call_or_t { $$ = new AstSysFuncAsTask($<fl>1, $1); }
;
system_f_call<nodep>: // IEEE: system_tf_call (as func)
yaD_IGNORE parenE { $$ = new AstConst($<fl>1, AstConst::StringToParse(), "'b0"); } // Unsized 0
| yaD_IGNORE '(' exprList ')' { $$ = new AstConst($2, AstConst::StringToParse(), "'b0"); } // Unsized 0
//
| yaD_DPI parenE { $$ = new AstFuncRef($<fl>1,*$1,NULL); }
| yaD_DPI '(' exprList ')' { $$ = new AstFuncRef($2,*$1,$3); GRAMMARP->argWrapList(VN_CAST($$, FuncRef)); }
//
| yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCFunc($1,$3)); }
| yD_SYSTEM '(' expr ')' { $$ = new AstSystemF($1,$3); }
//
| system_f_call_or_t { $$ = $1; }
;
system_f_call_or_t<nodep>: // IEEE: part of system_tf_call (can be task or func)
yD_ACOS '(' expr ')' { $$ = new AstAcosD($1,$3); }
| yD_ACOSH '(' expr ')' { $$ = new AstAcoshD($1,$3); }
| yD_ASIN '(' expr ')' { $$ = new AstAsinD($1,$3); }
| yD_ASINH '(' expr ')' { $$ = new AstAsinhD($1,$3); }
| yD_ATAN '(' expr ')' { $$ = new AstAtanD($1,$3); }
| yD_ATAN2 '(' expr ',' expr ')' { $$ = new AstAtan2D($1,$3,$5); }
| yD_ATANH '(' expr ')' { $$ = new AstAtanhD($1,$3); }
| yD_BITS '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_BITS,$3); }
| yD_BITS '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_BITS,$3,$5); }
| yD_BITSTOREAL '(' expr ')' { $$ = new AstBitsToRealD($1,$3); }
| yD_CEIL '(' expr ')' { $$ = new AstCeilD($1,$3); }
| yD_CLOG2 '(' expr ')' { $$ = new AstCLog2($1,$3); }
| yD_COS '(' expr ')' { $$ = new AstCosD($1,$3); }
| yD_COSH '(' expr ')' { $$ = new AstCoshD($1,$3); }
| yD_COUNTONES '(' expr ')' { $$ = new AstCountOnes($1,$3); }
| yD_DIMENSIONS '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_DIMENSIONS,$3); }
| yD_EXP '(' expr ')' { $$ = new AstExpD($1,$3); }
| yD_FEOF '(' expr ')' { $$ = new AstFEof($1,$3); }
| yD_FGETC '(' expr ')' { $$ = new AstFGetC($1,$3); }
| yD_FGETS '(' idClassSel ',' expr ')' { $$ = new AstFGetS($1,$3,$5); }
| yD_FREAD '(' idClassSel ',' expr ')' { $$ = new AstFRead($1,$3,$5,NULL,NULL); }
| yD_FREAD '(' idClassSel ',' expr ',' expr ')' { $$ = new AstFRead($1,$3,$5,$7,NULL); }
| yD_FREAD '(' idClassSel ',' expr ',' expr ',' expr ')' { $$ = new AstFRead($1,$3,$5,$7,$9); }
| yD_FLOOR '(' expr ')' { $$ = new AstFloorD($1,$3); }
| yD_FSCANF '(' expr ',' str commaVRDListE ')' { $$ = new AstFScanF($1,*$5,$3,$6); }
| yD_HIGH '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_HIGH,$3,NULL); }
| yD_HIGH '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_HIGH,$3,$5); }
| yD_HYPOT '(' expr ',' expr ')' { $$ = new AstHypotD($1,$3,$5); }
| yD_INCREMENT '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_INCREMENT,$3,NULL); }
| yD_INCREMENT '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_INCREMENT,$3,$5); }
| yD_ISUNKNOWN '(' expr ')' { $$ = new AstIsUnknown($1,$3); }
| yD_ITOR '(' expr ')' { $$ = new AstIToRD($1,$3); }
| yD_LEFT '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LEFT,$3,NULL); }
| yD_LEFT '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LEFT,$3,$5); }
| yD_LN '(' expr ')' { $$ = new AstLogD($1,$3); }
| yD_LOG10 '(' expr ')' { $$ = new AstLog10D($1,$3); }
| yD_LOW '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LOW,$3,NULL); }
| yD_LOW '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LOW,$3,$5); }
| yD_ONEHOT '(' expr ')' { $$ = new AstOneHot($1,$3); }
| yD_ONEHOT0 '(' expr ')' { $$ = new AstOneHot0($1,$3); }
| yD_PAST '(' expr ')' { $$ = new AstPast($1,$3, NULL); }
| yD_PAST '(' expr ',' expr ')' { $$ = new AstPast($1,$3, $5); }
| yD_PAST '(' expr ',' expr ',' expr ')' { $1->v3error("Unsupported: $past expr2 and clock arguments"); $$ = $3; }
| yD_PAST '(' expr ',' expr ',' expr ',' expr')' { $1->v3error("Unsupported: $past expr2 and clock arguments"); $$ = $3; }
| yD_POW '(' expr ',' expr ')' { $$ = new AstPowD($1,$3,$5); }
| yD_RANDOM '(' expr ')' { $$ = NULL; $1->v3error("Unsupported: Seeding $random doesn't map to C++, use $c(\"srand\")"); }
| yD_RANDOM parenE { $$ = new AstRand($1); }
| yD_REALTIME parenE { $$ = new AstTimeD($1); }
| yD_REALTOBITS '(' expr ')' { $$ = new AstRealToBits($1,$3); }
| yD_RIGHT '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_RIGHT,$3,NULL); }
| yD_RIGHT '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_RIGHT,$3,$5); }
| yD_RTOI '(' expr ')' { $$ = new AstRToIS($1,$3); }
| yD_SFORMATF '(' str commaEListE ')' { $$ = new AstSFormatF($1,*$3,false,$4); }
| yD_SIGNED '(' expr ')' { $$ = new AstSigned($1,$3); }
| yD_SIN '(' expr ')' { $$ = new AstSinD($1,$3); }
| yD_SINH '(' expr ')' { $$ = new AstSinhD($1,$3); }
| yD_SIZE '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_SIZE,$3,NULL); }
| yD_SIZE '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_SIZE,$3,$5); }
| yD_SQRT '(' expr ')' { $$ = new AstSqrtD($1,$3); }
| yD_SSCANF '(' expr ',' str commaVRDListE ')' { $$ = new AstSScanF($1,*$5,$3,$6); }
| yD_STIME parenE { $$ = new AstSel($1,new AstTime($1),0,32); }
| yD_TAN '(' expr ')' { $$ = new AstTanD($1,$3); }
| yD_TANH '(' expr ')' { $$ = new AstTanhD($1,$3); }
| yD_TESTPLUSARGS '(' str ')' { $$ = new AstTestPlusArgs($1,*$3); }
| yD_TIME parenE { $$ = new AstTime($1); }
| yD_UNPACKED_DIMENSIONS '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_UNPK_DIMENSIONS,$3); }
| yD_UNSIGNED '(' expr ')' { $$ = new AstUnsigned($1,$3); }
| yD_VALUEPLUSARGS '(' expr ',' expr ')' { $$ = new AstValuePlusArgs($1,$3,$5); }
;
elaboration_system_task<nodep>: // IEEE: elaboration_system_task (1800-2009)
// // TODO: These currently just make initial statements, should instead give runtime error
elaboration_system_task_guts ';' { $$ = new AstInitial($<fl>1, $1); }
;
elaboration_system_task_guts<nodep>: // IEEE: part of elaboration_system_task (1800-2009)
// // $fatal first argument is exit number, must be constant
yD_INFO parenE { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, "", NULL,NULL); }
| yD_INFO '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, *$3,NULL,$4); }
| yD_WARNING parenE { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING,"", NULL,NULL); }
| yD_WARNING '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING,*$3,NULL,$4); }
| yD_ERROR parenE { $$ = GRAMMARP->createDisplayError($1); }
| yD_ERROR '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_ERROR, *$3,NULL,$4); $$->addNext(new AstStop($1)); }
| yD_FATAL parenE { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); }
| yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); DEL($3); }
| yD_FATAL '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, *$5,NULL,$6); $$->addNext(new AstStop($1)); DEL($3); }
;
exprOrDataType<nodep>: // expr | data_type: combined to prevent conflicts
expr { $$ = $1; }
// // data_type includes id that overlaps expr, so special flavor
| data_type { $$ = $1; }
// // not in spec, but needed for $past(sig,1,,@(posedge clk))
//UNSUP event_control { }
;
list_of_argumentsE<nodep>: // IEEE: [list_of_arguments]
argsDottedList { $$ = $1; }
| argsExprListE { if (VN_IS($1, Arg) && VN_CAST($1, Arg)->emptyConnectNoNext()) { $1->deleteTree(); $$ = NULL; } // Mis-created when have 'func()'
/*cont*/ else $$ = $1; }
| argsExprListE ',' argsDottedList { $$ = $1->addNextNull($3); }
;
task_declaration<ftaskp>: // ==IEEE: task_declaration
yTASK lifetimeE taskId tfGuts yENDTASK endLabelE
{ $$ = $3; $$->addStmtsp($4); SYMP->popScope($$);
GRAMMARP->endLabel($<fl>6,$$,$6); }
;
task_prototype<ftaskp>: // ==IEEE: task_prototype
yTASK taskId '(' tf_port_listE ')' { $$=$2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); }
| yTASK taskId { $$=$2; $$->prototype(true); SYMP->popScope($$); }
;
function_declaration<ftaskp>: // IEEE: function_declaration + function_body_declaration
yFUNCTION lifetimeE funcId funcIsolateE tfGuts yENDFUNCTION endLabelE
{ $$ = $3; $3->attrIsolateAssign($4); $$->addStmtsp($5);
SYMP->popScope($$);
GRAMMARP->endLabel($<fl>7,$$,$7); }
;
function_prototype<ftaskp>: // IEEE: function_prototype
yFUNCTION funcId '(' tf_port_listE ')' { $$=$2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); }
| yFUNCTION funcId { $$=$2; $$->prototype(true); SYMP->popScope($$); }
;
funcIsolateE<cint>:
/* empty */ { $$ = 0; }
| yVL_ISOLATE_ASSIGNMENTS { $$ = 1; }
;
method_prototype:
task_prototype { }
| function_prototype { }
;
lifetimeE: // IEEE: [lifetime]
/* empty */ { }
| lifetime { }
;
lifetime: // ==IEEE: lifetime
// // Note lifetime used by members is instead under memberQual
ySTATIC { $1->v3error("Unsupported: Static in this context"); }
| yAUTOMATIC { }
;
taskId<ftaskp>:
tfIdScoped
{ $$ = new AstTask($<fl>1, *$<strp>1, NULL);
SYMP->pushNewUnder($$, NULL); }
;
funcId<ftaskp>: // IEEE: function_data_type_or_implicit + part of function_body_declaration
// // IEEE: function_data_type_or_implicit must be expanded here to prevent conflict
// // function_data_type expanded here to prevent conflicts with implicit_type:empty vs data_type:ID
/**/ tfIdScoped
{ $$ = new AstFunc($<fl>1,*$<strp>1,NULL,
new AstBasicDType($<fl>1, LOGIC_IMPLICIT));
SYMP->pushNewUnder($$, NULL); }
| signingE rangeList tfIdScoped
{ $$ = new AstFunc($<fl>3,*$<strp>3,NULL,
GRAMMARP->addRange(new AstBasicDType($<fl>3, LOGIC_IMPLICIT, $1), $2,true));
SYMP->pushNewUnder($$, NULL); }
| signing tfIdScoped
{ $$ = new AstFunc($<fl>2,*$<strp>2,NULL,
new AstBasicDType($<fl>2, LOGIC_IMPLICIT, $1));
SYMP->pushNewUnder($$, NULL); }
| data_type tfIdScoped
{ $$ = new AstFunc($<fl>2,*$<strp>2,NULL,$1);
SYMP->pushNewUnder($$, NULL); }
// // To verilator tasks are the same as void functions (we separately detect time passing)
| yVOID tfIdScoped
{ $$ = new AstTask($<fl>2,*$<strp>2,NULL);
SYMP->pushNewUnder($$, NULL); }
;
tfIdScoped<strp>: // IEEE: part of function_body_declaration/task_body_declaration
// // IEEE: [ interface_identifier '.' | class_scope ] function_identifier
id { $<fl>$=$<fl>1; $<strp>$ = $1; }
//UNSUP id/*interface_identifier*/ '.' id { UNSUP }
//UNSUP class_scope_id { UNSUP }
;
tfGuts<nodep>:
'(' tf_port_listE ')' ';' tfBodyE { $$ = $2->addNextNull($5); }
| ';' tfBodyE { $$ = $2; }
;
tfBodyE<nodep>: // IEEE: part of function_body_declaration/task_body_declaration
/* empty */ { $$ = NULL; }
| tf_item_declarationList { $$ = $1; }
| tf_item_declarationList stmtList { $$ = $1->addNextNull($2); }
| stmtList { $$ = $1; }
;
tf_item_declarationList<nodep>:
tf_item_declaration { $$ = $1; }
| tf_item_declarationList tf_item_declaration { $$ = $1->addNextNull($2); }
;
tf_item_declaration<nodep>: // ==IEEE: tf_item_declaration
block_item_declaration { $$ = $1; }
| tf_port_declaration { $$ = $1; }
| tf_item_declarationVerilator { $$ = $1; }
;
tf_item_declarationVerilator<nodep>: // Verilator extensions
yVL_PUBLIC { $$ = new AstPragma($1,AstPragmaType::PUBLIC_TASK); v3Global.dpi(true); }
| yVL_NO_INLINE_TASK { $$ = new AstPragma($1,AstPragmaType::NO_INLINE_TASK); }
;
tf_port_listE<nodep>: // IEEE: tf_port_list + empty
// // Empty covered by tf_port_item
{VARRESET_LIST(UNKNOWN); VARIO(INPUT); }
tf_port_listList { $$ = $2; VARRESET_NONLIST(UNKNOWN); }
;
tf_port_listList<nodep>: // IEEE: part of tf_port_list
tf_port_item { $$ = $1; }
| tf_port_listList ',' tf_port_item { $$ = $1->addNextNull($3); }
;
tf_port_item<nodep>: // ==IEEE: tf_port_item
// // We split tf_port_item into the type and assignment as don't know what follows a comma
/* empty */ { $$ = NULL; PINNUMINC(); } // For example a ",," port
| tf_port_itemFront tf_port_itemAssignment { $$ = $2; }
| tf_port_itemAssignment { $$ = $1; }
;
tf_port_itemFront: // IEEE: part of tf_port_item, which has the data type
data_type { VARDTYPE($1); }
| signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1), $2, true)); }
| signing { VARDTYPE(new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $1)); }
| yVAR data_type { VARDTYPE($2); }
| yVAR implicit_typeE { VARDTYPE($2); }
//
| tf_port_itemDir /*implicit*/ { VARDTYPE(NULL); /*default_nettype-see spec*/ }
| tf_port_itemDir data_type { VARDTYPE($2); }
| tf_port_itemDir signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2),$3,true)); }
| tf_port_itemDir signing { VARDTYPE(new AstBasicDType($<fl>2, LOGIC_IMPLICIT, $2)); }
| tf_port_itemDir yVAR data_type { VARDTYPE($3); }
| tf_port_itemDir yVAR implicit_typeE { VARDTYPE($3); }
;
tf_port_itemDir: // IEEE: part of tf_port_item, direction
port_direction { } // port_direction sets VARIO
;
tf_port_itemAssignment<varp>: // IEEE: part of tf_port_item, which has assignment
id variable_dimensionListE sigAttrListE
{ $$ = VARDONEA($<fl>1, *$1, $2, $3); }
| id variable_dimensionListE sigAttrListE '=' expr
{ $$ = VARDONEA($<fl>1, *$1, $2, $3); $$->valuep($5); }
;
parenE:
/* empty */ { }
| '(' ')' { }
;
// method_call: // ==IEEE: method_call + method_call_body
// // IEEE: method_call_root '.' method_identifier [ '(' list_of_arguments ')' ]
// // "method_call_root '.' method_identifier" looks just like "expr '.' id"
// // "method_call_root '.' method_identifier (...)" looks just like "expr '.' tf_call"
// // IEEE: built_in_method_call
// // method_call_root not needed, part of expr resolution
// // What's left is below array_methodNoRoot
array_methodNoRoot<nodep>:
yOR { $$ = new AstFuncRef($1, "or", NULL); }
| yAND { $$ = new AstFuncRef($1, "and", NULL); }
| yXOR { $$ = new AstFuncRef($1, "xor", NULL); }
;
dpi_import_export<nodep>: // ==IEEE: dpi_import_export
yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE function_prototype ';'
{ $$ = $5; if (*$4!="") $5->cname(*$4); $5->dpiContext($3==iprop_CONTEXT); $5->pure($3==iprop_PURE);
$5->dpiImport(true); GRAMMARP->checkDpiVer($1,*$2); v3Global.dpi(true);
if ($$->prettyName()[0]=='$') SYMP->reinsert($$,NULL,$$->prettyName()); // For $SysTF overriding
SYMP->reinsert($$); }
| yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE task_prototype ';'
{ $$ = $5; if (*$4!="") $5->cname(*$4); $5->dpiContext($3==iprop_CONTEXT); $5->pure($3==iprop_PURE);
$5->dpiImport(true); $5->dpiTask(true); GRAMMARP->checkDpiVer($1,*$2); v3Global.dpi(true);
if ($$->prettyName()[0]=='$') SYMP->reinsert($$,NULL,$$->prettyName()); // For $SysTF overriding
SYMP->reinsert($$); }
| yEXPORT yaSTRING dpi_importLabelE yFUNCTION idAny ';' { $$ = new AstDpiExport($1,*$5,*$3);
GRAMMARP->checkDpiVer($1,*$2); v3Global.dpi(true); }
| yEXPORT yaSTRING dpi_importLabelE yTASK idAny ';' { $$ = new AstDpiExport($1,*$5,*$3);
GRAMMARP->checkDpiVer($1,*$2); v3Global.dpi(true); }
;
dpi_importLabelE<strp>: // IEEE: part of dpi_import_export
/* empty */ { static string s; $$ = &s; }
| idAny/*c_identifier*/ '=' { $$ = $1; $<fl>$=$<fl>1; }
;
dpi_tf_import_propertyE<iprop>: // IEEE: [ dpi_function_import_property + dpi_task_import_property ]
/* empty */ { $$ = iprop_NONE; }
| yCONTEXT { $$ = iprop_CONTEXT; }
| yPURE { $$ = iprop_PURE; }
;
//************************************************
// Expressions
//
// ~l~ means this is the (l)eft hand side of any operator
// it will get replaced by "", "f" or "s"equence
// ~r~ means this is a (r)ight hand later expansion in the same statement,
// not under parenthesis for <= disambiguation
// it will get replaced by "", or "f"
// ~p~ means this is a (p)arenthetized expression
// it will get replaced by "", or "s"equence
constExpr<nodep>:
expr { $$ = $1; }
;
expr<nodep>: // IEEE: part of expression/constant_expression/primary
// *SEE BELOW* // IEEE: primary/constant_primary
//
// // IEEE: unary_operator primary
'+' ~r~expr %prec prUNARYARITH { $$ = $2; }
| '-' ~r~expr %prec prUNARYARITH { $$ = new AstNegate ($1,$2); }
| '!' ~r~expr %prec prNEGATION { $$ = new AstLogNot ($1,$2); }
| '&' ~r~expr %prec prREDUCTION { $$ = new AstRedAnd ($1,$2); }
| '~' ~r~expr %prec prNEGATION { $$ = new AstNot ($1,$2); }
| '|' ~r~expr %prec prREDUCTION { $$ = new AstRedOr ($1,$2); }
| '^' ~r~expr %prec prREDUCTION { $$ = new AstRedXor ($1,$2); }
| yP_NAND ~r~expr %prec prREDUCTION { $$ = new AstLogNot($1, new AstRedAnd($1, $2)); }
| yP_NOR ~r~expr %prec prREDUCTION { $$ = new AstLogNot($1, new AstRedOr($1, $2)); }
| yP_XNOR ~r~expr %prec prREDUCTION { $$ = new AstRedXnor ($1,$2); }
//
// // IEEE: inc_or_dec_expression
//UNSUP ~l~inc_or_dec_expression { UNSUP }
//
// // IEEE: '(' operator_assignment ')'
// // Need exprScope of variable_lvalue to prevent conflict
//UNSUP '(' ~p~exprScope '=' expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_PLUSEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_MINUSEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_TIMESEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_DIVEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_MODEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_ANDEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_OREQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_XOREQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_SLEFTEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_SRIGHTEQ expr ')' { UNSUP }
//UNSUP '(' ~p~exprScope yP_SSRIGHTEQ expr ')' { UNSUP }
//
// // IEEE: expression binary_operator expression
| ~l~expr '+' ~r~expr { $$ = new AstAdd ($2,$1,$3); }
| ~l~expr '-' ~r~expr { $$ = new AstSub ($2,$1,$3); }
| ~l~expr '*' ~r~expr { $$ = new AstMul ($2,$1,$3); }
| ~l~expr '/' ~r~expr { $$ = new AstDiv ($2,$1,$3); }
| ~l~expr '%' ~r~expr { $$ = new AstModDiv ($2,$1,$3); }
| ~l~expr yP_EQUAL ~r~expr { $$ = new AstEq ($2,$1,$3); }
| ~l~expr yP_NOTEQUAL ~r~expr { $$ = new AstNeq ($2,$1,$3); }
| ~l~expr yP_CASEEQUAL ~r~expr { $$ = new AstEqCase ($2,$1,$3); }
| ~l~expr yP_CASENOTEQUAL ~r~expr { $$ = new AstNeqCase ($2,$1,$3); }
| ~l~expr yP_WILDEQUAL ~r~expr { $$ = new AstEqWild ($2,$1,$3); }
| ~l~expr yP_WILDNOTEQUAL ~r~expr { $$ = new AstNeqWild ($2,$1,$3); }
| ~l~expr yP_ANDAND ~r~expr { $$ = new AstLogAnd ($2,$1,$3); }
| ~l~expr yP_OROR ~r~expr { $$ = new AstLogOr ($2,$1,$3); }
| ~l~expr yP_POW ~r~expr { $$ = new AstPow ($2,$1,$3); }
| ~l~expr '<' ~r~expr { $$ = new AstLt ($2,$1,$3); }
| ~l~expr '>' ~r~expr { $$ = new AstGt ($2,$1,$3); }
| ~l~expr yP_GTE ~r~expr { $$ = new AstGte ($2,$1,$3); }
| ~l~expr '&' ~r~expr { $$ = new AstAnd ($2,$1,$3); }
| ~l~expr '|' ~r~expr { $$ = new AstOr ($2,$1,$3); }
| ~l~expr '^' ~r~expr { $$ = new AstXor ($2,$1,$3); }
| ~l~expr yP_XNOR ~r~expr { $$ = new AstXnor ($2,$1,$3); }
| ~l~expr yP_NOR ~r~expr { $$ = new AstNot($2,new AstOr ($2,$1,$3)); }
| ~l~expr yP_NAND ~r~expr { $$ = new AstNot($2,new AstAnd ($2,$1,$3)); }
| ~l~expr yP_SLEFT ~r~expr { $$ = new AstShiftL ($2,$1,$3); }
| ~l~expr yP_SRIGHT ~r~expr { $$ = new AstShiftR ($2,$1,$3); }
| ~l~expr yP_SSRIGHT ~r~expr { $$ = new AstShiftRS ($2,$1,$3); }
| ~l~expr yP_LTMINUSGT ~r~expr { $$ = new AstLogEq ($2,$1,$3); }
// // <= is special, as we need to disambiguate it with <= assignment
// // We copy all of expr to fexpr and rename this token to a fake one.
| ~l~expr yP_LTE~f__IGNORE~ ~r~expr { $$ = new AstLte ($2,$1,$3); }
//
// // IEEE: conditional_expression
| ~l~expr '?' ~r~expr ':' ~r~expr { $$ = new AstCond($2,$1,$3,$5); }
//
// // IEEE: inside_expression
| ~l~expr yINSIDE '{' open_range_list '}' { $$ = new AstInside($2,$1,$4); }
//
// // IEEE: tagged_union_expression
//UNSUP yTAGGED id/*member*/ %prec prTAGGED { UNSUP }
//UNSUP yTAGGED id/*member*/ %prec prTAGGED expr { UNSUP }
//
//======================// PSL expressions
//
| ~l~expr yP_MINUSGT ~r~expr { $$ = new AstLogIf ($2,$1,$3); }
//
//======================// IEEE: primary/constant_primary
//
// // IEEE: primary_literal (minus string, which is handled specially)
| yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
| yaFLOATNUM { $$ = new AstConst($<fl>1,AstConst::RealDouble(),$1); }
//UNSUP yaTIMENUM { UNSUP }
| strAsInt~noStr__IGNORE~ { $$ = $1; }
//
// // IEEE: "... hierarchical_identifier select" see below
//
// // IEEE: empty_queue (IEEE 1800-2017 empty_unpacked_array_concatenation)
| '{' '}' { $$ = new AstConst($1, AstConst::LogicFalse());
$<fl>1->v3error("Unsupported: empty queues (\"{ }\")"); }
//
// // IEEE: concatenation/constant_concatenation
// // Part of exprOkLvalue below
//
// // IEEE: multiple_concatenation/constant_multiple_concatenation
| '{' constExpr '{' cateList '}' '}' { $$ = new AstReplicate($1,$4,$2); }
//
| function_subroutine_callNoMethod { $$ = $1; }
// // method_call
| ~l~expr '.' function_subroutine_callNoMethod { $$ = new AstDot($2,$1,$3); }
// // method_call:array_method requires a '.'
| ~l~expr '.' array_methodNoRoot { $$ = new AstDot($2,$1,$3); }
//
// // IEEE: let_expression
// // see funcRef
//
// // IEEE: '(' mintypmax_expression ')'
| ~noPar__IGNORE~'(' expr ')' { $$ = $2; }
| ~noPar__IGNORE~'(' expr ':' expr ':' expr ')' { $$ = $2; BBUNSUP($1, "Unsupported: min typ max expressions"); }
// // PSL rule
| '_' '(' expr ')' { $$ = $3; } // Arbitrary Verilog inside PSL
//
// // IEEE: cast/constant_cast
| casting_type yP_TICK '(' expr ')' { $$ = new AstCast($2,$4,$1); }
// // expanded from casting_type
| ySIGNED yP_TICK '(' expr ')' { $$ = new AstSigned($1,$4); }
| yUNSIGNED yP_TICK '(' expr ')' { $$ = new AstUnsigned($1,$4); }
// // Spec only allows primary with addition of a type reference
// // We'll be more general, and later assert LHS was a type.
| ~l~expr yP_TICK '(' expr ')' { $$ = new AstCastParse($2,$4,$1); }
//
// // IEEE: assignment_pattern_expression
// // IEEE: streaming_concatenation
// // See exprOkLvalue
//
// // IEEE: sequence_method_call
// // Indistinguishable from function_subroutine_call:method_call
//
| '$' { $$ = new AstConst($<fl>1, AstConst::LogicFalse());
$<fl>1->v3error("Unsupported: $ expression"); }
| yNULL { $$ = new AstConst($1, AstConst::LogicFalse());
$<fl>1->v3error("Unsupported: null expression"); }
// // IEEE: yTHIS
// // See exprScope
//
//----------------------
//
// // Part of expr that may also be used as lvalue
| ~l~exprOkLvalue { $$ = $1; }
//
//----------------------
//
// // IEEE: cond_predicate - here to avoid reduce problems
// // Note expr includes cond_pattern
| ~l~expr yP_ANDANDAND ~r~expr { $$ = new AstConst($2, AstConst::LogicFalse());
$<fl>2->v3error("Unsupported: &&& expression"); }
//
// // IEEE: cond_pattern - here to avoid reduce problems
// // "expr yMATCHES pattern"
// // IEEE: pattern - expanded here to avoid conflicts
//UNSUP ~l~expr yMATCHES patternNoExpr { UNSUP }
//UNSUP ~l~expr yMATCHES ~r~expr { UNSUP }
//
// // IEEE: expression_or_dist - here to avoid reduce problems
// // "expr yDIST '{' dist_list '}'"
//UNSUP ~l~expr yDIST '{' dist_list '}' { UNSUP }
;
fexpr<nodep>: // For use as first part of statement (disambiguates <=)
BISONPRE_COPY(expr,{s/~l~/f/g; s/~r~/f/g; s/~f__IGNORE~/__IGNORE/g;}) // {copied}
;
exprNoStr<nodep>: // expression with string removed
BISONPRE_COPY(expr,{s/~noStr__IGNORE~/Ignore/g;}) // {copied}
;
exprOkLvalue<nodep>: // expression that's also OK to use as a variable_lvalue
~l~exprScope { $$ = $1; }
// // IEEE: concatenation/constant_concatenation
// // Replicate(1) required as otherwise "{a}" would not be self-determined
| '{' cateList '}' { $$ = new AstReplicate($1,$2,1); }
| '{' cateList '}' '[' expr ']' { $$ = new AstSelBit($4, new AstReplicate($1,$2,1), $5); }
| '{' cateList '}' '[' constExpr ':' constExpr ']'
{ $$ = new AstSelExtract($4, new AstReplicate($1,$2,1), $5, $7); }
| '{' cateList '}' '[' expr yP_PLUSCOLON constExpr ']'
{ $$ = new AstSelPlus($4, new AstReplicate($1,$2,1), $5, $7); }
| '{' cateList '}' '[' expr yP_MINUSCOLON constExpr ']'
{ $$ = new AstSelMinus($4, new AstReplicate($1,$2,1), $5, $7); }
// // IEEE: assignment_pattern_expression
// // IEEE: [ assignment_pattern_expression_type ] == [ ps_type_id /ps_paremeter_id/data_type]
// // We allow more here than the spec requires
//UNSUP ~l~exprScope assignment_pattern { UNSUP }
| data_type assignment_pattern { $$ = $2; $2->childDTypep($1); }
| assignment_pattern { $$ = $1; }
//
| streaming_concatenation { $$ = $1; }
;
fexprOkLvalue<nodep>: // exprOkLValue, For use as first part of statement (disambiguates <=)
BISONPRE_COPY(exprOkLvalue,{s/~l~/f/g}) // {copied}
;
fexprLvalue<nodep>: // For use as first part of statement (disambiguates <=)
fexprOkLvalue { $<fl>$=$<fl>1; $$ = $1; }
;
exprScope<nodep>: // scope and variable for use to inside an expression
// // Here we've split method_call_root | implicit_class_handle | class_scope | package_scope
// // from the object being called and let expr's "." deal with resolving it.
// // (note method_call_root was simplified to require a primary in 1800-2009)
//
// // IEEE: [ implicit_class_handle . | class_scope | package_scope ] hierarchical_identifier select
// // Or method_call_body without parenthesis
// // See also varRefClassBit, which is the non-expr version of most of this
//UNSUP yTHIS { UNSUP }
idArrayed { $$ = $1; }
| package_scopeIdFollows idArrayed { $$ = AstDot::newIfPkg($2->fileline(), $1, $2); }
//UNSUP class_scopeIdFollows idArrayed { UNSUP }
| ~l~expr '.' idArrayed { $$ = new AstDot($<fl>2,$1,$3); }
// // expr below must be a "yTHIS"
//UNSUP ~l~expr '.' ySUPER { UNSUP }
// // Part of implicit_class_handle
//UNSUP ySUPER { UNSUP }
;
fexprScope<nodep>: // exprScope, For use as first part of statement (disambiguates <=)
BISONPRE_COPY(exprScope,{s/~l~/f/g}) // {copied}
;
// PLI calls exclude "" as integers, they're strings
// For $c("foo","bar") we want "bar" as a string, not a Verilog integer.
exprStrText<nodep>:
exprNoStr { $$ = $1; }
| strAsText { $$ = $1; }
;
cStrList<nodep>:
exprStrText { $$ = $1; }
| exprStrText ',' cStrList { $$ = $1;$1->addNext($3); }
;
cateList<nodep>:
// // Not just 'expr' to prevent conflict via stream_concOrExprOrType
stream_expression { $$ = $1; }
| cateList ',' stream_expression { $$ = new AstConcat($2,$1,$3); }
;
exprListE<nodep>:
/* empty */ { $$ = NULL; }
| exprList { $$ = $1; }
;
exprList<nodep>:
expr { $$ = $1; }
| exprList ',' expr { $$ = $1;$1->addNext($3); }
;
commaEListE<nodep>:
/* empty */ { $$ = NULL; }
| ',' exprList { $$ = $2; }
;
vrdList<nodep>:
idClassSel { $$ = $1; }
| vrdList ',' idClassSel { $$ = $1;$1->addNext($3); }
;
commaVRDListE<nodep>:
/* empty */ { $$ = NULL; }
| ',' vrdList { $$ = $2; }
;
argsExprList<nodep>: // IEEE: part of list_of_arguments (used where ,, isn't legal)
expr { $$ = $1; }
| argsExprList ',' expr { $$ = $1->addNext($3); }
;
argsExprListE<nodep>: // IEEE: part of list_of_arguments
argsExprOneE { $$ = $1; }
| argsExprListE ',' argsExprOneE { $$ = $1->addNext($3); }
;
argsExprOneE<nodep>: // IEEE: part of list_of_arguments
/*empty*/ { $$ = new AstArg(CRELINE(), "", NULL); }
| expr { $$ = new AstArg(CRELINE(), "", $1); }
;
argsDottedList<nodep>: // IEEE: part of list_of_arguments
argsDotted { $$ = $1; }
| argsDottedList ',' argsDotted { $$ = $1->addNextNull($3); }
;
argsDotted<nodep>: // IEEE: part of list_of_arguments
'.' idAny '(' ')' { $$ = new AstArg($1,*$2,NULL); }
| '.' idAny '(' expr ')' { $$ = new AstArg($1,*$2,$4); }
;
streaming_concatenation<nodep>: // ==IEEE: streaming_concatenation
// // Need to disambiguate {<< expr-{ ... expr-} stream_concat }
// // From {<< stream-{ ... stream-} }
// // Likewise simple_type's idScoped from constExpr's idScope
// // Thus we allow always any two operations. Sorry
// // IEEE: "'{' yP_SL/R stream_concatenation '}'"
// // IEEE: "'{' yP_SL/R simple_type stream_concatenation '}'"
// // IEEE: "'{' yP_SL/R constExpr stream_concatenation '}'"
'{' yP_SLEFT stream_concOrExprOrType '}' { $$ = new AstStreamL($1, $3, new AstConst($1,1)); }
| '{' yP_SRIGHT stream_concOrExprOrType '}' { $$ = new AstStreamR($1, $3, new AstConst($1,1)); }
| '{' yP_SLEFT stream_concOrExprOrType stream_concatenation '}' { $$ = new AstStreamL($1, $4, $3); }
| '{' yP_SRIGHT stream_concOrExprOrType stream_concatenation '}' { $$ = new AstStreamR($1, $4, $3); }
;
stream_concOrExprOrType<nodep>: // IEEE: stream_concatenation | slice_size:simple_type | slice_size:constExpr
cateList { $$ = $1; }
| simple_type { $$ = $1; }
// // stream_concatenation found via cateList:stream_expr:'{-normal-concat'
// // simple_typeRef found via cateList:stream_expr:expr:id
// // constant_expression found via cateList:stream_expr:expr
;
stream_concatenation<nodep>: // ==IEEE: stream_concatenation
'{' cateList '}' { $$ = $2; }
;
stream_expression<nodep>: // ==IEEE: stream_expression
// // IEEE: array_range_expression expanded below
expr { $$ = $1; }
//UNSUP expr yWITH__BRA '[' expr ']' { UNSUP }
//UNSUP expr yWITH__BRA '[' expr ':' expr ']' { UNSUP }
//UNSUP expr yWITH__BRA '[' expr yP_PLUSCOLON expr ']' { UNSUP }
//UNSUP expr yWITH__BRA '[' expr yP_MINUSCOLON expr ']' { UNSUP }
;
//************************************************
// Gate declarations
gateDecl<nodep>:
yBUF delayE gateBufList ';' { $$ = $3; }
| yBUFIF0 delayE gateBufif0List ';' { $$ = $3; }
| yBUFIF1 delayE gateBufif1List ';' { $$ = $3; }
| yNOT delayE gateNotList ';' { $$ = $3; }
| yNOTIF0 delayE gateNotif0List ';' { $$ = $3; }
| yNOTIF1 delayE gateNotif1List ';' { $$ = $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; }
| yPULLUP delayE gatePullupList ';' { $$ = $3; }
| yPULLDOWN delayE gatePulldownList ';' { $$ = $3; }
| yNMOS delayE gateBufif1List ';' { $$ = $3; } // ~=bufif1, as don't have strengths yet
| yPMOS delayE gateBufif0List ';' { $$ = $3; } // ~=bufif0, as don't have strengths yet
//
| yTRAN delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"tran"); } // Unsupported
| yRCMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rcmos"); } // Unsupported
| yCMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"cmos"); } // Unsupported
| yRNMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rmos"); } // Unsupported
| yRPMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"pmos"); } // Unsupported
| yRTRAN delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rtran"); } // Unsupported
| yRTRANIF0 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rtranif0"); } // Unsupported
| yRTRANIF1 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rtranif1"); } // Unsupported
| yTRANIF0 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"tranif0"); } // Unsupported
| yTRANIF1 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"tranif1"); } // Unsupported
;
gateBufList<nodep>:
gateBuf { $$ = $1; }
| gateBufList ',' gateBuf { $$ = $1->addNext($3); }
;
gateBufif0List<nodep>:
gateBufif0 { $$ = $1; }
| gateBufif0List ',' gateBufif0 { $$ = $1->addNext($3); }
;
gateBufif1List<nodep>:
gateBufif1 { $$ = $1; }
| gateBufif1List ',' gateBufif1 { $$ = $1->addNext($3); }
;
gateNotList<nodep>:
gateNot { $$ = $1; }
| gateNotList ',' gateNot { $$ = $1->addNext($3); }
;
gateNotif0List<nodep>:
gateNotif0 { $$ = $1; }
| gateNotif0List ',' gateNotif0 { $$ = $1->addNext($3); }
;
gateNotif1List<nodep>:
gateNotif1 { $$ = $1; }
| gateNotif1List ',' gateNotif1 { $$ = $1->addNext($3); }
;
gateAndList<nodep>:
gateAnd { $$ = $1; }
| gateAndList ',' gateAnd { $$ = $1->addNext($3); }
;
gateNandList<nodep>:
gateNand { $$ = $1; }
| gateNandList ',' gateNand { $$ = $1->addNext($3); }
;
gateOrList<nodep>:
gateOr { $$ = $1; }
| gateOrList ',' gateOr { $$ = $1->addNext($3); }
;
gateNorList<nodep>:
gateNor { $$ = $1; }
| gateNorList ',' gateNor { $$ = $1->addNext($3); }
;
gateXorList<nodep>:
gateXor { $$ = $1; }
| gateXorList ',' gateXor { $$ = $1->addNext($3); }
;
gateXnorList<nodep>:
gateXnor { $$ = $1; }
| gateXnorList ',' gateXnor { $$ = $1->addNext($3); }
;
gatePullupList<nodep>:
gatePullup { $$ = $1; }
| gatePullupList ',' gatePullup { $$ = $1->addNext($3); }
;
gatePulldownList<nodep>:
gatePulldown { $$ = $1; }
| gatePulldownList ',' gatePulldown { $$ = $1->addNext($3); }
;
gateUnsupList<nodep>:
gateUnsup { $$ = $1; }
| gateUnsupList ',' gateUnsup { $$ = $1->addNext($3); }
;
gateRangeE<nodep>:
instRangeE { $$ = $1; GATERANGE(GRAMMARP->scrubRange($1)); }
;
gateBuf<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gatePinExpr ')'
{ $$ = new AstAssignW($3,$4,$6); DEL($2); }
;
gateBufif0<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
{ $$ = new AstAssignW($3,$4,new AstBufIf1($3,new AstNot($3,$8),$6)); DEL($2); }
;
gateBufif1<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
{ $$ = new AstAssignW($3,$4,new AstBufIf1($3,$8,$6)); DEL($2); }
;
gateNot<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gatePinExpr ')'
{ $$ = new AstAssignW($3,$4,new AstNot($5,$6)); DEL($2); }
;
gateNotif0<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
{ $$ = new AstAssignW($3,$4,new AstBufIf1($3,new AstNot($3,$8), new AstNot($3, $6))); DEL($2); }
;
gateNotif1<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
{ $$ = new AstAssignW($3,$4,new AstBufIf1($3,$8, new AstNot($3,$6))); DEL($2); }
;
gateAnd<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gateAndPinList ')'
{ $$ = new AstAssignW($3,$4,$6); DEL($2); }
;
gateNand<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gateAndPinList ')'
{ $$ = new AstAssignW($3,$4,new AstNot($5,$6)); DEL($2); }
;
gateOr<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gateOrPinList ')'
{ $$ = new AstAssignW($3,$4,$6); DEL($2); }
;
gateNor<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gateOrPinList ')'
{ $$ = new AstAssignW($3,$4,new AstNot($5,$6)); DEL($2); }
;
gateXor<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gateXorPinList ')'
{ $$ = new AstAssignW($3,$4,$6); DEL($2); }
;
gateXnor<nodep>:
gateIdE gateRangeE '(' variable_lvalue ',' gateXorPinList ')'
{ $$ = new AstAssignW($3,$4,new AstNot($5,$6)); DEL($2); }
;
gatePullup<nodep>:
gateIdE gateRangeE '(' variable_lvalue ')' { $$ = new AstPull($3, $4, true); DEL($2); }
;
gatePulldown<nodep>:
gateIdE gateRangeE '(' variable_lvalue ')' { $$ = new AstPull($3, $4, false); DEL($2); }
;
gateUnsup<nodep>:
gateIdE gateRangeE '(' gateUnsupPinList ')' { $$ = new AstImplicit($3,$4); DEL($2); }
;
gateIdE:
/*empty*/ {}
| id {}
;
gateAndPinList<nodep>:
gatePinExpr { $$ = $1; }
| gateAndPinList ',' gatePinExpr { $$ = new AstAnd($2,$1,$3); }
;
gateOrPinList<nodep>:
gatePinExpr { $$ = $1; }
| gateOrPinList ',' gatePinExpr { $$ = new AstOr($2,$1,$3); }
;
gateXorPinList<nodep>:
gatePinExpr { $$ = $1; }
| gateXorPinList ',' gatePinExpr { $$ = new AstXor($2,$1,$3); }
;
gateUnsupPinList<nodep>:
gatePinExpr { $$ = $1; }
| gateUnsupPinList ',' gatePinExpr { $$ = $1->addNext($3); }
;
gatePinExpr<nodep>:
expr { $$ = GRAMMARP ->createGatePin($1); }
;
// This list is also hardcoded in VParseLex.l
strength: // IEEE: strength0+strength1 - plus HIGHZ/SMALL/MEDIUM/LARGE
ygenSTRENGTH { BBUNSUP($1, "Unsupported: Verilog 1995 strength specifiers"); }
| ySUPPLY0 { BBUNSUP($1, "Unsupported: Verilog 1995 strength specifiers"); }
| ySUPPLY1 { BBUNSUP($1, "Unsupported: Verilog 1995 strength specifiers"); }
;
strengthSpecE: // IEEE: drive_strength + pullup_strength + pulldown_strength + charge_strength - plus empty
/* empty */ { }
| strengthSpec { }
;
strengthSpec: // IEEE: drive_strength + pullup_strength + pulldown_strength + charge_strength - plus empty
yP_PAR__STRENGTH strength ')' { }
| yP_PAR__STRENGTH strength ',' strength ')' { }
;
//************************************************
// Tables
combinational_body<nodep>: // IEEE: combinational_body + sequential_body
yTABLE tableEntryList yENDTABLE { $$ = new AstUdpTable($1,$2); }
;
tableEntryList<nodep>: // IEEE: { combinational_entry | sequential_entry }
tableEntry { $$ = $1; }
| tableEntryList tableEntry { $$ = $1->addNext($2); }
;
tableEntry<nodep>: // IEEE: combinational_entry + sequential_entry
yaTABLELINE { $$ = new AstUdpTableLine($<fl>1,*$1); }
| error { $$ = NULL; }
;
//************************************************
// Specify
specify_block<nodep>: // ==IEEE: specify_block
ySPECIFY specifyJunkList yENDSPECIFY { $$ = NULL; }
| ySPECIFY yENDSPECIFY { $$ = NULL; }
;
specifyJunkList:
specifyJunk { } /* ignored */
| specifyJunkList specifyJunk { } /* ignored */
;
specifyJunk:
BISONPRE_NOT(ySPECIFY,yENDSPECIFY) { }
| ySPECIFY specifyJunk yENDSPECIFY { }
| error {}
;
specparam_declaration<nodep>: // ==IEEE: specparam_declaration
ySPECPARAM junkToSemiList ';' { $$ = NULL; }
;
junkToSemiList:
junkToSemi { } /* ignored */
| junkToSemiList junkToSemi { } /* ignored */
;
junkToSemi:
BISONPRE_NOT(';',yENDSPECIFY,yENDMODULE) { }
| error {}
;
//************************************************
// IDs
id<strp>:
yaID__ETC { $$ = $1; $<fl>$=$<fl>1; }
;
idAny<strp>: // Any kind of identifier
yaID__aPACKAGE { $$ = $1; $<fl>$=$<fl>1; }
| yaID__aTYPE { $$ = $1; $<fl>$=$<fl>1; }
| yaID__ETC { $$ = $1; $<fl>$=$<fl>1; }
;
idSVKwd<strp>: // Warn about non-forward compatible Verilog 2001 code
// // yBIT, yBYTE won't work here as causes conflicts
yDO { static string s = "do" ; $$ = &s; ERRSVKWD($1,*$$); $<fl>$=$<fl>1; }
| yFINAL { static string s = "final"; $$ = &s; ERRSVKWD($1,*$$); $<fl>$=$<fl>1; }
;
variable_lvalue<nodep>: // IEEE: variable_lvalue or net_lvalue
// // Note many variable_lvalue's must use exprOkLvalue when arbitrary expressions may also exist
idClassSel { $$ = $1; }
| '{' variable_lvalueConcList '}' { $$ = $2; }
// // IEEE: [ assignment_pattern_expression_type ] assignment_pattern_variable_lvalue
// // We allow more assignment_pattern_expression_types then strictly required
//UNSUP data_type yP_TICKBRA variable_lvalueList '}' { UNSUP }
//UNSUP idClassSel yP_TICKBRA variable_lvalueList '}' { UNSUP }
//UNSUP /**/ yP_TICKBRA variable_lvalueList '}' { UNSUP }
| streaming_concatenation { $$ = $1; }
;
variable_lvalueConcList<nodep>: // IEEE: part of variable_lvalue: '{' variable_lvalue { ',' variable_lvalue } '}'
variable_lvalue { $$ = $1; }
| variable_lvalueConcList ',' variable_lvalue { $$ = new AstConcat($2,$1,$3); }
;
// VarRef to dotted, and/or arrayed, and/or bit-ranged variable
idClassSel<nodep>: // Misc Ref to dotted, and/or arrayed, and/or bit-ranged variable
idDotted { $$ = $1; }
// // IEEE: [ implicit_class_handle . | package_scope ] hierarchical_variable_identifier select
//UNSUP yTHIS '.' idDotted { UNSUP }
//UNSUP ySUPER '.' idDotted { UNSUP }
//UNSUP yTHIS '.' ySUPER '.' idDotted { UNSUP }
// // Expanded: package_scope idDotted
//UNSUP class_scopeIdFollows idDotted { UNSUP }
//UNSUP package_scopeIdFollows idDotted { UNSUP }
;
idDotted<nodep>:
//UNSUP yD_ROOT '.' idDottedMore { UNSUP }
idDottedMore { $$ = $1; }
;
idDottedMore<nodep>:
idArrayed { $$ = $1; }
| idDottedMore '.' idArrayed { $$ = new AstDot($2,$1,$3); }
;
// 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.
// id below includes:
// enum_identifier
idArrayed<nodep>: // IEEE: id + select
id { $$ = new AstParseRef($<fl>1,AstParseRefExp::PX_TEXT,*$1,NULL,NULL); }
// // IEEE: id + part_select_range/constant_part_select_range
| idArrayed '[' expr ']' { $$ = new AstSelBit($2,$1,$3); } // Or AstArraySel, don't know yet.
| idArrayed '[' constExpr ':' constExpr ']' { $$ = new AstSelExtract($2,$1,$3,$5); }
// // IEEE: id + indexed_range/constant_indexed_range
| idArrayed '[' expr yP_PLUSCOLON constExpr ']' { $$ = new AstSelPlus($2,$1,$3,$5); }
| idArrayed '[' expr yP_MINUSCOLON constExpr ']' { $$ = new AstSelMinus($2,$1,$3,$5); }
;
idClassForeach<nodep>:
idForeach { $$ = $1; }
| package_scopeIdFollows idForeach { $$ = AstDot::newIfPkg($2->fileline(), $1, $2); }
;
idForeach<nodep>:
varRefBase { $$ = $1; }
| idForeach '.' varRefBase { $$ = new AstDot($2,$1,$3); }
;
// VarRef without any dots or vectorizaion
varRefBase<varrefp>:
id { $$ = new AstVarRef($<fl>1,*$1,false);}
;
// yaSTRING shouldn't be used directly, instead via an abstraction below
str<strp>: // yaSTRING but with \{escapes} need decoded
yaSTRING { $$ = PARSEP->newString(GRAMMARP->deQuote($<fl>1,*$1)); }
;
strAsInt<nodep>:
yaSTRING { $$ = new AstConst($<fl>1, AstConst::VerilogStringLiteral(), GRAMMARP->deQuote($<fl>1, *$1));}
;
strAsIntIgnore<nodep>: // strAsInt, but never matches for when expr shouldn't parse strings
yaSTRING__IGNORE { $$ = NULL; yyerror("Impossible token"); }
;
strAsText<nodep>:
yaSTRING { $$ = GRAMMARP->createTextQuoted($<fl>1,*$1);}
;
endLabelE<strp>:
/* empty */ { $$ = NULL; $<fl>$=NULL; }
| ':' idAny { $$ = $2; $<fl>$=$<fl>2; }
//UNSUP ':' yNEW__ETC { $$ = $2; $<fl>$=$<fl>2; }
;
//************************************************
// Clocking
clocking_declaration<nodep>: // IEEE: clocking_declaration (INCOMPLETE)
yDEFAULT yCLOCKING '@' '(' senitemEdge ')' ';' yENDCLOCKING
{ $$ = new AstClocking($1, $5, NULL); }
//UNSUP: Vastly simplified grammar
;
//************************************************
// Asserts
assertion_item<nodep>: // ==IEEE: assertion_item
concurrent_assertion_item { $$ = $1; }
| deferred_immediate_assertion_item { $$ = $1; }
;
deferred_immediate_assertion_item<nodep>: // ==IEEE: deferred_immediate_assertion_item
deferred_immediate_assertion_statement { $$ = $1; }
| id/*block_identifier*/ ':' deferred_immediate_assertion_statement
{ $$ = new AstBegin($2, *$1, $3); }
;
procedural_assertion_statement<nodep>: // ==IEEE: procedural_assertion_statement
concurrent_assertion_statement { $$ = $1; }
| immediate_assertion_statement { $$ = $1; }
// // IEEE: checker_instantiation
// // Unlike modules, checkers are the only "id id (...)" form in statements.
//UNSUP checker_instantiation { $$ = $1; }
;
immediate_assertion_statement<nodep>: // ==IEEE: immediate_assertion_statement
simple_immediate_assertion_statement { $$ = $1; }
| deferred_immediate_assertion_statement { $$ = $1; }
;
simple_immediate_assertion_statement<nodep>: // ==IEEE: simple_immediate_assertion_statement
// // action_block expanded here, for compatibility with AstVAssert
yASSERT '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstVAssert($1,$3,$5, GRAMMARP->createDisplayError($1)); }
| yASSERT '(' expr ')' yELSE stmtBlock { $$ = new AstVAssert($1,$3,NULL,$6); }
| yASSERT '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstVAssert($1,$3,$5,$7); }
// // action_block expanded here, for compatibility with AstVAssert
| yASSUME '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstVAssert($1,$3,$5, GRAMMARP->createDisplayError($1)); }
| yASSUME '(' expr ')' yELSE stmtBlock { $$ = new AstVAssert($1,$3,NULL,$6); }
| yASSUME '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstVAssert($1,$3,$5,$7); }
// // IEEE: simple_immediate_cover_statement
| yCOVER '(' expr ')' stmt { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: immediate cover"); }
;
final_zero: // IEEE: part of deferred_immediate_assertion_statement
'#' yaINTNUM
{ if ($2->isNeqZero()) { $<fl>2->v3error("Deferred assertions must use '#0' (IEEE 2017 16.4)"); } }
// // 1800-2012:
| yFINAL { }
;
deferred_immediate_assertion_statement<nodep>: // ==IEEE: deferred_immediate_assertion_statement
// // IEEE: deferred_immediate_assert_statement
yASSERT final_zero '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstVAssert($1,$4,$6, GRAMMARP->createDisplayError($1)); }
| yASSERT final_zero '(' expr ')' yELSE stmtBlock { $$ = new AstVAssert($1,$4,NULL,$7); }
| yASSERT final_zero '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstVAssert($1,$4,$6,$8); }
// // IEEE: deferred_immediate_assume_statement
| yASSUME final_zero '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstVAssert($1,$4,$6, GRAMMARP->createDisplayError($1)); }
| yASSUME final_zero '(' expr ')' yELSE stmtBlock { $$ = new AstVAssert($1,$4,NULL,$7); }
| yASSUME final_zero '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstVAssert($1,$4,$6,$8); }
// // IEEE: deferred_immediate_cover_statement
| yCOVER final_zero '(' expr ')' stmt { $$ = NULL; BBUNSUP($<fl>1, "Unsupported: immediate cover"); }
;
concurrent_assertion_item<nodep>: // IEEE: concurrent_assertion_item
concurrent_assertion_statement { $$ = $1; }
| id/*block_identifier*/ ':' concurrent_assertion_statement { $$ = new AstBegin($2,*$1,$3); }
// // IEEE: checker_instantiation
// // identical to module_instantiation; see etcInst
;
concurrent_assertion_statement<nodep>: // ==IEEE: concurrent_assertion_statement
// // IEEE: assert_property_statement
yASSERT yPROPERTY '(' property_spec ')' elseStmtBlock { $$ = new AstPslAssert($1,$4,$6); }
// // IEEE: cover_property_statement
| yCOVER yPROPERTY '(' property_spec ')' stmtBlock { $$ = new AstPslCover($1,$4,$6); }
// // IEEE: restrict_property_statement
| yRESTRICT yPROPERTY '(' property_spec ')' ';' { $$ = new AstPslRestrict($1,$4); }
;
elseStmtBlock<nodep>: // Part of concurrent_assertion_statement
';' { $$ = NULL; }
| yELSE stmtBlock { $$ = $2; }
;
property_spec<nodep>: // IEEE: property_spec
//UNSUP: This rule has been super-specialized to what is supported now
'@' '(' senitemEdge ')' yDISABLE yIFF '(' expr ')' expr
{ $$ = new AstPslClocked($1,$3,$8,$10); }
| '@' '(' senitemEdge ')' expr { $$ = new AstPslClocked($1,$3,NULL,$5); }
| yDISABLE yIFF '(' expr ')' expr { $$ = new AstPslClocked($4->fileline(),NULL,$4,$6); }
| expr { $$ = new AstPslClocked($1->fileline(),NULL,NULL,$1); }
;
//************************************************
// Let
//************************************************
// Covergroup
//**********************************************************************
// Randsequence
//**********************************************************************
// Checker
//**********************************************************************
// Class
//=========
// Package scoping - to traverse the symbol table properly, the final identifer
// must be included in the rules below.
// Each of these must end with {symsPackageDone | symsClassDone}
ps_id_etc: // package_scope + general id
package_scopeIdFollowsE id { }
;
ps_type<dtypep>: // IEEE: ps_parameter_identifier | ps_type_identifier
// Even though we looked up the type and have a AstNode* to it,
// we can't fully resolve it because it may have been just a forward definition.
package_scopeIdFollowsE yaID__aTYPE { $$ = new AstRefDType($<fl>2, *$2); VN_CAST($$, RefDType)->packagep($1); }
// // Simplify typing - from ps_covergroup_identifier
//UNSUP package_scopeIdFollowsE yaID__aCOVERGROUP { $<fl>$=$<fl>1; $$=$1+$2; }
;
//=== Below rules assume special scoping per above
package_scopeIdFollowsE<packagep>: // IEEE: [package_scope]
// // IMPORTANT: The lexer will parse the following ID to be in the found package
// // class_qualifier := [ yLOCAL '::' ] [ implicit_class_handle '.' class_scope ]
/* empty */ { $$ = NULL; }
| package_scopeIdFollows { $$ = $1; }
;
package_scopeIdFollows<packagep>: // IEEE: package_scope
// // IMPORTANT: The lexer will parse the following ID to be in the found package
// //vv mid rule action needed otherwise we might not have NextId in time to parse the id token
yD_UNIT { SYMP->nextId(PARSEP->rootp()); }
/*cont*/ yP_COLONCOLON { $$ = GRAMMARP->unitPackage($<fl>1); }
| yaID__aPACKAGE { SYMP->nextId($<scp>1); }
/*cont*/ yP_COLONCOLON { $$ = VN_CAST($<scp>1, Package); }
//UNSUP yLOCAL__COLONCOLON { PARSEP->symTableNextId($<scp>1); }
//UNSUP /*cont*/ yP_COLONCOLON { UNSUP }
;
//**********************************************************************
// Constraints
//**********************************************************************
// VLT Files
vltItem:
vltOffFront { V3Config::addIgnore($1,false,"*",0,0); }
| vltOffFront yVLT_D_FILE yaSTRING { V3Config::addIgnore($1,false,*$3,0,0); }
| vltOffFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM { V3Config::addIgnore($1,false,*$3,$5->toUInt(),$5->toUInt()+1); }
| vltOffFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM '-' yaINTNUM { V3Config::addIgnore($1,false,*$3,$5->toUInt(),$7->toUInt()+1); }
| vltOnFront { V3Config::addIgnore($1,true,"*",0,0); }
| vltOnFront yVLT_D_FILE yaSTRING { V3Config::addIgnore($1,true,*$3,0,0); }
| vltOnFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM { V3Config::addIgnore($1,true,*$3,$5->toUInt(),$5->toUInt()+1); }
| vltOnFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM '-' yaINTNUM { V3Config::addIgnore($1,true,*$3,$5->toUInt(),$7->toUInt()+1); }
;
vltOffFront<errcodeen>:
yVLT_COVERAGE_OFF { $$ = V3ErrorCode::I_COVERAGE; }
| yVLT_TRACING_OFF { $$ = V3ErrorCode::I_TRACING; }
| yVLT_LINT_OFF { $$ = V3ErrorCode::I_LINT; }
| yVLT_LINT_OFF yVLT_D_MSG yaID__ETC
{ $$ = V3ErrorCode((*$3).c_str());
if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: "<<*$3<<endl); } }
;
vltOnFront<errcodeen>:
yVLT_COVERAGE_ON { $$ = V3ErrorCode::I_COVERAGE; }
| yVLT_TRACING_ON { $$ = V3ErrorCode::I_TRACING; }
| yVLT_LINT_ON { $$ = V3ErrorCode::I_LINT; }
| yVLT_LINT_ON yVLT_D_MSG yaID__ETC
{ $$ = V3ErrorCode((*$3).c_str());
if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: "<<*$3<<endl); } }
;
//**********************************************************************
%%
// For implementation functions see V3ParseGrammar.cpp
//YACC = /kits/sources/bison-2.4.1/src/bison --report=lookahead
// --report=lookahead
// --report=itemset
// --graph
|
<filename>src/cmsk/cmsk_parse.y<gh_stars>10-100
%{
/*
* ISC License
*
* Copyright (C) 1983-2018 by
* <NAME>
* <NAME>
* Delft University of Technology
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "src/cmsk/extern.h"
#define P_E fprintf(stderr,
#define ROUND(x) (x < 0)?(x - 0.5001):(x + 0.5001)
struct list *newlistptr;
char *cp;
int pfactor;
int t_nr;
int mlistflag;
int mlistdef;
extern int yylineno;
int p_nr, p_mode;
double p_arr[5];
%}
%token MASKS MASKLIST MASKEY
%token PFACTOR PATTERN END
%token RA RR TOK_RS LA POLY TEXT
%token POLYGON PATH CIRCLE CPEEL
%token T1 T2 T3 X Y CX CY MX MY
%token ROTATE ROT0 ROT90 ROT180 ROT270
%token EXTRACT REMOVE TRANSFER
%token FORMMASK GROW AND OR NOT
%token ABSOLUTE RELATIVE SLANTING TEST
%token PATNAME MASKNAME STRING
%token INTEGER FLOAT
%token EOL GARBAGE
%start defs
%%
defs : /* empty file */
| defs definition
;
definition : pat_def
| masksdef eol
| mlistsdef eol
| PFACTOR integer { pfactor = $2; } eol
| commands eol
| eol
| error
{
pr_err1 ("warning: unidentified statement skipped");
}
eol
;
pat_def :
{
cl_boxes_etc ();
}
beg_pattern p_stats end_pattern
{
if (pat_key) write_info ();
*pat_name = '\0';
}
;
beg_pattern : PATTERN patname
{
strcpy (pat_name, words[$2]);
if (v_mode) pr_err2 ("pattern", pat_name);
if (check_tree (pat_name)) {
/* pattern name found */
pr_err ("error: pattern", mpn (pat_name),
"already defined");
killpattern ();
}
if (makepattern)
mk_patdir ();
}
eol
| PATTERN error
{
pr_err2 ("error: illegal pattern begin", mpn (pat_name));
killpattern ();
}
eol
{
yyerrok;
}
;
end_pattern : END patname
{
if (strcmp (pat_name, words[$2])) {
pr_err2 ("error: illegal pattern end, expected end",
mpn (pat_name));
killpattern ();
}
}
eol
| END error
{
pr_err2 ("error: illegal pattern end", mpn (pat_name));
killpattern ();
}
eol
;
p_stats : /* empty */
| p_stats pat_stat
;
pat_stat : simple_pattern eol
| complex_pattern eol
| slanting_pattern eol
| pat_call eol
| functioncall eol
| masksdef eol
| mlistsdef eol
| eol
| error
{
pr_err2 ("error: unidentified statement part:", textval());
killpattern ();
}
eol
;
simple_pattern : RA '(' masklist ',' coord ',' coord ',' coord ',' coord ')' placement
{
if (pat_key) {
p_x[0] = $5;
p_x[1] = $7;
p_y[0] = $9;
p_y[1] = $11;
printonebox ();
}
}
| RR '(' masklist ',' coord ',' coord ')' placement
{
if (pat_key) {
p_x[0] = 0;
p_x[1] = $5;
p_y[0] = 0;
p_y[1] = $7;
printonebox ();
}
}
;
complex_pattern : la_pattern placement
{
if (pat_key)
pr_la_pattern ();
}
| poly_pattern placement
{
if (pat_key)
pr_boxes_from_edges ();
}
| text_pattern placement
{
if (pat_key)
pr_boxes_from_edges ();
}
;
la_pattern : LA '(' masklist ',' coord
{
line_width = $5;
lw_tan225 = line_width * TAN225;
lw_hsqrt2 = line_width * HSQRT2;
}
line_start lin_segments ')'
;
line_start : ',' coord ',' direction ',' coord ',' coord
{
if (pat_key) {
register struct la_elmt *t1, *t2;
for (t1 = first_la_elmt; t1; t1 = t2) {
t2 = t1 -> next;
FREE (t1);
}
ALLOC_STRUCT (first_la_elmt, la_elmt);
last_la_elmt = first_la_elmt;
last_la_elmt -> gtype = 0;
if ($4 == 0) { /* X-direction */
x1 = $2; g_y1 = $6; x2 = $8;
if (x2 < x1) {
last_la_elmt -> xl = x2;
last_la_elmt -> xr = x1;
last_la_elmt -> yb = g_y1 - line_width;
last_la_elmt -> yt = g_y1;
}
else {
last_la_elmt -> xl = x1;
last_la_elmt -> xr = x2;
last_la_elmt -> yb = g_y1;
last_la_elmt -> yt = g_y1 + line_width;
}
prev_grow = x2 - x1;
x1 = x2; dir_flag = 1;
}
else { /* Y-direction */
g_y1 = $2; x1 = $6; y2 = $8;
if (y2 < g_y1) {
last_la_elmt -> xl = x1;
last_la_elmt -> xr = x1 + line_width;
last_la_elmt -> yb = y2;
last_la_elmt -> yt = g_y1;
}
else {
last_la_elmt -> xl = x1 - line_width;
last_la_elmt -> xr = x1;
last_la_elmt -> yb = g_y1;
last_la_elmt -> yt = y2;
}
prev_grow = y2 - g_y1;
g_y1 = y2; dir_flag = 0;
}
}
}
;
lin_segments : /* empty */
| lin_segments line_segment
;
line_segment : ',' coord
{
if (pat_key) {
register struct la_elmt *new1;
ALLOC_STRUCT (new1, la_elmt);
new1 -> gtype = 0;
if (dir_flag == 0) { /* X-direction */
x2 = $2;
if (x2 < x1) {
if (prev_grow <= 0) {
new1 -> xr = x1 + line_width;
last_la_elmt -> yb -= line_width;
}
else {
new1 -> xr = x1;
}
new1 -> xl = x2;
new1 -> yb = g_y1 - line_width;
new1 -> yt = g_y1;
}
else {
if (prev_grow >= 0) {
new1 -> xl = x1 - line_width;
last_la_elmt -> yt += line_width;
}
else {
new1 -> xl = x1;
}
new1 -> xr = x2;
new1 -> yb = g_y1;
new1 -> yt = g_y1 + line_width;
}
prev_grow = x2 - x1;
x1 = x2; dir_flag = 1;
}
else { /* Y-direction */
y2 = $2;
if (y2 < g_y1) {
if (prev_grow >= 0) {
new1 -> yt = g_y1 + line_width;
last_la_elmt -> xr += line_width;
}
else {
new1 -> yt = g_y1;
}
new1 -> xl = x1;
new1 -> xr = x1 + line_width;
new1 -> yb = y2;
}
else {
if (prev_grow <= 0) {
new1 -> yb = g_y1 - line_width;
last_la_elmt -> xl -= line_width;
}
else {
new1 -> yb = g_y1;
}
new1 -> xl = x1 - line_width;
new1 -> xr = x1;
new1 -> yt = y2;
}
prev_grow = y2 - g_y1;
g_y1 = y2; dir_flag = 0;
}
last_la_elmt -> next = new1;
new1 -> next = NULL;
last_la_elmt = new1;
}
}
| ',' SLANTING ',' direction ',' coord ',' coord
{
if (pat_key) {
register struct la_elmt *new1;
register struct la_elmt *new2;
ALLOC_STRUCT (new1, la_elmt);
ALLOC_STRUCT (new2, la_elmt);
if (dir_flag == 0) { /* X-direction */
if ($4 == 0) { /* SX */
x2 = $8; y2 = $6;
if (x2 < x1) {
new2 -> gtype = LA_G_XR;
new2 -> xl = x2;
new2 -> yb = y2 - line_width;
new2 -> yt = y2;
if (prev_grow <= 0) {
new1 -> gtype = LA_SB_N;
last_la_elmt -> gtype |= LA_G_YB;
last_la_elmt -> yb -= lw_tan225;
new2 -> xr = x1 - (g_y1 - y2) + lw_tan225;
new1 -> xl = new2 -> xr;
new1 -> yb = new2 -> yb;
new1 -> xr = last_la_elmt -> xr - lw_hsqrt2;
new1 -> yt = last_la_elmt -> yb + lw_hsqrt2;
}
else {
new1 -> gtype = LA_SB_P;
last_la_elmt -> gtype |= LA_G_YT;
new2 -> xr = x1 - (y2 - g_y1);
new1 -> xl = x1 - lw_hsqrt2;
new1 -> yb = g_y1 - lw_hsqrt2;
new1 -> xr = new2 -> xr;
new1 -> yt = y2;
}
}
else { /* x2 >= x1 */
new2 -> gtype = LA_G_XL;
new2 -> xr = x2;
new2 -> yb = y2;
new2 -> yt = y2 + line_width;
if (prev_grow >= 0) {
new1 -> gtype = LA_SB_N;
last_la_elmt -> gtype |= LA_G_YT;
last_la_elmt -> yt += lw_tan225;
new2 -> xl = x1 + (y2 - g_y1) - lw_tan225;
new1 -> xl = last_la_elmt -> xl + lw_hsqrt2;
new1 -> yb = last_la_elmt -> yt - lw_hsqrt2;
new1 -> xr = new2 -> xl;
new1 -> yt = new2 -> yt;
}
else {
new1 -> gtype = LA_SB_P;
last_la_elmt -> gtype |= LA_G_YB;
new2 -> xl = x1 + (g_y1 - y2);
new1 -> xl = new2 -> xl;
new1 -> yb = y2;
new1 -> xr = x1 + lw_hsqrt2;
new1 -> yt = g_y1 + lw_hsqrt2;
}
}
prev_grow = x2 - x1;
dir_flag = 1;
}
else { /* SY */
x2 = $6; y2 = $8;
if (x2 < x1) {
if (prev_grow <= 0) {
last_la_elmt -> gtype |= LA_G_YB;
last_la_elmt -> yb -= lw_tan225;
new1 -> gtype = LA_SB_N;
new2 -> gtype = LA_G_YT;
new2 -> xl = x2;
new2 -> xr = x2 + line_width;
new2 -> yb = y2;
new2 -> yt = g_y1 - (x1 - x2);
new1 -> xl = x2 + lw_hsqrt2;
new1 -> yb = new2 -> yt - lw_hsqrt2;
new1 -> xr = last_la_elmt -> xr - lw_hsqrt2;
new1 -> yt = last_la_elmt -> yb + lw_hsqrt2;
}
else {
last_la_elmt -> gtype |= LA_G_YT;
new1 -> gtype = LA_SB_P;
new2 -> gtype = LA_G_YB;
new2 -> xl = x2 - line_width;
new2 -> xr = x2;
new2 -> yb = g_y1 + (x1 - x2) - lw_tan225;
new2 -> yt = y2;
new1 -> xl = x1 - lw_hsqrt2;
new1 -> yb = g_y1 - lw_hsqrt2;
new1 -> xr = new2 -> xl + lw_hsqrt2;
new1 -> yt = new2 -> yb + lw_hsqrt2;
}
}
else { /* x2 >= x1 */
if (prev_grow >= 0) {
last_la_elmt -> gtype |= LA_G_YT;
last_la_elmt -> yt += lw_tan225;
new1 -> gtype = LA_SB_N;
new2 -> gtype = LA_G_YB;
new2 -> xl = x2 - line_width;
new2 -> xr = x2;
new2 -> yb = g_y1 + (x2 - x1);
new2 -> yt = y2;
new1 -> xl = last_la_elmt -> xl + lw_hsqrt2;
new1 -> yb = last_la_elmt -> yt - lw_hsqrt2;
new1 -> xr = x2 - lw_hsqrt2;
new1 -> yt = new2 -> yb + lw_hsqrt2;
}
else {
last_la_elmt -> gtype |= LA_G_YB;
new1 -> gtype = LA_SB_P;
new2 -> gtype = LA_G_YT;
new2 -> xl = x2;
new2 -> xr = x2 + line_width;
new2 -> yb = y2;
new2 -> yt = g_y1 - (x2 - x1) + lw_tan225;
new1 -> xl = new2 -> xr - lw_hsqrt2;
new1 -> yb = new2 -> yt - lw_hsqrt2;
new1 -> xr = x1 + lw_hsqrt2;
new1 -> yt = g_y1 + lw_hsqrt2;
}
}
prev_grow = y2 - g_y1;
dir_flag = 0;
}
}
else { /* Y-direction */
if ($4 == 0) { /* SX */
x2 = $8; y2 = $6;
if (y2 < g_y1) {
if (prev_grow <= 0) {
last_la_elmt -> gtype |= LA_G_XL;
new1 -> gtype = LA_SB_N;
new2 -> gtype = LA_G_XR;
new2 -> xl = x2;
new2 -> xr = x1 - (g_y1 - y2) + lw_tan225;
new2 -> yb = y2 - line_width;
new2 -> yt = y2;
new1 -> xl = new2 -> xr;
new1 -> yb = new2 -> yb;
new1 -> xr = x1;
new1 -> yt = g_y1;
}
else {
last_la_elmt -> gtype |= LA_G_XR;
last_la_elmt -> xr += lw_tan225;
new1 -> gtype = LA_SB_P;
new2 -> gtype = LA_G_XL;
new2 -> xl = x1 + (g_y1 - y2);
new2 -> xr = x2;
new2 -> yb = y2;
new2 -> yt = y2 + line_width;
new1 -> xl = new2 -> xl;
new1 -> yb = y2;
new1 -> xr = last_la_elmt -> xr;
new1 -> yt = last_la_elmt -> yt;
}
}
else { /* y2 >= g_y1 */
if (prev_grow >= 0) {
last_la_elmt -> gtype |= LA_G_XR;
new1 -> gtype = LA_SB_N;
new2 -> gtype = LA_G_XL;
new2 -> xl = x1 + (y2 - g_y1) - lw_tan225;
new2 -> xr = x2;
new2 -> yb = y2;
new2 -> yt = y2 + line_width;
new1 -> xl = x1;
new1 -> yb = g_y1;
new1 -> xr = new2 -> xl;
new1 -> yt = new2 -> yt;
}
else {
last_la_elmt -> gtype |= LA_G_XL;
last_la_elmt -> xl -= lw_tan225;
new1 -> gtype = LA_SB_P;
new2 -> gtype = LA_G_XR;
new2 -> xl = x2;
new2 -> xr = x1 - (y2 - g_y1);
new2 -> yb = y2 - line_width;
new2 -> yt = y2;
new1 -> xl = last_la_elmt -> xl;
new1 -> yb = last_la_elmt -> yb;
new1 -> xr = new2 -> xr;
new1 -> yt = y2;
}
}
prev_grow = x2 - x1;
dir_flag = 1;
}
else { /* SY */
x2 = $6; y2 = $8;
if (y2 < g_y1) {
new2 -> gtype = LA_G_YT;
new2 -> xl = x2;
new2 -> xr = x2 + line_width;
new2 -> yb = y2;
if (prev_grow <= 0) {
last_la_elmt -> gtype |= LA_G_XL;
new1 -> gtype = LA_SB_N;
new2 -> yt = g_y1 - (x1 - x2);
new1 -> xl = x2 + lw_hsqrt2;
new1 -> yb = new2 -> yt - lw_hsqrt2;
new1 -> xr = x1;
new1 -> yt = g_y1;
}
else {
last_la_elmt -> gtype |= LA_G_XR;
last_la_elmt -> xr += lw_tan225;
new1 -> gtype = LA_SB_P;
new2 -> yt = g_y1 - (x2 - x1) + lw_tan225;
new1 -> xl = new2 -> xr - lw_hsqrt2;
new1 -> yb = new2 -> yt - lw_hsqrt2;
new1 -> xr = last_la_elmt -> xr;
new1 -> yt = last_la_elmt -> yt;
}
}
else { /* y2 >= g_y1 */
new2 -> gtype = LA_G_YB;
new2 -> xl = x2 - line_width;
new2 -> xr = x2;
new2 -> yt = y2;
if (prev_grow >= 0) {
last_la_elmt -> gtype |= LA_G_XR;
new1 -> gtype = LA_SB_N;
new2 -> yb = g_y1 + (x2 - x1);
new1 -> xl = x1;
new1 -> yb = g_y1;
new1 -> xr = x2 - lw_hsqrt2;
new1 -> yt = new2 -> yb + lw_hsqrt2;
}
else {
last_la_elmt -> gtype |= LA_G_XL;
last_la_elmt -> xl -= lw_tan225;
new1 -> gtype = LA_SB_P;
new2 -> yb = g_y1 + (x1 - x2) - lw_tan225;
new1 -> xl = last_la_elmt -> xl;
new1 -> yb = last_la_elmt -> yb;
new1 -> xr = new2 -> xl + lw_hsqrt2;
new1 -> yt = new2 -> yb + lw_hsqrt2;
}
}
prev_grow = y2 - g_y1;
dir_flag = 0;
}
}
last_la_elmt -> next = new1;
new1 -> next = new2;
new2 -> next = NULL;
last_la_elmt = new2;
x1 = x2; g_y1 = y2;
}
}
;
direction : X { $$ = 0; }
| Y { $$ = 1; }
;
poly_pattern : POLY '(' masklist ',' start_pair coordi_pairs ')'
{
if (pat_key)
sort_ins_edge (start_x, y_previous, start_y, RIGHT);
}
;
start_pair : coord ',' coord
{
start_x = $1; start_y = y_previous = $3;
}
;
coordi_pairs : /* empty */
| coordi_pairs ',' coord_pair
;
coord_pair : coord ',' coord
{
if (pat_key)
sort_ins_edge ($1, y_previous, $3, RIGHT);
y_previous = $3;
}
;
text_pattern : TEXT '(' MASKNAME ',' coord ',' STRING ')'
{
masknr = getmaskname (words[$3]);
if (masknr < 0 || !layset[masknr]) {
pr_err2 ("error: unknown mask:", words[$3]);
killpattern ();
}
if (pat_key) {
nroflistmasks = 1;
mlist[0][0] = masknr;
mlist[0][1] = 0;
proc_text ($5, words[$7]);
}
}
;
slanting_pattern: rs_pattern placement
{
if (pat_key)
pr_rs_pattern ();
}
| polygon_pattern placement
{
if (pat_key)
pr_po_pattern ();
}
| path_pattern placement
{
if (pat_key)
pr_pa_pattern ();
}
| circle_pattern placement
{
if (pat_key)
pr_ci_pattern ();
}
| cpeel_pattern placement
{
if (pat_key)
pr_cp_pattern ();
}
;
rs_pattern : TOK_RS '(' masklist
',' coord ',' coord ',' coord ',' coord ')'
{
p_x[0] = $5; p_y[0] = $7;
p_x[1] = $9; p_y[1] = $11;
}
;
polygon_pattern : POLYGON '(' masklist startpoint pointlist ')'
{
if (p_incr > 50) {
pr_err1 ("error: polygon: more than 50 increments");
killpattern ();
}
else {
if (p_x[p_incr] != p_x[0] || p_y[p_incr] != p_y[0]) {
pr_err1 ("error: polygon: endpoint not equal to startpoint");
P_E "%s: polygon: endpoint is (%s",
argv0, d2a (p_x[p_incr]));
P_E ",%s)\n", d2a (p_y[p_incr]));
killpattern ();
}
}
}
;
startpoint : ',' coord ',' coord
{
p_nr = p_incr = 0;
p_x[p_incr] = $2;
p_y[p_incr] = $4;
}
;
pointlist : edgepoint
| pointlist edgepoint
;
edgepoint : ',' ABSOLUTE ',' coord ',' coord
{
if (++p_incr <= 50) {
p_x[p_incr] = $4;
p_y[p_incr] = $6;
}
}
| ',' RELATIVE ',' coord ',' coord
{
if (++p_incr <= 50) {
p_x[p_incr] = p_x[p_incr-1] + $4;
p_y[p_incr] = p_y[p_incr-1] + $6;
}
}
;
path_pattern : PATH '(' masklist startpoint pathptlist ')'
{
if (p_mode) {
upd_path_coords (0);
}
}
;
pathptlist : pathpoint
{
p_mode = $1;
if (p_mode == 0 || p_mode == 3) {
pr_err1 ("syntax error: path: missing a or r");
killpattern ();
p_mode = 0;
}
}
| pathptlist pathpoint
{
if (p_mode) {
if ($2 == 0) {
if (p_nr > 4 || (p_nr > 2 && p_mode == 3)) {
pr_err1 ("syntax error: path: missing a or r");
killpattern ();
p_mode = 0;
}
}
else {
upd_path_coords ($2);
}
}
}
;
pathpoint : ',' coord { $$ = 0; if (++p_nr <= 4) p_arr[p_nr] = $2; }
| ',' ABSOLUTE { $$ = 1; }
| ',' RELATIVE { $$ = 2; }
| ',' TEST { $$ = 3; }
;
circle_pattern : CIRCLE '(' masklist ',' coord ',' coord ',' coord opt_n ')'
{
p_x[0] = $5;
p_y[0] = $7;
p_x[1] = $9;
if (p_x[1] < 0) {
pr_err2 ("error: circle: illegal radius:", d2a (p_x[1]));
killpattern ();
}
}
;
cpeel_pattern : CPEEL '(' masklist ',' coord ',' coord
',' coord ',' coord ',' angle ',' angle opt_n ')'
{
p_x[0] = $5;
p_y[0] = $7;
if ($11 < $9) {
p_x[1] = $9; p_y[1] = $11;
}
else {
p_x[1] = $11; p_y[1] = $9;
}
if (p_y[1] < 0) {
pr_err1 ("error: cpeel: radius less than zero");
killpattern ();
}
p_x[2] = $13;
p_y[2] = $15;
if (p_y[2] == p_x[2]) {
pr_err1 ("error: cpeel: angles are equal");
killpattern ();
}
}
;
opt_n : /* empty */ { n_edges = 32; }
| ',' integer
{
n_edges = $2;
if (n_edges < 0 || n_edges > 32000) {
pr_err1i ("error: circle/cpeel: illegal n:", n_edges);
killpattern ();
}
else {
n_edges /= 8;
n_edges *= 8;
if (n_edges > 96) n_edges = 96;
else if (n_edges < 8) n_edges = 8;
if (n_edges != $2)
pr_err1i ("warning: circle/cpeel: n set to:",
n_edges);
}
}
;
pat_call : patname tplacement
{
if (t_nr)
pr_err1 ("warning: T[123] special processing not implemented");
if (pat_key) {
if (!check_tree (words[$1])) {
/* pattern name missing */
pr_err ("error: pattern", mpn (words[$1]),
"is not defined");
killpattern ();
}
else {
if (!tree_ptr -> correct) {
pr_err ("error: pattern", mpn (words[$1]),
"defined but not placed");
killpattern ();
}
if (pat_key) pr_pat_call (words[$1]);
}
}
}
;
functioncall : REMOVE '(' patname ')'
{
if (!check_tree (words[$3])) {
/* pattern name missing */
pr_err2 ("error: unknown pattern:", words[$3]);
killpattern ();
}
else {
if (!tree_ptr -> correct) {
pr_err ("error: pattern", mpn (words[$3]),
"defined but not placed");
killpattern ();
}
}
if (pat_key) {
fflush (fpmc -> dmfp); fflush (fpbox -> dmfp);
get_pattern (words[$3], edges2, tree_ptr -> impcell);
get_pattern (pat_name, edges1, (IMPCELL *)0);
dmCloseStream (fpbox, COMPLETE);
dmCloseStream (fpmc, COMPLETE);
fpbox = dmOpenStream (pat_key, "box", "w");
fpmc = dmOpenStream (pat_key, "mc", "w");
clean_bb ();
invert_edges (edges2);
mix_and_scan_and_grow (1, 0);
mk_all_boxes_of_edges ();
rm_array (edges1);
edgeptr = mostleft = mostright = NULL;
}
}
| TRANSFER '(' MASKNAME ',' patname opt_grow ')'
{
masknr = getmaskname (words[$3]);
if (masknr < 0 || !layset[masknr]) {
pr_err2 ("error: unknown mask:", words[$3]);
killpattern ();
}
if (!check_tree (words[$5])) {
/* pattern name missing */
pr_err2 ("error: unknown pattern:", words[$5]);
killpattern ();
}
else {
if (!tree_ptr -> correct) {
pr_err ("error: pattern", mpn (words[$5]),
"defined but not placed");
killpattern ();
}
}
if (pat_key) {
fflush (fpbox -> dmfp); fflush (fpmc -> dmfp);
get_pattern (words[$5], edges1, tree_ptr -> impcell);
get_pattern (pat_name, edges2, (IMPCELL *)0);
mix_and_scan_and_grow (2, $6);
mk_mask_boxes_of_edges (masknr);
rm_array (edges1);
edgeptr = mostleft = mostright = NULL;
}
}
| EXTRACT '(' patname ',' patname ')'
{
struct ptree *t;
if (!check_tree (words[$3])) {
/* pattern name missing */
pr_err2 ("error: unknown pattern:", words[$3]);
killpattern ();
}
else {
if (!tree_ptr -> correct) {
pr_err ("error: pattern", mpn (words[$3]),
"defined but not placed");
killpattern ();
}
}
t = tree_ptr;
if (!check_tree (words[$5])) {
/* pattern name missing */
pr_err2 ("error: unknown pattern:", words[$5]);
killpattern ();
}
else {
if (!tree_ptr -> correct) {
pr_err ("error: pattern", mpn (words[$5]),
"defined but not placed");
killpattern ();
}
}
if (pat_key) {
get_pattern (words[$3], edges1, t -> impcell);
get_pattern (words[$5], edges2, tree_ptr -> impcell);
mix_and_scan_and_grow (2, 0);
mk_all_boxes_of_edges ();
rm_array (edges1);
edgeptr = mostleft = mostright = NULL;
}
}
| FORMMASK MASKNAME
'(' MASKNAME opt_not operator MASKNAME opt_not ')'
{
dest_mask = getmaskname (words[$2]);
if (dest_mask < 0 || !layset[dest_mask]) {
pr_err2 ("error: unknown mask:", words[$2]);
killpattern ();
}
src1_mask = getmaskname (words[$4]);
if (src1_mask < 0 || !layset[src1_mask]) {
pr_err2 ("error: unknown mask:", words[$4]);
killpattern ();
}
src2_mask = getmaskname (words[$7]);
if (src2_mask < 0 || !layset[src2_mask]) {
pr_err2 ("error: unknown mask:", words[$7]);
killpattern ();
}
if (pat_key) {
fflush (fpmc -> dmfp); fflush (fpbox -> dmfp);
get_pattern (pat_name, edges1, (IMPCELL *)0);
edgeptr = mostleft = mostright = NULL;
if ($5) {
for (fmptr = edges1[1][src1_mask]; fmptr; fmptr = fmptr->rnext)
sort_ins_edge (fmptr->x, fmptr->ybottom,
fmptr->ytop, -fmptr->bodybit);
}
else {
for (fmptr = edges1[1][src1_mask]; fmptr; fmptr = fmptr->rnext)
sort_ins_edge (fmptr->x, fmptr->ybottom,
fmptr->ytop, fmptr->bodybit);
}
if ($8) {
for (fmptr = edges1[1][src2_mask]; fmptr; fmptr = fmptr->rnext)
sort_ins_edge (fmptr->x, fmptr->ybottom,
fmptr->ytop, -fmptr->bodybit);
}
else {
for (fmptr = edges1[1][src2_mask]; fmptr; fmptr = fmptr->rnext)
sort_ins_edge (fmptr->x, fmptr->ybottom,
fmptr->ytop, fmptr->bodybit);
}
if ($5 || $8 || $6 == 1)
scan_edges (1);
else
scan_edges (2);
if (src1_mask == dest_mask && $6 == 2) {
dmCloseStream (fpbox, COMPLETE);
dmCloseStream (fpmc, COMPLETE);
fpbox = dmOpenStream (pat_key, "box", "w");
fpmc = dmOpenStream (pat_key, "mc", "w");
clean_bb ();
for (fmptr = edges1[1][dest_mask]; fmptr; fmptr = fmptr->rnext)
{
fmptr -> list = fr_edge_structs;
fr_edge_structs = fmptr;
}
setarraytoptr (edges1, dest_mask);
mk_all_boxes_of_edges ();
edgeptr = mostleft = mostright = NULL;
}
else {
masknr = dest_mask;
mk_boxes_of_edges ();
for (edgeptr = mostleft; edgeptr; edgeptr = edgeptr->rnext)
free_edge (edgeptr);
}
rm_array (edges1);
}
}
| GROW '(' MASKNAME ',' coord ')'
{
masknr = getmaskname (words[$3]);
if (masknr < 0 || !layset[masknr]) {
pr_err2 ("error: unknown mask:", words[$3]);
killpattern ();
}
if (pat_key) {
fflush (fpbox -> dmfp); fflush (fpmc -> dmfp);
get_pattern (pat_name, edges1, (IMPCELL *)0);
setedgeptrto (edges1, masknr);
grow ($5);
setarraytoptr (edges1, masknr);
if ($5 < 0) {
dmCloseStream (fpbox, COMPLETE);
dmCloseStream (fpmc, COMPLETE);
fpbox = dmOpenStream (pat_key, "box", "w");
fpmc = dmOpenStream (pat_key, "mc", "w");
clean_bb ();
mk_all_boxes_of_edges ();
}
else
mk_boxes_of_edges ();
rm_array (edges1);
edgeptr = mostleft = mostright = NULL;
}
}
;
opt_not : /* empty */ { $$ = 0; }
| '(' NOT ')' { $$ = 1; }
;
operator : AND { $$ = 2; }
| OR { $$ = 1; }
;
opt_grow : /* empty */ { $$ = 0; }
| ',' coord { $$ = $2; }
;
masksdef : MASKS
{
for (masknr = 0; masknr < nrofmasks; ++masknr) {
layset[masknr] = 0; /* off */
}
for (listptr = mlistnames; listptr; ) {
newlistptr = listptr -> next;
FREE (listptr);
listptr = newlistptr;
}
mlistnames = NULL;
}
mask_names
;
mask_names : maskname
| mask_names ',' maskname
;
maskname : MASKNAME
{
masknr = getmaskname (words[$1]);
if (masknr < 0) {
pr_err2 ("error: unknown mask:", words[$1]);
}
else {
layset[masknr] = 1; /* on */
}
}
| error
{
pr_err2 ("error: illegal mask name:", textval());
}
;
mlistsdef : MASKLIST ml_defs
;
ml_defs : ml_def
| ml_defs ',' ml_def
;
ml_def : MASKNAME
{
mlistdef = 1;
newlistptr = NULL;
masknr = getmaskname (words[$1]);
if (masknr >= 0 && layset[masknr]) {
pr_err ("error:", words[$1],
"already used as mask name");
}
else if (getlistname (words[$1])) {
pr_err ("error:", words[$1],
"already used as masklist name");
}
else {
ALLOC_STRUCT (newlistptr, list);
strcpy (newlistptr->name, words[$1]);
newlistptr->next = NULL;
if (!mlistnames) {
mlistnames = newlistptr;
}
else {
endlistptr->next = newlistptr;
}
endlistptr = newlistptr;
}
}
'(' masklist ')'
{
if (newlistptr) {
for (masknr = 0; masknr < nroflistmasks; ++masknr) {
newlistptr->element[masknr][0] = mlist[masknr][0];
newlistptr->element[masknr][1] = mlist[masknr][1];
}
newlistptr->nrofelements = nroflistmasks;
}
mlistdef = 0;
}
| error
{
mlistdef = 0;
}
;
masklist : MASKNAME
{
mlistflag = 0;
mlist[0][0] = -1;
mlist[0][1] = 0;
nroflistmasks = 1;
masknr = getmaskname (words[$1]);
if (masknr >= 0 && layset[masknr]) {
mlist[0][0] = masknr;
}
else {
if (!mlistdef && (listptr = getlistname (words[$1]))) {
++mlistflag;
nroflistmasks = listptr->nrofelements;
for (masknr = 0; masknr < nroflistmasks; ++masknr) {
mlist[masknr][0] = listptr->element[masknr][0];
mlist[masknr][1] = listptr->element[masknr][1];
if (mlist[masknr][0] < 0) {
pr_err2 ("error: unknown mask in masklist:", words[$1]);
killpattern ();
break;
}
}
}
else {
pr_err2 ("error: unknown mask:", words[$1]);
if (!mlistdef) killpattern ();
}
}
}
| masklist ',' MASKNAME ',' coord
{
if (mlistflag) {
pr_err2 ("error: masklist should only contain one",
"masklist name or one or more mask names");
killpattern ();
}
else {
mlist[nroflistmasks][0] = -1;
mlist[nroflistmasks][1] = $5;
masknr = getmaskname (words[$3]);
if (masknr >= 0 && layset[masknr]) {
mlist[nroflistmasks][0] = masknr;
}
else {
pr_err2 ("error: unknown mask:", words[$3]);
if (!mlistdef) killpattern ();
}
++nroflistmasks;
}
}
;
commands : MASKEY
{
P_E "== basic mask list ==\n nr: ");
for (masknr = -1; ++masknr < nrofmasks;)
P_E "%-4d", masknr);
P_E "\ncmk: ");
for (masknr = -1; ++masknr < nrofmasks;)
P_E "%-4s", cmklay[masknr]);
P_E "\nldm: ");
for (masknr = -1; ++masknr < nrofmasks;)
P_E "%-4s", ldmlay[masknr]);
P_E "\nset: ");
for (masknr = -1; ++masknr < nrofmasks;)
P_E "%-4d", layset[masknr]);
P_E "\n\n");
for (listptr = mlistnames; listptr;) {
P_E "== masklist: %s ==\nmsknr:", listptr->name);
for (masknr = -1; ++masknr < listptr->nrofelements;)
P_E "%4d", listptr->element[masknr][0]);
P_E "\ndelta:");
for (masknr = -1; ++masknr < listptr->nrofelements;)
P_E "%4d", listptr->element[masknr][1]);
P_E "\n\n");
listptr = listptr -> next;
}
}
;
tplacement :
{
t_nr = 0;
mirrorflag = rotateflag = 0;
x_origin = y_origin = 0;
cxnumber = cynumber = 0;
}
tplac_ment
;
placement :
{
mirrorflag = rotateflag = 0;
x_origin = y_origin = 0;
cxnumber = cynumber = 0;
}
plac_ment
;
tplac_ment : t_item
| t_item ',' p_rest1
| p_rest1
| /* empty */
| error
{
pr_err1 ("error: illegal placement statement");
killpattern ();
}
;
plac_ment : mirror
| mirror ',' p_rest2
| p_rest2
| /* empty */
| error
{
pr_err1 ("error: illegal placement statement");
killpattern ();
}
;
p_rest1 : mirror
| mirror ',' p_rest2
| p_rest2
;
p_rest2 : rotate
| rotate ',' p_rest3
| p_rest3
;
p_rest3 : origin
| origin ',' p_rest4
| p_rest4
;
p_rest4 : copyx
| copyx ',' copyy
| copyy
;
t_item : T1 { t_nr = 1; }
| T2 { t_nr = 2; }
| T3 { t_nr = 3; }
;
mirror : MX { mirrorflag = 1; }
| MY { mirrorflag = -1; }
;
rotate : ROTATE integer
{
rotateflag = $2;
switch (rotateflag) {
case 0: break;
case 90: break;
case 180: break;
case 270: break;
default:
pr_err1i ("error: illegal rotation angle:", rotateflag);
killpattern ();
}
}
| ROT0 { rotateflag = 0; }
| ROT90 { rotateflag = 90; }
| ROT180 { rotateflag = 180; }
| ROT270 { rotateflag = 270; }
;
origin : coord ',' coord
{
x_origin = $1; y_origin = $3;
}
;
copyx : CX coord ',' integer
{
cxdistance = $2; cxnumber = $4;
if (cxnumber <= 0) {
if (cxnumber < 0) {
pr_err1 ("error: illegal number of x-copies");
killpattern ();
}
else
pr_err1 ("warning: number of x-copies is 0");
}
}
;
copyy : CY coord ',' integer
{
cydistance = $2; cynumber = $4;
if (cynumber <= 0) {
if (cynumber < 0) {
pr_err1 ("error: illegal number of y-copies");
killpattern ();
}
else
pr_err1 ("warning: number of y-copies is 0");
}
}
;
angle : INTEGER
{
if (yylval < 0 || yylval > 360) {
pr_err1i ("error: cpeel: illegal angle:", yylval);
killpattern ();
}
$$ = 10 * yylval;
}
| FLOAT
{
if (d_f < 0 || d_f > 360) {
pr_err1f ("error: cpeel: illegal angle:", d_f);
killpattern ();
}
d_f = 10 * d_f;
$$ = ROUND (d_f);
d_i = $$;
d_i = d_i - d_f;
if (d_i > 0.0001 || d_i < -0.0001) {
pr_err ("warning: cpeel: angle", d2a (d_f),
"not of correct resolution");
d_i = $$;
pr_err2 ("warning: value rounded to:", d2a (d_i));
}
}
;
coord : INTEGER
{
if (int_res) {
$$ = int_res * yylval;
}
else {
d_f = yylval / resol;
$$ = ROUND (d_f);
d_i = $$;
d_i = d_i - d_f;
if (d_i > 0.0001 || d_i < -0.0001) {
pr_err ("warning: parameter", d2a (d_f),
"not of correct resolution");
d_i = $$;
pr_err2 ("warning: value rounded to:", d2a (d_i));
}
}
}
| FLOAT
{
d_f = d_f / resol;
$$ = ROUND (d_f);
d_i = $$;
d_i = d_i - d_f;
if (d_i > 0.0001 || d_i < -0.0001) {
pr_err ("warning: parameter", d2a (d_f),
"not of correct resolution");
d_i = $$;
pr_err2 ("warning: value rounded to:", d2a (d_i));
}
}
;
integer : INTEGER
{
$$ = yylval;
}
| FLOAT
{
pr_err1f ("error: parameter not integer:", d_f);
killpattern ();
}
;
patname : PATNAME
{
$$ = $1;
for (cp = words[$1]; *cp != '\0'; ++cp) {
if (*cp == '-') *cp = '_';
}
if (cp - words[$1] > DM_MAXNAME) {
words[$1][DM_MAXNAME] = '\0';
pr_err2 ("warning: pattern name truncated to",
mpn (words[$1]));
}
}
;
eol : EOL
{
++yylineno;
wordsindex = 0;
}
;
%%
void upd_path_coords (int new_mode)
{
if (p_nr < 2) {
pr_err1 ("syntax error: path: missing coordinates");
killpattern ();
p_mode = 0;
return;
}
if (p_mode == 3) { /* test only */
if (p_x[p_incr] != p_arr[1] || p_y[p_incr] != p_arr[2]) {
pr_err1 ("error: path: lastpoint not equal to testpoint");
P_E "%s: path: lastpoint is (%s",
argv0, d2a (p_x[p_incr]));
P_E ",%s) ", d2a (p_y[p_incr]));
P_E "testpoint is (%s", d2a (p_arr[1]));
P_E ",%s)\n", d2a (p_arr[2]));
killpattern ();
p_mode = 0;
return;
}
}
else {
if (++p_incr > 50) {
pr_err1 ("error: path: more than 50 edge points");
killpattern ();
p_mode = 0;
return;
}
if (p_incr == 1) {
if (p_nr < 3) {
pr_err1 ("syntax error: path: missing width");
killpattern ();
p_mode = 0;
return;
}
p_width = p_arr[3];
}
switch (p_nr) {
case 4:
if (p_arr[4] != p_width) {
pr_err1 ("path: width change not implemented");
killpattern ();
p_mode = 0;
return;
}
case 3:
if (p_arr[3] != p_width) {
pr_err1 ("path: width change not implemented");
killpattern ();
p_mode = 0;
return;
}
case 2:
if (p_mode == 1) { /* abs */
p_x[p_incr] = p_arr[1];
p_y[p_incr] = p_arr[2];
}
else { /* rel */
p_x[p_incr] = p_x[p_incr-1] + p_arr[1];
p_y[p_incr] = p_y[p_incr-1] + p_arr[2];
}
}
}
p_nr = 0;
p_mode = new_mode;
}
int savename (char *s)
{
char *w;
register int i;
if (wordsindex >= MAXWORDS) {
pr_err1 ("fatal error: word buffer overflow");
die ();
}
w = words[wordsindex];
i = 0;
while (*s && i < DM_MAXNAME) w[i++] = *s++;
w[i] = 0;
return (wordsindex++);
}
void yyerror (char *s)
{
P_E "%s: line %d: %s\n", argv0, yylineno, s);
}
void pr_err1 (char *s1)
{
P_E "%s: line %d: %s\n", argv0, yylineno, s1);
}
void pr_err1i (char *s1, int i)
{
P_E "%s: line %d: %s %d\n", argv0, yylineno, s1, i);
}
void pr_err1f (char *s1, double d)
{
P_E "%s: line %d: %s %g\n", argv0, yylineno, s1, d);
}
void pr_err2 (char *s1, char *s2)
{
P_E "%s: line %d: %s %s\n", argv0, yylineno, s1, s2);
}
void pr_err (char *s1, char *s2, char *s3)
{
P_E "%s: line %d: %s %s %s\n", argv0, yylineno, s1, s2, s3);
}
int yywrap ()
{
return (1);
}
|
%{
#include <stdio.h>
#include <stdlib.h>
#include "assembler.h"
#include "string.h"
#include "instruction.h"
#define YYDEBUG 1
extern int yylex();
extern int yyparse();
extern FILE* yyin;
extern int yyline;
void yyerror(FILE * output_file, const char* s);
void my_memcpy(void*,void*,size_t);
%}
%union{
char* sval;
struct _GList* list;
int ival;
struct _Instruction* instr;
struct _OP* op;
struct _Addr* addr;
}
%error-verbose
%token COMMA NEWLINE LBRACKET RBRACKET DIRECTIVE_WORD BYTE_FLAG PLUS COLON DIRECTIVE_ASCIZ DIRECTIVE_ASCII
%token DIRECTIVE_GLOBAL DIRECTIVE_BYTE DIRECTIVE_DWORD DIRECTIVE_ALIGN
%token <op> OPCODE
%token <ival> CONDITION_CODE
%token <sval> IDENTIFIER LABEL STRING
%token <ival> REGISTER IMMEDIATE CP_REGISTER NUMBER BACK_REFERENCE FORWARD_REFERENCE LOCAL_LABEL
%type <instr> instruction
%type <list> program
%type <addr> address
%type <sval> global_label
%parse-param {FILE* output_file}
%start start
%%
start: program {process_list($1, output_file);};
program:
program instruction{$$=g_list_append($$, $2);}
|program NEWLINE {$$=$1;}
| {$$=NULL;}
;
address:
IMMEDIATE {$$=addr_from_immediate($1);}
| IDENTIFIER {$$=addr_from_label($1);}
| NUMBER {$$=addr_from_immediate($1);}
| BACK_REFERENCE {$$=addr_from_reference($1,0);}
| FORWARD_REFERENCE {$$=addr_from_reference($1,1);}
;
global_label:
DIRECTIVE_GLOBAL LABEL {$$=$2;}
| DIRECTIVE_GLOBAL NEWLINE LABEL {$$=$3;}
;
//Instruction* new_instrution_memi(OP* op, int rD, int rS, int immediate, bool byte, bool displacement);
instruction:
OPCODE NEWLINE{$$=new_instruction($1);}
| OPCODE REGISTER NEWLINE {
if($1->type == JMP ){
$$=new_instruction_jmp($1,$2,AL);
}else{
$$=new_instruction_r($1,$2);
}
}
| OPCODE REGISTER COMMA REGISTER NEWLINE{$$=new_instruction_rr($1,$2,$4);}
| OPCODE REGISTER COMMA address NEWLINE{$$=new_instruction_ri($1,$2,$4);}
| OPCODE address COMMA REGISTER NEWLINE{$$=new_instruction_ri($1,$4,$2);}
| OPCODE REGISTER COMMA CP_REGISTER NEWLINE{$$=new_instruction_rc($1,$2,$4);}
| OPCODE CP_REGISTER COMMA REGISTER NEWLINE{$$=new_instruction_rc($1,$4,$2);}
| OPCODE REGISTER COMMA LBRACKET REGISTER RBRACKET NEWLINE{$$=new_instruction_mem($1,$2,$5,false);}//ld r3,[r4]
| OPCODE LBRACKET REGISTER RBRACKET COMMA REGISTER NEWLINE{$$=new_instruction_mem($1,$6,$3,false);}//st [r4],r3
| OPCODE BYTE_FLAG REGISTER COMMA LBRACKET REGISTER RBRACKET NEWLINE{$$=new_instruction_mem($1,$3,$6,true);}//ld.b r3,[r4]
| OPCODE BYTE_FLAG LBRACKET REGISTER RBRACKET COMMA REGISTER NEWLINE{$$=new_instruction_mem($1,$7,$4,true);}//st.b [r4],r3
| OPCODE REGISTER COMMA LBRACKET address RBRACKET NEWLINE{$$=new_instruction_memi($1,$2,0,$5,false,false);}//ld r3,[23]
| OPCODE LBRACKET address RBRACKET COMMA REGISTER NEWLINE{$$=new_instruction_memi($1,$6,0,$3,false,false);}//st [23], r3
| OPCODE BYTE_FLAG REGISTER COMMA LBRACKET address RBRACKET NEWLINE{$$=new_instruction_memi($1,$3,0,$6,true,false);}//ld.b r3,[23]
| OPCODE BYTE_FLAG LBRACKET address RBRACKET COMMA REGISTER NEWLINE{$$=new_instruction_memi($1,$7,0,$4,true,false);}//st.b [23],r3
| OPCODE REGISTER COMMA LBRACKET REGISTER PLUS address RBRACKET NEWLINE{$$=new_instruction_memi($1,$2,$5,$7,false,true);}
| OPCODE LBRACKET REGISTER PLUS address RBRACKET COMMA REGISTER NEWLINE{$$=new_instruction_memi($1,$8,$3,$5,false,true);}
| OPCODE BYTE_FLAG REGISTER COMMA LBRACKET REGISTER PLUS address RBRACKET NEWLINE{$$=new_instruction_memi($1,$3,$6,$8,true,true);}
| OPCODE BYTE_FLAG LBRACKET REGISTER PLUS address RBRACKET COMMA REGISTER NEWLINE{$$=new_instruction_memi($1,$9,$4,$6,true,true);}
| OPCODE address NEWLINE {$$=new_instruction_jmpi($1,$2,AL);} //jump
| OPCODE CONDITION_CODE address NEWLINE {$$=new_instruction_jmpi($1,$3,$2);}
| OPCODE CONDITION_CODE REGISTER NEWLINE {$$=new_instruction_jmp($1,$3,$2);}
| DIRECTIVE_WORD address NEWLINE{int *i=malloc(sizeof(struct _Addr)); my_memcpy(i,$2,sizeof(struct _Addr));$$=new_instruction_directive(D_WORD,i);}
| DIRECTIVE_BYTE address NEWLINE{int *i=malloc(sizeof(struct _Addr)); my_memcpy(i,$2,sizeof(struct _Addr));$$=new_instruction_directive(D_BYTE,i);}
| DIRECTIVE_DWORD address NEWLINE{int *i=malloc(sizeof(struct _Addr)); my_memcpy(i,$2,sizeof(struct _Addr)); $$=new_instruction_directive(D_DWORD,i);}
| DIRECTIVE_ALIGN NUMBER NEWLINE{int *i=malloc(sizeof(int)); *i = $2; $$=new_instruction_directive(D_ALIGN,i);}
| DIRECTIVE_ASCIZ STRING NEWLINE {$$=new_instruction_directive(D_ASCIZ,$2);}
| DIRECTIVE_ASCII STRING NEWLINE {$$=new_instruction_directive(D_ASCII,$2);}
| LABEL {$$=new_instruction_label(strdup($1),0);}
| LOCAL_LABEL {$$=new_instruction_local_label($1);}
| global_label {$$=new_instruction_label(strdup($1),1);}
;
%%
void my_memcpy(void* dest, void* src, size_t bytes){
memcpy(dest,src,bytes);
}
void yyerror(FILE * output_file, const char* s){
fprintf(stderr, "Parse error on line %d: %s\n",yyline,s);
exit(1);
}
|
<filename>src/ocean/trout/imageparse.y
%{
/*
* ISC License
*
* Copyright (C) 1991-2018 by
* <NAME>
* <NAME>
* Delft University of Technology
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Seadif image parser.
*/
#include "src/ocean/trout/typedef.h"
void yderror (char *s);
int ydlex (void);
/*
* export
*/
extern GRIDPOINTPTR
**CoreFeed, /* matrix of universal feedthroughs in basic image */
**RestrictedCoreFeed; /* matrix of restricted feedthroughs in basic image */
extern int Verbose_parse;
extern long
NumImageTearLine[2], /* number of tearlines in orientation of index (HORIZONTAL/VERTICAL) */
*ImageTearLine[2], /* array containing the coordinates of the tearline of basic image */
Chip_num_layer, /* number of metal layers to be used */
GridRepitition[2], /* repitionvector (dx, dy) of grid core image (in grid points) */
*LayerOrient; /* array of orientations of each layer */
extern POWERLINEPTR
PowerLineList; /* list of template power lines */
extern char *ThisImage; /* Seadif name of this image */
extern GRIDADRESSUNIT xl_chiparea, xr_chiparea, yb_chiparea, yt_chiparea;
extern int ydlineno;
/*
* LOCAL
*/
static long orient, counter;
static long sometoken, bracecount; /* Used for skipping unknown keywords. */
static GRIDPOINTPTR Feedlist;
%}
%union {
int itg;
char str[200];
}
%token <str> STRINGTOKEN
%token <str> NUMBER
%token LBR RBR
%token SEADIFTOKEN
%token LIBRARYTOKEN
%token TECHNOLOGY
%token TECHDESIGNRULES
%token TECHNROFLAYERS
%token TECHWIREORIENT
%token TECHWIREWIDTH
%token TECHWIREMASKNAME
%token TECHVIAMASKNAME
%token TECHVIACELLNAME
%token IMAGEDESCRIPTION
%token CHIPDESCRIPTION
%token CHIPIMAGEREF
%token CHIPSIZE
%token CHIPROUTINGAREA
%token CIRCUITIMAGE
%token LAYOUTIMAGE
%token LAYOUTMODELCALL
%token LAYOUTIMAGEREPITITION
%token LAYOUTIMAGEPATTERN
%token LAYOUTIMAGEPATTERNLAYER
%token RECTANGLE
%token GRIDIMAGE
%token GRIDSIZE
%token GRIDMAPPING
%token GRIDTEARLINE
%token GRIDPOWERLINE
%token GRIDCONNECTLIST
%token GRIDBLOCK
%token RESTRICTEDFEED
%token UNIVERSALFEED
%token FEED
%token GRIDCOST
%token FEEDCOST
%token GRIDCOSTLIST
%token STATUSTOKEN
%token WRITTEN
%token TIMESTAMP
%token AUTHOR
%token PROGRAM
%token COMMENT
%start Seadif
%%
Seadif : LBR SEADIFTOKEN SeadifFileName _Seadif RBR
/* EdifVersion, EdifLevel and KeywordMap skipped */
;
SeadifFileName : STRINGTOKEN { }
;
_Seadif : /* nothing */
| _Seadif Library
| _Seadif Chip
| _Seadif Image
| _Seadif Status
| _Seadif Comment
| _Seadif UserData
;
/*
* Chip description
*/
Chip : LBR CHIPDESCRIPTION ChipNameDef _Chip RBR
;
/*
* ascii name of chip
*/
ChipNameDef : STRINGTOKEN { }
;
_Chip :
| _Chip Status
| _Chip ChipImageRef
| _Chip ChipSize
| _Chip ChipRoutingArea
| _Chip Comment
| _Chip UserData
;
ChipImageRef : LBR CHIPIMAGEREF STRINGTOKEN RBR
;
ChipSize : LBR CHIPSIZE NUMBER NUMBER RBR
;
ChipRoutingArea : LBR CHIPROUTINGAREA NUMBER NUMBER NUMBER NUMBER RBR
{
xl_chiparea = (GRIDADRESSUNIT)atol($3);
xr_chiparea = (GRIDADRESSUNIT)atol($4);
yb_chiparea = (GRIDADRESSUNIT)atol($5);
yt_chiparea = (GRIDADRESSUNIT)atol($6);
}
;
/*
* Imagedescription
*/
Image : LBR IMAGEDESCRIPTION ImageNameDef _Image RBR
;
/*
* ImageDescription/ImageNameDef
* ascii name of image
*/
ImageNameDef : STRINGTOKEN { ThisImage = cs($1); }
;
_Image :
| _Image Technology
| _Image Status
| _Image CircuitImage
| _Image GridImage
| _Image LayoutImage
| _Image Comment
| _Image UserData
;
/*
* (library or Image)/technology description
*/
Technology : LBR TECHNOLOGY _Technology RBR
;
_Technology : STRINGTOKEN { } /* currently not used */
| _Technology DesignRules
| _Technology Comment
| _Technology UserData
;
/*
* Technology/designrules
*/
DesignRules : LBR TECHDESIGNRULES _DesignRules RBR
;
_DesignRules : TechNumLayer /* number of layers before others */
| _DesignRules TechLayOrient
| _DesignRules TechWireWidth
| _DesignRules TechWireMask
| _DesignRules TechViaMask
| _DesignRules TechViaCellName
| _DesignRules Comment
| _DesignRules UserData
;
/*
* Designrules/numlayer: number of metal layers,
* In this routine a number of arrays are allocated
*/
TechNumLayer : LBR TECHNROFLAYERS NUMBER RBR
{
allocate_layer_arrays (atol($3));
}
;
/*
* declares the orientation of a layer
*/
TechLayOrient : LBR TECHWIREORIENT NUMBER STRINGTOKEN RBR
{
if (atol($3) < 0 || atol($3) >= Chip_num_layer)
yderror ("Illegal layer index for orient");
else {
switch ($4[0]) {
case 'h': case 'H': case 'x': case 'X':
LayerOrient[atol($3)] = HORIZONTAL;
break;
case 'v': case 'V': case 'y': case 'Y':
LayerOrient[atol($3)] = VERTICAL;
break;
default:
yderror ("warning: Unknown orientation for layerorient");
}
}
}
;
/*
* declares wire width in a layer
*/
TechWireWidth : LBR TECHWIREWIDTH NUMBER NUMBER RBR
{
}
;
/*
* declares mask name of a layer
*/
TechWireMask : LBR TECHWIREMASKNAME NUMBER STRINGTOKEN RBR
{
}
;
/*
* declares the mask name of a via
*/
TechViaMask : LBR TECHVIAMASKNAME NUMBER NUMBER STRINGTOKEN RBR
{
}
;
/*
* declares the cell name of a via
*/
TechViaCellName : LBR TECHVIACELLNAME NUMBER NUMBER STRINGTOKEN RBR
{
}
;
/*
* Image/CircuitImage
* Currently not implemented
*/
CircuitImage : LBR CIRCUITIMAGE /* anything RBR */
{
bracecount = 1;
while (bracecount > 0)
if ((sometoken = ydlex ()) == LBR)
++bracecount;
else if (sometoken == RBR)
--bracecount;
/* printf ("CircuitImage\n"); */
}
;
/*
* Image/LayoutImage
*/
LayoutImage : LBR LAYOUTIMAGE _LayoutImage RBR
;
_LayoutImage :
| _LayoutImage LayModelCall
| _LayoutImage LayImageRep
| _LayoutImage LayImagePat
| _LayoutImage Comment
| _LayoutImage UserData
;
LayModelCall : LBR LAYOUTMODELCALL STRINGTOKEN RBR
{ /* store image name */
}
;
LayImageRep : LBR LAYOUTIMAGEREPITITION NUMBER NUMBER RBR
{ /* store repititions */
}
;
LayImagePat : LBR LAYOUTIMAGEPATTERN _LayImagePat RBR
;
_LayImagePat :
| _LayImagePat LayImPatLay
| _LayImagePat Comment
| _LayImagePat UserData
;
LayImPatLay : LBR LAYOUTIMAGEPATTERNLAYER STRINGTOKEN _LayImPatLay RBR
;
_LayImPatLay :
| _LayImPatLay Rectangle
| _LayImPatLay Comment
| _LayImPatLay UserData
;
Rectangle : LBR RECTANGLE NUMBER NUMBER NUMBER NUMBER RBR
;
/*
* Image/GridImage
* Interesting
*/
GridImage : LBR GRIDIMAGE _GridImage RBR
;
_GridImage : GridSize
| _GridImage GridConnectList
| _GridImage GridCostList
| _GridImage Comment
| _GridImage UserData
;
/*
* specifies size of the basic grid
*/
GridSize : LBR GRIDSIZE GridBbx _GridSize RBR
;
GridBbx : NUMBER NUMBER /* dimensions to allocate */
{
if (GridRepitition[X] > 0) {
yderror ("redeclaration of GridSize");
error (FATAL_ERROR, "parser");
}
GridRepitition[X] = atol($1);
GridRepitition[Y] = atol($2);
// allocate lots of global array related to the image size
allocate_core_image (atol($1), atol($2));
orient = -1;
}
;
_GridSize :
| _GridSize GridMapping
| _GridSize GridTearLine
| _GridSize GridPowerLine
| _GridSize Comment
| _GridSize UserData
;
/* mapping of gridpositions to layoutpositions */
GridMapping : LBR GRIDMAPPING GridMapOrient _GridMapping RBR
{
}
;
GridMapOrient : STRINGTOKEN /* should specify horizontal of vertical */
{ /* set index */
}
;
_GridMapping :
| _GridMapping NUMBER /* read in number */
{ /* add number to array */
}
;
/* positions of power lines : ( PowerLine <orient> <ident> <layer_no> <row or column number> ) */
GridPowerLine : LBR GRIDPOWERLINE STRINGTOKEN STRINGTOKEN NUMBER NUMBER RBR
{
POWERLINEPTR pline;
/* allocate new, link in list */
NewPowerLine (pline);
if (PowerLineList) pline->next = PowerLineList;
PowerLineList = pline;
/* fill struct: orient */
switch ($3[0]) {
case 'h': case 'H': case 'x': case 'X':
pline->orient = X;
break;
case 'v': case 'V': case 'y': case 'Y':
pline->orient = Y;
break;
default:
yderror ("warning: Powerline has unknown orientation (should be 'horizontal' or 'vertical')");
pline->orient = X;
}
/* fill struct: name */
pline->type = gimme_net_type ($4);
switch (pline->type) {
case VDD:
case VSS: break;
default:
yderror ("WARNING: Powerline has unknown type (should be 'vss' or 'vdd', 'vss' assumed)");
pline->type = VSS;
}
/* fill struct: layer number */
pline->z = atoi($5);
if (pline->z < 0 || pline->z >= Chip_num_layer) {
yderror ("WARNING: Powerline in illegal layer:");
fprintf (stderr, " layer no = %ld (set to 0)\n", pline->z);
pline->z = 0;
}
/* fill struct: row or column number */
pline->x = pline->y = atol($6);
if (pline->x > GridRepitition[opposite(pline->orient)]) {
yderror ("WARNING: row or column coordinate of power line is out or range");
fprintf (stderr, "%ld is size of image, %ld was specified, 0 assumed\n",
GridRepitition[opposite(pline->orient)], pline->x);
pline->x = pline->y = 0;
}
/* printf ("POWER: orient = %d, type = %d, layer = %d, row = %d\n",
(int) pline->orient, (int) pline->type, (int) pline->z, (int) pline->x); */
}
;
/* positions of Tearlines */
GridTearLine : LBR GRIDTEARLINE TearLineOrient _GridTearLine RBR
{
if (counter != NumImageTearLine[orient] && counter >= 0) {
yderror ("warning: incomplete tearline list");
fprintf (stderr, "%ld of the %ld points found\n", counter, GridRepitition[orient]);
NumImageTearLine[orient] = counter;
}
}
;
TearLineOrient : STRINGTOKEN NUMBER /* should specify horizontal of vertical, followed by the number of tearlines */
{ /* set index */
switch ($1[0]) {
case 'h': case 'H': case 'x': case 'X':
orient = X;
break;
case 'v': case 'V': case 'y': case 'Y':
orient = Y;
break;
default:
yderror ("warning: Tearline has unknown orientation (should be 'horizontal' or 'vertical')");
orient = X;
}
if (ImageTearLine[orient]) {
yderror ("warning: redeclaration of tearlines");
fprintf (stderr, "direction '%s' was already declared\n", $1);
}
if ((NumImageTearLine[orient] = atol($2)) < 0) NumImageTearLine[orient] = 0;
if (NumImageTearLine[orient] > GridRepitition[orient]) {
yderror ("warning: possibly too many tearlines for this image");
fprintf (stderr, "%ld is size of image, %ld points are declared. trunctating...\n",
GridRepitition[orient], NumImageTearLine[orient]);
NumImageTearLine[orient] = GridRepitition[orient];
}
CALLOC (ImageTearLine[orient], long, NumImageTearLine[orient]);
counter = 0; /* reset index */
}
;
_GridTearLine :
| _GridTearLine NUMBER /* read in number */
{ /* add number to array */
if (counter >= 0)
{ /* negative indicates out of bounds */
if (counter < NumImageTearLine[orient]) {
ImageTearLine[orient][counter++] = atol($2);
}
else {
yderror ("warning: more tear lines specified than declared");
fprintf (stderr, "should be %ld points; points starting from '%s' ignored\n",
NumImageTearLine[orient], $2);
counter = -1; /* disables further errors */
}
}
}
;
/*
* Define connections/neighbours of grid points
*/
GridConnectList : LBR GRIDCONNECTLIST _GridConnectList RBR
{
/* if ready: link offset arrays */
/* link_feeds_to_offsets(); */
}
;
_GridConnectList :
| _GridConnectList Block
| _GridConnectList RestrictedFeed
| _GridConnectList UniversalFeed
| _GridConnectList Comment
| _GridConnectList UserData
;
Block : LBR GRIDBLOCK NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RBR
{
if (add_grid_block (atol($3), atol($4), atol($5), atol($6), atol($7), atol($8)) == FALSE)
{
yderror ("grid block position outside image");
}
}
;
UniversalFeed : LBR UNIVERSALFEED
{
Feedlist = NULL;
}
_GridFeed RBR
{
if (process_feeds (Feedlist, CoreFeed) == FALSE)
fprintf (stderr, "error was on line %d\n", ydlineno);
}
;
RestrictedFeed : LBR RESTRICTEDFEED
{
Feedlist = NULL;
}
_GridFeed RBR
{
if (process_feeds (Feedlist, RestrictedCoreFeed) == FALSE)
fprintf (stderr, "error was on line %d\n", ydlineno);
}
;
_GridFeed :
| _GridFeed GridFeedRef
| _GridFeed Comment
| _GridFeed UserData
;
GridFeedRef : LBR FEED STRINGTOKEN NUMBER NUMBER RBR
{ GRIDPOINTPTR new_point;
new_point = new_gridpoint (atol($4), atol($5), 0);
new_point -> next = Feedlist;
Feedlist = new_point;
}
;
/*
* declares costs of point
* should be called after GridCOnnectList
*/
GridCostList : LBR GRIDCOSTLIST _GridCostList RBR
{
/* if ready: link offset arrays */
link_feeds_to_offsets ();
}
;
_GridCostList :
| _GridCostList GridCost
| _GridCostList FeedCost
| _GridCostList Comment
| _GridCostList UserData
;
GridCost : LBR GRIDCOST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RBR
{ /* <cost> <vector> <startpoint_range> <endpoint_range> */
if (set_grid_cost (atol($3), atol($4), atol($5), atol($6), atol($7),
atol($8), atol($9), atol($10), atol($11), atol($12)) == FALSE)
yderror ("WARNING: GridCost has no effect, no such offset found on range");
}
;
FeedCost : LBR FEEDCOST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RBR
{ /* <cost> <vector> <startpoint_range> <endpoint_range> */
if (set_feed_cost (atol($3), atol($4), atol($5), atol($6), atol($7),
atol($8), atol($9), atol($10), atol($11), atol($12)) == FALSE)
yderror ("WARNING: FeedCost has no effect, no such offset found on range");
}
;
/*
* Library module
*/
Library : LBR LIBRARYTOKEN anything RBR
;
/*
* BASIC functions
*/
/* status block called on many levels */
Status : LBR STATUSTOKEN _Status RBR
{
/* printf ("Status detected on line %d\n", ydlineno); */
}
;
_Status :
| _Status Written
| _Status Comment
| _Status UserData
;
Written : LBR WRITTEN _Written RBR
;
_Written : TimeStamp
| _Written Author
| _Written Program
/* | _Written DataOrigin not implemented */
/* | _Written Property not implemented */
| _Written Comment
| _Written UserData
;
/* year month day hour minute second */
TimeStamp : LBR TIMESTAMP NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RBR
{
/* printf ("Timestamp detected on line %d: %ld %ld %ld %ld %ld %ld\n",
ydlineno, atol($3), atol($4), atol($5), atol($6), atol($7), atol($8)); */
}
;
Author : LBR AUTHOR anything RBR /* anything should be a string */
{
/* printf ("Author detected on line %d\n", ydlineno); */
}
;
Program : LBR PROGRAM anything RBR /* anything should be a string, followed by a version */
{
/* printf ("Program signature detected on line %d\n", ydlineno); */
}
;
UserData : LBR
{
if (Verbose_parse) printf ("unknown keyword in line %d:", ydlineno);
}
STRINGTOKEN
{
bracecount = 1;
while (bracecount > 0)
if ((sometoken = ydlex ()) == LBR)
++bracecount;
else if (sometoken == RBR)
--bracecount;
if (Verbose_parse) printf (" %s (skipped until line %d)\n", $3, ydlineno);
}
;
Comment : LBR COMMENT
{
bracecount = 1;
while (bracecount > 0)
if ((sometoken = ydlex ()) == LBR)
++bracecount;
else if (sometoken == RBR)
--bracecount;
/* printf ("Comment detected on line %d\n", ydlineno); */
}
;
anything : /* empty */
| anything something
;
something : STRINGTOKEN { }
| NUMBER { }
| LBR anything RBR
;
%%
#include "imagelex.h"
void yderror (char *s)
{
fflush (stdout);
fprintf (stderr, "ERROR (Seadif image file): %s. Try line %d.\n", s, ydlineno);
}
|
<filename>v2/parsv2.y
%{
#include <stdio.h>
#include <stdlib.h>
#include "linkedList.h"
void yyerror(char *s);
int depth = 0;
int add;
char type[20];
char value[20];
char operat[4];
int valueInt;
FILE *fp;
%}
%union
{
char char_val;
int int_val;
double double_val;
char* str_val;
}
%token <int_val> tIF tELSE tTHEN tWHILE tPRINTF tCHAR tMAIN tCONST tINTEGER tSPACE tTAB tBACKSPACE tCOMA tSEMICOLON tGEQ tLEQ tBE tINF tSUP tNEWL tEXPO tCOMMENT
%token <int_val> tVOID tPLUS tMOINS tMULT tDIV tPOW tEQUAL tAND tOR tPOPEN tPCLOSE tAOPEN tACLOSE tCOPEN tCCLOSE tERROR tTRUE tFALSE
%token <double_val> tDEC tAPOS
%token <char_val> tCHARACTER
%token <str_val> tVARNAME tPOINTER tFLOAT tINT
%type <str_val> type
%type <str_val> variable_multiple
%type <int_val> value_variable
%start go
%left tPLUS tMOINS
%left
%%
go
: tMAIN tPOPEN tPCLOSE statement {printf("GO\n");}
| tINT tMAIN tPOPEN tPCLOSE statement {printf("GO\n");}
;
statement
: tAOPEN expression tACLOSE
;
expression
: expression expression
| expression_arithmetic
| iteration_statement
| expression_print
// | expression_fonction
;
/*
expression_fonction
: tVARNAME tPOPEN parameters tPCLOSE statement {printf("fonction\n");}
| tINT tVARNAME tPOPEN parameters tPCLOSE statement {printf("fonction\n");}
|tINT tVARNAME tPOPEN tPCLOSE statement {printf("fonction\n");}
;
parameters
: tINT tVARNAME
| tCHAR tVARNAME
| tINT tVARNAME tCOMA parameters
| tCHAR tVARNAME tCOMA parameters
;
*/
expression_arithmetic
: type tVARNAME tEQUAL tAPOS tVARNAME tAPOS tSEMICOLON
| type variable_multiple tSEMICOLON
{
//printf("%s\n", $1);
}
| variable_multiple tSEMICOLON /* Pour plus tard on rajoutera une boucle qui permettra de succΓ©der plusieurs opΓ©rations*/
| declaration_pointeur tSEMICOLON;
;
declaration_pointeur
: tINT tPOINTER
| tINT tPOINTER tEQUAL tINTEGER
;
expression_print
: tPRINTF tPOPEN tVARNAME tPCLOSE tSEMICOLON
;
/* int a; int a,b,c; int a,b=5,c;*/
type
: tINT
{
$$ = $1;
//printf("%s\n", $1);
strcpy(type, "int");
}
| tCONST
{
//strcpy(type, $1);
}
| tFLOAT
{
//strcpy(type, $1);
}
| tCHAR
{
//strcpy(type, $1);
}
;
variable_multiple
: tVARNAME
| tVARNAME tEQUAL value_variable
{
//depth++;
/* printf("typeeeeee %s\n", type);
printf("varName %s\n", $1);
printf("Value %d\n",valueInt);
printf("Depth %d\n", depth);*/
add = insertNode($1,type,value,0);
printList();
fprintf(fp,"AFC %d %d\n", add, valueInt); // add 0 1 temp
/*printf("teeesst %s\n", yylval.str_val);
insertNode(yylval.str_val,type,depth);
printf("insertioooon %s\n", yylval.str_val);
printList();*/
}
| tVARNAME tEQUAL value_variable tCOMA variable_multiple {printf("%s\n", $1);}
| tVARNAME tEQUAL value_variable operation value_variable
{
printf("%s\n", $1);
fprintf(fp,"AFC %d %d\n", 0, $2); // on veut rΓ©cupΓ©rer la valeur de value variable num 1
//fprintf(fp,"AFC %d %d\n", 1, $4);// on veut rΓ©cupΓ©rer la valeur de value variable num 2
fprintf(fp,operat);
//
fprintf(fp, " %d %d\n",0,1);
}
| tVARNAME tEQUAL value_variable operation value_variable tCOMA variable_multiple {printf("%s\n", $1);}
| tVARNAME tCOMA variable_multiple
;
iteration_statement
: tWHILE conditioner statement
| tIF conditioner statement
| tIF conditioner statement tELSE statement
| tIF conditioner tTHEN statement
;
conditional_expression
: tFALSE
| tTRUE
| value_variable
| value_variable comparator value_variable
| conditional_expression logical_connector conditional_expression
;
/* 1.024 == 2*/
value_variable
: tINTEGER
{
printf("%d\n", yylval.int_val);
valueInt = $1;
printf("value integer %d\n", $1);
sprintf(value,"%d",$1);
$$ = $1;
}
| tVARNAME
{
printf("tVARNAME %s\n", $1);
printf("value integer %d\n", findByID($1));
$$ = $1;
}
| tDEC {printf("%.2f\n", yylval.double_val);}
;
logical_connector
: tAND
| tOR
;
conditioner
: tPOPEN conditional_expression tPCLOSE
;
comparator
: tBE
| tGEQ
| tLEQ
| tINF
| tSUP
;
operation
: tDIV
{
strcpy(operat, "DIV");
}
| tPLUS
{
strcpy(operat, "ADD");
}
/*| tMOINS
| tMULT
| tPOW
| tEXPO*/
;
%%
yyerror(char *s)
{
fprintf(stderr, "%s\n", s);
}
yywrap()
{
return(1);
}
int main(){
fp = fopen("./output/file.txt","w");
printf("Start analysis \n");
yyparse();
fclose(fp);
/* yylex(); */
return(0);
}
|
<gh_stars>0
/********************************************
parse.y
copyright 1991-94, <NAME>
This is a source file for mawk, an implementation of
the AWK programming language.
Mawk is distributed without warranty under the terms of
the GNU General Public License, version 2, 1991.
********************************************/
/* $Log: parse.y,v $
* Revision 1.11 1995/06/11 22:40:09 mike
* change if(dump_code) -> if(dump_code_flag)
* cleanup of parse()
* add cast to shutup solaris cc compiler on char to int comparison
* switch_code_to_main() which cleans up outside_error production
*
* Revision 1.10 1995/04/21 14:20:21 mike
* move_level variable to fix bug in arglist patching of moved code.
*
* Revision 1.9 1995/02/19 22:15:39 mike
* Always set the call_offset field in a CA_REC (for obscure
* reasons in fcall.c (see comments) there.)
*
* Revision 1.8 1994/12/13 00:39:20 mike
* delete A statement to delete all of A at once
*
* Revision 1.7 1994/10/08 19:15:48 mike
* remove SM_DOS
*
* Revision 1.6 1993/12/01 14:25:17 mike
* reentrant array loops
*
* Revision 1.5 1993/07/22 00:04:13 mike
* new op code _LJZ _LJNZ
*
* Revision 1.4 1993/07/15 23:38:15 mike
* SIZE_T and indent
*
* Revision 1.3 1993/07/07 00:07:46 mike
* more work on 1.2
*
* Revision 1.2 1993/07/03 21:18:01 mike
* bye to yacc_mem
*
* Revision 1.1.1.1 1993/07/03 18:58:17 mike
* move source to cvs
*
* Revision 5.8 1993/05/03 01:07:18 mike
* fix bozo in LENGTH production
*
* Revision 5.7 1993/01/09 19:03:44 mike
* code_pop checks if the resolve_list needs relocation
*
* Revision 5.6 1993/01/07 02:50:33 mike
* relative vs absolute code
*
* Revision 5.5 1993/01/01 21:30:48 mike
* split new_STRING() into new_STRING and new_STRING0
*
* Revision 5.4 1992/08/08 17:17:20 brennan
* patch 2: improved timing of error recovery in
* bungled function definitions. Fixes a core dump
*
* Revision 5.3 1992/07/08 15:43:41 brennan
* patch2: length returns. I am a wimp
*
* Revision 5.2 1992/01/08 16:11:42 brennan
* code FE_PUSHA carefully for MSDOS large mode
*
* Revision 5.1 91/12/05 07:50:22 brennan
* 1.1 pre-release
*
*/
%{
#include <stdio.h>
#include "mawk.h"
#include "symtype.h"
#include "code.h"
#include "memory.h"
#include "bi_funct.h"
#include "bi_vars.h"
#include "jmp.h"
#include "field.h"
#include "files.h"
#define YYMAXDEPTH 200
extern void PROTO( eat_nl, (void) ) ;
static void PROTO( resize_fblock, (FBLOCK *) ) ;
static void PROTO( switch_code_to_main, (void)) ;
static void PROTO( code_array, (SYMTAB *) ) ;
static void PROTO( code_call_id, (CA_REC *, SYMTAB *) ) ;
static void PROTO( field_A2I, (void)) ;
static void PROTO( check_var, (SYMTAB *) ) ;
static void PROTO( check_array, (SYMTAB *) ) ;
static void PROTO( RE_as_arg, (void)) ;
static int scope ;
static FBLOCK *active_funct ;
/* when scope is SCOPE_FUNCT */
#define code_address(x) if( is_local(x) ) \
code2op(L_PUSHA, (x)->offset) ;\
else code2(_PUSHA, (x)->stval.cp)
#define CDP(x) (code_base+(x))
/* WARNING: These CDP() calculations become invalid after calls
that might change code_base. Which are: code2(), code2op(),
code_jmp() and code_pop().
*/
/* this nonsense caters to MSDOS large model */
#define CODE_FE_PUSHA() code_ptr->ptr = (PTR) 0 ; code1(FE_PUSHA)
%}
%union{
CELL *cp ;
SYMTAB *stp ;
int start ; /* code starting address as offset from code_base */
PF_CP fp ; /* ptr to a (print/printf) or (sub/gsub) function */
BI_REC *bip ; /* ptr to info about a builtin */
FBLOCK *fbp ; /* ptr to a function block */
ARG2_REC *arg2p ;
CA_REC *ca_p ;
int ival ;
PTR ptr ;
}
/* two tokens to help with errors */
%token UNEXPECTED /* unexpected character */
%token BAD_DECIMAL
%token NL
%token SEMI_COLON
%token LBRACE RBRACE
%token LBOX RBOX
%token COMMA
%token <ival> IO_OUT /* > or output pipe */
%right ASSIGN ADD_ASG SUB_ASG MUL_ASG DIV_ASG MOD_ASG POW_ASG
%right QMARK COLON
%left OR
%left AND
%left IN
%left <ival> MATCH /* ~ or !~ */
%left EQ NEQ LT LTE GT GTE
%left CAT
%left GETLINE
%left PLUS MINUS
%left MUL DIV MOD
%left NOT UMINUS
%nonassoc IO_IN PIPE
%right POW
%left <ival> INC_or_DEC
%left DOLLAR FIELD /* last to remove a SR conflict
with getline */
%right LPAREN RPAREN /* removes some SR conflicts */
%token <ptr> DOUBLE STRING_ RE
%token <stp> ID D_ID
%token <fbp> FUNCT_ID
%token <bip> BUILTIN LENGTH
%token <cp> FIELD
%token PRINT PRINTF SPLIT MATCH_FUNC SUB GSUB
/* keywords */
%token DO WHILE FOR BREAK CONTINUE IF ELSE IN
%token DELETE BEGIN END EXIT NEXT RETURN FUNCTION
%type <start> block block_or_separator
%type <start> statement_list statement mark
%type <ival> pr_args
%type <arg2p> arg2
%type <start> builtin
%type <start> getline_file
%type <start> lvalue field fvalue
%type <start> expr cat_expr p_expr
%type <start> while_front if_front
%type <start> for1 for2
%type <start> array_loop_front
%type <start> return_statement
%type <start> split_front re_arg sub_back
%type <ival> arglist args
%type <fp> print sub_or_gsub
%type <fbp> funct_start funct_head
%type <ca_p> call_args ca_front ca_back
%type <ival> f_arglist f_args
%%
/* productions */
program : program_block
| program program_block
;
program_block : PA_block /* pattern-action */
| function_def
| outside_error block
;
PA_block : block
{ /* this do nothing action removes a vacuous warning
from Bison */
}
| BEGIN
{ be_setup(scope = SCOPE_BEGIN) ; }
block
{ switch_code_to_main() ; }
| END
{ be_setup(scope = SCOPE_END) ; }
block
{ switch_code_to_main() ; }
| expr /* this works just like an if statement */
{ code_jmp(_JZ, (INST*)0) ; }
block_or_separator
{ patch_jmp( code_ptr ) ; }
/* range pattern, see comment in execute.c near _RANGE */
| expr COMMA
{
INST *p1 = CDP($1) ;
int len ;
code_push(p1, code_ptr - p1, scope, active_funct) ;
code_ptr = p1 ;
code2op(_RANGE, 1) ;
code_ptr += 3 ;
len = code_pop(code_ptr) ;
code_ptr += len ;
code1(_STOP) ;
p1 = CDP($1) ;
p1[2].op = code_ptr - (p1+1) ;
}
expr
{ code1(_STOP) ; }
block_or_separator
{
INST *p1 = CDP($1) ;
p1[3].op = CDP($6) - (p1+1) ;
p1[4].op = code_ptr - (p1+1) ;
}
;
block : LBRACE statement_list RBRACE
{ $$ = $2 ; }
| LBRACE error RBRACE
{ $$ = code_offset ; /* does nothing won't be executed */
print_flag = getline_flag = paren_cnt = 0 ;
yyerrok ; }
;
block_or_separator : block
| separator /* default print action */
{ $$ = code_offset ;
code1(_PUSHINT) ; code1(0) ;
code2(_PRINT, bi_print) ;
}
statement_list : statement
| statement_list statement
;
statement : block
| expr separator
{ code1(_POP) ; }
| /* empty */ separator
{ $$ = code_offset ; }
| error separator
{ $$ = code_offset ;
print_flag = getline_flag = 0 ;
paren_cnt = 0 ;
yyerrok ;
}
| BREAK separator
{ $$ = code_offset ; BC_insert('B', code_ptr+1) ;
code2(_JMP, 0) /* don't use code_jmp ! */ ; }
| CONTINUE separator
{ $$ = code_offset ; BC_insert('C', code_ptr+1) ;
code2(_JMP, 0) ; }
| return_statement
{ if ( scope != SCOPE_FUNCT )
compile_error("return outside function body") ;
}
| NEXT separator
{ if ( scope != SCOPE_MAIN )
compile_error( "improper use of next" ) ;
$$ = code_offset ;
code1(_NEXT) ;
}
;
separator : NL | SEMI_COLON
;
expr : cat_expr
| lvalue ASSIGN expr { code1(_ASSIGN) ; }
| lvalue ADD_ASG expr { code1(_ADD_ASG) ; }
| lvalue SUB_ASG expr { code1(_SUB_ASG) ; }
| lvalue MUL_ASG expr { code1(_MUL_ASG) ; }
| lvalue DIV_ASG expr { code1(_DIV_ASG) ; }
| lvalue MOD_ASG expr { code1(_MOD_ASG) ; }
| lvalue POW_ASG expr { code1(_POW_ASG) ; }
| expr EQ expr { code1(_EQ) ; }
| expr NEQ expr { code1(_NEQ) ; }
| expr LT expr { code1(_LT) ; }
| expr LTE expr { code1(_LTE) ; }
| expr GT expr { code1(_GT) ; }
| expr GTE expr { code1(_GTE) ; }
| expr MATCH expr
{
INST *p3 = CDP($3) ;
if ( p3 == code_ptr - 2 )
{
if ( p3->op == _MATCH0 ) p3->op = _MATCH1 ;
else /* check for string */
if ( p3->op == _PUSHS )
{ CELL *cp = ZMALLOC(CELL) ;
cp->type = C_STRING ;
cp->ptr = p3[1].ptr ;
cast_to_RE(cp) ;
code_ptr -= 2 ;
code2(_MATCH1, cp->ptr) ;
ZFREE(cp) ;
}
else code1(_MATCH2) ;
}
else code1(_MATCH2) ;
if ( !$2 ) code1(_NOT) ;
}
/* short circuit boolean evaluation */
| expr OR
{ code1(_TEST) ;
code_jmp(_LJNZ, (INST*)0) ;
}
expr
{ code1(_TEST) ; patch_jmp(code_ptr) ; }
| expr AND
{ code1(_TEST) ;
code_jmp(_LJZ, (INST*)0) ;
}
expr
{ code1(_TEST) ; patch_jmp(code_ptr) ; }
| expr QMARK { code_jmp(_JZ, (INST*)0) ; }
expr COLON { code_jmp(_JMP, (INST*)0) ; }
expr
{ patch_jmp(code_ptr) ; patch_jmp(CDP($7)) ; }
;
cat_expr : p_expr %prec CAT
| cat_expr p_expr %prec CAT
{ code1(_CAT) ; }
;
p_expr : DOUBLE
{ $$ = code_offset ; code2(_PUSHD, $1) ; }
| STRING_
{ $$ = code_offset ; code2(_PUSHS, $1) ; }
| ID %prec AND /* anything less than IN */
{ check_var($1) ;
$$ = code_offset ;
if ( is_local($1) )
{ code2op(L_PUSHI, $1->offset) ; }
else code2(_PUSHI, $1->stval.cp) ;
}
| LPAREN expr RPAREN
{ $$ = $2 ; }
;
p_expr : RE
{ $$ = code_offset ; code2(_MATCH0, $1) ; }
;
p_expr : p_expr PLUS p_expr { code1(_ADD) ; }
| p_expr MINUS p_expr { code1(_SUB) ; }
| p_expr MUL p_expr { code1(_MUL) ; }
| p_expr DIV p_expr { code1(_DIV) ; }
| p_expr MOD p_expr { code1(_MOD) ; }
| p_expr POW p_expr { code1(_POW) ; }
| NOT p_expr
{ $$ = $2 ; code1(_NOT) ; }
| PLUS p_expr %prec UMINUS
{ $$ = $2 ; code1(_UPLUS) ; }
| MINUS p_expr %prec UMINUS
{ $$ = $2 ; code1(_UMINUS) ; }
| builtin
;
p_expr : ID INC_or_DEC
{ check_var($1) ;
$$ = code_offset ;
code_address($1) ;
if ( $2 == '+' ) code1(_POST_INC) ;
else code1(_POST_DEC) ;
}
| INC_or_DEC lvalue
{ $$ = $2 ;
if ( $1 == '+' ) code1(_PRE_INC) ;
else code1(_PRE_DEC) ;
}
;
p_expr : field INC_or_DEC
{ if ($2 == '+' ) code1(F_POST_INC ) ;
else code1(F_POST_DEC) ;
}
| INC_or_DEC field
{ $$ = $2 ;
if ( $1 == '+' ) code1(F_PRE_INC) ;
else code1( F_PRE_DEC) ;
}
;
lvalue : ID
{ $$ = code_offset ;
check_var($1) ;
code_address($1) ;
}
;
arglist : /* empty */
{ $$ = 0 ; }
| args
;
args : expr %prec LPAREN
{ $$ = 1 ; }
| args COMMA expr
{ $$ = $1 + 1 ; }
;
builtin :
BUILTIN mark LPAREN arglist RPAREN
{ BI_REC *p = $1 ;
$$ = $2 ;
if ( (int)p->min_args > $4 || (int)p->max_args < $4 )
compile_error(
"wrong number of arguments in call to %s" ,
p->name ) ;
if ( p->min_args != p->max_args ) /* variable args */
{ code1(_PUSHINT) ; code1($4) ; }
code2(_BUILTIN , p->fp) ;
}
| LENGTH /* this is an irritation */
{
$$ = code_offset ;
code1(_PUSHINT) ; code1(0) ;
code2(_BUILTIN, $1->fp) ;
}
;
/* an empty production to store the code_ptr */
mark : /* empty */
{ $$ = code_offset ; }
/* print_statement */
statement : print mark pr_args pr_direction separator
{ code2(_PRINT, $1) ;
if ( $1 == bi_printf && $3 == 0 )
compile_error("no arguments in call to printf") ;
print_flag = 0 ;
$$ = $2 ;
}
;
print : PRINT { $$ = bi_print ; print_flag = 1 ;}
| PRINTF { $$ = bi_printf ; print_flag = 1 ; }
;
pr_args : arglist { code2op(_PUSHINT, $1) ; }
| LPAREN arg2 RPAREN
{ $$ = $2->cnt ; zfree($2,sizeof(ARG2_REC)) ;
code2op(_PUSHINT, $$) ;
}
| LPAREN RPAREN
{ $$=0 ; code2op(_PUSHINT, 0) ; }
;
arg2 : expr COMMA expr
{ $$ = (ARG2_REC*) zmalloc(sizeof(ARG2_REC)) ;
$$->start = $1 ;
$$->cnt = 2 ;
}
| arg2 COMMA expr
{ $$ = $1 ; $$->cnt++ ; }
;
pr_direction : /* empty */
| IO_OUT expr
{ code2op(_PUSHINT, $1) ; }
;
/* IF and IF-ELSE */
if_front : IF LPAREN expr RPAREN
{ $$ = $3 ; eat_nl() ; code_jmp(_JZ, (INST*)0) ; }
;
/* if_statement */
statement : if_front statement
{ patch_jmp( code_ptr ) ; }
;
else : ELSE { eat_nl() ; code_jmp(_JMP, (INST*)0) ; }
;
/* if_else_statement */
statement : if_front statement else statement
{ patch_jmp(code_ptr) ;
patch_jmp(CDP($4)) ;
}
/* LOOPS */
do : DO
{ eat_nl() ; BC_new() ; }
;
/* do_statement */
statement : do statement WHILE LPAREN expr RPAREN separator
{ $$ = $2 ;
code_jmp(_JNZ, CDP($2)) ;
BC_clear(code_ptr, CDP($5)) ; }
;
while_front : WHILE LPAREN expr RPAREN
{ eat_nl() ; BC_new() ;
$$ = $3 ;
/* check if const expression */
if ( code_ptr - 2 == CDP($3) &&
code_ptr[-2].op == _PUSHD &&
*(double*)code_ptr[-1].ptr != 0.0
)
code_ptr -= 2 ;
else
{ INST *p3 = CDP($3) ;
code_push(p3, code_ptr-p3, scope, active_funct) ;
code_ptr = p3 ;
code2(_JMP, (INST*)0) ; /* code2() not code_jmp() */
}
}
;
/* while_statement */
statement : while_front statement
{
int saved_offset ;
int len ;
INST *p1 = CDP($1) ;
INST *p2 = CDP($2) ;
if ( p1 != p2 ) /* real test in loop */
{
p1[1].op = code_ptr-(p1+1) ;
saved_offset = code_offset ;
len = code_pop(code_ptr) ;
code_ptr += len ;
code_jmp(_JNZ, CDP($2)) ;
BC_clear(code_ptr, CDP(saved_offset)) ;
}
else /* while(1) */
{
code_jmp(_JMP, p1) ;
BC_clear(code_ptr, CDP($2)) ;
}
}
;
/* for_statement */
statement : for1 for2 for3 statement
{
int cont_offset = code_offset ;
unsigned len = code_pop(code_ptr) ;
INST *p2 = CDP($2) ;
INST *p4 = CDP($4) ;
code_ptr += len ;
if ( p2 != p4 ) /* real test in for2 */
{
p4[-1].op = code_ptr - p4 + 1 ;
len = code_pop(code_ptr) ;
code_ptr += len ;
code_jmp(_JNZ, CDP($4)) ;
}
else /* for(;;) */
code_jmp(_JMP, p4) ;
BC_clear(code_ptr, CDP(cont_offset)) ;
}
;
for1 : FOR LPAREN SEMI_COLON { $$ = code_offset ; }
| FOR LPAREN expr SEMI_COLON
{ $$ = $3 ; code1(_POP) ; }
;
for2 : SEMI_COLON { $$ = code_offset ; }
| expr SEMI_COLON
{
if ( code_ptr - 2 == CDP($1) &&
code_ptr[-2].op == _PUSHD &&
* (double*) code_ptr[-1].ptr != 0.0
)
code_ptr -= 2 ;
else
{
INST *p1 = CDP($1) ;
code_push(p1, code_ptr-p1, scope, active_funct) ;
code_ptr = p1 ;
code2(_JMP, (INST*)0) ;
}
}
;
for3 : RPAREN
{ eat_nl() ; BC_new() ;
code_push((INST*)0,0, scope, active_funct) ;
}
| expr RPAREN
{ INST *p1 = CDP($1) ;
eat_nl() ; BC_new() ;
code1(_POP) ;
code_push(p1, code_ptr - p1, scope, active_funct) ;
code_ptr -= code_ptr - p1 ;
}
;
/* arrays */
expr : expr IN ID
{ check_array($3) ;
code_array($3) ;
code1(A_TEST) ;
}
| LPAREN arg2 RPAREN IN ID
{ $$ = $2->start ;
code2op(A_CAT, $2->cnt) ;
zfree($2, sizeof(ARG2_REC)) ;
check_array($5) ;
code_array($5) ;
code1(A_TEST) ;
}
;
lvalue : ID mark LBOX args RBOX
{
if ( $4 > 1 )
{ code2op(A_CAT, $4) ; }
check_array($1) ;
if( is_local($1) )
{ code2op(LAE_PUSHA, $1->offset) ; }
else code2(AE_PUSHA, $1->stval.array) ;
$$ = $2 ;
}
;
p_expr : ID mark LBOX args RBOX %prec AND
{
if ( $4 > 1 )
{ code2op(A_CAT, $4) ; }
check_array($1) ;
if( is_local($1) )
{ code2op(LAE_PUSHI, $1->offset) ; }
else code2(AE_PUSHI, $1->stval.array) ;
$$ = $2 ;
}
| ID mark LBOX args RBOX INC_or_DEC
{
if ( $4 > 1 )
{ code2op(A_CAT,$4) ; }
check_array($1) ;
if( is_local($1) )
{ code2op(LAE_PUSHA, $1->offset) ; }
else code2(AE_PUSHA, $1->stval.array) ;
if ( $6 == '+' ) code1(_POST_INC) ;
else code1(_POST_DEC) ;
$$ = $2 ;
}
;
/* delete A[i] or delete A */
statement : DELETE ID mark LBOX args RBOX separator
{
$$ = $3 ;
if ( $5 > 1 ) { code2op(A_CAT, $5) ; }
check_array($2) ;
code_array($2) ;
code1(A_DEL) ;
}
| DELETE ID separator
{
$$ = code_offset ;
check_array($2) ;
code_array($2) ;
code1(DEL_A) ;
}
;
/* for ( i in A ) statement */
array_loop_front : FOR LPAREN ID IN ID RPAREN
{ eat_nl() ; BC_new() ;
$$ = code_offset ;
check_var($3) ;
code_address($3) ;
check_array($5) ;
code_array($5) ;
code2(SET_ALOOP, (INST*)0) ;
}
;
/* array_loop */
statement : array_loop_front statement
{
INST *p2 = CDP($2) ;
p2[-1].op = code_ptr - p2 + 1 ;
BC_clear( code_ptr+2 , code_ptr) ;
code_jmp(ALOOP, p2) ;
code1(POP_AL) ;
}
;
/* fields
D_ID is a special token , same as an ID, but yylex()
only returns it after a '$'. In essense,
DOLLAR D_ID is really one token.
*/
field : FIELD
{ $$ = code_offset ; code2(F_PUSHA, $1) ; }
| DOLLAR D_ID
{ check_var($2) ;
$$ = code_offset ;
if ( is_local($2) )
{ code2op(L_PUSHI, $2->offset) ; }
else code2(_PUSHI, $2->stval.cp) ;
CODE_FE_PUSHA() ;
}
| DOLLAR D_ID mark LBOX args RBOX
{
if ( $5 > 1 )
{ code2op(A_CAT, $5) ; }
check_array($2) ;
if( is_local($2) )
{ code2op(LAE_PUSHI, $2->offset) ; }
else code2(AE_PUSHI, $2->stval.array) ;
CODE_FE_PUSHA() ;
$$ = $3 ;
}
| DOLLAR p_expr
{ $$ = $2 ; CODE_FE_PUSHA() ; }
| LPAREN field RPAREN
{ $$ = $2 ; }
;
p_expr : field %prec CAT /* removes field (++|--) sr conflict */
{ field_A2I() ; }
;
expr : field ASSIGN expr { code1(F_ASSIGN) ; }
| field ADD_ASG expr { code1(F_ADD_ASG) ; }
| field SUB_ASG expr { code1(F_SUB_ASG) ; }
| field MUL_ASG expr { code1(F_MUL_ASG) ; }
| field DIV_ASG expr { code1(F_DIV_ASG) ; }
| field MOD_ASG expr { code1(F_MOD_ASG) ; }
| field POW_ASG expr { code1(F_POW_ASG) ; }
;
/* split is handled different than a builtin because
it takes an array and optionally a regular expression as args */
p_expr : split_front split_back
{ code2(_BUILTIN, bi_split) ; }
;
split_front : SPLIT LPAREN expr COMMA ID
{ $$ = $3 ;
check_array($5) ;
code_array($5) ;
}
;
split_back : RPAREN
{ code2(_PUSHI, &fs_shadow) ; }
| COMMA expr RPAREN
{
if ( CDP($2) == code_ptr - 2 )
{
if ( code_ptr[-2].op == _MATCH0 )
RE_as_arg() ;
else
if ( code_ptr[-2].op == _PUSHS )
{ CELL *cp = ZMALLOC(CELL) ;
cp->type = C_STRING ;
cp->ptr = code_ptr[-1].ptr ;
cast_for_split(cp) ;
code_ptr[-2].op = _PUSHC ;
code_ptr[-1].ptr = (PTR) cp ;
}
}
}
;
/* match(expr, RE) */
p_expr : MATCH_FUNC LPAREN expr COMMA re_arg RPAREN
{ $$ = $3 ;
code2(_BUILTIN, bi_match) ;
}
;
re_arg : expr
{
INST *p1 = CDP($1) ;
if ( p1 == code_ptr - 2 )
{
if ( p1->op == _MATCH0 ) RE_as_arg() ;
else
if ( p1->op == _PUSHS )
{ CELL *cp = ZMALLOC(CELL) ;
cp->type = C_STRING ;
cp->ptr = p1[1].ptr ;
cast_to_RE(cp) ;
p1->op = _PUSHC ;
p1[1].ptr = (PTR) cp ;
}
}
}
/* exit_statement */
statement : EXIT separator
{ $$ = code_offset ;
code1(_EXIT0) ; }
| EXIT expr separator
{ $$ = $2 ; code1(_EXIT) ; }
return_statement : RETURN separator
{ $$ = code_offset ;
code1(_RET0) ; }
| RETURN expr separator
{ $$ = $2 ; code1(_RET) ; }
/* getline */
p_expr : getline %prec GETLINE
{ $$ = code_offset ;
code2(F_PUSHA, &field[0]) ;
code1(_PUSHINT) ; code1(0) ;
code2(_BUILTIN, bi_getline) ;
getline_flag = 0 ;
}
| getline fvalue %prec GETLINE
{ $$ = $2 ;
code1(_PUSHINT) ; code1(0) ;
code2(_BUILTIN, bi_getline) ;
getline_flag = 0 ;
}
| getline_file p_expr %prec IO_IN
{ code1(_PUSHINT) ; code1(F_IN) ;
code2(_BUILTIN, bi_getline) ;
/* getline_flag already off in yylex() */
}
| p_expr PIPE GETLINE
{ code2(F_PUSHA, &field[0]) ;
code1(_PUSHINT) ; code1(PIPE_IN) ;
code2(_BUILTIN, bi_getline) ;
}
| p_expr PIPE GETLINE fvalue
{
code1(_PUSHINT) ; code1(PIPE_IN) ;
code2(_BUILTIN, bi_getline) ;
}
;
getline : GETLINE { getline_flag = 1 ; }
fvalue : lvalue | field ;
getline_file : getline IO_IN
{ $$ = code_offset ;
code2(F_PUSHA, field+0) ;
}
| getline fvalue IO_IN
{ $$ = $2 ; }
;
/*==========================================
sub and gsub
==========================================*/
p_expr : sub_or_gsub LPAREN re_arg COMMA expr sub_back
{
INST *p5 = CDP($5) ;
INST *p6 = CDP($6) ;
if ( p6 - p5 == 2 && p5->op == _PUSHS )
{ /* cast from STRING to REPL at compile time */
CELL *cp = ZMALLOC(CELL) ;
cp->type = C_STRING ;
cp->ptr = p5[1].ptr ;
cast_to_REPL(cp) ;
p5->op = _PUSHC ;
p5[1].ptr = (PTR) cp ;
}
code2(_BUILTIN, $1) ;
$$ = $3 ;
}
;
sub_or_gsub : SUB { $$ = bi_sub ; }
| GSUB { $$ = bi_gsub ; }
;
sub_back : RPAREN /* substitute into $0 */
{ $$ = code_offset ;
code2(F_PUSHA, &field[0]) ;
}
| COMMA fvalue RPAREN
{ $$ = $2 ; }
;
/*================================================
user defined functions
*=================================*/
function_def : funct_start block
{
resize_fblock($1) ;
restore_ids() ;
switch_code_to_main() ;
}
;
funct_start : funct_head LPAREN f_arglist RPAREN
{ eat_nl() ;
scope = SCOPE_FUNCT ;
active_funct = $1 ;
*main_code_p = active_code ;
$1->nargs = $3 ;
if ( $3 )
$1->typev = (char *)
memset( zmalloc($3), ST_LOCAL_NONE, $3) ;
else $1->typev = (char *) 0 ;
code_ptr = code_base =
(INST *) zmalloc(INST_BYTES(PAGESZ));
code_limit = code_base + PAGESZ ;
code_warn = code_limit - CODEWARN ;
}
;
funct_head : FUNCTION ID
{ FBLOCK *fbp ;
if ( $2->type == ST_NONE )
{
$2->type = ST_FUNCT ;
fbp = $2->stval.fbp =
(FBLOCK *) zmalloc(sizeof(FBLOCK)) ;
fbp->name = $2->name ;
fbp->code = (INST*) 0 ;
}
else
{
type_error( $2 ) ;
/* this FBLOCK will not be put in
the symbol table */
fbp = (FBLOCK*) zmalloc(sizeof(FBLOCK)) ;
fbp->name = "" ;
}
$$ = fbp ;
}
| FUNCTION FUNCT_ID
{ $$ = $2 ;
if ( $2->code )
compile_error("redefinition of %s" , $2->name) ;
}
;
f_arglist : /* empty */ { $$ = 0 ; }
| f_args
;
f_args : ID
{ $1 = save_id($1->name) ;
$1->type = ST_LOCAL_NONE ;
$1->offset = 0 ;
$$ = 1 ;
}
| f_args COMMA ID
{ if ( is_local($3) )
compile_error("%s is duplicated in argument list",
$3->name) ;
else
{ $3 = save_id($3->name) ;
$3->type = ST_LOCAL_NONE ;
$3->offset = $1 ;
$$ = $1 + 1 ;
}
}
;
outside_error : error
{ /* we may have to recover from a bungled function
definition */
/* can have local ids, before code scope
changes */
restore_ids() ;
switch_code_to_main() ;
}
;
/* a call to a user defined function */
p_expr : FUNCT_ID mark call_args
{ $$ = $2 ;
code2(_CALL, $1) ;
if ( $3 ) code1($3->arg_num+1) ;
else code1(0) ;
check_fcall($1, scope, code_move_level, active_funct,
$3, token_lineno) ;
}
;
call_args : LPAREN RPAREN
{ $$ = (CA_REC *) 0 ; }
| ca_front ca_back
{ $$ = $2 ;
$$->link = $1 ;
$$->arg_num = $1 ? $1->arg_num+1 : 0 ;
}
;
/* The funny definition of ca_front with the COMMA bound to the ID is to
force a shift to avoid a reduce/reduce conflict
ID->id or ID->array
Or to avoid a decision, if the type of the ID has not yet been
determined
*/
ca_front : LPAREN
{ $$ = (CA_REC *) 0 ; }
| ca_front expr COMMA
{ $$ = ZMALLOC(CA_REC) ;
$$->link = $1 ;
$$->type = CA_EXPR ;
$$->arg_num = $1 ? $1->arg_num+1 : 0 ;
$$->call_offset = code_offset ;
}
| ca_front ID COMMA
{ $$ = ZMALLOC(CA_REC) ;
$$->link = $1 ;
$$->arg_num = $1 ? $1->arg_num+1 : 0 ;
code_call_id($$, $2) ;
}
;
ca_back : expr RPAREN
{ $$ = ZMALLOC(CA_REC) ;
$$->type = CA_EXPR ;
$$->call_offset = code_offset ;
}
| ID RPAREN
{ $$ = ZMALLOC(CA_REC) ;
code_call_id($$, $1) ;
}
;
%%
/* resize the code for a user function */
static void resize_fblock( fbp )
FBLOCK *fbp ;
{
CODEBLOCK *p = ZMALLOC(CODEBLOCK) ;
unsigned dummy ;
code2op(_RET0, _HALT) ;
/* make sure there is always a return */
*p = active_code ;
fbp->code = code_shrink(p, &dummy) ;
/* code_shrink() zfrees p */
if ( dump_code_flag ) add_to_fdump_list(fbp) ;
}
/* convert FE_PUSHA to FE_PUSHI
or F_PUSH to F_PUSHI
*/
static void field_A2I()
{ CELL *cp ;
if ( code_ptr[-1].op == FE_PUSHA &&
code_ptr[-1].ptr == (PTR) 0)
/* On most architectures, the two tests are the same; a good
compiler might eliminate one. On LM_DOS, and possibly other
segmented architectures, they are not */
{ code_ptr[-1].op = FE_PUSHI ; }
else
{
cp = (CELL *) code_ptr[-1].ptr ;
if ( cp == field ||
#ifdef MSDOS
SAMESEG(cp,field) &&
#endif
cp > NF && cp <= LAST_PFIELD )
{
code_ptr[-2].op = _PUSHI ;
}
else if ( cp == NF )
{ code_ptr[-2].op = NF_PUSHI ; code_ptr-- ; }
else
{
code_ptr[-2].op = F_PUSHI ;
code_ptr -> op = field_addr_to_index( code_ptr[-1].ptr ) ;
code_ptr++ ;
}
}
}
/* we've seen an ID in a context where it should be a VAR,
check that's consistent with previous usage */
static void check_var( p )
register SYMTAB *p ;
{
switch(p->type)
{
case ST_NONE : /* new id */
p->type = ST_VAR ;
p->stval.cp = ZMALLOC(CELL) ;
p->stval.cp->type = C_NOINIT ;
break ;
case ST_LOCAL_NONE :
p->type = ST_LOCAL_VAR ;
active_funct->typev[p->offset] = ST_LOCAL_VAR ;
break ;
case ST_VAR :
case ST_LOCAL_VAR : break ;
default :
type_error(p) ;
break ;
}
}
/* we've seen an ID in a context where it should be an ARRAY,
check that's consistent with previous usage */
static void check_array(p)
register SYMTAB *p ;
{
switch(p->type)
{
case ST_NONE : /* a new array */
p->type = ST_ARRAY ;
p->stval.array = new_ARRAY() ;
break ;
case ST_ARRAY :
case ST_LOCAL_ARRAY :
break ;
case ST_LOCAL_NONE :
p->type = ST_LOCAL_ARRAY ;
active_funct->typev[p->offset] = ST_LOCAL_ARRAY ;
break ;
default : type_error(p) ; break ;
}
}
static void code_array(p)
register SYMTAB *p ;
{
if ( is_local(p) ) code2op(LA_PUSHA, p->offset) ;
else code2(A_PUSHA, p->stval.array) ;
}
/* we've seen an ID as an argument to a user defined function */
static void code_call_id( p, ip )
register CA_REC *p ;
register SYMTAB *ip ;
{ static CELL dummy ;
p->call_offset = code_offset ;
/* This always get set now. So that fcall:relocate_arglist
works. */
switch( ip->type )
{
case ST_VAR :
p->type = CA_EXPR ;
code2(_PUSHI, ip->stval.cp) ;
break ;
case ST_LOCAL_VAR :
p->type = CA_EXPR ;
code2op(L_PUSHI, ip->offset) ;
break ;
case ST_ARRAY :
p->type = CA_ARRAY ;
code2(A_PUSHA, ip->stval.array) ;
break ;
case ST_LOCAL_ARRAY :
p->type = CA_ARRAY ;
code2op(LA_PUSHA, ip->offset) ;
break ;
/* not enough info to code it now; it will have to
be patched later */
case ST_NONE :
p->type = ST_NONE ;
p->sym_p = ip ;
code2(_PUSHI, &dummy) ;
break ;
case ST_LOCAL_NONE :
p->type = ST_LOCAL_NONE ;
p->type_p = & active_funct->typev[ip->offset] ;
code2op(L_PUSHI, ip->offset) ;
break ;
#ifdef DEBUG
default :
bozo("code_call_id") ;
#endif
}
}
/* an RE by itself was coded as _MATCH0 , change to
push as an expression */
static void RE_as_arg()
{ CELL *cp = ZMALLOC(CELL) ;
code_ptr -= 2 ;
cp->type = C_RE ;
cp->ptr = code_ptr[1].ptr ;
code2(_PUSHC, cp) ;
}
/* reset the active_code back to the MAIN block */
static void
switch_code_to_main()
{
switch(scope)
{
case SCOPE_BEGIN :
*begin_code_p = active_code ;
active_code = *main_code_p ;
break ;
case SCOPE_END :
*end_code_p = active_code ;
active_code = *main_code_p ;
break ;
case SCOPE_FUNCT :
active_code = *main_code_p ;
break ;
case SCOPE_MAIN :
break ;
}
active_funct = (FBLOCK*) 0 ;
scope = SCOPE_MAIN ;
}
void
parse()
{
if ( yyparse() || compile_error_count != 0 ) mawk_exit(2) ;
scan_cleanup() ;
set_code() ;
/* code must be set before call to resolve_fcalls() */
if ( resolve_list ) resolve_fcalls() ;
if ( compile_error_count != 0 ) mawk_exit(2) ;
if ( dump_code_flag ) { dump_code() ; mawk_exit(0) ; }
}
|
%{
#include "main.h"
#include <stdio.h>
%}
%union {
double val; /* actual value */
Symbol *sym; /* symbol table pointer */
}
%token <val> NUMBER
%token <sym> VAR BLTIN UNDEF
%type <val> expr asgn
%right '='
%left '+' '-'
%left '*' '/'
%left UNARYMINUS
%right '^' /* exponentiation */
%%
list: /* nothing */
| list '\n'
| list asgn '\n'
| list expr '\n' { printf("\t%.8g\n", $2); }
| list error '\n' { yyerrok; }
;
asgn: VAR '=' expr { $$=$1->value.val=$3; $1->type = VAR; }
;
expr: NUMBER
| VAR { if ($1->type == UNDEF)
execerror("undefined variable", $1->name);
$$ = $1->value.val; }
| BLTIN '(' expr ')' { $$ = (*($1->value.ptr))($3); }
| expr '+' expr { $$ = $1 + $3; }
| expr '-' expr { $$ = $1 - $3; }
| expr '*' expr { $$ = $1 * $3; }
| expr '/' expr {
if ($3 == 0.0)
execerror("division by zero", "");
$$ = $1 / $3; }
| expr '^' expr { $$ = Pow($1, $3); }
| '(' expr ')' { $$ = $2; }
| '-' expr %prec UNARYMINUS { $$ = -$2; }
;
%%
|
<reponame>MyersResearchGroup/ATACS
%{
/*
This file generates a grammar for the reading of
gate building data.
Author: <NAME>
School: University of Utah
Date: 1/12/07
*/
#include <stdio.h>
#include "interaction.c"
#include "biostructure.h"
#include <iostream>
//#include "loadg.h"
using namespace std;
int yyerror(char*);
string gene_name;
string protein_name;
string promoter_name;
vector<string> activated;
vector<string> repressed;
vector<string> combos;
hash_map<promoter> promoters;
hash_map<interaction_data> interactions;
hash_map<gene> genes;
string stripQuote(string to_strip);
#ifdef OSX
// extern char yytext[];
#endif
%}
%token COMMA GENE PROMOTER INTERACTION LEFT_BRACE LEFT_CURLY NUMBER RIGHT_BRACE RIGHT_CURLY TEXT UNKNOWN_TOKEN;
/*
* Grammar Rules
* For the construct rules, each number represents:
* #act, #rep, #compAct, #compRep, #actAct, #repRep, #actRep
*/
%%
line: line promoter | line gene | line interaction | ;
gene: GENE TEXT {gene_name = stripQuote(string(yytext));
gene temp = gene(gene_name);
genes.put(temp.name, gene_name);
};
promoter: PROMOTER TEXT {promoter_name = stripQuote(string(yytext));}
LEFT_CURLY {activated.clear();} activate RIGHT_CURLY
LEFT_CURLY {repressed.clear();} repressed RIGHT_CURLY {
set<string, cmpstr> activate;
for (unsigned int i = 0; i < activated.size(); i++) {
activate.insert(activated[i]);
}
set<string, cmpstr> repress;
for (unsigned int i = 0; i < repressed.size(); i++) {
repress.insert(repressed[i]);
}
promoter temp = promoter(promoter_name, activate, repress);
promoters.put(temp.name, temp);
};
activate: activate TEXT {activated.push_back(stripQuote(string(yytext)));} |;
repressed: repressed TEXT {repressed.push_back(stripQuote(string(yytext)));} |;
interaction: INTERACTION LEFT_CURLY {activated.clear();} activate RIGHT_CURLY
LEFT_CURLY TEXT {protein_name = stripQuote(string(yytext));} RIGHT_CURLY{
set<string, cmpstr> activate;
for (unsigned int i = 0; i < activated.size(); i++) {
activate.insert(activated[i]);
}
interaction_data temp = interaction_data(activate, protein_name);
interactions.put(temp.product, temp);
};
%%
extern FILE *yyin;
void loadInteractFile(char* filename) {
yyin = fopen(filename, "r");
}
void parseInteractFile(hash_map<promoter> *promoters_set, hash_map<interaction_data> *interactions_set, hash_map<gene> *genes_set) {
do {
yyparse();
}
while (!feof(yyin));
*interactions_set = interactions;
*promoters_set = promoters;
*genes_set = genes;
}
int yyerror(char* s)
{
fprintf(stderr, "%s\n",s);
return -1;
}
string stripQuote(string temp) {
unsigned int size = temp.length();
return temp.substr(1, size-2);
}
|
<filename>Snippets/Lex and Yacc/fbcalc/par.y
%{
#include <stdio.h>
%}
%token NUM ADD EOL
%%
line:
/* nothing */
| expr EOL { printf("= %d\n", $1); }
;
expr:
NUM { $$ = $1; }
| expr ADD expr { $$ = $1 + $3; }
;
%%
int yyerror (char *error)
{
fprintf(stderr, "error: %s\n", error);
}
|
<filename>src/sv_parser/sieve.y
%{
/* sieve.y -- sieve parser
* <NAME>
* $Id$
*/
/***********************************************************
Copyright 1999 by Carnegie Mellon University
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Carnegie Mellon
University not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR
ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* sv_regex */
#include "src/sv_regex/regex.h"
/* sv_parser */
#include "comparator.h"
#include "addrinc.h"
#include "sieveinc.h"
/* sv_interface */
#include "src/sv_interface/callbacks2.h"
/* sv_util */
#include "src/sv_util/util.h"
#include "sieve.h"
#include "sieve-lex.h"
#define THIS_MODULE "sv_parser"
struct vtags {
int days;
stringlist_t *addresses;
char *subject;
int mime;
char *from;
char *handle;
};
struct hftags {
char *comparator;
int comptag;
};
struct htags {
char *comparator;
int comptag;
};
struct aetags {
int addrtag;
char *comparator;
int comptag;
};
struct ntags {
char *method;
char *id;
stringlist_t *options;
char *priority;
char *message;
};
static test_t *static_build_address(struct sieve2_context *context, int t,
struct aetags *ae, stringlist_t *sl, patternlist_t *pl);
static test_t *static_build_header(struct sieve2_context *context, int t,
struct htags *h, stringlist_t *sl, patternlist_t *pl);
static commandlist_t *static_build_vacation(struct sieve2_context *context, int t, struct vtags *h, char *s);
static commandlist_t *static_build_notify(struct sieve2_context *context,
int t, struct ntags *n);
static commandlist_t *static_build_validnotif(struct sieve2_context *context,
int t, stringlist_t *sl);
static struct aetags *static_new_aetags(void);
static struct aetags *static_canon_aetags(struct aetags *ae);
static void static_free_aetags(struct aetags *ae);
static struct hftags *static_new_hftags(void);
static struct htags *static_new_htags(void);
static struct htags *static_canon_htags(struct htags *h);
static void static_free_htags(struct htags *h);
static struct vtags *static_new_vtags(void);
static struct vtags *static_canon_vtags(struct vtags *v);
static void static_free_vtags(struct vtags *v);
static struct ntags *static_new_ntags(void);
static struct ntags *static_canon_ntags(struct ntags *n);
static void static_free_ntags(struct ntags *n);
static int static_verify_stringlist(struct sieve2_context *context, stringlist_t *sl, int (*verify)(struct sieve2_context *context, const char *));
static int static_verify_mailbox(const char *s);
static int static_verify_address(struct sieve2_context *context, const char *s);
static int static_verify_header(struct sieve2_context *context, const char *s);
static int static_verify_flag(struct sieve2_context *context, const char *s);
static regex_t *static_verify_regex(struct sieve2_context *context, const char *s, int cflags);
static patternlist_t *static_verify_regexs(struct sieve2_context *context, stringlist_t *sl, char *comp);
static int static_ok_header(char *s);
static int static_check_reqs(struct sieve2_context *context, char *req);
extern YY_DECL;
#define YYERROR_VERBOSE /* i want better error messages! */
%}
%defines
%name-prefix="libsieve_sieve"
%define api.pure
%lex-param {struct sieve2_context *context}
%lex-param {void *yyscanner}
%parse-param {struct sieve2_context *context}
%parse-param {void *yyscanner}
%union {
int nval;
char *sval;
stringlist_t *sl;
test_t *test;
testlist_t *testl;
commandlist_t *cl;
struct vtags *vtag;
struct aetags *aetag;
struct htags *htag;
struct hftags *hftag;
struct ntags *ntag;
}
%token <nval> NUMBER
%token <sval> STRING
%token IF ELSIF ELSE
%token REJCT FILEINTO REDIRECT KEEP STOP DISCARD VACATION REQUIRE
%token SETFLAG ADDFLAG REMOVEFLAG MARK UNMARK FLAGS HASFLAG
%token NOTIFY VALIDNOTIF
%token ANYOF ALLOF EXISTS SFALSE STRUE HEADER NOT SIZE ADDRESS ENVELOPE
%token COMPARATOR IS CONTAINS MATCHES REGEX OVER UNDER COUNT VALUE
%token ALL LOCALPART DOMAIN USER DETAIL
%token DAYS ADDRESSES SUBJECT MIME FROM HANDLE
%token METHOD ID OPTIONS LOW NORMAL HIGH MESSAGE
%type <cl> commands command action elsif block
%type <sl> stringlist strings
%type <test> test
%type <nval> comptag sizetag addrparttag addrorenv
%type <testl> testlist tests
%type <htag> htags
%type <hftag> hftags
%type <aetag> aetags
%type <vtag> vtags
%type <ntag> ntags
%type <sval> priority
%%
start: /* empty */ { context->sieve_ret = NULL; }
| reqs commands { context->sieve_ret = $2; }
;
reqs: /* empty */
| require reqs
;
require: REQUIRE stringlist ';' {
int unsupp = 0;
char *msg;
char *freemsg;
stringlist_t *s;
stringlist_t *sl = $2;
msg = libsieve_strconcat("unsupported feature:", NULL);
while (sl != NULL) {
s = sl;
sl = sl->next;
/* Returns 1 if supported, 0 if not. */
if (!static_check_reqs(context, s->s)) {
unsupp = 1;
freemsg = msg;
msg = libsieve_strconcat(freemsg, " ", s->s, NULL);
libsieve_free(freemsg);
}
libsieve_free(s->s);
libsieve_free(s);
}
/* If something wasn't supported, bomb out with msg. */
if (unsupp) {
libsieve_sieveerror(context, yyscanner, msg);
libsieve_free(msg);
YYERROR;
}
/* This needs to be free'd regardless of error */
libsieve_free(msg);
}
;
commands: command { $$ = $1; }
| command commands { $1->next = $2; $$ = $1; }
;
command: action ';' { $$ = $1; }
| IF test block elsif { $$ = libsieve_new_if($2, $3, $4); }
| error ';' { $$ = libsieve_new_command(STOP); }
;
elsif: /* empty */ { $$ = NULL; }
| ELSIF test block elsif { $$ = libsieve_new_if($2, $3, $4); }
| ELSE block { $$ = $2; }
;
action: REJCT STRING { if (!context->require.reject) {
libsieve_sieveerror(context, yyscanner, "reject not required");
YYERROR;
}
$$ = libsieve_new_command(REJCT); $$->u.str = $2; }
| KEEP FLAGS stringlist { if (!context->require.imap4flags) {
libsieve_sieveerror(context, yyscanner, "imap4flags not required");
YYERROR;
}
$$ = libsieve_new_command(KEEP);
$$->u.f.mailbox = NULL;
$$->u.f.slflags = $3; }
| KEEP { $$ = libsieve_new_command(KEEP);
$$->u.f.mailbox = NULL;
$$->u.f.slflags = NULL; }
| FILEINTO FLAGS stringlist STRING { if (!context->require.fileinto) {
libsieve_sieveerror(context, yyscanner, "fileinto not required");
YYERROR;
} if (!context->require.imap4flags) {
libsieve_sieveerror(context, yyscanner, "imap4flags not required");
YYERROR;
}
if (!static_verify_stringlist(context, $3, static_verify_flag)) {
YYERROR; /* vh should call sieveerror() */
}
if (!static_verify_mailbox($4)) {
YYERROR; /* vm should call sieveerror() */
}
$$ = libsieve_new_command(FILEINTO);
$$->u.f.slflags = $3;
$$->u.f.mailbox = $4; }
| FILEINTO STRING { if (!context->require.fileinto) {
libsieve_sieveerror(context, yyscanner, "fileinto not required");
YYERROR;
}
if (!static_verify_mailbox($2)) {
YYERROR; /* vm should call sieveerror() */
}
$$ = libsieve_new_command(FILEINTO);
$$->u.f.slflags = NULL;
$$->u.f.mailbox = $2; }
| REDIRECT STRING { $$ = libsieve_new_command(REDIRECT);
if (!static_verify_address(context, $2)) {
YYERROR; /* va should call sieveerror() */
}
$$->u.str = $2; }
| STOP { $$ = libsieve_new_command(STOP); }
| DISCARD { $$ = libsieve_new_command(DISCARD); }
| VACATION vtags STRING { if (!context->require.vacation) {
libsieve_sieveerror(context, yyscanner, "vacation not required");
$$ = libsieve_new_command(VACATION);
YYERROR;
} else {
$$ = static_build_vacation(context,
VACATION, static_canon_vtags($2), $3);
} }
| SETFLAG stringlist { if (!context->require.imap4flags) {
libsieve_sieveerror(context, yyscanner, "imap4flags not required");
YYERROR;
}
if (!static_verify_stringlist(context, $2, static_verify_flag)) {
YYERROR; /* vf should call sieveerror() */
}
$$ = libsieve_new_command(SETFLAG);
$$->u.sl = $2; }
| ADDFLAG stringlist { if (!context->require.imap4flags) {
libsieve_sieveerror(context, yyscanner, "imap4flags not required");
YYERROR;
}
if (!static_verify_stringlist(context, $2, static_verify_flag)) {
YYERROR; /* vf should call sieveerror() */
}
$$ = libsieve_new_command(ADDFLAG);
$$->u.sl = $2; }
| REMOVEFLAG stringlist { if (!context->require.imap4flags) {
libsieve_sieveerror(context, yyscanner, "imap4flags not required");
YYERROR;
}
if (!static_verify_stringlist(context, $2, static_verify_flag)) {
YYERROR; /* vf should call sieveerror() */
}
$$ = libsieve_new_command(REMOVEFLAG);
$$->u.sl = $2; }
| NOTIFY ntags { if (!context->require.notify) {
libsieve_sieveerror(context, yyscanner, "notify not required");
$$ = libsieve_new_command(NOTIFY);
YYERROR;
} else {
$$ = static_build_notify(context, NOTIFY,
static_canon_ntags($2));
} }
| VALIDNOTIF stringlist { if (!context->require.notify) {
libsieve_sieveerror(context, yyscanner, "notify not required");
$$ = libsieve_new_command(VALIDNOTIF);
YYERROR;
} else {
$$ = static_build_validnotif(context, VALIDNOTIF, $2);
} }
;
ntags: /* empty */ { $$ = static_new_ntags(); }
| ntags ID STRING { if ($$->id != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :method"); YYERROR; }
else { $$->id = $3; } }
| ntags METHOD STRING { if ($$->method != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :method"); YYERROR; }
else { $$->method = $3; } }
| ntags OPTIONS stringlist { if ($$->options != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :options"); YYERROR; }
else { $$->options = $3; } }
| ntags priority { if ($$->priority != NULL) {
libsieve_sieveerror(context, yyscanner,"duplicate :priority"); YYERROR; }
else { $$->priority = $2; } }
| ntags MESSAGE STRING { if ($$->message != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :message"); YYERROR; }
else { $$->message = $3; } }
;
hftags: /*empty */ { $$ = static_new_hftags(); }
| hftags comptag { $$->comptag = $2; }
| hftags COMPARATOR STRING { if ($$->comparator != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate comparator tag"); YYERROR; }
else { $$->comparator = $3; } }
;
priority: LOW { $$ = "low"; }
| NORMAL { $$ = "normal"; }
| HIGH { $$ = "high"; }
;
vtags: /* empty */ { $$ = static_new_vtags(); }
| vtags DAYS NUMBER { if ($$->days != -1) {
libsieve_sieveerror(context, yyscanner, "duplicate :days");
YYERROR; }
else { $$->days = $3; } }
| vtags ADDRESSES stringlist { if ($$->addresses != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :addresses");
YYERROR;
} else if (!static_verify_stringlist(context, $3,
static_verify_address)) {
YYERROR;
} else {
$$->addresses = $3; } }
| vtags SUBJECT STRING { if ($$->subject != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :subject");
YYERROR;
} else if (!static_ok_header($3)) {
YYERROR;
} else { $$->subject = $3; } }
| vtags HANDLE STRING { if ($$->handle != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :handle");
YYERROR;
} else if (!static_ok_header($3)) {
YYERROR;
} else { $$->handle = $3; } }
| vtags FROM STRING { if ($$->from != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate :from");
YYERROR;
} else if (!static_ok_header($3)) {
YYERROR;
} else { $$->from = $3; } }
| vtags MIME { if ($$->mime != -1) {
libsieve_sieveerror(context, yyscanner, "duplicate :mime");
YYERROR; }
else { $$->mime = MIME; } }
;
stringlist: '[' strings ']' { $$ = $2; }
| STRING { $$ = libsieve_new_sl($1, NULL); }
;
strings: STRING { $$ = libsieve_new_sl($1, NULL); }
| STRING ',' strings { $$ = libsieve_new_sl($1, $3); }
;
block: '{' commands '}' { $$ = $2; }
| '{' '}' { $$ = NULL; }
;
test: ANYOF testlist { $$ = libsieve_new_test(ANYOF); $$->u.tl = $2; }
| ALLOF testlist { $$ = libsieve_new_test(ALLOF); $$->u.tl = $2; }
| EXISTS stringlist { $$ = libsieve_new_test(EXISTS); $$->u.sl = $2; }
| SFALSE { $$ = libsieve_new_test(SFALSE); }
| STRUE { $$ = libsieve_new_test(STRUE); }
| HASFLAG hftags stringlist { if (!context->require.imap4flags) {
libsieve_sieveerror(context, yyscanner, "imap4flags not required");
YYERROR;
}
if (!static_verify_stringlist(context, $3, static_verify_flag)) {
YYERROR; /* vf should call sieveerror() */
}
$$ = libsieve_new_test(HASFLAG);
if ($2->comptag != -1) {
$$->u.hf.comp = libsieve_comparator_lookup(context, $2->comparator, $2->comptag);
$$->u.hf.comptag = $2->comptag;
}
if ($2) {
libsieve_free($2);
}
$$->u.hf.sl = $3; }
| HEADER htags stringlist stringlist
{ patternlist_t *pl;
if (!static_verify_stringlist(context, $3, static_verify_header)) {
YYERROR; /* vh should call sieveerror() */
}
$2 = static_canon_htags($2);
if ($2->comptag == REGEX) {
pl = static_verify_regexs(context, $4, $2->comparator);
if (!pl) { YYERROR; }
}
else
pl = (patternlist_t *) $4;
$$ = static_build_header(context, HEADER, $2, $3, pl);
if ($$ == NULL) { YYERROR; } }
| addrorenv aetags stringlist stringlist
{ patternlist_t *pl;
if (!static_verify_stringlist(context, $3, static_verify_header)) {
YYERROR; /* vh should call sieveerror() */
}
$2 = static_canon_aetags($2);
if ($2->comptag == REGEX) {
pl = static_verify_regexs(context, $4, $2->comparator);
if (!pl) { YYERROR; }
}
else
pl = (patternlist_t *) $4;
$$ = static_build_address(context, $1, $2, $3, pl);
if ($$ == NULL) { YYERROR; } }
| NOT test { $$ = libsieve_new_test(NOT); $$->u.t = $2; }
| SIZE sizetag NUMBER { $$ = libsieve_new_test(SIZE); $$->u.sz.t = $2;
$$->u.sz.n = $3; }
| error { $$ = NULL; }
;
addrorenv: ADDRESS { $$ = ADDRESS; }
| ENVELOPE { $$ = ENVELOPE; }
;
aetags: /* empty */ { $$ = static_new_aetags(); }
| aetags addrparttag { $$ = $1;
if ($$->addrtag != -1) {
libsieve_sieveerror(context, yyscanner, "duplicate or conflicting address part tag");
YYERROR; }
else { $$->addrtag = $2; } }
| aetags comptag { $$ = $1;
if ($$->comptag != -1) {
libsieve_sieveerror(context, yyscanner, "duplicate comparator type tag"); YYERROR; }
else { $$->comptag = $2; } }
| aetags COMPARATOR STRING { $$ = $1;
if ($$->comparator != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate comparator tag"); YYERROR; }
else { $$->comparator = $3; } }
;
htags: /* empty */ { $$ = static_new_htags(); }
| htags comptag { $$ = $1;
if ($$->comptag != -1) {
libsieve_sieveerror(context, yyscanner, "duplicate comparator type tag"); YYERROR; }
else { $$->comptag = $2; } }
| htags COMPARATOR STRING { $$ = $1;
if ($$->comparator != NULL) {
libsieve_sieveerror(context, yyscanner, "duplicate comparator tag");
YYERROR; }
else { $$->comparator = $3; } }
;
addrparttag: ALL { $$ = ALL; }
| LOCALPART { $$ = LOCALPART; }
| DOMAIN { $$ = DOMAIN; }
| USER { if (!context->require.subaddress) {
libsieve_sieveerror(context, yyscanner, "subaddress not required");
YYERROR;
}
$$ = USER; }
| DETAIL { if (!context->require.subaddress) {
libsieve_sieveerror(context, yyscanner, "subaddress not required");
YYERROR;
}
$$ = DETAIL; }
;
comptag: IS { $$ = IS; }
| VALUE STRING { $$ = VALUE | libsieve_relational_lookup($2); libsieve_free($2); /* HACK: bits above 10 carry the relational. And we don't need this string anymore, either. */ }
| COUNT STRING { $$ = COUNT | libsieve_relational_lookup($2); libsieve_free($2); /* HACK: bits above 10 carry the relational. And we don't need this string anymore, either. */ }
| CONTAINS { $$ = CONTAINS; }
| MATCHES { $$ = MATCHES; }
| REGEX { if (!context->require.regex) {
libsieve_sieveerror(context, yyscanner, "regex not required");
YYERROR;
}
$$ = REGEX; }
;
sizetag: OVER { $$ = OVER; }
| UNDER { $$ = UNDER; }
;
testlist: '(' tests ')' { $$ = $2; }
;
tests: test { $$ = libsieve_new_testlist($1, NULL); }
| test ',' tests { $$ = libsieve_new_testlist($1, $3); }
;
%%
commandlist_t *libsieve_sieve_parse_buffer(struct sieve2_context *context)
{
commandlist_t *t;
void *sieve_scan = context->sieve_scan;
YY_BUFFER_STATE buf = libsieve_sieve_scan_string(context->script.script, sieve_scan);
if (libsieve_sieveparse(context, sieve_scan)) {
return NULL;
} else {
libsieve_sieve_delete_buffer(buf, sieve_scan);
t = context->sieve_ret;
context->sieve_ret = NULL;
return t;
}
}
int libsieve_sieveerror(struct sieve2_context *context, void* yyscanner, const char *msg)
{
context->parse_errors++;
libsieve_do_error_parse(context, libsieve_sieveget_lineno(context->sieve_scan), msg);
return 0;
}
static test_t *static_build_address(struct sieve2_context *context, int t,
struct aetags *ae, stringlist_t *sl, patternlist_t *pl)
{
test_t *ret = libsieve_new_test(t); /* can be either ADDRESS or ENVELOPE */
libsieve_assert((t == ADDRESS) || (t == ENVELOPE));
if (ret) {
ret->u.ae.comptag = ae->comptag;
ret->u.ae.comp = libsieve_comparator_lookup(context, ae->comparator, ae->comptag);
ret->u.ae.sl = sl;
ret->u.ae.pl = pl;
ret->u.ae.addrpart = ae->addrtag;
static_free_aetags(ae);
if (ret->u.ae.comp == NULL) {
libsieve_free_test(ret);
ret = NULL;
}
}
return ret;
}
static test_t *static_build_header(struct sieve2_context *context, int t, struct htags *h, stringlist_t *sl, patternlist_t *pl)
{
test_t *ret = libsieve_new_test(t); /* can be HEADER */
libsieve_assert(t == HEADER);
if (ret) {
ret->u.h.comptag = h->comptag;
ret->u.h.comp = libsieve_comparator_lookup(context, h->comparator, h->comptag);
ret->u.h.sl = sl;
ret->u.h.pl = pl;
static_free_htags(h);
if (ret->u.h.comp == NULL) {
libsieve_free_test(ret);
ret = NULL;
}
}
return ret;
}
static commandlist_t *static_build_vacation(struct sieve2_context *context, int t, struct vtags *v, char *reason)
{
commandlist_t *ret = libsieve_new_command(t);
libsieve_assert(t == VACATION);
if (ret) {
ret->u.v.subject = v->subject; v->subject = NULL;
ret->u.v.handle = v->handle; v->handle = NULL;
ret->u.v.from = v->from; v->from = NULL;
ret->u.v.days = v->days;
ret->u.v.mime = v->mime;
ret->u.v.addresses = v->addresses; v->addresses = NULL;
static_free_vtags(v);
ret->u.v.message = reason;
}
return ret;
}
static commandlist_t *static_build_notify(struct sieve2_context *context, int t, struct ntags *n)
{
commandlist_t *ret = libsieve_new_command(t);
libsieve_assert(t == NOTIFY);
if (ret) {
ret->u.n.method = n->method; n->method = NULL;
ret->u.n.id = n->id; n->id = NULL;
ret->u.n.options = n->options; n->options = NULL;
ret->u.n.priority = n->priority;
ret->u.n.message = n->message; n->message = NULL;
static_free_ntags(n);
}
return ret;
}
// FIXME: I think we just test and return true or false... check around.
static commandlist_t *static_build_validnotif(struct sieve2_context *context, int t, stringlist_t *sl)
{
commandlist_t *ret = libsieve_new_command(t);
libsieve_assert(t == VALIDNOTIF);
/*
if (ret) {
ret->u.d.comptag = d->comptag;
ret->u.d.comp = libsieve_comparator_lookup(context, "i;ascii-casemap", d->comptag);
ret->u.d.pattern = d->pattern; d->pattern = NULL;
ret->u.d.priority = d->priority;
static_free_dtags(d);
}*/
return ret;
}
static struct hftags *static_new_hftags(void)
{
struct hftags *r = (struct hftags *) libsieve_malloc(sizeof(struct hftags));
r->comptag = -1;
r->comparator = NULL;
return r;
}
static struct aetags *static_new_aetags(void)
{
struct aetags *r = (struct aetags *) libsieve_malloc(sizeof(struct aetags));
r->addrtag = r->comptag = -1;
r->comparator = NULL;
return r;
}
static struct aetags *static_canon_aetags(struct aetags *ae)
{
char *map = "i;ascii-casemap";
if (ae->addrtag == -1) { ae->addrtag = ALL; }
if (ae->comparator == NULL) { ae->comparator = libsieve_strdup(map); }
if (ae->comptag == -1) { ae->comptag = IS; }
return ae;
}
static void static_free_aetags(struct aetags *ae)
{
libsieve_free(ae->comparator);
libsieve_free(ae);
}
static struct htags *static_new_htags(void)
{
struct htags *r = (struct htags *) libsieve_malloc(sizeof(struct htags));
r->comptag = -1;
r->comparator = NULL;
return r;
}
static struct htags *static_canon_htags(struct htags *h)
{
char *map = "i;ascii-casemap";
if (h->comparator == NULL) { h->comparator = libsieve_strdup(map); }
if (h->comptag == -1) { h->comptag = IS; }
return h;
}
static void static_free_htags(struct htags *h)
{
libsieve_free(h->comparator);
libsieve_free(h);
}
static struct vtags *static_new_vtags(void)
{
struct vtags *r = (struct vtags *) libsieve_malloc(sizeof(struct vtags));
r->days = -1;
r->addresses = NULL;
r->subject = NULL;
r->handle = NULL;
r->from = NULL;
r->mime = -1;
return r;
}
static struct vtags *static_canon_vtags(struct vtags *v)
{
/* TODO: Change this to an *in*sane default, and specify that the
* client app has to check for boundaries. That would be much
* simpler than having a context registration for something that
* the user cannot test/check for at all.
*/
if (v->days == -1) { v->days = 7; }
if (v->mime == -1) { v->mime = 0; }
return v;
}
static void static_free_vtags(struct vtags *v)
{
if (v->addresses) { libsieve_free_sl(v->addresses); }
libsieve_free(v->subject);
libsieve_free(v->handle);
libsieve_free(v->from);
libsieve_free(v);
}
static struct ntags *static_new_ntags(void)
{
struct ntags *r = (struct ntags *) libsieve_malloc(sizeof(struct ntags));
r->method = NULL;
r->id = NULL;
r->options = NULL;
r->priority = NULL;
r->message = NULL;
return r;
}
static struct ntags *static_canon_ntags(struct ntags *n)
{
char *from = "$from$: $subject$";
if (n->priority == NULL) { n->priority = "normal"; }
if (n->message == NULL) { n->message = libsieve_strdup(from); }
return n;
}
static void static_free_ntags(struct ntags *n)
{
libsieve_free(n->method);
libsieve_free(n->id);
if (n->options) libsieve_free_sl(n->options);
libsieve_free(n->message);
libsieve_free(n);
}
static int static_verify_stringlist(struct sieve2_context *context, stringlist_t *sl, int (*verify)(struct sieve2_context*, const char *))
{
for (; sl != NULL && verify(context, sl->s); sl = sl->next) ;
return (sl == NULL);
}
static int static_verify_flag(struct sieve2_context *context, const char *s)
{
/* xxx if not a flag, call sieveerror */
return 1;
}
static int static_verify_address(struct sieve2_context *context, const char *s)
{
struct address *addr = NULL;
addr = libsieve_addr_parse_buffer(context, &addr, &s);
if (addr == NULL) {
return 0;
}
libsieve_addrstructfree(context, addr, CHARSALSO);
return 1;
}
static int static_verify_mailbox(const char *s UNUSED)
{
/* xxx if not a mailbox, call sieveerror */
return 1;
}
static int static_verify_header(struct sieve2_context *context, const char *hdr)
{
const char *h = hdr;
char *err;
while (*h) {
/* field-name = 1*ftext
ftext = %d33-57 / %d59-126
; Any character except
; controls, SP, and
; ":". */
if (!((*h >= 33 && *h <= 57) || (*h >= 59 && *h <= 126))) {
err = libsieve_strconcat("header '", hdr, "': not a valid header", NULL);
libsieve_sieveerror(context, context->sieve_scan, err);
libsieve_free(err);
return 0;
}
h++;
}
return 1;
}
/* Was this supposed to be modifying its argument?! */
/*
static int static_verify_flag(const char *flag)
{
int ret;
char *f, *err;
// Make ourselves a local copy to change the case
f = libsieve_strdup(flag);
if (f[0] == '\\') {
libsieve_strtolower(f,strlen(f));
if (strcmp(f, "\\\\seen") && strcmp(f, "\\\\answered") &&
strcmp(f, "\\\\flagged") && strcmp(f, "\\\\draft") &&
strcmp(f, "\\\\deleted")) {
err = libsieve_strconcat("flag '", f, "': not a system flag", NULL);
libsieve_sieveerror(err);
libsieve_free(err);
ret = 0;
}
ret = 1;
}
else if (!libsieve_strisatom(f,strlen(f))) {
err = libsieve_strconcat("flag '", f, "': not a valid keyword", NULL);
libsieve_sieveerror(err);
libsieve_free(err);
ret = 0;
}
ret = 1;
libsieve_free(f);
return ret;
}
*/
static regex_t *static_verify_regex(struct sieve2_context *context, const char *s, int cflags)
{
int ret;
char errbuf[100];
regex_t *reg = (regex_t *) libsieve_malloc(sizeof(regex_t));
if ((ret = libsieve_regcomp(reg, s, cflags)) != 0) {
(void) libsieve_regerror(ret, reg, errbuf, sizeof(errbuf));
libsieve_sieveerror(context, context->sieve_scan, errbuf);
libsieve_free(reg);
return NULL;
}
return reg;
}
static patternlist_t *static_verify_regexs(struct sieve2_context *context, stringlist_t *sl, char *comp)
{
stringlist_t *sl2;
patternlist_t *pl = NULL;
int cflags = REG_EXTENDED | REG_NOSUB;
regex_t *reg;
if (!strcmp(comp, "i;ascii-casemap")) {
cflags |= REG_ICASE;
}
for (sl2 = sl; sl2 != NULL; sl2 = sl2->next) {
if ((reg = static_verify_regex(context, sl2->s, cflags)) == NULL) {
libsieve_free_pl(pl, REGEX);
break;
}
pl = libsieve_new_pl(reg, pl);
}
if (sl2 == NULL) {
libsieve_free_sl(sl);
return pl;
}
return NULL;
}
/* xxx is it ok to put this in an RFC822 header body? */
static int static_ok_header(char *s UNUSED)
{
return 1;
}
/* Checks if interpreter supports specified action
* */
static int static_check_reqs(struct sieve2_context *c, char *req)
{
if (0 == strcmp("fileinto", req)) {
return c->require.fileinto = c->support.fileinto;
} else if (0 == strcmp("reject", req)) {
return c->require.reject = c->support.reject;
} else if (!strcmp("envelope", req)) {
return c->require.envelope = c->support.envelope;
} else if (!strcmp("vacation", req)) {
return c->require.vacation = c->support.vacation;
} else if (!strcmp("notify",req)) {
return c->require.notify = c->support.notify;
} else if (!strcmp("subaddress", req)) {
return c->require.subaddress = c->support.subaddress;
/* imap4flags is built into the parser. */
} else if (!strcmp("imap4flags", req)) {
return c->require.imap4flags = 1;
/* regex is built into the parser. */
} else if (!strcmp("regex", req)) {
return c->require.regex = 1;
/* relational is built into the parser. */
} else if (!strcmp("relational", req)) {
return c->require.relational = 1;
/* These comparators are built into the parser. */
} else if (!strcmp("comparator-i;octet", req)) {
return 1;
} else if (!strcmp("comparator-i;ascii-casemap", req)) {
return 1;
} else if (!strcmp("comparator-i;ascii-numeric", req)) {
return 1;
}
/* If we don't recognize it, then we don't support it! */
return 0;
}
|
<reponame>npocmaka/Windows-Server-2003
%{
class CValueParser;
#if 0
%}
%union
{
WCHAR * pwszChar;
DBCOMMANDOP dbop;
CDbRestriction * pRest;
CStorageVariant * pStorageVar;
CValueParser *pPropValueParser;
int iInt;
int iEmpty;
}
%left _OR
%left _AND _NEAR _NEARDIST
%left _NOT
%left '(' ')'
/***
*** Tokens (used also by flex via parser.h)
***/
/***
*** reserved_words
***/
%token _CONTAINS
%token _AND
%token _OR
%token _NOT
%token _NEAR
%token _LT
%token _GT
%token _LTE
%token _GTE
%token _EQ
%token _NE
%token _ALLOF
%token _SOMEOF
%token _OPEN
%token _CLOSE
%token _VECTOR_END
%token _VE
%token _VE_END
%token _PROPEND
%token _NEAR_END
%token _LTSOME
%token _GTSOME
%token _LTESOME
%token _GTESOME
%token _EQSOME
%token _NESOME
%token _ALLOFSOME
%token _SOMEOFSOME
%token _LTALL
%token _GTALL
%token _LTEALL
%token _GTEALL
%token _EQALL
%token _NEALL
%token _ALLOFALL
%token _SOMEOFALL
%token _COERCE
%token _SHGENPREFIX
%token _SHGENINFLECT
%token _GENPREFIX
%token _GENINFLECT
%token _GENNORMAL
/***
*** Terminal tokens
***/
%token <pwszChar> _PHRASE
%token <pwszChar> _PROPNAME
%token <pwszChar> _NEARDIST
%token <pwszChar> _NEARUNIT
%token <pwszChar> _WEIGHT
%token <pwszChar> _REGEX
%token <pwszChar> _FREETEXT
%token <pwszChar> _VECTORELEMENT
%token <pwszChar> _VEMETHOD
%token <pwszChar> _PHRASEORREGEX
/***
*** Nonterminal tokens
***/
%type <pStorageVar> Value
%type <pStorageVar> VectorValue
%type <pPropValueParser> SingletVector
%type <pPropValueParser> EmptyVector
%type <pPropValueParser> MultiVector
%type <dbop> Op
%type <dbop> Matches
%type <iEmpty> Property // placeholder. value is empty (info saved to state)
%type <iEmpty> Contains // placeholder. value is empty
%type <iEmpty> Open // placeholder. value is empty
%type <iEmpty> Close // placeholder. value is empty
%type <iInt> Gen
%type <iEmpty> GenEnd // placeholder. value is empty (info saved to state)
%type <iEmpty> PropEnd // placeholder. value is empty (info saved to state)
%type <iInt> ShortGen
%type <pRest> Term
%type <pRest> PropTerm
%type <pRest> NestTerm
%type <pRest> CoerceTerm
%type <pRest> NearTerm
%type <pRest> AndTerm
%type <pRest> VectorTerm
%type <pRest> VectorSpec
%type <pRest> query
%{
#endif
#define YYDEBUG CIDBG
#include <malloc.h>
#include "yybase.hxx"
#include "parser.h" // defines yystype
#include "parsepl.h"
#include "flexcpp.h"
#if CIDBG == 1
#define AssertReq(x) Assert(x != NULL)
#else
#define AssertReq(x)
#endif
const GUID guidSystem = PSGUID_STORAGE;
static CDbColId psContents( guidSystem, PID_STG_CONTENTS );
//+---------------------------------------------------------------------------
//
// Function: TreeFromText, public
//
// Synopsis: Create a CDbRestriction from a restriction string
//
// Arguments: [wcsRestriction] -- restriction
// [ColumnMapper] -- property list
// [lcid] -- locale id of the query
//
// History: 01-Oct-97 emilyb created
// 26-Aug-98 KLam No longer need to lower case
//
//----------------------------------------------------------------------------
CDbContentRestriction * TreeFromText(
WCHAR const * wcsRestriction,
IColumnMapper & ColumnMapper,
LCID lcid )
{
unsigned cwc = 1 + wcslen( wcsRestriction );
XGrowable<WCHAR> xRestriction( cwc );
WCHAR * pwc = xRestriction.Get();
RtlCopyMemory( pwc, wcsRestriction, cwc * sizeof WCHAR );
cwc--;
// The parser can't deal with trailing space so strip it off
while ( cwc > 0 && L' ' == pwc[cwc-1] )
cwc--;
pwc[cwc] = 0;
TripLexer Lexer;
XPtr<YYPARSER> xParser( new TripParser( ColumnMapper, lcid, Lexer ) );
xParser->yyprimebuffer( pwc );
#if 0 // YYDEBUG == 1
// Set this to 1 if you want command line output. to 0 otherwise.
xParser->SetDebug();
#endif
// Actually parse the text producing a tree
SCODE hr = xParser->Parse();
if (FAILED(hr))
THROW( CException( hr ) );
// return the DBCOMMANDTREE
return (CDbContentRestriction *)( xParser->GetParseTree() );
} //TextFromTree
void StripQuotes(WCHAR *wcsPhrase)
{
ULONG cChars = wcslen(wcsPhrase);
LPWSTR pLast = wcsPhrase + cChars - 1;
if (L'"' == *wcsPhrase && L'"' == *pLast)
{
*pLast = L'\0';
MoveMemory(wcsPhrase, wcsPhrase+1, sizeof(WCHAR) * (cChars-1) );
}
}
//+---------------------------------------------------------------------------
//
// Member: CValueParser::CValueParser, public
//
// Synopsis: Allocs CStorageVariant of correct type
//
// History: 01-Oct-97 emilyb created
// 02-Sep-98 KLam Added locale
//
//----------------------------------------------------------------------------
CValueParser::CValueParser(
BOOL fVectorElement,
DBTYPE PropType,
LCID locale ) :
_pStgVariant( 0 ),
_fVector(fVectorElement),
_PropType (PropType),
_cElements ( 0 ),
_locale ( locale )
{
if ( _fVector )
{
// this is a vector
if ( DBTYPE_VECTOR != ( _PropType & DBTYPE_VECTOR ) )
THROW( CParserException( QPARSE_E_EXPECTING_PHRASE ) );
VARENUM ve = (VARENUM ) _PropType;
if ( _PropType == ( DBTYPE_VECTOR | DBTYPE_WSTR ) )
ve = (VARENUM) (VT_VECTOR | VT_LPWSTR);
else if ( _PropType == ( DBTYPE_VECTOR | DBTYPE_STR ) )
ve = (VARENUM) (VT_VECTOR | VT_LPSTR);
_pStgVariant.Set( new CStorageVariant( ve, _cElements ) );
}
else
{
_pStgVariant.Set( new CStorageVariant() );
}
if ( _pStgVariant.IsNull() )
THROW( CException( E_OUTOFMEMORY ) );
}
//+---------------------------------------------------------------------------
//
// Member: CValueParser::AddValue, public
//
// Synopsis: Adds value to CStorageVariant
//
// Arguments: [pwszValue] -- value
//
// History: 01-Oct-97 emilyb code moved here from CPropertyValueParser
//
//----------------------------------------------------------------------------
void CValueParser::AddValue(WCHAR const * pwszValue)
{
if ( _pStgVariant.IsNull() )
THROW( CException( E_OUTOFMEMORY ) );
switch ( _PropType & ~DBTYPE_VECTOR )
{
case DBTYPE_WSTR :
case DBTYPE_WSTR | DBTYPE_BYREF :
{
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetLPWSTR( pwszValue, _cElements );
else
_pStgVariant->SetLPWSTR( pwszValue );
break;
}
case DBTYPE_BSTR :
{
BSTR bstr = SysAllocString( pwszValue );
if ( 0 == bstr )
THROW( CException( E_OUTOFMEMORY ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetBSTR( bstr, _cElements );
else
_pStgVariant->SetBSTR( bstr );
SysFreeString( bstr );
break;
}
case DBTYPE_STR :
case DBTYPE_STR | DBTYPE_BYREF :
{
// make sure there's enough room to translate
unsigned cbBuffer = 1 + 3 * wcslen( pwszValue );
XArray<char> xBuf( cbBuffer );
int cc = WideCharToMultiByte( CP_ACP,
0,
pwszValue,
-1,
xBuf.Get(),
cbBuffer,
NULL,
NULL );
if ( 0 == cc )
{
#if CIDBG
ULONG ul = GetLastError();
#endif
THROW( CParserException( QPARSE_E_EXPECTING_PHRASE ) );
}
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetLPSTR( xBuf.Get(), _cElements );
else
_pStgVariant->SetLPSTR( xBuf.Get() );
break;
}
case DBTYPE_I1 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
LONG l = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( l, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( ( l > SCHAR_MAX ) ||
( l < SCHAR_MIN ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetI1( (CHAR) l, _cElements );
else
_pStgVariant->SetI1( (CHAR) l );
break;
}
case DBTYPE_UI1 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
ULONG ul = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( ul, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( ul > UCHAR_MAX )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetUI1( (BYTE) ul, _cElements );
else
_pStgVariant->SetUI1( (BYTE) ul );
break;
}
case DBTYPE_I2 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
LONG l = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( l, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( ( l > SHRT_MAX ) ||
( l < SHRT_MIN ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetI2( (short) l, _cElements );
else
_pStgVariant->SetI2( (short) l );
break;
}
case DBTYPE_UI2 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
ULONG ul = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( ul, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( ul > USHRT_MAX )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetUI2( (USHORT) ul, _cElements );
else
_pStgVariant->SetUI2( (USHORT) ul );
break;
}
case DBTYPE_I4 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
LONG l = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( l, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetI4( l, _cElements );
else
_pStgVariant->SetI4( l );
break;
}
case DBTYPE_UI4 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
ULONG ul = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( ul, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetUI4( ul, _cElements );
else
_pStgVariant->SetUI4( ul );
break;
}
case DBTYPE_ERROR :
{
// SCODE/HRESULT are typedefed as long (signed)
CQueryScanner scan( pwszValue, FALSE, _locale );
SCODE sc = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( sc, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetERROR( sc, _cElements );
else
_pStgVariant->SetERROR( sc );
break;
}
case DBTYPE_I8 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
_int64 ll = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( ll, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
LARGE_INTEGER LargeInt;
LargeInt.QuadPart = ll;
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetI8( LargeInt , _cElements );
else
_pStgVariant->SetI8( LargeInt );
break;
}
case DBTYPE_UI8 :
{
CQueryScanner scan( pwszValue, FALSE, _locale );
unsigned _int64 ull = 0;
BOOL fAtEndOfString;
if ( ! ( scan.GetNumber( ull, fAtEndOfString ) &&
fAtEndOfString ) )
THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
ULARGE_INTEGER LargeInt;
LargeInt.QuadPart = ull;
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetUI8( LargeInt , _cElements );
else
_pStgVariant->SetUI8( LargeInt );
break;
}
case DBTYPE_BOOL :
{
if ( pwszValue[0] == 'T' ||
pwszValue[0] == 't' )
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetBOOL( VARIANT_TRUE, _cElements );
else
_pStgVariant->SetBOOL( VARIANT_TRUE );
else
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetBOOL( VARIANT_FALSE, _cElements );
else
_pStgVariant->SetBOOL( VARIANT_FALSE );
break;
}
case DBTYPE_R4 :
{
WCHAR *pwcEnd = 0;
float Float = (float)( wcstod( pwszValue, &pwcEnd ) );
if ( *pwcEnd != 0 && !iswspace( *pwcEnd ) )
THROW( CParserException( QPARSE_E_EXPECTING_REAL ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetR4( Float, _cElements );
else
_pStgVariant->SetR4( Float );
break;
}
case DBTYPE_R8 :
{
WCHAR *pwcEnd = 0;
double Double = ( double )( wcstod( pwszValue, &pwcEnd ) );
if ( *pwcEnd != 0 && !iswspace( *pwcEnd ) )
THROW( CParserException( QPARSE_E_EXPECTING_REAL ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetR8( Double, _cElements );
else
_pStgVariant->SetR8( Double );
break;
}
case DBTYPE_DECIMAL :
{
WCHAR *pwcEnd = 0;
double Double = ( double )( wcstod( pwszValue, &pwcEnd ) );
if( *pwcEnd != 0 && !iswspace( *pwcEnd ) )
THROW( CParserException( QPARSE_E_EXPECTING_REAL ) );
// Vectors are not supported by OLE for VT_DECIMAL (yet)
Win4Assert( 0 == ( _PropType & DBTYPE_VECTOR ) );
PROPVARIANT * pPropVar = (PROPVARIANT *) _pStgVariant.GetPointer();
VarDecFromR8( Double, &(pPropVar->decVal) );
pPropVar->vt = VT_DECIMAL;
break;
}
case DBTYPE_DATE :
{
FILETIME ftValue;
ParseDateTime( pwszValue, ftValue );
SYSTEMTIME stValue;
BOOL fOK = FileTimeToSystemTime( &ftValue, &stValue );
if ( !fOK )
THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
DATE dosDate;
fOK = SystemTimeToVariantTime( &stValue, &dosDate );
if ( !fOK )
THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetDATE( dosDate, _cElements );
else
_pStgVariant->SetDATE( dosDate );
break;
}
case VT_FILETIME :
{
FILETIME ftValue;
ParseDateTime( pwszValue, ftValue );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetFILETIME( ftValue, _cElements );
else
_pStgVariant->SetFILETIME( ftValue );
break;
}
case DBTYPE_CY :
{
double dbl;
if ( swscanf( pwszValue,
L"%lf",
&dbl ) < 1 )
THROW( CParserException( QPARSE_E_EXPECTING_CURRENCY ) );
CY cyCurrency;
VarCyFromR8( dbl, &cyCurrency );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetCY( cyCurrency, _cElements );
else
_pStgVariant->SetCY( cyCurrency );
break;
}
case DBTYPE_GUID :
case DBTYPE_GUID | DBTYPE_BYREF:
{
CLSID clsid;
if ( swscanf( pwszValue,
L"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
&clsid.Data1,
&clsid.Data2,
&clsid.Data3,
&clsid.Data4[0], &clsid.Data4[1],
&clsid.Data4[2], &clsid.Data4[3],
&clsid.Data4[4], &clsid.Data4[5],
&clsid.Data4[6], &clsid.Data4[7] ) < 11 )
THROW( CParserException( QPARSE_E_EXPECTING_GUID ) );
if ( _PropType & DBTYPE_VECTOR )
_pStgVariant->SetCLSID( clsid, _cElements );
else
_pStgVariant->SetCLSID( &clsid );
break;
}
default:
{
THROW( CParserException( QPARSE_E_UNSUPPORTED_PROPERTY_TYPE ) );
}
} // switch
// make sure memory allocations succeeded
if ( !_pStgVariant->IsValid() )
THROW( CException( E_OUTOFMEMORY ) );
if ( _fVector )
{
_cElements++;
}
}
//+---------------------------------------------------------------------------
//
// Member: CValueParser::ParseDateTime, private
//
// Synopsis: Attempts to parse a date expression.
//
// Arguments: phrase -- pointer to the phrase to parse
// ft -- reference to the FILETIME structure to fill in
// with the result
//
// History: 31-May-96 dlee Created
// 23-Jan-97 KyleP Better Year 2000 support
// 02-Sep-98 KLam Use user settings for Y2K support
//
//----------------------------------------------------------------------------
void CValueParser::ParseDateTime(
WCHAR const * phrase,
FILETIME & ft )
{
if( !CheckForRelativeDate( phrase, ft ) )
{
SYSTEMTIME stValue = { 0, 0, 0, 0, 0, 0, 0, 0 };
int cItems = swscanf( phrase,
L"%4hd/%2hd/%2hd %2hd:%2hd:%2hd:%3hd",
&stValue.wYear,
&stValue.wMonth,
&stValue.wDay,
&stValue.wHour,
&stValue.wMinute,
&stValue.wSecond,
&stValue.wMilliseconds );
if ( 1 == cItems )
cItems = swscanf( phrase,
L"%4hd-%2hd-%2hd %2hd:%2hd:%2hd:%3hd",
&stValue.wYear,
&stValue.wMonth,
&stValue.wDay,
&stValue.wHour,
&stValue.wMinute,
&stValue.wSecond,
&stValue.wMilliseconds );
if( cItems != 3 && cItems != 6 && cItems != 7)
THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
//
// Make a sensible split for Year 2000 using the user's system settings
//
if ( stValue.wYear < 100 )
{
DWORD dwYearHigh = 0;
if ( 0 == GetCalendarInfo ( _locale,
CAL_GREGORIAN,
CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
0,
0,
&dwYearHigh ) )
{
THROW ( CException () );
}
if ( ( dwYearHigh < 99 ) || ( dwYearHigh > 9999 ) )
dwYearHigh = 2029;
WORD wMaxDecade = (WORD) dwYearHigh % 100;
WORD wMaxCentury = (WORD) dwYearHigh - wMaxDecade;
if ( stValue.wYear <= wMaxDecade )
stValue.wYear += wMaxCentury;
else
stValue.wYear += ( wMaxCentury - 100 );
}
if( !SystemTimeToFileTime( &stValue, &ft ) )
THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
}
} //ParseDateTime
//+---------------------------------------------------------------------------
//
// Member: CValueParser::CheckForRelativeDate, private
//
// Synopsis: Attempts to parse a relative date expression. If successful,
// it fills in the FILETIME structure with the calculated
// absolute date.
//
// Notes: Returns TRUE if the phrase is recognized as a relative
// date (i.e., it begins with a '-'). Otherwise, returns FALSE.
// The format of a relative date is
// "-"{INTEGER("h"|"n"|"s"|"y"|"q"|"m"|"d"|"w")}*
// Case is not significant.
//
// Arguments: phrase -- pointer to the phrase to parse
// ft -- reference to the FILETIME structure to fill in
// with the result
//
// History: 26-May-94 t-jeffc Created
// 02-Mar-95 t-colinb Moved from CQueryParser to
// be more accessible
// 22-Jan-97 KyleP Fix local/UTC discrepancy
//
//----------------------------------------------------------------------------
BOOL CValueParser::CheckForRelativeDate(
WCHAR const * phrase,
FILETIME & ft )
{
if( *phrase++ == L'-' )
{
SYSTEMTIME st;
LARGE_INTEGER liLocal;
LONGLONG llTicksInADay = ((LONGLONG)10000000) * ((LONGLONG)3600)
* ((LONGLONG) 24);
LONGLONG llTicksInAHour = ((LONGLONG) 10000000) * ((LONGLONG)3600);
int iMonthDays[12] = {1,-1,1,0,1,0,1,1,0,1,0,1};
int iLoopValue, iPrevMonth, iPrevQuarter, iQuarterOffset;
WORD wYear, wDayOfMonth, wStartDate;
//
//Obtain local time and convert it to file time
//Copy the filetime to largeint data struct
//
GetSystemTime(&st);
if(!SystemTimeToFileTime(&st, &ft))
THROW( CParserException( QPARSE_E_INVALID_LITERAL ));
liLocal.LowPart = ft.dwLowDateTime;
liLocal.HighPart = ft.dwHighDateTime;
LONGLONG llRelDate = (LONGLONG)0;
for( ;; )
{
// eat white space
while( iswspace( *phrase ) )
phrase++;
if( *phrase == 0 ) break;
// parse the number
WCHAR * pwcEnd;
LONG lValue = wcstol( phrase, &pwcEnd, 10 );
if( lValue < 0 )
THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
// eat white space
phrase = pwcEnd;
while( iswspace( *phrase ) )
phrase++;
// grab the unit char & subtract the appropriate amount
WCHAR wcUnit = *phrase++;
switch( wcUnit )
{
case L'y':
case L'Y':
lValue *= 4;
// Fall through and handle year like 4 quarters
case L'q':
case L'Q':
lValue *= 3;
// Fall through and handle quarters like 3 months
case L'm':
case L'M':
// Getting the System time to determine the day and month.
if(!FileTimeToSystemTime(&ft, &st))
{
THROW(CParserException(QPARSE_E_INVALID_LITERAL));
}
wStartDate = st.wDay;
wDayOfMonth = st.wDay;
iLoopValue = lValue;
while(iLoopValue)
{
// Subtracting to the end of previous month
llRelDate = llTicksInADay * ((LONGLONG)(wDayOfMonth));
liLocal.QuadPart -= llRelDate;
ft.dwLowDateTime = liLocal.LowPart;
ft.dwHighDateTime = liLocal.HighPart;
SYSTEMTIME stTemp;
if(!FileTimeToSystemTime(&ft, &stTemp))
{
THROW(CParserException(QPARSE_E_INVALID_LITERAL));
}
//
// if the end of previous month is greated then start date then we subtract to back up to the
// start date. This will take care of 28/29 Feb(backing from 30/31 by 1 month).
//
if(stTemp.wDay > wStartDate)
{
llRelDate = llTicksInADay * ((LONGLONG)(stTemp.wDay - wStartDate));
liLocal.QuadPart -= llRelDate;
ft.dwLowDateTime = liLocal.LowPart;
ft.dwHighDateTime = liLocal.HighPart;
// Getting the date into stTemp for further iteration
if(!FileTimeToSystemTime(&ft, &stTemp))
{
THROW( CParserException( QPARSE_E_INVALID_LITERAL ));
}
}
wDayOfMonth = stTemp.wDay;
iLoopValue--;
} //End While
break;
case L'w':
case L'W':
lValue *= 7;
case L'd':
case L'D':
llRelDate = llTicksInADay * ((LONGLONG)lValue);
liLocal.QuadPart -= llRelDate;
ft.dwLowDateTime = liLocal.LowPart;
ft.dwHighDateTime = liLocal.HighPart;
break;
case L'h':
case L'H':
llRelDate = llTicksInAHour * ((LONGLONG)lValue);
liLocal.QuadPart -= llRelDate;
ft.dwLowDateTime = liLocal.LowPart;
ft.dwHighDateTime = liLocal.HighPart;
break;
case L'n':
case L'N':
llRelDate = ((LONGLONG)10000000) * ((LONGLONG)60) * ((LONGLONG)lValue) ;
liLocal.QuadPart -= llRelDate;
ft.dwLowDateTime = liLocal.LowPart;
ft.dwHighDateTime = liLocal.HighPart;
break;
case L's':
case L'S':
llRelDate = ((LONGLONG)10000000) * ((LONGLONG)lValue);
liLocal.QuadPart -= llRelDate;
ft.dwLowDateTime = liLocal.LowPart;
ft.dwHighDateTime = liLocal.HighPart;
break;
default:
THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
}
} // for( ;; )
return TRUE;
}
else
{
return FALSE;
}
}
%}
%start query
%%
/***
*** Tripolish YACC grammar
***
*** Note - left recursion (i.e. A: A,B) used throughout because yacc
*** handles it more efficiently.
***
***/
query: AndTerm
{
$$ = $1;
}
| query _OR AndTerm
{
AssertReq($1);
AssertReq($3);
XDbRestriction prstQuery($1);
XDbRestriction prstTerm($3);
_setRst.Remove( $1 );
_setRst.Remove( $3 );
BOOL fAcquireQuery = FALSE;
XDbBooleanNodeRestriction prstNew;
if (DBOP_or == $1->GetCommandType())
{
// add right term & release its smart pointer
((CDbBooleanNodeRestriction *)($1))->AppendChild( prstTerm.GetPointer() );
prstTerm.Acquire();
fAcquireQuery = TRUE;
$$ = prstQuery.GetPointer();
}
else
{
// create smart Or node
prstNew.Set( new CDbBooleanNodeRestriction( DBOP_or ) );
if( 0 == prstNew.GetPointer() )
THROW( CException( E_OUTOFMEMORY ) );
prstNew->SetWeight(MAX_QUERY_RANK);
// add left term & release its smart pointer
prstNew->AppendChild( prstQuery.GetPointer() );
prstQuery.Acquire();
// add right term & release its smart pointer
prstNew->AppendChild( prstTerm.GetPointer() );
prstTerm.Acquire();
$$ = prstNew.GetPointer();
}
_setRst.Add( $$ );
if ( fAcquireQuery )
prstQuery.Acquire();
else
prstNew.Acquire();
}
| _NOT query
{
AssertReq($2);
XDbRestriction prstQuery($2);
_setRst.Remove( $2 );
// Create not node
XDbBooleanNodeRestriction prstNew( new CDbBooleanNodeRestriction( DBOP_not ) );
if( 0 == prstNew.GetPointer() )
THROW( CException( E_OUTOFMEMORY ) );
prstNew->SetWeight(MAX_QUERY_RANK);
// add right term and release its smart pointer
prstNew->AppendChild( prstQuery.GetPointer() );
prstQuery.Acquire();
$$ = prstNew.GetPointer();
_setRst.Add( $$ );
prstNew.Acquire();
}
;
AndTerm: NearTerm
{ $$ = $1;}
| _NOT PropTerm
{
AssertReq($2);
XDbRestriction prstTerm($2);
_setRst.Remove( $2 );
// Create not node
XDbBooleanNodeRestriction prstNew( new CDbBooleanNodeRestriction( DBOP_not ) );
if( 0 == prstNew.GetPointer() )
THROW( CException( E_OUTOFMEMORY ) );
prstNew->SetWeight(MAX_QUERY_RANK);
// add right term and release its smart pointer
prstNew->AppendChild( prstTerm.GetPointer() );
prstTerm.Acquire();
$$ = prstNew.GetPointer();
_setRst.Add( $$ );
prstNew.Acquire();
}
| AndTerm _AND NearTerm
{
AssertReq($1);
AssertReq($3);
XDbRestriction prstQuery($1);
XDbRestriction prstTerm($3);
_setRst.Remove( $1 );
_setRst.Remove( $3 );
BOOL fAcquireQuery = FALSE;
XDbBooleanNodeRestriction prstNew;
if (DBOP_and == $1->GetCommandType())
{
// add right term & release its smart pointer
((CDbBooleanNodeRestriction *)($1))->AppendChild( prstTerm.GetPointer() );
prstTerm.Acquire();
fAcquireQuery = TRUE;
$$ = prstQuery.GetPointer();
}
else
{
// create smart And node
prstNew.Set( new CDbBooleanNodeRestriction( DBOP_and ) );
if( prstNew.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
prstNew->SetWeight(MAX_QUERY_RANK);
// add left term & release its smart pointer
prstNew->AppendChild( prstQuery.GetPointer() );
prstQuery.Acquire();
// add right term & release its smart pointer
prstNew->AppendChild( prstTerm.GetPointer() );
prstTerm.Acquire();
$$ = prstNew.GetPointer();
}
_setRst.Add( $$ );
if ( fAcquireQuery )
prstQuery.Acquire();
else
prstNew.Acquire();
}
| AndTerm _AND _NOT NearTerm
{
AssertReq($1);
AssertReq($4);
XDbRestriction prstQuery($1);
XDbRestriction prstTerm($4);
_setRst.Remove( $1 );
_setRst.Remove( $4 );
// create smart Not node
XDbNotRestriction prstNot( new CDbNotRestriction );
if( prstNot.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
prstNot->SetWeight(MAX_QUERY_RANK);
// set child of Not node & release smart factor pointer
prstNot->SetChild( prstTerm.GetPointer() );
prstTerm.Acquire();
BOOL fAcquireQuery = FALSE;
XDbBooleanNodeRestriction prstNew;
if (DBOP_and == $1->GetCommandType())
{
// add right term & release its smart pointer
((CDbBooleanNodeRestriction *)($1))->AppendChild( prstNot.GetPointer() );
prstNot.Acquire();
$$ = prstQuery.GetPointer();
fAcquireQuery = TRUE;
}
else
{
// create smart And node
prstNew.Set( new CDbBooleanNodeRestriction( DBOP_and ) );
if( prstNew.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
prstNew->SetWeight(MAX_QUERY_RANK);
// add left term & release its smart pointer
prstNew->AppendChild( prstQuery.GetPointer() );
prstQuery.Acquire();
// add right term & release its smart pointer
prstNew->AppendChild( prstNot.GetPointer() );
prstNot.Acquire();
$$ = prstNew.GetPointer();
}
_setRst.Add( $$ );
if ( fAcquireQuery )
prstQuery.Acquire();
else
prstNew.Acquire();
}
;
NearTerm: CoerceTerm
{ $$ = $1; }
| NearTerm _NEAR CoerceTerm
{
// uses defaults
AssertReq($1);
AssertReq($3);
XDbRestriction prstLeft($1);
XDbRestriction prstRight($3);
_setRst.Remove( $1 );
_setRst.Remove( $3 );
BOOL fAcquireLeft = FALSE;
XDbProximityNodeRestriction prstNew;
if (DBOP_content_proximity == $1->GetCommandType() &&
50 == ((CDbProximityNodeRestriction *)$1)->GetProximityDistance() &&
PROXIMITY_UNIT_WORD == ((CDbProximityNodeRestriction *)$1)->GetProximityUnit())
{
// add right term & release its smart pointer
((CDbProximityNodeRestriction *)$1)->AppendChild( prstRight.GetPointer() );
prstRight.Acquire();
$$ = prstLeft.GetPointer();
fAcquireLeft = TRUE;
}
else
{
// create smart Prox node
prstNew.Set(new CDbProximityNodeRestriction()); // uses defaults
if ( prstNew.IsNull() || !prstNew->IsValid() )
THROW( CException( E_OUTOFMEMORY ) );
// add left phrase & release its smart pointer
prstNew->AppendChild( prstLeft.GetPointer() );
prstLeft.Acquire();
// add right term & release its smart pointer
prstNew->AppendChild( prstRight.GetPointer() );
prstRight.Acquire();
$$ = prstNew.GetPointer();
}
_setRst.Add( $$ );
if ( fAcquireLeft )
prstLeft.Acquire();
else
prstNew.Acquire();
}
| NearTerm _NEARDIST _NEARUNIT _NEAR_END CoerceTerm
{
AssertReq($1);
AssertReq($2);
AssertReq($3);
AssertReq($5);
XDbRestriction prstLeft($1);
XDbRestriction prstRight($5);
_setRst.Remove( $1 );
_setRst.Remove( $5 );
WCHAR * pwcEnd;
ULONG ulValue = wcstol( $2, &pwcEnd, 10 );
ULONG ulUnit;
if (L'w' == *$3)
ulUnit = PROXIMITY_UNIT_WORD;
else if (L's' == *$3)
ulUnit = PROXIMITY_UNIT_SENTENCE;
else if (L'p' == *$3)
ulUnit = PROXIMITY_UNIT_PARAGRAPH;
else if (L'c' == *$3)
ulUnit = PROXIMITY_UNIT_CHAPTER;
BOOL fAcquireLeft = FALSE;
XDbProximityNodeRestriction prstNew;
if (DBOP_content_proximity == $1->GetCommandType() &&
ulValue == ((CDbProximityNodeRestriction *)$1)->GetProximityDistance() &&
ulUnit == ((CDbProximityNodeRestriction *)$1)->GetProximityUnit())
{
// add right term & release its smart pointer
((CDbProximityNodeRestriction *)$1)->AppendChild( prstRight.GetPointer() );
prstRight.Acquire();
$$ = prstLeft.GetPointer();
fAcquireLeft = TRUE;
}
else
{
// create smart Prox node
prstNew.Set(new CDbProximityNodeRestriction(ulUnit, ulValue));
if( prstNew.IsNull() || !prstNew->IsValid() )
THROW( CException( E_OUTOFMEMORY ) );
// add left phrase & release its smart pointer
prstNew->AppendChild( prstLeft.GetPointer() );
prstLeft.Acquire();
// add right term & release its smart pointer
prstNew->AppendChild( prstRight.GetPointer() );
prstRight.Acquire();
$$ = prstNew.GetPointer();
}
_setRst.Add( $$ );
if ( fAcquireLeft )
prstLeft.Acquire();
else
prstNew.Acquire();
}
;
CoerceTerm:
Gen NestTerm GenEnd
{
$$ = $2;
}
| Gen _COERCE Gen NestTerm GenEnd
{
AssertReq($4);
XDbRestriction prstQuery($4);
$4->SetWeight(MAX_QUERY_RANK);
$$ = prstQuery.Acquire();
}
| Gen _WEIGHT Gen NestTerm GenEnd
{
AssertReq($2);
AssertReq($4);
XDbRestriction prstQuery($4);
WCHAR * pwcEnd;
double dWeight = wcstod( $2, &pwcEnd );
if ( dWeight > 1.0 )
THROW( CParserException( QPARSE_E_WEIGHT_OUT_OF_RANGE ) );
LONG lWeight = (LONG)(dWeight * MAX_QUERY_RANK);
$4->SetWeight(lWeight);
$$ = prstQuery.Acquire();
}
;
Gen: /* empty */
{
$$ = 0;
}
| _GENPREFIX
{
SetCurrentGenerate(GENERATE_METHOD_PREFIX);
$$ = GENERATE_METHOD_PREFIX;
}
| _GENINFLECT
{
SetCurrentGenerate(GENERATE_METHOD_INFLECT);
$$ = GENERATE_METHOD_INFLECT;
}
;
GenEnd: /* empty */
{
$$ = GENERATE_METHOD_EXACT;
}
| _GENNORMAL
{
// don't set the generate method to 0 here. Doing so will
// reset the method before it gets used.
$$ = GENERATE_METHOD_EXACT;
}
NestTerm: VectorTerm
{
$$ = $1;
}
| Term
{
$$ = $1;
}
| Open query Close
{
$$ = $2;
}
;
VectorTerm: VectorSpec _VECTOR_END
{
$$ = $1;
}
VectorSpec: _VEMETHOD _VE query
{
AssertReq($1);
AssertReq($3);
XDbRestriction prstQuery($3);
_setRst.Remove( $3 );
ULONG rankMethod = VECTOR_RANK_JACCARD; // default if nothing else matches
if ( 0 == _wcsicmp( L"jaccard", $1) )
{
rankMethod = VECTOR_RANK_JACCARD;
}
else if ( 0 == _wcsicmp( L"dice", $1) )
{
rankMethod = VECTOR_RANK_DICE;
}
else if ( 0 == _wcsicmp( L"inner", $1) )
{
rankMethod = VECTOR_RANK_INNER;
}
else if ( 0 == _wcsicmp( L"max", $1) )
{
rankMethod = VECTOR_RANK_MAX;
}
else if ( 0 == _wcsicmp( L"min", $1) )
{
rankMethod = VECTOR_RANK_MIN;
}
else
{
THROW( CException( QPARSE_E_INVALID_RANKMETHOD ) );
}
// create smart Vector node
XDbVectorRestriction prstNew( new CDbVectorRestriction( rankMethod ) );
if ( prstNew.IsNull() || !prstNew->IsValid() )
{
THROW( CException( E_OUTOFMEMORY ) );
}
// add expression & release its smart pointer
prstNew->AppendChild( prstQuery.GetPointer() );
prstQuery.Acquire();
// Let the next vector element start off with a clean slate...
// We don't want the current element's property and genmethod
// to rub off on it.
InitState();
$$ = prstNew.GetPointer();
_setRst.Add( $$ );
prstNew.Acquire();
}
| VectorSpec _VE query
{
AssertReq($1);
AssertReq($3);
XDbRestriction prstLeft($1);
XDbRestriction prstRight($3);
_setRst.Remove( $1 );
_setRst.Remove( $3 );
// add right term & release its smart pointer
((CDbVectorRestriction *)($1))->AppendChild( prstRight.GetPointer() );
prstRight.Acquire();
// Let the next vector element start off with a clean slate...
// We don't want the current element's property and genmethod
// to rub off on it.
InitState();
$$ = prstLeft.GetPointer();
_setRst.Add( $$ );
prstLeft.Acquire();
}
;
Open: _OPEN
{
SaveState();
$$ = 0;
}
Close: _CLOSE
{
RestoreState();
$$ = 0;
}
Term: PropTerm
{
$$ = $1;
}
| Property Contains _PHRASE ShortGen PropEnd
{
$$ = BuildPhrase($3, $4);
_setRst.Add( $$ );
}
| Property Contains _PHRASE PropEnd
{
$$ = BuildPhrase($3, 0);
_setRst.Add( $$ );
}
| Property Contains Gen _PHRASE GenEnd PropEnd
{
$$ = BuildPhrase($4, $3);
_setRst.Add( $$ );
}
| Property Contains query
{
$$ = $3;
}
| Property Contains _FREETEXT ShortGen PropEnd
{
AssertReq($3);
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
// We used the property. Now pop it off if need be
if (fDeferredPop)
PopProperty();
// Clear generation method so it won't rub off on the following phrase
SetCurrentGenerate(GENERATE_METHOD_EXACT);
// generation method not used - if it's there, ignore it
// (already stripped from longhand version, but not from
// shorthand version
LPWSTR pLast = $3 + wcslen($3) -1;
if ( L'*' == *pLast) // prefix
*pLast-- = L'\0';
if ( L'*' == *pLast) // inflect
*pLast-- = L'\0';
XDbNatLangRestriction pRest ( new CDbNatLangRestriction ($3, *pps, _lcid));
if ( pRest.IsNull() || !pRest->IsValid() )
THROW( CException( E_OUTOFMEMORY ) );
$$ = pRest.GetPointer();
_setRst.Add( $$ );
pRest.Acquire();
}
;
PropTerm: Property Matches _REGEX PropEnd
{
AssertReq($3);
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
// We used the property. Now pop it off if need be
if (fDeferredPop)
PopProperty();
if ( ( ( DBTYPE_WSTR|DBTYPE_BYREF ) != dbType ) &&
( ( DBTYPE_STR|DBTYPE_BYREF ) != dbType ) &&
( VT_BSTR != dbType ) &&
( VT_LPWSTR != dbType ) &&
( VT_LPSTR != dbType ) )
THROW( CParserException( QPARSE_E_EXPECTING_REGEX_PROPERTY ) );
if( $3 == 0 )
THROW( CParserException( QPARSE_E_EXPECTING_REGEX ) );
// create smart Property node
XDbPropertyRestriction prstProp( new CDbPropertyRestriction );
if( prstProp.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
prstProp->SetRelation(DBOP_like); // LIKE relation
if ( ( ! prstProp->SetProperty( *pps ) ) ||
( ! prstProp->SetValue( $3 ) ) ||
( ! prstProp->IsValid() ) )
THROW( CException( E_OUTOFMEMORY ) );
// release & return smart Property node
$$ = prstProp.GetPointer();
_setRst.Add( $$ );
prstProp.Acquire();
}
| Property Op Value PropEnd
{
AssertReq($2);
AssertReq($3);
XPtr<CStorageVariant> pStorageVar( $3 );
_setStgVar.Remove( $3 );
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
// We used the property. Now pop it off if need be
if (fDeferredPop)
PopProperty();
// create smart Property node
XDbPropertyRestriction prstProp( new CDbPropertyRestriction );
if( prstProp.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
if (! prstProp->SetProperty( *pps ) )
THROW( CException( E_OUTOFMEMORY ) );
// don't allow @contents <relop> X -- it's too expensive and we'll
// never find any hits anyway (until we implement this feature)
if ( *pps == psContents )
THROW( CParserException( QPARSE_E_EXPECTING_PHRASE ) );
prstProp->SetRelation( $2 );
if ( 0 != pStorageVar.GetPointer() )
{
// This should always be the case - else PropValueParser would have thrown
if ( ! ( ( prstProp->SetValue( pStorageVar.GetReference() ) ) &&
( prstProp->IsValid() ) ) )
THROW( CException( E_OUTOFMEMORY ) );
}
$$ = prstProp.GetPointer();
_setRst.Add( $$ );
prstProp.Acquire();
}
;
Property: /* empty */
{
$$ = 0;
}
| _PROPNAME
{
PushProperty($1);
$$ = 0;
}
;
PropEnd: /* empty */
{
fDeferredPop = FALSE;
$$ = 0;
}
| _PROPEND
{
// When PropEnd is matched, the action of using the property
// hasn't yet taken place. So popping the property right now
// will cause the property to be unavailable when the action
// is performed. Instead, pop it off after it has been used.
fDeferredPop = TRUE;
$$ = 0;
}
;
Op: _EQ
{ $$ = DBOP_equal;}
| _NE
{ $$ = DBOP_not_equal;}
| _GT
{ $$ = DBOP_greater;}
| _GTE
{ $$ = DBOP_greater_equal;}
| _LT
{ $$ = DBOP_less;}
| _LTE
{ $$ = DBOP_less_equal;}
| _ALLOF
{ $$ = DBOP_allbits;}
| _SOMEOF
{ $$ = DBOP_anybits;}
| _EQSOME
{ $$ = DBOP_equal_any;}
| _NESOME
{ $$ = DBOP_not_equal_any;}
| _GTSOME
{ $$ = DBOP_greater_any;}
| _GTESOME
{ $$ = DBOP_greater_equal_any;}
| _LTSOME
{ $$ = DBOP_less_any;}
| _LTESOME
{ $$ = DBOP_less_equal_any;}
| _ALLOFSOME
{ $$ = DBOP_allbits_any;}
| _SOMEOFSOME
{ $$ = DBOP_anybits_any;}
| _EQALL
{ $$ = DBOP_equal_all;}
| _NEALL
{ $$ = DBOP_not_equal_all;}
| _GTALL
{ $$ = DBOP_greater_all;}
| _GTEALL
{ $$ = DBOP_greater_equal_all;}
| _LTALL
{ $$ = DBOP_less_all;}
| _LTEALL
{ $$ = DBOP_less_equal_all;}
| _ALLOFALL
{ $$ = DBOP_allbits_all;}
| _SOMEOFALL
{ $$ = DBOP_anybits_all;}
;
Matches: /* empty */
{ $$ = 0; }
| _EQ
{ $$ = DBOP_equal; }
Value: _PHRASE
{
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
CValueParser PropValueParser( FALSE, dbType, _lcid );
StripQuotes($1);
PropValueParser.AddValue( $1 );
$$ = PropValueParser.GetStgVariant();
_setStgVar.Add( $$ );
PropValueParser.AcquireStgVariant();
}
| _FREETEXT
{
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
CValueParser PropValueParser( FALSE, dbType, _lcid );
PropValueParser.AddValue( $1 );
$$ = PropValueParser.GetStgVariant();
_setStgVar.Add( $$ );
PropValueParser.AcquireStgVariant();
}
| VectorValue
{
$$ = $1;
}
;
VectorValue: EmptyVector
{
XPtr <CValueParser> pPropValueParser ( $1 );
_setValueParser.Remove( $1 );
$$ = $1->GetStgVariant();
_setStgVar.Add( $$ );
$1->AcquireStgVariant();
}
| SingletVector
{
XPtr <CValueParser> pPropValueParser ( $1 );
_setValueParser.Remove( $1 );
$$ = $1->GetStgVariant();
_setStgVar.Add( $$ );
$1->AcquireStgVariant();
}
| MultiVector _VE_END
{
XPtr <CValueParser> pPropValueParser ( $1 );
_setValueParser.Remove( $1 );
$$ = $1->GetStgVariant();
_setStgVar.Add( $$ );
$1->AcquireStgVariant();
}
EmptyVector: _OPEN _CLOSE
{
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
if( pPropValueParser.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
$$ = pPropValueParser.GetPointer();
_setValueParser.Add( $$ );
pPropValueParser.Acquire();
}
SingletVector: _OPEN _PHRASE _CLOSE
{
AssertReq($2);
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
if( pPropValueParser.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
StripQuotes($2);
pPropValueParser->AddValue( $2 );
$$ = pPropValueParser.GetPointer();
_setValueParser.Add( $$ );
pPropValueParser.Acquire();
}
| _OPEN _FREETEXT _CLOSE
{
AssertReq($2);
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
if( pPropValueParser.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
pPropValueParser->AddValue( $2 );
$$ = pPropValueParser.GetPointer();
_setValueParser.Add( $$ );
pPropValueParser.Acquire();
}
MultiVector: _VECTORELEMENT _VECTORELEMENT
{
AssertReq($1);
AssertReq($2);
CDbColId *pps;
DBTYPE dbType;
GetCurrentProperty(&pps, &dbType);
XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
if( pPropValueParser.GetPointer() == 0 )
THROW( CException( E_OUTOFMEMORY ) );
pPropValueParser->AddValue( $1 );
pPropValueParser->AddValue( $2 );
$$ = pPropValueParser.GetPointer();
_setValueParser.Add( $$ );
pPropValueParser.Acquire();
}
| MultiVector _VECTORELEMENT
{
AssertReq($1);
AssertReq($2);
$1->AddValue($2);
$$ = $1;
}
;
Contains: /* empty */
{
$$ = 0;
}
| _CONTAINS
{
$$ = 0;
}
;
ShortGen: /* empty */
{
$$ = 0;
}
| _SHGENPREFIX
{
$$ = 1;
}
| _SHGENINFLECT
{
$$ = 2;
}
;
|
<reponame>MyersResearchGroup/ATACS<filename>src/parser.y
/************************************************************************
* COMPILER--VHDL *
* ---PARSER--- *
************************************************************************/
%{
#include <algorithm>
#include <cassert>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <unistd.h>
#include <vector>
#include "classes.h"
#include "events.h"
#include "hse.hpp"
#include "makedecl.h"
#define EXPANDED_RATE_NETS 2
char token_buffer_1[512], token_buffer_2[512], token_buffer_3[512] ;
char distrib1[128];
char distrib2[128];
int yylex (void*);
int yyerror(char *s);
int yywarning(char *s);
void constructor();
void destructor();
//#define YYDEBUG 1
extern FILE *lg; // Log file from atacs.c
// The following externs are defined in compile.c /////////////////////////
extern SymTab* table;
extern tels_table* tel_tb;
extern vhd_tel_tb *open_entity_lst;
extern csp_tel_tb *open_module_list;
extern string cur_dir;
extern string cur_file;
extern int mingatedelay, maxgatedelay;
extern char* file_scope1;
extern int linenumber;
extern char* outpath;
extern char* outputname;
extern string cur_entity;
extern bool toTEL;
extern bool compiled;
extern long PSC; // Program state counter
extern bool pre_compile;
extern map<string,string> *name_mapping;
// End of externs from compile.c //////////////////////////////////////////
/*************************************************************************/
//extern char g_lline[]; /* from lexer */
//extern char yytext[];
//extern int column;
/*************************************************************************/
//This function is called when a file is needed to compile in the
//current compiling file. It pushes the old buffer into the stack
//and allocates new buffer for the new file and then set the file
//pointer to the new file. From parser.l. extern bool
//switch_buffer(const char *dir, const char *file_name);
//This function cleans the buffer of the lexer. From parser.l.
extern void clean_buffer();
map < string, map < string, int > > signals;
map < string, int > processChannels;
string reqSuffix=SEND_SUFFIX ; // Setting up defaults for send
string ackSuffix=RECEIVE_SUFFIX ; // Setting up defaults for send
actionADT join=NULL; // Branches of parallel sends/receives will join here.
int direction=SENT;
stack < pair < string, tels_table* > > parsing_stack;
//Indicates whether the process statement contains a sensitivity list
int __sensitivity_list__= 0;
int isENTITY= 0;
int isTOP= 0;
// Create a dummy action.
actionADT dummyE();
// Create a new dummy action with name $name
actionADT make_dummy(char *name);
// Create a timed event-rule structure for an guard.
TERstructADT Guard(const string & expression);
// Create a timed event-rule structure for a CV assignment
TERstructADT Assign(const string & expression);
// Create a timed event-rule structure for an guarded action.
TERstructADT Guard(const string & expression, actionADT target,
const string& data);
TERstructADT FourPhase(const string & channel, const string & data="");
TERstructADT signalAssignment(TYPES* target, TYPES* waveform);
TYPES * Probe(const string & channel);
void declare(list<pair<string,int> >* ports);
//Converts an double to a string
string numToString(double num);
string intToString(int num);
%}
%pure_parser
%union{
int intval;
double floatval;
char *C_str;
char *id;
long int basedlit;
char *charlit;
char *strlit;
char *bitlit;
char *stringval;
bool boolval;
string *str;
TYPES *types;
actionADT actionptr;
TERstructADT TERSptr;
delayADT delayval;
TYPELIST *typelist;
pair<string, string> *csp_pair;
pair<TYPES,telADT> *ty_tel2;
map<string, string> *csp_map;
list<actionADT> *action_list;
list<string> *str_list;
list<TYPES> *ty_lst;
list<pair<string,string> > *str_str_l;
list<pair<string,int> > *str_bl_lst;
list<pair<TYPES,telADT> > *ty_tel_lst;
list<pair<TYPES,TYPES> > *ty_ty_lst;
pair<string,list<string> > *stmt_pair;
list<pair<string,list<string> > > *simul_lst;
};
%token ABSOLUTE ACCESS AFTER ALIAS ALL AND ARCHITECTURE ARRAY ASSERT ATTRIBUTE
%token VBEGIN BLOCK BODY BUFFER BUS CASE COMPONENT CONFIGURATION CONSTANT
%token DISCONNECT DOWNTO ELSE ELSIF END ENTITY EXIT VFILE FOR
%token FUNCTION PROCEDURE NATURAL
%token GENERATE GENERIC GUARDED IF IMPURE VIN INITIALIZE INOUT IS LABEL LIBRARY
%token LINKAGE LITERAL LOOP MAP MOD NAND NEW NEXT NOR NOT UNAFFECTED
%token UNITS GROUP OF ON OPEN OR OTHERS VOUT VREJECT INERTIAL XNOR
%token PACKAGE PORT POSTPONED PROCESS PURE RANGE RECORD REGISTER REM
%token REPORT RETURN SELECT SEVERITY SHARED SIGNAL SUBTYPE THEN TO TRANSPORT
%token TYPE UNTIL USE VARIABLE VNULL WAIT WHEN WHILE WITH XOR
%token ARROW EXPON ASSIGN BOX
%token SLL SRL SLA SRA ROL ROR AT INF EOC ASSIGNMENT
%token PROBE RECEIVE SEND VASSIGNMENT
%token INITCHANNEL
/* VHDL-AMS Additions */
%token ACROSS BREAK EQ LIMIT NATURE NOISE PROCEDURAL QUANTITY REFERENCE
%token SPECTRUM SUBNATURE TERMINAL THROUGH TOLER VDOT ABOVE
/* End Additions */
%token MODULE ENDMODULE BOOL PARA ATACS_DELAY ENDPROC SKIP INIT DEL BOOLEAN
%token SLASH CID CPORT CINT CARROW PROC RECURSIVE_ERROR GATE ENDGATE
%token GUARD GUARDAND GUARDOR GUARDTO LARROW INCLUDE ENDTB TESTBENCH
%token AWAIT AWAITALL AWAITANY ATACS_DEFINE
%token CONSTRAINT ENDCONSTRAINT ASSUMP ENDASSUMP SUM DIFF
%token <strlit>STRLIT BITLIT
%token <intval> INT VBOOL
%token <basedlit> BASEDLIT
%token <floatval> REAL
%token <actionptr> VID ACTION
%token <charlit> CHARLIT
/* VHDL-AMS Additions */
%type <C_str> concurrent_break_statement
%type <C_str> procedural_head in_out_symbol
%type <TERSptr> break_statement
//%type <C_str> neg
%type <types> terminal_aspect subnature_indication scalar_nature_definition
%type <types> procedural_declarative_item array_nature_definition
%type <types> record_nature_definition nature_definition
%type <types> andor_ams
%type <simul_lst> simul_statement
%type <simul_lst> simul_elsifthen sequence_of_simul_statements
%type <simul_lst> simul_case_statement_alternative simul_else_part
%type <simul_lst> simultaneous_if_statement simultaneous_case_statement
%type <simul_lst> simple_simultaneous_statement
%type <str_list> across_aspect through_aspect
%type <str_list> record_nature_alternative
%type <str_bl_lst> interface_terminal_declaration
%type <str_bl_lst> interface_quantity_declaration
%type <TERSptr> simultaneous_procedural_statement
%type <TERSptr> simultaneous_statement rate_assignment
%type <TERSptr> when_symbol
%type <str> break_element break_elements
/* End Additions */
%type <C_str> alias_name signal_mode block_label designator mode
%type <C_str> idparan suffix relational_operator direction sign
%type <C_str> multiplying_operator adding_operator
%type <C_str> enumeration_literal label label_symbol
%type <C_str> package_tail endofentity architail
%type <C_str> entity_descr package_body_head comp_decl_tail process_head
%type <types> type_definition scalar_type_definition composite_type_definition
%type <types> access_type_definition file_type_definition
%type <types> integer_floating_type_definition
%type <types> array_type_definition record_type_definition
%type <types> unconstrainted_array_definition constrained_array_definition
%type <types> subtype_indication
%type <types> subtype_indication1 subtype_indication_list
%type <types> enumeration_type_definition
%type <types> allocator secondary_unit_declaration
%type <types> element_association base_unit_declaration
%type <types> choice qualified_expression
%type <types> elarep aggregate sub_body_head discrete_range
%type <types> xorexpr literal physical_literal_no_default
%type <typelist> range_constraint range
%type <typelist> gen_association_list gen_association_list_1
%type <typelist> ee physical_literal
%type <typelist> sud physical_type_definition discrete_range1
%type <typelist> gen_association_element
%type <typelist> index_constraint disdis isd index_subtype_definition
%type <types> subprogram_specification subprogram_declaration
%type <types> attribute_name al_decl_head assign_exp
%type <types> waveform_element waveform cmpnt_stmt_body
%type <types> expression relation target probedChannel shift_expression
%type <types> simple_expression terms term factor
%type <types> primary orexpr andexpr
%type <types> insl_name name3 name2
%type <types> name condition_clause iteration_scheme //condition
%type <types> andor_stmt and_stmts or_stmts target_factors target_terms
%type <str_list> mark selected_name
%type <TERSptr> block_statement block_statement_part
%type <TERSptr> loop_statement concurrent_statement
%type <TERSptr> process_statement
%type <TERSptr> process_statement_part
%type <TERSptr> wait_statement else_part conditional_signal_assignment
%type <TERSptr> timeout_clause
%type <TERSptr> concurrent_signal_assignment_statement
%type <TERSptr> if_statement case_statement
%type <TERSptr> signal_assignment_statement variable_assignment_statement
%type <TERSptr> assign_statements assign_statement assign_stmt
%type <TERSptr> vassign_statements vassign_statement vassign_stmt
%type <TERSptr> communicationStatement parallelCommunication
%type <TERSptr> fourPhase guardish_statement assertion_statement
%type <TERSptr> guard_statement guard_and_statement guard_or_statement
%type <TERSptr> await_statement await_all_statement await_any_statement
%type <str_bl_lst> interface_list interface_declaration port_clause
%type <str_bl_lst> interface_signal_declaration
%type <str_bl_lst> interface_unknown_declaration component_declaration_tail
%type <str_list> identifier_list
%type <str_str_l> association_list
%type <str_str_l> port_map_aspect generic_map_aspect map_aspects
%type <csp_pair> association_element
%type <str> formal_part
%type <types> actual_part
%type <ty_tel_lst> case_statement_alternative elsifthen sequence_of_statements
%type <ty_ty_lst> waveform_head conditional_waveforms selected_waveforms
%type <ty_lst> choices
%type <ty_tel2> sequential_statement
%type <TERSptr> process body action skip or_constraint and_constraint
%type <TERSptr> guardstruct guardcmdset guardcmd leakyexprs leakyexpr
%type <TERSptr> expr conjunct csp_literal actionexpr prs constraint
%type <csp_pair> formal_2_actual
%type <csp_map> port_map_list
%type <id> file_name
%type <str> leveliteral levelexpr levelconjunct path_name filename
%type <delayval> delay
%type <intval> CINT BOOL CPORT
%type <boolval> INIT
%type <action_list> id_list
%type <str_bl_lst> booldecl decl decls delaydecl constructs component_instances
%type <str_bl_lst> definedecl
%type <floatval> sing_dist
%nonassoc <actionptr> ID
%nonassoc '>' '<' '=' GE LE NEQ
%left '+' '-' '&' '|' PARA
%left MED_PRECEDENCE ';' ':'
%left '*' '/' MOD REM ARROW
%nonassoc EXPON ABSOLUTE NOT MAX_PRECEDENCE
%start start_point
%%
/* Design File */
start_point : {
constructor();
}
design_file
{
destructor();
}
| csp_compiler { destructor(); }
| recursive_errors { return 1; }
;
design_file
: design_unit {}
| design_file design_unit { }
;
design_unit
: context_clause library_unit { }
;
context_clause
:
| context_clause context_item
;
context_item
: library_clause
| use_clause
{
//string f_name = string(".");
//for(list<string>::iterator b=$1->begin(); b!=$1->end(); b++)
// f_name += ('/' + *b);
//f_name += ".vhd";
//if(switch_buffer(f_name) == false){
//destructor();
//yy_abort();
//return 1;
//}
}
;
library_unit
: primary_unit {}
| secondary_unit {}
;
primary_unit
: entity_declaration
| configuration_declaration
| package_declaration
;
secondary_unit
: architecture_body {}
| package_body { }
;
library_clause
: library_list ';'
;
library_list
: LIBRARY VID
{ }
| library_list ',' VID
{}
;
/* Library Unit Declarations */
entity_declaration
: ENTITY VID
{
new_action_table($2->label);
new_event_table($2->label);
new_rule_table($2->label);
new_conflict_table($2->label);
delete tel_tb;
tel_tb = new tels_table;
tel_tb->set_id($2->label);
tel_tb->set_type($2->label);
table->new_design_unit($2->label);
cur_entity = $2->label;
}
entity_descr
{
if(open_entity_lst->insert($2->label,*tel_tb)==false)
err_msg("error: multiple declaration of entity '",
$2->label, "'");
if($4 && !strcmp_nocase($2->label,$4))
err_msg("warning: '", $4, "' undeclared as an entity name");
// delete tel_tb;
//tel_tb=0;
}
;
entity_descr
: IS entity_header entity_declarative_part END endofentity ';'
{ $$ = $5; }
| IS entity_header entity_declarative_part
VBEGIN entity_statement_part END endofentity ';'
{ $$ = $7; }
;
endofentity
: { $$ = 0; }
| ENTITY { $$ = 0; }
| VID { $$ = $1->label; }
| ENTITY VID { $$ = $2->label; }
;
entity_header
:
| generic_clause
| port_clause {declare($1);}
| generic_clause port_clause {declare($2);}
;
generic_clause
: GENERIC '(' interface_list ')' ';'
;
port_clause
: PORT '(' interface_list ')' ';'
{ $$= $3; }
;
entity_declarative_part
:
| entity_declarative_part entity_declarative_item
;
entity_declarative_item
: subprogram_declaration {}
| subprogram_body {}
| type_declaration
| subtype_declaration
| constant_declaration
| signal_declaration
| file_declaration
| alias_declaration
| attribute_declaration
| label_declaration /* Unknown */
| attribute_specification
| initialization_specification /* Unknown */
| disconnection_specification
| use_clause {}
| variable_declaration /* Unknown */
| group_template_declaration
| group_declaration
/* Added for AMS */
| step_limit_specification
| nature_declaration
| subnature_declaration
| quantity_declaration
| terminal_declaration
;
group_template_declaration
: GROUP VID IS '(' gtp_body ')' ';'
;
gtp_body : gtp_body ',' entity_class box_symbol
| entity_class box_symbol
;
box_symbol :
| BOX
;
group_declaration
: GROUP VID ':' VID '(' gd_body ')' ';'
;
gd_body : gd_body ',' VID
| gd_body ',' CHARLIT
| VID {}
| CHARLIT {}
;
entity_statement_part
:
| entity_statement_part entity_statement
;
entity_statement
: concurrent_assertion_statement
| concurrent_procedure_call
| process_statement {}
;
architecture_body
: ARCHITECTURE VID OF VID IS
{
signals[cur_entity].clear();
delete tel_tb;
const tels_table& TT=open_entity_lst->find(Tolower($4->label));
if(TT.empty())
err_msg("entity '",$4->label,"' undeclared");
tel_tb = new tels_table(TT);
tel_tb->set_type(Tolower($4->label));
if(table->design_unit(Tolower($4->label)) == false){
err_msg("entity '",$4->label,"' undeclared");
}
table->new_tb();
}
architecture_declarative_part
VBEGIN architecture_statement_part END architail ';'
{
if($11 && strcmp_nocase($11, $2->label) == false)
err_msg("warning: '", $2->label,
"' undeclared as an architecture name");
if(open_entity_lst->insert(Tolower($4->label),
Tolower($2->label),tel_tb)==2)
err_msg("error: multiple declaration of architecture '",
$2->label, "'");
table->delete_tb();
}
;
architail
: { $$ = 0; }
| ARCHITECTURE VID { $$ = $2->label; }
| ARCHITECTURE { $$ = 0; }
| VID { $$ = $1->label; }
;
architecture_declarative_part
:
| architecture_declarative_part block_declarative_item
;
architecture_statement_part
:
| architecture_statement_part concurrent_statement
/* Added for AMS */
| architecture_statement_part simultaneous_statement
;
configuration_declaration
: CONFIGURATION VID OF VID config_tail
;
config_tail
: /*IS configuration_declarative_part block_configuration
END configtail VID ';'
|*/ IS configuration_declarative_part block_configuration
END configtail ';'
;
configtail
:
| CONFIGURATION
| VID {}
| CONFIGURATION VID {}
;
configuration_declarative_item
: use_clause {}
| attribute_specification
| group_declaration
;
configuration_declarative_part
:
| configuration_declarative_part configuration_declarative_item
;
block_configuration
: FOR block_specification us ci END FOR ';'
;
block_specification
: VID { }
| VID '(' www ')' {}
;
www
: discrete_range {}
| INT {}
| REAL {}
;
us
:
| us use_clause {}
;
ci
:
| ci configuration_item
;
configuration_item
: block_configuration
| component_configuration
;
component_configuration
: FOR component_specification END FOR ';'
| FOR component_specification binding_indication ';'
END FOR ';'
| FOR component_specification block_configuration END FOR ';'
| FOR component_specification binding_indication ';'
block_configuration END FOR ';'
;
package_declaration
: PACKAGE VID
{ table->new_design_unit($2->label); }
package_tail
{
if($4 && strcmp_nocase($2->label, $4)==false)
err_msg("warning: '", $2->label,
"' undeclared as a package label");
}
;
package_tail
: IS package_declarative_part END packagetail ';'{ $$ = 0; }
| IS package_declarative_part
END packagetail VID ';' { $$ = $5->label; }
;
packagetail
:
| PACKAGE
;
package_declarative_part
:
| package_declarative_part package_declarative_item
;
package_declarative_item
: subprogram_declaration {}
| type_declaration
| subtype_declaration
| constant_declaration
| signal_declaration
| file_declaration
| alias_declaration
| component_declaration
| attribute_declaration
| attribute_specification
| initialization_specification
| disconnection_specification
| use_clause {}
| variable_declaration
| group_template_declaration
| group_declaration
/* Added for AMS */
| nature_declaration
| subnature_declaration
| terminal_declaration
;
package_body_head
: PACKAGE BODY VID
{
/*const char *t = table->find($3->label);
if(t == 0 || strcmp_nocase(t, "package"))
err_msg("warning: '", $3->label,
"' undeclared as a package name");
$$ = $3->label;*/
}
;
package_body
: package_body_head
IS package_body_declarative_part END pac_body_tail ';'
{}
| package_body_head
IS package_body_declarative_part END pac_body_tail VID ';'
{
/*if(strcmp_nocase($1, $6->label))
err_msg("warning: '", $6->label,
"' is not declared as a package body name");*/
}
;
pac_body_tail
:
| PACKAGE BODY
;
package_body_declarative_part
:
| package_body_declarative_part package_body_declarative_item
;
package_body_declarative_item
: subprogram_declaration {}
| subprogram_body
| type_declaration
| subtype_declaration
| constant_declaration
| file_declaration
| alias_declaration
| use_clause {}
| variable_declaration
| group_template_declaration
| group_declaration
;
/* Declarations and Specifications */
subprogram_declaration
: subprogram_specification ';'
{
/*if(strcmp_nocase($1->obj_type(), "fct") == 0 &&
$1->data_type() == 0)
{
err_msg("undefined the return type of function '",
$1->get_string(), "'");
$1->set_data("err");
}
table->insert($1->get_string(), $1);*/
}
;
subprogram_specification
: PROCEDURE designator
{
/*$$ = new TYPES("prd", 0);
$$->set_string($2);*/
}
| PROCEDURE designator '(' interface_list ')'
{/*
$$ = new TYPES("prd", 0);
//$$->set_string($2);
//$$->set_list($4);
*/
}
| func_head FUNCTION designator RETURN mark
{
/*TYPES *mt = table->lookup($5);
if(mt == 0)
$$ = new TYPES("fct", 0);
else
{
$$ = new TYPES1(mt->get_ters(), mt);
$$->set_obj("fct");
}
$$->set_string($3);
delete mt;*/
}
| func_head FUNCTION designator '(' interface_list ')'
RETURN mark
{
/*TYPES *mt = table->lookup($8->front());
if(mt == 0)
$$ = new TYPES("fct", 0);
else
{
$$ = new TYPES1(mt->get_ters(), mt);
$$->set_obj("fct");
}
$$->set_string($3);
//$$->set_list($5);
delete mt;*/
}
;
func_head
:
| PURE
| IMPURE
;
sub_body_head
: subprogram_specification IS
{
/*$$ = $1;
table->new_scope($$->get_string(), "function");
TYPELIST *l = $1->get_list();
l->iteration_init();
while(l->end() == false)
{
table->insert(l->value().first, l->value().second);
l->next();
}*/
}
;
subprogram_body
: sub_body_head subprogram_declarative_part
VBEGIN subprogram_statement_part END subprog_tail ';'
{
//table->delete_scope();
}
| sub_body_head subprogram_declarative_part VBEGIN
subprogram_statement_part END subprog_tail designator ';'
{
//table->delete_scope();
}
;
subprog_tail
:
| PROCEDURE
| FUNCTION
;
subprogram_statement_part
: {}
| subprogram_statement_part sequential_statement
{}
;
designator
: VID { $$= $1->label; }
| STRLIT { $$= $1; }
;
subprogram_declarative_part
:
| subprogram_declarative_part subprogram_declarative_item
;
subprogram_declarative_item
: subprogram_declaration {}
| subprogram_body
| type_declaration
| subtype_declaration
| constant_declaration
| variable_declaration
| file_declaration
| alias_declaration
| attribute_declaration
| label_declaration
| attribute_specification
| use_clause {}
| group_template_declaration
| group_declaration
;
type_declaration
: full_type_declaration
| incomplete_type_declaration
;
full_type_declaration
: TYPE VID IS type_definition ';'
{
/*if(strcmp_nocase($4->obj_type(), "uk") == 0)
$4->set_obj("typ");
$4->set_data($2->label);
table->insert($2->label, $4);
if($4->get_grp() == TYPES::Physical)
{
TYPELIST *l = $4->get_list();
TYPES *ty = new TYPES("uk", $2->label);
l->iteration_init();
l->next();
l->next();
while(l->end() == false)
{
const TYPES *tmp = l->value().second;
table->insert(tmp->get_string(), ty);
l->next();
}
delete ty;
}*/
}
;
incomplete_type_declaration
: TYPE VID ';'
{
/*TYPES *t = new TYPES("typ", $2->label);
table->insert($2->label, t);
delete t;*/
}
;
type_definition
: scalar_type_definition { $$= $1; }
| composite_type_definition { $$= $1; }
| access_type_definition { $$= $1; }
| file_type_definition { $$= $1; }
;
scalar_type_definition
: enumeration_type_definition
{
//$$ = $1;
}
| integer_floating_type_definition { $$= $1; }
| physical_type_definition
{
/*$$ = new TYPES;
$$->set_grp(TYPES::Physical);
$$->set_list($1);*/
}
;
composite_type_definition
: array_type_definition { $$= $1; }
| record_type_definition { $$= $1; }
;
/* Added for AMS */
nature_declaration
: NATURE VID IS nature_definition ';'
;
nature_definition
: scalar_nature_definition
| array_nature_definition
| record_nature_definition
;
/* End Additions */
constant_declaration
: CONSTANT identifier_list ':' subtype_indication ';'
{}
| CONSTANT identifier_list ':' subtype_indication
ASSIGN expression ';'
{
for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
string LL = Tolower(*b);
makeconstantdecl(action(LL), $6->get_int());
}
}
;
identifier_list
: VID
{ $$ = new list<string>; $$->push_back($1->label); }
| identifier_list ',' VID
{ $$ = $1; $$->push_back($3->label); }
;
signal_declaration
: SIGNAL identifier_list ':' subtype_indication signal_kind
assign_exp ';' signal_mode
{
list<string> *sufficies = new list<string>;
int type(IN);
string assigned($6->get_string());
delayADT myBounds;
int rise_min(0), rise_max(0), fall_min(-1), fall_max(-1);
if("init_channel"==assigned){
sufficies->push_back(SEND_SUFFIX);
sufficies->push_back(RECEIVE_SUFFIX);
TYPELIST arguments($6->get_list());
TYPELIST::iterator i(arguments.begin());
while(i!=arguments.end()){
if("timing"==i->second.get_string()){
TYPELIST bounds(i->second.get_list());
TYPELIST::iterator j(bounds.begin());
int pos(1);
while(j != bounds.end()){
string formal(j->first);
int actual(j->second.get_int());
if("rise_min"==formal || "lower"==formal ||
formal.empty() && 1==pos){
rise_min = actual;
}
else if("rise_max"==formal || "upper"==formal ||
formal.empty() && 2==pos){
rise_max = actual;
}
else if("fall_min"==formal || "lower"==formal ||
formal.empty() && 3==pos){
fall_min = actual;
}
else if("fall_max"==formal || "upper"==formal ||
formal.empty() && 4==pos){
fall_max = actual;
}
j++;
pos++;
}
}
i++;
}
}
else if("active"==assigned || "passive"==assigned){
err_msg(assigned,
" doesn't make sense in signal declaration");
}
else{
sufficies->push_back("" );
if($8 == string("out")){
type=OUT|ISIGNAL;
}
}
if(fall_min<0){
fall_min = rise_min;
}
if(fall_max<0){
fall_max = rise_max;
}
assigndelays(&myBounds,
rise_min,rise_max,NULL,
fall_min,fall_max,NULL);
int init = 0;
if($6->get_string() == "'1'"){
init = 1;
}
for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
list<string>::iterator suffix=sufficies->begin();
signals[cur_entity][Tolower(*b)] = type;
while ( suffix != sufficies->end() ) {
string LL = Tolower(*b) + *suffix;
makebooldecl(type, action(LL), init, &myBounds);
if(!table->insert(LL, make_pair((string)$8,(TYPES*)0))){
err_msg("multiple declaration of signal '",*b,"'");
}
suffix++;
}
// if(type==OUT)
tel_tb->add_signals(*b, type);
//else
//tel_tb->add_signals(*b, IN);
}
delete sufficies;
}
;
signal_kind
:
| REGISTER | BUS
;
signal_mode
: { $$= "out"; }
| AT VIN { $$= "in"; }
| AT VOUT { $$= "out"; }
;
variable_declaration
: var_decl_head VARIABLE identifier_list ':'
subtype_indication ';'
{
for(list<string>::iterator b=$3->begin(); b!=$3->end();b++){
if(!table->insert(*b,make_pair((string)"var",(TYPES*)0))){
err_msg("multiple declaration of variable '",*b,"'");
}
}
delete $3;
}
| var_decl_head VARIABLE identifier_list ':' subtype_indication
ASSIGN expression ';'
{
for(list<string>::iterator b=$3->begin(); b!=$3->end();b++){
if(!table->insert(*b,make_pair((string)"var",(TYPES*)0))){
err_msg("multiple declaration of variable '",*b,"'");
}
}
delete $3;
delete $7;
}
;
var_decl_head
:
| SHARED
;
/* Added for AMS */
terminal_declaration :
TERMINAL identifier_list ':' subnature_indication ';'
;
quantity_declaration :
QUANTITY identifier_list ':' subtype_indication
assign_exp ';'
{
for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
if(!table->insert(*b,make_pair((string)"qty",(TYPES*)0))){
err_msg("multiple declaration of quantity '",*b,"'");
}
}
TERstructADT x;
actionADT a = action(*($2->begin()));
a->type = CONT + VAR + DUMMY;
/* TODO: Support span */
a->linitval = atoi($5->theExpression.c_str());
a->uinitval = atoi($5->theExpression.c_str());
x = TERS(a,FALSE,0,0,FALSE);
tel_tb->insert(*($2->begin()), x);
if (EXPANDED_RATE_NETS==0) {
TERstructADT xdot;
string dollar2 = (*($2->begin()));
actionADT adot = action((dollar2 + "dot").c_str());
adot->type = CONT + VAR + DUMMY;
adot->linitval = 0;//atoi($5->theExpression.c_str());
adot->uinitval = 0;//atoi($5->theExpression.c_str());
xdot = TERS(adot,FALSE,0,0,FALSE);
tel_tb->insert((dollar2 + "dot").c_str(), xdot);
}
delete $2;
}
| QUANTITY terminal_aspect ';'
{
/*for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
if(!table->insert(*b,make_pair((string)"qty",(TYPES*)0))){
err_msg("multiple declaration of quantity '",*b,"'");
}
}
delete $2;*/
}
| QUANTITY across_aspect terminal_aspect ';'
{
for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
if(!table->insert(*b,make_pair((string)"qty",(TYPES*)0))){
err_msg("multiple declaration of quantity '",*b,"'");
}
}
delete $2;
}
| QUANTITY through_aspect terminal_aspect ';'
{
for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
if(!table->insert(*b,make_pair((string)"qty",(TYPES*)0))){
err_msg("multiple declaration of quantity '",*b,"'");
}
}
delete $2;
}
| QUANTITY across_aspect through_aspect terminal_aspect ';'
{
for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
if(!table->insert(*b,make_pair((string)"qty",(TYPES*)0))){
err_msg("multiple declaration of quantity '",*b,"'");
}
}
delete $2;
}
| QUANTITY identifier_list ':' subtype_indication
source_aspect ';'
{
for(list<string>::iterator b=$2->begin(); b!=$2->end();b++){
if(!table->insert(*b,make_pair((string)"qty",(TYPES*)0))){
err_msg("multiple declaration of quantity '",*b,"'");
}
}
delete $2;
}
;
across_aspect : identifier_list tolerances assign_exp ACROSS {$$ = $1;}
;
tolerances : TOLER expression
|
;
through_aspect :
identifier_list tolerances assign_exp THROUGH {$$ = $1;}
;
terminal_aspect :
name
| name TO name
;
source_aspect : SPECTRUM simple_expression ',' simple_expression
| NOISE simple_expression
;
/* End Additions */
file_declaration
: VFILE identifier_list ':' subtype_indication ';'
{}
| VFILE identifier_list ':' subtype_indication
{}
external_file_association ';'
;
file_access_mode
:
| OPEN expression
;
external_file_association
: file_access_mode IS file_logical_name
| file_access_mode IS mode file_logical_name
;
file_logical_name
: name {} //expression revised on July/1/1996.
;
alias_declaration
: ALIAS alias_name al_decl_head IS name al_decl_tail ';'
{}// TYPES *t= search( table, $5->name2->label );
//table->add_symbol($2, $3); }
;
alias_name
: VID { $$= $1->label; }
| CHARLIT { $$= $1; }
| STRLIT { $$= $1; }
;
al_decl_head
: {}// $$= new TYPES( "unknown", "unknown", "unknown" ); }
| ':' sub_indications {}// $$= $2; }
;
al_decl_tail : signature
|
;
signature_symbol
:
| signature
;
signature
: '[' signature_body signature_tail ']'
| '[' signature_tail ']'
;
signature_body
: name
{}// TYPES *t= search(table, $1->name2->label );
// delete t;
//}
| signature_body ',' name
{}
/* TYPES *t= search(table,$3->name2->label );
delete t;
}*/
;
signature_tail
:
| RETURN name
;
recursive_units
:
| design_file
;
component_declaration
: COMPONENT VID
{
parsing_stack.push(make_pair(cur_entity, tel_tb));
cur_entity = $2->label;
tel_tb = 0;
table->push();
if(open_entity_lst->find($2->label).empty()){
//cout << $2->label<< " " << (*name_mapping)[$2->label] << endl;
if(switch_buffer((*name_mapping)[$2->label] + ".vhd")){
new_action_table(cur_entity.c_str());
new_event_table(cur_entity.c_str());
new_rule_table(cur_entity.c_str());
new_conflict_table(cur_entity.c_str());
}
}
}
recursive_units
{
cur_entity = parsing_stack.top().first;
tel_tb = parsing_stack.top().second;
parsing_stack.pop();
table->pop();
new_action_table(cur_entity.c_str());
new_event_table(cur_entity.c_str());
new_rule_table(cur_entity.c_str());
new_conflict_table(cur_entity.c_str());
}
component_declaration_tail comp_decl_tail
{
if(open_entity_lst->find(Tolower($2->label)).empty())
err_msg("error: component ",$2->label," not found");
if($7 && strcmp_nocase($2->label, $7)==false)
err_msg("warning: '", $7,
"' not declared as a component name");
if ($6) delete $6;
}
;
component_declaration_tail
: comp_decl_head { $$ = 0; }
| comp_decl_head generic_clause { $$ = 0; }
| comp_decl_head port_clause
{ $$ = $2; }
| comp_decl_head generic_clause port_clause
{ $$ = $3; }
;
comp_decl_head
:
| IS
;
comp_decl_tail
: END COMPONENT ';'
{ $$ = 0; }
| END COMPONENT VID ';'
{ $$ = $3->label; }
;
attribute_declaration
: ATTRIBUTE VID ':' VID ';'
{
yyerror("Attributes not supported.");
/*
TYPES *t= search( table, $4->label );
TYPES *temp= new TYPES( "attribute", t->datatype() );
table->add_symbol( $2->label,temp );
delete t,temp;
*/
}
;
attribute_specification
: ATTRIBUTE VID
{
yyerror("Attributes not supported.");
//Type *t= search( table, $2->label );
//delete t;
}
OF entity_specification IS expression ';'
;
entity_specification
: entity_name_list ':' entity_class
;
entity_name_list
: entity_name_sequence
| OTHERS
| ALL
;
entity_name_sequence
: entity_designator signature_symbol
| entity_name_sequence ',' entity_designator signature_symbol
;
entity_designator
: VID
{ //TYPES *t= search( table, $1->label );
//delete t;
}
| STRLIT
{}
| CHARLIT
{}
;
entity_class
: ENTITY | ARCHITECTURE | CONFIGURATION | PROCEDURE | FUNCTION
| PACKAGE | TYPE | SUBTYPE | CONSTANT | SIGNAL | VARIABLE
| COMPONENT | LABEL | LITERAL | UNITS | GROUP | VFILE
| NATURE | SUBNATURE | QUANTITY | TERMINAL /* Added for AMS */
;
configuration_specification
: FOR component_specification binding_indication ';'
;
component_specification
: instantiation_list ':' name
{ }
;
instantiation_list
: component_list
| OTHERS
| ALL
;
component_list
: VID
{ //TYPES *t= search( table, $1->label );
//delete t;
}
| component_list ',' VID
{ //TYPES *t= search( table, $3->label );
//delete t;
}
;
binding_indication
:
| USE entity_aspect
| USE entity_aspect map_aspects
| map_aspects {}
;
entity_aspect
: ENTITY name
{}// search( table, $2->name2->label ); }
| CONFIGURATION name
{ /* FILE *temp= NULL;//fopen(strcat($2, ".sim"),"r");
if( temp )
printf("cannot find the configuration");*/
}
| OPEN
;
port_map_aspect: PORT MAP '(' association_list ')' { $$= $4; } ;
generic_map_aspect: GENERIC MAP '(' association_list ')' { $$= $4; } ;
map_aspects
: generic_map_aspect
| port_map_aspect
| generic_map_aspect port_map_aspect {$$ = $2;}
;
disconnection_specification
: DISCONNECT guarded_signal_specification AFTER expression ';'
;
guarded_signal_specification
: signal_list ':' VID
{ //TYPES *t= search( table, $3->label );
//delete t;
}
;
signal_list
: signal_id_list
| OTHERS
| ALL
;
signal_id_list
: VID
{}// table->add_symbol( $1->label, "unknown", "unknown" ); }
| signal_list ',' VID
{}//table->add_symbol( $3->label, "unknown", "unknown" ); }
;
/* Added for AMS */
step_limit_specification
: LIMIT guarded_signal_specification WITH expression ';'
;
use_clause
: USE selected_name ';' { delete $2; }
;
initialization_specification
: INITIALIZE signal_specification TO expression ';'
;
signal_specification
: signal_list ':' mark
;
label_declaration
: VID
{}
statement_name_list ';'
;
statement_name_list
: statement_name
| statement_name_list ',' statement_name
;
statement_name
: VID
{}//table->add_symbol( $1->label, "unknown", "unknown" ); }
| label_array
;
label_array
: VID
{}// table->add_symbol( $1->label, "unknown", "unknown" ); }
index_constraint
;
/* Type Definitions */
enumeration_type_definition
: '(' ee ')'
{
/*$$ = new TYPES;
$$->set_grp(TYPES::Enumeration);
$$->set_list($2);
delete $2;*/
}
;
ee
: enumeration_literal
{ /*
TYPES *ty = new TYPES;
$$ = new TYPELIST($1, ty);*/
}
| ee ',' enumeration_literal
{/*
$$ = $1;
TYPES *ty = new TYPES;
$$->insert($3, ty);*/
}
;
enumeration_literal
: VID
{ $$ = $1->label; }
| CHARLIT
{ $$ = $1; }
;
integer_floating_type_definition /* int and float type syntactically same */
: range_constraint {}
;
range_constraint
: RANGE range { $$ = $2; }
;
range
: attribute_name { yyerror("Attributes not supported."); }
| simple_expression direction simple_expression
{
/*if(strcmp_nocase($1->data_type(), $3->data_type()))
err_msg("different types used on sides of ", $2);
*/
$$ = new TYPELIST(make_pair(string(), $1));
$$->insert($2, $3);
}
;
direction
: TO { $$ = "'to'"; }
| DOWNTO { $$ = "'downto'"; }
;
physical_type_definition
: range_constraint UNITS base_unit_declaration sud END UNITS
{
//$$ = new TYPELIST(0, $3);
//$$->combine($4);
}
| range_constraint UNITS base_unit_declaration sud
END UNITS VID
{
//$$ = new TYPELIST(0, $3);
//$$->combine($4);
}
;
sud
: { $$ = 0; }
| sud secondary_unit_declaration
{
/*if($1)
{
$$ = $1;
$$->insert(0, $2);
}
else
$$ = new TYPELIST(0, $2); */
}
;
base_unit_declaration
: VID ';'
{
//$$ = new TYPES;
//$$->set_string($1->label);
}
;
secondary_unit_declaration
: VID '=' physical_literal ';'
{
//$$ = new TYPES("uk", "uk");
//$$->set_string($1->label);
}
;
array_type_definition
: unconstrainted_array_definition
{
//$$ = $1;
//$$->set_base($$->data_type());
//$$->set_data("vec");
//$$->set_grp(TYPES::Array);
}
| constrained_array_definition
{
//$$ = $1;
//$$->set_base($$->data_type());
//$$->set_data("vec");
}
;
unconstrainted_array_definition
: ARRAY '(' isd ')' OF subtype_indication
{
/* $$ = $6;
$$->set_base($$->data_type());
$$->set_list($3);
delete $3;*/
}
;
constrained_array_definition
: ARRAY index_constraint OF subtype_indication
{
/*$$ = $4;
$2->combine($$->get_list());
$$->set_list($2);
$$->set_base($$->data_type());
$$->set_grp(TYPES::Array);
delete $2;*/
}
;
isd
: index_subtype_definition
| isd index_subtype_definition {$$ = $1; $$->combine($2); }
;
index_subtype_definition
: mark RANGE BOX
{
/*TYPES *ty = table->lookup($1->front());
if(ty == 0)
{
table->print();
err_msg("'", $1->front(), "' undeclared.");
ty = new TYPES("err", "err");
}
else if(strcmp_nocase(ty->obj_type(), "typ"))
{
err_msg("'", $1->front(), "' is not a type name.");
ty->set_obj("err");
ty->set_data("err");
}
else if(ty->get_grp() != TYPES::Integer &&
ty->get_grp() != TYPES::Enumeration)
{
err_msg("integers or enumerations required for ",
"subscripts of arrays");
ty->set_obj("err");
ty->set_data("err");
}
TYPES lower; lower.set_int(0);
TYPES upper; upper.set_int(0);
TYPELIST tl(0, &lower);
tl.insert(0, &upper);
ty->set_list(&tl);
$$ = new TYPELIST(0, ty);
delete ty;*/
}
;
index_constraint
: '(' disdis ')' // Store the subscripts of array declarations
{ $$ = $2; } // in typelists.
;
disdis
: discrete_range
{
$$ = new TYPELIST(make_pair(string(), $1));
}
| disdis ',' discrete_range
{
$$ = $1;
$$->insert(string(), $3);
}
;
record_type_definition
: RECORD elde END RECORD
{
//$$= new TYPES("uk", "RECORD","RECORD");
}
| RECORD elde END RECORD VID
{
//$$= new TYPES("uk", "RECORD","RECORD");
}
;
elde
: element_declaration
| elde element_declaration
;
element_declaration
: identifier_list ':' subtype_indication ';'
{}
;
access_type_definition
: ACCESS subtype_indication {}
;
file_type_definition
: VFILE OF name {}
| VFILE size_constraint OF name {}
;
size_constraint
: '(' expression ')'
;
subtype_declaration
: SUBTYPE VID IS sub_indications ';'
{
/*if(strcmp_nocase($4->obj_type(), "uk") == 0)
$4->set_obj("typ");
//$4->set_base($4->data_type());
//$4->set_data($2->label);
//cout<< $2->label<< endl;
if(table->insert($2->label, $4) == false)
{
err_msg("re-declaration of '", $2->label, "'");
}
delete $4;*/
}
;
/* Added for AMS */
sub_indications
: mark tolerances
{}
| mark tolerances more_toler
{}
| mark gen_association_list tolerances
{}
| mark gen_association_list tolerances more_toler
{}
| subtype_indication1 tolerances
{}
;
more_toler
: ACROSS expression THROUGH
;
/* End Additions */
subtype_indication
: mark
{
/*$$ = table->lookup($1->front());
if($$ == 0)
{
err_msg("'", $1->front(), "' undeclared");
$$ = new TYPES("err", "err");
}
$$->set_string($1->front().c_str());*/
}
| mark gen_association_list
{ /*
$$ = table->lookup($1->front());
if($$ == 0)
{
err_msg("'", $1->front(), "' undeclared");
$$ = new TYPES("err", "err");
}
else
{
$$->set_list($2);
}*/
}
| subtype_indication1 {}
;
subtype_indication1
: mark range_constraint
{/*
$$ = table->lookup($1->front());
if($$ == 0)
{
err_msg("'", $1->front(), "' undeclared");
$$ = new TYPES("err", "err");
}
else if(strcmp_nocase($$->obj_type(), "typ"))
{
err_msg("'", $1->front(), "' is not a type name");
$$->set_obj("err");
$$->set_data("err");
}
$$->set_list($2);*/
}
| mark mark range_constraint
{
//$$= search( table, $1->label );
}
| mark mark
{ /*
$$ = table->lookup($2->front());
if($$ == 0)
{
err_msg("'", $2->front(), "' undeclared");
$$ = new TYPES("err", "err");
}*/
}
| mark mark gen_association_list
{
//$$= search( table, $1->label );
}
;
discrete_range
: range
{
$$ = new TYPES;
$$->set_list($1);
$1->iteration_init();
$$->set_data($1->value().second.data_type());
}
| subtype_indication
;
discrete_range1
: simple_expression direction simple_expression
{
$$ = new TYPELIST(make_pair(string(), $1));
$$->front().second.theExpression = $1->theExpression;
$$->insert($2, $3);
}
| subtype_indication1
{
$$= new TYPELIST(make_pair(string(), $1));
}
;
/* Added for AMS */
scalar_nature_definition
: name ACROSS name THROUGH VID REFERENCE
;
array_nature_definition
: ARRAY '(' isd ')' OF subnature_indication {}
| ARRAY index_constraint OF subnature_indication {}
;
record_nature_definition
: RECORD record_nature_alternative
END RECORD VID
{}
;
record_nature_alternative
: identifier_list ':' subnature_indication ';'
| record_nature_alternative
identifier_list ':' subnature_indication ';'
;
subnature_declaration
: SUBNATURE VID IS subnature_indication ';'
;
subnature_indication
: mark //tolerances
{}
| mark gen_association_list //tolerances
{}
| subnature_indication1 {}//tolerances
;
subnature_indication1
: mark TOLER expression ACROSS expression THROUGH {}
| mark gen_association_list TOLER expression
ACROSS expression THROUGH {}
;
/* End Additions */
/* Concurrent Statements */
concurrent_statement
: block_statement { $$ = 0; }
| process_statement { $$ = 0; }
| concurrent_procedure_call { $$ = 0; }
| concurrent_assertion_statement { $$ = 0; }
| concurrent_signal_assignment_statement{ $$ = 0; }
| component_instantiation_statement { $$ = 0; }
| generate_statement { $$ = 0; }
| concurrent_break_statement { $$ = 0; } /* Added for AMS */
;
block_statement
: block_label is_symbol block_header block_declarative_part
VBEGIN block_statement_part block_end
{ tel_tb->insert($1, $6); }
| block_label guarded_exp is_symbol block_header
block_declarative_part VBEGIN block_statement_part
block_end
{ tel_tb->insert($1, $7); }
;
block_end
: END BLOCK ';'
| END BLOCK VID ';'
;
guarded_exp
: '(' expression ')' {}
;
block_label
: label BLOCK
;
is_symbol
:
| IS
;
block_header
:
| generic_clause
| generic_clause generic_map_aspect ';'
| port_clause {}
| port_clause { }
port_map_aspect ';' { }
| generic_clause port_clause
| generic_clause port_clause port_map_aspect ';'
| generic_clause generic_map_aspect ';' port_clause
| generic_clause generic_map_aspect ';'
port_clause port_map_aspect ';'
;
block_declarative_part
:
| block_declarative_part block_declarative_item
;
block_statement_part
: { $$= TERSempty(); }
| block_statement_part concurrent_statement
{ $$= TERScompose($1, $2, "||"); }
| block_statement_part simultaneous_statement //AMS
{ $$= TERScompose($1, $2, "||");}
;
block_declarative_item
: subprogram_declaration {}
| subprogram_body
| type_declaration
| subtype_declaration
| constant_declaration
| signal_declaration
| file_declaration
| alias_declaration
| component_declaration
| attribute_declaration
| label_declaration
| attribute_specification
| initialization_specification
| configuration_specification
| disconnection_specification
| use_clause {}
| variable_declaration
| group_template_declaration
| group_declaration
/* Added for AMS */
| step_limit_specification
| nature_declaration
| subnature_declaration
| quantity_declaration
| terminal_declaration
;
process_statement
: process_head process_tail
{
table->new_tb();
processChannels.clear();
}
process_declarative_part VBEGIN process_statement_part
END postpone process_end
{
map<string,int>::iterator m(processChannels.begin());
while(m != processChannels.end()){
string name(m->first);
int type(m->second);
if(type&ACTIVE && type&SENT||
type&PASSIVE && type&RECEIVED){
type |= PUSH;
}
if(type&ACTIVE && type&RECEIVED ||
type&PASSIVE && type&SENT ){
type |= PULL;
}
signals[cur_entity][name] |= type;
action(name+SEND_SUFFIX+"+")->type |= type;
action(name+SEND_SUFFIX+"-")->type |= type;
action(name+RECEIVE_SUFFIX+"+")->type |= type;
action(name+RECEIVE_SUFFIX+"-")->type |= type;
m++;
}
table->delete_tb();
$$ = 0;
if($6){
$$ = TERSmakeloop($6);
$$ = TERSrepeat($$,";");
char s[255];
strcpy(s, rmsuffix($1));
if (1) {
printf("Compiled process %s\n",s);
fprintf(lg,"Compiled process %s\n",s);
}
else
emitters(outpath, s, $$);
}
if(tel_tb->insert(($1), $$) == false)
err_msg("duplicate process label '", $1, "'");
}
;
process_end
: PROCESS ';'
| PROCESS VID ';'
;
process_head
: PROCESS
{
char n[1000];
sprintf(n, "p%ld", PSC);
PSC++;
$$ = copy_string(n);
//TYPES *t = new TYPES("prc", "uk");
//table->new_scope($$, "process", t);
}
| label PROCESS
{
$$ = copy_string($1);
//TYPES *t = new TYPES("prc", "uk");
//table->new_scope($$, "process", t);
}
| POSTPONED PROCESS
{
char n[1000];
sprintf(n, "p%ld", PSC);
PSC++;
$$ = copy_string(n);
}
| label POSTPONED PROCESS
{ $$ = copy_string($1); }
;
postpone
: { }
| POSTPONED
;
process_tail
: is_symbol
| '(' sensitivity_list ')' is_symbol
{
__sensitivity_list__= 1;
}
;
sensitivity_list
: name
{
//TYPES *t= search( table, $1->getstring());
//table->add_symbol( $1->getstring(), t );
//delete t;
}
| sensitivity_list ',' name
{
//TYPES *t= search( table, $3->getstring());
//table->add_symbol($3->getstring(), t );
//delete t;
}
;
process_declarative_part
:
| process_declarative_part process_declarative_item
;
process_declarative_item
: subprogram_declaration {}
| subprogram_body
| type_declaration
| subtype_declaration
| constant_declaration
| variable_declaration
| file_declaration
| alias_declaration
| attribute_declaration
| label_declaration
| attribute_specification
| use_clause {}
| group_template_declaration
| group_declaration
;
process_statement_part
: { $$ = 0; }
| process_statement_part sequential_statement
{
if($2->second)
$$ = TERScompose($1, TERSrename($1,$2->second),";");
else
$$ = $1;
delete $2;
}
;
concurrent_procedure_call
: procedure_call_statement
//: name '(' association_list ')' ';' {}
| label procedure_call_statement {}
| POSTPONED procedure_call_statement
| label POSTPONED procedure_call_statement {}
;
component_instantiation_statement
: label COMPONENT name ';'
{
//SymTab *temp= search1(table,$3->name2->label );
//delete temp;
}
| label cmpnt_stmt_body map_aspects ';'
{
string comp_id = $2->str();
if(open_entity_lst->find(comp_id).empty()){
err_msg("error: component '",comp_id.c_str(), "' not found");
delete $3;
return 1;
}
else {
const tels_table& TT = open_entity_lst->find(comp_id,
string());
if(TT.empty()){
err_msg("error: no architecture defined for '",
comp_id, "'");
return 1;
}
tels_table* rpc = new tels_table(TT);
const list<pair<string,int> >& tmp = rpc->signals1();
if(tmp.size() != $3->size())
err_msg("incorrect port map of '",$2->str(),"'");
else {
const vector<pair<string,int> > sig_v(tmp.begin(),
tmp.end());
const map<string,int>& sig_m = rpc->signals();
map<string,int>& ports = tel_tb->port_decl();
list<pair<string,string> >::size_type pos = 0;
map<string,string> port_maps;
list<pair<string,string> >::iterator BB;
for(BB = $3->begin(); BB != $3->end(); BB++, pos++){
string formal(BB->first);
string actual(BB->second);
if(formal.empty() && pos < sig_v.size()){
formal = sig_v[pos].first;
}
if(sig_m.find(formal) == sig_m.end()){
err_msg("undeclared formal signal '", formal,"'");
}
else{
int type(sig_m.find(formal)->second);
if(signals[cur_entity].find(actual) ==
signals[cur_entity].end()){
if(ports.find(actual) == ports.end()){
err_msg("undeclared actual signal ", actual);
}
else{
ports[actual] |= type;
}
}
else{
const int use(ACTIVE|PASSIVE|SENT|RECEIVED);
int overlap(signals[cur_entity][actual] &type & use);
if(overlap & ACTIVE){
err_msg("Channel ",actual,
" is active on both sides!");
}
if(overlap & PASSIVE){
err_msg("Channel ",actual,
" is passive on both sides!");
}
if(overlap & SENT){
err_msg("Channel ",actual,
" has sends on both sides!");
}
if(overlap & RECEIVED){
err_msg("Channel ",actual,
" has receives on both sides!");
}
if(type&ACTIVE && type&SENT||
type&PASSIVE && type&RECEIVED){
type |= PUSH;
}
if(type&ACTIVE && type&RECEIVED ||
type&PASSIVE && type&SENT ){
type |= PULL;
}
signals[cur_entity][actual] |= type;
action(actual+SEND_SUFFIX+"+")->type |= type;
action(actual+SEND_SUFFIX+"-")->type |= type;
action(actual+RECEIVE_SUFFIX+"+")->type |= type;
action(actual+RECEIVE_SUFFIX+"-")->type |= type;
}
}
port_maps[formal]=actual;
}
my_list *netlist = new my_list(port_maps);
string s = $2->str();
rpc->set_id($1);
rpc->set_type(comp_id);
rpc->instantiate(netlist, $1, s);
rpc->insert(port_maps);
if(tel_tb->insert(($1), rpc) == false)
err_msg("duplicate component label '", $1, "'");
delete netlist;
}
delete $3;
}
}
;
cmpnt_stmt_body
: name
| COMPONENT name { $$ = $2; }
| ENTITY name { $$ = $2; }
| CONFIGURATION name { $$ = $2; }
;
concurrent_assertion_statement
: assertion_statement
{
char n[100];
sprintf(n, "ss%ld", PSC);
PSC++;
printf("Compiled assertion statement %s\n",n);
fprintf(lg,"Compiled assertion statement %s\n",n);
TERstructADT x;
x = TERSmakeloop($1);
x = TERSrepeat(x,";");
tel_tb->insert(n, x);
}
| label assertion_statement {
char n[100];
if ($1)
strcpy(n,$1);
else {
sprintf(n, "ss%ld", PSC);
PSC++;
}
printf("Compiled assertion statement %s\n",n);
fprintf(lg,"Compiled assertion statement %s\n",n);
TERstructADT x;
x = TERSmakeloop($2);
x = TERSrepeat(x,";");
tel_tb->insert(n, x);
}
| POSTPONED assertion_statement { }
| label POSTPONED assertion_statement { }
;
concurrent_signal_assignment_statement
: conditional_signal_assignment
{
char id[200];
sprintf(id, "CS%ld", (unsigned long)$1);
tel_tb->insert((id), $1);
}
| label conditional_signal_assignment
{ tel_tb->insert(($1), $2); }
| selected_signal_assignment { $$ = 0; }
| label selected_signal_assignment { $$ = 0; }
| POSTPONED conditional_signal_assignment { $$ = 0; }
| label POSTPONED conditional_signal_assignment
{ $$ = 0; }
| POSTPONED selected_signal_assignment { $$ = 0; }
| label POSTPONED selected_signal_assignment { $$ = 0; }
;
conditional_signal_assignment
: target LE options conditional_waveforms ';'
{
string ENC, EN_r, EN_f;
int LL = INFIN, UU = 0;
list<pair<TYPES,TYPES> >::iterator b;
for(b = $4->begin(); b != $4->end(); b++){
if(b->first.grp_id() != TYPES::Error &&
b->second.grp_id() != TYPES::Error){
// Calculate the delay.
const TYPELIST *t = b->first.get_list();
if(b->first.str() != "unaffected" &&
t != 0 && t->empty() == false){
if(LL>t->front().second.get_int())
LL = t->front().second.get_int();
if(UU<t->back().second.get_int())
UU = t->back().second.get_int();
if (!(t->front().second.get_string().empty())) {
actionADT a= action(t->front().second.get_string());
LL = a->intval;
}
if (!(t->back().second.get_string().empty())) {
actionADT a = action(t->back().second.get_string());
UU = a->intval;
}
}
if(!ENC.size()){
if(b->first.str() != "unaffected"){
EN_r = logic(bool_relation(b->first.str(), "'1'"),
b->second.str());
EN_f = logic(bool_relation(b->first.str(), "'0'"),
b->second.str());
}
ENC = my_not(b->second.str());
}
else{
if(b->first.str() != "unaffected"){
EN_r = logic(EN_r,
logic(logic(bool_relation(b->first.str(),
"'1'"),
b->second.str()),
ENC),
"|");
EN_f = logic(EN_f,
logic(logic(bool_relation(b->first.str(),
"'0'"),
b->second.str()),
ENC),
"|");
}
ENC = logic(ENC, my_not(b->second.str()));
}
}
}
string a_r = $1->get_string() + '+';
string a_f = $1->get_string() + '-';
actionADT a = action($1->str() + '+');
telADT RR, FF, RC, FC;
string CC = '[' + EN_r + ']' + 'd';
RC = TERS(dummyE(), FALSE, 0,0, TRUE, CC.c_str());
RR = TERS(action($1->str()+'+'),FALSE,LL,UU,TRUE);
CC = '[' + EN_f + ']' + 'd';
FC = TERS(dummyE(), FALSE, 0,0, TRUE, CC.c_str());
FF = TERS(action($1->str()+'-'),FALSE,LL,UU,TRUE);
if (a->initial) {
$$ = TERScompose(TERScompose(FC, FF, ";"),
TERScompose(RC, RR, ";"), ";");
} else {
$$ = TERScompose(TERScompose(RC, RR, ";"),
TERScompose(FC, FF, ";"), ";");
}
$$ = TERSmakeloop($$);
$$ = TERSrepeat($$,";");
//emitters(0, "tmp", $$);
}
;
target
: name
| aggregate
;
options
:
| delay_mechanism
| GUARDED
| GUARDED delay_mechanism
;
delay_mechanism
: TRANSPORT
| INERTIAL
| VREJECT expression INERTIAL
;
conditional_waveforms
: waveform_head waveform
{
if($1) $$ = $1;
else $$ = $$ = new list<pair<TYPES,TYPES> >;
TYPES ty("uk","bool");
ty.set_grp(TYPES::Enumeration);
ty.set_str("true");
$$->push_back(make_pair(*$2,ty));
}
| waveform_head waveform WHEN expression
{
if($1)
$$ = $1;
else
$$ = new list<pair<TYPES,TYPES> >;
if($4->grp_id() != TYPES::Error &&
$4->data_type() != string("bool")) {
err_msg("expect a boolean expression after 'when'");
$4->set_grp(TYPES::Error);
}
$$->push_back(make_pair(*$2, *$4));
}
;
waveform_head
: { $$ = 0; }
| waveform_head waveform WHEN expression ELSE
{
if($1) $$ = $1;
else $$ = new list<pair<TYPES,TYPES> >;
if($4->grp_id() != TYPES::Error &&
$4->data_type() != string("bool")){
err_msg("expect a boolean expression after 'when'");
$4->set_grp(TYPES::Error);
}
$$->push_back(make_pair(*$2, *$4));
}
;
selected_signal_assignment
: WITH expression SELECT target LE options
selected_waveforms ';'
{
delete $7;
/*telADT ret_t = TERSempty();
if($7){
for(list<pair<TYPES*,TYPES*> >::iterator b = $7->begin();
b != $7->end(); b++){*/
}
;
selected_waveforms
: waveform WHEN choices
{
$$ = 0;
if($3){
if($3->back().data_type() != "bool")
err_msg("expect a boolean expression after 'when'");
else{
$$ = new list<pair<TYPES,TYPES> >;
TYPES ty("uk","bool");
ty.set_grp(TYPES::Enumeration);
list<string> str_l;
for(list<TYPES>::iterator b = $3->begin();
b != $3->end(); b++)
str_l.push_back(b->str());
ty.set_str(logic(str_l, "|"));
$$->push_back(make_pair(*$1,ty));
}
}
}
| selected_waveforms ',' waveform WHEN choices
{
$$ = 0;
if($1 && $5){
if($5->back().data_type() != "bool"){
err_msg("expect a boolean expression after 'when'");
delete $1; delete $5; $1 = 0;
}
else{
TYPES ty("uk","bool");
ty.set_grp(TYPES::Enumeration);
list<string> str_l;
for(list<TYPES>::iterator b = $5->begin();
b != $5->end(); b++)
str_l.push_back(b->str());
ty.set_str(logic(str_l, "|"));
$1->push_back(make_pair(*$3,ty));
}
}
$$ = $1;
}
/*| {
//$$= new TYPES( "ERROR", "ERROR" );
}*/
;
generate_statement
: label generation_head generate_declarative_part
concurrent_statement_sequence END GENERATE generate_tail ';'
{}
| label generation_head generate_declarative_part
VBEGIN concurrent_statement_sequence END GENERATE
generate_tail ';'
{}
;
generation_head
: generation_scheme GENERATE
{}
;
generate_tail
:
| VID
{
/*TYPES *t= search( table, $1->label );
delete t;
SymTab *temp= table->header;
delete table;
table= temp;*/
}
;
generate_declarative_part
: generate_declarative_part block_declarative_item
|
;
/* Added for AMS (Simultaneous Statement Parts) */
concurrent_statement_sequence
: concurrent_statement
{}
| simultaneous_statement
{}
| concurrent_statement_sequence concurrent_statement
| concurrent_statement_sequence simultaneous_statement
;
generation_scheme
: FOR parameter_specification
| IF expression
{ /*
if( !($2.type->isBool() || $2.type->isError()) )
err_msg_3( "the 'if' should be followed a boolean",
"expression", "");*/
}
;
parameter_specification
: VID VIN discrete_range
{}
;
/* Added for AMS */
concurrent_break_statement
: label_symbol BREAK break_elements
sensitivity_clause when_symbol ';'
| label_symbol BREAK break_elements when_symbol ';'
{
TERstructADT breakElem = 0;
if ($3) {
breakElem = Guard(*$3);
}
//An assign statement
if ($4) {
char n[100];
if ($1)
strcpy(n,$1);
else {
sprintf(n, "ss%ld", PSC);
PSC++;
}
string condition = $4->O->event->exp;
string remainder;
//Removes the ]
condition = condition.substr(0,condition.size()-1);
//change ='0' and ='1' to bool or ~bool
while(condition.find("='") != string::npos) {
if (condition.find("='1'") != string::npos) {
remainder = condition.substr(condition.find("='1'")+
4, string::npos);
condition = condition.substr(0,
condition.find("='1'"));
}
else if (condition.find("='0'") != string::npos) {
remainder = condition.substr(condition.find("='0'")+
4, string::npos);
condition = condition.substr(1,string::npos);
condition = "[~(" +
condition.substr(0,condition.find("='0'")) + ")";
}
condition = condition + remainder;
}
string action = breakElem->O->event->exp;
action = action.substr(1, string::npos);
$4->O->event->exp = CopyString((condition+
" & "+ action).c_str());
TERstructADT x;
//x = TERScompose($4, breakElem, ";");
x = TERSmakeloop($4);
x = TERSrepeat(x,";");
char s[255];
strcpy(s, rmsuffix(n));
printf("Compiled break statement %s\n",s);
fprintf(lg,"Compiled break statement %s\n",s);
tel_tb->insert(n, x);
}
//initial conditions
else {
for (eventsetADT step = breakElem->O; step; step = step->link) {
TERstructADT x;
//pull apart the exp to get the variable and the number
string var = step->event->exp;
var = var.substr(1,var.find(":=")-1);
string num = step->event->exp;
num = num.substr(num.find(":=")+2,string::npos);
num = num.substr(0,num.find(']'));
actionADT a = action(var);
a->type = CONT + VAR + DUMMY;
if (num.find(';') == string::npos) {
a->linitval = atoi(num.c_str());
a->uinitval = atoi(num.c_str());
} else {
string lval = num.substr(1,num.find(';'));
string uval = num.substr(num.find(';')+1,
string::npos-1);
a->linitval = atoi(lval.c_str());
a->uinitval = atoi(uval.c_str());
}
x = TERS(a,FALSE,0,0,FALSE);
tel_tb->insert(var, x);
}
}
}
;
/* Simultaneous Statements */
/* Added for AMS */
simultaneous_statement :
simul_statement
{
/*
for (simul_lst::iterator elem = $1->begin();
elem != $1->end() && elem != NULL; elem++) {
cout << elem->first << endl;
for (list<string>::iterator selem=elem->second.begin();
selem != elem->second.end(); selem++) {
cout << "\t" << *selem << endl;
}
}
*/
if ($1) {
if ($1->size() == 1) {
//Simple Simultaneous Statment
//Like a rate assignment
char n[1000];
sprintf(n, "ss%ld", PSC);
PSC++;
char s[255];
strcpy(s, rmsuffix(n));
printf("Compiled simple simultaneous statement %s\n",s);
fprintf(lg,
"Compiled simple simultaneous statement %s\n",s);
$$ = Guard(*($1->begin()->second.begin()));
$$ = TERSmakeloop($$);
$$ = TERSrepeat($$,";");
tel_tb->insert(n, $$);
}
else {
actionsetADT allActions;
eventsetADT allEvents;
rulesetADT allRules;
conflictsetADT allConflicts;
rulesetADT initRules;
unsigned int j = 1;
int expanded = EXPANDED_RATE_NETS;
if (expanded==0 || expanded==2) {
actionADT x;
x = dummyE();
x->maxoccur = 1;
allActions = create_action_set(x);
allEvents = create_event_set(event(x,1,2,1,NULL,""));
}
for (simul_lst::iterator elem = $1->begin();
elem != $1->end(); elem++) {
string level = "[" + elem->first;
//level = level.substr(0,level.find(" & true"));
for(list<string>::iterator selem=elem->second.begin();
selem != elem->second.end(); selem++) {
level += " & " + *selem;
}
while (level.find(" & true") != string::npos) {
level.replace(level.find(" & true"),7,"");
}
while (level.find("true ") != string::npos) {
level.replace(level.find("true "),7,"");
}
if (expanded==2) {
for (simul_lst::iterator elem2 = $1->begin();
elem2 != $1->end(); elem2++) {
if (elem2 != elem) {
for(list<string>::iterator selem2=elem2->second.begin();
selem2 != elem2->second.end(); selem2++) {
unsigned int first,last,ins,curEnd;
curEnd=(*selem2).length()-1;
while (curEnd > 0) {
for (last=curEnd;(*selem2)[last]!=':'
&& last>=0;last--);
for (first=last;(*selem2)[first]!=' '
&& first>=0;first--);
if (first >= 0) {
for (ins=level.length()-1;level[ins]==')'
&& ins>=0;ins--);
if (ins >= 0) {
level.insert(ins+1," & " +
(*selem2).substr(first+1,
last-first-1) +
":=FALSE");
}
}
for (curEnd=first;(*selem2)[curEnd]!='|'
&& curEnd>0;curEnd--);
}
}
}
}
}
level += "]";
if (expanded==1) {
//Creates one event for each of the other events
for (unsigned int i = 1; i <= $1->size(); i++) {
if (i != j) {
eventsetADT curEvent;
actionsetADT curAction;
actionADT a;
if (j == 1 && i == 2) {
a = dummyE();
a->maxoccur = 1;
allActions = create_action_set(a);
allEvents =
create_event_set(event(a,1,i,j,NULL,
level.c_str()));
}
else {
a = dummyE();
a->maxoccur = 1;
curAction = create_action_set(a);
curEvent =
create_event_set(event(a,1,i,j,
NULL,level.c_str()));
allActions = union_actions(allActions,
curAction);
allEvents = union_events(allEvents,curEvent);
}
}
}
}
else {
eventsetADT curEvent;
actionsetADT curAction;
actionADT a;
a = dummyE();
a->maxoccur = 1;
curAction = create_action_set(a);
curEvent =
create_event_set(event(a,1,1,2,
NULL,level.c_str()));
allActions = union_actions(allActions,
curAction);
allEvents = union_events(allEvents,curEvent);
}
if (expanded==1) j++;
}
bool firstR = true;
bool firstRp = true;
bool firstC = true;
for (eventsetADT toEvent = allEvents;
toEvent != NULL; toEvent = toEvent->link) {
for (eventsetADT fromEvent = allEvents;
fromEvent != NULL; fromEvent = fromEvent->link) {
if(fromEvent->event->upper==toEvent->event->lower) {
if (toEvent->event->lower == 1) {
if (firstRp) {
initRules =
create_rule_set(rule(fromEvent->event,
toEvent->event,
0,0,TRIGGER,true,NULL,
toEvent->event->exp));
firstRp = false;
}
else {
initRules = add_rule(initRules,
fromEvent->event,
toEvent->event,
0,0,TRIGGER,NULL,
toEvent->event->exp);
}
}
else {
if (firstR) {
allRules =
create_rule_set(rule(fromEvent->event,
toEvent->event,
0,0,TRIGGER,true,NULL,
toEvent->event->exp));
firstR = false;
}
else {
allRules = add_rule(allRules,fromEvent->event,
toEvent->event,
0,0,TRIGGER,NULL,
toEvent->event->exp);
}
}
}
if(((fromEvent->event->lower!=toEvent->event->lower &&
fromEvent->event->upper==toEvent->event->upper) ||
(fromEvent->event->upper!=toEvent->event->upper &&
fromEvent->event->lower==toEvent->event->lower)) ||
((expanded==0 || expanded==2) &&
fromEvent->event->upper==toEvent->event->upper &&
fromEvent->event->lower==toEvent->event->lower &&
fromEvent->event->upper != 1 &&
strcmp(fromEvent->event->exp,toEvent->event->exp)))
{
if (firstC) {
allConflicts =
create_conflict_set(conflict(fromEvent->
event,
toEvent->
event));
firstC = false;
}
else {
allConflicts = add_conflict(allConflicts,
fromEvent->event,
toEvent->event);
}
}
}
}
for (simul_lst::iterator elem = $1->begin();
elem != $1->end(); elem++) {
if (expanded==2) {
for(list<string>::iterator selem=elem->second.begin();
selem != elem->second.end(); selem++) {
eventsetADT curEvent;
actionsetADT curAction;
actionADT a;
unsigned int first,last,curEnd;
curEnd=(*selem).length()-1;
while (curEnd > 0) {
for (last=curEnd;(*selem)[last]!=':'
&& last>=0;last--);
for (first=last;(*selem)[first]!=' '
&& first>=0;first--);
if ((first >= 0)&&(last >= 0)) {
a = action((*selem).substr(first+1,last-first-1)+'+');
a->type = OUT;
a->maxoccur = 1;
curAction = create_action_set(a);
curEvent =
create_event_set(event(a,1,0,0,NULL,NULL));
allActions = union_actions(allActions,
curAction);
allEvents = union_events(allEvents,curEvent);
a = action((*selem).substr(first+1,last-first-1)+'-');
a->type = OUT;
a->maxoccur = 1;
curAction = create_action_set(a);
curEvent =
create_event_set(event(a,1,0,0,NULL,NULL));
allActions = union_actions(allActions,
curAction);
allEvents = union_events(allEvents,curEvent);
}
for (curEnd=first;(*selem)[curEnd]!='|'
&& curEnd>0;curEnd--);
}
}
}
}
$$ = new terstruct_tag;
$$->A = allActions;
$$->O = allEvents;
$$->R = allRules;
$$->Rp = initRules;
if (firstC == true) $$->C = NULL;
else $$->C = allConflicts;
$$->I = NULL;
$$->first = NULL;
$$->last = NULL;
$$->loop = NULL;
$$->CT = NULL;
$$->CP = NULL;
$$->DPCT = NULL;
$$->CPCT = NULL;
$$->DTCP = NULL;
$$->CTCP = NULL;
$$->CPDT = NULL;
$$->Cp = NULL;
$$->exp = NULL;
char n[1000];
sprintf(n, "ss%ld", PSC);
PSC++;
char s[255];
strcpy(s,rmsuffix(n));
fflush(stdout);
tel_tb->insert(n, $$);
printf("Compiled simultaneous statement %s\n",s);
fprintf(lg,"Compiled simultaneous statement %s\n",s);
}
}
}
;
simul_statement :
simple_simultaneous_statement
{
$$ = $1;
}
| simultaneous_if_statement
{
$$ = $1;
}
| simultaneous_case_statement
{
$$ = $1;
//TYPES ty; ty.set_str("case");
//$$ = new pair<TYPES,telADT>(ty, $1);
}
| simultaneous_procedural_statement
{
$$ = 0;
printf("Procedures are not supported\n");
//TYPES ty; ty.set_str("proc");
//$$ = new pair<TYPES,telADT>(ty, 0);
}
| null_statement
{
$$ = 0;
//TYPES ty; ty.set_str("nil");
//$$ = new pair<TYPES,telADT>(ty, 0);
}
;
sequence_of_simul_statements : { $$ = 0; }
| sequence_of_simul_statements simul_statement
{
$$ = new simul_lst;
bool simple=true;
if ($1) {
for (simul_lst::iterator elem = $1->begin();
elem != $1->end(); elem++) {
if (elem->first != "true") {
simple=false;
break;
}
}
}
if (simple) {
if ($2) {
for (simul_lst::iterator elem = $2->begin();
elem != $2->end(); elem++) {
if (elem->first != "true") {
simple=false;
break;
}
}
}
}
if (simple) {
list<string> expressions;
string expression="";
bool first=true;
if ($1) {
for (simul_lst::iterator elem = $1->begin();
elem != $1->end(); elem++) {
for(list<string>::iterator selem=elem->second.begin();
selem != elem->second.end(); selem++) {
if (first) {
first=false;
expression="((";
} else
expression+="|(";
expression+=(*selem);
expression+=")";
}
}
}
if ($2) {
for (simul_lst::iterator elem = $2->begin();
elem != $2->end(); elem++) {
for(list<string>::iterator selem=elem->second.begin();
selem != elem->second.end(); selem++) {
if (first) {
first=false;
expression="((";
} else
expression+="|(";
expression+=(*selem);
expression+=")";
}
}
}
expression+=")";
expressions.push_back(expression);
$$->push_back(make_pair("true",expressions));
} else {
if ($1)
$$ = $1;
for (simul_lst::iterator elem = $2->begin();
elem != $2->end(); elem++) {
list<string> expressions;
for(list<string>::iterator selem=elem->second.begin();
selem != elem->second.end(); selem++) {
expressions.push_back(elem->first+" & "+(*selem));
}
$$->push_back(make_pair("true",expressions));
}
}
/*
for (simul_lst::iterator elem = $2->begin();
elem != $2->end(); elem++) {
$$->push_back(*elem);
}*/
}
;
simple_simultaneous_statement :
label simple_expression EQ simple_expression
tolerances ';'
{
$$ = new simul_lst;
list<string> expressions;
expressions.push_back($2->theExpression + ":=" +
$4->theExpression);
$$->push_back(make_pair("true",expressions));
}
| simple_expression EQ simple_expression
tolerances ';'
{
$$ = new simul_lst;
list<string> expressions;
expressions.push_back($1->theExpression + ":=" +
$3->theExpression);
$$->push_back(make_pair("true",expressions));
}
| label mark '\'' VDOT EQ simple_expression ';'
{
$$ = new simul_lst;
list<string> expressions;
if (EXPANDED_RATE_NETS==0) {
expressions.push_back("~(" + (*$2->begin()) + "dot>=" +
$6->theExpression + " & " +
(*$2->begin()) + "dot<=" +
$6->theExpression + ") & " +
*($2->begin()) + "'dot:=" +
$6->theExpression);
} else if (EXPANDED_RATE_NETS==1) {
expressions.push_back(*($2->begin()) + "'dot:=" +
$6->theExpression);
} else {
string temp_str;
temp_str =(*$2->begin()) + "dot_";
for (int i=0;$6->theExpression[i]!='\0';i++) {
if ($6->theExpression[i]=='-')
temp_str += "m";
else if ($6->theExpression[i]==';')
temp_str += "_";
else if (($6->theExpression[i]!='{') &&
($6->theExpression[i]!='}'))
temp_str += $6->theExpression[i];
}
expressions.push_back("~(" + temp_str + ") & " +
*($2->begin()) + "'dot:=" +
$6->theExpression + " & " +
temp_str + ":=TRUE");
}
$$->push_back(make_pair("true",expressions));
}
| mark '\'' VDOT EQ simple_expression ';'
{
$$ = new simul_lst;
list<string> expressions;
if (EXPANDED_RATE_NETS==0) {
expressions.push_back("~(" + (*$1->begin()) + "dot>=" +
$5->theExpression + " & " +
(*$1->begin()) + "dot<=" +
$5->theExpression + ") & " +
*($1->begin()) + "'dot:=" +
$5->theExpression);
} else if (EXPANDED_RATE_NETS==1) {
expressions.push_back(*($1->begin()) + "'dot:=" +
$5->theExpression);
} else {
string temp_str;
temp_str =(*$1->begin()) + "dot_";
for (int i=0;$5->theExpression[i]!='\0';i++) {
if ($5->theExpression[i]=='-')
temp_str += "m";
else if ($5->theExpression[i]==';')
temp_str += "_";
else if (($5->theExpression[i]!='{') &&
($5->theExpression[i]!='}'))
temp_str += $5->theExpression[i];
}
expressions.push_back("~(" + temp_str + ") & " +
*($1->begin()) + "'dot:=" +
$5->theExpression + " & " +
temp_str + ":=TRUE");
}
$$->push_back(make_pair("true",expressions));
}
;
simultaneous_if_statement :
label IF expression USE
sequence_of_simul_statements
simul_elsifthen simul_else_part END USE VID ';'
{
string exp = "";
if($3->data_type() != string("bool"))
exp = $3->theExpression;
else
exp = $3->str();
/*
if ($3->theExpression.find("=") != string::npos) {
if ($3->theExpression.find("\'0\'") != string::npos) {
exp = "~";
}
exp +=
$3->theExpression.substr(0,$3->theExpression.find("="));
}
*/
$$ = new simul_lst;
for (simul_lst::iterator elem = $5->begin();
elem != $5->end(); elem++) {
$$->push_back(make_pair(exp + " & " +
elem->first,elem->second));
}
string notOthers = "";
if ($6) {
string current = "";
string last = "";
bool first = true;
for (simul_lst::iterator elem = $6->begin();
elem != $6->end(); elem++) {
if (elem->first != current) {
last = notOthers;
if (first) {
notOthers = "(";
first=false;
} else {
notOthers += " & ";
}
notOthers += "~(" + elem->first + ")";
current=elem->first;
}
if (last=="") {
$$->push_back(make_pair("~(" + exp +
") & " +
elem->first,
elem->second));
} else {
$$->push_back(make_pair("~(" + exp +
") & " +
last + ") & " +
elem->first,
elem->second));
}
}
notOthers += ") & ";
}
if ($7) {
for (simul_lst::iterator elem = $7->begin();
elem != $7->end(); elem++) {
$$->push_back(make_pair("~(" + exp +
") & " + notOthers+elem->first,
elem->second));
}
}
}
| IF expression USE
sequence_of_simul_statements
simul_elsifthen simul_else_part END USE ';'
{
string exp = "";
if($2->data_type() != string("bool"))
exp = $2->theExpression;
else
exp = $2->str();
/*
if ($2->theExpression.find("=") != string::npos) {
if ($2->theExpression.find("\'0\'") != string::npos) {
exp = "~";
}
exp +=
$2->theExpression.substr(0,$2->theExpression.find("="));
}
*/
$$ = new simul_lst;
for (simul_lst::iterator elem = $4->begin();
elem != $4->end(); elem++) {
$$->push_back(make_pair(exp + " & " +
elem->first,elem->second));
}
string notOthers = "";
if ($5) {
string current = "";
string last = "";
bool first = true;
for (simul_lst::iterator elem = $5->begin();
elem != $5->end(); elem++) {
if (elem->first != current) {
last = notOthers;
if (first) {
notOthers = "(";
first=false;
} else {
notOthers += " & ";
}
notOthers += "~(" + elem->first + ")";
current=elem->first;
}
if (last=="") {
$$->push_back(make_pair("~(" + exp +
") & " +
elem->first,
elem->second));
} else {
$$->push_back(make_pair("~(" + exp +
") & " +
last + ") & " +
elem->first,
elem->second));
}
}
notOthers += ") & ";
}
if ($6) {
for (simul_lst::iterator elem = $6->begin();
elem != $6->end(); elem++) {
$$->push_back(make_pair("~(" + exp +
") & " + notOthers+elem->first,
elem->second));
}
}
}
;
simul_elsifthen :
{ $$ = 0; }
| simul_elsifthen ELSIF expression USE
sequence_of_simul_statements
{
string exp = "";
if($3->data_type() != string("bool"))
exp = $3->theExpression;
else
exp = $3->str();
/*
if ($3->theExpression.find("=") != string::npos) {
if ($3->theExpression.find("\'0\'") != string::npos) {
exp = "~";
}
exp +=
$3->theExpression.substr(0,$3->theExpression.find("="));
}*/
$$ = new simul_lst;
/* string notOthers = ""; */
if ($1) {
/* notOthers = "("; */
/* bool first = true; */
/* for (simul_lst::iterator elem = $1->begin(); */
/* elem != $1->end(); elem++) { */
/* if (!first) notOthers += " & "; */
/* notOthers += "~(" + elem->first + ")"; */
/* first = false; */
/* } */
/* notOthers += ") & "; */
$$ = $1;
}
/* add the expression to each in the sequence */
for (simul_lst::iterator elem = $5->begin();
elem != $5->end(); elem++) {
$$->push_back(make_pair(/*notOthers +*/
exp /*+ " & " +
elem->first*/,
elem->second));
}
}
;
simul_else_part :
{ $$ = 0; }
| ELSE sequence_of_simul_statements
{
$$ = $2;
}
;
simultaneous_case_statement :
label_symbol CASE expression USE
simul_case_statement_alternative
END CASE VID ';'
{
$$ = $5;
for (simul_lst::iterator elem = $$->begin();
elem != $$->end(); elem++) {
if (elem->first[0] == '~') {
elem->first = "~(" + $3->theExpression + ")" +
elem->first.substr(1,string::npos);
}
else {
elem->first = $3->theExpression + elem->first;
}
}
}
| label_symbol CASE expression USE
simul_case_statement_alternative
END CASE ';'
{
$$ = $5;
for (simul_lst::iterator elem = $$->begin();
elem != $$->end(); elem++) {
if (elem->first[0] == '~') {
elem->first = "~(" + $3->theExpression + ")" +
elem->first.substr(1,string::npos);
}
else {
elem->first = $3->theExpression + elem->first;
}
}
}
;
simul_case_statement_alternative :
WHEN choices ARROW sequence_of_simul_statements
{
$$ = new simul_lst;
/* These probably aren't going to be as robust
as they should be, but work for now */
string exp = "";
if ($2->begin()->str() == "'0'")
exp = "~";
/* add the expression to each in the sequence */
for (simul_lst::iterator elem = $4->begin();
elem != $4->end(); elem++) {
$$->push_back(make_pair(exp + " & " +
elem->first,elem->second));
}
}
| simul_case_statement_alternative
WHEN choices ARROW sequence_of_simul_statements
{
$$ = $1;
string exp = "";
if ($3->begin()->str() == "'0'")
exp = "~";
/* add the expression to each in the sequence */
for (simul_lst::iterator elem = $5->begin();
elem != $5->end(); elem++) {
$$->push_back(make_pair(exp + " & " +
elem->first,elem->second));
}
}
;
simultaneous_procedural_statement :
procedural_head is_symbol
{
table->new_tb();
processChannels.clear();
}
sequence_of_declarative_items VBEGIN
process_statement_part END procedural_end
{
map<string,int>::iterator m(processChannels.begin());
while(m != processChannels.end()){
string name(m->first);
int type(m->second);
if(type&ACTIVE && type&SENT||
type&PASSIVE && type&RECEIVED){
type |= PUSH;
}
if(type&ACTIVE && type&RECEIVED ||
type&PASSIVE && type&SENT ){
type |= PULL;
}
signals[cur_entity][name] |= type;
action(name+SEND_SUFFIX+"+")->type |= type;
action(name+SEND_SUFFIX+"-")->type |= type;
action(name+RECEIVE_SUFFIX+"+")->type |= type;
action(name+RECEIVE_SUFFIX+"-")->type |= type;
m++;
}
table->delete_tb();
$$ = 0;
if($6){
$$ = TERSmakeloop($6);
$$ = TERSrepeat($$,";");
char s[255];
strcpy(s, rmsuffix($1));
if (1) {
printf("Compiled process %s\n",s);
fprintf(lg,"Compiled process %s\n",s);
}
else
emitters(outpath, s, $$);
}
if(tel_tb->insert(($1), $$) == false)
err_msg("duplicate process label '", $1, "'");
}
;
procedural_end :
PROCEDURAL ';'
| PROCEDURAL VID ';'
;
procedural_head :
PROCEDURAL
{
char n[1000];
sprintf(n, "p%ld", PSC);
PSC++;
$$ = copy_string(n);
}
| label PROCEDURAL
{
$$ = copy_string($1);
}
;
sequence_of_declarative_items :
| sequence_of_declarative_items procedural_declarative_item
;
procedural_declarative_item :
subprogram_declaration {}
| subprogram_body {}
| type_declaration {}
| subtype_declaration {}
| constant_declaration {}
| variable_declaration {}
| alias_declaration {}
| attribute_declaration {}
| attribute_specification {}
| use_clause {}
| group_template_declaration {}
| group_declaration {}
;
/* Sequential Statements */
sequential_statement
: wait_statement
{
/*if(__sensitivity_list__)
{
err_msg("wait statement must not appear",
"in a process statement which has",
"a sensitivity list");
__sensitivity_list__= 0;
}*/
TYPES ty; ty.set_str("wait");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| assertion_statement
{
TYPES ty; ty.set_str("assert");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| signal_assignment_statement
{
TYPES ty; ty.set_str("sig");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| variable_assignment_statement
{
TYPES ty; ty.set_str("var");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| procedure_call_statement
{
TYPES ty; ty.set_str("proc");
$$ = new pair<TYPES,telADT>(ty, 0);
}
| if_statement
{
TYPES ty; ty.set_str("if");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| case_statement
{
TYPES ty; ty.set_str("case");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| loop_statement
{
TYPES ty; ty.set_str("loop");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| next_statement
{
TYPES ty; ty.set_str("next");
$$ = new pair<TYPES,telADT>(ty, 0);
}
| exit_statement
{
TYPES ty; ty.set_str("exit");
$$ = new pair<TYPES,telADT>(ty, 0);
}
| return_statement
{
TYPES ty; ty.set_str("rtn");
$$ = new pair<TYPES,telADT>(ty, 0);
}
| null_statement
{
TYPES ty; ty.set_str("nil");
$$ = new pair<TYPES,telADT>(ty, 0);
}
| report_statement
{
TYPES ty; ty.set_str("rep");
$$ = new pair<TYPES,telADT>(ty, 0);
}
| communicationStatement
{
TYPES ty; ty.set_str("sig");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| assign_statements
{
TYPES ty; ty.set_str("sig");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| vassign_statements
{
TYPES ty; ty.set_str("sig");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| guardish_statement
{
TYPES ty; ty.set_str("wait");
$$ = new pair<TYPES,telADT>(ty, $1);
}
/* Added for AMS */
| break_statement
{
TYPES ty; ty.set_str("break");
$$ = new pair<TYPES,telADT>(ty, $1);
}
| rate_assignment
{
TYPES ty; ty.set_str("rate");
$$ = new pair<TYPES,telADT>(ty, $1);
}
/* End Additions */
;
guardish_statement: guard_statement | guard_or_statement | guard_and_statement
| await_statement | await_any_statement | await_all_statement
;
guard_statement : GUARD '(' andor_stmt ')' ';'
{
$$=Guard($3->str());
}
| GUARD '(' expression ')' ';'
{
$$ = Guard($3->theExpression);
}
| GUARD '(' andor_ams ')' ';'
{
$$ = Guard($3->str());
}
;
guard_or_statement :GUARDOR '(' or_stmts ')' ';' {$$=Guard($3->str());};
guard_and_statement:GUARDAND '(' and_stmts ')' ';' {$$=Guard($3->str());};
await_statement :AWAIT '(' probedChannel ')' ';' {$$=Guard($3->str());};
await_any_statement:AWAITANY '(' target_terms ')' ';' {$$=Guard($3->str());};
await_all_statement:AWAITALL '(' target_factors ')' ';' {$$=Guard($3->str());};
target_factors : probedChannel
| probedChannel ',' target_factors
{
string s = $1->str() + '&' + $3->str();
$$->set_str(s);
}
;
target_terms : probedChannel
| probedChannel ',' target_terms
{
string s = $1->str() + '|' + $3->str();
$$->set_str(s);
}
;
probedChannel : target
{
$$ = new TYPES;
$$->set_data("bool");
$$->set_str(bool_relation(Probe($1->str())->str(), "'1'", "="));
}
;
and_stmts : andor_stmt
| andor_stmt ',' and_stmts
{
string s = $1->str() + '&' + $3->str();
$$->set_str(s);
}
;
or_stmts : andor_stmt
| andor_stmt ',' or_stmts
{
string s = $1->str() + '|' + $3->str();
$$->set_str(s);
}
;
andor_stmt : expression ',' expression
{
pair<string,TYPES> TT1 = table->lookup($1->str());
pair<string,TYPES> TT3 = table->lookup($3->str());
$$ = new TYPES;
$$->set_data("bool");
if(table->lookup($1->get_string()).first == "qty" ||
table->lookup($3->get_string()).first == "qty")
cout << "WARNING: Use the guard(expr,relop,expr) syntax "
<< "for quantities.";
else if(table->lookup($1->get_string()).first == "var" ||
table->lookup($3->get_string()).first == "var")
$$->set_str("maybe");
else {
$$->set_str(bool_relation($1->str(), $3->str(), "="));
}
}
;
andor_ams : expression ',' INT ',' REAL
{
pair<string,TYPES> TT1 = table->lookup($1->str());
$$ = new TYPES;
$$->set_data("expr");
if (table->lookup($1->get_string()).first == "qty") {
string relop;
switch ($3) {
case 0:
relop = ">";
break;
case 1:
relop = ">=";
break;
case 2:
relop = "<";
break;
case 3:
relop = "<=";
break;
case 4:
relop = "=";
break;
default:
relop = "=";
break;
}
$$->set_str($1->str() + relop + numToString((int)$5));
}
else
$$->set_str("maybe");
}
;
wait_statement
: label_symbol WAIT ';' { $$ = 0; }
| label_symbol WAIT sensitivity_clause ';' { $$ = 0; }
| label_symbol WAIT condition_clause ';'
{
$$ = TERS(dummyE(), FALSE, 0, 0, TRUE, $3->str().c_str());
}
| label_symbol WAIT timeout_clause ';' { $$ = $3; }
| label_symbol WAIT sensitivity_clause condition_clause ';'
{$$ = 0; }
| label_symbol WAIT sensitivity_clause timeout_clause ';'
{$$ = 0; }
| label_symbol WAIT sensitivity_clause condition_clause
timeout_clause ';' {$$ = 0; }
| label_symbol WAIT condition_clause timeout_clause ';'
{$$ = 0; }
;
condition_clause
: UNTIL expression
{
$$ = $2;
string s;
if($2->data_type() != string("bool"))
s = '[' + $$->theExpression + ']';
else
s = '[' + $$->str() + ']';
$$->set_str(s);
}
;
sensitivity_clause
: ON sensitivity_list
;
timeout_clause
: FOR expression
{
int l = 0, u = INFIN;
const TYPELIST *tl = $2->get_list();
if(tl != 0){
TYPELIST::const_iterator I = tl->begin();
if(I != tl->end()) {
l = tl->front().second.get_int();
I++;
if(I!=tl->end())
u = tl->back().second.get_int();
}
$$ = TERS(dummyE(), FALSE, l, u, TRUE);
}
else{
$$ = NULL;
}
}
;
assertion_statement
: ASSERT expression tralass ';'
{
string expr;
if($2->data_type() != string("bool"))
expr = "[~(" + $2->theExpression + ")]";
else
expr = "[~(" + $2->str() + ")]";
string LL = "fail+";
actionADT a = action(LL);
makebooldecl(OUT|ISIGNAL, a, false, NULL);
$$ = TERS(a, FALSE, 0, 0, FALSE, expr.c_str());
}
;
/*
condition
: expression
{
if($1->data_type() != string("bool")){
//err_msg("non-boolean expression used as condition");
warn_msg("non-boolean expression used as condition");
$$ = new TYPES("err", "err");
$$->set_str("maybe");
}
else
$$ = $1;
}
;
*/
tralass
:
| REPORT expression
| SEVERITY VID
{}
| REPORT expression SEVERITY VID
{}
;
communication
: SEND
{
reqSuffix = SEND_SUFFIX;
ackSuffix = RECEIVE_SUFFIX;
join = dummyE(); //Branches of parallel send join here.
join->lower = join->upper = 0;
direction = SENT;
}
| RECEIVE
{
reqSuffix = RECEIVE_SUFFIX;
ackSuffix = SEND_SUFFIX;
join = dummyE(); //Branches of parallel receive join here.
join->lower = join->upper = 0;
direction = RECEIVED;
}
;
communicationStatement
: communication '(' parallelCommunication ')' ';' {$$ = $3;}
| communication '(' target ')' ';'
{
$$ = FourPhase($3->get_string());
}
;
parallelCommunication
: fourPhase
| parallelCommunication ',' fourPhase
{
$$ = TERScompose($1, $3, "||");
}
;
fourPhase : target ',' expression
{
$$ = FourPhase($1->get_string(),$3->get_string());
}
;
assign_statements : ASSIGNMENT '(' assign_statement ')' ';' { $$ = $3; }
;
assign_statement : assign_stmt
| assign_statement ',' assign_stmt
{
$$ = TERScompose($1, $3, "||");
}
;
assign_stmt : target ',' expression ',' INT ',' INT
{
string s;
string sb;
TERstructADT x,y,z;
if($3->get_string() == "'1'") {
actionADT a = action($1->get_string() + '+');
$$ = TERS(a, FALSE, $5, $7, FALSE);
} else if($3->get_string() == "'0'") {
actionADT a = action($1->get_string() + '-');
$$ = TERS(a, FALSE, $5, $7, FALSE);
} else {
actionADT a = dummyE();
a->list_assigns = addAssign(a->list_assigns, $1->get_string(), $3->get_string());
$$ = TERS(a, FALSE, $5, $7, TRUE);
} /* else {
s = '[' + $3->get_string() + ']';
sb = "[~(" + $3->get_string() + ")]";
actionADT a = action($1->get_string() + '+');
actionADT b = action($1->get_string() + '-');
x = TERS(dummyE(), FALSE, 0, 0, FALSE);
y = TERS(a, FALSE, $5, $7, FALSE, s.c_str());
z = TERS(b, FALSE, $5, $7, FALSE, sb.c_str());
$$ = TERScompose(y,z,"|");
$$ = TERScompose(x,$$,";");
}*/
}
;
/* Added for AMS */
rate_assignment :
mark '\'' VDOT ASSIGN simple_expression ';'
{
if (table->lookup(*($1->begin())).first == "qty") {
$$ = Guard(*($1->begin()) + "'dot:=" +
$5->theExpression);
}
else
$$ = 0;
}
/*
{
TERstructADT x,y;
actionADT a = action(*($1->begin()));
a->type = CONT + VAR;
x = TERS(a, FALSE, (int)$6, (int)$6, FALSE);
string sign = $5;
y = Guard(*($1->begin()) + "'dot" + ":=" +
sign + numToString($6));
$$ = TERScompose(x,y,";");
}*/
/*
| mark '\'' VDOT ASSIGN mark '(' neg REAL ',' neg REAL ')' ';'
{
TERstructADT x,y;
actionADT a = action(*($1->begin()));
a->type = CONT + VAR;
x = TERS(a, FALSE, (int)$8, (int)$11, FALSE);
string sign1 = $7;
string sign2 = $10;
y = Guard(*($1->begin()) + "'dot" + ":={" +
sign1 + numToString($8) + ";" +
sign2 + numToString($11) + '}');
$$ = TERScompose(x,y,";");
}
*/
;
/* End Additions */
vassign_statements : VASSIGNMENT '(' vassign_statement ')' ';'
{
$$ = $3;
}
;
vassign_statement : vassign_stmt
| vassign_statement ',' vassign_stmt
{
$$ = TERScompose($1, $3, "||");
}
;
vassign_stmt : target ',' expression ',' INT ',' INT
{
string s;
string sb;
TERstructADT x,y,z;
if($3->get_string() == "'1'") {
s = "[~" + $1->get_string() + ']';
sb = '[' + $1->get_string() + ']';
actionADT a = action($1->get_string() + '+');
x = TERS(dummyE(), FALSE, 0, 0, FALSE);
y = TERS(a, FALSE, $5, $7, FALSE, s.c_str());
z = TERS(dummyE(),FALSE,$5,$7,FALSE,sb.c_str());
$$ = TERScompose(y,z,"|");
$$ = TERScompose(x,$$,";");
} else if($3->get_string() == "'0'") {
s = '[' + $1->get_string() + ']';
sb = "[~" + $1->get_string() + ']';
actionADT a = action($1->get_string() + '-');
x = TERS(dummyE(), FALSE, 0, 0, FALSE);
y = TERS(a, FALSE, $5, $7, FALSE, s.c_str());
z = TERS(dummyE(),FALSE,$5,$7,FALSE,sb.c_str());
$$ = TERScompose(y,z,"|");
$$ = TERScompose(x,$$,";");
} else {
actionADT a = dummyE();
a->list_assigns = addAssign(a->list_assigns, $1->get_string(), $3->get_string());
$$ = TERS(a, FALSE, $5, $7, TRUE);
} /* else {
s = '[' + $3->get_string() + ']';
sb = "[~(" + $3->get_string() + ")]";
actionADT a = action($1->get_string() + '+');
actionADT b = action($1->get_string() + '-');
x = TERS(dummyE(), FALSE, 0, 0, FALSE);
y = TERS(a, FALSE, $5, $7, FALSE, s.c_str());
z = TERS(b, FALSE, $5, $7, FALSE, sb.c_str());
$$ = TERScompose(y,z,"|");
$$ = TERScompose(x,$$,";");
}*/
}
/*
{
string s,sb,sc;
TERstructADT w,x,y,z;
if($3->get_string() == "'1'") {
s = "[~" + $1->get_string() + ']';
sb = '[' + $1->get_string() + ']';
actionADT a = action($1->get_string() + '+');
x = TERS(dummyE(), FALSE, 0, 0, FALSE);
y = TERS(a, FALSE, $5, $7, FALSE, s.c_str());
z = TERS(dummyE(),FALSE,$5,$7,FALSE,sb.c_str());
$$ = TERScompose(y,z,"|");
$$ = TERScompose(x,$$,";");
} else if($3->get_string() == "'0'") {
s = '[' + $1->get_string() + ']';
sb = "[~" + $1->get_string() + ']';
actionADT a = action($1->get_string() + '-');
x = TERS(dummyE(), FALSE, 0, 0, FALSE);
y = TERS(a, FALSE, $5, $7, FALSE, s.c_str());
z = TERS(dummyE(),FALSE,$5,$7,FALSE,sb.c_str());
$$ = TERScompose(y,z,"|");
$$ = TERScompose(x,$$,";");
} else {
s = "[(" + $3->get_string() + ")&(~" + $1->get_string()
+ ")]";
sb = "[(~(" + $3->get_string() + "))&(" +
$1->get_string() + ")]";
sc = "[((" + $3->get_string() + ")&(" +
$1->get_string() + "))|((~(" + $3->get_string() +
"))&(~(" + $1->get_string() + ")))]";
actionADT a = action($1->get_string() + '+');
actionADT b = action($1->get_string() + '-');
w = TERS(dummyE(),FALSE,$5,$7,FALSE,sc.c_str());
x = TERS(dummyE(), FALSE, 0, 0, FALSE);
y = TERS(a, FALSE, $5, $7, FALSE, s.c_str());
z = TERS(b, FALSE, $5, $7, FALSE, sb.c_str());
$$ = TERScompose(y,z,"|");
$$ = TERScompose($$,w,"|");
$$ = TERScompose(x,$$,";");
}
}
*/
;
signal_assignment_statement
: target LE delay_mechanism waveform ';'
{ /*
if(check_type($1, $4))
err_msg("left and right sides of",
" '<=' have different types", ";");*/
$4->set_str($4->theExpression);
$$ = signalAssignment($1,$4);
}
| target LE waveform ';'
{
$3->set_str($3->theExpression);
$$ = signalAssignment($1,$3);
}
/*else {
$$ = TERSempty();
err_msg("input signal '", $1->get_string(),
"' used as the target of the assignment");
} */
| label target LE delay_mechanism waveform ';'
{
$5->set_str($5->theExpression);
$$ = signalAssignment($2,$5);
/*
if(check_type($2, $5))
err_msg("left and right sides of '<=' have",
" different types", ";");
$$= TERSempty();*/
}
| label target LE waveform ';'
{
$4->set_str($4->theExpression);
$$ = signalAssignment($2,$4);
/*
if(check_type($2, $4))
err_msg("left and right sides of '<=' have",
" different types", ";");
$$= TERSempty(); */
}
;
waveform
: waveform_element { $$= $1; }
| waveform ',' waveform_element
{
$$ = $1;
/*
if(!check_type($1, $3))
$$= $1;
else if($1->isUnknown())
$$= $3; */
}
| UNAFFECTED
{
$$ = new TYPES();
$$->set_str("unaffected");
}
;
waveform_element
: expression
{
$$ = $1;
TYPES lower; lower.set_int(0);
TYPES upper; upper.set_int(0);
str_ty_lst ll(1, make_pair(string(), lower));
ll.push_back(make_pair(string(), upper));
$$->set_list(TYPELIST(ll));
}
| expression AFTER expression
{
$$ = $1;
if($3->get_list() == 0){
TYPES upper; upper.set_int(INFIN);
str_ty_lst LL(1, make_pair(string(), *$3));
LL.push_back(make_pair(string(), upper));
$$->set_list(TYPELIST(LL));
}
else
$$->set_list($3->get_list());
delete $3;
}
;
variable_assignment_statement
: label target ASSIGN expression ';'
{
/*
if(check_type($2, $4))
err_msg("left and right sides of ':='",
" have different types", ";");*/
if (table->lookup($2->get_string()).first == "qty") {
$$ = Guard($2->get_string() + ":=" + $4->theExpression);
}
else
$$ = 0;
}
| target ASSIGN expression ';'
{ /*
if(check_type($1, $3))
err_msg("left and right sides of ':='",
" have different types", ";");*/
if (table->lookup($1->get_string()).first == "qty") {
$$ = Guard($1->get_string() + ":=" + $3->theExpression);
}
else
$$ = 0;
}
;
/* Adding label_symbol or association list creates conflicts */
procedure_call_statement
: name ';' {}
//| name '(' association_list ')' ';' {}
;
if_statement
: label_symbol IF expression THEN sequence_of_statements
elsifthen else_part END IF ';'
{
if($5->size() == 1 && $5->front().first.str() == "wait")
$$ = $5->front().second;
else {
telADT T5 = telcompose(*$5);
string EN;
//condition vs. expression
if($3->data_type() != string("bool"))
EN = $3->theExpression;
else
EN = $3->str();
string ENC = my_not(EN);
string CC = '['+ EN +']';
actionADT AA = dummyE();
$$ = TERS(AA, FALSE, 0, 0, TRUE, CC.c_str());
$$ = TERScompose($$, T5, ";");
if($6){
ty_tel_lst::iterator BB;
for(BB = $6->begin(); BB != $6->end(); BB++){
if (BB->first.data_type() == string("bool"))
CC = '['+ logic(ENC, BB->first.str()) +']';
else
CC = '[' + logic(ENC, BB->first.theExpression)
+ ']';
telADT TT = TERS(dummyE(),FALSE,0,0,TRUE, CC.c_str());
telADT TTT = TERScompose(TT, BB->second, ";");
$$ = TERScompose($$, TERSrename($$, TTT), "|");
if (BB->first.data_type() == string("bool"))
ENC = logic(ENC, my_not(BB->first.str()));
else
ENC = logic(ENC, my_not(BB->first.theExpression));
}
}
CC = '['+ ENC +']';
telADT LL = TERS(dummyE(), FALSE,0,0,TRUE, CC.c_str());
telADT LLL = TERScompose(LL, $7, ";");
$$ = TERScompose($$, TERSrename($$, LLL), "|");
}
delete $5;
}
| label_symbol IF expression THEN sequence_of_statements
elsifthen else_part END IF VID ';'
{
if($5->size() == 1 && $5->front().first.str() == "wait")
$$ = $5->front().second;
else {
telADT T5 = telcompose(*$5);
string EN;
//condition vs. expression
if($3->data_type() != string("bool"))
EN = $3->theExpression;
else
EN = $3->str();
string ENC = my_not(EN);
string CC = '['+ EN +']';
actionADT AA = dummyE();
$$ = TERS(AA, FALSE, 0, 0, TRUE, CC.c_str());
$$ = TERScompose($$, T5, ";");
if($6){
ty_tel_lst::iterator BB;
for(BB = $6->begin(); BB != $6->end(); BB++){
if (BB->first.data_type() == string("bool"))
CC = '['+ logic(ENC, BB->first.str()) +']';
else
CC = '[' + logic(ENC, BB->first.theExpression)
+ ']';
telADT TT = TERS(dummyE(),FALSE,0,0,TRUE, CC.c_str());
telADT TTT = TERScompose(TT, BB->second, ";");
$$ = TERScompose($$, TERSrename($$, TTT), "|");
if (BB->first.data_type() == string("bool"))
ENC = logic(ENC, my_not(BB->first.str()));
else
ENC = logic(ENC, my_not(BB->first.theExpression));
}
}
CC = '['+ ENC +']';
telADT LL = TERS(dummyE(), FALSE,0,0,TRUE, CC.c_str());
telADT LLL = TERScompose(LL, $7, ";");
$$ = TERScompose($$, TERSrename($$, LLL), "|");
}
delete $5;
if($1 && $10->label && strcmp_nocase($1, $10->label)==false)
err_msg($10->label, " is not the if statement label.");
}
;
elsifthen
: { $$ = 0; }
| elsifthen ELSIF expression THEN sequence_of_statements
{
if($1) $$ = $1;
else $$ = new ty_tel_lst;
$$->push_back(make_pair(*$3, telcompose(*$5)));
$$->back().first.theExpression = $3->theExpression;
delete $5; delete $3;
}
;
else_part
: { $$ = 0;}
| ELSE sequence_of_statements
{ $$ = telcompose(*$2); delete $2;}
;
label_symbol
: { $$ = 0; }
| label
;
label
: VID ':' { $$ = $1->label; }
;
sequence_of_statements
: { $$ = 0; }
| sequence_of_statements sequential_statement
{
if($1) $$ = $1;
else $$ = new list<pair<TYPES,telADT> >;
$$->push_back(*$2);
delete $2;
}
;
case_statement
: label_symbol CASE expression IS case_statement_alternative
END CASE ';'
{
$$ = 0;
ty_tel_lst::iterator b;
string SS = table->lookup($3->get_string()).first;
for(b = $5->begin(); b != $5->end(); b++){
telADT tt = 0;
if(SS == "var")
tt = TERS(dummyE(), FALSE, 0, 0, TRUE);
else {
string ss='['+bool_relation($3->str(),b->first.str())+']';
tt = TERS(dummyE(), FALSE, 0, 0, TRUE, ss.c_str());
}
telADT T = TERScompose(tt,TERSrename(tt,b->second),";");
if($$)
$$ = TERScompose($$, TERSrename($$, T), "|");
else
$$ = T;
}
// $$ = TERScompose(TERS(dummyE(),FALSE, 0, 0, TRUE), $$, "|");
delete $5;
}
| label_symbol CASE expression IS case_statement_alternative
END CASE VID ';'
{
$$ = 0;
ty_tel_lst::iterator b;
string SS = table->lookup($3->get_string()).first;
for(b = $5->begin(); b != $5->end(); b++){
telADT tt = 0;
if(SS == "var")
tt = TERS(dummyE(), FALSE, 0, 0, TRUE);
else {
string ss='['+bool_relation($3->str(),b->first.str())+']';
tt = TERS(dummyE(), FALSE, 0, 0, TRUE, ss.c_str());
}
telADT T = TERScompose(tt,TERSrename(tt,b->second),";");
if($$)
$$ = TERScompose($$, TERSrename($$, T), "|");
else
$$ = T;
}
// $$ = TERScompose(TERS(dummyE(),FALSE, 0, 0, TRUE), $$, "|");
delete $5;
}
;
case_statement_alternative
: WHEN choices ARROW sequence_of_statements
{
$$ = new list<pair<TYPES,telADT> >;
TYPES ty("uk", "bool");
if($2){
list<string> str_l;
for(list<TYPES>::iterator b = $2->begin();
b != $2->end(); b++)
str_l.push_back(b->str());
ty.set_str(logic(str_l, "|"));
}
else{
ty.set_grp(TYPES::Error);
ty.set_str("false");
}
$$->push_back(make_pair(ty, telcompose(*$4)));
delete $2; delete $4;
}
| case_statement_alternative
WHEN choices ARROW sequence_of_statements
{
$$ = $1;
TYPES ty("uk", "bool");
if($3){
list<string> str_l;
for(list<TYPES>::iterator b = $3->begin();
b != $3->end(); b++)
str_l.push_back(b->str());
ty.set_str(logic(str_l, "|"));
}
else{
ty.set_grp(TYPES::Error);
ty.set_str("false");
}
$$->push_back(make_pair(ty, telcompose(*$5)));
delete $3; delete $5;
}
;
loop_statement
: label_symbol iteration_scheme LOOP sequence_of_statements
END LOOP ';'
{
telADT T4 = telcompose(*$4); delete $4;
if($2 == 0)
$$ = TERSempty();
else{
actionADT a = dummyE();
string ss = "[" + $2->str() + "]";
TERstructADT t3 = TERS(a, FALSE, 0, 0, TRUE, ss.c_str());
TERstructADT loop_body =
TERScompose(t3, TERSrename(t3, T4), ";");
loop_body = TERSmakeloop(loop_body);
// create the tel structure for loop exit.
string s = '['+ my_not($2->str()) + ']';
TERstructADT loop_exit = TERS(dummyE(), FALSE, 0, 0,
TRUE, s.c_str());
// make conflict between loop body and loop exit
$$ = TERScompose(loop_body,TERSrename(loop_body,
loop_exit), "|");
$$ = TERSrepeat($$,";");
}
}
| label_symbol iteration_scheme LOOP sequence_of_statements
END LOOP VID ';'
{
telADT T4 = telcompose(*$4); delete $4;
if($2 == 0)
$$ = TERSempty();
else{
string ss = "[" + $2->str() + "]";
telADT t3=TERS(dummyE(),FALSE,0,0,TRUE, ss.c_str());
telADT loop_body = TERScompose(t3,TERSrename(t3, T4),";");
loop_body = TERSmakeloop(loop_body);
// create the tel structure for loop exit.
string s = '[' + my_not($2->str()) + ']';
telADT loop_exit= TERS(dummyE(),FALSE,0,0,TRUE,s.c_str());
// make conflict between loop body and loop exit
$$ = TERScompose(loop_body,TERSrename(loop_body,
loop_exit), "|");
$$ = TERSrepeat($$,";");
if($1 && strcmp_nocase($1, $7->label)==false)
err_msg($7->label, " is not the loop statement label.");
}
}
;
iteration_scheme
:
{
$$ = new TYPES();
$$->set_str("true");
$$->set_data("bool");
}
| WHILE expression
{
$$ = $2;
if(strcmp_nocase($2->data_type(), "bool")==false){
warn_msg("non-boolean expression used as condition");
$$->set_grp(TYPES::Error);
$$->set_str("maybe");
}
}
| FOR VID VIN discrete_range { $$ = 0; }
;
next_statement
: label_symbol NEXT ';' {}
| label_symbol NEXT VID ';' { }
| label_symbol NEXT WHEN expression ';'{ }
| label_symbol NEXT VID {}
WHEN expression ';' {}
;
exit_statement
: label_symbol EXIT ';' {}
| label_symbol EXIT VID ';' {}
| label_symbol EXIT WHEN expression ';' {}
| label_symbol EXIT VID {}
WHEN expression ';' {}
;
return_statement
: label_symbol RETURN ';' {}
| label_symbol RETURN expression ';' {}
;
null_statement
: VNULL ';' {}
| label VNULL ';' {}
;
report_statement
: label_symbol REPORT expression ';' {}
| label_symbol REPORT expression SEVERITY VID ';' {}
;
/* Added for AMS */
break_statement
: label_symbol BREAK break_elements when_symbol ';'
{ $$=Guard(*$3); }
| label_symbol BREAK when_symbol ';' { $$=0; }
;
when_symbol
: {$$ = 0;}
| WHEN expression
{$$ = Guard($2->theExpression);}
;
break_elements
: break_element {$$ = $1;}
| break_elements ',' break_element
{
if ($1 && $3) {
$$ = new string((*$1) + " & " + (*$3));
delete $1;
delete $3;
} else if ($1) {
$$ = $1;
} else {
$$ = $3;
}
}
;
break_element
: FOR name USE name ARROW expression
{$$ = 0;}
| name ARROW expression
{
$$ = new string($1->theExpression + ":=" + $3->theExpression);
}
;
/* End Additions */
/* Interfaces and Associations */
interface_list
: interface_declaration
| interface_list ';' interface_declaration
{
if($1 && $3){
$$ = $3;
$$->splice($$->begin(), *$1);
delete $1;
}
else if($3)
$$ = $3;
else
$$ = $1;
}
;
interface_declaration
: interface_constant_declaration { $$ = 0; }
| interface_signal_declaration { $$ = $1; }
| interface_variable_declaration { $$ = 0; }
| interface_file_declaration { $$ = 0; }
| interface_unknown_declaration { $$= $1; }
/* Added for AMS */
| interface_terminal_declaration { $$ = 0;}
| interface_quantity_declaration { $$ = 0;}
;
/* Added for AMS */
interface_terminal_declaration
: TERMINAL identifier_list ':' subnature_indication {}
;
interface_quantity_declaration
: QUANTITY identifier_list ':' in_out_symbol
subtype_indication assign_exp
{
$$ = new list<pair<string, int> >;
for(list<string>::iterator b=$2->begin();b!=$2->end(); b++){
int init = 0;
if($6->get_string() == "'1'")
init = 1;
string LL = (*b);
actionADT a = action(LL);
if(strcmp_nocase($4, "in")){
makebooldecl(IN, a, init, NULL);
$$->push_back(make_pair(LL, IN));
}
else{
makebooldecl(OUT, a, init, NULL);
$$->push_back(make_pair(LL, OUT));
}
}
}
;
in_out_symbol
: VIN { $$ = "in";}
| VOUT { $$ = "out";}
| {}
;
/* End Additions */
interface_constant_declaration
: CONSTANT identifier_list ':' subtype_indication assign_exp
{}
| CONSTANT identifier_list ':' VIN subtype_indication assign_exp
{}
;
interface_signal_declaration
: SIGNAL identifier_list ':' subtype_indication bus_symbol
assign_exp
{
//$4->set_obj("in");
$$ = new list<pair<string, int> >;
for(list<string>::iterator b=$2->begin();b!=$2->end(); b++){
int init = 0;
if($6->get_string() == "'1'")
init = 1;
string LL((*b));
actionADT a = action(LL);
makebooldecl(IN, a, init, NULL);
$$->push_back(make_pair(LL, IN));
}
/* for a signal of array
else{
TYPELIST *index =
$4->get_list()->value().second->get_list();
index->iteration_init();
int len = index->value().second->get_int();
index->next();
len = len - index->value().second->get_int();
int char_len = strlen($$->value().first);
char *name = 0;
for(int i = 0; i < len; i++)
{
name = new char[char_len+10];
sprintf(name, "%s__%d__+",
$$->value().first, i);
}
#ifdef DDEBUG
assert(name);
#endif
actionADT a = action(name, strlen(name));
delete [] name;
makebooldecl(IN, a, init, NULL);
}
$$->next();
}*/
}
| SIGNAL identifier_list ':' mode subtype_indication
bus_symbol assign_exp
{
/*if(strcmp_nocase($4, "in") == 0)
$5->set_obj("in");
else if(strcmp_nocase($4, "out") == 0)
$5->set_obj("out");
else
$5->set_obj("in");*/
$$ = new list<pair<string, int> >;
for(list<string>::iterator b=$2->begin();b!=$2->end(); b++){
int init = 0;
if($7->get_string() == "'1'")
init = 1;
string LL = (*b);
actionADT a = action(LL);
if(strcmp_nocase($4, "in")){
makebooldecl(IN, a, init, NULL);
$$->push_back(make_pair(LL, IN));
}
else{
makebooldecl(OUT, a, init, NULL);
$$->push_back(make_pair(LL, OUT));
}
}
/*
$$->iteration_init();
while($$->end() == false)
{
TYPES *ty = new TYPES($5);
$$->value().second = ty;
int init = 0;
if($7)
init = !strcmp_nocase($7->get_string(), "'1'");
if($5->grp_id() != TYPES::Array)
{
char *name = copy_string($$->value().first);
actionADT a = action(name, strlen(name));
delete [] name;
if(strcmp_nocase($4, "out") == 0)
makebooldecl(OUT, a, init, NULL);
else
makebooldecl(IN, a, init, NULL);
}
else
{
TYPELIST *index =
$5->get_list();//->value().second->get_list();
index->iteration_init();
int len = index->value().second->get_int();
index->next();
len = len - index->value().second->get_int();
int char_len = strlen($$->value().first);
char *name = 0;
for(int i = 0; i < len; i++)
{
name = new char[char_len+10];
sprintf(name, "%s__%d__+",
$$->value().first, i);
}
#ifdef DDEBUG
assert(name);
#endif
actionADT a = action(name, strlen(name));
delete [] name;
if(strcmp_nocase($4, "out") == 0)
makebooldecl(OUT, a, init, NULL);
else
makebooldecl(IN, a, init, NULL);
}
$$->next();
}*/
}
;
interface_variable_declaration
: VARIABLE identifier_list ':' subtype_indication
assign_exp
{}
| VARIABLE identifier_list ':' mode subtype_indication
assign_exp
{}
;
bus_symbol
:
| BUS
;
assign_exp
: { $$ = new TYPES; $$->set_str("'0'"); }
| ASSIGN expression
{ $$ = $2; }
;
interface_unknown_declaration
: identifier_list ':' subtype_indication bus_symbol assign_exp
{
//$3->set_obj("in");
$$ = new list<pair<string,int> >;
for(list<string>::iterator b=$1->begin(); b!=$1->end(); b++){
int init = 0;
if($5->str() == "'1'")
init = 1;
const string LL = (*b);
actionADT a = action(LL);
makebooldecl(IN, a, init, NULL);
$$->push_back(make_pair(LL, IN));
}
delete $1;
}
| identifier_list ':' mode subtype_indication
bus_symbol assign_exp
{
$$ = new list<pair<string,int> >;
list<string> *sufficies = new list<string>;
int type(IN);
string assigned($6->get_string());
delayADT myBounds;
int rise_min(0), rise_max(0), fall_min(-1), fall_max(-1);
if("init_channel" == assigned ||
"active" == assigned ||
"passive" == assigned ){
sufficies->push_back(SEND_SUFFIX);
sufficies->push_back(RECEIVE_SUFFIX);
TYPELIST arguments($6->get_list());
TYPELIST::iterator i(arguments.begin());
while(i!=arguments.end()){
if("timing"==i->second.get_string()){
if("sender"==i->first){
type |= SENT;
}
if("receiver"==i->first){
type |= RECEIVED;
}
TYPELIST bounds(i->second.get_list());
TYPELIST::iterator j(bounds.begin());
int pos(1);
while(j != bounds.end()){
string formal(j->first);
int actual(j->second.get_int());
if("rise_min"==formal || "lower"==formal ||
formal.empty() && 1==pos){
rise_min = actual;
}
else if("rise_max"==formal || "upper"==formal ||
formal.empty() && 2==pos){
rise_max = actual;
}
else if("fall_min"==formal || "lower"==formal ||
formal.empty() && 3==pos){
fall_min = actual;
}
else if("fall_max"==formal || "upper"==formal ||
formal.empty() && 4==pos){
fall_max = actual;
}
j++;
pos++;
}
}
i++;
}
if("active"==assigned){
type |= ACTIVE;
}
else if("passive"==assigned){
type |= PASSIVE;
}
}
else{
sufficies->push_back("" );
if(strcmp_nocase($3,"out")){
type = OUT;
}
}
if(fall_min<0){
fall_min = rise_min;
}
if(fall_max<0){
fall_max = rise_max;
}
assigndelays(&myBounds,
rise_min,rise_max,NULL,
fall_min,fall_max,NULL);
int init = 0;
if($6->str() == "'1'"){
init = 1;
}
for(list<string>::iterator b=$1->begin(); b!=$1->end(); b++){
$$->push_back(make_pair((*b), type));
list<string>::iterator suffix=sufficies->begin();
while ( suffix != sufficies->end() ) {
makebooldecl(type,action((*b)+*suffix),init,
&myBounds);
suffix++;
}
}
delete sufficies;
delete $1;
}
;
interface_file_declaration
: VFILE identifier_list ':' subtype_indication_list
{}
;
subtype_indication_list
: subtype_indication
{ $$= $1; }
| subtype_indication_list ',' subtype_indication
{ $$= $3; }
;
mode
: VIN { $$= "in"; }| VOUT { $$= "out"; }
| INOUT { $$= "out"; } | BUFFER {$$= "out"; }
| LINKAGE { $$= "linkage"; }
;
gen_association_list
: '(' gen_association_list_1 ')'
{
$$ = $2;
}
;
gen_association_list_1
: gen_association_element
| gen_association_list_1 ',' gen_association_element
{
$$ = $1;
$$->front().second.theExpression += ";" +
$3->front().second.theExpression;
$$->combine(*$3);
delete $3;
}
;
gen_association_element
: expression
{
$$ = new TYPELIST(make_pair(string(), *$1));
$$->front().second.theExpression = $1->theExpression;
delete $1;
}
| discrete_range1 { $$ = $1 ; }
| formal_part ARROW actual_part
{
$$ = new TYPELIST(make_pair(*$1 , *$3));
delete $1; delete $3;
}
| OPEN
{
//$$= new TYPES("uk","uk", "uk");
}
;
association_list
: association_element
{
$$ = new list<pair<string,string> >;
$$->push_back(*$1); delete $1;
}
| association_list ',' association_element
{ $$ = $1; $$->push_back(*$3); delete $3; }
;
association_element
: actual_part
{ $$ = new pair<string,string>(string(), $1->str()); delete $1; }
| formal_part ARROW actual_part
{
$$ = new pair<string,string>(*$1, $3->str());
delete $1; delete $3;
}
;
formal_part
: name { $$ = new string($1->str()); delete $1; }
;
actual_part
: expression
| OPEN { $$ = new TYPES; }
;
/* Expressions */
expression
: relation andexpr
{
$$ = $1;
$$->set_obj("exp");
$$->set_str(logic($1->str(), $2->str(), "&"));
$$->theExpression = $$->theExpression + '&' +
$2->theExpression;
delete $2;
}
| relation orexpr
{
$$ = $1;
$$->set_obj("exp");
$$->set_str(logic($1->str(), $2->str(), "|"));
$$->theExpression = $$->theExpression + '|' +
$2->theExpression;
delete $2;
}
| relation xorexpr
{
string one_bar=("~("+$1->str())+')';
string two_bar=("~("+$2->str())+')';
$$->set_obj("exp");
$$->set_str(logic(logic($1->str(), two_bar, "&"),
logic(one_bar, $2->str(), "&"), "|"));
delete $2;
//$$= new TYPES1(check_logic($1, $2, "'xor'" ));
//$$->setTers(TERSempty());
}
| relation NAND relation
{
$1->set_str(("~("+$1->str())+')');
$3->set_str(("~("+$3->str())+')');
$$->set_obj("exp");
$$->set_str(logic($1->str(), $3->str(), "|"));
delete $3;
//$$= new TYPES1(check_logic($1, $3, "'nand'"));
//$$->setTers( TERSempty());
}
| relation NOR relation
{
$1->set_str(("~("+$1->str())+')');
$3->set_str(("~("+$3->str())+')');
$$->set_obj("exp");
$$->set_str(logic($1->str(), $3->str(), "&"));
delete $3;
//$$= new TYPES1(check_logic($1, $3, "'nor'"));
//$$->setTers( TERSempty());
}
| relation XNOR relation
{
string one_bar=("~("+$1->str())+')';
string three_bar=("~("+$3->str())+')';
$$->set_obj("exp");
$$->set_str(logic(logic($1->str(), $3->str(), "&"),
logic(one_bar, three_bar, "&"), "|"));
delete $3;
/* NOTE: should $1 be deleted also??? */
//$$= new TYPES1(check_logic($1, $3, "'xnor'"));
//$$->setTers(TERSempty());
}
| relation { $$ = $1; }
;
andexpr
: andexpr AND relation
{
$$ = $1;
$$->set_obj("exp");
$$->set_str(logic($1->str(), $3->str(), "&"));
$$->theExpression = $$->theExpression + '&' +
$3->theExpression;
delete $3;
}
| AND relation
{
$$ = $2;
}
;
orexpr
: orexpr OR relation
{
$$ = $1;
$$->set_obj("exp");
$$->set_str(logic($1->str(), $3->str(), "|"));
$$->theExpression = $$->theExpression + '|' +
$3->theExpression;
delete $3;
}
| OR relation { $$ = $2; }
;
xorexpr
: xorexpr XOR relation
{
string one_bar=("~("+$1->str())+')';
string three_bar=("~("+$3->str())+')';
$$->set_obj("exp");
$$->set_str(logic(logic($1->str(), three_bar, "&"),
logic(one_bar, $3->str(), "&"), "|"));
delete $3;
//$$= new TYPES1(check_logic($1, $3, "'xor'"));
}
| XOR relation { $$ = $2; }
;
relation
: shift_expression { $$ = $1; }
| PROBE '(' target ')' {
$$ = Probe($3->str());
}
| shift_expression relational_operator shift_expression
{
pair<string,TYPES> TT1 = table->lookup($1->str());
pair<string,TYPES> TT3 = table->lookup($3->str());
/*if(TT1.first == "err" || TT3.first == "err"){
if(TT1.first == "err")
err_msg("undeclared identifier '",$1->get_string(),"'");
if(TT3.first == "err")
err_msg("undeclared identifier '",$3->get_string(),"'");
}
else*/{
$$ = new TYPES;
if (table->lookup($1->get_string()).first != "qty" &&
table->lookup($3->get_string()).first != "qty")
$$->set_data("bool");
else
$$->set_data("expr");
if(table->lookup($1->get_string()).first == "var" ||
table->lookup($3->get_string()).first == "var")
$$->set_str("maybe");
else
//$$->set_str($1->str() + $2 + $3->str());
$$->set_str(bool_relation($1->theExpression, $3->theExpression, $2));
$$->theExpression += $1->theExpression + $2 + $3->theExpression;
//cout << "@relation " << $$->theExpression << endl;
}
}
;
relational_operator
: '=' { $$ = "="; } | NEQ { $$ = "/="; } | '<' { $$ = "<"; }
| LE { $$ = "<="; } | '>' { $$ = ">"; } | GE { $$ = ">=";}
;
shift_expression
: simple_expression {$$ = $1;}
| simple_expression shift_operators simple_expression
{ /*
if( !$3->isInt() ) {
TYPES *ty= new TYPES("ERROR", "ERROR", "ERROR");
$$= new TYPES1(ty);
err_msg("expecting an integer"); }
else
$$= $1;*/
}
;
shift_operators
: SLL | SRL | SRA | SLA | ROL | ROR
;
simple_expression
: terms
| sign terms
{
$$ = $2;
$$->theExpression = $1 + $$->theExpression;
}
;
sign
: '+' {$$ = "+";} %prec MED_PRECEDENCE
| '-' {$$ = "-";} %prec MED_PRECEDENCE
;
terms
: term {$$ = $1;}
| terms adding_operator term
{
$$ = $1;
$$->theExpression = $$->theExpression + $2
+ $3->theExpression;
}
;
adding_operator
: '+' {$$ = "+";} | '-' {$$ = "-";} | '&' {$$ = "&";}
;
term
: term multiplying_operator factor
{
$$ = $1;
$$->theExpression = $$->theExpression + $2 +
$3->theExpression;
}
| factor { $$ = $1; }
;
multiplying_operator
: '*' {$$ = "*";} | '/' {$$ = "/";}
| MOD {$$ = "%";} | REM {$$ = "rem";}
;
factor
: primary
| primary EXPON primary
| ABSOLUTE primary { $$ = $2; }
| NOT primary
{
$2->set_str(("~("+$2->theExpression)+')');
$$ = $2;
$$->theExpression = "~(" + $2->theExpression + ")";
}
;
primary
: name
{
$$=$1;
if($$->get_string()=="true" || $$->get_string()=="false"){
$$->set_data("bool");
}
}
// | attribute_name { yywarning("Attributes not supported."); }
| literal
| aggregate
| qualified_expression
{ yyerror("Qualified expressions not supported."); }
| allocator
{ yyerror("Allocators not supported."); }
| '(' expression ')'
{ $$ = $2; }
;
allocator
: NEW mark allocator1 {}// $$= search(table,$2->label); }
| NEW mark mark allocator1 {}// $$= search(table,$2->label); }
| NEW qualified_expression { $$= $2; }
;
allocator1
:
| gen_association_list {}
;
qualified_expression
: mark '\'' '(' expression ')' { $$= $4; }
| mark '\'' aggregate { $$= $3; }
;
name
: mark
{
$$ = new TYPES();
$$->set_str($1->front());
$$->theExpression += $1->front();
}/*
| mark '\'' ABOVE '(' REAL ')'
{
$$ = new TYPES();
$$->set_str($1->front());
$$->theExpression += $1->front() + ">=" + numToString($5);
}
| mark '\'' ABOVE '(' '-' REAL ')'
{
$$ = new TYPES();
$$->set_str($1->front());
$$->theExpression += $1->front() + ">="
+ numToString($6 * -1);
}*/
| mark '\'' ABOVE '(' simple_expression ')'
{
$$ = new TYPES();
$$->set_str($1->front());
$$->theExpression += $1->front() + ">="
+ $5->theExpression;
}
| name2 { $$= $1; }
;
mark
: VID
{ $$ = new list<string>; $$->push_back($1->label); }
| selected_name
;
selected_name
: mark '.' suffix
{ $$ = $1; $$->push_back($3); }
;
name2
: name3 { $$= $1; }
| attribute_name { $$= $1; }
;
name3
: STRLIT
{
$$= new TYPES;
//$$->set_str(strtok($1, "\""));
//$$->theExpression += $1;
char *chptr;
chptr = strpbrk($1, "\"");
chptr = strtok(chptr+1, "\"");
$$->set_str(chptr);
$$->theExpression += chptr;
//cout << "@STRLIT " << $$->theExpression << endl;
}
| insl_name { $$= $1; }
;
suffix
: VID { $$= $1->label; }
| CHARLIT { $$ = $1; }
| STRLIT { $$= $1; }
| ALL { $$ = "all"; }
;
/* Lots of conflicts */
attribute_name
: mark '\'' idparan
{
$$ = new TYPES();
$$->set_str($1->front());
//yyerror("Attributes not supported.");
//TYPES *t=search(table,$1->label);
//$$= t; $$->setstring($1->label);
}
| name2 '\'' idparan
{
//yyerror("Attributes not supported.");
//TYPES *t=search( table, $1->name );
//$$= t;
}
| name signature '\'' idparan
{
//yyerror("Attributes not supported.");
//TYPES *t=search( table, $1->name2->label );
//$$= t;
}
;
idparan
: VID { $$= $1->label; }
| VID '(' expression_list ')'
{ $$= $1->label; }
| RANGE { $$= "range"; }
| RANGE '(' expressions ')' {}
;
expression_list
: expression {}
| expression_list ',' expression {}
;
expressions
: {}
| expressions ',' expression
;
insl_name
: mark gen_association_list
{
/*($$ = table->lookup($1->front());
if($$ == 0)
{
err_msg("'", $1->front(), "' undeclared");
$$ = new TYPES("err", "err");
}*/
$$ = new TYPES;
$$->set_list($2);
$$->set_str($1->front());
if ($1->front()=="delay") {
$$->theExpression =
"{" + $2->front().second.theExpression + "}";
} else if ($1->front()=="selection") {
// ZHEN(Done): extract the first integer of $2 and subtract 1 from it
// "uniform(0," + $2->front().second.theExpression + ")";
//$$->theExpression ="uniform(0," + intToString(atoi((($2->front().second.theExpression).substr(0,($2->front().second.theExpression).find(";")).c_str()))-1) + ")";
// "floor(uniform(0," + $2->front().second.theExpression + "))";
$$->theExpression ="floor(uniform(0," + intToString(atoi((($2->front().second.theExpression).substr(0,($2->front().second.theExpression).find(";")).c_str()))) + "))";
$$->set_str($$->theExpression);
} else if (($1->front()=="init_channel") ||
($1->front()=="active") ||
($1->front()=="passive") ||
($1->front()=="timing")) {
} else {
$$->theExpression =
"BIT(" + $1->front() + "," + $2->front().second.theExpression + ")";
$$->set_str($$->theExpression);
//cout << "$$->theExpression " << $$->theExpression << endl;
}
/*
char s[200] = {'\0'};
$2->iteration_init();
if($2->value().second->grp_id() == TYPES::Integer)
sprintf(s, "%s__%ld__", $1->front().c_str(),
$2->value().second->get_int());
$$->set_str(s);*/
}
| name3 gen_association_list
{
$$ = new TYPES($1);
//$$->formal_list= NULL;
//$$= $1;
$$->set_list($2);
}
;
literal
: INT
{
$$ = new TYPES("uk", "integer");
$$->set_grp(TYPES::Integer);
$$->set_int($1);
$$->theExpression += intToString($1);
$$->set_str($$->theExpression);
}
| REAL
{
$$= new TYPES("uk", "real");
$$->set_grp(TYPES::Real);
$$->set_flt($1);
$$->theExpression += numToString($1);
}
| BASEDLIT
{
$$ = new TYPES("uk", "integer");
$$->set_grp(TYPES::Integer);
$$->set_int($1);
$$->theExpression += intToString($1);
}
| CHARLIT
{
$$ = new TYPES("chr", "uk");
$$->set_string($1);
$$->theExpression += $1;
// cout << "@CHARLIT " << $$->theExpression << endl;
}
| BITLIT
{
$$= new TYPES("uk", "BIT_VECTOR");
$$->set_string($1);
$$->theExpression += $1;
}
| VNULL {}
| physical_literal_no_default { $$= $1; }
;
physical_literal
: VID { $$ = new TYPELIST(make_pair($1->label, TYPES())); }
| INT VID
{
TYPES t("cst", "int");
t.set_int($1);
$$ = new TYPELIST(make_pair($2->label, t));
}
| REAL VID
{
TYPES t("cst", "flt");
t.set_flt($1);
$$ = new TYPELIST(make_pair($2->label, t));
}
| BASEDLIT VID
{
TYPES t("cst", "int");
t.set_int($1);
$$ = new TYPELIST(make_pair($2->label, t));
//TYPES *temp= search(table,$2->label);
//$$= new TYPES("CONST", "uk", "uk");
}
;
physical_literal_no_default
: INT VID
{
//$$ = table->lookup($2->label);
$$ = new TYPES("cst", "int");
$$->set_int($1);
}
| REAL VID
{
$$ = new TYPES("cst", "flt");
$$->set_flt($1);
/*
TYPES *temp = table->lookup($2->label);
if(temp == NULL)
{
err_msg("'", $2->label, "' was not declared before;");
temp = new TYPES("err", "err", "err");
}
$$= new TYPES("CONST", temp->datatype(), temp->subtype());*/
}
| BASEDLIT VID
{
$$ = new TYPES("cst", "int");
$$->set_int($1);
/*
TYPES *temp = table->lookup($2->label);
if(temp == NULL)
{
err_msg("'", $2->label, "' was not declared before;");
temp = new TYPES("err", "err", "err");
}
$$= new TYPES("CONST", temp->datatype(), temp->subtype() );*/
}
;
aggregate
: '(' element_association ',' elarep ')'
{
/*if(strcmp_nocase($2->datatype(), $4->datatype())
&& !($2->isError() || $4->isError()))
{
$$= new TYPES("err","err", "err");
err_msg("wrong types between '(' and ')'");
}
else
*/
$$= $4;
}
| '(' choices ARROW expression ')'
{
//if($2->isUnknown())
$$= $4;
/*
else if(($2->datatype() == $4->datatype()) &&
!($2->isError() || $4->isError()))
$$= $2;
else
err_msg("different types on left and right sides",
"of '=>'", ";");
$$= new TYPES("err", "err", "err");
*/
}
;
elarep
: element_association
| elarep ',' element_association
/*
{
if(strcmp_nocaseyy( $1->datatype(), $3->datatype())
&& !($1->isError() || $3->isError()))
{
$$= new TYPES("err", "err", "err");
err_msg("wrong types between '(' and ')'");
}
else
$$= $1;
}
*/
;
element_association
: expression
| choices ARROW expression
{
//if($1->isUnknown())
$$= $3;
/*
else if(($1->datatype()==$3->datatype()) &&
!($1->isError() || $3->isError()))
$$= $1;
else
err_msg("different types on left and right sides",
" of '=>' ", ";");
$$= new TYPES("err", "err", "err");
*/
}
;
choices
: choices '|' choice
{
$$ = $1;
if($$ && $3->grp_id() != TYPES::Error){
if($$->back().grp_id() != $3->grp_id()){
err_msg("type mismatch");
delete $1;
$$ = 0;
}
else
$$->push_back(*$3);
}
}
| choice
{
$$ = 0;
if($1->grp_id() != TYPES::Error){
$$ = new list<TYPES>;
$$->push_back(*$1);
}
delete $1;
}
;
choice
: simple_expression { $$= $1; }
| discrete_range1 { $$ = new TYPES(); }
| OTHERS { $$= new TYPES(); $$->set_str("OTHERS"); }
;
recursive_errors
: RECURSIVE_ERROR
;
/*****************************************************************************
---CSP PARSER---
*****************************************************************************/
csp_compiler
: csp_compiler basic_module {} //*$$ = $2;*/ }
| basic_module
;
basic_module
: MODULE VID ';'
{
new_action_table($2->label);
new_event_table($2->label);
new_rule_table($2->label);
new_conflict_table($2->label);
tel_tb = new tels_table;
}
decls constructs ENDMODULE
{
map<string,int> sig_list;
if($5)
for(list<pair<string,int> >::iterator b = $5->begin();
b != $5->end(); b++)
sig_list.insert(*b);
if($6)
for(list<pair<string,int> >::iterator b = $6->begin();
b != $6->end(); b++)
if(sig_list.find(b->first) == sig_list.end())
sig_list.insert(make_pair(b->first, OUT));
tel_tb->insert(sig_list);
tel_tb->set_id($2->label);
tel_tb->set_type($2->label);
(*open_module_list)[$2->label] = make_pair(tel_tb, false);
}
| INCLUDE filename ';'
{
cur_file = *$2;
switch_buffer(*$2);
delete $2;
}
;
filename
: path_name '/' file_name
{
string f_name;
if(*$1 != "error"){
if (toTEL)
f_name = *$1 + '/' + $3 + ".hse";
else
f_name = *$1 + '/' + $3 + ".csp";
$$ = new string(f_name);
delete $1;
}
else
$$ = $1;
}
| file_name
{
string f_name;
if (toTEL)
f_name = cur_dir + '/' + string($1) + ".hse";
else
f_name = cur_dir + '/' + string($1) + ".csp";
$$ = new string(f_name);
}
;
path_name
: path_name '/' VID
{
string ss = *$1 + '/' + $3->label;
$$ = new string(ss);
}
| VID
{ $$ = new string($1->label); }
| '~'
{
char *s = getenv("HOME");
if(s)
$$ = new string(s);
else
{
err_msg("home directory not found");
$$ = new string("error");
}
}
| { $$ = &cur_dir; }
;
file_name
: VID
{ $$ = copy_string(((*name_mapping)[$1->label]).c_str()); }
| '*'
{ $$ = "*"; }
;
decls
: decls decl
{
if($1 && $2)
{
$1->splice($1->begin(), *$2);
$$ = $1;
}
else if($1)
$$ = $1;
else
$$ = $2;
}
| { $$ = 0; }
;
decl
: delaydecl
| definedecl
| booldecl
// | portdecl
;
delaydecl
: ATACS_DELAY VID '=' delay ';'
{
makedelaydecl($2,$4);
$$ = 0;
}
;
definedecl
: ATACS_DEFINE VID '=' REAL ';'
{
makedefinedecl($2,$4);
$$ = 0;
}
| ATACS_DEFINE VID '=' '-' REAL ';'
{
makedefinedecl($2,(-1.0)*$5);
$$ = 0;
}
;
booldecl
: BOOL id_list ';'
{
initial_stateADT init_st(true, false, false);
$$ = new list<pair<string,int> >;
for(list<actionADT>::iterator b = $2->begin();
b != $2->end(); b++){
(*b)->initial_state = init_st;
makebooldecl($1, *b, FALSE, NULL);
$$->push_back(make_pair((*b)->label, $1));
}
}
| BOOL id_list '=' '{' INIT '}' ';'
{
initial_stateADT init_st(true, true, false);
$$ = new list<pair<string,int> >;
for(list<actionADT>::iterator b = $2->begin();
b != $2->end(); b++) {
(*b)->initial_state = init_st;
makebooldecl($1, *b, $5, NULL);
$$->push_back(make_pair((*b)->label, $1));
}
}
| BOOL id_list '=' '{' delay '}' ';'
{
initial_stateADT init_st(true, false, true);
$$ = new list<pair<string,int> >;
for(list<actionADT>::iterator b = $2->begin();
b != $2->end(); b++)
{
(*b)->initial_state = init_st;
makebooldecl($1, *b, FALSE, &($5));
$$->push_back(make_pair((*b)->label, $1));
}
}
| BOOL id_list '=' '{' INIT ',' delay '}' ';'
{
initial_stateADT init_st(true, true, true);
$$ = new list<pair<string,int> >;
for(list<actionADT>::iterator b = $2->begin();
b != $2->end(); b++)
{
(*b)->initial_state = init_st;
makebooldecl($1, *b, $5, &($7));
$$->push_back(make_pair((*b)->label, $1));
}
}
;
id_list
: VID
{
$$ = new list<actionADT>;
$$->push_back($1);
}
| id_list ',' VID
{
$$ = $1;
$$->push_back($3);
}
;
/*portdecl
: CPORT VID ';'
{ makeportdecl($1,$2,FALSE,0,INFIN,0,INFIN,
0,INFIN,0,INFIN,1,1); }
| CPORT VID '=' '{' INIT '}' ';'
{ makeportdecl($1,$2,$5,0,INFIN,0,INFIN,
0,INFIN,0,INFIN,1,1); }
| CPORT VID '=' '{' delay ',' delay '}' ';'
{ makeportdecl($1,$2,FALSE,$5.lr,$5.ur,$5.lf,$5.uf,
$7.lr,$7.ur,$7.lf,$7.uf,1,1); }
| CPORT VID '=' '{' '(' CINT ',' CINT ')' '}' ';'
{ makeportdecl($1,$2,FALSE,0,INFIN,0,INFIN,
0,INFIN,0,INFIN,$6,$8); }
| CPORT VID '=' '{' INIT ',' delay ',' delay '}' ';'
{ makeportdecl($1,$2,$5,$7.lr,$7.ur,$7.lf,$7.uf,
$9.lr,$9.ur,$9.lf,$9.uf,1,1); }
| CPORT VID '=' '{' INIT ',' '(' CINT ',' CINT ')' '}' ';'
{ makeportdecl($1,$2,$5,0,INFIN,0,INFIN,
0,INFIN,0,INFIN,$8,$10); }
| CPORT VID '=' '{' delay ',' delay ','
'(' CINT ',' CINT ')' '}' ';'
{ makeportdecl($1,$2,FALSE,$5.lr,$5.ur,$5.lf,$5.uf,
$7.lr,$7.ur,$7.lf,$7.uf,$10,$12); }
| CPORT VID '=' '{' INIT ',' delay ',' delay ','
'(' CINT ',' CINT ')' '}' ';'
{ makeportdecl($1,$2,$5,$7.lr,$7.ur,$7.lf,$7.uf,
$9.lr,$9.ur,$9.lf,$9.uf,$12,$14);}
;
*/
delay
: '<' CINT ',' CINT ';' CINT ',' CINT '>'
{ assigndelays(&($$),$2,$4,NULL,$6,$8,NULL); }
| '<' CINT ',' CINT ',' VID '(' REAL ',' REAL ')'
';' CINT ',' CINT ',' VID '(' REAL ',' REAL ')' '>'
{ sprintf(distrib1,"%s(%g,%g)",$6->label,$8,$10);
sprintf(distrib2,"%s(%g,%g)",$17->label,$19,$21);
assigndelays(&($$),$2,$4,distrib1,$13,$15,distrib2);
}
| '<' CINT ',' CINT ',' VID '(' REAL ',' REAL ')'
';' CINT ',' CINT '>'
{ sprintf(distrib1,"%s(%g,%g)",$6->label,$8,$10);
assigndelays(&($$),$2,$4,distrib1,$13,$15,NULL);
}
| '<' CINT ',' CINT ';' CINT ',' CINT ','
VID '(' REAL ',' REAL ')' '>'
{ sprintf(distrib2,"%s(%g,%g)",$10->label,$12,$14);
assigndelays(&($$),$2,$4,NULL,$6,$8,distrib2);
}
| '<' CINT ',' CINT '>'
{ assigndelays(&($$),$2,$4,NULL,$2,$4,NULL); }
| '<' CINT ',' CINT ',' VID '(' REAL ',' REAL ')' '>'
{ sprintf(distrib1,"%s(%g,%g)",$6->label,$8,$10);
assigndelays(&($$),$2,$4,distrib1,$2,$4,distrib1); }
| VID
{ checkdelay($1->label,$1->type);
assigndelays(&($$),$1->delay.lr,$1->delay.ur,
$1->delay.distr,$1->delay.lf,
$1->delay.uf,$1->delay.distf); }
;
constructs
: constructs process
| constructs component_instances
{
if($1 && $2){
$$ = $1;
$$->splice($$->begin(), *$2);
}
else if($1)
$$ = $1;
else
$$ = $2;
}
| process { $$ = 0; }
| component_instances
;
component_instances
: VID VID '(' port_map_list ')' ';'
{
pair<tels_table*,bool> rp = (*open_module_list)[$1->label];
if(rp.first != 0){
$$ = new list<pair<string,int> >;
tels_table* rpc = new tels_table(rp.first);
rpc->set_id($2->label);
rpc->set_type($1->label);
rpc->insert(*$4);
my_list sig_mapping(rpc->portmap());
rpc->instantiate(&sig_mapping, $2->label, $1->label, true);
if(tel_tb->insert($2->label, rpc) == false)
err_msg("duplicate component label '", $2->label, "'");
const map<string,int> tmp = rpc->signals();
for(map<string,string>::iterator b = $4->begin();
b != $4->end(); b++){
if(tmp.find(b->first) != tmp.end())
$$->push_back(make_pair(b->second,
tmp.find(b->first)->second));
else
err_msg("signal '", b->first, "' not found");
}
}
else {
err_msg("module '", $1->label, "' not found");
delete $4;
return 1;
}
delete $4;
}
;
port_map_list
: port_map_list ',' formal_2_actual
{ $$ = $1; $$->insert(*$3); delete $3; }
| formal_2_actual
{ $$ = new map<string, string>; $$->insert(*$1); delete $1; }
;
formal_2_actual
: VID LARROW VID
{ $$ = new pair<string, string>($1->label, $3->label); }
;
process
: PROC VID ';' body ENDPROC
{
$$ = TERSrepeat($4,";");
if(tel_tb->insert($2->label, $$)==false){
err_msg("duplicate process label '", $2->label, "'");
delete $$;
return 1;
}
if (1) {
printf("Compiled process %s\n",$2->label);
fprintf(lg,"Compiled process %s\n",$2->label);
} else
emitters(0, $2->label, $$);
TERSdelete($$);
}
| PROC VID ';' body ':' ENDPROC
{
$$ = TERSrepeat($4,":");
if(tel_tb->insert($2->label, $$)==false){
err_msg("duplicate process label '", $2->label, "'");
delete $$;
return 1;
}
if (1) {
printf("Compiled process %s\n",$2->label);
fprintf(lg,"Compiled process %s\n",$2->label);
} else
emitters(0, $2->label, $$);
TERSdelete($$);
}
| TESTBENCH VID ';' body tail
{
$$ = TERSrepeat($4,";");
if(tel_tb->insert($2->label, $$, true)==false) {
err_msg("duplicate testbench label '", $2->label, "'");
delete $$;
return 1;
}
if (1) {
printf("Compiled testbench %s\n",$2->label);
fprintf(lg,"Compiled testbench %s\n",$2->label);
} else
emitters(outpath, $2->label, $$);
TERSdelete($$);
}
| TESTBENCH VID ';' body ':' tail
{
$$ = TERSrepeat($4,":");
if(tel_tb->insert($2->label, $$, true)==false) {
err_msg("duplicate testbench label '", $2->label, "'");
delete $$;
return 1;
}
if (1) {
printf("Compiled testbench %s\n",$2->label);
fprintf(lg,"Compiled testbench %s\n",$2->label);
} else
emitters(outpath, $2->label, $$);
TERSdelete($$);
}
| GATE VID ';' prs ENDGATE
{
$$ = TERSrepeat($4,";");
if(tel_tb->insert($2->label, $$)==false) {
err_msg("duplicate gate label '", $2->label, "'");
delete $$;
return 1;
}
if (1) {
printf("Compiled gate %s\n",$2->label);
fprintf(lg,"Compiled gate %s\n",$2->label);
} else
emitters(outpath, $2->label, $$);
TERSdelete($$);
}
| CONSTRAINT VID ';' constraint ENDCONSTRAINT
{
$$ = TERSrepeat($4,";");
if(tel_tb->insert($2->label, $$)==false) {
err_msg("duplicate constant label '", $2->label, "'");
delete $$;
return 1;
}
TERSmarkord($$);
if (1) {
printf("Compiled constraint %s\n",$2->label);
fprintf(lg,"Compiled constraint %s\n",$2->label);
} else
emitters(outpath, $2->label, $$);
TERSdelete($$);
}
| ASSUMP VID ';' body ENDASSUMP
{
$$ = TERSrepeat($4,";");
if(tel_tb->insert($2->label, $$)==false) {
err_msg("duplicate assumption label '", $2->label, "'");
delete $$;
return 1;
}
TERSmarkassump($$);
if (1) {
printf("Compiled assumption %s\n",$2->label);
fprintf(lg,"Compiled assumption %s\n",$2->label);
} else
emitters(outpath, $2->label, $$);
TERSdelete($$);
}
;
tail
: ENDTB | END
;
prs
: levelexpr ARROW ACTION levelexpr ARROW ACTION
{
$3->vacuous=FALSE;
$6->vacuous=FALSE;
string ss1 = '[' + *$1 + ']' + 'd';
$$ = TERS($3, FALSE,$3->lower,$3->upper,FALSE,
ss1.c_str(), $3->dist);
string ss2 = '[' + *$4 + ']' + 'd';
if ((!($3->initial) && !(strchr($3->label,'+'))) ||
($3->initial && strchr($3->label,'+'))) {
$$ = TERScompose(TERS($6, FALSE,$6->lower,$6->upper,
FALSE,ss2.c_str(),$6->dist),$$,";");
} else {
$$ = TERScompose($$,TERS($6, FALSE,$6->lower,$6->upper,
FALSE,ss2.c_str(),$6->dist),";");
}
$$ = TERSmakeloop($$);
delete $1;
delete $4;
}
| leakyexprs ARROW ACTION leakyexprs ARROW ACTION
{
$3->vacuous=FALSE;
$6->vacuous=FALSE;
$$ = TERScompose($1,TERS($3, FALSE,$3->lower,$3->upper,
FALSE,"[true]",$3->dist),";");
$$ = TERScompose($$,TERSrename($$,$4),";");
$$ = TERScompose($$,TERS($6, FALSE,$6->lower,$6->upper,
FALSE,"[true]",$6->dist),";");
$$ = TERSmakeloop($$);
}
;
leakyexprs : leakyexprs '|' leakyexpr
{ $$ = TERScompose($1, TERSrename($1,$3),"|"); }
| leakyexpr
;
leakyexpr : levelexpr '(' sing_dist ')'
{
$$ = Guard(*$1);
delete $1;
TERSmodifydist($$,$3);
}
;
constraint
: levelexpr ARROW ACTION
{
$3->vacuous=FALSE;
string ss1 = '[' + *$1 + ']';// + 'd';
$$ = TERS($3,FALSE,0,INFIN,FALSE,ss1.c_str(),$3->dist);
//$$ = TERScompose($$,TERS($6, FALSE,$6->lower,$6->upper,
// FALSE, Cstr, $6->dist),";");
$$ = TERSmakeloop($$);
delete $1;
}
| levelexpr ARROW '<' CINT ',' CINT '>' ACTION
{
$8->vacuous=FALSE;
string ss1 = '[' + *$1 + ']';// + 'd';
$$ = TERS($8,FALSE,$4,$6,FALSE,ss1.c_str(),$8->dist);
//$$ = TERScompose($$,TERS($6, FALSE,$6->lower,$6->upper,
// FALSE, Cstr, $6->dist),";");
$$ = TERSmakeloop($$);
delete $1;
}
| ACTION ARROW or_constraint
{
$1->vacuous=FALSE;
$$ = TERS($1,FALSE,0,INFIN,FALSE,"[true]",$1->dist);
$$ = TERScompose($$,$3,";");
//$$ = TERSmakeloop($$);
}
| ACTION '@' ARROW or_constraint
{
$1->vacuous=TRUE;
$$ = TERS($1,FALSE,0,INFIN,FALSE,"[true]",$1->dist);
$$ = TERScompose($$,$4,";");
//$$ = TERSmakeloop($$);
}
;
or_constraint
: or_constraint '|' and_constraint
{ $$ = TERScompose($1,TERSrename($1,$3),"#"); }
| and_constraint
;
and_constraint
: and_constraint '&' action
{ $$ = TERScompose($1,$3,"||"); }
| action
;
action
: ACTION
{ $1->vacuous=FALSE;
$$ = TERS($1, FALSE, $1->lower, $1->upper, FALSE,
"[true]",$1->dist);
}
| VID
{
$$ = TERS(make_dummy($1->label),FALSE,$1->lower,$1->upper,
FALSE,"[true]",$1->dist);
}
| '<' CINT ',' CINT '>' ACTION
{ $6->vacuous=FALSE;
$$ = TERS($6, FALSE, $2, $4, FALSE); }
| skip
;
skip
: SKIP { $$ = TERSempty(); }//TERS(dummyE(), FALSE, 0, 0, FALSE); }
;
body
: body '|' body
{ $$ = TERScompose($1, TERSrename($1,$3), "|"); }
| body ';' body
{ $$ = TERScompose($1, TERSrename($1,$3), ";"); }
| body ':' body
{ $$ = TERScompose($1, TERSrename($1,$3), ":"); }
| body PARA body
{ $$ = TERScompose($1, $3, "||"); }
| '(' body ')' { $$ = $2; }
| action
| guardstruct
;
guardstruct
: '[' guardcmdset ']' { $$=$2; $$ = TERSrepeat($$,";"); }
| '[' expr ']' { $$ = $2; }
| '*' '[' body ']' { $$=TERSmakeloop($3); }
;
guardcmdset
: guardcmdset '|' guardcmd
{ $$ = TERScompose($1, TERSrename($1,$3),"|"); }
| guardcmd
;
guardcmd
: expr ARROW body
{ $$ = TERScompose($1, TERSrename($1,$3),";"); }
| expr ARROW body ';' '*'
{
$$ = TERScompose($1, TERSrename($1,$3),";");
$$ = TERSmakeloop($$);
}
| expr '(' sing_dist ')' ARROW body
{
TERSmodifydist($1,$3);
$$ = TERScompose($1, TERSrename($1,$6),";");
}
| expr '(' sing_dist ')' ARROW body ';' '*'
{
TERSmodifydist($1,$3);
$$ = TERScompose($1, TERSrename($1,$6),";");
$$ = TERSmakeloop($$);
}
| expr ARROW ':' body
{ $$ = TERScompose($1, TERSrename($1,$4),":"); }
| expr ARROW ':' body ';' '*'
{
$$ = TERScompose($1, TERSrename($1,$4),":");
$$ = TERSmakeloop($$);
}
| expr '(' sing_dist ')' ARROW ':' body
{
TERSmodifydist($1,$3);
$$ = TERScompose($1, TERSrename($1,$7),":");
}
| expr '(' sing_dist ')' ARROW ':' body ';' '*'
{
TERSmodifydist($1,$3);
$$ = TERScompose($1, TERSrename($1,$7),":");
$$ = TERSmakeloop($$);
}
;
/*
sing_dist : REAL { $$ = $1; }
| REAL '*' CINT { $$ = $1 * $3; }
| REAL '*' VID
{ checkdefine($3->label,$3->type);
$$ = $1 * $3->real_def; }
| REAL '/' CINT { $$ = $1 / $3; }
| REAL '/' VID
{ checkdefine($3->label,$3->type);
$$ = $1 / $3->real_def; }
;
*/
sing_dist : REAL { $$ = $1; }
| CINT { $$ = (double)$1; }
| VID
{ checkdefine($1->label,$1->type);
$$ = $1->real_def; }
| SUM '(' sing_dist ',' sing_dist ')' { $$ = $3+$5; }
| DIFF '(' sing_dist ',' sing_dist ')' { $$ = $3-$5; }
| sing_dist '*' REAL { $$ = $1 * $3; }
| sing_dist '*' CINT { $$ = $1 * $3; }
| sing_dist '*' VID
{ checkdefine($3->label,$3->type);
$$ = $1 * $3->real_def; }
| sing_dist '*' SUM '(' sing_dist ',' sing_dist ')'
{ $$ = $1*($5+$7); }
| sing_dist '*' DIFF '(' sing_dist ',' sing_dist ')'
{ $$ = $1*($5-$7); }
| sing_dist '/' REAL { $$ = $1 / $3; }
| sing_dist '/' CINT { $$ = $1 / $3; }
| sing_dist '/' VID
{ checkdefine($3->label,$3->type);
$$ = $1 / $3->real_def; }
| sing_dist '/' SUM '(' sing_dist ',' sing_dist ')'
{ $$ = $1/($5+$7); }
| sing_dist '/' DIFF '(' sing_dist ',' sing_dist ')'
{ $$ = $1/($5-$7); }
;
expr
: actionexpr
| levelexpr
{
$$ = Guard(*$1);
delete $1;
}
| '<' CINT ',' CINT '>' levelexpr
{
//char *t = new char[strlen($6) + 3];
//sprintf(t, "[%s]", $6);
string ss = '[' + *$6 + ']';
$$ = TERS(dummyE(), FALSE, $2, $4, FALSE, ss.c_str());
delete $6;
}
;
actionexpr
: actionexpr '|' conjunct
{ $$ = TERScompose($1,TERSrename($1,$3),"#"); }
| conjunct
;
levelexpr
: levelexpr '|' levelconjunct
{
string ss = *$1 + '|' + *$3;
$$ = $$ = new string(ss);
delete $3;
}
| levelconjunct
;
levelconjunct
: levelconjunct '&' leveliteral
{
string ss = *$1 + '&' + *$3;
$$ = new string(ss);
delete $3;
}
| leveliteral
;
leveliteral
: VID { $$ = new string($1->label); }
| '~' VID
{
string ss = '~' + string($2->label);
$$ = new string(ss);
}
| '(' levelexpr ')'
{
string ss = '(' + *$2 + ')';
$$ = new string( ss );
}
| '~' '(' levelexpr ')'
{
string ss = '(' + *$3 + ')';
ss = '~' + ss;
$$ = new string( ss );
}
| INIT
{
if($1 == TRUE)
$$ = new string("true");
else
$$ = new string("false");
}
;
conjunct
: conjunct '&' csp_literal
{ $$ = TERScompose($1,$3,"||"); }
| csp_literal
;
csp_literal
: ACTION
{
$1->vacuous=FALSE;
$$ = TERS($1,TRUE,$1->lower,$1->upper,FALSE,"[true]",
$1->dist);
}
| ACTION '/' CINT
{
$1->vacuous=FALSE;
$$ = TERS($1,TRUE,$1->lower,$1->upper,FALSE,"[true]",
$1->dist,$3);
}
| ACTION '@'
{ $1->vacuous=TRUE;
$$ = TERS($1,TRUE,$1->lower,$1->upper,FALSE,"[true]",
$1->dist); }
/*
| ACTION '#'
{ $$ = probe($1,0); }
| ACTION '(' CINT ')' '#'
{ $$ = probe($1,$3); }
*/
| '(' actionexpr ')'
{ $$ = $2; }
| skip
;
%%
int yyerror(char* S)
{
printf("%s\n",S);
fprintf(lg,"%s\n",S);
printf("%s: %d: syntax error.\n", file_scope1, linenumber);
fprintf(lg,"%s: %d: syntax error.\n", file_scope1, linenumber);
clean_buffer();
compiled=FALSE;
return 1;
}
int yywarning(char* S)
{
printf("%s\n",S);
fprintf(lg,"%s\n",S);
//printf("%s: %d: syntax error.\n", file_scope1, linenumber);
//fprintf(lg,"%s: %d: syntax error.\n", file_scope1, linenumber);
//clean_buffer();
//compiled=FALSE;
return 0;
}
void constructor()
{
//table = new SymTab;
PSC = 0;
}
void destructor()
{
//delete table;
clean_buffer();
}
actionADT make_dummy(char *name)
{
char s[1000]; //= string("$") + (int)PSC + '+';
sprintf(s, "$%s",name);
actionADT a = action(s, strlen(s));
a->type = DUMMY;
return a;
}
actionADT dummyE()
{
char s[1000]; //= string("$") + (int)PSC + '+';
sprintf(s, "$%ld+", PSC);
actionADT a = action(s, strlen(s));
a->type = DUMMY;
PSC++;
return a;
}
//Converts an double into a string
//An int string for now
string numToString(double num) {
char cnumber[50];
sprintf(cnumber, "%d", (int)num);
string toReturn = cnumber;
return toReturn;
}
//Converts an double into a string
//An int string for now
string intToString(int num) {
char cnumber[50];
sprintf(cnumber, "%i", (int)num);
string toReturn = cnumber;
return toReturn;
}
// Create a timed event-rule structure for an guard.
TERstructADT Guard(const string & expression){
string bracketed('[' + expression + ']');
return TERS(dummyE(),FALSE,0,0,FALSE,bracketed.c_str());
}
TERstructADT Assign(const string & expression) {
string angled('<' + expression + '>');
return TERS(dummyE(),FALSE,0,0,FALSE,angled.c_str());
}
// Create a timed event-rule structure for an guarded action.
TERstructADT Guard(const string & expression,
actionADT target,
const string&data=""){
string bracketed('[' + expression + ']');
return TERS(target,FALSE,target->lower,target->upper,FALSE,
bracketed.c_str(),NULL,-1,data);
}
TERstructADT FourPhase(const string & channel, const string & data){
string req(channel+reqSuffix);//channel_send for send,channel_rcv for receive
string ack(channel+ackSuffix);//channel_rcv for send,channel_send for receive
TERstructADT result(TERS(++req,FALSE,(++req)->lower,(++req)->upper,FALSE,
"[true]",NULL,-1,data));
result = TERScompose(result, Guard( ack,--req,data),";");
result = TERScompose(result, Guard('~'+ack, join ),";");
int antiType((SENT|RECEIVED)^direction);
map<string,int>& ports = tel_tb->port_decl();
if(signals[cur_entity].find(channel) == signals[cur_entity].end()){
if(ports.find(channel) == ports.end()){
err_msg("Undeclared channel ", channel);
}
else{
if(ports[channel] & antiType){
err_msg("send and receive on the same side of channel ", channel);
}
ports[channel] |= direction;
}
}
else{
if(signals[cur_entity][channel] & direction){
if(direction & SENT){
err_msg("Attempt to send on both sides of channel ", channel);
}
else{
err_msg("Attempt to receive on both sides of channel ", channel);
}
}
if(processChannels.find(channel)==processChannels.end()){
processChannels[channel]=direction;
}
else{
if(processChannels[channel] & antiType){
err_msg("send and receive on the same side of channel ", channel);
}
processChannels[channel] |= direction;
}
}
return result;
}
TYPES * Probe(const string & channel){
map<string,int>& ports(tel_tb->port_decl());
if(ports.find(channel)==ports.end()){
if(signals[cur_entity].find(channel)==
signals[cur_entity].end()){
err_msg("Probing undeclared channel ", channel);
}
if(signals[cur_entity][channel]&PASSIVE){
err_msg("Channel ", channel, " is probed on both sides!");
}
processChannels[channel] |= PASSIVE;
signals[cur_entity][channel] |= PASSIVE;
}
else{
if(ports[channel] & ACTIVE){
err_msg("Attempt to probe active channel ", channel);
}
ports[channel] |= PASSIVE;
}
TYPES * result = new TYPES;
result->set_obj("exp");
result->set_str(logic(channel+SEND_SUFFIX, channel+RECEIVE_SUFFIX, "|"));
result->set_data("bool");
return result;
}
actionADT operator++(const string & name){
actionADT rise(action(name+"+"));
rise->type &= ~IN;
rise->type |= OUT;
return rise;
}
actionADT operator--(const string & name){
actionADT fall(action(name+"-"));
fall->type &= ~IN;
fall->type |= OUT;
return fall;
}
void declare(list<pair<string,int> >* ports){
if(ports){
map<string,int> tmp(ports->begin(), ports->end());
tel_tb->insert(tmp);
tel_tb->insert(*ports);
for(map<string,int>::iterator b = tmp.begin(); b != tmp.end(); b++){
if(b->second & IN){
table->insert(b->first, make_pair((string)"in",(TYPES*)0));
}
else{
table->insert(b->first, make_pair((string)"out",(TYPES*)0));
}
}
delete ports;
}
}
TERstructADT signalAssignment(TYPES* target, TYPES* waveform){
string temp;
if(waveform->get_string() == "'1'")
temp = target->get_string() + '+';
else if(waveform->get_string() == "'0'")
temp = target->get_string() + '-';
else
temp = '$';// + target->get_string(); //"error";
int l = 0, u = INFIN;
const TYPELIST *tl = waveform->get_list();
if(tl != 0){
TYPELIST::const_iterator I = tl->begin();
if(I != tl->end()) {
l = tl->front().second.get_int();
I++;
if(I!=tl->end())
u = tl->back().second.get_int();
}
}
actionADT a;
if (temp[0] == '$') {
a = dummyE();
//a->type = DUMMY;
// cout << "target = " << target->get_string() << " waveform = " << waveform->get_string() << endl;
// ZHEN(Done): add assignment to action "a" of (target->get_string(),waveform->get_string())
// a->list_assigns= NULL;
if (target->get_string().c_str()!=NULL && waveform->get_string().c_str()!=NULL){
a->list_assigns = addAssign(a->list_assigns, target->get_string(), waveform->get_string());
}
} else {
a = action(temp);
}
TERstructADT result(TERS(a, FALSE, l, u, TRUE));
delete_event_set(result->last);
result->last = 0;
return result;
}
|
%{
/*
* ISC License
*
* Copyright (C) 1993-2018 by
* <NAME>
* <NAME>
* Delft University of Technology
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Edif 2.0.0 parser (level 0), based on the parser by <<EMAIL>>
*/
#include "src/ocean/esea/cedif.h"
#include "src/ocean/libseadif/sea_decl.h"
/*
* global variables that are local to the parser:
*/
static LIBRARYPTR current_library;
static FUNCTIONPTR current_function;
static CIRCUITPTR current_circuit;
static STATUSPTR current_status;
static seadifViewType current_viewtype;
static STRING current_viewtype_string = NULL;
static INSTANCE_TPTR current_instance;
static NETPTR current_net;
static CIRPORTREFPTR current_joined;
static CIRPORTREFPTR current_cirportref;
%}
%union {
char *str;
STATUSPTR status;
int integer;
time_t time;
LIBRARYPTR library;
FUNCTIONPTR function;
CIRCUITPTR circuit;
seadifViewType viewtype;
INSTANCE_TPTR instance;
CIRINSTPTR cirinst;
NETPTR net;
CIRPORTREFPTR cpref;
}
%token <integer> INT
%token <str> STR
%token ANGLE
%token BEHAVIOR
%token CALCULATED
%token CAPACITANCE
%token CENTERCENTER
%token CENTERLEFT
%token CENTERRIGHT
%token CHARGE
%token CONDUCTANCE
%token CURRENT
%token DISTANCE
%token DOCUMENT
%token ENERGY
%token EXTEND
%token FLUX
%token FREQUENCY
%token GENERIC
%token GRAPHIC
%token INDUCTANCE
%token INOUT
%token INPUT
%token LOGICMODEL
%token LOWERCENTER
%token LOWERLEFT
%token LOWERRIGHT
%token MASKLAYOUT
%token MASS
%token MEASURED
%token MX
%token MXR90
%token MY
%token MYR90
%token NETLIST
%token OUTPUT
%token PCBLAYOUT
%token POWER
%token R0
%token R180
%token R270
%token R90
%token REQUIRED
%token RESISTANCE
%token RIPPER
%token ROUND
%token SCHEMATIC
%token STRANGER
%token SYMBOLIC
%token TEMPERATURE
%token TIE
%token TIME
%token TRUNCATE
%token UPPERCENTER
%token UPPERLEFT
%token UPPERRIGHT
%token VOLTAGE
%token ACLOAD
%token AFTER
%token ANNOTATE
%token APPLY
%token ARC
%token ARRAY
%token ARRAYMACRO
%token ARRAYRELATEDINFO
%token ARRAYSITE
%token ATLEAST
%token ATMOST
%token AUTHOR
%token BASEARRAY
%token BECOMES
%token BETWEEN
%token BOOLEAN
%token BOOLEANDISPLAY
%token BOOLEANMAP
%token BORDERPATTERN
%token BORDERWIDTH
%token BOUNDINGBOX
%token CELL
%token CELLREF
%token CELLTYPE
%token CHANGE
%token CIRCLE
%token COLOR
%token COMMENT
%token COMMENTGRAPHICS
%token COMPOUND
%token CONNECTLOCATION
%token CONTENTS
%token CORNERTYPE
%token CRITICALITY
%token CURRENTMAP
%token CURVE
%token CYCLE
%token DATAORIGIN
%token DCFANINLOAD
%token DCFANOUTLOAD
%token DC<PASSWORD>FANIN
%token DCMAXFANOUT
%token DELAY
%token DELTA
%token DERIVATION
%token DESIGN
%token DESIGNATOR
%token DIFFERENCE
%token DIRECTION
%token DISPLAY
%token DOMINATES
%token DOT
%token DURATION
%token E_TOK
%token EDIF
%token EDIFLEVEL
%token EDIFVERSION
%token ENCLOSUREDISTANCE
%token ENDTYPE
%token ENTRY
%token EVENT
%token EXACTLY
%token EXTERNAL
%token FABRICATE
%token FALSE
%token FIGURE
%token FIGUREAREA
%token FIGUREGROUP
%token FIGUREGROUPOBJECT
%token FIGUREGROUPOVERRIDE
%token FIGUREGROUPREF
%token FIGUREPERIMETER
%token FIGUREWIDTH
%token FILLPATTERN
%token FOLLOW
%token FORBIDDENEVENT
%token GLOBALPORTREF
%token GREATERTHAN
%token GRIDMAP
%token IGNORE
%token INCLUDEFIGUREGROUP
%token INITIAL_TOK
%token INSTANCE
%token INSTANCEBACKANNOTATE
%token INSTANCEGROUP
%token INSTANCEMAP
%token INSTANCEREF
%token INTEGER
%token INTEGERDISPLAY
%token INTERFACE
%token INTERFIGUREGROUPSPACING
%token INTERSECTION
%token INTRAFIGUREGROUPSPACING
%token INVERSE
%token ISOLATED
%token JOINED
%token JUSTIFY
%token KEYWORDDISPLAY
%token KEYWORDLEVEL
%token KEYWORDMAP
%token LESSTHAN
%token LIBRARY_TOK
%token LIBRARYREF
%token LISTOFNETS
%token LISTOFPORTS
%token LOADDELAY
%token LOGICASSIGN
%token LOGICINPUT
%token LOGICLIST
%token LOGICMAPINPUT
%token LOGICMAPOUTPUT
%token LOGICONEOF
%token LOGICOUTPUT
%token LOGICPORT
%token LOGICREF
%token LOGICVALUE
%token LOGICWAVEFORM
%token MAINTAIN
%token MATCH
%token MEMBER
%token MINOMAX
%token MINOMAXDISPLAY
%token MNM
%token MULTIPLEVALUESET
%token MUSTJOIN
%token NAME
%token NET_TOK
%token NETBACKANNOTATE
%token NETBUNDLE
%token NETDELAY
%token NETGROUP
%token NETMAP
%token NETREF_TOK
%token NOCHANGE
%token NONPERMUTABLE
%token NOTALLOWED
%token NOTCHSPACING
%token NUMBER
%token NUMBERDEFINITION
%token NUMBERDISPLAY
%token OFFPAGECONNECTOR
%token OFFSETEVENT
%token OPENSHAPE
%token ORIENTATION
%token ORIGIN
%token OVERHANGDISTANCE
%token OVERLAPDISTANCE
%token OVERSIZE
%token OWNER
%token PAGE
%token PAGESIZE
%token PARAMETER
%token PARAMETERASSIGN
%token PARAMETERDISPLAY
%token PATH
%token PATHDELAY
%token PATHWIDTH
%token PERMUTABLE
%token PHYSICALDESIGNRULE
%token PLUG
%token POINT
%token POINTDISPLAY
%token POINTLIST
%token POLYGON
%token PORT
%token PORTBACKANNOTATE
%token PORTBUNDLE
%token PORTDELAY
%token PORTGROUP
%token PORTIMPLEMENTATION
%token PORTINSTANCE
%token PORTLIST
%token PORTLISTALIAS
%token PORTMAP
%token PORTREF
%token PROGRAM
%token PROPERTY
%token PROPERTYDISPLAY
%token PROTECTIONFRAME
%token PT
%token RANGEVECTOR
%token RECTANGLE
%token RECTANGLESIZE
%token RENAME
%token RESOLVES
%token SCALE
%token SCALEX
%token SCALEY
%token SECTION
%token SHAPE
%token SIMULATE
%token SIMULATIONINFO
%token SINGLEVALUESET
%token SITE
%token SOCKET
%token SOCKETSET
%token STATUS_TOK
%token STEADY
%token STRING_TOK
%token STRINGDISPLAY
%token STRONG
%token SYMBOL
%token SYMMETRY
%token TABLE
%token TABLEDEFAULT
%token TECHNOLOGY
%token TEXTHEIGHT
%token TIMEINTERVAL
%token TIMESTAMP
%token TIMING_TOK
%token TRANSFORM
%token TRANSITION
%token TRIGGER
%token TRUE_TOK
%token UNCONSTRAINED
%token UNDEFINED
%token UNION
%token UNIT
%token UNUSED
%token USERDATA
%token VERSION
%token VIEW
%token VIEWLIST
%token VIEWMAP
%token VIEWREF
%token VIEWTYPE
%token VISIBLE
%token VOLTAGEMAP
%token WAVEVALUE
%token WEAK
%token WEAKJOINED
%token WHEN
%token WRITTEN
%token LBR
%token RBR
%type <str> NameDef LibNameDef Ident Name _Name Rename __Rename
EdifFileName CellNameDef CellNameRef FigGrpNameDef
InstNameDef KeywordName LayerNameDef LogicNameDef NameRef
NetNameDef PortNameDef PropNameDef RuleNameDef ValueNameDef
ViewNameDef Str Author Program _PortRef InstanceRef
InstNameRef LibNameRef PortNameRef
%type <status> Status
%type <integer> Int
%type <time> TimeStamp
%type <library> Library External
%type <function> Cell
%type <viewtype> ViewType _ViewType View
%type <instance> Instance
%type <cpref> Joined
%type <net> Net
%start Edif
%%
Edif : LBR EDIF EdifFileName EdifVersion EdifLevel KeywordMap
{
edif_source.filename = $3;
edif_source.library = NULL;
edif_source.status = NULL;
}
_Edif RBR
;
_Edif :
| _Edif Status { edif_source.status = $2; }
| _Edif External
{
if (externalBehavesLikeLibrary)
{
LIBRARYPTR last_library = edif_source.library;
while (last_library && last_library->next)
last_library = last_library->next;
if (last_library)
last_library->next = $2;
else
edif_source.library = $2;
}
}
| _Edif Library
{
LIBRARYPTR last_library = edif_source.library;
while (last_library && last_library->next)
last_library = last_library->next;
if (last_library)
last_library->next = $2;
else
edif_source.library = $2;
}
| _Edif Design
| _Edif Comment
| _Edif UserData
;
EdifFileName : NameDef { $<str>$ = $1; }
;
EdifLevel : LBR EDIFLEVEL Int RBR
;
EdifVersion : LBR EDIFVERSION Int Int Int RBR
;
AcLoad : LBR ACLOAD _AcLoad RBR
;
_AcLoad : MiNoMaValue
| MiNoMaDisp
;
After : LBR AFTER _After RBR
;
_After : MiNoMaValue
| _After Follow
| _After Maintain
| _After LogicAssn
| _After Comment
| _After UserData
;
Annotate : LBR ANNOTATE _Annotate RBR
;
_Annotate : Str {;}
| StrDisplay {;}
;
Apply : LBR APPLY _Apply RBR
;
_Apply : Cycle
| _Apply LogicIn
| _Apply LogicOut
| _Apply Comment
| _Apply UserData
;
Arc : LBR ARC PointValue PointValue PointValue RBR
;
Array : LBR ARRAY NameDef Int _Array RBR
;
_Array :
| Int {;}
;
ArrayMacro : LBR ARRAYMACRO Plug RBR
;
ArrayRelInfo : LBR ARRAYRELATEDINFO _ArrayRelInfo RBR
;
_ArrayRelInfo : BaseArray
| ArraySite
| ArrayMacro
| _ArrayRelInfo Comment
| _ArrayRelInfo UserData
;
ArraySite : LBR ARRAYSITE Socket RBR
;
AtLeast : LBR ATLEAST ScaledInt RBR
;
AtMost : LBR ATMOST ScaledInt RBR
;
Author : LBR AUTHOR Str RBR { $<str>$ = $3; }
;
BaseArray : LBR BASEARRAY RBR
;
Becomes : LBR BECOMES _Becomes RBR
;
_Becomes : LogicNameRef
| LogicList
| LogicOneOf
;
Between : LBR BETWEEN __Between _Between RBR
;
__Between : AtLeast
| GreaterThan
;
_Between : AtMost
| LessThan
;
Boolean : LBR BOOLEAN _Boolean RBR
;
_Boolean :
| _Boolean BooleanValue
| _Boolean BooleanDisp
| _Boolean Boolean
;
BooleanDisp : LBR BOOLEANDISPLAY _BooleanDisp RBR
;
_BooleanDisp : BooleanValue
| _BooleanDisp Display
;
BooleanMap : LBR BOOLEANMAP BooleanValue RBR
;
BooleanValue : True
| False
;
BorderPat : LBR BORDERPATTERN Int Int Boolean RBR
;
BorderWidth : LBR BORDERWIDTH Int RBR
;
BoundBox : LBR BOUNDINGBOX Rectangle RBR
;
Cell : LBR CELL CellNameDef
{
NewFunction(current_function);
current_function->name = $3;
}
_Cell RBR
{
$<function>$ = current_function;
}
;
_Cell : CellType
| _Cell Status { current_function->status = $2; }
| _Cell ViewMap
| _Cell View
{
switch($2)
{
case SeadifCircuitView:
current_circuit->name = cs(current_function->name);
current_circuit->function = current_function;
current_function->circuit = current_circuit;
break;
default:
break;
}
}
| _Cell Comment
| _Cell UserData
| _Cell Property
;
CellNameDef : NameDef { $<str>$ = $1; }
;
CellRef : LBR CELLREF CellNameRef
{
if (current_instance)
current_instance->cell_ref = $3;
}
_CellRef RBR
;
_CellRef :
/* empty, that is: no library specified */
{
if (current_instance)
current_instance->library_ref = cs(current_library->name);
}
| LibraryRef
;
CellNameRef : NameRef { $<str>$ = $1; }
;
CellType : LBR CELLTYPE _CellType RBR
;
_CellType : TIE
| RIPPER
| GENERIC
;
Change : LBR CHANGE __Change _Change RBR
;
__Change : PortNameRef {;}
| PortRef {;}
| PortList
;
_Change :
| Becomes
| Transition
;
Circle : LBR CIRCLE PointValue PointValue _Circle RBR
;
_Circle :
| _Circle Property
;
Color : LBR COLOR ScaledInt ScaledInt ScaledInt RBR
;
Comment : LBR COMMENT _Comment RBR
;
_Comment :
| _Comment Str
;
CommGraph : LBR COMMENTGRAPHICS _CommGraph RBR
;
_CommGraph :
| _CommGraph Annotate
| _CommGraph Figure
| _CommGraph Instance
| _CommGraph BoundBox
| _CommGraph Property
| _CommGraph Comment
| _CommGraph UserData
;
Compound : LBR COMPOUND LogicNameRef RBR
;
Contents : LBR CONTENTS _Contents RBR
;
_Contents :
| _Contents Instance
{
CIRINSTPTR cinst;
switch (current_viewtype)
{
case SeadifCircuitView:
NewCirinst(cinst);
cinst->name = ($2)->instance_name;
($2)->instance_name = NULL;
cinst->circuit = (CIRCUITPTR) $2; /* __HACK__ */
cinst->curcirc = current_circuit;
cinst->next = current_circuit->cirinst;
current_circuit->cirinst = cinst;
break;
default:
break;
}
}
| _Contents OffPageConn
| _Contents Figure
| _Contents Section
| _Contents Net
{
switch (current_viewtype)
{
case SeadifCircuitView:
($2)->next = current_circuit->netlist;
current_circuit->netlist = $2;
break;
default:
break;
}
}
| _Contents NetBundle
| _Contents Page
| _Contents CommGraph
| _Contents PortImpl
| _Contents Timing
| _Contents Simulate
| _Contents When
| _Contents Follow
| _Contents LogicPort
| _Contents BoundBox
| _Contents Comment
| _Contents UserData
;
ConnectLoc : LBR CONNECTLOCATION _ConnectLoc RBR
;
_ConnectLoc :
| Figure
;
CornerType : LBR CORNERTYPE _CornerType RBR
;
_CornerType : EXTEND
| ROUND
| TRUNCATE
;
Criticality : LBR CRITICALITY _Criticality RBR
;
_Criticality : Int {;}
| IntDisplay {;}
;
CurrentMap : LBR CURRENTMAP MiNoMaValue RBR
;
Curve : LBR CURVE _Curve RBR
;
_Curve :
| _Curve Arc
| _Curve PointValue
;
Cycle : LBR CYCLE Int _Cycle RBR
;
_Cycle :
| Duration
;
DataOrigin : LBR DATAORIGIN Str _DataOrigin RBR
;
_DataOrigin :
| Version
;
DcFanInLoad : LBR DCFANINLOAD _DcFanInLoad RBR
;
_DcFanInLoad : ScaledInt
| NumbDisplay
;
DcFanOutLoad : LBR DCFANOUTLOAD _DcFanOutLoad RBR
;
_DcFanOutLoad : ScaledInt
| NumbDisplay
;
DcMaxFanIn : LBR DCMAXFANIN _DcMaxFanIn RBR
;
_DcMaxFanIn : ScaledInt
| NumbDisplay
;
DcMaxFanOut : LBR DCMAXFANOUT _DcMaxFanOut RBR
;
_DcMaxFanOut : ScaledInt
| NumbDisplay
;
Delay : LBR DELAY _Delay RBR
;
_Delay : MiNoMaValue
| MiNoMaDisp
;
Delta : LBR DELTA _Delta RBR
;
_Delta :
| _Delta PointValue
;
Derivation : LBR DERIVATION _Derivation RBR
;
_Derivation : CALCULATED
| MEASURED
| REQUIRED
;
Design : LBR DESIGN DesignNameDef
{
current_instance = NULL; /* disable assign to current_instance*/
}
_Design RBR
;
_Design : CellRef
| _Design Status
| _Design Comment
| _Design Property
| _Design UserData
;
Designator : LBR DESIGNATOR _Designator RBR
;
_Designator : Str {;}
| StrDisplay {;}
;
DesignNameDef : NameDef { $<str>$ = $1; }
;
DesignRule : LBR PHYSICALDESIGNRULE _DesignRule RBR
;
_DesignRule :
| _DesignRule FigureWidth
| _DesignRule FigureArea
| _DesignRule RectSize
| _DesignRule FigurePerim
| _DesignRule OverlapDist
| _DesignRule OverhngDist
| _DesignRule EncloseDist
| _DesignRule InterFigGrp
| _DesignRule IntraFigGrp
| _DesignRule NotchSpace
| _DesignRule NotAllowed
| _DesignRule FigGrp
| _DesignRule Comment
| _DesignRule UserData
;
Difference : LBR DIFFERENCE _Difference RBR
;
_Difference : FigGrpRef
| FigureOp
| _Difference FigGrpRef
| _Difference FigureOp
;
Direction : LBR DIRECTION _Direction RBR
;
_Direction : INOUT
{
#ifdef SDF_PORT_DIRECTIONS
current_circuit->cirport->direction = SDF_PORT_INOUT;
#endif
}
| INPUT
{
#ifdef SDF_PORT_DIRECTIONS
current_circuit->cirport->direction = SDF_PORT_IN;
#endif
}
| OUTPUT
{
#ifdef SDF_PORT_DIRECTIONS
current_circuit->cirport->direction = SDF_PORT_OUT;
#endif
}
;
Display : LBR DISPLAY _Display _DisplayJust _DisplayOrien _DisplayOrg RBR
;
_Display : FigGrpNameRef
| FigGrpOver
;
_DisplayJust :
| Justify
;
_DisplayOrien :
| Orientation
;
_DisplayOrg :
| Origin
;
Dominates : LBR DOMINATES _Dominates RBR
;
_Dominates :
| _Dominates LogicNameRef
;
Dot : LBR DOT _Dot RBR
;
_Dot : PointValue
| _Dot Property
;
Duration : LBR DURATION ScaledInt RBR
;
EncloseDist : LBR ENCLOSUREDISTANCE RuleNameDef FigGrpObj FigGrpObj _EncloseDist RBR
;
_EncloseDist : Range
| SingleValSet
| _EncloseDist Comment
| _EncloseDist UserData
;
EndType : LBR ENDTYPE _EndType RBR
;
_EndType : EXTEND
| ROUND
| TRUNCATE
;
Entry : LBR ENTRY ___Entry __Entry _Entry RBR
;
___Entry : Match
| Change
| Steady
;
__Entry : LogicRef
| PortRef
| NoChange
| Table
;
_Entry :
| Delay
| LoadDelay
;
Event : LBR EVENT _Event RBR
;
_Event : PortRef
| PortList
| PortGroup
| NetRef
| NetGroup
| _Event Transition
| _Event Becomes
;
Exactly : LBR EXACTLY ScaledInt RBR
;
External : LBR EXTERNAL LibNameDef EdifLevel
{
NewLibrary(current_library);
current_library->name = $3; /* $3 already is canonic */
/* current library goes at end of list: */
}
_External RBR
{
$<library>$ = current_library;
}
;
_External : Technology
| _External Status { current_library->status = $2; }
| _External Cell
{
FUNCTIONPTR last_function = current_library->function;
while (last_function && last_function->next)
last_function = last_function->next;
if (last_function)
last_function->next = $2;
else
current_library->function = $2;
($2)->library = current_library;
}
| _External Comment
| _External UserData
;
Fabricate : LBR FABRICATE LayerNameDef FigGrpNameRef RBR
;
False : LBR FALSE RBR
;
FigGrp : LBR FIGUREGROUP _FigGrp RBR
;
_FigGrp : FigGrpNameDef {;}
| _FigGrp CornerType
| _FigGrp EndType
| _FigGrp PathWidth
| _FigGrp BorderWidth
| _FigGrp Color
| _FigGrp FillPattern
| _FigGrp BorderPat
| _FigGrp TextHeight
| _FigGrp Visible
| _FigGrp Comment
| _FigGrp Property
| _FigGrp UserData
| _FigGrp IncFigGrp
;
FigGrpNameDef : NameDef { $<str>$ = $1; }
;
FigGrpNameRef : NameRef { $<str>$ = $1; }
;
FigGrpObj : LBR FIGUREGROUPOBJECT _FigGrpObj RBR
;
_FigGrpObj : FigGrpNameRef
| FigGrpRef
| FigureOp
;
FigGrpOver : LBR FIGUREGROUPOVERRIDE _FigGrpOver RBR
;
_FigGrpOver : FigGrpNameRef
| _FigGrpOver CornerType
| _FigGrpOver EndType
| _FigGrpOver PathWidth
| _FigGrpOver BorderWidth
| _FigGrpOver Color
| _FigGrpOver FillPattern
| _FigGrpOver BorderPat
| _FigGrpOver TextHeight
| _FigGrpOver Visible
| _FigGrpOver Comment
| _FigGrpOver Property
| _FigGrpOver UserData
;
FigGrpRef : LBR FIGUREGROUPREF FigGrpNameRef _FigGrpRef RBR
;
_FigGrpRef :
| LibraryRef
;
Figure : LBR FIGURE _Figure RBR
;
_Figure : FigGrpNameDef {;}
| FigGrpOver {;}
| _Figure Circle
| _Figure Dot
| _Figure OpenShape
| _Figure Path
| _Figure Polygon
| _Figure Rectangle
| _Figure Shape
| _Figure Comment
| _Figure UserData
;
FigureArea : LBR FIGUREAREA RuleNameDef FigGrpObj _FigureArea RBR
;
_FigureArea : Range
| SingleValSet
| _FigureArea Comment
| _FigureArea UserData
;
FigureOp : Intersection
| Union
| Difference
| Inverse
| Oversize
;
FigurePerim : LBR FIGUREPERIMETER RuleNameDef FigGrpObj _FigurePerim RBR
;
_FigurePerim : Range
| SingleValSet
| _FigurePerim Comment
| _FigurePerim UserData
;
FigureWidth : LBR FIGUREWIDTH RuleNameDef FigGrpObj _FigureWidth RBR
;
_FigureWidth : Range
| SingleValSet
| _FigureWidth Comment
| _FigureWidth UserData
;
FillPattern : LBR FILLPATTERN Int Int Boolean RBR
;
Follow : LBR FOLLOW __Follow _Follow RBR
;
__Follow : PortNameRef {;}
| PortRef {;}
;
_Follow : PortRef
| Table
| _Follow Delay
| _Follow LoadDelay
;
Forbidden : LBR FORBIDDENEVENT _Forbidden RBR
;
_Forbidden : TimeIntval
| _Forbidden Event
;
GlobPortRef : LBR GLOBALPORTREF PortNameRef RBR
;
GreaterThan : LBR GREATERTHAN ScaledInt RBR
;
GridMap : LBR GRIDMAP ScaledInt ScaledInt RBR
;
Ignore : LBR IGNORE RBR
;
IncFigGrp : LBR INCLUDEFIGUREGROUP _IncFigGrp RBR
;
_IncFigGrp : FigGrpRef
| FigureOp
;
Initial : LBR INITIAL_TOK RBR
;
Instance : LBR INSTANCE InstNameDef
{
NewInstance_t(current_instance);
current_instance->instance_name = $3;
break;
}
_Instance RBR
{
$<instance>$ = current_instance;
}
;
_Instance : ViewRef
| ViewList
| _Instance Transform
| _Instance ParamAssign
| _Instance PortInst
| _Instance Timing
| _Instance Designator
| _Instance Property
| _Instance Comment
| _Instance UserData
;
InstanceRef : LBR INSTANCEREF InstNameRef _InstanceRef RBR
{
$<str>$ = $3;
}
;
_InstanceRef :
| InstanceRef {;}
| ViewRef
;
InstBackAn : LBR INSTANCEBACKANNOTATE _InstBackAn RBR
;
_InstBackAn : InstanceRef {;}
| _InstBackAn Designator
| _InstBackAn Timing
| _InstBackAn Property
| _InstBackAn Comment
;
InstGroup : LBR INSTANCEGROUP _InstGroup RBR
;
_InstGroup :
| _InstGroup InstanceRef {;}
;
InstMap : LBR INSTANCEMAP _InstMap RBR
;
_InstMap :
| _InstMap InstanceRef {;}
| _InstMap InstGroup
| _InstMap Comment
| _InstMap UserData
;
InstNameDef : NameDef { $<str>$ = $1; }
| Array { $<str>$ = NULL; }
;
InstNameRef : NameRef { $<str>$ = $1; }
| Member { $<str>$ = NULL; }
;
IntDisplay : LBR INTEGERDISPLAY _IntDisplay RBR
;
_IntDisplay : Int {;}
| _IntDisplay Display
;
Integer : LBR INTEGER _Integer RBR
;
_Integer :
| _Integer Int
| _Integer IntDisplay
| _Integer Integer
;
Interface : LBR INTERFACE _Interface RBR
;
_Interface :
| _Interface Port
| _Interface PortBundle
| _Interface Symbol
| _Interface ProtectFrame
| _Interface ArrayRelInfo
| _Interface Parameter
| _Interface Joined
| _Interface MustJoin
| _Interface WeakJoined
| _Interface Permutable
| _Interface Timing
| _Interface Simulate
| _Interface Designator
| _Interface Property
| _Interface Comment
| _Interface UserData
;
InterFigGrp : LBR INTERFIGUREGROUPSPACING RuleNameDef FigGrpObj FigGrpObj _InterFigGrp RBR
;
_InterFigGrp : Range
| SingleValSet
| _InterFigGrp Comment
| _InterFigGrp UserData
;
Intersection : LBR INTERSECTION _Intersection RBR
;
_Intersection : FigGrpRef
| FigureOp
| _Intersection FigGrpRef
| _Intersection FigureOp
;
IntraFigGrp : LBR INTRAFIGUREGROUPSPACING RuleNameDef FigGrpObj _IntraFigGrp RBR
;
_IntraFigGrp : Range
| SingleValSet
| _IntraFigGrp Comment
| _IntraFigGrp UserData
;
Inverse : LBR INVERSE _Inverse RBR
;
_Inverse : FigGrpRef
| FigureOp
;
Isolated : LBR ISOLATED RBR
;
Joined : LBR JOINED
{
current_joined = NULL;
}
_Joined RBR
{
$<cpref>$ = current_joined;
}
;
_Joined :
| _Joined PortRef
{
current_cirportref->next = current_joined;
current_joined = current_cirportref;
}
| _Joined PortList
| _Joined GlobPortRef
;
Justify : LBR JUSTIFY _Justify RBR
;
_Justify : CENTERCENTER
| CENTERLEFT
| CENTERRIGHT
| LOWERCENTER
| LOWERLEFT
| LOWERRIGHT
| UPPERCENTER
| UPPERLEFT
| UPPERRIGHT
;
KeywordDisp : LBR KEYWORDDISPLAY _KeywordDisp RBR
;
_KeywordDisp : KeywordName {;}
| _KeywordDisp Display
;
KeywordLevel : LBR KEYWORDLEVEL Int RBR
;
KeywordMap : LBR KEYWORDMAP _KeywordMap RBR
;
_KeywordMap : KeywordLevel
| _KeywordMap Comment
;
KeywordName : Ident { $<str>$ = $1; }
;
LayerNameDef : NameDef { $<str>$ = $1; }
;
LessThan : LBR LESSTHAN ScaledInt RBR
;
LibNameDef : NameDef { $<str>$ = $1; }
;
LibNameRef : NameRef { $<str>$ = $1; }
;
Library : LBR LIBRARY_TOK LibNameDef EdifLevel
{
NewLibrary(current_library);
current_library->name = $3; /* $3 already is canonic */
/* current library goes at end of list: */
}
_Library RBR
{
$<library>$ = current_library;
}
;
_Library : Technology
| _Library Status { current_library->status = $2; }
| _Library Cell
{
FUNCTIONPTR last_function = current_library->function;
while (last_function && last_function->next)
last_function = last_function->next;
if (last_function)
last_function->next = $2;
else
current_library->function = $2;
($2)->library = current_library;
}
| _Library Comment
| _Library UserData
;
LibraryRef : LBR LIBRARYREF LibNameRef RBR
{
if (current_instance)
current_instance->library_ref = $3;
}
;
ListOfNets : LBR LISTOFNETS _ListOfNets RBR
;
_ListOfNets :
| _ListOfNets Net
;
ListOfPorts : LBR LISTOFPORTS _ListOfPorts RBR
;
_ListOfPorts :
| _ListOfPorts Port
| _ListOfPorts PortBundle
;
LoadDelay : LBR LOADDELAY _LoadDelay _LoadDelay RBR
;
_LoadDelay : MiNoMaValue
| MiNoMaDisp
;
LogicAssn : LBR LOGICASSIGN ___LogicAssn __LogicAssn _LogicAssn RBR
;
___LogicAssn : PortNameRef {;}
| PortRef {;}
;
__LogicAssn : PortRef
| LogicRef
| Table
;
_LogicAssn :
| Delay
| LoadDelay
;
LogicIn : LBR LOGICINPUT _LogicIn RBR
;
_LogicIn : PortList
| PortRef {;}
| PortNameRef {;}
| _LogicIn LogicWave
;
LogicList : LBR LOGICLIST _LogicList RBR
;
_LogicList :
| _LogicList LogicNameRef
| _LogicList LogicOneOf
| _LogicList Ignore
;
LogicMapIn : LBR LOGICMAPINPUT _LogicMapIn RBR
;
_LogicMapIn :
| _LogicMapIn LogicNameRef
;
LogicMapOut : LBR LOGICMAPOUTPUT _LogicMapOut RBR
;
_LogicMapOut :
| _LogicMapOut LogicNameRef
;
LogicNameDef : NameDef { $<str>$ = $1; }
;
LogicNameRef : NameRef { $<str>$ = $1; }
;
LogicOneOf : LBR LOGICONEOF _LogicOneOf RBR
;
_LogicOneOf :
| _LogicOneOf LogicNameRef
| _LogicOneOf LogicList
;
LogicOut : LBR LOGICOUTPUT _LogicOut RBR
;
_LogicOut : PortList
| PortRef {;}
| PortNameRef {;}
| _LogicOut LogicWave
;
LogicPort : LBR LOGICPORT _LogicPort RBR
;
_LogicPort : PortNameDef {;}
| _LogicPort Property
| _LogicPort Comment
| _LogicPort UserData
;
LogicRef : LBR LOGICREF LogicNameRef _LogicRef RBR
;
_LogicRef :
| LibraryRef
;
LogicValue : LBR LOGICVALUE _LogicValue RBR
;
_LogicValue : LogicNameDef {;}
| _LogicValue VoltageMap
| _LogicValue CurrentMap
| _LogicValue BooleanMap
| _LogicValue Compound
| _LogicValue Weak
| _LogicValue Strong
| _LogicValue Dominates
| _LogicValue LogicMapOut
| _LogicValue LogicMapIn
| _LogicValue Isolated
| _LogicValue Resolves
| _LogicValue Property
| _LogicValue Comment
| _LogicValue UserData
;
LogicWave : LBR LOGICWAVEFORM _LogicWave RBR
;
_LogicWave :
| _LogicWave LogicNameRef
| _LogicWave LogicList
| _LogicWave LogicOneOf
| _LogicWave Ignore
;
Maintain : LBR MAINTAIN __Maintain _Maintain RBR
;
__Maintain : PortNameRef {;}
| PortRef {;}
;
_Maintain :
| Delay
| LoadDelay
;
Match : LBR MATCH __Match _Match RBR
;
__Match : PortNameRef {;}
| PortRef {;}
| PortList
;
_Match : LogicNameRef
| LogicList
| LogicOneOf
;
Member : LBR MEMBER NameRef _Member RBR
;
_Member : Int {;}
| _Member Int
;
MiNoMa : LBR MINOMAX _MiNoMa RBR
;
_MiNoMa :
| _MiNoMa MiNoMaValue
| _MiNoMa MiNoMaDisp
| _MiNoMa MiNoMa
;
MiNoMaDisp : LBR MINOMAXDISPLAY _MiNoMaDisp RBR
;
_MiNoMaDisp : MiNoMaValue
| _MiNoMaDisp Display
;
MiNoMaValue : Mnm
| ScaledInt
;
Mnm : LBR MNM _Mnm _Mnm _Mnm RBR
;
_Mnm : ScaledInt
| Undefined
| Unconstrained
;
MultValSet : LBR MULTIPLEVALUESET _MultValSet RBR
;
_MultValSet :
| _MultValSet RangeVector
;
MustJoin : LBR MUSTJOIN _MustJoin RBR
;
_MustJoin :
| _MustJoin PortRef
| _MustJoin PortList
| _MustJoin WeakJoined
| _MustJoin Joined
;
Name : LBR NAME _Name RBR { $<str>$ = $3; }
;
_Name : Ident { $<str>$ = $1; }
| _Name Display { $<str>$ = $1; }
;
NameDef : Ident { $<str>$ = $1; }
| Name { $<str>$ = $1; }
| Rename { $<str>$ = $1; }
;
NameRef : Ident { $<str>$ = $1; }
| Name { $<str>$ = $1; }
;
Net : LBR NET_TOK NetNameDef
{
NewNet(current_net);
current_net->name = $3;
current_net->circuit = current_circuit;
}
_Net RBR
{
int num_term = 0;
CIRPORTREFPTR cpr = current_net->terminals;
for (; cpr; cpr = cpr->next) ++num_term;
current_net->num_term = num_term;
$<net>$ = current_net;
}
;
_Net : Joined { current_net->terminals = $1; }
| _Net Criticality
| _Net NetDelay
| _Net Figure
| _Net Net
| _Net Instance
| _Net CommGraph
| _Net Property
| _Net Comment
| _Net UserData
;
NetBackAn : LBR NETBACKANNOTATE _NetBackAn RBR
;
_NetBackAn : NetRef
| _NetBackAn NetDelay
| _NetBackAn Criticality
| _NetBackAn Property
| _NetBackAn Comment
;
NetBundle : LBR NETBUNDLE NetNameDef _NetBundle RBR
;
_NetBundle : ListOfNets
| _NetBundle Figure
| _NetBundle CommGraph
| _NetBundle Property
| _NetBundle Comment
| _NetBundle UserData
;
NetDelay : LBR NETDELAY Derivation _NetDelay RBR
;
_NetDelay : Delay
| _NetDelay Transition
| _NetDelay Becomes
;
NetGroup : LBR NETGROUP _NetGroup RBR
;
_NetGroup :
| _NetGroup NetNameRef
| _NetGroup NetRef
;
NetMap : LBR NETMAP _NetMap RBR
;
_NetMap :
| _NetMap NetRef
| _NetMap NetGroup
| _NetMap Comment
| _NetMap UserData
;
NetNameDef : NameDef { $<str>$ = $1; }
| Array { $<str>$ = NULL; }
;
NetNameRef : NameRef { $<str>$ = $1; }
| Member { $<str>$ = NULL; }
;
NetRef : LBR NETREF_TOK NetNameRef _NetRef RBR
;
_NetRef :
| NetRef
| InstanceRef {;}
| ViewRef
;
NoChange : LBR NOCHANGE RBR
;
NonPermut : LBR NONPERMUTABLE _NonPermut RBR
;
_NonPermut :
| _NonPermut PortRef
| _NonPermut Permutable
;
NotAllowed : LBR NOTALLOWED RuleNameDef _NotAllowed RBR
;
_NotAllowed : FigGrpObj
| _NotAllowed Comment
| _NotAllowed UserData
;
NotchSpace : LBR NOTCHSPACING RuleNameDef FigGrpObj _NotchSpace RBR
;
_NotchSpace : Range
| SingleValSet
| _NotchSpace Comment
| _NotchSpace UserData
;
Number : LBR NUMBER _Number RBR
;
_Number :
| _Number ScaledInt
| _Number NumbDisplay
| _Number Number
;
NumbDisplay : LBR NUMBERDISPLAY _NumbDisplay RBR
;
_NumbDisplay : ScaledInt
| _NumbDisplay Display
;
NumberDefn : LBR NUMBERDEFINITION _NumberDefn RBR
;
_NumberDefn :
| _NumberDefn Scale
| _NumberDefn GridMap
| _NumberDefn Comment
;
OffPageConn : LBR OFFPAGECONNECTOR _OffPageConn RBR
;
_OffPageConn : PortNameDef {;}
| _OffPageConn Unused
| _OffPageConn Property
| _OffPageConn Comment
| _OffPageConn UserData
;
OffsetEvent : LBR OFFSETEVENT Event ScaledInt RBR
;
OpenShape : LBR OPENSHAPE _OpenShape RBR
;
_OpenShape : Curve
| _OpenShape Property
;
Orientation : LBR ORIENTATION _Orientation RBR
;
_Orientation : R0
| R90
| R180
| R270
| MX
| MY
| MYR90
| MXR90
;
Origin : LBR ORIGIN PointValue RBR
;
OverhngDist : LBR OVERHANGDISTANCE RuleNameDef FigGrpObj FigGrpObj _OverhngDist RBR
;
_OverhngDist : Range
| SingleValSet
| _OverhngDist Comment
| _OverhngDist UserData
;
OverlapDist : LBR OVERLAPDISTANCE RuleNameDef FigGrpObj FigGrpObj _OverlapDist RBR
;
_OverlapDist : Range
| SingleValSet
| _OverlapDist Comment
| _OverlapDist UserData
;
Oversize : LBR OVERSIZE Int _Oversize CornerType RBR
;
_Oversize : FigGrpRef
| FigureOp
;
Owner : LBR OWNER Str RBR
;
Page : LBR PAGE _Page RBR
;
_Page : InstNameDef {;}
| _Page Instance
| _Page Net
| _Page NetBundle
| _Page CommGraph
| _Page PortImpl
| _Page PageSize
| _Page BoundBox
| _Page Comment
| _Page UserData
;
PageSize : LBR PAGESIZE Rectangle RBR
;
ParamDisp : LBR PARAMETERDISPLAY _ParamDisp RBR
;
_ParamDisp : ValueNameRef
| _ParamDisp Display
;
Parameter : LBR PARAMETER ValueNameDef TypedValue _Parameter RBR
;
_Parameter :
| Unit
;
ParamAssign : LBR PARAMETERASSIGN ValueNameRef TypedValue RBR
;
Path : LBR PATH _Path RBR
;
_Path : PointList
| _Path Property
;
PathDelay : LBR PATHDELAY _PathDelay RBR
;
_PathDelay : Delay
| _PathDelay Event
;
PathWidth : LBR PATHWIDTH Int RBR
;
Permutable : LBR PERMUTABLE _Permutable RBR
;
_Permutable :
| _Permutable PortRef
| _Permutable Permutable
| _Permutable NonPermut
;
Plug : LBR PLUG _Plug RBR
;
_Plug :
| _Plug SocketSet
;
Point : LBR POINT _Point RBR
;
_Point :
| _Point PointValue
| _Point PointDisp
| _Point Point
;
PointDisp : LBR POINTDISPLAY _PointDisp RBR
;
_PointDisp : PointValue
| _PointDisp Display
;
PointList : LBR POINTLIST _PointList RBR
;
_PointList :
| _PointList PointValue
;
PointValue : LBR PT Int Int RBR
;
Polygon : LBR POLYGON _Polygon RBR
;
_Polygon : PointList
| _Polygon Property
;
Port : LBR PORT
{
CIRPORTPTR cp;
switch (current_viewtype)
{
case SeadifCircuitView: /* create CirPort and link in list */
NewCirport(cp); cp->name = NULL;
cp->next = current_circuit->cirport;
#ifdef SDF_PORT_DIRECTIONS
cp->direction = SDF_PORT_UNKNOWN;
#endif
current_circuit->cirport = cp;
break;
default:
report(eFatal,"line %d: this port is not supported\n",ediflineno);
break;
}
}
_Port RBR
;
_Port : PortNameDef
{current_circuit->cirport->name = cs($1);}
| _Port Direction
| _Port Unused
| _Port PortDelay
| _Port Designator
| _Port DcFanInLoad
| _Port DcFanOutLoad
| _Port DcMaxFanIn
| _Port DcMaxFanOut
| _Port AcLoad
| _Port Property
| _Port Comment
| _Port UserData
;
PortBackAn : LBR PORTBACKANNOTATE _PortBackAn RBR
;
_PortBackAn : PortRef
| _PortBackAn Designator
| _PortBackAn PortDelay
| _PortBackAn DcFanInLoad
| _PortBackAn DcFanOutLoad
| _PortBackAn DcMaxFanIn
| _PortBackAn DcMaxFanOut
| _PortBackAn AcLoad
| _PortBackAn Property
| _PortBackAn Comment
;
PortBundle : LBR PORTBUNDLE PortNameDef _PortBundle RBR
;
_PortBundle : ListOfPorts
| _PortBundle Property
| _PortBundle Comment
| _PortBundle UserData
;
PortDelay : LBR PORTDELAY Derivation _PortDelay RBR
;
_PortDelay : Delay
| LoadDelay
| _PortDelay Transition
| _PortDelay Becomes
;
PortGroup : LBR PORTGROUP _PortGroup RBR
;
_PortGroup :
| _PortGroup PortNameRef
| _PortGroup PortRef
;
PortImpl : LBR PORTIMPLEMENTATION _PortImpl RBR
;
_PortImpl : PortRef {;}
| PortNameRef {;}
| _PortImpl ConnectLoc
| _PortImpl Figure
| _PortImpl Instance
| _PortImpl CommGraph
| _PortImpl PropDisplay
| _PortImpl KeywordDisp
| _PortImpl Property
| _PortImpl UserData
| _PortImpl Comment
;
PortInst : LBR PORTINSTANCE _PortInst RBR
;
_PortInst : PortRef {;}
| PortNameRef {;}
| _PortInst Unused
| _PortInst PortDelay
| _PortInst Designator
| _PortInst DcFanInLoad
| _PortInst DcFanOutLoad
| _PortInst DcMaxFanIn
| _PortInst DcMaxFanOut
| _PortInst AcLoad
| _PortInst Property
| _PortInst Comment
| _PortInst UserData
;
PortList : LBR PORTLIST _PortList RBR
;
_PortList :
| _PortList PortRef
| _PortList PortNameRef
;
PortListAls : LBR PORTLISTALIAS PortNameDef PortList RBR
;
PortMap : LBR PORTMAP _PortMap RBR
;
_PortMap :
| _PortMap PortRef
| _PortMap PortGroup
| _PortMap Comment
| _PortMap UserData
;
PortNameDef : NameDef { $<str>$ = $1; }
| Array { $<str>$ = NULL; }
;
PortNameRef : NameRef { $<str>$ = $1; }
| Member { $<str>$ = NULL; }
;
PortRef : LBR PORTREF PortNameRef _PortRef RBR
{
switch (current_viewtype)
{
case SeadifCircuitView:
NewCirportref(current_cirportref);
current_cirportref->cirport = (CIRPORTPTR) $3; /* __HACK__ */
current_cirportref->cirinst = (CIRINSTPTR) $4; /* __HACK__ */
current_cirportref->net = current_net;
break;
default:
break;
}
}
;
_PortRef : { $<str>$ = NULL; /* empty */ }
| PortRef { $<str>$ = NULL; }
| InstanceRef { $<str>$ = $1; }
| ViewRef { $<str>$ = NULL; }
;
Program : LBR PROGRAM Str _Program RBR { $<str>$ = $3; }
;
_Program :
| Version
;
PropDisplay : LBR PROPERTYDISPLAY _PropDisplay RBR
;
_PropDisplay : PropNameRef
| _PropDisplay Display
;
Property : LBR PROPERTY PropNameDef _Property RBR
;
_Property : TypedValue
| _Property Owner
| _Property Unit
| _Property Property
| _Property Comment
;
PropNameDef : NameDef { $<str>$ = $1; }
;
PropNameRef : NameRef { $<str>$ = $1; }
;
ProtectFrame : LBR PROTECTIONFRAME _ProtectFrame RBR
;
_ProtectFrame :
| _ProtectFrame PortImpl
| _ProtectFrame Figure
| _ProtectFrame Instance
| _ProtectFrame CommGraph
| _ProtectFrame BoundBox
| _ProtectFrame PropDisplay
| _ProtectFrame KeywordDisp
| _ProtectFrame ParamDisp
| _ProtectFrame Property
| _ProtectFrame Comment
| _ProtectFrame UserData
;
Range : LessThan
| GreaterThan
| AtMost
| AtLeast
| Exactly
| Between
;
RangeVector : LBR RANGEVECTOR _RangeVector RBR
;
_RangeVector :
| _RangeVector Range
| _RangeVector SingleValSet
;
Rectangle : LBR RECTANGLE PointValue _Rectangle RBR
;
_Rectangle : PointValue
| _Rectangle Property
;
RectSize : LBR RECTANGLESIZE RuleNameDef FigGrpObj _RectSize RBR
;
_RectSize : RangeVector
| MultValSet
| _RectSize Comment
| _RectSize UserData
;
Rename : LBR RENAME __Rename _Rename RBR
{
/* we ignore the rename facility, return the EDIF name: */
$<str>$ = $3;
}
;
__Rename : Ident { $<str>$ = $1; }
| Name { $<str>$ = $1; }
;
_Rename : Str { $<str>$ = $1; }
| StrDisplay { $<str>$ = NULL; }
;
Resolves : LBR RESOLVES _Resolves RBR
;
_Resolves :
| _Resolves LogicNameRef
;
RuleNameDef : NameDef { $<str>$ = $1; }
;
Scale : LBR SCALE ScaledInt ScaledInt Unit RBR
;
ScaledInt : Int {;}
| LBR E_TOK Int Int RBR
;
ScaleX : LBR SCALEX Int Int RBR
;
ScaleY : LBR SCALEY Int Int RBR
;
Section : LBR SECTION _Section RBR
;
_Section : Str {;}
| _Section Section
| _Section Str
| _Section Instance
;
Shape : LBR SHAPE _Shape RBR
;
_Shape : Curve
| _Shape Property
;
SimNameDef : NameDef { $<str>$ = $1; }
;
Simulate : LBR SIMULATE _Simulate RBR
;
_Simulate : SimNameDef
| _Simulate PortListAls
| _Simulate WaveValue
| _Simulate Apply
| _Simulate Comment
| _Simulate UserData
;
SimulInfo : LBR SIMULATIONINFO _SimulInfo RBR
;
_SimulInfo :
| _SimulInfo LogicValue
| _SimulInfo Comment
| _SimulInfo UserData
;
SingleValSet : LBR SINGLEVALUESET _SingleValSet RBR
;
_SingleValSet :
| Range
;
Site : LBR SITE ViewRef _Site RBR
;
_Site :
| Transform
;
Socket : LBR SOCKET _Socket RBR
;
_Socket :
| Symmetry
;
SocketSet : LBR SOCKETSET _SocketSet RBR
;
_SocketSet : Symmetry
| _SocketSet Site
;
Status : LBR STATUS_TOK
{
NewStatus(current_status);
}
_Status RBR
{
$<status>$ = current_status;
}
;
_Status :
| _Status Written
| _Status Comment
| _Status UserData
;
Steady : LBR STEADY __Steady _Steady RBR
;
__Steady : PortNameRef {;}
| PortRef {;}
| PortList
;
_Steady : Duration
| _Steady Transition
| _Steady Becomes
;
StrDisplay : LBR STRINGDISPLAY _StrDisplay RBR
;
String : LBR STRING_TOK _String RBR
;
_String :
| _String Str
| _String StrDisplay
| _String String
;
_StrDisplay : Str {;}
| _StrDisplay Display
;
Strong : LBR STRONG LogicNameRef RBR
;
Symbol : LBR SYMBOL _Symbol RBR
;
_Symbol :
| _Symbol PortImpl
| _Symbol Figure
| _Symbol Instance
| _Symbol CommGraph
| _Symbol Annotate
| _Symbol PageSize
| _Symbol BoundBox
| _Symbol PropDisplay
| _Symbol KeywordDisp
| _Symbol ParamDisp
| _Symbol Property
| _Symbol Comment
| _Symbol UserData
;
Symmetry : LBR SYMMETRY _Symmetry RBR
;
_Symmetry :
| _Symmetry Transform
;
Table : LBR TABLE _Table RBR
;
_Table :
| _Table Entry
| _Table TableDeflt
;
TableDeflt : LBR TABLEDEFAULT __TableDeflt _TableDeflt RBR
;
__TableDeflt : LogicRef
| PortRef
| NoChange
| Table
;
_TableDeflt :
| Delay
| LoadDelay
;
Technology : LBR TECHNOLOGY _Technology RBR
;
_Technology : NumberDefn
| _Technology FigGrp
| _Technology Fabricate
| _Technology SimulInfo
| _Technology DesignRule
| _Technology Comment
| _Technology UserData
;
TextHeight : LBR TEXTHEIGHT Int RBR
;
TimeIntval : LBR TIMEINTERVAL __TimeIntval _TimeIntval RBR
;
__TimeIntval : Event
| OffsetEvent
;
_TimeIntval : Event
| OffsetEvent
| Duration
;
TimeStamp : LBR TIMESTAMP Int Int Int Int Int Int RBR
{
time_t thetime = 0;
sdftimecvt (&thetime, $3, $4, $5, $6, $7, $8);
$<time>$ = thetime;
}
;
Timing : LBR TIMING_TOK _Timing RBR
;
_Timing : Derivation
| _Timing PathDelay
| _Timing Forbidden
| _Timing Comment
| _Timing UserData
;
Transform : LBR TRANSFORM _TransX _TransY _TransDelta _TransOrien _TransOrg RBR
;
_TransX :
| ScaleX
;
_TransY :
| ScaleY
;
_TransDelta :
| Delta
;
_TransOrien :
| Orientation
;
_TransOrg :
| Origin
;
Transition : LBR TRANSITION _Transition _Transition RBR
;
_Transition : LogicNameRef
| LogicList
| LogicOneOf
;
Trigger : LBR TRIGGER _Trigger RBR
;
_Trigger :
| _Trigger Change
| _Trigger Steady
| _Trigger Initial
;
True : LBR TRUE_TOK RBR
;
TypedValue : Boolean
| Integer
| MiNoMa
| Number
| Point
| String
;
Unconstrained : LBR UNCONSTRAINED RBR
;
Undefined : LBR UNDEFINED RBR
;
Union : LBR UNION _Union RBR
;
_Union : FigGrpRef
| FigureOp
| _Union FigGrpRef
| _Union FigureOp
;
Unit : LBR UNIT _Unit RBR
;
_Unit : DISTANCE
| CAPACITANCE
| CURRENT
| RESISTANCE
| TEMPERATURE
| TIME
| VOLTAGE
| MASS
| FREQUENCY
| INDUCTANCE
| ENERGY
| POWER
| CHARGE
| CONDUCTANCE
| FLUX
| ANGLE
;
Unused : LBR UNUSED RBR
;
UserData : LBR USERDATA _UserData RBR
;
_UserData : /* empty */
| _UserData Int
| _UserData Str
| _UserData LBR _UserData RBR
;
ValueNameDef : NameDef { $<str>$ = $1; }
| Array { $<str>$ = NULL; }
;
ValueNameRef : NameRef { $<str>$ = $1; }
| Member { $<str>$ = NULL; }
;
Version : LBR VERSION Str RBR
;
View : LBR VIEW ViewNameDef ViewType
{
current_viewtype = $4;
if (current_viewtype == SeadifCircuitView)
NewCircuit (current_circuit);
else
report (eFatal, "line %d: cannot handle viewType \"%s\"",
ediflineno, current_viewtype_string);
}
View_ RBR
{
$<viewtype>$ = current_viewtype;
}
;
View_ : Interface
| View_ Status
| View_ Contents
| View_ Comment
| View_ Property
| View_ UserData
;
ViewList : LBR VIEWLIST ViewList_ RBR
;
ViewList_ :
| ViewList_ ViewRef
| ViewList_ ViewList
;
ViewMap : LBR VIEWMAP ViewMap_ RBR
;
ViewMap_ :
| ViewMap_ PortMap
| ViewMap_ PortBackAn
| ViewMap_ InstMap
| ViewMap_ InstBackAn
| ViewMap_ NetMap
| ViewMap_ NetBackAn
| ViewMap_ Comment
| ViewMap_ UserData
;
ViewNameDef : NameDef { $<str>$ = $1; }
;
ViewRef : LBR VIEWREF
{
/* the name of the VIEWREF can be any string. In particular, it
* can be an edif keyword. This sort of thing means that the
* edif syntax (at least as generated by Cadence "edifout") is
* not context-free. Oh well...
*/
ediflex(); /* we call ediflex() ourselves... */
/* the VIEWREF identifier is now in (char *)ediftext */
if (current_instance)
current_instance->view_name_ref = cs(ediftext);
}
_ViewRef RBR
;
_ViewRef :
| CellRef
;
ViewType : LBR VIEWTYPE _ViewType
{
/* save the name of the current view type
(e.g. for error messages) */
if (current_viewtype_string)
fs(current_viewtype_string);
current_viewtype_string = cs(ediftext);
}
RBR
{
$<viewtype>$ = $3;
}
;
_ViewType : MASKLAYOUT { $<viewtype>$ = SeadifLayoutView; }
| PCBLAYOUT { $<viewtype>$ = SeadifNoView; }
| NETLIST { $<viewtype>$ = SeadifCircuitView; }
| SCHEMATIC { $<viewtype>$ = SeadifNoView; }
| SYMBOLIC { $<viewtype>$ = SeadifNoView; }
| BEHAVIOR { $<viewtype>$ = SeadifFunctionView; }
| LOGICMODEL { $<viewtype>$ = SeadifNoView; }
| DOCUMENT { $<viewtype>$ = SeadifNoView; }
| GRAPHIC { $<viewtype>$ = SeadifNoView; }
| STRANGER { $<viewtype>$ = SeadifNoView; }
;
Visible : LBR VISIBLE BooleanValue RBR
;
VoltageMap : LBR VOLTAGEMAP MiNoMaValue RBR
;
WaveValue : LBR WAVEVALUE LogicNameDef ScaledInt LogicWave RBR
;
Weak : LBR WEAK LogicNameRef RBR
;
WeakJoined : LBR WEAKJOINED _WeakJoined RBR
;
_WeakJoined :
| _WeakJoined PortRef
| _WeakJoined PortList
| _WeakJoined Joined
;
When : LBR WHEN _When RBR
;
_When : Trigger
| _When After
| _When Follow
| _When Maintain
| _When LogicAssn
| _When Comment
| _When UserData
;
Written : LBR WRITTEN _Written RBR
;
_Written : TimeStamp { current_status->timestamp = $1; }
| _Written Author { current_status->author = $2; }
| _Written Program { current_status->program = $2; }
| _Written DataOrigin
| _Written Property
| _Written Comment
| _Written UserData
;
Str : STR
;
Ident : STR
;
Int : INT
;
%%
int ediferror (char *mesg)
{
report (eFatal, "Edif parser, line %d: %s", ediflineno, mesg);
return 0;
}
|
<reponame>vhnatyk/vlsistuff<gh_stars>10-100
%token module number token endmodule assign
%token input output inout reg wire logic tri0 tri1 signed event
%token bin hex dig integer real wreal
%token ubin uhex udig
%token domino and_and or_or eq3 eq_eq not_eq gr_eq sm_eq
%token always begin end if else posedge negedge or wait emit
%token string defparam parameter localparam case casez casex endcase default initial forever
%token function endfunction task endtask
%token for while backtick_define backtick_include backtick_timescale backtick_undef define
%token strong1 strong0 pull1 pull0 weak1 weak0 highz1 highz0
%token fork join
%token disable
%token pragma1 pragma2
%token plus_range minus_range
%token floating
%token power star
%token generate endgenerate genvar
%token force release
%token xnor nand nor repeat
%token supply0 supply1
%token newver
%token return
%token always_comb
%right '?' ':'
%left '|'
%left or_or
%left '^' xnor nand nor
%left '&'
%left and_and
%left shift_left shift_right SignedLeft arith_shift_right
%left '<' '>' sm_eq gr_eq
%left '+' '-'
%left eq3 eq_eq not_eq noteqeq Veryequal
%left '*' '/' '%' power
%left StarStar
%left UNARY_PREC
%nonassoc else
%%
Main : Mains ;
Mains : Mains MainItem | MainItem ;
MainItem : Module | Define ;
Module : module token Hparams Header Module_stuffs endmodule
Hparams : '#' '(' head_params ')' | '#' '(' ')' | ;
Header : ';' | '(' Header_list ')' ';' | '(' ')' ';' ;
Header_list : Header_list ',' Header_item | Header_item ;
Header_item : ExtDir token | ExtDir Width token | ExtDir integer token | ExtDir Width token Width | ExtDir Width Width token | token | ExtDir token '=' Literal | ExtDir Width token '=' Literal;
Module_stuffs : Mstuff Module_stuffs | ;
Mstuff :
Definition
| Assign
| Instance
| Always
| Generate
| Parameter
| Localparam
| Defparam
| Initial
| Function
| Task
| Define
| Pragma
| newver
;
// Define : backtick_undef token | backtick_define token Expr | backtick_include Expr | backtick_timescale number token '/' number token ;
Define : define string | define token | define token Expr | define number token '/' number token ;
Initial : initial Statement ;
Definition :
ExtDir Tokens_list ';'
| event Tokens_list ';'
| IntDir Tokens_list ';'
| IntDir Tokens_list '=' Expr ';'
| ExtDir Width Tokens_list ';'
| ExtDir Width Tokens_list Width ';'
| IntDir Width Tokens_list ';'
| IntDir Width token '=' Expr ';'
| IntDir Width token Width ';'
| IntDir Width Width Tokens_list ';'
| IntDir Width Width token '=' Expr ';'
| IntDir token Width ';'
| IntDir InstParams Tokens_list ';'
| IntDir InstParams token '=' Expr ';'
| token domino token token ';'
;
Assign :
assign Soft_assigns ';'
| assign AssignParams LSH '=' Expr ';'
| assign StrengthDef AssignParams LSH '=' Expr ';'
| assign StrengthDef LSH '=' Expr ';'
;
StrengthDef : '(' Strength ',' Strength ')' ;
Strength : strong1 | strong0 | pull1 | pull0 | weak1 | weak0 | highz1 | highz0 ;
WidthInt : Width | integer ;
Function :
function token ';' Mem_defs Statements endfunction
| function token ';' Statements endfunction
| function Width Width token ';' Mem_defs Statement endfunction
| function WidthInt token ';' Mem_defs Statement endfunction
| function WidthInt token ';' Statement endfunction
| function token '(' Header_list ')' ';' Statement endfunction
| function token '(' Header_list ')' ';' Mem_defs Statement endfunction
| function WidthInt token '(' Header_list ')' ';' Statement endfunction
| function WidthInt token '(' Header_list ')' ';' Mem_defs Statement endfunction
;
Task :
task token ';' Mem_defs Statement endtask
| task token ';' Statement endtask
| task token '(' Header_list ')' ';' Statement endtask
| task token '(' Header_list ')' ';' Mem_defs Statement endtask
;
Mem_defs : Mem_defs Mem_def | Mem_def ;
Mem_def :
reg Tokens_list ';'
| real Tokens_list ';'
| wreal Tokens_list ';'
| reg Width Tokens_list ';'
| reg Width token Width ';'
| reg Width Width token ';'
| output reg Width Width token ';'
| input Tokens_list ';'
| input Tokens_list Width ';'
| input Width Width Tokens_list ';'
| input integer Tokens_list ';'
| integer Tokens_list ';'
| integer Tokens_list Width ';'
;
Parameter :
parameter Pairs ';'
| parameter signed Pairs ';'
| parameter Width Pairs ';'
| parameter Width Width Pairs ';'
| parameter signed Width Pairs ';'
;
Localparam : localparam Pairs ';' | localparam Width Pairs ';' | localparam Width Width Pairs ';';
Defparam : defparam DottedPairs ';' ;
DottedPair : Dotted '=' Expr ;
DottedPairs : DottedPairs ',' DottedPair | DottedPair ;
Pairs : Pairs ',' Pair | Pair ;
Pair : token '=' Expr ;
head_params : head_params ',' head_param | head_param ;
head_param :
localparam token '=' Expr
| parameter token '=' Expr
| parameter Width token '=' Expr
| token '=' Expr
;
Instance :
token token '(' ')' ';'
| token InstParams token '(' ')' ';'
| token token ';'
| or '(' Exprs ')' ';'
| or token '(' Exprs ')' ';'
| token token '(' Conns_list ')' ';'
| or token '(' Conns_list ')' ';'
| token token '(' Exprs ')' ';'
| token '(' Exprs ')' ';'
| token InstParams token '(' Conns_list ')' ';'
| token InstParams token Width '(' Conns_list ')' ';'
| token token Width '(' Conns_list ')' ';'
| token token Width '(' Exprs ')' ';'
;
// | token '(' Exprs ')' ';'
Conns_list : Conns_list ',' Connection | Connection ;
Connection : '.' '*' | '.' token '(' Expr ')' | '.' token '(' ')' ;
AssignParams : '#' '(' Exprs ')' | '#' number | '#' token | '#' floating ;
Prms_list : Prms_list ',' PrmAssign | PrmAssign ;
PrmAssign : '.' token '(' Expr ')' | '.' token ;
InstParams : '#' '(' Exprs ')' | '#' number | '#' floating | '#' token | '#' '(' Prms_list ')' | '#' '(' ')' ;
Always : always_comb Statement | always Statement | always When Statement ;
Generate : generate GenStatements endgenerate ;
GenStatements : GenStatements GenStatement | GenStatement ;
GenStatement :
begin GenStatements end
| begin ':' token GenStatements end
| genvar token ';'
| Definition
| Assign
| Parameter
| Localparam
| Defparam
| Instance
| GenFor_statement
| Always
| Initial
| if '(' Expr ')' GenStatement
| if '(' Expr ')' GenStatement else GenStatement
;
GenFor_statement : for '(' Soft_assigns ';' Expr ';' Soft_assigns ')' GenStatement ;
When : '@' '*' | '@' star | '@' token | '@' '(' When_items ')' ;
Or_coma : or | ',' ;
When_items : When_items Or_coma When_item | When_item ;
When_item : posedge Expr | negedge Expr | Expr ;
// If_only : if '(' Expr ')' Statement ;
// If_else : If_only else Statement ;
Statement :
begin Statements end
| begin end
| forever Statement
| begin ':' token Statements end
| fork Statements join
| LSH '=' Expr ';'
| LSH '=' AssignParams Expr ';'
| LSH sm_eq Expr ';'
| LSH sm_eq AssignParams Expr ';'
| if '(' Expr ')' Statement
| if '(' Expr ')' Statement else Statement
| wait Expr ';'
| integer Tokens_list ';'
| reg Tokens_list ';'
| reg Width Tokens_list ';'
| release Expr ';'
| force Expr '=' Expr ';'
| When ';'
| emit token ';'
| disable token ';'
| token '(' ')' ';'
| token '(' Exprs ')' ';'
| case '(' Expr ')' Cases endcase
| case '(' Expr ')' Cases Default endcase
| case '(' Expr ')' Default endcase
| casez '(' Expr ')' Cases endcase
| casez '(' Expr ')' Cases Default endcase
| casex '(' Expr ')' Cases endcase
| casex '(' Expr ')' Cases Default endcase
| '#' Expr ';'
| '#' Expr Statement
| token ';'
| For_statement
| Repeat_statement
| While_statement
| Dotted ';'
| Pragma
| assign LSH '=' Expr ';'
| return token ';'
;
Pragma : pragma1 string pragma2 ;
For_statement : for '(' Soft_assigns ';' Expr ';' Soft_assigns ')' Statement ;
Repeat_statement : repeat '(' Expr ')' Statement ;
While_statement : while '(' Expr ')' Statement ;
Soft_assigns : Soft_assigns ',' Soft_assign | Soft_assign ;
Soft_assign : LSH '=' Expr ;
Cases : Cases Case | Case ;
Case : Exprs ':' Statement | Exprs ':' ';' ;
Default : default ':' Statement | default ':' ';' ;
Exprs : Exprs ',' Expr | Expr ;
Statements : Statements Statement | Statement ;
LSH : token | token Width | token BusBit Width | token BusBit BusBit | token BusBit | Dotted |CurlyList ;
Tokens_list : token ',' Tokens_list | token ;
Width : '[' Expr ':' Expr ']' | '[' Expr plus_range Expr ']' | '[' Expr minus_range Expr ']';
BusBit : '[' Expr ']' ;
ExtDir : input | output | inout | output reg | input wire | output wire | inout wire | input signed | output signed | output reg signed | output logic | input logic ;
IntDir : logic | reg | wire | signed | integer | real | reg signed | wire signed | genvar | supply0 | supply1 | tri0 | tri1 ;
CurlyList : '{' CurlyItems '}' ;
CurlyItems : CurlyItems ',' CurlyItem | CurlyItem;
CurlyItem :
Expr CurlyList
| Expr
| shift_left CurlyList
;
Dotted :
token '.' Dotted
| token '.' token
| token '.' token Width
| token '.' token BusBit
| token '.' token '(' Expr ')'
;
Literal :
number
| floating
| string
| bin | hex | dig | ubin | uhex | udig
;
Expr :
token
| Dotted
| number
| floating
| string
| define
| define '(' Expr ')'
| bin | hex | dig | ubin | uhex | udig
| token Width
| token BusBit Width
| token BusBit BusBit
| token BusBit
| Expr '?' Expr ':' Expr
| Expr '+' Expr
| Expr '*' Expr
| Expr '-' Expr
| Expr '/' Expr
| Expr '%' Expr
| Expr '^' Expr
| Expr '|' Expr
| Expr '&' Expr
| Expr '<' Expr
| Expr '>' Expr
| Expr power Expr
| Expr and_and Expr
| Expr or_or Expr
| Expr xnor Expr
| Expr nand Expr
| Expr nor Expr
| Expr eq_eq Expr
| Expr eq3 Expr
| Expr not_eq Expr
| Expr noteqeq Expr
| Expr gr_eq Expr
| Expr sm_eq Expr
| Expr shift_left Expr
| Expr shift_right Expr
| Expr arith_shift_right Expr
| token '(' Exprs ')'
| '(' Expr ')'
| CurlyList
| '-' Expr %prec UNARY_PREC
| '|' Expr %prec UNARY_PREC
| '&' Expr %prec UNARY_PREC
| '^' Expr %prec UNARY_PREC
| xnor Expr %prec UNARY_PREC
| nor Expr %prec UNARY_PREC
| nand Expr %prec UNARY_PREC
| '!' Expr %prec UNARY_PREC
| '~' Expr %prec UNARY_PREC
;
%%
|
<reponame>vasileiosbi/XRT<filename>tests/unit_test/013_montecarlo/testinfo.yml
#template_tql < $RDI_TEMPLATES/sdx/sdaccel/swhw/template.tql
description: testinfo generated using import_sdx_test.py script
level: 6
owner: sonals
user:
allowed_test_modes: [sw_emu, hw]
force_makefile: "--force"
host_args: {all: -d acc -k kernel.xclbin -i 5}
host_cflags: ' -DDSA64'
host_exe: host.exe
host_src: main.cpp oclErrorCodes.cpp oclHelper.cpp
kernels:
- {cflags: {all: ' -I.'}, file: montecarlo.xo, ksrc: kernel.cl, name: montecarlo, type: C}
name: 013_montecarlo
xclbins:
- files: 'montecarlo.xo '
kernels:
- cus: [montecarlo_cu0]
name: montecarlo
num_cus: 1
name: kernel.xclbin
|
name: cgra_sim_build
commands:
- bash test_build.sh
outputs:
- meta
parameters:
array_width: 12
array_height: 12
pipeline_config_interval: 8
interconnect_only: False
soc_only: False
PWR_AWARE: False
use_container: True
cgra_apps: ["tests/conv_1_2"]
postconditions:
- assert File( 'outputs/meta' ) # must exist
|
%YAML 1.2
---
PF:
wo_ps_sigma_when_vo_is_valid: 0.025
wo_t_sigma_when_vo_is_valid: 0.034
wo_ps_sigma_when_vo_is_invalid: 0.0001
wo_t_sigma_when_vo_is_invalid: 0.0002
|
name: Generate and deploy documentation
on:
push:
branches: [ master ]
jobs:
GenDoc:
name: Generate documentation
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
with:
ghc-version: '9.2.1'
- name: Generate documentation
run: |
haddock --source-module=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/$GITHUB_SHA/%{FILE} \
--source-entity=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/$GITHUB_SHA/%{FILE}#L%{LINE} \
--title=blarney \
--optghc=-XNoImplicitPrelude \
--html \
--odir doc \
$(find Haskell/ -name "*.hs" | grep -v BlarneyPlugins)
- name: Upload documentation artifact
uses: actions/upload-artifact@v2
with:
name: doc
path: doc
PublishDoc:
name: Publish documentation
needs: GenDoc
runs-on: ubuntu-latest
steps:
- name: Download documentation artifact
uses: actions/download-artifact@v2
with:
name: doc
- name: Deploy documentation
run: |
git init
git checkout --orphan haddock
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git config user.name the-blarney-fairy
git config user.email <EMAIL>
git add --all
git commit -m "deploy documentation for $GITHUB_SHA"
git push origin -f haddock
|
name: valgrind OPAE tests
on:
schedule:
- cron: '0 7 * * 0'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: update
run: sudo apt-get update -y
- name: Get Packages
uses: mstksg/get-package@v1
with:
apt-get: uuid-dev libjson-c-dev libhwloc-dev libtbb-dev valgrind
- name: configure
run: mkdir ${{ github.workspace }}/.build && cd ${{ github.workspace }}/.build && cmake .. -DCMAKE_BUILD_TYPE=Debug -DOPAE_ENABLE_MOCK=ON -DOPAE_BUILD_TESTS=ON
- name: make
run: cd ${{ github.workspace }}/.build && make -j
- name: set hugepages
run: sudo sysctl -w vm.nr_hugepages=8
- name: test
continue-on-error: true
run: cd ${{ github.workspace }}/.build && ${{ github.workspace }}/scripts/valgrind ${{ github.workspace }}/.build
env:
OPAE_EXPLICIT_INITIALIZE: 1
LD_LIBRARY_PATH: ${{ github.workspace }}/.build/lib
- name: Archive Results
uses: actions/upload-artifact@v1
with:
name: valgrind
path: ${{ github.workspace }}/.build/valgrind
|
<reponame>idex-biometrics/fusesoc
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
version: 2
sphinx:
configuration: doc/source/conf.py
# Optionally build your docs in additional formats such as PDF and ePub
formats: all
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3
install:
- requirements: doc/requirements.txt
- method: pip
path: .
|
<filename>mkdocs.yml
site_name: "Hardware Generator Debugger"
theme:
name: "material"
nav:
- Overview: "index.md"
- Install and Usage: "usage.md"
- Simulator: "simulator.md"
- Debugger: "debugger.md"
- How it works: "internal.md"
markdown_extensions:
- attr_list
- md_in_html
- admonition
- pymdownx.details
- pymdownx.superfences
plugins:
- mkdocs-video:
css_style:
width: "100vw"
height: "450px"
|
package:
name: tech_cells_generic
description: "Technology-agnostic building blocks."
sources:
- target: all(fpga, xilinx)
files:
- src/cluster_clock_gating_xilinx.sv
- src/pulp_clock_gating_xilinx.sv
- src/pulp_clock_mux2_xilinx.sv
- target: not(all(fpga, xilinx))
files:
- src/cluster_clock_gating.sv
- src/pulp_clock_gating.sv
- src/pulp_clock_mux2.sv
- target: not(synthesis)
files:
- src/cluster_clock_and2.sv
- src/cluster_clock_buffer.sv
- src/cluster_clock_inverter.sv
- src/cluster_clock_mux2.sv
- src/cluster_clock_xor2.sv
- src/cluster_level_shifter_in.sv
- src/cluster_level_shifter_in_clamp.sv
- src/cluster_level_shifter_inout.sv
- src/cluster_level_shifter_out.sv
- src/cluster_level_shifter_out_clamp.sv
- src/generic_memory.sv
- src/generic_rom.sv
- src/pad_functional.sv
- src/pulp_buffer.sv
- src/pulp_clock_and2.sv
- src/pulp_clock_buffer.sv
- src/pulp_clock_gating_async.sv
- src/pulp_clock_inverter.sv
- src/pulp_clock_xor2.sv
- src/pulp_level_shifter_in.sv
- src/pulp_level_shifter_in_clamp.sv
- src/pulp_level_shifter_out.sv
- src/pulp_level_shifter_out_clamp.sv
- src/pulp_power_gating.sv
|
<gh_stars>0
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Azure template for installing dependencies from various package managers,
# necessary for building, testing, and packaging OpenTitan.
#
# This template can be included from pipelines in other repositories.
# In this case, set the the REPO_TOP parameter to point to the root of the
# checked out opentitan repository.
#
# This template executes:
# - apt-get (*) install for all packages listed in apt-requirements.txt
# - pip install for all packages listed in python-requirements.txt
#
# * As an optimization, apt-fast is used instead of apt-get if it is available.
parameters:
- name: REPO_TOP
type: string
default: .
steps:
- bash: |
set -e
# Use apt-fast if available for faster installation.
if command -v apt-fast >/dev/null; then
APT_CMD=apt-fast
else
APT_CMD=apt-get
fi
cd "${{ parameters.REPO_TOP }}"
# Install verilator from experimental OBS repository
# apt-requirements.txt doesn't cover this dependency as we don't support
# using the repository below for anything but our CI (yet).
EDATOOLS_REPO_KEY="https://download.opensuse.org/repositories/home:phiwag:edatools/xUbuntu_$(lsb_release -sr)/Release.key"
EDATOOLS_REPO="deb http://download.opensuse.org/repositories/home:/phiwag:/edatools/xUbuntu_$(lsb_release -sr)/ /"
curl -sL "$EDATOOLS_REPO_KEY" | sudo apt-key add -
sudo sh -c "echo \"$EDATOOLS_REPO\" > /etc/apt/sources.list.d/edatools.list"
cp apt-requirements.txt apt-requirements-ci.txt
echo "verilator-$(VERILATOR_VERSION)" >> apt-requirements-ci.txt
echo "openocd-$(OPENOCD_VERSION)" >> apt-requirements-ci.txt
echo rsync >> apt-requirements-ci.txt
cat apt-requirements-ci.txt
# Ensure apt package index is up-to-date.
sudo $APT_CMD update
# NOTE: We use sed to remove all comments from apt-requirements-ci.txt,
# since apt-get/apt-fast doesn't actually provide such a feature.
sed 's/#.*//' apt-requirements-ci.txt \
| xargs sudo $APT_CMD install -y
# Python requirements are installed to the local user directory so prepend
# appropriate bin directory to the PATH
export PATH=$HOME/.local/bin:$PATH
# Explicitly updating pip and setuptools is required to have these tools
# properly parse Python-version metadata, which some packages uses to
# specify that an older version of a package must be used for a certain
# Python version. If that information is not read, pip installs the latest
# version, which then fails to run.
python3 -m pip install --user -U pip setuptools
pip3 install --user -r python-requirements.txt
# Install Verible
mkdir -p build/verible
cd build/verible
curl -Ls -o verible.tar.gz "https://github.com/google/verible/releases/download/$(VERIBLE_VERSION)/verible-$(VERIBLE_VERSION)-Ubuntu-$(lsb_release -sr)-$(lsb_release -sc)-x86_64.tar.gz"
sudo mkdir -p /tools/verible && sudo chmod 777 /tools/verible
tar -C /tools/verible -xf verible.tar.gz --strip-components=1
# Propagate PATH changes to all subsequent steps of the job
echo "##vso[task.setvariable variable=PATH]/tools/verible/bin:$PATH"
displayName: 'Install package dependencies'
|
<reponame>recogni/bigpulp<gh_stars>10-100
components:
incdirs: [
../includes,
]
files: [
axi_slice_dc_master_wrap.sv,
axi_slice_dc_slave_wrap.sv,
generic_memory.sv,
pulp_interfaces.sv,
]
|
name: 'Update Pyodide package'
description: 'Update the WASM compiled Pygments with Pyodide'
runs:
using: 'docker'
image: 'birkenfeld/pyodide-pygments-builder'
|
before_script:
# paths to local or network installations (the riscv toolchain and
# verilator are not built in the ci job as in travis)
- export QUESTASIM_HOME=/usr/pack/modelsim-10.6b-kgf/questasim/
- export QUESTASIM_VERSION=-10.6b
- export QUESTASIM_FLAGS=-noautoldlibpath
- export CXX=g++-7.2.0 CC=gcc-7.2.0
- export RISCV=/usr/scratch2/larain1/gitlabci/riscv_install
- export VERILATOR_ROOT=/usr/scratch2/larain1/gitlabci/verilator-3.924
# setup dependent paths
- export PATH=${RISCV}/bin:$VERILATOR_ROOT/bin:${PATH}
- export LIBRARY_PATH=$RISCV/lib
- export LD_LIBRARY_PATH=$RISCV/lib:/usr/pack/gcc-7.2.0-af/linux-x64/lib64/
- export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include:/usr/pack/gcc-7.2.0-af/linux-x64/include
- export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include:/usr/pack/gcc-7.2.0-af/linux-x64/include
# number of parallel jobs to use for make commands and simulation
- export NUM_JOBS=4
- ci/make-tmp.sh
- git submodule update --init --recursive
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
- test_std
# prepare
build:
stage: build
script:
- ci/build-riscv-tests.sh
- ci/get-torture.sh
- make clean
- make torture-gen
artifacts:
paths:
- tmp
# rv64ui-p-* and rv64ui-v-* tests
run-asm-tests-questa:
stage: test_std
script:
- make -j${NUM_JOBS} run-asm-tests
dependencies:
- build
run-benchmarks-questa:
stage: test_std
script:
- make -j${NUM_JOBS} run-benchmarks
dependencies:
- build
torture:
stage: test_std
script:
- make torture-rtest
dependencies:
- build
|
---
# YML file to print Hello World in ansible.
- name: Hello World!
hosts: localhost
connection: local
gather_facts: no
tasks: # Debug is used to print Hello World.
- debug:
msg: "Hello World!"
|
<gh_stars>0
# Copyright 2020 ETH Zurich and University of Bologna.
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51
package:
name: system-occamy
authors:
- <NAME> <<EMAIL>>
- <NAME> <<EMAIL>>
dependencies:
# axi_riscv_atomics: {path: ../../vendor/pulp_platform_axi_riscv_atomics}
snitch_const_cache: {path: ../../ip/snitch_const_cache}
snitch-cluster: {path: ../../ip/snitch_cluster}
export_include_dirs:
- include
sources:
# Level 0:
- src/occamy_cluster_wrapper.sv
# Level 1:
- src/occamy_pkg.sv
# Level 2:
- src/occamy_quadrant_s1.sv
# Level 3:
- src/occamy_top.sv
# # Level 3:
# - target: any(simulation, verilator)
# files:
# - test/tb_memory.sv
# - test/testharness.sv
# # Level 4:
# - target: test
# files:
# - test/tb_bin.sv
|
<reponame>Koheron/koheron-sdk<filename>examples/red-pitaya/phase-noise-analyzer/config.yml
---
name: phase-noise-analyzer
board: boards/red-pitaya
version: 0.1.0
cores:
- fpga/cores/axi_ctl_register_v1_0
- fpga/cores/axi_sts_register_v1_0
- fpga/cores/dna_reader_v1_0
- fpga/cores/axis_constant_v1_0
- fpga/cores/latched_mux_v1_0
- fpga/cores/tlast_gen_v1_0
- fpga/cores/redp_adc_v1_0
- fpga/cores/redp_dac_v1_0
- fpga/cores/axis_lfsr_v1_0
- fpga/cores/phase_unwrapper_v1_0
- fpga/cores/boxcar_filter_v1_0
memory:
- name: control
offset: '0x40000000'
range: 4K
- name: status
offset: '0x50000000'
range: 4K
- name: xadc
offset: '0x43C00000'
range: 64K
- name: ram
offset: '0x1E000000'
range: 32M
- name: dma
offset: '0x80000000'
range: 64K
- name: axi_hp0
offset: '0xF8008000'
range: 4K
control_registers:
- led
- phase_incr[4]
- cordic
status_registers:
- adc[n_adc]
parameters:
fclk0: 125000000
fclk1: 125000000
adc_clk: 125000000
dac_width: 16
adc_width: 16
n_adc: 2
cic_differential_delay: 1
cic_decimation_rate: 20
cic_n_stages: 6
xdc:
- boards/red-pitaya/config/ports.xdc
- boards/red-pitaya/config/clocks.xdc
drivers:
- server/drivers/common.hpp
- ./dds.hpp
- ./dma.hpp
web:
- web/index.html
- web/main.css
- web/koheron.ts
|
---
algorithm:
class: Nsga2
population_size: 200
probabilities:
crossover: 0.5
mutation: 0.1
injection: 0.4
shorten_individual: true
init:
method: ramped # grow or full or ramped
sensible_depth: 7
inject:
method: grow # grow or full or random
sensible_depth: 7
termination:
max_steps: 1000
on_individual: stopping_condition
grammar:
class: Abnf::File
filename: sample/toy_regression/grammar.abnf
mapper:
class: DepthLocus
crossover:
class: CrossoverRipple
margin: 2 #1
step: 2
mutation:
class: MutationRipple
store:
class: Store
filename: ./toy_nsga2.store
report:
class: ToyReport
require: sample/toy_regression/toy_report.rb
individual:
class: ToyIndividualMOStrict # ToyIndividualMOWeak
require: sample/toy_regression/toy_individual.rb
shorten_chromozome: false
|
<reponame>slaclab/amc-carrier-core<gh_stars>1-10
##############################################################################
## This file is part of 'LCLS2 Common Carrier Core'.
## It is subject to the license terms in the LICENSE.txt file found in the
## top-level directory of this distribution and at:
## https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
## No part of 'LCLS2 Common Carrier Core', including this file,
## may be copied, modified, propagated, or distributed except according to
## the terms contained in the LICENSE.txt file.
##############################################################################
#schemaversion 3.0.0
#once RtmDigitalDebug.yaml
RtmDigitalDebug: &RtmDigitalDebug
name: RtmDigitalDebug
description: RtmDigitalDebug Module
class: MMIODev
configPrio: 1
size: 0x100
children:
#########################################################
DisableOutputs:
at:
offset: 0x00
class: IntField
name: DisableOutputs
mode: RW
sizeBits: 16
description: 16-bit Output Disable Mask
#########################################################
FpgaPllLock:
at:
offset: 0x08
class: IntField
name: FpgaPllLock
mode: RO
sizeBits: 1
description: FPGA PLL Lock status
#########################################################
|
language: bash
addons:
apt:
update: true
packages:
- mtools
script:
- bash compiler/get_compiler.sh
- bash part-1/armc-03/build.sh rpi0
- bash part-1/armc-03/build.sh rpi1
- bash part-1/armc-03/build.sh rpi2
- bash part-1/armc-03/build.sh rpi3bp
- bash part-1/armc-03/build.sh rpi4
|
# Copyright 2020 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Run functional regression checks
name: ci
on: [push]
jobs:
###########
# Banshee #
###########
Banshee:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- beta
- nightly
- 1.46.0 # minimum supported version
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt
- uses: KyleMayes/install-llvm-action@v1
with:
version: '10.0'
directory: ${{ runner.temp }}/llvm
- working-directory: sw/banshee
run: cargo build
- working-directory: sw/banshee
run: cargo test --all
- working-directory: sw/banshee
run: make test TERM=xterm-256color LOG_FAILED=`mktemp` LOG_TOTAL=`mktemp`
#################
# SW on Banshee #
#################
sw-banshee:
runs-on: ubuntu-latest
name: SW on Banshee
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: KyleMayes/install-llvm-action@v1
with:
version: '10.0'
directory: ${{ runner.temp }}/llvm
- working-directory: sw/banshee
run: cargo install --path .
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: 3.19.x
- name: Install RISC-V Toolchain
run: |
curl -Ls -o riscv-gcc.tar.gz https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-${RISCV_GCC_VERSION}-x86_64-linux-ubuntu14.tar.gz
sudo mkdir -p /tools/riscv && sudo chmod 777 /tools/riscv
tar -C /tools/riscv -xf riscv-gcc.tar.gz --strip-components=1
cd /tools/riscv/bin && for file in riscv64-*; do ln -s $file $(echo "$file" | sed 's/^riscv64/riscv32/g'); done
echo "PATH=$PATH:/tools/riscv/bin" >> $GITHUB_ENV
env:
RISCV_GCC_VERSION: 8.3.0-2020.04.0
- name: Build runtime
working-directory: sw/snRuntime
run: mkdir build && cd build && cmake .. && make
- name: Test snRuntime
working-directory: sw/snRuntime/build
run: make test
- name: Build snBLAS
working-directory: sw/snBLAS
run: mkdir build && cd build && cmake .. && make
- name: Test snBLAS
working-directory: sw/snBLAS/build
run: make test
#############################
# SW on Banshee (Container) #
#############################
snRuntime:
container:
image: ghcr.io/pulp-platform/snitch
runs-on: ubuntu-18.04
name: SW on Banshee (Container)
steps:
- uses: actions/checkout@v2
- name: Build runtime
working-directory: sw/snRuntime
run: mkdir build && cd build && cmake .. && make
- name: Test snRuntime
working-directory: sw/snRuntime/build
run: make test
- name: Build snBLAS
working-directory: sw/snBLAS
run: mkdir build && cd build && cmake .. && make
- name: Test snBLAS
working-directory: sw/snBLAS/build
run: make test
################################
# SW on Default Snitch Cluster #
################################
sw-snitch-cluster-default:
container:
image: ghcr.io/pulp-platform/snitch
name: SW on Default Snitch Cluster Config
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Build Hardware
run: |
cd hw/system/snitch_cluster && make bin/snitch_cluster.vlt
- name: Build Software
run: |
cd hw/system/snitch_cluster/sw && mkdir build && cd build && cmake .. && make
- name: Run Unit Tests
run: |
cd hw/system/snitch_cluster/sw/build && make test
|
<filename>.travis.yml
dist: bionic
language: cpp
compiler: gcc
git:
depth: 5
submodules: false
before_install:
- sudo apt-get install -y make autoconf g++ flex bison libfl-dev
- |
if [[ ! -d "$HOME/verilator-4.014/bin" ]]; then
pushd $HOME
curl --retry 10 --retry-max-time 120 -L \
"https://www.veripool.org/ftp/verilator-4.014.tgz" | tar xfz -
cd verilator-4.014
./configure && make -j2
popd
fi
- |
pushd $HOME/verilator-4.014
sudo make install
popd
- verilator --version
script:
- cd sim/verilator
- make test_all
cache:
apt: true
directories:
- $HOME/verilator-4.014
|
<filename>ivas-platforms/Embedded/zcu104_vcuDec_vmixHdmiTx/petalinux/build/misc/config/data/sysconf_koptions.yaml
selected_device:
flash:
is_valid_and:
SUBSYSTEM_FLASH_MANUAL_SELECT: n
linux_kernel_properties:
MTD: bool y
MTD_OF_PARTS: bool y
serial:
is_valid_and:
SUBSYSTEM_SERIAL_MANUAL_SELECT: n
linux_kernel_properties:
SERIAL_OF_PLATFORM: bool y
ethernet:
is_valid_and: SUBSYSTEM_ETHERNET_MANUAL_SELECT n
linux_kernel_properties:
NET: bool y
PACKET: bool y
UNIX: bool y
INET: bool y
pmufw_enable:
is_valid_and:
SUBSYSTEM_PMUFW_POWER_KERNEL_CONFIGURATION_ENABLE: y
linux_kernel_properties:
SUSPEND: bool y
PM_WAKELOCKS: bool y
PM: bool y
CPU_IDLE: bool y
ARM_CPUIDLE: bool y
CPU_FREQ: bool y
CPU_FREQ_DEFAULT_GOV_USERSPACE: bool y
CPU_FREQ_GOV_USERSPACE: bool y
COMMON_CLK_ZYNQMP: bool y
SOC_XILINX_ZYNQMP: bool y
ZYNQMP_PM_DOMAINS: bool y
PM_SLEEP: bool y
pmufw_disable:
is_valid_and:
SUBSYSTEM_PMUFW_POWER_KERNEL_CONFIGURATION_DISABLE: y
linux_kernel_properties:
SUSPEND: bool n
PM_WAKELOCKS: bool n
PM: bool n
CPU_IDLE: bool n
ARM_CPUIDLE: bool n
CPU_FREQ: bool n
CPU_FREQ_DEFAULT_GOV_USERSPACE: bool n
CPU_FREQ_GOV_USERSPACE: bool n
COMMON_CLK_ZYNQMP: bool n
SOC_XILINX_ZYNQMP: bool n
ZYNQMP_PM_DOMAINS: bool n
PM_SLEEP: bool n
|
<gh_stars>1-10
rbe:
vlog_opts: [
+nowarnSVCHK,
-suppress 2275,
-L hwpe_stream_lib,
-L hwpe_ctrl_lib,
-L hci_lib,
]
incdirs: [
.,
../hwpe-stream/rtl,
../hwpe-ctrl/rtl,
]
files: [
rtl/rbe_package.sv,
rtl/rbe_accumulators_scm.sv,
rtl/rbe_accumulator_normquant.sv,
rtl/rbe_normquant.sv,
rtl/rbe_normquant_multiplier.sv,
rtl/rbe_input_register.sv,
rtl/rbe_binconv_sop.sv,
rtl/rbe_binconv_scale.sv,
rtl/rbe_binconv_block.sv,
rtl/rbe_binconv_column.sv,
rtl/rbe_binconv_array.sv,
rtl/rbe_engine_core.sv,
rtl/rbe_engine.sv,
rtl/rbe_ctrl_fsm.sv,
rtl/rbe_ctrl.sv,
rtl/rbe_streamer.sv,
rtl/rbe_top.sv,
rtl/rbe_top_wrap.sv,
# rtl/rbe_fake_engine_wrap.sv,
]
|
dsp_test:
before_script:
- cd dsp && export PYTHONPATH=../build-tools/
stage: test
script:
- make && make checks
digaree_test:
before_script:
- cd dsp/digaree
stage: test
script:
- make
feedforward_test:
before_script:
- cd dsp/feedforward
stage: test
script:
- make
chirp_test:
before_script:
- cd dsp/chirp
stage: test
script:
- make && make checks
|
<gh_stars>10-100
---
name: cluster
board: boards/red-pitaya
version: 0.1.1
cores:
- fpga/cores/axi_ctl_register_v1_0
- fpga/cores/axi_sts_register_v1_0
- fpga/cores/dna_reader_v1_0
- fpga/cores/redp_adc_v1_0
- fpga/cores/redp_dac_v1_0
- fpga/cores/axis_variable_v1_0
- fpga/cores/bus_multiplexer_v1_0
- fpga/cores/pulse_generator_v1_0
- fpga/cores/edge_detector_v1_0
memory:
- name: control
offset: '0x60000000'
range: 4K
- name: status
offset: '0x50000000'
range: 4K
- name: ctl_clk
offset: '0x70000000'
range: 4K
control_registers:
- led
- phase_incr[2]
- ctl_sata
- pulse_width
- pulse_period
- trigger
status_registers:
- adc[n_adc]
- sts_sata
parameters:
fclk0: 200000000
adc_clk: 125000000
dac_width: 14
adc_width: 14
n_dac: 2
n_adc: 2
xdc:
- ./ports.xdc
- boards/red-pitaya/config/clocks.xdc
- ./sata.xdc
- ./expansion_connector.xdc
drivers:
- server/drivers/common.hpp
- ./cluster.hpp
web:
- web/index.html
- web/main.css
- web/koheron.ts
|
# Technology Setup
vlsi.core.technology: <tech_name>
vlsi.core.technology_path: ["hammer-<tech_name>-plugin"]
vlsi.core.technology_path_meta: append
# technology files installation directory
technology.<tech_name>.install_dir: "</path/to/technology/pdk/>"
|
---
name: spectrum
board: boards/red-pitaya
control_registers:
- substract_mean
- ctl_fft
status_registers:
parameters:
bram_addr_width: 12
adc_width: 14
|
<gh_stars>1-10
theme: jekyll-theme-dinky
title: RISC-V Timer
description: RISC-V Compliant Timer IP
show_downloads: true
show_license: true
license: Non-Commercial License
|
<reponame>hackdac/hackdac_2018_beta
tech_cells_rtl:
flags: [
skip_synthesis,
]
files: [
cluster_clock_gating.sv,
pulp_clock_gating.sv,
pulp_clock_mux2.sv,
pulp_clock_buffer.sv,
pulp_clock_inverter.sv,
pulp_clock_xor2.sv,
pulp_buffer.sv,
pulp_level_shifter_in.sv,
pulp_level_shifter_in_clamp.sv,
pulp_level_shifter_out.sv,
pulp_level_shifter_out_clamp.sv,
pulp_clock_and2.sv,
cluster_clock_buffer.sv,
cluster_clock_inverter.sv,
cluster_clock_mux2.sv,
cluster_clock_xor2.sv,
cluster_level_shifter_in.sv,
cluster_level_shifter_in_clamp.sv,
cluster_level_shifter_out.sv,
cluster_level_shifter_out_clamp.sv,
cluster_clock_and2.sv,
pulp_clock_gating_async.sv,
pulp_power_gating.sv,
generic_rom.sv,
generic_memory.sv,
pad_functional.sv,
]
tech_cells_fpga:
targets: [
xilinx,
]
files: [
cluster_clock_gating_xilinx.sv,
pulp_clock_gating_xilinx.sv,
pulp_clock_mux2_xilinx.sv,
pulp_clock_buffer.sv,
pulp_clock_inverter.sv,
pulp_clock_xor2.sv,
pulp_buffer.sv,
pulp_level_shifter_in.sv,
pulp_level_shifter_in_clamp.sv,
pulp_level_shifter_out.sv,
pulp_level_shifter_out_clamp.sv,
pulp_clock_and2.sv,
cluster_clock_buffer.sv,
cluster_clock_inverter.sv,
cluster_clock_mux2.sv,
cluster_clock_xor2.sv,
cluster_level_shifter_in.sv,
cluster_level_shifter_in_clamp.sv,
cluster_level_shifter_out.sv,
cluster_level_shifter_out_clamp.sv,
cluster_clock_and2.sv,
pulp_clock_gating_async.sv,
pulp_power_gating.sv,
]
|
<reponame>antmicro/trace_debugger<filename>src_files.yml<gh_stars>1-10
trace_debugger:
incdirs: [
include,
]
files: [
include/trdb_pkg.sv,
rtl/trace_debugger_stimuli_gen.sv,
rtl/trace_debugger.sv,
rtl/tracer_if.sv,
rtl/tracer_reg_if.sv,
rtl/trdb_apb_if.sv,
rtl/trdb_branch_map.sv,
rtl/trdb_packet_emitter.sv,
rtl/trdb_priority.sv,
rtl/trdb_reg.sv,
rtl/trdb_align.sv,
rtl/trdb_align8.sv,
rtl/trdb_timer.sv,
rtl/trdb_filter.sv,
rtl/trdb_lzc.sv,
]
|
common_cells:
commit: v1.21.0
group: pulp-platform
common_verification:
commit: v0.2.0
group: pulp-platform
|
<reponame>cloudfoundry-community/bosh-cloudstack-cpi-core
logging:
level:
org.springframework: INFO
org.springframework.boot.actuate: DEBUG
org.apache.http.client: DEBUG
management:
context-path: /admin
spring:
application:
name: cloudstack-cpi
main:
show-banner: true
jackson:
deserialization:
ACCEPT_SINGLE_VALUE_AS_ARRAY: true
jpa:
hibernate:
ddl-auto: none
profiles:
active: ikoula
pidfile: ./target/application.pid
sleuth:
sampler:
percentage: 1.0
zipkin:
enabled: true
base-url: http://zipkin-server
datasource:
url: jdbc:hsqldb:file:./target/testdb
# username: sa
# password: sa
# driverClassName: org.hsql.Driver
server:
tomcat:
access-log-enabled: true
---
spring:
profiles: ikoula
cloudstack:
endpoint: https://cloudstack.ikoula.com/client/api
proxy_host:
proxy_port: 8080
proxy_user: zz
proxy_password: <PASSWORD>
api_key: xxx
secret_access_key: yyy
default_key_name: bosh-keypair
private_key: zz
state_timeout: 600
state_timeout_volume: 600
stemcell_public_visibility: true
stemcell_publish_timeout: 5
stemcell_requires_hvm: true
stemcell_os_type: Other PV (64-bit)
# stemcell_os_type: Ubuntu 14.04 (64-bit)
default_zone: EU-FR-IKDC1-Z1-ADV
cpi:
vm_create_delay: 15
vm_expunge_delay: 30
force_expunge: true
use_dhcp: false
webdav_host: 127.0.0.1
webdav_port: 8080
webdav_directory: "/tmp"
calculate_vm_cloud_properties:
disk:
tags: SCALEIO
compute:
tags: SCALEIO
core:
user: cpi
password: <PASSWORD>
default_disk_offering: "Data disk"
default_ephemeral_disk_offering: "Data disk"
lightstemcell:
network_name: "orange-private"
instance_type: "m1.small"
registry:
endpoint: http://127.0.0.1:8080
user: admin
password: <PASSWORD>
blobstore:
provider: local
path: /var/vcap/micro_bosh/data/cache
address: xx.xx.xx.xx
port: 25250
options:
user: agent
password: password
agent:
mbus: "nats://nats:[email protected]:4222"
ntp: "[xx.xx.xx.xx ,yy.yy.yy.yy]"
|
<reponame>AlSaqr-platform/cva6<gh_stars>1-10
# File auto-generated by Padrick 0.1.0.post0.dev49+g9979c54.dirty
alsaqr_periph_padframe:
files:
- src/pkg_alsaqr_periph_padframe.sv
- src/pkg_internal_alsaqr_periph_padframe_periphs.sv
- src/alsaqr_periph_padframe_periphs_config_reg_pkg.sv
- src/alsaqr_periph_padframe_periphs_config_reg_top.sv
- src/alsaqr_periph_padframe_periphs_pads.sv
- src/alsaqr_periph_padframe_periphs.sv
- src/alsaqr_periph_padframe.sv
vlog_opts:
- -L axi_lib
|
<filename>setup/docker/dockerfiles/gpu_conda/vitis-ai-caffe.yml
name: vitis-ai-caffe
channels:
- conda-forge
- anaconda
dependencies:
- python=3.6
- caffe_decent_gpu
- vaic
- vart
- rt-engine
|
# RUN: lld -flavor darwin -arch x86_64 -macosx_version_min 10.9 -twolevel_namespace -undefined dynamic_lookup %s -o %t %p/Inputs/libSystem.yaml
#
# Sanity check '-twolevel_namespace -undefined dynamic_lookup'.
# This should pass without error, even though '_bar' is undefined.
--- !native
defined-atoms:
- name: _main
scope: global
content: [ E9, 00, 00, 00, 00 ]
alignment: 16
references:
- kind: branch32
offset: 1
target: _bar
undefined-atoms:
- name: _bar
|
<filename>.travis.yml
notifications:
email:
recipients:
- <EMAIL>
on_success: always
on_failure: always
language: java
jdk:
# - oraclejdk8
# - oraclejdk9
# - oraclejdk11
- openjdk8
# - openjdk9
# - openjdk10
- openjdk11
branches:
only:
- master
# Download jars zip
before_install:
# Rate limiting will cause this command to fail, we'll need to hard code the jars path for now
#- curl -s https://api.github.com/repos/Xilinx/RapidWright/releases/latest | grep '/rapidwright_jars.zip' | awk -F'"' '{print $4}' | wget -i -
- wget https://github.com/Xilinx/RapidWright/releases/download/v2019.1.2-beta/rapidwright_jars.zip
- unzip rapidwright_jars.zip
|
name: 'VUnit Action'
description: 'Automatically test your VHDL code with VUnit'
inputs:
cmd:
description: 'VUnit run script or command (Python)'
default: './run.py'
image:
description: 'Container image to run the script/command on'
default: ghdl/vunit:mcode
runs:
using: "composite"
steps:
- run: docker run --rm -v $(pwd):/src -w /src ${{ inputs.image }} ${{ inputs.cmd }}
shell: bash
branding:
icon: cpu
color: blue
|
scm:
vlog_opts: [
+nowarnSVCHK,
]
targets: [
rtl,
tsmc55,
gf22,
]
files: [
latch_scm/register_file_1r_1w_test_wrap.sv,
latch_scm/register_file_1w_64b_multi_port_read_32b_1row.sv,
latch_scm/register_file_1w_multi_port_read_1row.sv,
latch_scm/register_file_1r_1w_all.sv,
latch_scm/register_file_1r_1w_all_test_wrap.sv,
latch_scm/register_file_1r_1w_be.sv,
latch_scm/register_file_1r_1w.sv,
latch_scm/register_file_1r_1w_1row.sv,
latch_scm/register_file_1w_128b_multi_port_read_32b.sv,
latch_scm/register_file_1w_64b_multi_port_read_32b.sv,
latch_scm/register_file_1w_64b_1r_32b.sv,
latch_scm/register_file_1w_multi_port_read_be.sv,
latch_scm/register_file_1w_multi_port_read.sv,
latch_scm/register_file_2r_1w_asymm.sv,
latch_scm/register_file_2r_1w_asymm_test_wrap.sv,
latch_scm/register_file_2r_2w.sv,
latch_scm/register_file_3r_2w.sv,
latch_scm/register_file_3r_2w_be.sv,
latch_scm/register_file_multi_way_1w_64b_multi_port_read_32b.sv,
latch_scm/register_file_multi_way_1w_multi_port_read.sv,
]
scm_fpga:
vlog_opts: [
+nowarnSVCHK,
]
targets: [
xilinx,
]
files: [
fpga_scm/register_file_1r_1w_all.sv,
fpga_scm/register_file_1r_1w_be.sv,
fpga_scm/register_file_1r_1w.sv,
fpga_scm/register_file_1r_1w_1row.sv,
fpga_scm/register_file_1r_1w_raw.sv,
fpga_scm/register_file_1w_multi_port_read.sv,
fpga_scm/register_file_1w_64b_multi_port_read_32b.sv,
fpga_scm/register_file_1w_64b_1r_32b.sv,
fpga_scm/register_file_2r_1w_asymm.sv,
fpga_scm/register_file_2r_1w_asymm_test_wrap.sv,
fpga_scm/register_file_2r_2w.sv,
fpga_scm/register_file_3r_2w.sv,
fpga_scm/register_file_3r_2w_be.sv,
]
|
input: doc
output: _build
requirements: requirements.txt
target: gh-pages
formats: [ html, pdf, man ]
theme: https://codeload.github.com/buildthedocs/sphinx.theme/tar.gz/v1
|
<gh_stars>100-1000
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
sphinx:
configuration: doc/conf.py
formats:
- pdf
python:
install:
- requirements: doc/requirements.txt
|
<filename>.travis.yml<gh_stars>1-10
language: cpp
# cache results
cache:
directories:
- $TRAVIS_BUILD_DIR/abc
- $TRAVIS_BUILD_DIR/yosys
- $TRAVIS_BUILD_DIR/ace2
# - $TRAVIS_BUILD_DIR/libs
- $HOME/.ccache
# - $HOME/deps
# Currently sudo is not required, NO ENV is used
# Supported Operating systems
dist: bionic
#compiler: g++-8
addons:
apt:
sources:
- ubuntu-toolchain-r-test # For newer GCC
- llvm_toolchain-trusty-7
packages:
- autoconf
- automake
- bash
- bison
- build-essential
- cmake
- ctags
- curl
- doxygen
- flex
- fontconfig
- gdb
- git
- gperf
- iverilog
- libcairo2-dev
- libevent-dev
- libfontconfig1-dev
- liblist-moreutils-perl
- libncurses5-dev
- libx11-dev
- libxft-dev
- libxml++2.6-dev
- perl
- python
- python-lxml
- texinfo
- time
- valgrind
- zip
- qt5-default
- clang-format-7
# Add all the supported compilers
- g++-5
- gcc-5
- g++-6
- gcc-6
- g++-7
- gcc-7
- g++-8
- gcc-8
- g++-9
- gcc-9
- clang-6.0
- clang-8
#- os: osx
# osx_image: xcode10.2 # we target latest MacOS Mojave
# sudo: true
# compiler: gcc-4.9 # Use clang instead of gcc in MacOS
# addons:
# homebrew:
# packages:
# - bison
# - cmake
# - ctags
# - flex
# - fontconfig
# - git
# - gcc@6
# - [email protected]
# - gawk
# - icarus-verilog
# - libxml++
# - qt5
# Use gcc-8 as default compiler
env:
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
before_script:
- source .travis/common.sh
- source .travis/install.sh
stages:
- name: Test
if: type != cron
jobs:
include:
- stage: Test
name: "Basic regression tests"
script:
- source .travis/build.sh
- source .travis/basic_reg_test.sh
- stage: Test
name: "FPGA-Verilog regression tests"
script:
- source .travis/build.sh
- source .travis/fpga_verilog_reg_test.sh
- stage: Test
name: "FPGA-Bitstream regression tests"
script:
- source .travis/build.sh
- source .travis/fpga_bitstream_reg_test.sh
- stage: Test
name: "FPGA-SDC regression tests"
script:
- source .travis/build.sh
- source .travis/fpga_sdc_reg_test.sh
- stage: Test
name: "FPGA-SPICE regression tests"
script:
- source .travis/build.sh
- source .travis/fpga_spice_reg_test.sh
- stage: Test
name: "Build Compatibility: GCC-5 (Ubuntu Bionic 18.04)"
env:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
script:
- source .travis/build.sh
- stage: Test
name: "Build Compatibility: GCC-6 (Ubuntu Bionic 18.04)"
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
script:
- source .travis/build.sh
- stage: Test
name: "Build Compatibility: GCC-7 (Ubuntu Bionic 18.04)"
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
script:
- source .travis/build.sh
- stage: Test
name: "Build Compatibility: GCC-8 (Ubuntu Bionic 18.04)"
env:
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
script:
- source .travis/build.sh
- stage: Test
name: "Build Compatibility: GCC-9 (Ubuntu Bionic 18.04)"
env:
- MATRIX_EVAL="CC=gcc-9 && CXX=g++-9"
script:
- source .travis/build.sh
- stage: Test
name: "Build Compatibility: Clang-6 (Ubuntu Bionic 18.04)"
env:
- MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
script:
- source .travis/build.sh
- stage: Test
name: "Build Compatibility: Clang-8 (Ubuntu Bionic 18.04)"
env:
- MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
script:
- source .travis/build.sh
#after_failure:
# - .travis/after_failure.sh
#after_success:
# - .travis/after_success.sh
script:
- true
notifications:
slack:
secure: <KEY>
|
---
# Firmware folder relative to repository root
firmwareFolder: firmware/fox_hoplite
hdlFolder: hdl/fox_hoplite
|
pulp_soc:
incdirs: [
../includes,
]
files: [
apb_soc_ctrl.sv,
axi2apb_wrap.sv,
axi_id_remap_wrap.sv,
axi_mem_if_wrap.sv,
axi_node_intf_wrap.sv,
axi_node_intf_wrap_with_slices.sv,
axi_rab_wrap.sv,
axi_slice_wrap.sv,
l2_generic.sv,
l2_mem.sv,
soc_bus_wrap.sv,
soc_peripherals.sv,
pulp_cluster_wrap.sv,
pulp_soc.sv,
]
|
<reponame>iicarus-bit/google-ctf
secretGenerator:
- name: challenge-skeleton-secrets
files:
- flag
generatorOptions:
disableNameSuffixHash: true
labels:
type: generated
annotations:
note: generated
|
<reponame>parzival3/Surelog
package:
name: register_interface
authors: ["<NAME> <<EMAIL>>"]
dependencies:
axi: { git: "https://github.com/pulp-platform/axi.git", version: 0.4.5 }
sources:
- src/reg_intf.sv
- src/reg_uniform.sv
- src/axi_lite_to_reg.sv
- src/apb_to_reg.sv
- target: test
files:
- src/reg_test.sv
|
---
project:
description: "SoC by the team of Undergraduate students at Purdue University, aimed To Be Integrated Into Low Power Iot Systems"
foundry: "SkyWater"
git_url: "https://github.com/Purdue-SoCET/AFTx06_Private.git"
organization: "SoCET-Purdue"
organization_url: "https://engineering.purdue.edu/SoC-Team/about"
owner: "<NAME>"
process: "SKY130"
project_name: "Caravel"
project_id: "00000000"
tags:
- "Open MPW"
- "Test Harness"
category: "Test Harness"
top_level_netlist: "caravel/verilog/gl/caravel.v"
user_level_netlist: "verilog/gl/user_project_wrapper.v"
version: "1.00"
cover_image: "docs/source/_static/caravel_harness.png"
|
<filename>mkdocs.yml
site_name: Ashet Home Computer
site_url: https://ashet.computer/
site_author: Felix "xq" QueiΓner
site_description: The Ashet Home Computer is a self-made late 80ies style inspired home computer with a 16 bit cpu.
repo_url: https://github.com/MasterQ32/spu-mark-ii/
edit_uri: ''
docs_dir: documentation
site_dir: website-out
nav:
- 'Live Demo': livedemo.md
- 'Documentation':
- 'Specifications':
- 'SPU Mark II': specs/spu-mark-ii.md
- 'Ashet': specs/ashet.md
- 'Datasheet':
- 'TinyUART': specs/uart.md
- 'SimpleMMU': specs/mmu.md
- 'IRQ Controller': specs/irq.md
- 'BasicVGA': specs/vga.md
- 'PS/2': specs/ps2.md
- 'OverkillDMA': specs/dma.md
- 'Ethernet': specs/eth.md
- 'IDE Interface': specs/ide.md
- 'Joystick Interface': specs/joystick.md
- 'IEEE 1284 II Parallel Port': specs/parport.md
- 'PCM Audio': specs/pcm.md
- 'Real Time Clock': specs/rtc.md
- 'Timer': specs/timer.md
- 'Application Notes':
- 'AN000 - Understanding the Instruction Set': 'app-notes/AN000 - Understanding the Instruction Set.md'
- 'AN001 - The SPU Assembly Language': 'app-notes/AN001 - The SPU Assembly Language.md'
- 'AN002 - Standard Calling Convention': 'app-notes/AN002 - Standard Calling Convention.md'
- 'AN003 - Writing efficient code': 'app-notes/AN003 - Writing efficient code.md'
- 'Manuals':
- 'Assembler': manuals/assembler.md
- 'Disassembler': manuals/disassembler.md
- 'Ashet Emulator': manuals/ashet-emulator.md
- 'Basic System Emulator': manuals/basic-emulator.md
- 'Ashet OS':
- 'Overview': os/index.md
- 'Syscalls': os/syscalls.md
theme:
name: mkdocs
nav_style: light
|
<filename>litex_things/deps/migen/conda/migen/meta.yaml
package:
name: migen
version: {{ environ.get("GIT_DESCRIBE_TAG", "") }}
source:
git_url: ../..
build:
noarch: python
number: {{ environ.get("GIT_DESCRIBE_NUMBER", 0) }}
string: py35_{{ environ.get("GIT_DESCRIBE_NUMBER", 0) }}+git{{ environ.get("GIT_DESCRIBE_HASH", "")[1:] }}
script: python setup.py install
requirements:
build:
- python 3.5*
- sphinx
- sphinx_rtd_theme
- colorama
run:
- python 3.5*
- colorama
test:
imports:
- migen
about:
home: https://m-labs.hk/gateware.html
license: 2-clause BSD
summary: 'A Python toolbox for building complex digital hardware'
|
fpu:
incdirs: [
.,
]
files: [
hdl/fpu_utils/fpu_ff.sv,
hdl/fpu_v0.1/fpu_defs.sv,
hdl/fpu_v0.1/fpexc.sv,
hdl/fpu_v0.1/fpu_add.sv,
hdl/fpu_v0.1/fpu_core.sv,
hdl/fpu_v0.1/fpu_ftoi.sv,
hdl/fpu_v0.1/fpu_itof.sv,
hdl/fpu_v0.1/fpu_mult.sv,
hdl/fpu_v0.1/fpu_norm.sv,
hdl/fpu_v0.1/fpu_private.sv,
hdl/fpu_v0.1/riscv_fpu.sv,
hdl/fpu_v0.1/fp_fma_wrapper.sv,
hdl/fpu_div_sqrt_tp_nlp/fpu_defs_div_sqrt_tp.sv,
hdl/fpu_div_sqrt_tp_nlp/control_tp.sv,
hdl/fpu_div_sqrt_tp_nlp/fpu_norm_div_sqrt.sv,
hdl/fpu_div_sqrt_tp_nlp/iteration_div_sqrt_first.sv,
hdl/fpu_div_sqrt_tp_nlp/iteration_div_sqrt.sv,
hdl/fpu_div_sqrt_tp_nlp/nrbd_nrsc_tp.sv,
hdl/fpu_div_sqrt_tp_nlp/preprocess.sv,
hdl/fpu_div_sqrt_tp_nlp/div_sqrt_top_tp.sv,
hdl/fpu_fmac/fpu_defs_fmac.sv,
hdl/fpu_fmac/preprocess_fmac.sv,
hdl/fpu_fmac/booth_encoder.sv,
hdl/fpu_fmac/booth_selector.sv,
hdl/fpu_fmac/pp_generation.sv,
hdl/fpu_fmac/wallace.sv,
hdl/fpu_fmac/aligner.sv,
hdl/fpu_fmac/CSA.sv,
hdl/fpu_fmac/adders.sv,
hdl/fpu_fmac/LZA.sv,
hdl/fpu_fmac/fpu_norm_fmac.sv,
hdl/fpu_fmac/fmac.sv,
]
|
image: debian:testing
#service:
# - python:latest
build:
stage: build
before_script:
- apt-get update
- apt-get install -y git make colormake
- apt-get install -y gcc-7 gnat-7 gcc gnat
- apt-get install -y llvm-4.0 llvm-4.0-dev llvm-4.0-tools llvm
- apt-get install -y clang-4.0 clang
- apt-get install -y zlib1g-dev libedit-dev
- apt-get install -y python3 python3-pip
# - ./tools/GitLab-CI/grc.setup.sh
- ./tools/GitLab-CI/ghdl.setup.sh
- pip3 install -r ./tools/GitLab-CI/requirements.txt
script:
- echo "build"
- export PATH=$PATH:./ghdl/bin
- export VUNIT_SIMULATOR=ghdl
- python3 ./testbench/run.py -k
# artifacts:
# paths:
# - mybinary
## run tests using the binary built before
#test:
# stage: test
# script:
|
<filename>src_files.yml
hw-mac-engine:
incdirs : [
rtl
]
files : [
rtl/mac_package.sv,
rtl/mac_fsm.sv,
rtl/mac_ctrl.sv,
rtl/mac_streamer.sv,
rtl/mac_engine.sv,
rtl/mac_top.sv,
wrap/mac_top_wrap.sv
]
vlog_opts : [
"-L hwpe_ctrl_lib",
"-L hwpe_stream_lib"
]
|
<filename>.github/workflows/test-frontend.yml<gh_stars>0
name: test-frontend-workflow
on:
workflow_dispatch:
app_endpoint:
description: 'Endpoint (URL) to Content Localization Application to test'
required: false
note:
description: 'Note'
required: false
jobs:
test-content-localization-dev-us-west-2:
needs: deploy-content-localization-dev-us-west-2
runs-on: ubuntu-latest
env:
MIE_REGION: 'us-west-2'
steps:
- name: Check out development branch
uses: actions/[email protected]
with:
ref: development
- name: Initialize test AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Generate short sha
run: |
echo "CONTENT_LOCALIZATION_STACK_NAME=cl" >> $GITHUB_ENV
echo "MIE_STACK_NAME=mi" >> $GITHUB_ENV
- name: Run cfn_nag
uses: stelligent/cfn_nag@master
continue-on-error: true
with:
input_path: deployment
# - name: Run unit tests
# run: |
# cd $GITHUB_WORKSPACE
# cd test/unit
# ./run_unit.sh workflowapi
# ./run_unit.sh dataplaneapi
# - name: Run integ tests
# run: |
# cd $GITHUB_WORKSPACE
# cd test/integ
# ./run_integ.sh
- name: Initialize build AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.BUILD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.BUILD_AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Setup Chromedriver
uses: nanasess/setup-chromedriver@master
- name: Get user pool id
run: |
echo "USER_POOL_ID=`aws cloudformation describe-stacks --query 'Stacks[?starts_with(StackName, \`cl-ContentAnalysisAuthStack\`)].Outputs[1].OutputValue' --output text`" >> $GITHUB_ENV
- name: Reset CL user password
run: |
aws cognito-idp admin-set-user-password --user-pool-id $USER_POOL_ID --username ${{ secrets.TEST_ADMIN_EMAIL }} --password ${{ secrets.TEST_ADMIN_PASSWORD }} --permanent
- name: Get Content Localization endpoint
run: |
echo "USE_EXISTING_WORKFLOW=True" >> $GITHUB_ENV
- name: Get Content Localization endpoint
run: |
echo "APP_ENDPOINT=`aws cloudformation describe-stacks --query 'Stacks[?starts_with(StackName, \`cl-ContentAnalysisWebStack\`)].Outputs[0].OutputValue' --output text`" >> $GITHUB_ENV
- name: Set admin creds
run: |
echo APP_USERNAME=${{ secrets.TEST_ADMIN_EMAIL }} >> $GITHUB_ENV
echo APP_PASSWORD=${{ secrets.TEST_ADMIN_PASSWORD }} >> $GITHUB_ENV
- name: Set media path and file name
run: |
echo TEST_MEDIA_PATH=$GITHUB_WORKSPACE/test/e2e/ >> $GITHUB_ENV
echo TEST_FILE_NAME=run_e2e.sh >> $GITHUB_ENV
- name: Initialize test AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Run e2e tests
run: |
cd $GITHUB_WORKSPACE
cd test/e2e
./run_e2e.sh
- name: Initialize build AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.BUILD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.BUILD_AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
|
<reponame>LaudateCorpus1/RosettaCodeData
---
category:
- Recursion
- Memoization
- Classic CS problems and programs
note: Arithmetic operations
|
---
foxFirmware:
name: firmware_hoplite
memory_size: 3072
resultFirmware:
name: firmware_hoplite_result
memory_size: 5120
|
<reponame>Malcolmnixon/MotionFpga
name: CI/VSG
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
- name: Install VSG
run: python -m pip install vsg
- name: VHDL Style Guide Checks
run: python -m vsg -c ../../style_rules.yaml style_files.yaml -of syntastic
working-directory: fpga/targets/MachX02-7000HE-Breakout
|
<filename>mflowgen/tile_array/testbench/configure.yml
name: testbench
parameters:
array_width: 4
array_height: 2
commands:
- python $GARNET_HOME/tests/test_timing/generate_testbench.py outputs --width $array_width --height $array_height
- mv outputs/Interconnect_tb.sv outputs/testbench.sv
outputs:
- testbench.sv
|
<gh_stars>10-100
sudo: required
dist: trusty
language: c
compiler: gcc
before_install:
- sudo apt-get -qq update
- sudo apt-get --assume-yes install gcc help2man git make
- wget http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/cxl.h
- sudo mkdir -p /usr/include/misc/
- sudo mv cxl.h /usr/include/misc/
- git clone https://github.com/ibm-capi/pslse ../pslse
- make -C ../pslse/libcxl
- sudo cp ../pslse/libcxl/libcxl.a /usr/lib
- sudo cp ../pslse/libcxl/libcxl.h /usr/include
script:
- make
- make test
|
# @package _global_
defaults:
- override /do_blink/fig1a@do_blink.fig.fig1a: ["7020"]
- override /do_blink/fig2a@do_blink.fig.fig2a: []
- override /do_blink/spam_filter@do_blink.fig.spam_filter: []
- override /do_blink/digit_recognition@do_blink.fig.digit_recognition: []
- override /do_blink/rendering@do_blink.fig.rendering: []
- override /hydra/launcher: submitit_slurm
do_blink:
vpr_options:
acc_fac: 0.596250776360891
astar_fac: 2.436544968882927
bb_factor: 15
initial_pres_fac: 6.1782498518525335
max_criticality: 0.9426811745984208
place_algorithm: bounding_box
pres_fac_mult: 1.0863560895369713
target_ext_pin_util.input: 0.7173967251881876
target_ext_pin_util.output: 0.7620163114072525
hydra:
launcher:
cpus_per_task: 8
mem_per_cpu: 7500mb
nodes: 1
|
axi:
files:
# Source files grouped in levels. Files in level 0 have no dependencies on files in this
# package. Files in level 1 only depend on files in level 0, files in level 2 on files in
# levels 1 and 0, etc. Files within a level are ordered alphabetically.
# Level 0
- src/axi_pkg.sv
# Level 1
- src/axi_intf.sv
# Level 2
- src/axi_atop_filter.sv
- src/axi_burst_splitter.sv
- src/axi_cdc.sv
- src/axi_cut.sv
- src/axi_delayer.sv
- src/axi_demux.sv
- src/axi_dw_converter.sv
- src/axi_dw_downsizer.sv
- src/axi_dw_upsizer.sv
- src/axi_id_prepend.sv
- src/axi_join.sv
- src/axi_lite_demux.sv
- src/axi_lite_join.sv
- src/axi_lite_mailbox.sv
- src/axi_lite_mux.sv
- src/axi_lite_to_apb.sv
- src/axi_lite_to_axi.sv
- src/axi_modify_address.sv
- src/axi_mux.sv
# Level 3
- src/axi_err_slv.sv
- src/axi_multicut.sv
- src/axi_to_axi_lite.sv
# Level 4
- src/axi_lite_xbar.sv
- src/axi_xbar.sv
axi_sim:
files:
- src/axi_test.sv
flags:
- skip_synthesis
- only_local
|
<filename>setup/docker/dockerfiles/gpu_conda/vitis-ai-lstm.yml
name: vitis-ai-lstm
channels:
- pytorch
- conda-forge
- anaconda
dependencies:
- python=3.6
- dctc_lstm
- tf_nndct
- pytorch_nndct_lstm
- pydot
- pyyaml
- jupyter
- ipywidgets
- dill
- progressbar2
- pytest
- scikit-learn
- pandas
- matplotlib
- pillow
|
<gh_stars>0
package:
name: ariane
authors: [ "<NAME> <<EMAIL>>" ]
dependencies:
axi: { git: "https://github.com/pulp-platform/axi.git", version: 0.4.5 }
axi_mem_if: { git: "https://github.com/pulp-platform/axi_mem_if.git", version: 0.2.0 }
axi_node: { git: "https://github.com/pulp-platform/axi_node.git", version: 1.1.1 }
tech_cells_generic: { git: "https://github.com/pulp-platform/tech_cells_generic.git", version: 0.1.1 }
common_cells: { git: "https://github.com/pulp-platform/common_cells.git", version: 1.7.5 }
fpga-support: { git: "https://github.com/pulp-platform/fpga-support.git", version: 0.3.2 }
sources:
- src/fpu_div_sqrt_mvp/hdl/fpu_ff.sv
- src/fpu_div_sqrt_mvp/hdl/defs_div_sqrt_mvp.sv
- src/fpu_div_sqrt_mvp/hdl/control_mvp.sv
- src/fpu_div_sqrt_mvp/hdl/div_sqrt_mvp_wrapper.sv
- src/fpu_div_sqrt_mvp/hdl/div_sqrt_top_mvp.sv
- src/fpu_div_sqrt_mvp/hdl/iteration_div_sqrt_mvp.sv
- src/fpu_div_sqrt_mvp/hdl/norm_div_sqrt_mvp.sv
- src/fpu_div_sqrt_mvp/hdl/nrbd_nrsc_mvp.sv
- src/fpu_div_sqrt_mvp/hdl/preprocess_mvp.sv
- src/fpu/src/pkg/fpnew_pkg.vhd
- src/fpu/src/pkg/fpnew_fmts_pkg.vhd
- src/fpu/src/pkg/fpnew_comps_pkg.vhd
- src/fpu/src/pkg/fpnew_pkg_constants.vhd
- src/fpu/src/utils/fp_pipe.vhd
- src/fpu/src/utils/fp_rounding.vhd
- src/fpu/src/utils/fp_arbiter.vhd
- src/fpu/src/ops/fma_core.vhd
- src/fpu/src/ops/fp_fma.vhd
- src/fpu/src/ops/fp_divsqrt_multi.vhd
- src/fpu/src/ops/fp_noncomp.vhd
- src/fpu/src/ops/fp_f2fcasts_fmt.vhd
- src/fpu/src/ops/fp_f2icasts_fmt.vhd
- src/fpu/src/ops/fp_i2fcasts_fmt.vhd
- src/fpu/src/subunits/addmul_fmt_slice.vhd
- src/fpu/src/subunits/addmul_block.vhd
- src/fpu/src/subunits/divsqrt_multifmt_slice.vhd
- src/fpu/src/subunits/divsqrt_block.vhd
- src/fpu/src/subunits/noncomp_fmt_slice.vhd
- src/fpu/src/subunits/noncomp_block.vhd
- src/fpu/src/subunits/conv_fmt_slice.vhd
- src/fpu/src/subunits/conv_ifmt_slice.vhd
- src/fpu/src/subunits/conv_block.vhd
- src/fpu/src/fpnew.vhd
- src/fpu/src/fpnew_top.vhd
- include/riscv_pkg.sv
- src/debug/dm_pkg.sv
- include/ariane_pkg.sv
- include/std_cache_pkg.sv
- target: not(synthesis)
files:
- src/util/instruction_tracer_pkg.sv
- src/util/instruction_tracer_if.sv
- src/alu.sv
- src/fpu_wrap.sv
- src/ariane.sv
- src/branch_unit.sv
- src/compressed_decoder.sv
- src/controller.sv
- src/csr_buffer.sv
- src/csr_regfile.sv
- src/decoder.sv
- src/ex_stage.sv
- src/frontend/btb.sv
- src/frontend/bht.sv
- src/frontend/ras.sv
- src/frontend/instr_scan.sv
- src/frontend/frontend.sv
- src/id_stage.sv
- src/instr_realigner.sv
- src/issue_read_operands.sv
- src/issue_stage.sv
- src/load_unit.sv
- src/lsu_arbiter.sv
- src/lsu.sv
- src/mmu.sv
- src/mult.sv
- src/perf_counters.sv
- src/ptw.sv
- src/ariane_regfile_ff.sv
# - src/ariane_regfile.sv
- src/re_name.sv
- src/scoreboard.sv
- src/store_buffer.sv
- src/amo_buffer.sv
- src/store_unit.sv
- src/tlb.sv
- src/commit_stage.sv
- src/axi_adapter.sv
- src/cache_subsystem/cache_ctrl.sv
- src/cache_subsystem/amo_alu.sv
- src/cache_subsystem/miss_handler.sv
- src/cache_subsystem/std_cache_subsystem.sv
- src/cache_subsystem/std_icache.sv
- src/cache_subsystem/std_nbdcache.sv
- src/debug/debug_rom/debug_rom.sv
- src/debug/dm_csrs.sv
- src/clint/clint.sv
- src/clint/axi_lite_interface.sv
- src/debug/dm_mem.sv
- src/debug/dm_top.sv
- src/debug/dmi_cdc.sv
- src/debug/dmi_jtag.sv
- src/debug/dm_sba.sv
- src/debug/dmi_jtag_tap.sv
|
<gh_stars>1-10
site_name: OC-Accel Doc
repo_name: GitHub
repo_url: https://github.com/OpenCAPI/oc-accel
edit_uri: ""
nav:
- About:
- 'Overview': 'index.md'
- 'About the repository': 'repository.md'
- User Guide:
- '(0) Steps in a glance': 'user-guide/0-steps.md'
- '(1) Prepare environment': 'user-guide/1-prepare-env.md'
- '(2) Run helloworld': 'user-guide/2-run-helloworld.md'
- '(3) Create a new action': 'user-guide/3-new-action.md'
- '(4) Verilog/VHDL design': 'user-guide/4-hdl-design.md'
- '(5) HLS C++ design': 'user-guide/5-hls-design.md'
- '(6) Co-Simulation': 'user-guide/6-co-simulation.md'
- '(7) Build image': 'user-guide/7-build-image.md'
- '(8) Deploy on Power Server': 'user-guide/8-deploy.md'
- '(9) Migrate from SNAP1/2': 'user-guide/9-migrate.md'
- '(10) Tips': 'user-guide/10-tips.md'
- Examples:
- 'hdl_example': 'actions-doc/hdl_example.md'
- 'hdl_single_engine': 'actions-doc/hdl_single_engine.md'
- 'hls_helloworld': 'actions-doc/hls_helloworld.md'
- 'hls_memcopy_1024': 'actions-doc/hls_memcopy_1024.md'
- Deep Dive:
- 'Software API': 'deep-dive/software-api.md'
- 'Registers': 'deep-dive/registers.md'
- 'Hardware Logic': 'deep-dive/hardware-logic.md'
- 'New Board Support': 'deep-dive/board-package.md'
- Misc:
- 'Document Guide': 'misc/doc-guide.md'
theme:
name: yeti
# Code block colors: Dark
# hljs_style: hybrid
# hljs_style: monokai
# hljs_style: tomorrow-night
# hljs_style: railscasts
# Code block colors: Light
# hljs_style: googlecode
# hljs_style: solarized-light
hljs_style: github
# hljs_style: foundation
extra_css:
- extra.css
extra_javascript:
- extra.js
markdown_extensions:
- admonition
|
<reponame>micprog/apb_adv_timer
package:
name: apb_adv_timer
authors:
- "<NAME> <<EMAIL>>"
- "<NAME> <<EMAIL>>"
- "<NAME> <<EMAIL>>"
- "<NAME> <<EMAIL>>"
dependencies:
tech_cells_generic: { git: "https://github.com/pulp-platform/tech_cells_generic.git", version: 0.2.3 }
sources:
- files:
# Source files grouped in levels. Files in level 0 have no dependencies on files in this
# package. Files in level 1 only depend on files in level 0, files in level 2 on files in
# levels 1 and 0, etc. Files within a level are ordered alphabetically.
# Level 0
- rtl/adv_timer_apb_if.sv
- rtl/comparator.sv
- rtl/input_stage.sv
- rtl/lut_4x4.sv
- rtl/out_filter.sv
- rtl/prescaler.sv
- rtl/timer_cntrl.sv
- rtl/up_down_counter.sv
# Level 1
- rtl/timer_module.sv
# Level 2
- rtl/apb_adv_timer.sv
include_dirs:
- rtl
|
<gh_stars>1-10
name: Build and Test
on:
push:
release:
types:
- created
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macOS-latest]
steps:
- uses: actions/checkout@v1
- name: Install Dependencies
run: |
brew install haskell-stack shunit2 icarus-verilog || ls
sudo apt-get install -y haskell-stack shunit2 flex bison autoconf gperf || ls
- name: Cache iverilog
uses: actions/cache@v1
with:
path: ~/.local
key: ${{ runner.OS }}-iverilog-10-3
restore-keys: ${{ runner.OS }}-iverilog-10-3
- name: Install iverilog
run: |
if [ "${{ runner.OS }}" = "Linux" ] && [ ! -e "$HOME/.local/bin/iverilog" ]; then
curl -L https://github.com/steveicarus/iverilog/archive/v10_3.tar.gz > iverilog-10_3.tar.gz
tar -xzf iverilog-10_3.tar.gz
cd iverilog-10_3
autoconf
./configure --prefix=$HOME/.local
make
make install
cd ..
fi
- name: Build
run: make
- name: Test
run: |
export PATH="$PATH:$HOME/.local/bin"
make test
- name: Prepare Artifact
if: github.event_name == 'release'
run: cp LICENSE NOTICE README.md bin
- name: Upload Artifact
if: github.event_name == 'release'
uses: actions/upload-artifact@v1
with:
name: ${{ runner.os }}
path: bin
release:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'release'
steps:
- run: sudo apt-get install -y tree
- name: Download Linux Artifact
uses: actions/download-artifact@v1
with:
name: Linux
path: sv2v-Linux
- name: Download MacOS Artifact
uses: actions/download-artifact@v1
with:
name: macOS
path: sv2v-macOS
- name: Create ZIPs
run: |
chmod +x */sv2v
zip -r sv2v-Linux ./sv2v-Linux
zip -r sv2v-macOS ./sv2v-macOS
- name: Upload Linux Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./sv2v-Linux.zip
asset_name: sv2v-Linux.zip
asset_content_type: application/zip
- name: Upload MacOS Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./sv2v-macOS.zip
asset_name: sv2v-macOS.zip
asset_content_type: application/zip
|
<filename>.travis.yml
language: generic
git:
submodules: false
os:
-linux
dist:
- trusty
- xenial
- bionis
cache:
apt: true
directories:
- externals
addons:
apt:
packages:
- cmake
- iverilog
- yosys
before_script:
- mkdir build
- cd build
- cmake ..
script: cmake --build . && ctest -C Debug
|
<filename>examples/alpha250/fft/config_1g.yml
---
name: fft
board: boards/alpha250-1g
version: 0.2.0
cores:
- fpga/cores/axi_ctl_register_v1_0
- fpga/cores/axi_sts_register_v1_0
- fpga/cores/dna_reader_v1_0
- fpga/cores/axis_constant_v1_0
- fpga/cores/latched_mux_v1_0
- fpga/cores/edge_detector_v1_0
- fpga/cores/comparator_v1_0
- fpga/cores/unrandomizer_v1_0
- boards/alpha250/cores/precision_dac_v1_0
- boards/alpha250/cores/spi_cfg_v1_0
- fpga/cores/psd_counter_v1_0
memory:
- name: control
offset: '0x40000000'
range: 4K
- name: ps_control
offset: '0x44000000'
range: 4K
- name: status
offset: '0x50000000'
range: 4K
- name: ps_status
offset: '0x55000000'
range: 4K
- name: xadc
offset: '0x43C00000'
range: 64K
- name: demod
offset: '0x60000000'
range: 32K
- name: psd
offset: '0x70000000'
range: 32K
control_registers:
- mmcm
- precision_dac_ctl
- precision_dac_data[2]
- ctl_fft
- psd_valid
- psd_input_sel
- phase_incr[2]
- digital_outputs
status_registers:
- adc[n_adc]
- cycle_index
- digital_inputs
ps_control_registers:
- spi_cfg_data
- spi_cfg_cmd
ps_status_registers:
- spi_cfg_sts
parameters:
fclk0: 200000000
adc_clk: 250000000
dac_width: 16
adc_width: 16
n_adc: 2
fft_size: 8192
n_cycles: 1023
cic_differential_delay: 1
cic_decimation_rate: 500
cic_n_stages: 6
xdc:
- boards/alpha250-1g/config/ports.xdc
drivers:
- boards/alpha250/drivers/common.hpp
- boards/alpha250/drivers/eeprom.hpp
- boards/alpha250/drivers/gpio-expander.hpp
- boards/alpha250/drivers/temperature-sensor.hpp
- boards/alpha250/drivers/power-monitor.hpp
- boards/alpha250/drivers/clock-generator.hpp
- boards/alpha250/drivers/ltc2157.hpp
- boards/alpha250/drivers/ad9747.hpp
- boards/alpha250/drivers/precision-adc.hpp
- boards/alpha250/drivers/precision-dac.hpp
- boards/alpha250/drivers/spi-config.hpp
- ./fft.hpp
web:
- web/koheron.ts
- web/jquery.flot.d.ts
- web/main.css
- web/dds-frequency/dds-frequency.html
- web/dds-frequency/dds-frequency.ts
- ./web/index.html
- ./web/app.ts
- ./web/fft.ts
- ./web/fft/fft-window.html
- ./web/fft/input-channel.html
- ./web/fft/fft-app.ts
- web/plot-basics/plot-basics.ts
- web/plot-basics/plot-basics.html
- ./web/plot/plot.ts
- ./web/plot/yunit.html
- ./web/plot/peak-detection.html
- ./web/precision-channels/precision-adc.ts
- ./web/precision-channels/precision-dac.ts
- ./web/precision-channels/precision-channels-app.ts
- ./web/precision-channels/precision-channels.html
- ./web/clock-generator/clock-generator.ts
- ./web/clock-generator/clock-generator-app.ts
- ./web/clock-generator/sampling-frequency.html
- ./web/clock-generator/reference-clock.html
- ./web/export-file/export-file.html
- ./web/export-file/export-file.ts
- ./web/temperature-sensor/temperature-sensor.html
- ./web/temperature-sensor/temperature-sensor.ts
- ./web/temperature-sensor/temperature-sensor-app.ts
- ./web/power-monitor/power-monitor.html
- ./web/power-monitor/power-monitor.ts
- ./web/power-monitor/power-monitor-app.ts
|
<filename>models/AI-Model-Zoo/model-list/pt_salsanext_semantic-kitti_64_2048_0.6_20.4G_2.0/model.yaml<gh_stars>1-10
# Copyright 2019 Xilinx Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
description: Salsanext segmentation on Semantic-Kitti
input size: 1*5*64*2048
float ops: 20.4G
task: segmentation
framework: pytorch
prune: '0.6'
version: 2.0
files:
- name: pt_salsanext_semantic-kitti_64_2048_0.6_20.4G_2.0
type: float & quantized
board: GPU
download link: https://www.xilinx.com/bin/public/openDownload?filename=pt_salsanext_semantic-kitti_64_2048_0.6_20.4G_2.0.zip
checksum: 01bf048dfade040615c01c2c0d99e5f5
- name: salsanext_pt
type: xmodel
board: zcu102 & zcu104 & kv260
download link: https://www.xilinx.com/bin/public/openDownload?filename=salsanext_pt-zcu102_zcu104_kv260-r2.0.0.tar.gz
checksum: fff557c0c22b15c3f90f2e0e9090748e
- name: salsanext_pt
type: xmodel
board: vck190
download link: https://www.xilinx.com/bin/public/openDownload?filename=salsanext_pt-vck190-r2.0.0.tar.gz
checksum: e7b5eb5e6cd89f109ff5cd46f8eea3b4
- name: salsanext_pt
type: xmodel
board: vck50006pe-DPUCVDX8H-DWC
download link: https://www.xilinx.com/bin/public/openDownload?filename=salsanext_pt-vck50006pe-DPUCVDX8H-DWC-r2.0.0.tar.gz
checksum: d103edb4c9a4b76838ecbb0373cec9f7
- name: salsanext_pt
type: xmodel
board: vck50008pe-DPUCVDX8H
download link: https://www.xilinx.com/bin/public/openDownload?filename=salsanext_pt-vck50008pe-DPUCVDX8H-r2.0.0.tar.gz
checksum: d315f854cc48894dcf87d5bb044743d9
- name: salsanext_pt
type: xmodel
board: u50lv-DPUCAHX8H
download link: https://www.xilinx.com/bin/public/openDownload?filename=salsanext_pt-u50lv-DPUCAHX8H-r2.0.0.tar.gz
checksum: 4d3f08881f7b7397ecfe6ae731858152
- name: salsanext_pt
type: xmodel
board: u50lv-DPUCAHX8H-DWC & u55c-DPUCAHX8H-DWC
download link: https://www.xilinx.com/bin/public/openDownload?filename=salsanext_pt-u55c-u50lv-DPUCAHX8H-DWC-r2.0.0.tar.gz
checksum: 36fd8af22881a97b403f1267af09eeae
license: https://github.com/Xilinx/Vitis-AI/blob/master/LICENSE
|
<gh_stars>10-100
tcdm_interconnect:
incdirs: [
]
files: [
src/tcdm_interconnect_pkg.sv,
src/addr_dec_resp_mux.sv,
src/amo_shim.sv,
src/xbar.sv,
src/clos_net.sv,
src/bfly_net.sv,
src/tcdm_interconnect.sv,
]
|
board-arty: ["targets/arty", "platforms/arty.py"]
board-atlys: ["targets/atlys", "platforms/atlys.py"]
board-basys3: ["targets/basys3", "platforms/basys3.py"]
board-cmod_a7: ["targets/cmod_a7", "platforms/cmod_a7.py"]
board-galatea: ["targets/galatea", "platforms/galatea.py"]
board-ice40_hx8k_b_env: ["targets/ice40_hx8k_b_evn", "platforms/ice40_hx8k_b_env.py"]
board-mimasv2: ["targets/mimasv2", "platforms/mimasv2.py"]
board-minispartan6: ["targets/minispartan6", "platforms/minispartan6.py"]
board-neso: ["targets/neso", "platforms/neso.py"]
board-netv2: ["targets/netv2", "platforms/netv2.py"]
board-nexys-video: ["targets/nexys-video", "platforms/nexys-video.py"]
board-opsis: ["targets/opsis", "platforms/opsis.py", "platforms/tofe_*.py"]
board-pipistrello: ["targets/pipistrello", "platforms/pipistrello.py"]
board-saturn: ["targets/saturn", "platforms/saturn.py"]
board-sim: ["targets/sim", "platforms/sim.py"]
board-tinyfpga_bx: ["targets/tinyfpga_bx", "platforms/tinyfpga_bx.py"]
board-waxwing: ["targets/waxwing", "platforms/waxwing.py"]
boards-all: ["targets/common/"]
boards-artix7: [
"targets/arty", "platforms/arty.py",
"targets/basys3", "platforms/basys3.py",
"targets/cmod_a7", "platforms/cmod_a7.py",
"targets/neso", "platforms/neso.py",
"targets/netv2", "platforms/netv2.py",
"targets/nexys-video", "platforms/nexys-video.py"
]
boards-ice40: [
"targets/ice40_hx8k_b_evn", "platforms/ice40_hx8k_b_env.py",
"targets/tinyfpga_bx", "platforms/tinyfpga_bx.py",
]
boards-spartan6: [
"targets/atlys", "platforms/atlys.py",
"targets/galatea", "platforms/galatea.py",
"targets/mimasv2", "platforms/mimasv2.py",
"targets/minispartan6", "platforms/minispartan6.py",
"targets/opsis", "platforms/opsis.py",
"targets/pipstrello", "platforms/pipstrello.py",
"targets/saturn", "platforms/saturn.py",
"targets/waxwing", "platforms/waxwing.py"
]
firmware-fpga: ["gateware/"]
firmware-softcpu: ["firmware/"]
hdmi2ethernet: ["targets/*/net.py", "targets/*/hdmi2eth.py", "firmware/uip/", "third_party/libuip/"]
hdmi2usb: ["targets/*/hdmi2usb.py", "gateware/encoder/"]
hdmi2***: ["targets/*/base.py"]
level-docs: ["docs/", "README.md", "*.md"]
level-firmware: ["gateware/", "firmware/"]
level-infrastructure: [".travis.yml", ".travis/", "scripts/", ".github/"]
level-software: ["software/"]
|
<reponame>timkpaine/pynqpandas<filename>.github/workflows/build.yml
name: Build Status
on:
push:
branches:
- main
pull_request:
schedule:
# run on sunday nights
- cron: '0 0 * * 0'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9]
event-name: [push]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -r requirements.txt -U
pip install -U pytest pytest-cov flake8 pylint codecov
- name: Lint
run: |
make lint
- name: Test
run: |
make test
if: ${{ github.event_name == matrix.event-name || matrix.os == 'ubuntu-latest' }}
- name: Codecov
run: |
codecov --token <KEY>
|
<reponame>mfkiwl/garnet
name: rtl
inputs:
- rtl
outputs:
- design.v
commands:
- mkdir -p outputs
- cd outputs
- ln -s ../inputs/rtl/aham3soc_pad_frame/genesis_verif/GarnetSOC_pad_frame.sv design.v
|
name: 'push'
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 5'
env:
# https://github.com/tox-dev/tox/issues/1468
PY_COLORS: 1
jobs:
#
# Python code format
#
fmt:
runs-on: ubuntu-latest
name: 'π black'
steps:
- name: 'π§° Checkout'
uses: actions/checkout@v2
- name: 'π Setup Python'
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: 'π Install dependencies'
run: |
pip install -U pip --progress-bar off
pip install -U virtualenv tox --progress-bar off
- name: 'π Run black'
run: tox -e py310-fmt -- --check
#
# Linux linting and unit tests
#
lin:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { py: '3.10' , task: 310-lint }
- { py: '3.6' , task: 36-unit }
- { py: '3.10' , task: 310-unit }
name: 'π§ Ubuntu Β· ${{ matrix.task }}'
steps:
- name: 'π§° Checkout'
uses: actions/checkout@v2
- name: 'π Setup Python'
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
- name: 'π Install dependencies'
run: |
pip install -U pip --progress-bar off
pip install -U virtualenv tox --progress-bar off
- name: 'π§ Run job'
run: tox -e py${{ matrix.task }} -- --color=yes
#
# Docker (Linux) acceptance tests
#
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
task: [
{do: 310-acceptance, tag: llvm},
{do: 310-vcomponents, tag: mcode},
]
name: 'π³οΈ Container Β· ${{ matrix.task.do }} Β· ${{ matrix.task.tag }}'
steps:
- name: 'π§° Checkout'
uses: actions/checkout@v2
with:
submodules: recursive
- name: 'π§ Run job'
run: docker run --rm -tv $(pwd):/src -w /src ghcr.io/vunit/dev/${{ matrix.task.tag }} tox -e py${{ matrix.task.do }}-ghdl
#
# Windows (MSYS2) with 'nightly' GHDL
#
win-setup:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
task: [
39-acceptance-ghdl,
39-vcomponents-ghdl,
39-lint,
39-unit,
]
name: 'π¦ Windows Β· nightly Β· ${{ matrix.task }}'
defaults:
run:
shell: msys2 {0}
steps:
- name: 'π¦ Setup MSYS2'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: mingw-w64-x86_64-python-pip
- name: 'π§° Checkout'
uses: actions/checkout@v2
with:
submodules: recursive
- name: 'βοΈ Setup GHDL'
uses: ghdl/setup-ghdl-ci@master
with:
backend: llvm
- name: 'π Install dependencies'
run: pip install -U tox --progress-bar off
- name: 'π§ Run job'
run: tox -e py${{ matrix.task }} -- --color=yes
#
# Windows with latest tagged GHDL
#
win-tagged:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
task: [
36-acceptance-ghdl,
36-vcomponents-ghdl,
36-lint,
36-unit,
]
name: 'π§ Windows Β· tagged Β· ${{ matrix.task }}'
steps:
- name: 'π§° Checkout'
uses: actions/checkout@v2
with:
submodules: recursive
- name: 'π Setup Python'
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: 'π Install dependencies'
run: |
pip install -U pip --progress-bar off
pip install -U virtualenv tox --progress-bar off
- name: 'βοΈ Install GHDL'
if: endsWith( matrix.task, '-ghdl' )
shell: bash
run: |
curl -fsSL -o ghdl.zip https://github.com/ghdl/ghdl/releases/download/v0.37/ghdl-0.37-mingw32-mcode.zip
7z x ghdl.zip "-o../ghdl" -y
mv ../ghdl/GHDL/0.37-mingw32-mcode/ ../ghdl-v0.37
rm -rf ../ghdl ghdl.zip
- name: 'π§ Run job'
shell: bash
run: |
export PATH=$PATH:$(pwd)/../ghdl-v0.37/bin
tox -e py${{ matrix.task }} -- --color=yes
#
# Deploy to PyPI
#
deploy:
runs-on: ubuntu-latest
needs: [ fmt, lin, docker, win-setup, win-tagged ]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
name: 'π Deploy'
steps:
- name: 'π§° Checkout'
uses: actions/checkout@v2
with:
submodules: recursive
- name: 'π Setup Python'
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: 'π Install dependencies'
run: |
pip install -U pip
pip install -U setuptools wheel twine
- name: 'π Build and deploy to PyPI'
if: github.repository == 'VUnit/vunit'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.VUNIT_HDL_PYPI_DEPLOY_TOKEN }}
run: |
./tools/release.py validate
python setup.py sdist
twine upload dist/*
|
<filename>software/glip/src/common/logic/fifo/test/test_fifo_singleclock_fwft.manifest.yaml
module: test_fifo_singleclock_fwft
sources:
- ../verilog/fifo_singleclock_fwft.sv
- ../verilog/fifo_singleclock_standard.sv
toplevel: fifo_singleclock_fwft
simulators:
- vcs
parameters:
WIDTH: 16
DEPTH: 32
|
<reponame>cm8f/hdl-base<gh_stars>0
name: CI
on: [push]
jobs:
vunit-ghdl-sim:
runs-on: ubuntu-latest
steps:
- name: Checksout Repository
uses: actions/checkout@v2
- name: ghdl elab
uses: docker://ghdl/vunit:gcc
with:
args: python3 ./run.py -p 12 --elaborate --cover
- name: ghdl tests
uses: docker://ghdl/vunit:gcc
with:
args: python3 ./run.py -p 12 --cover
- shell: bash
run: |
cat coverage.txt
sleep 5
|
#=========================================================================
# Mentor Calibre GDS Merge
#=========================================================================
# Author : <NAME>
# Date : November 5, 2019
#
name: mentor-calibre-gdsmerge
#-------------------------------------------------------------------------
# Inputs and Outputs
#-------------------------------------------------------------------------
inputs:
- design.gds.gz
- adk
outputs:
- design_merged.gds
#-------------------------------------------------------------------------
# Commands
#-------------------------------------------------------------------------
commands:
# - cp ../../build_prbs/18-cadence-innovus-signoff/results/prbs_generator_syn-merged.gds ./inputs/prbs_generator_syn.gds
# - cp ../../build_16t4/18-cadence-innovus-signoff/results/hr_16t4_mux_top-merged.gds ./inputs/hr_16t4_mux_top.gds
# - cp ../../build_4t1/19-cadence-innovus-signoff/results/qr_4t1_mux_top-merged.gds ./inputs/qr_4t1_mux_top.gds
# - cp /tmp/canw/mflowgen/build/build_digital/8-submodule/outputs/osc_core.gds ./inputs/osc_core.gds
# - cp /tmp/canw/mflowgen/build/build_digital/8-submodule/outputs/fine_freq_track.gds ./inputs/fine_freq_track.gds
# For some reason, Calibre requires this directory to exist
- mkdir -p $HOME/.calibrewb_workspace/tmp
# Glob for all gds files in adk
# Done manually because -indir inputs/adk did not work on Calibre 17
- ins=""; for f in inputs/adk/*.gds*; do ins="$ins -in $f"; done
- for f in inputs/*.gds*; do ins="$ins -in $f"; done
# Use calibredrv to merge gds files
# Need 'echo |' to stop calibredrv from hanging if the step is backgrounded,
# which is a known calibredrv bug noted in the manual (see calibr_drv_ref.pdf)
- echo | calibredrv -a layout filemerge \
-indir inputs \
$ins
-topcell {design_name} \
-out design_merged.gds 2>&1 | tee merge.log
- mkdir -p outputs && cd outputs
- ln -sf ../design_merged.gds
#-------------------------------------------------------------------------
# Parameters
#-------------------------------------------------------------------------
parameters:
design_name: undefined
#-------------------------------------------------------------------------
# Debug
#-------------------------------------------------------------------------
debug:
- calibredrv -m design_merged.gds \
-l inputs/adk/calibre.layerprops
#-------------------------------------------------------------------------
# Assertions
#-------------------------------------------------------------------------
preconditions:
- assert Tool( 'calibredrv' )
- assert File( 'inputs/design.gds.gz' )
- assert File ( '../../build_prbs/18-cadence-innovus-signoff/results/prbs_generator_syn-merged.gds' )
- assert File ( '../../build_16t4/18-cadence-innovus-signoff/results/hr_16t4_mux_top-merged.gds' )
- assert File ( '../../build_4t1/19-cadence-innovus-signoff/results/qr_4t1_mux_top-merged.gds' )
postconditions:
- assert File( 'outputs/design_merged.gds' )
# Duplicate structures
#
# GDS can be hierarchical, meaning they have holes where library cells
# (e.g., stdcell GDS) can be filled in. If library cell names conflict,
# there is a chance that one definition will overwrite the other and you
# will see a very weird GDS that may not be functional or DRC clean
# anymore (e.g., one SRAM macro may now be using another SRAM macro's
# bitcell array). If a conflict happens unexpectedly here and goes by
# undetected, it can take days or weeks to debug LVS before finally
# realizing it was an incorrect GDS merge.
#
# Assert here to make sure we detect it early. There is a choice for
# what to do next for the merged GDS: (1) use one library's version, (2)
# use the other library's version, (3) rename both and each reference
# their own version, (4) something else...
#
- "assert 'WARNING: Ignoring duplicate structure'
not in File( 'merge.log' )"
|
<reponame>nordicneurolab/vunit<filename>.github/workflows/docs.yml
name: 'docs'
on: [ push, pull_request ]
env:
# https://github.com/tox-dev/tox/issues/1468
PY_COLORS: 1
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/setup-python@v1
with:
python-version: 3.8
- name: install dependencies
run: |
pip install -U pip --progress-bar off
pip install -U virtualenv tox --progress-bar off
- name: build docs
run: tox -e py38-docs -- --color
- uses: actions/upload-artifact@master
with:
name: VUnit-site
path: .tox/py38-docs/tmp/docsbuild/
- name: 'publish site to gh-pages'
if: github.event_name != 'pull_request' && github.repository == 'VUnit/vunit'
env:
GH_DEPKEY: ${{ secrets.VUNIT_GITHUB_IO_DEPLOY_KEY }}
run: |
cd .tox/py38-docs/tmp/docsbuild/
touch .nojekyll
git init
git add .
git config --local user.email "push@gha"
git config --local user.name "GHA"
git commit -a -m "update ${{ github.sha }}"
git remote add origin <EMAIL>:VUnit/VUnit.github.io
eval `ssh-agent -t 60 -s`
echo "$GH_DEPKEY" | ssh-add -
mkdir -p ~/.ssh/
ssh-keyscan github.com >> ~/.ssh/known_hosts
git push -u origin +master
ssh-agent -k
|
<filename>vlsi/digital.sky130.yml
vlsi.inputs.placement_constraints:
- path: "Digital"
type: toplevel
x: 0
y: 0
width: 2900
height: 2615
margins:
left: 0
right: 0
top: 0
bottom: 0
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_0_0"
type: hardmacro
x: 30
y: 2186.5
orientation: r0
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_1_0"
type: hardmacro
x: 30
y: 1529
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_2_0"
type: hardmacro
x: 30
y: 1028.5
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_3_0"
type: hardmacro
x: 30
y: 530.5
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_4_0"
type: hardmacro
x: 30
y: 30
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_5_0"
type: hardmacro
x: 1110
y: 30
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_6_0"
type: hardmacro
x: 2150
y: 30
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/dcache/data/data_arrays_0/data_arrays_0_ext/mem_7_0"
type: hardmacro
x: 2150
y: 530.5
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/frontend/icache/data_arrays_0/data_arrays_0_0_ext/mem_0_0"
type: hardmacro
x: 2150
y: 1550
orientation: mx
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/frontend/icache/data_arrays_0/data_arrays_0_0_ext/mem_1_0"
type: hardmacro
x: 2150
y: 1028.5
orientation: r0
top_layer: "met4"
- path: "Digital/system/tile_prci_domain/tile_reset_domain/tile/frontend/icache/tag_array/tag_array_ext/mem_0_0"
type: hardmacro
x: 2350
y: 2198
orientation: r0
top_layer: "met4"
|
<gh_stars>0
#
# List of IPs and relative branch/commit-hash/tag.
# Uses the YAML syntax.
#
axi/axi2mem:
commit: d704c8beff729476d1dbfd7b60679afa796947d2
domain: [soc, cluster]
group: pulp-platform
axi/axi2per:
commit: tags/v1.0.1
domain: [cluster]
group: pulp-platform
axi/per2axi:
commit: v1.0.4
domain: [soc, cluster]
group: pulp-platform
axi/axi_size_conv:
commit: tags/pulp-v1.0
domain: [cluster]
group: pulp-platform
axi/axi:
commit: <PASSWORD>
domain: [soc, cluster]
group: recogni
cluster_interconnect:
commit: tags/v1.0.3
domain: [cluster]
group: pulp-platform
event_unit_flex:
commit: v1.4.0
domain: [cluster]
group: pulp-platform
mchan:
commit: tags/v1.1.0
domain: [cluster]
group: pulp-platform
hier-icache:
commit: marsellus_v1.2.0
domain: [cluster]
group: pulp-platform
icache-intc:
commit: tags/v1.0.1
domain: [cluster]
group: pulp-platform
icache_mp_128_pf:
commit: 8b6c8c71a31237318f952f04882a090a7f0cb5ff
domain: [cluster]
group: recogni
icache_private:
commit: <PASSWORD>
domain: [cluster]
group: pulp-platform
jpeg_enc:
commit: 9dd48510db2a86815b615745eb5e0bd35eb9f084
domain: [cluster]
group: recogni
cluster_peripherals:
commit: tags/v1.0.1
domain: [cluster]
group: pulp-platform
fpu_interco:
commit: <PASSWORD>
domain: [soc, cluster]
group: pulp-platform
|
<gh_stars>0
name: YAPF Formatting Check
on: [push]
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Run YAPF python style checks
uses: AlexanderMelde/yapf-action@master
with:
args: --diff --recursive --style env/.style.yapf
|
name: thermostat
system:
outputs:
temperature: REAL
parameters:
lowTemp:
type: REAL
default: 22.78
highTemp:
type: REAL
default: 25
locations:
t1:
invariant: temperature > lowTemp
flow:
temperature: 10 - temperature
transitions:
- to: t2
guard: temperature <= lowTemp
t2:
invariant: temperature < highTemp
flow:
temperature: 37.78 - temperature
transitions:
- to: t1
guard: temperature >= highTemp
initialisation:
state: t1
valuations:
temperature: 20
codegenConfig:
execution:
stepSize: 0.0001
simulationTime: 100
logging:
enable: true
file: out.csv
parametrisationMethod: COMPILE_TIME
maximumInterTransitions: 1
requireOneIntraTransitionPerTick: false
|
name: 'test'
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 5'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: ./tests/run.sh ghdl ./Boards2.sh
- run: ./tests/run.sh VUnit python3 run.py -v
|
axi_size_conv:
incdirs: [
.,
]
files: [
AXI_UPSIZE_simple/axi_size_UPSIZE_32_64.sv,
AXI_UPSIZE_simple/axi_size_UPSIZE_32_64_wrap.sv,
AXI_UPSIZE/Write_UPSIZE.sv,
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.