2007-11-19 02:36:03 +01:00
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program 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.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
extern int sdflex(void);
|
|
|
|
|
static void yyerror(const char*msg);
|
|
|
|
|
# include "vpi_user.h"
|
|
|
|
|
# include "sdf_parse_priv.h"
|
2007-11-21 07:20:22 +01:00
|
|
|
# include "sdf_priv.h"
|
2007-11-19 02:36:03 +01:00
|
|
|
# include <stdio.h>
|
2007-11-21 07:20:22 +01:00
|
|
|
|
|
|
|
|
/* This is the hierarchy separator to use. */
|
|
|
|
|
static char use_hchar = '.';
|
|
|
|
|
|
2007-11-19 02:36:03 +01:00
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
%union {
|
|
|
|
|
unsigned long int_val;
|
|
|
|
|
double real_val;
|
|
|
|
|
char* string_val;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%token K_ABSOLUTE K_CELL K_CELLTYPE K_DATE K_DELAYFILE K_DELAY K_DESIGN
|
|
|
|
|
%token K_DIVIDER K_INCREMENT K_INSTANCE K_IOPATH
|
|
|
|
|
%token K_PROCESS K_PROGRAM K_SDFVERSION K_TEMPERATURE K_TIMESCALE
|
|
|
|
|
%token K_VENDOR K_VERSION K_VOLTAGE
|
|
|
|
|
|
|
|
|
|
%token <string_val> QSTRING IDENTIFIER
|
|
|
|
|
%token <real_val> REAL_NUMBER
|
|
|
|
|
%token <int_val> INTEGER
|
|
|
|
|
|
2007-11-21 07:20:22 +01:00
|
|
|
%type <string_val> celltype
|
|
|
|
|
%type <string_val> cell_instance
|
|
|
|
|
%type <string_val> hierarchical_identifier
|
|
|
|
|
%type <string_val> port port_instance port_spec
|
|
|
|
|
|
2007-11-19 02:36:03 +01:00
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
source_file
|
|
|
|
|
: '(' K_DELAYFILE sdf_header_list cell_list ')'
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
sdf_header_list
|
|
|
|
|
: sdf_header_list sdf_header_item
|
|
|
|
|
| sdf_header_item
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
sdf_header_item
|
|
|
|
|
: sdfversion
|
|
|
|
|
| design_name
|
|
|
|
|
| date
|
|
|
|
|
| vendor
|
|
|
|
|
| program_name
|
|
|
|
|
| program_version
|
|
|
|
|
| hierarchy_divider
|
|
|
|
|
| voltage
|
|
|
|
|
| process
|
|
|
|
|
| temperature
|
|
|
|
|
| time_scale
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
sdfversion
|
|
|
|
|
: '(' K_SDFVERSION QSTRING ')'
|
2007-11-21 07:20:22 +01:00
|
|
|
{ free($3);
|
2007-11-19 02:36:03 +01:00
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
design_name
|
|
|
|
|
: '(' K_DESIGN QSTRING ')'
|
|
|
|
|
{ vpi_printf("SDF Design: %s\n", $3);
|
|
|
|
|
free($3);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
date
|
|
|
|
|
: '(' K_DATE QSTRING ')'
|
|
|
|
|
{ vpi_printf("SDF Date: %s\n", $3);
|
|
|
|
|
free($3);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
vendor : '(' K_VENDOR QSTRING ')'
|
|
|
|
|
{ vpi_printf("SDF Vendor: %s\n", $3);
|
|
|
|
|
free($3);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
program_name : '(' K_PROGRAM QSTRING ')'
|
|
|
|
|
{ vpi_printf("SDF Program: %s\n", $3);
|
|
|
|
|
free($3);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
program_version : '(' K_VERSION QSTRING ')'
|
|
|
|
|
{ vpi_printf("SDF Program Version: %s\n", $3);
|
|
|
|
|
free($3);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
hierarchy_divider
|
2007-11-21 07:20:22 +01:00
|
|
|
: '(' K_DIVIDER '.' ')' { use_hchar = '.'; }
|
|
|
|
|
| '(' K_DIVIDER '/' ')' { use_hchar = '/'; }
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
voltage
|
|
|
|
|
: '(' K_VOLTAGE rtriple ')'
|
|
|
|
|
| '(' K_VOLTAGE signed_real_number ')'
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
process : '(' K_PROCESS QSTRING ')'
|
|
|
|
|
{ vpi_printf("SDF Process: %s\n", $3);
|
|
|
|
|
free($3);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
temperature
|
|
|
|
|
: '(' K_TEMPERATURE rtriple ')'
|
|
|
|
|
| '(' K_TEMPERATURE signed_real_number ')'
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
time_scale
|
|
|
|
|
: '(' K_TIMESCALE REAL_NUMBER IDENTIFIER ')'
|
|
|
|
|
{ vpi_printf("SDF TIMESCALE : %f%s\n", $3, $4);
|
|
|
|
|
free($4);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
cell_list
|
|
|
|
|
: cell_list cell
|
|
|
|
|
| cell
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
cell
|
2007-11-21 07:20:22 +01:00
|
|
|
: '(' K_CELL celltype cell_instance
|
|
|
|
|
{ sdf_select_instance($3, $4); /* find the instance in the design */}
|
|
|
|
|
timing_spec_list
|
|
|
|
|
')'
|
|
|
|
|
{ free($3);
|
|
|
|
|
free($4); }
|
2007-11-19 02:36:03 +01:00
|
|
|
| '(' K_CELL error ')'
|
2007-11-21 07:20:22 +01:00
|
|
|
{ vpi_printf("%s:%d: Syntax error in CELL\n",
|
|
|
|
|
sdf_parse_path, @2.first_line); }
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
celltype
|
|
|
|
|
: '(' K_CELLTYPE QSTRING ')'
|
2007-11-21 07:20:22 +01:00
|
|
|
{ $$ = $3; }
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
cell_instance
|
|
|
|
|
: '(' K_INSTANCE hierarchical_identifier ')'
|
2007-11-21 07:20:22 +01:00
|
|
|
{ $$ = $3; }
|
2007-11-19 02:36:03 +01:00
|
|
|
| '(' K_INSTANCE '*' ')'
|
2007-11-21 07:20:22 +01:00
|
|
|
{ $$ = 0; }
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
timing_spec_list
|
|
|
|
|
: timing_spec_list timing_spec
|
|
|
|
|
| timing_spec
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
timing_spec
|
|
|
|
|
: '(' K_DELAY deltype_list ')'
|
|
|
|
|
| '(' K_DELAY error ')'
|
|
|
|
|
{ vpi_printf("%s:%d: Syntax error in CELL DELAY SPEC\n",
|
|
|
|
|
sdf_parse_path, @2.first_line); }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
deltype_list
|
|
|
|
|
: deltype_list deltype
|
|
|
|
|
| deltype
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
deltype
|
|
|
|
|
: '(' K_ABSOLUTE del_def_list ')'
|
|
|
|
|
| '(' K_INCREMENT del_def_list ')'
|
|
|
|
|
| '(' error ')'
|
|
|
|
|
{ vpi_printf("%s:%d: Invalid/malformed delay type\n",
|
|
|
|
|
sdf_parse_path, @1.first_line); }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
del_def_list
|
|
|
|
|
: del_def_list del_def
|
|
|
|
|
| del_def
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
del_def
|
|
|
|
|
: '(' K_IOPATH port_spec port_instance delval_list ')'
|
2007-11-21 07:20:22 +01:00
|
|
|
{ sdf_iopath_delays($3, $4);
|
|
|
|
|
free($3);
|
|
|
|
|
free($4);
|
|
|
|
|
}
|
2007-11-19 02:36:03 +01:00
|
|
|
| '(' K_IOPATH error ')'
|
2007-11-21 07:20:22 +01:00
|
|
|
{ vpi_printf("%s:%d: Invalid/malformed IOPATH\n",
|
|
|
|
|
sdf_parse_path, @2.first_line); }
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
port_spec
|
|
|
|
|
: port_instance
|
|
|
|
|
/* | port_edge */
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
port_instance
|
2007-11-21 07:20:22 +01:00
|
|
|
: port { $$ = $1; }
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
port
|
|
|
|
|
: hierarchical_identifier
|
2007-11-21 07:20:22 +01:00
|
|
|
{ $$ = $1; }
|
|
|
|
|
/* | hierarchical_identifier '[' INTEGER ']' */
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
delval_list
|
|
|
|
|
: delval_list delval
|
|
|
|
|
| delval
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
delval
|
|
|
|
|
: rvalue
|
|
|
|
|
| '(' rvalue rvalue ')'
|
|
|
|
|
| '(' rvalue rvalue rvalue ')'
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rvalue
|
|
|
|
|
: '(' signed_real_number ')'
|
|
|
|
|
| '(' rtriple ')'
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
hierarchical_identifier
|
|
|
|
|
: IDENTIFIER
|
2007-11-21 07:20:22 +01:00
|
|
|
{ $$ = $1; }
|
2007-11-19 02:36:03 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
rtriple
|
|
|
|
|
: signed_real_number ':' signed_real_number ':' signed_real_number
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
signed_real_number
|
|
|
|
|
: REAL_NUMBER
|
|
|
|
|
| '+' REAL_NUMBER
|
|
|
|
|
| '-' REAL_NUMBER
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
void yyerror(const char*msg)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "SDF ERROR: %s\n", msg);
|
|
|
|
|
}
|