Arnim Läuger 16 years ago
parent a4a48f0158
commit 411b89d84e

@ -549,6 +549,18 @@ AC_CHECK_LIB([m], [fmax], [
])
dnl Enable use of DMALLOC library?
AC_ARG_ENABLE(dmalloc,
[AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging with dmalloc library])],
[dmalloc=$enableval], [dmalloc=no])
AS_IF([test "x$dmalloc" = xyes], [
AM_CONDITIONAL(DMALLOC, true)
AC_DEFINE(DMALLOC, 1, [define for dmalloc library])
],[
AM_CONDITIONAL(DMALLOC, false)
])
AC_OUTPUT
dnl

@ -89,6 +89,8 @@ nobase_dist_pkgdata_DATA = \
bsdl/STD_1149_1_1990 \
bsdl/STD_1149_1_1994 \
bsdl/STD_1149_1_2001 \
bsdl/STD_1532_2001 \
bsdl/STD_1532_2002 \
dec/PARTS \
dec/sa1100/STEPPINGS \
dec/sa1100/sa1100 \

@ -0,0 +1,19 @@
Package STD_1532_2001 is -- Attribute definitions for ISC description
use STD_1149_1_2001.all; -- Refer to BSDL definitions
attribute ISC_Conformance: BSDL_Extension;
attribute ISC_Pin_Behavior: BSDL_Extension;
attribute ISC_Fixed_System_Pins: BSDL_Extension; -- Optional
attribute ISC_Status: BSDL_Extension;
attribute ISC_Blank_Usercode: BSDL_Extension;
attribute ISC_Security: BSDL_Extension; -- Optional
attribute ISC_Flow: BSDL_Extension;
attribute ISC_Procedure: BSDL_Extension;
attribute ISC_Action: BSDL_Extension;
attribute ISC_Illegal_Exit: BSDL_Extension; -- Optional
attribute ISC_Design_Warning: BSDL_Extension; -- Optional
end STD_1532_2001;
Package Body STD_1532_2001 is
-- No content, this package body is required by BSDL syntax
end STD_1532_2001;

@ -0,0 +1,19 @@
Package STD_1532_2002 is -- Attribute definitions for ISC description
use STD_1149_1_2001.all; -- Refer to BSDL definitions
attribute ISC_Conformance: BSDL_Extension;
attribute ISC_Pin_Behavior: BSDL_Extension;
attribute ISC_Fixed_System_Pins: BSDL_Extension; -- Optional
attribute ISC_Status: BSDL_Extension;
attribute ISC_Blank_Usercode: BSDL_Extension;
attribute ISC_Security: BSDL_Extension; -- Optional
attribute ISC_Flow: BSDL_Extension;
attribute ISC_Procedure: BSDL_Extension;
attribute ISC_Action: BSDL_Extension;
attribute ISC_Illegal_Exit: BSDL_Extension; -- Optional
attribute ISC_Design_Warning: BSDL_Extension; -- Optional
end STD_1532_2002;
Package Body STD_1532_2002 is
-- No content, this package body is required by BSDL syntax
end STD_1532_2002;

@ -92,5 +92,9 @@ jtag_LDADD += -Ljim -ljim
jtag_DEPENDENCIES += jim/libjim.a
endif
if DMALLOC
jtag_LDADD += -ldmalloc
endif
localedir = $(datadir)/locale
INCLUDES = -DLOCALEDIR=\"$(localedir)\"

@ -23,19 +23,37 @@ include $(top_srcdir)/Makefile.rules
noinst_LIBRARIES = libbsdl.a
libbsdl_a_SOURCES = \
libbsdl_a_SOURCES = \
vhdl_bison.y \
vhdl_flex.l \
bsdl_bison.y \
bsdl_flex.l \
bsdl.c \
bsdl_flex.l \
bsdl.c \
bsdl_sem.c
bsdl_flex.$(OBJEXT) bsdl_sem.$(OBJEXT): bsdl_bison.$(OBJEXT)
# additional dependencies
# - all files depend on bsdl_config.h which dynamically generated
# - *_flex files must be processed after their *_bison counterparts
# to ensure that *_bison.h is present
vhdl_flex.$(OBJEXT): vhdl_bison.$(OBJEXT) bsdl_config.h
vhdl_bison.$(OBJEXT): bsdl_config.h
bsdl_flex.$(OBJEXT): bsdl_bison.$(OBJEXT) bsdl_config.h
bsdl_bison.$(OBJEXT): bsdl_config.h
bsdl.$(OBJEXT) : bsdl_config.h
bsdl_sem.$(OBJEXT): bsdl_config.h
vhdl_bison.h: vhdl_bison.c
bsdl_bison.h: bsdl_bison.c
bsdl_config.h: ../../config.h
grep 'DMALLOC' $< > $@
AM_LFLAGS = -i
MAINTAINERCLEANFILES = \
vhdl_bison.c \
vhdl_bison.h \
bsdl_bison.c \
bsdl_bison.h \
bsdl_flex.c
vhdl_flex.c \
bsdl_config.h

@ -36,148 +36,206 @@
#include "jtag.h"
#include "cmd.h"
#include "bsdl_local.h"
//#include "bsdl_local.h"
#include "bsdl_types.h"
#include "vhdl_parser.h"
#include "bsdl_parser.h"
#include "bsdl_msg.h"
void bsdl_msg(int type, const char *format, ...)
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/*****************************************************************************
* bsdl_msg( type, format, ... )
*
* Main printing function for the BSDL subsystem.
*
* Parameters
* type : one of the BSDL_MSG_* defines, determines message tag
* format : printf format
* ... : additional parameters to fill the printf format string
*
* Returns
* void
****************************************************************************/
void bsdl_msg( int type, const char *format, ... )
{
va_list lst;
va_start(lst, format);
switch (type) {
va_start( lst, format );
switch (type)
{
case BSDL_MSG_NOTE:
printf("-N- ");
printf( "-N- " );
break;
case BSDL_MSG_WARN:
printf("-W- ");
printf( "-W- " );
break;
case BSDL_MSG_ERR:
printf("-E- ");
printf( "-E- " );
break;
case BSDL_MSG_FATAL:
printf("-F- ");
printf( "-F- " );
break;
default:
printf("-?- ");
printf( "-?- " );
break;
}
vprintf(format, lst);
va_end(lst);
vprintf( format, lst );
va_end( lst );
}
/*****************************************************************************
* bsdl_read_file(BSDL_File_Name, mode, idcode)
* bsdl_read_file( chain, BSDL_File_Name, mode, idcode )
*
* Read, parse and optionally apply contents of BSDL file.
*
* mode: -1 -> read file
* no further action based on components
* 0 -> read file and extract all components
* dump commands to stdout, do not execute commands
* 1 -> read file and extract all components
* execute commands
* Parameters
* chain : pointer to active chain structure
* BSDL_File_Name : name of BSDL file to read
* mode : -1 -> read file
* no further action based on components
* 0 -> read file and extract all components
* dump commands to stdout, do not execute commands
* 1 -> read file and extract all components
* execute commands
* idcode : reference idcode string
*
* Return value:
* < 0 : Error occured, parse/syntax problems or out of memory
* = 0 : No errors, idcode not checked or mismatching
* > 0 : No errors, idcode checked and matched
* Returns
* < 0 : Error occured, parse/syntax problems or out of memory
* = 0 : No errors, idcode not checked or mismatching
* > 0 : No errors, idcode checked and matched
*
****************************************************************************/
int bsdl_read_file(chain_t *chain, const char *BSDL_File_Name, int mode, const char *idcode)
int bsdl_read_file( chain_t *chain, const char *BSDL_File_Name, int mode,
const char *idcode )
{
bsdl_globs_t *globs = &(chain->bsdl);
FILE *BSDL_File;
parser_priv_t *parser_priv;
vhdl_parser_priv_t *vhdl_parser_priv;
bsdl_parser_priv_t *bsdl_parser_priv;
jtag_ctrl_t jtag_ctrl;
int Compile_Errors = 1;
int idcode_match = 0;
BSDL_File = fopen(BSDL_File_Name, "r");
jtag_ctrl.mode = mode;
jtag_ctrl.debug = globs->debug;
/* perform some basic checks */
if (mode >= 0)
{
if (mode >= 1)
{
if (chain == NULL)
{
bsdl_msg( BSDL_MSG_ERR, _("No JTAG chain available\n") );
return -1;
}
if (chain->parts == NULL)
{
bsdl_msg( BSDL_MSG_ERR, _("Chain without any parts\n") );
return -1;
}
if (!(chain && chain->parts))
return -1;
jtag_ctrl.chain = chain;
jtag_ctrl.part = chain->parts->parts[chain->active_part];
}
else
{
jtag_ctrl.chain = NULL;
jtag_ctrl.part = NULL;
}
}
else
{
jtag_ctrl.chain = NULL;
jtag_ctrl.part = NULL;
}
BSDL_File = fopen( BSDL_File_Name, "r" );
if (globs->debug || (mode == 0))
bsdl_msg(BSDL_MSG_NOTE, _("Reading file '%s'\n"), BSDL_File_Name);
bsdl_msg( BSDL_MSG_NOTE, _("Reading file '%s'\n"), BSDL_File_Name );
if (BSDL_File == NULL) {
bsdl_msg(BSDL_MSG_ERR, _("Unable to open BSDL_file '%s'\n"), BSDL_File_Name);
bsdl_msg( BSDL_MSG_ERR, _("Unable to open BSDL file '%s'\n"), BSDL_File_Name );
return -1;
}
if ((parser_priv = bsdl_parser_init(BSDL_File, mode, globs->debug))) {
if (mode >= 0) {
if (mode >= 1) {
if (chain == NULL) {
bsdl_msg(BSDL_MSG_ERR, _("No JTAG chain available\n"));
bsdl_parser_deinit(parser_priv);
fclose(BSDL_File);
return -1;
}
if (chain->parts == NULL) {
bsdl_msg(BSDL_MSG_ERR, _("Chain without any parts\n"));
bsdl_parser_deinit(parser_priv);
fclose(BSDL_File);
return -1;
}
if (!(chain && chain->parts)) {
bsdl_parser_deinit(parser_priv);
fclose(BSDL_File);
return -1;
}
parser_priv->jtag_ctrl.chain = chain;
parser_priv->jtag_ctrl.part = chain->parts->parts[chain->active_part];
} else {
parser_priv->jtag_ctrl.chain = NULL;
parser_priv->jtag_ctrl.part = NULL;
}
} else {
parser_priv->jtag_ctrl.chain = NULL;
parser_priv->jtag_ctrl.part = NULL;
}
if ((vhdl_parser_priv = vhdl_parser_init( BSDL_File, &jtag_ctrl )))
{
vhdl_parser_priv->jtag_ctrl->idcode = NULL;
parser_priv->jtag_ctrl.idcode = NULL;
bsdlparse(parser_priv);
Compile_Errors = bsdl_flex_get_compile_errors(parser_priv->scanner);
if (Compile_Errors == 0) {
if (globs->debug)
bsdl_msg(BSDL_MSG_NOTE, _("BSDL file '%s' compiled correctly\n"), BSDL_File_Name);
} else {
if (globs->debug || (mode >= 0))
bsdl_msg(BSDL_MSG_ERR, _("BSDL file '%s' contains errors, stopping\n"), BSDL_File_Name);
}
vhdlparse( vhdl_parser_priv );
Compile_Errors = vhdl_flex_get_compile_errors( vhdl_parser_priv->scanner );
if (Compile_Errors == 0)
bsdl_ac_finalize(parser_priv);
if ((Compile_Errors == 0) && parser_priv->jtag_ctrl.idcode) {
{
if (globs->debug)
bsdl_msg(BSDL_MSG_NOTE, _("Got IDCODE: %s\n"), parser_priv->jtag_ctrl.idcode);
/* should be compare the idcodes? */
if (idcode) {
if (strlen(idcode) == strlen(parser_priv->jtag_ctrl.idcode)) {
int idx;
/* compare given idcode with idcode from BSDL file
including the end of string character */
idcode_match = 1;
for (idx = 0; idx <= strlen(idcode); idx++)
if (parser_priv->jtag_ctrl.idcode[idx] != 'X')
if (idcode[idx] != parser_priv->jtag_ctrl.idcode[idx])
idcode_match = 0;
if (globs->debug) {
if (idcode_match)
bsdl_msg(BSDL_MSG_NOTE, _("IDCODE matched\n") );
else
bsdl_msg(BSDL_MSG_NOTE, _("IDCODE mismatch\n") );
bsdl_msg( BSDL_MSG_NOTE, _("BSDL file '%s' passed VHDL stage correctly\n"),
BSDL_File_Name );
if ((bsdl_parser_priv = bsdl_parser_init( &jtag_ctrl )))
{
Compile_Errors = bsdl_sem_process_elements( bsdl_parser_priv );
if ((Compile_Errors == 0) && globs->debug)
bsdl_msg( BSDL_MSG_NOTE, _("BSDL file '%s' passed BSDL stage correctly\n"),
BSDL_File_Name );
/* handle IDCODE comparison */
if ((Compile_Errors == 0) && jtag_ctrl.idcode)
{
if (globs->debug)
bsdl_msg( BSDL_MSG_NOTE, _("Got IDCODE: %s\n"), jtag_ctrl.idcode );
/* should we compare the idcodes? */
if (idcode)
{
if (strlen( idcode ) == strlen(jtag_ctrl.idcode))
{
int idx;
/* compare given idcode with idcode from BSDL file
including the end of string character */
idcode_match = 1;
for (idx = 0; idx <= strlen( idcode ); idx++)
if (jtag_ctrl.idcode[idx] != 'X')
if (idcode[idx] != jtag_ctrl.idcode[idx])
idcode_match = 0;
if (globs->debug)
{
if (idcode_match)
bsdl_msg( BSDL_MSG_NOTE, _("IDCODE matched\n") );
else
bsdl_msg( BSDL_MSG_NOTE, _("IDCODE mismatch\n") );
}
}
}
}
}
if (parser_priv->jtag_ctrl.idcode)
free(parser_priv->jtag_ctrl.idcode);
parser_priv->jtag_ctrl.idcode = NULL;
bsdl_parser_deinit( bsdl_parser_priv );
}
}
else
{
if (globs->debug || (mode >= 0))
bsdl_msg( BSDL_MSG_ERR, _("BSDL file '%s' contains errors in VHDL stage, stopping\n"),
BSDL_File_Name );
}
bsdl_parser_deinit(parser_priv);
vhdl_parser_deinit( vhdl_parser_priv );
}
return Compile_Errors == 0 ? idcode_match : -1;
@ -185,83 +243,93 @@ int bsdl_read_file(chain_t *chain, const char *BSDL_File_Name, int mode, const c
/*****************************************************************************
* void bsdl_set_path(const char *pathlist)
* void bsdl_set_path( chain, pathlist )
*
* Dissects pathlist and enters its elements to the global variable
* bsdl.path_list.
*
* Return value:
* void
* Parameters
* chain : pointer to active chain structure
* pathlist : string containing the paths to be stored, format:
* <path1>;<path2>;<path3>;...
*
* Returns
* void
****************************************************************************/
void bsdl_set_path(chain_t *chain, const char *pathlist)
void bsdl_set_path( chain_t *chain, const char *pathlist )
{
bsdl_globs_t *globs = &(chain->bsdl);
char *delim;
char *elem;
char *pathelem;
int num;
char *delim;
char *elem;
char *pathelem;
int num;
size_t len;
/* free memory of current path list */
if (globs->path_list) {
if (globs->path_list)
{
for (num = 0; globs->path_list[num]; num++)
if (globs->path_list[num])
free(globs->path_list[num]);
free(globs->path_list);
free( globs->path_list[num] );
free( globs->path_list );
globs->path_list = NULL;
}
/* run through path list and determine number of elements */
for (num = 0, elem = (char *)pathlist; strlen(elem) > 0; ) {
delim = strchr(elem, ';');
if ((delim - elem > 0) || (delim == NULL)) {
for (num = 0, elem = (char *)pathlist; strlen(elem) > 0; )
{
delim = strchr( elem, ';' );
if ((delim - elem > 0) || (delim == NULL))
{
num++;
/* extend path list array */
globs->path_list = (char **)realloc(globs->path_list, (num+1) * sizeof(char *));
globs->path_list = (char **)realloc( globs->path_list, (num+1) * sizeof(char *) );
/* enter path element up to the delimeter */
if (delim == NULL)
len = strlen(elem);
len = strlen( elem );
else
len = delim-elem;
pathelem = malloc(len + 1);
memcpy(pathelem, elem, len);
pathelem = malloc( len + 1 );
memcpy( pathelem, elem, len );
pathelem[len] = '\0';
globs->path_list[num-1] = pathelem;
globs->path_list[num] = NULL;
}
elem = delim ? delim + 1 : elem + strlen(elem);
elem = delim ? delim + 1 : elem + strlen( elem );
}
if (globs->debug)
for (num = 0; globs->path_list[num] != NULL; num++) {
bsdl_msg(BSDL_MSG_NOTE, "%s\n", globs->path_list[num]);
}
for (num = 0; globs->path_list[num] != NULL; num++)
bsdl_msg( BSDL_MSG_NOTE, "%s\n", globs->path_list[num] );
}
/*****************************************************************************
* int bsdl_scan_files(const char *idcode, int mode)
* bsdl_scan_files( chain, idcode, mode )
*
* Scans through all files found via the elements in bsdl_path_list
* and does a test read on each of them.
* If mode >= 1 is requested, it will read the first BSDL file with matching
* idcode in "execute" mode. I.e. all extracted statements are applied to
* the current part.
*
* mode: -1 -> read file
* no further action based on components
* 0 -> read file and extract all components
* dump commands to stdout, do not execute commands
* 1 -> read file and extract all components
* execute commands
*
* Return value:
* < 0 : Error occured, parse/syntax problems or out of memory
* = 0 : No errors, idcode not checked or mismatching
* > 0 : No errors, idcode checked and matched
* Parameters
* chain : pointer to active chain structure
* idcode : reference idcode string
* mode : -1 -> read file
* no further action based on components
* 0 -> read file and extract all components
* dump commands to stdout, do not execute commands
* 1 -> read file and extract all components
* execute commands
*
* Returns
* < 0 : Error occured, parse/syntax problems or out of memory
* = 0 : No errors, idcode not checked or mismatching
* > 0 : No errors, idcode checked and matched
*
****************************************************************************/
int bsdl_scan_files(chain_t *chain, const char *idcode, int mode)
int bsdl_scan_files( chain_t *chain, const char *idcode, int mode )
{
bsdl_globs_t *globs = &(chain->bsdl);
int idx = 0;
@ -271,50 +339,70 @@ int bsdl_scan_files(chain_t *chain, const char *idcode, int mode)
if (globs->path_list == NULL)
return 0;
while (globs->path_list[idx] && (result <= 0)) {
while (globs->path_list[idx] && (result <= 0))
{
DIR *dir;
if ((dir = opendir(globs->path_list[idx]))) {
if ((dir = opendir( globs->path_list[idx] )))
{
struct dirent *elem;
/* run through all elements in the current directory */
while ((elem = readdir(dir)) && (result <= 0)) {
while ((elem = readdir( dir )) && (result <= 0))
{
char *name;
name = (char *)malloc(strlen(globs->path_list[idx]) + strlen(elem->d_name) + 1 + 1);
if (name) {
name = (char *)malloc( strlen( globs->path_list[idx] )
+ strlen( elem->d_name ) + 1 + 1 );
if (name)
{
struct stat buf;
strcpy(name, globs->path_list[idx]);
strcat(name, "/");
strcat(name, elem->d_name);
strcpy( name, globs->path_list[idx] );
strcat( name, "/" );
strcat( name, elem->d_name );
if (stat(name, &buf) == 0) {
if (buf.st_mode & S_IFREG) {
if (mode >= 1) {
if (stat( name, &buf ) == 0)
{
if (buf.st_mode & S_IFREG)
{
if (mode >= 1)
{
/* now we know we can finally read the file */
/* do a test read first */
result = bsdl_read_file(chain, name, -1, idcode);
if (result > 0) {
result = bsdl_read_file( chain, name, -1, idcode );
if (result > 0)
{
/* read in BSDL file if IDCODE matched */
printf( _(" Filename: %s\n"), name );
result = bsdl_read_file(chain, name, 1, idcode);
result = bsdl_read_file( chain, name, 1, idcode );
}
} else
result = bsdl_read_file(chain, name, mode, idcode);
}
else
result = bsdl_read_file( chain, name, mode, idcode );
}
}
free(name);
free( name );
}
}
closedir(dir);
} else
bsdl_msg(BSDL_MSG_WARN, _("Cannot open directory %s\n"), globs->path_list[idx]);
closedir( dir );
}
else
bsdl_msg( BSDL_MSG_WARN, _("Cannot open directory %s\n"), globs->path_list[idx] );
idx++;
}
return result;
}
/*
Local Variables:
mode:C
c-default-style:gnu
indent-tabs-mode:nil
End:
*/

File diff suppressed because it is too large Load Diff

@ -129,16 +129,23 @@ LEGAL NOTICES:
#include "bsdl_sysdep.h"
#include "bsdl_msg.h"
#include "bsdl_bison.h"
#include "bsdl_local.h"
#include "bsdl_parser.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#define YY_EXTRA_TYPE scan_extra_t *
static char *new_string(const char *);
static char *new_string( const char * );
#define BINARY 0
#define DECIMAL 1
#define BIN_X 2
#define HEX 3
%}
%a 2800
@ -147,95 +154,68 @@ static char *new_string(const char *);
%n 520
%k 140
%o 3000
%START RES BOU REG PAC
%START RES BOU REG PAC ISC
White [ \t\b\r]*
VHDL_Comment \-\-[^\n]*
Binary_Pattern [0-1]+
Bin_X_Pattern [0-1X]+
Hex_String [0-9A-F]+
Digit [0-9]
Exponent [E][+-]?{Digit}+
Real_Number {Digit}+[\.]{Digit}+{Exponent}
Decimal_Number {Digit}+
Identifier [A-Z][A-Z0-9_]*
Quoted_String \"[^\"\n]*\"
Concatenate &
Single_Quote [\']
Semicolon ;
Eol [\n]
Comma [,]
Lparen [\(]
Rparen [\)]
Lbracket [\[]
Rbracket [\]]
Colon_Equal \:\=
Colon [\:]
Period [\.]
Asterisk [\*]
Box [\<][\>]
Illegal [^A-Z0-9 \t\b\n\r\"\&\'\*\(\)\[\]\_\:\.\,\;\<\>]
Entity ENTITY
Port PORT
Generic GENERIC
Use USE
Attribute ATTRIBUTE
Is IS
Of OF
Dollar [\$]
Equal [\=]
Plus [\+]
Minus [\-]
Sh_Right [\>][\>]
Sh_Left [\<][\<]
Tilde [\~]
Question_Exclamation [\?][\!]
Question [\?]
Exclamation [\!]
Illegal [^A-Z0-9 \t\b\n\r\"\&\'\*\(\)\[\]\_\:\.\,\;\$\=\+\-\>\<\~\?\!]
Constant CONSTANT
String STRING
End END
All ALL
Physical_Pin_Map PHYSICAL_PIN_MAP
Pin_Map PIN_MAP
Pin_Map_String PIN_MAP_STRING
True TRUE
False FALSE
Signal SIGNAL
Tap_Scan_In TAP_SCAN_IN
Tap_Scan_Out TAP_SCAN_OUT
Tap_Scan_Clock TAP_SCAN_CLOCK
Tap_Scan_Mode TAP_SCAN_MODE
Tap_Scan_Reset TAP_SCAN_RESET
Low LOW
Both BOTH
Out OUT
Inout INOUT
In IN
Buffer BUFFER
Linkage LINKAGE
Bit_Vector BIT_VECTOR
Bit BIT
To TO
Downto DOWNTO
Package PACKAGE
Body BODY
Type TYPE
Subtype SUBTYPE
Record RECORD
Array ARRAY
Positive POSITIVE
Range RANGE
Cell_Info CELL_INFO
Instruction_Length INSTRUCTION_LENGTH
Instruction_Opcode INSTRUCTION_OPCODE
Instruction_Capture INSTRUCTION_CAPTURE
Instruction_Disable INSTRUCTION_DISABLE
Instruction_Guard INSTRUCTION_GUARD
Instruction_Private INSTRUCTION_PRIVATE
Instruction_Usage INSTRUCTION_USAGE
Instruction_Sequence INSTRUCTION_SEQUENCE
Register_Access REGISTER_ACCESS
Boundary_Cells BOUNDARY_CELLS
Boundary_Length BOUNDARY_LENGTH
Boundary_Register BOUNDARY_REGISTER
Idcode_Register IDCODE_REGISTER
Usercode_Register USERCODE_REGISTER
Design_Warning DESIGN_WARNING
Boundary BOUNDARY
Bypass BYPASS
Clamp CLAMP
Extest EXTEST
Highz HIGHZ
Idcode IDCODE
Device_Id DEVICE_ID
Intest INTEST
Preload PRELOAD
Runbist RUNBIST
Sample SAMPLE
Usercode USERCODE
Device_Id DEVICE_ID
Input INPUT
Output2 OUTPUT2
Output3 OUTPUT3
@ -253,185 +233,219 @@ Weak1 WEAK1
Pull0 PULL0
Pull1 PULL1
Keeper KEEPER
Extest EXTEST
Sample SAMPLE
Intest INTEST
Runbist RUNBIST
Pi PI
Po PO
Upd UPD
Cap CAP
X X
Zero ZERO
One ONE
Component_Conformance COMPONENT_CONFORMANCE
Port_Grouping PORT_GROUPING
Runbist_Execution RUNBIST_EXECUTION
Intest_Execution INTEST_EXECUTION
Bsdl_Extension BSDL_EXTENSION
Compliance_Patterns COMPLIANCE_PATTERNS
Component_Conformance COMPONENT_CONFORMANCE
Std_1149_1_1990 STD_1149_1_1990
Std_1149_1_1993 STD_1149_1_1993
Std_1149_1_2001 STD_1149_1_2001
ISC_Conformance ISC_CONFORMANCE
Std_1532_2001 STD_1532_2001
Std_1532_2002 STD_1532_2002
ISC_Pin_Behavior ISC_PIN_BEHAVIOR
ISC_Fixed_System_Pins ISC_FIXED_SYSTEM_PINS
ISC_Status ISC_STATUS
Implemented IMPLEMENTED
ISC_Blank_Usercode ISC_BLANK_USERCODE
ISC_Security ISC_SECURITY
ISC_Disable_Read ISC_DISABLE_READ
ISC_Disable_Program ISC_DISABLE_PROGRAM
ISC_Disable_Erase ISC_DISABLE_ERASE
ISC_Disable_Key ISC_DISABLE_KEY
ISC_Flow ISC_FLOW
Unprocessed UNPROCESSED
Exit_On_Error EXIT_ON_ERROR
Array ARRAY
Security SECURITY
Initialize INITIALIZE
Repeat REPEAT
Terminate TERMINATE
Loop LOOP
Wait WAIT
Min MIN
Max MAX
Crc CRC
Ost OST
ISC_Procedure ISC_PROCEDURE
ISC_Action ISC_ACTION
Proprierary PROPRIETARY
Optional OPTIONAL
Recommended RECOMMENDED
ISC_Illegal_Exit ISC_ILLEGAL_EXIT
%%
{Entity} {return(ENTITY); }
{Port} {yyextra->Base = DECIMAL; /* Default number base */
return(PORT); }
{Generic} {yyextra->Base = DECIMAL; return(GENERIC); }
{Use} {yyextra->Base = DECIMAL; return(USE); }
{Attribute} {yyextra->Base = DECIMAL; return(ATTRIBUTE); }
{Is} {return(IS); }
{Constant} {yyextra->Base = DECIMAL; return(CONSTANT); }
{String} {return(STRING); }
{End} {yyextra->Base = DECIMAL;
BEGIN INITIAL; /* Turn off start conditions */
return(END); }
{All} {return(ALL); }
{Of} {return(OF); }
{Pin_Map} {return(PIN_MAP); }
{Physical_Pin_Map} {return(PHYSICAL_PIN_MAP); }
{Pin_Map_String} {return(PIN_MAP_STRING); }
{True} {return(TRUE); }
{False} {return(FALSE); }
{Signal} {return(SIGNAL); }
{Tap_Scan_In} {return(TAP_SCAN_IN); }
{Tap_Scan_Out} {return(TAP_SCAN_OUT); }
{Tap_Scan_Clock} {return(TAP_SCAN_CLOCK); }
{Tap_Scan_Mode} {return(TAP_SCAN_MODE); }
{Tap_Scan_Reset} {return(TAP_SCAN_RESET); }
{Low} {return(LOW); }
{Both} {return(BOTH); }
{In} {return(IN); }
{Out} {return(OUT); }
{Inout} {return(INOUT); }
{Buffer} {return(BUFFER); }
{Linkage} {return(LINKAGE); }
{Bit} {return(BIT); }
{Bit_Vector} {return(BIT_VECTOR); }
{To} {return(TO); }
{Downto} {return(DOWNTO); }
{Package} {return(PACKAGE); }
{Body} {return(BODY); }
{Type} {return(TYPE); }
{Subtype} {return(SUBTYPE); }
{Record} {return(RECORD); }
{Array} {yyextra->Base = DECIMAL; return(ARRAY); }
{Positive} {return(POSITIVE); }
{Range} {return(RANGE); }
{Cell_Info} {BEGIN PAC; return(CELL_INFO); }
{Instruction_Length} {return(INSTRUCTION_LENGTH); }
{Constant} {yyextra->Base = DECIMAL; return( CONSTANT ); }
{Pin_Map} {return( PIN_MAP ); }
{Physical_Pin_Map} {return( PHYSICAL_PIN_MAP ); }
{Pin_Map_String} {return( PIN_MAP_STRING ); }
{Tap_Scan_In} {return( TAP_SCAN_IN ); }
{Tap_Scan_Out} {return( TAP_SCAN_OUT ); }
{Tap_Scan_Clock} {return( TAP_SCAN_CLOCK ); }
{Tap_Scan_Mode} {return( TAP_SCAN_MODE ); }
{Tap_Scan_Reset} {return( TAP_SCAN_RESET ); }
{Instruction_Length} {yyextra->Base = DECIMAL; return( INSTRUCTION_LENGTH ); }
{Instruction_Opcode} {yyextra->Base = BINARY; /* Enable Binary Patterns */
return(INSTRUCTION_OPCODE); }
return( INSTRUCTION_OPCODE ); }
{Instruction_Capture} {yyextra->Base = BIN_X; /* Enable Bin_X Patterns */
return(INSTRUCTION_CAPTURE); }
{Instruction_Disable} {return(INSTRUCTION_DISABLE); }
{Instruction_Guard} {return(INSTRUCTION_GUARD); }
{Instruction_Private} {return(INSTRUCTION_PRIVATE); }
{Instruction_Usage} {return(INSTRUCTION_USAGE); }
{Instruction_Sequence} {return(INSTRUCTION_SEQUENCE); }
{Register_Access} {BEGIN REG; return(REGISTER_ACCESS); }
{Boundary_Cells} {return(BOUNDARY_CELLS); }
{Boundary_Length} {return(BOUNDARY_LENGTH); }
{Boundary_Register} {BEGIN BOU; return(BOUNDARY_REGISTER); }
{Idcode_Register} {yyextra->Base = BIN_X; return(IDCODE_REGISTER); }
{Usercode_Register} {yyextra->Base = BIN_X; return(USERCODE_REGISTER); }
{Design_Warning} {return(DESIGN_WARNING); }
{Component_Conformance} {return(COMPONENT_CONFORMANCE); }
{Port_Grouping} {return(PORT_GROUPING); }
{Runbist_Execution} {return(RUNBIST_EXECUTION); }
{Intest_Execution} {return(INTEST_EXECUTION); }
{Bsdl_Extension} {return(BSDL_EXTENSION); }
{Compliance_Patterns} {yyextra->Base = DECIMAL; return(COMPLIANCE_PATTERNS); }
<REG>{Boundary} {return(BOUNDARY); }
<REG>{Bypass} {return(BYPASS); }
<REG>{Highz} {return(HIGHZ); }
<REG>{Idcode} {return(IDCODE); }
<REG>{Usercode} {return(USERCODE); }
<REG>{Device_Id} {return(DEVICE_ID); }
<BOU,PAC>{Input} {return(INPUT); }
<BOU,PAC>{Output2} {return(OUTPUT2); }
<BOU,PAC>{Output3} {return(OUTPUT3); }
<BOU,PAC>{Controlr} {return(CONTROLR); }
<BOU,PAC>{Control} {return(CONTROL); }
<BOU,PAC>{Internal} {return(INTERNAL); }
<BOU,PAC>{Clock} {return(CLOCK); }
<BOU,PAC>{Observe_Only} {return(OBSERVE_ONLY); }
<BOU>{Bidir} {return(BIDIR); }
<PAC>{Bidir_In} {return(BIDIR_IN); }
<PAC>{Bidir_Out} {return(BIDIR_OUT); }
<PAC>{Extest} {return(EXTEST); }
<PAC>{Sample} {return(SAMPLE); }
<PAC>{Intest} {return(INTEST); }
<PAC>{Runbist} {return(RUNBIST); }
<PAC>{Pi} {return(PI); }
<PAC>{Po} {return(PO); }
<PAC>{Upd} {return(UPD); }
<PAC>{Cap} {return(CAP); }
<PAC>{X} {return(X); }
<PAC>{Zero} {return(ZERO); }
<PAC>{One} {return(ONE); }
<BOU>{Z} {return(Z); }
<BOU>{Weak0} {return(WEAK0); }
<BOU>{Weak1} {return(WEAK1); }
<BOU>{Pull0} {return(PULL0); }
<BOU>{Pull1} {return(PULL1); }
<BOU>{Keeper} {return(KEEPER); }
return( INSTRUCTION_CAPTURE ); }
{Instruction_Disable} {return( INSTRUCTION_DISABLE ); }
{Instruction_Guard} {return( INSTRUCTION_GUARD ); }
{Instruction_Private} {return( INSTRUCTION_PRIVATE ); }
{Register_Access} {BEGIN(REG); yyextra->Base = DECIMAL;
return( REGISTER_ACCESS ); }
{Boundary_Length} {return( BOUNDARY_LENGTH ); }
{Boundary_Register} {BEGIN(BOU); yyextra->Base = DECIMAL;
return( BOUNDARY_REGISTER ); }
{Idcode_Register} {yyextra->Base = BIN_X; return( IDCODE_REGISTER ); }
{Usercode_Register} {yyextra->Base = BIN_X; return( USERCODE_REGISTER ); }
{Compliance_Patterns} {yyextra->Base = DECIMAL; return( COMPLIANCE_PATTERNS ); }
{Component_Conformance} {return( COMPONENT_CONFORMANCE ); }
{Std_1149_1_1990} {return( STD_1149_1_1990 ); }
{Std_1149_1_1993} {return( STD_1149_1_1993 ); }
{Std_1149_1_2001} {return( STD_1149_1_2001 ); }
{ISC_Conformance} {yyextra->Base = DECIMAL; return( ISC_CONFORMANCE ); }
{Std_1532_2001} {return( STD_1532_2001 ); }
{Std_1532_2002} {return( STD_1532_2002 ); }
{ISC_Pin_Behavior} {BEGIN(ISC); yyextra->Base = DECIMAL; return( ISC_PIN_BEHAVIOR ); }
{ISC_Fixed_System_Pins} {yyextra->Base = DECIMAL; return( ISC_FIXED_SYSTEM_PINS ); }
{ISC_Status} {yyextra->Base = DECIMAL; return( ISC_STATUS ); }
<ISC>{Implemented} {return( IMPLEMENTED ); }
{ISC_Blank_Usercode} {yyextra->Base = BIN_X; return( ISC_BLANK_USERCODE ); }
{ISC_Security} {yyextra->Base = DECIMAL; return( ISC_SECURITY ); }
{ISC_Disable_Read} {yyextra->Base = DECIMAL; return( ISC_DISABLE_READ ); }
{ISC_Disable_Program} {yyextra->Base = DECIMAL; return( ISC_DISABLE_PROGRAM ); }
{ISC_Disable_Erase} {yyextra->Base = DECIMAL; return( ISC_DISABLE_ERASE ); }
{ISC_Disable_Key} {yyextra->Base = DECIMAL; return( ISC_DISABLE_KEY ); }
{ISC_Flow} {yyextra->Base = DECIMAL; return( ISC_FLOW ); }
<ISC>{Unprocessed} {return( UNPROCESSED ); }
<ISC>{Exit_On_Error} {return( EXIT_ON_ERROR ); }
<ISC>{Array} {return( ARRAY ); }
<ISC>{Security} {return( SECURITY ); }
<ISC>{Preload} {return( PRELOAD ); }
<ISC>{Initialize} {return( INITIALIZE ); }
<ISC>{Repeat} {yyextra->Base = DECIMAL; return( REPEAT ); }
<ISC>{Terminate} {return( TERMINATE ); }
<ISC>{Loop} {return( LOOP ); }
<ISC>{Wait} {return( WAIT ); }
<ISC>{Min} {return( MIN ); }
<ISC>{Max} {return( MAX ); }
<ISC>{Crc} {return( CRC ); }
<ISC>{Ost} {return( OST ); }
<ISC>{Dollar} {return( DOLLAR ); }
<ISC>{Equal} {return( EQUAL ); }
<ISC>{Plus} {return( PLUS ); }
<ISC>{Minus} {return( MINUS ); }
<ISC>{Sh_Right} {return( SH_RIGHT ); }
<ISC>{Sh_Left} {return( SH_LEFT ); }
<ISC>{Tilde} {return( TILDE ); }
<ISC>{Question_Exclamation} {return( QUESTION_EXCLAMATION ); }
<ISC>{Question} {return( QUESTION_MARK ); }
<ISC>{Exclamation} {return( EXCLAMATION_MARK ); }
{ISC_Procedure} {yyextra->Base = DECIMAL; return( ISC_PROCEDURE ); }
{ISC_Action} {yyextra->Base = DECIMAL; return( ISC_ACTION ); }
<ISC>{Proprierary} {return( PROPRIETARY ); }
<ISC>{Optional} {return( OPTIONAL ); }
<ISC>{Recommended} {return( RECOMMENDED ); }
{ISC_Illegal_Exit} {return( ISC_ILLEGAL_EXIT ); }
<REG,ISC>{Bypass} {return( BYPASS ); }
<REG,ISC>{Boundary} {return( BOUNDARY ); }
<REG,ISC>{Clamp} {return( CLAMP ); }
<REG,ISC>{Extest} {return( EXTEST ); }
<REG,ISC>{Highz} {return( HIGHZ ); }
<REG,ISC>{Idcode} {return( IDCODE ); }
<REG,ISC>{Intest} {return( INTEST ); }
<REG,ISC>{Preload} {return( PRELOAD ); }
<REG,ISC>{Runbist} {return( RUNBIST ); }
<REG,ISC>{Sample} {return( SAMPLE ); }
<REG,ISC>{Usercode} {return( USERCODE ); }
<REG,ISC>{Device_Id} {return( DEVICE_ID ); }
<BOU,PAC>{Input} {return( INPUT ); }
<BOU,PAC>{Output2} {return( OUTPUT2 ); }
<BOU,PAC>{Output3} {return( OUTPUT3 ); }
<BOU,PAC>{Controlr} {return( CONTROLR ); }
<BOU,PAC>{Control} {return( CONTROL ); }
<BOU,PAC>{Internal} {return( INTERNAL ); }
<BOU,PAC>{Clock} {return( CLOCK ); }
<BOU,PAC>{Observe_Only} {return( OBSERVE_ONLY ); }
<BOU>{Bidir} {return( BIDIR ); }
<PAC>{Bidir_In} {return( BIDIR_IN ); }
<PAC>{Bidir_Out} {return( BIDIR_OUT ); }
<BOU>{Z} {return( Z ); }
<BOU>{Weak0} {return( WEAK0 ); }
<BOU>{Weak1} {return( WEAK1 ); }
<BOU>{Pull0} {return( PULL0 ); }
<BOU>{Pull1} {return( PULL1 ); }
<BOU>{Keeper} {return( KEEPER ); }
{Eol} {yylineno++; /* Count lines */}
{Comma} {return(COMMA); }
{Lparen} {return(LPAREN);}
{Rparen} {return(RPAREN);}
{Period} {return(PERIOD); }
{Lbracket} {return(LBRACKET); }
{Rbracket} {return(RBRACKET); }
{Colon} {return(COLON); }
{Asterisk} {return(ASTERISK); }
{Box} {return(BOX); }
{Single_Quote} {yyextra->Base = BIN_X; return(SINGLE_QUOTE); }
{Colon_Equal} {return(COLON_EQUAL); }
{Comma} {return( COMMA ); }
{Lparen} {return( LPAREN );}
{Rparen} {return( RPAREN );}
{Lbracket} {return( LBRACKET ); }
{Rbracket} {return( RBRACKET ); }
{Colon} {return( COLON ); }
{Asterisk} {return( ASTERISK ); }
{White} { /* Do Nothing on White Space */ }
{VHDL_Comment} { /* Do Nothing on Comments */ }
{Bin_X_Pattern} {if (yyextra->Base != BIN_X) REJECT;
yylval->str = new_string(yytext);
return(BIN_X_PATTERN);}
{Identifier} {yylval->str = new_string(yytext);
return(IDENTIFIER); }
{Quoted_String} {yylval->str = new_string(yytext);
return(QUOTED_STRING); }
yylval->str = new_string( yytext );
return( BIN_X_PATTERN );}
{Hex_String} {if (yyextra->Base != HEX) REJECT;
yylval->str = new_string( yytext );
return( HEX_STRING );}
{Identifier} {yylval->str = new_string( yytext );
return( IDENTIFIER ); }
{Binary_Pattern} {if (yyextra->Base != BINARY) REJECT;
yylval->str = new_string(yytext);
return(BINARY_PATTERN);}
yylval->str = new_string( yytext );
return( BINARY_PATTERN );}
{Decimal_Number} {if (yyextra->Base != DECIMAL) REJECT;
yylval->integer = atoi((char *)yytext);
return(DECIMAL_NUMBER);}
{Real_Number} {yylval->str = new_string(yytext);
return(REAL_NUMBER);}
{Concatenate} {return(CONCATENATE);}
{Semicolon} {return(SEMICOLON);}
yylval->integer = atoi( (char *)yytext );
return( DECIMAL_NUMBER );}
{Real_Number} {yylval->str = new_string( yytext );
return( REAL_NUMBER );}
{Illegal} {if (yyextra->debug || (yyextra->mode >= 0))
bsdl_msg(BSDL_MSG_ERR,
_("Illegal character %c (/%03o) at line %d:\n"),
(char)yytext[yyleng-1], (int)yytext[yyleng-1],
yylineno);
bsdl_msg( BSDL_MSG_ERR,
_("Illegal character %c (/%03o) at line %d:\n"),
(char)yytext[yyleng-1], (int)yytext[yyleng-1],
yylineno );
yyextra->Compile_Errors++;
return(ILLEGAL); /* Will cause syntax error */}
return( ILLEGAL ); /* Will cause syntax error */}
<<EOF>> {
yypop_buffer_state(yyscanner);
yypop_buffer_state( yyscanner );
if ( !YY_CURRENT_BUFFER )
yyterminate();
}
%%
void *bsdl_flex_init(FILE *f, int mode, int debug)
/*****************************************************************************
* void *bsdl_flex_init( int mode, int debug )
*
* Initializes the scanner and storage elements extra data structure.
*
* Parameters
* mode : -1 -> read file
* no further action based on components
* 0 -> read file and extract all components
* dump commands to stdout, do not execute commands
* 1 -> read file and extract all components
* execute commands
* debug : 1 -> emit failure messages
* 0 -> no failure messages
*
* Returns
* pointer to newly initialized scanner structure
****************************************************************************/
void *bsdl_flex_init( int mode, int debug )
{
scan_extra_t *extra;
yyscan_t scanner;
/* get our scanner structure */
if (yylex_init(&scanner) != 0) {
bsdl_msg(BSDL_MSG_FATAL, _("Scanner could not be initialized\n") );
if (yylex_init(&scanner) != 0)
{
bsdl_msg( BSDL_MSG_FATAL, _("Scanner could not be initialized\n") );
return NULL;
}
yyset_in(f, scanner);
if (!(extra = (scan_extra_t *)malloc(sizeof(scan_extra_t)))) {
bsdl_msg(BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__);
yylex_destroy(scanner);
if (!(extra = (scan_extra_t *)malloc( sizeof( scan_extra_t ) ))) {
bsdl_msg( BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
yylex_destroy( scanner );
return NULL;
}
@ -440,142 +454,252 @@ void *bsdl_flex_init(FILE *f, int mode, int debug)
extra->Compile_Errors = 0;
extra->Base = DECIMAL;
yyset_extra(extra, scanner);
yyset_extra( extra, scanner );
return scanner;
}
void bsdl_flex_deinit(void *scanner)
/*****************************************************************************
* void bsdl_flex_deinit( void *scanner )
*
* Deinitializes the scanner and closes the input file.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
void bsdl_flex_deinit( void *scanner )
{
if (yyget_in(scanner)) {
if (yyget_in( scanner ))
{
/* file might still be open so close it in any case
e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */
fclose(yyget_in(scanner));
yyset_in(NULL, scanner);
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
free(yyget_extra(scanner));
yylex_destroy(scanner);
free( yyget_extra( scanner ) );
yylex_destroy( scanner );
}
int yywrap(yyscan_t scanner)
/*****************************************************************************
* void yywrap( yyscan_t scanner )
*
* Closes the input file upon EOF condition.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* 1
****************************************************************************/
int yywrap( yyscan_t scanner )
{
if (yyget_in(scanner)) {
fclose(yyget_in(scanner));
yyset_in(NULL, scanner);
if (yyget_in( scanner )) {
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
return(1);
return 1;
}
static char *new_string(const char *str)
/*****************************************************************************
* char *new_string( const char *str )
*
* Allocates memory for a string and copies the contents of *str.
*
* Parameters
* str : pointer to string to be duplicated
*
* Returns
* pointer to allocated and initialized string memory
****************************************************************************/
static char *new_string( const char *str )
{
char *n_str;
size_t n_str_size;
n_str_size = strlen(str) + 1;
if ((n_str = (char *)malloc(n_str_size))) {
strncpy(n_str, str, n_str_size-1);
n_str_size = strlen( str ) + 1;
if ((n_str = (char *)malloc( n_str_size )))
{
strncpy( n_str, str, n_str_size-1 );
n_str[n_str_size-1] = '\0'; /* set very last element to EOS */
} else
}
else
bsdl_msg(BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__);
return(n_str);
}
void bsdl_flex_switch_file(yyscan_t scanner, char *filename)
{
scan_extra_t *extra;
FILE *f;
char *s;
/* convert filename to all upper case */
s = filename;
while (*s) {
if (islower(*s))
*s = toupper(*s);
s++;
}
/* file in current directory has precedence */
f = fopen(filename, "r");
if (!f) {
const char *db_path = jtag_get_data_dir();
char *db_file;
if ((db_file = (char *)malloc(strlen(db_path) +
1 + /* "/" */
4 + /* "bsdl" */
1 + /* "/" */
strlen(filename) +
1))) {
strcpy(db_file, db_path);
strcat(db_file, "/");
strcat(db_file, "bsdl");
strcat(db_file, "/");
strcat(db_file, filename);
f = fopen(db_file, "r");
if (!f)
bsdl_msg(BSDL_MSG_FATAL, _("Cannot open file %s or %s.\n"), filename, db_file);
free(db_file);
if (!f)
return;
}
}
yypush_buffer_state(yy_create_buffer(f, YY_BUF_SIZE, scanner), scanner);
extra = yyget_extra(scanner);
yyset_lineno(1, scanner);
}
void bsdl_flex_switch_buffer(yyscan_t scanner, const char *buffer)
/*****************************************************************************
* void bsdl_flex_switch_buffer( yyscan_t scanner, const char *buffer, int lineno )
*
* Selects the specified string buffer for further scanning.
*
* Parameters
* scanner : pointer to scanner definition structure
* buffer : pointer to string buffer to be scanned
* lineno : initial line number offset
*
* Returns
* void
****************************************************************************/
void bsdl_flex_switch_buffer( yyscan_t scanner, const char *buffer, int lineno )
{
/* ugly, ulgy, ugly
prepare yyg for later use of YY_CURRENT_BUFFER */
struct yyguts_t * yyg = (struct yyguts_t*)scanner;
int lineno;
lineno = yyget_lineno(scanner);
/* yy_scan_string() switches to the string buffer internally,
so we must save the current buffer state explicitly by pushing the stack
and setting top of stack to the current buffer state again.
yy_scan_string() can then savely switch YY_CURRENT_BUFFER to the string buffer.
yypop_buffer_state() will delete the string buffer afterwards and pop the saved
current buffer state. */
yypush_buffer_state(YY_CURRENT_BUFFER, scanner);
yy_scan_string(buffer, scanner);
yyset_lineno(lineno, scanner);
yypush_buffer_state( YY_CURRENT_BUFFER, scanner );
yy_scan_string( buffer, scanner );
yyset_lineno( lineno, scanner );
}
int bsdl_flex_get_compile_errors(yyscan_t scanner)
/*****************************************************************************
* void bsdl_flex_stop_buffer( yyscan_t scanner )
*
* Removes the current buffer from the scanner stack.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
void bsdl_flex_stop_buffer( yyscan_t scanner )
{
yypop_buffer_state( scanner );
// if ( !YY_CURRENT_BUFFER )
// yyterminate();
}
/*****************************************************************************
* int bsdl_flex_get_compile_errors( yyscan_t scanner )
*
* Retrieves the accumulated number of compile errors encountered so far.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* number of compile errors
****************************************************************************/
int bsdl_flex_get_compile_errors( yyscan_t scanner )
{
scan_extra_t *extra = yyget_extra(scanner);
scan_extra_t *extra = yyget_extra( scanner );
return extra->Compile_Errors;
}
static void bsdl_flex_set_compile_errors(int n, yyscan_t scanner)
/*****************************************************************************
* void bsdl_flex_set_compile_errors( int n, yyscan_t scanner )
*
* Sets the number of compile errors to n.
*
* Parameters
* n : preset number
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
static void bsdl_flex_set_compile_errors( int n, yyscan_t scanner )
{
scan_extra_t *extra = yyget_extra(scanner);
scan_extra_t *extra = yyget_extra( scanner );
extra->Compile_Errors = n;
}
int bsdl_flex_postinc_compile_errors(yyscan_t scanner)
/*****************************************************************************
* int bsdl_flex_postinc_compile_errors( yyscan_t scanner )
*
* Increments the number of compile errors.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* number of compile errors before increment
****************************************************************************/
int bsdl_flex_postinc_compile_errors( yyscan_t scanner )
{
int errors = bsdl_flex_get_compile_errors(scanner);
int errors = bsdl_flex_get_compile_errors( scanner );
bsdl_flex_set_compile_errors(errors+1, scanner);
bsdl_flex_set_compile_errors( errors+1, scanner );
return errors;
}
int bsdl_flex_get_lineno(yyscan_t scanner)
/*****************************************************************************
* void bsdl_flex_set_bin_x( yyscan_t scanner )
*
* Selects BIN_X mode for pattern matching.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
void bsdl_flex_set_bin_x( yyscan_t scanner )
{
scan_extra_t *extra = yyget_extra( scanner );
extra->Base = BIN_X;
}
/*****************************************************************************
* void bsdl_flex_set_hex( yyscan_t scanner )
*
* Selects HEX mode for pattern matching.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
void bsdl_flex_set_hex( yyscan_t scanner )
{
return yyget_lineno(scanner);
scan_extra_t *extra = yyget_extra( scanner );
extra->Base = HEX;
}
void bsdl_flex_set_bin_x(yyscan_t scanner)
/*****************************************************************************
* void bsdl_flex_set_decimal( yyscan_t scanner )
*
* Selects DECIMAL mode for pattern matching.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
void bsdl_flex_set_decimal( yyscan_t scanner )
{
scan_extra_t *extra = yyget_extra(scanner);
extra->Base = BIN_X;
scan_extra_t *extra = yyget_extra( scanner );
extra->Base = DECIMAL;
}
/*
Local Variables:
mode:C
c-default-style:gnu
indent-tabs-mode:nil
End:
*/

@ -1,182 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2007, Arnim Laeuger
*
* This program is free software; you can redistribute it and/or
* modify it 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.
*
* Written by Arnim Laeuger <arniml@users.sourceforge.net>, 2007.
*
*/
#ifndef BSDL_LOCAL_H
#define BSDL_LOCAL_H
#include <jtag.h>
/* message types for bsdl_msg() */
#define BSDL_MSG_NOTE 0
#define BSDL_MSG_WARN 1
#define BSDL_MSG_ERR 2
#define BSDL_MSG_FATAL 3
/* private data of the flex scanner
handled internally in bsdl_flex.l as yyextra */
struct scan_extra {
int mode;
int debug;
int Compile_Errors;
int Base;
};
typedef struct scan_extra scan_extra_t;
/* list of instructions
the instruction name and its opcode (optional) is stored here */
struct instr_elem {
struct instr_elem *next;
char *instr;
char *opcode;
};
/* register access information
* derived from the entries of the REGISTER_ACCESS attribute
* ainfo_elem describes a register and its accosiated instructions
* - register name
* - register length (optional)
* - list of associated instructions
*/
struct ainfo_elem {
struct ainfo_elem *next;
char *reg;
int reg_len;
struct instr_elem *instr_list;
};
/* the access_data structure is the entry point into the register access
management data
it contains the pointer to the main list of REGISTER_ACCESS entries plus
components that store temporary data while an entry is parser/built */
struct access_data {
struct ainfo_elem *ainfo_list;
/* temporary private data for building the "current" access info entry */
char *reg;
int reg_len;
struct instr_elem *instr_list;
};
/* structure cell_info collects bit/cell information from the
BOUNDARY_REGISTER attribute
each Cell_Entry fills in the structure and the contents is used for the
respective 'bit' command */
struct cell_info {
/* basic cell spec entries */
int bit_num;
char *port_name;
int cell_function;
char *basic_safe_value;
/* the disable spec entries */
int ctrl_bit_num;
int disable_safe_value;
};
/* structure string_elem enables to build lists of strings */
struct string_elem {
struct string_elem *next;
char *string;
};
/* structure port_desc contains all descriptive information for a port
definition:
- one or more names
- flag showing whether it's a vector (element) or a scalar
- low and high indice if it's a vector */
struct port_desc {
struct string_elem *names_list;
int is_vector;
int low_idx;
int high_idx;
};
/* structure jtag_ctrl collects all elements that are required to interface
with jtag internals */
struct jtag_ctrl {
int mode;
int debug;
char *idcode; /* IDCODE string */
chain_t *chain;
part_t *part;
struct port_desc port_desc;
struct cell_info cell_info;
struct instr_elem *instr_list;
struct access_data access_data;
};
/* private data of the bison parser
used to store variables the would end up as globals otherwise */
struct parser_priv {
char Package_File_Name[100];
int Reading_Package;
char *buffer_for_switch;
size_t len_buffer_for_switch;
void *scanner;
struct jtag_ctrl jtag_ctrl;
};
typedef struct parser_priv parser_priv_t;
void bsdl_msg(int, const char *, ...);
/* BSDL lexer declarations */
void *bsdl_flex_init(FILE *, int, int);
void bsdl_flex_deinit(void *);
void bsdl_flex_switch_file(void *, char *);
void bsdl_flex_switch_buffer(void *, const char *);
int bsdl_flex_get_compile_errors(void *);
int bsdl_flex_postinc_compile_errors(void *);
int bsdl_flex_get_lineno(void *);
void bsdl_flex_set_bin_x(void *);
/* BSDL parser declarations */
parser_priv_t *bsdl_parser_init(FILE *, int, int);
void bsdl_parser_deinit(parser_priv_t *);
int bsdlparse(parser_priv_t *);
/* BSDL / JTAG semantic action interface */
void bsdl_sem_init(parser_priv_t *);
void bsdl_sem_deinit(parser_priv_t *);
void bsdl_set_entity(parser_priv_t *, char *);
void bsdl_set_instruction_length(parser_priv_t *, int);
void bsdl_prt_add_name(parser_priv_t *, char *);
void bsdl_prt_add_bit(parser_priv_t *);
void bsdl_prt_add_range(parser_priv_t *, int, int);
void bsdl_prt_apply_port(parser_priv_t *);
void bsdl_set_idcode(parser_priv_t *, char *);
void bsdl_set_usercode(parser_priv_t *, char *);
void bsdl_add_instruction(parser_priv_t *, char *, char *);
void bsdl_set_bsr_length(parser_priv_t *, int);
void bsdl_ci_no_disable(parser_priv_t *);
void bsdl_ci_set_cell_spec(parser_priv_t *, int, char *);
void bsdl_ci_set_cell_spec_disable(parser_priv_t *, int, int, int);
void bsdl_ci_apply_cell_info(parser_priv_t *, int);
void bsdl_ac_set_register(parser_priv_t *, char *, int);
void bsdl_ac_add_instruction(parser_priv_t *, char *);
void bsdl_ac_apply_assoc(parser_priv_t *);
void bsdl_ac_finalize(parser_priv_t *);
#endif /* BSDL_LOCAL_H */

@ -0,0 +1,36 @@
/*
* $Id$
*
* Copyright (C) 2008, Arnim Laeuger
*
* This program is free software; you can redistribute it and/or
* modify it 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.
*
* Written by Arnim Laeuger <arniml@users.sourceforge.net>, 2007.
*
*/
#ifndef BSDL_MSG_H
#define BSDL_MSG_H
/* message types for bsdl_msg() */
#define BSDL_MSG_NOTE 0
#define BSDL_MSG_WARN 1
#define BSDL_MSG_ERR 2
#define BSDL_MSG_FATAL 3
void bsdl_msg( int, const char *, ... );
#endif /* BSDL_MSG_H */

@ -0,0 +1,49 @@
/*
* $Id$
*
* Copyright (C) 2008, Arnim Laeuger
*
* This program is free software; you can redistribute it and/or
* modify it 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.
*
* Written by Arnim Laeuger <arniml@users.sourceforge.net>, 2008.
*
*/
#ifndef BSDL_PARSER_H
#define BSDL_PARSER_H
#include "bsdl_types.h"
/* VHDL lexer declarations */
void *bsdl_flex_init( int, int );
void bsdl_flex_deinit( void * );
void bsdl_flex_set_bin_x( void * );
void bsdl_flex_set_hex( void * );
void bsdl_flex_set_decimal( void * );
int bsdl_flex_get_compile_errors( void * );
int bsdl_flex_postinc_compile_errors( void * );
void bsdl_flex_switch_buffer( void *, const char *, int );
void bsdl_flex_stop_buffer( void * );
/* BSDL parser declarations */
bsdl_parser_priv_t *bsdl_parser_init( jtag_ctrl_t * );
void bsdl_parser_deinit( bsdl_parser_priv_t * );
int bsdlparse( bsdl_parser_priv_t * );
/* BSDL semantic functions */
int bsdl_sem_process_elements( bsdl_parser_priv_t * );
#endif /* BSDL_PARSER_H */

File diff suppressed because it is too large Load Diff

@ -26,6 +26,8 @@
#define BSDL_SYSDEP_H
#include "bsdl_config.h"
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)

@ -0,0 +1,195 @@
/*
* $Id$
*
* Copyright (C) 2008, Arnim Laeuger
*
* This program is free software; you can redistribute it and/or
* modify it 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.
*
* Written by Arnim Laeuger <arniml@users.sourceforge.net>, 2008.
*
*/
#ifndef BSDL_TYPES_H
#define BSDL_TYPES_H
#include <jtag.h>
/* private data of the flex scanner
handled internally in bsdl_flex.l as yyextra */
struct scan_extra
{
int mode;
int debug;
int Compile_Errors;
int Base;
};
typedef struct scan_extra scan_extra_t;
/* list of instructions
the instruction name and its opcode (optional) is stored here */
struct instr_elem
{
struct instr_elem *next;
char *instr;
char *opcode;
};
typedef struct instr_elem instr_elem_t;
/* register access information
* derived from the entries of the REGISTER_ACCESS attribute
* ainfo_elem describes a register and its accosiated instructions
* - register name
* - register length (optional)
* - list of associated instructions
*/
struct ainfo_elem
{
struct ainfo_elem *next;
char *reg;
int reg_len;
instr_elem_t *instr_list;
};
typedef struct ainfo_elem ainfo_elem_t;
/* structure cell_info collects bit/cell information from the
BOUNDARY_REGISTER attribute
each Cell_Entry fills in the structure and the contents is used for the
respective 'bit' command */
struct cell_info
{
struct cell_info *next;
/* basic cell spec entries */
int bit_num;
char *port_name;
int cell_function;
char *basic_safe_value;
/* the disable spec entries */
int ctrl_bit_num;
int disable_safe_value;
};
typedef struct cell_info cell_info_t;
/* structure string_elem enables to build lists of strings */
struct string_elem
{
struct string_elem *next;
char *string;
};
typedef struct string_elem string_elem_t;
/* structure port_desc contains all descriptive information for a port
definition:
- one or more names
- flag showing whether it's a vector (element) or a scalar
- low and high indice if it's a vector */
struct port_desc
{
string_elem_t *names_list;
struct port_desc *next;
int is_vector;
int low_idx;
int high_idx;
};
typedef struct port_desc port_desc_t;
typedef enum
{
VET_CONSTANT,
VET_ATTRIBUTE_STRING,
VET_ATTRIBUTE_DECIMAL,
VET_UNKNOWN
} vhdl_elem_type_t;
struct vhdl_elem
{
struct vhdl_elem *next;
vhdl_elem_type_t type;
char *name;
char *payload;
int line;
};
typedef struct vhdl_elem vhdl_elem_t;
typedef enum
{
CONF_1990,
CONF_1993,
CONF_2001,
CONF_UNKNOWN
} bsdl_conformance_t;
/* structure jtag_ctrl collects all elements that are required to interface
with jtag internals */
struct jtag_ctrl
{
int mode;
int debug;
chain_t *chain;
part_t *part;
/* collected by VHDL parser */
port_desc_t *port_desc;
vhdl_elem_t *vhdl_elem_first;
vhdl_elem_t *vhdl_elem_last;
/* collected by BSDL parser */
char *idcode; /* IDCODE string */
char *usercode; /* USERCODE string */
int instr_len;
int bsr_len;
bsdl_conformance_t conformance;
instr_elem_t *instr_list;
ainfo_elem_t *ainfo_list;
cell_info_t *cell_info_first;
cell_info_t *cell_info_last;
};
typedef struct jtag_ctrl jtag_ctrl_t;
/* private data of the VHDL bison parser
used to store variables the would end up as globals otherwise */
struct vhdl_parser_priv
{
char Package_File_Name[100];
int Reading_Package;
char *buffer;
size_t len_buffer;
void *scanner;
jtag_ctrl_t *jtag_ctrl;
port_desc_t tmp_port_desc;
};
typedef struct vhdl_parser_priv vhdl_parser_priv_t;
/* private data of the BSDL bison parser
used to store variables the would end up as globals otherwise */
struct bsdl_parser_priv
{
void *scanner;
jtag_ctrl_t *jtag_ctrl;
int lineno;
ainfo_elem_t ainfo;
cell_info_t tmp_cell_info;
port_desc_t tmp_port_desc;
};
typedef struct bsdl_parser_priv bsdl_parser_priv_t;
#endif /* BSDL_TYPES_H */
/*
Local Variables:
mode:C
c-default-style:gnu
indent-tabs-mode:nil
End:
*/

File diff suppressed because it is too large Load Diff

@ -0,0 +1,612 @@
/*
* $Id$
*
* Original Lex source by Ken Parker, 1990
* Extensions and adaptions for UrJTAG by Arnim Laeuger, 2007
*
*/
/*----------------------------------------------------------
*
* Lex source for BSDL
*
*----------------------------------------------------------*/
/* Date: 901003 */
/*
Email header accompanying the original Yacc code:
http://www.eda.org/vug_bbs/bsdl.parser
-----------------------------------8<--------------------------------------
Hello All,
This is this first mailing of the BSDL* Version 0.0 parser specifications
we are sending to people who request it from our publicized E-Mail address;
bsdl%hpmtlx@hplabs.HP.com
You are free to redistribute this at will, but we feel that it would be
better if respondents asked for it directly so that their addresses can
be entered into our list for future mailings and updates.
It would be helpful if you could confirm receipt of this transmission.
We also would be very interested to hear about your experiences with this
information and what you are planning to do with BSDL.
Regards,
Ken Parker
Hewlett-Packard Company
*Boundary-Scan Description Language - as documented in:
"A Language for Describing Boundary-Scan Devices", K.P. Parker
and S. Oresjo, Proceedings 1990 International Test Conference,
Washington DC, pp 222-234
- -----------------cut here---------------------------------------------------
901004.0721 Hewlett-Packard Company
901016.1049 Manufacturing Test Division
P.O. Box 301
Loveland, Colorado 80537
USA
October 1990
Hello BSDL Parser Requestor,
This Electronic Mail reply contains the computer specifications for
Hewlett-Packard's Version 0.0 BSDL parser. This section of the reply
explains the contents of the rest of this file.
This file is composed of seven (7) parts:
1) How to use this file
2) UNIX* Lex source (lexicographical tokenizing rules)
3) UNIX* Yacc source (BNF-like syntax description)
4) A sample main program to recognize BSDL.
5) A BSDL description of the Texas Instruments 74bct8374 that is
recognized by the parser, for testing purposes.
6) The VHDL package STD_1149_1_1990 needed by this parser.
7) [added 901016] Porting experiences to other systems.
RECOMMENDATION: Save a copy of this file in archival storage before
processing it via the instructions below. This will
allow you to recover from errors, and allow you to
compare subsequently released data for changes.
DISCLAIMERS:
1. The IEEE 1149.1 Working Group has not endorsed BSDL Version 0.0 and
therefore no person may represent it as an IEEE standard or imply that
a resulting IEEE standard will be identical to it.
2. The IEEE 1149.1 Working Group recognizes that BSDL Version 0.0 is a
well-conceived initiative that is likely to excelerate the creation
of tools that support the 1149.1 standard. As such, changes and
enhancements will be carefully considered so as not to needlessly
disrupt these development efforts. The overriding goal is the
ultimate success of the 1149.1 standard.
LEGAL NOTICES:
Hewlett-Packard Company makes no warranty of any kind with regard to
this information, including, but not limited to, the implied
waranties of merchantability and fitness for a particular purpose.
Hewlett-Packard Company shall not be liable for errors contained
herein or direct, indirect, special, incidental, or consequential
damages in connection with the furnishing, performance, or use of
this material.
*UNIX is a trademark of AT&T in the USA and other countries.
*/
%option bison-bridge
%option reentrant
%option prefix="vhdl"
%option outfile="lex.yy.c"
%{
/* Begin lex input specifications */
#include <stdlib.h>
#include <ctype.h>
#include "bsdl_sysdep.h"
#include "bsdl_msg.h"
#include "vhdl_bison.h"
#include "vhdl_parser.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#define YY_EXTRA_TYPE scan_extra_t *
static char *new_string( const char * );
#define BINARY 0
#define DECIMAL 1
#define BIN_X 2
%}
%a 2800
%e 1200
%p 4700
%n 520
%k 140
%o 3000
%START RES BOU REG PAC
White [ \t\b\r]*
VHDL_Comment \-\-[^\n]*
Bin_X_Pattern [0-1X]+
Digit [0-9]
Exponent [E][+-]?{Digit}+
Real_Number {Digit}+[\.]{Digit}+{Exponent}
Decimal_Number {Digit}+
Identifier [A-Z][A-Z0-9_]*
Quoted_String \"[^\"\n]*\"
Concatenate &
Single_Quote [\']
Semicolon ;
Eol [\n]
Comma [,]
Lparen [\(]
Rparen [\)]
Colon_Equal \:\=
Colon [\:]
Period [\.]
Box [\<][\>]
Illegal [^A-Z0-9 \t\b\n\r\"\&\'\*\(\)\[\]\_\:\.\,\;\<\>]
Entity ENTITY
Port PORT
Generic GENERIC
Use USE
Attribute ATTRIBUTE
Is IS
Of OF
Constant CONSTANT
String STRING
End END
All ALL
Physical_Pin_Map PHYSICAL_PIN_MAP
Pin_Map_String PIN_MAP_STRING
True TRUE
False FALSE
Signal SIGNAL
Low LOW
Both BOTH
Out OUT
Inout INOUT
In IN
Buffer BUFFER
Linkage LINKAGE
Bit_Vector BIT_VECTOR
Bit BIT
To TO
Downto DOWNTO
Package PACKAGE
Body BODY
Type TYPE
Subtype SUBTYPE
Record RECORD
Array ARRAY
Positive POSITIVE
Range RANGE
Cell_Info CELL_INFO
Input INPUT
Output2 OUTPUT2
Output3 OUTPUT3
Control CONTROL
Controlr CONTROLR
Internal INTERNAL
Clock CLOCK
Observe_Only OBSERVE_ONLY
Bidir BIDIR
Bidir_In BIDIR_IN
Bidir_Out BIDIR_OUT
Z Z
Extest EXTEST
Sample SAMPLE
Intest INTEST
Runbist RUNBIST
Pi PI
Po PO
Upd UPD
Cap CAP
X X
Zero ZERO
One ONE
Bsdl_Extension BSDL_EXTENSION
Std_1532_2001 STD_1532_2001
Std_1532_2002 STD_1532_2002
%%
{Entity} {return( ENTITY ); }
{Port} {yyextra->Base = DECIMAL; /* Default number base */
return( PORT ); }
{Generic} {yyextra->Base = DECIMAL; return( GENERIC ); }
{Use} {yyextra->Base = DECIMAL; return( USE ); }
{Attribute} {yyextra->Base = DECIMAL; return( ATTRIBUTE ); }
{Is} {return( IS ); }
{Constant} {yyextra->Base = DECIMAL; return( CONSTANT ); }
{String} {return( STRING ); }
{End} {yyextra->Base = DECIMAL;
BEGIN INITIAL; /* Turn off start conditions */
return( END ); }
{All} {return( ALL ); }
{Of} {return( OF ); }
{Physical_Pin_Map} {return( PHYSICAL_PIN_MAP ); }
{Pin_Map_String} {return( PIN_MAP_STRING ); }
{True} {return( TRUE ); }
{False} {return( FALSE ); }
{Signal} {return( SIGNAL ); }
{Low} {return( LOW ); }
{Both} {return( BOTH ); }
{In} {return( IN ); }
{Out} {return( OUT ); }
{Inout} {return( INOUT ); }
{Buffer} {return( BUFFER ); }
{Linkage} {return( LINKAGE ); }
{Bit} {return( BIT ); }
{Bit_Vector} {return( BIT_VECTOR ); }
{To} {return( TO ); }
{Downto} {return( DOWNTO ); }
{Package} {return( PACKAGE ); }
{Body} {return( BODY ); }
{Type} {return( TYPE ); }
{Subtype} {return( SUBTYPE ); }
{Record} {return( RECORD ); }
{Array} {yyextra->Base = DECIMAL; return( ARRAY ); }
{Positive} {return( POSITIVE ); }
{Range} {return( RANGE ); }
{Cell_Info} {BEGIN PAC; return( CELL_INFO ); }
{Bsdl_Extension} {return( BSDL_EXTENSION ); }
{Std_1532_2001} {return( STD_1532_2001 ); }
{Std_1532_2002} {return( STD_1532_2002 ); }
<BOU,PAC>{Input} {return( INPUT ); }
<BOU,PAC>{Output2} {return( OUTPUT2 ); }
<BOU,PAC>{Output3} {return( OUTPUT3 ); }
<BOU,PAC>{Controlr} {return( CONTROLR ); }
<BOU,PAC>{Control} {return( CONTROL ); }
<BOU,PAC>{Internal} {return( INTERNAL ); }
<BOU,PAC>{Clock} {return( CLOCK ); }
<BOU,PAC>{Observe_Only} {return( OBSERVE_ONLY ); }
<BOU>{Bidir} {return( BIDIR ); }
<PAC>{Bidir_In} {return( BIDIR_IN ); }
<PAC>{Bidir_Out} {return( BIDIR_OUT ); }
<PAC>{Extest} {return( EXTEST ); }
<PAC>{Sample} {return( SAMPLE ); }
<PAC>{Intest} {return( INTEST ); }
<PAC>{Runbist} {return( RUNBIST ); }
<PAC>{Pi} {return( PI ); }
<PAC>{Po} {return( PO ); }
<PAC>{Upd} {return( UPD ); }
<PAC>{Cap} {return( CAP ); }
<PAC>{X} {return( X ); }
<PAC>{Zero} {return( ZERO ); }
<PAC>{One} {return( ONE ); }
<BOU>{Z} {return( Z ); }
{Eol} {yylineno++; /* Count lines */}
{Comma} {return( COMMA ); }
{Lparen} {return( LPAREN );}
{Rparen} {return( RPAREN );}
{Period} {return( PERIOD ); }
{Colon} {return( COLON ); }
{Box} {return( BOX ); }
{Single_Quote} {yyextra->Base = BIN_X; return( SINGLE_QUOTE ); }
{Colon_Equal} {return( COLON_EQUAL ); }
{White} { /* Do Nothing on White Space */ }
{VHDL_Comment} { /* Do Nothing on Comments */ }
{Bin_X_Pattern} {if (yyextra->Base != BIN_X) REJECT;
yylval->str = new_string( yytext );
return( BIN_X_PATTERN );}
{Identifier} {yylval->str = new_string( yytext );
return( IDENTIFIER ); }
{Quoted_String} {yylval->str = new_string( yytext );
return( QUOTED_STRING ); }
{Decimal_Number} {if (yyextra->Base != DECIMAL) REJECT;
yylval->integer = atoi( (char *)yytext );
return( DECIMAL_NUMBER );}
{Real_Number} {yylval->str = new_string( yytext );
return( REAL_NUMBER );}
{Concatenate} {return( CONCATENATE );}
{Semicolon} {return( SEMICOLON );}
{Illegal} {if (yyextra->debug || (yyextra->mode >= 0))
bsdl_msg( BSDL_MSG_ERR,
_("Illegal character %c (/%03o) at line %d:\n"),
(char)yytext[yyleng-1], (int)yytext[yyleng-1],
yylineno );
yyextra->Compile_Errors++;
return( ILLEGAL ); /* Will cause syntax error */}
<<EOF>> {
yypop_buffer_state( yyscanner );
if ( !YY_CURRENT_BUFFER )
yyterminate();
}
%%
/*****************************************************************************
* void *vhdl_flex_init( FILE *f, int mode, int debug )
*
* Initializes the scanner and storage elements extra data structure.
*
* Parameters
* f : descriptor of file for scanning
* mode : -1 -> read file
* no further action based on components
* 0 -> read file and extract all components
* dump commands to stdout, do not execute commands
* 1 -> read file and extract all components
* execute commands
* debug : 1 -> emit failure messages
* 0 -> no failure messages
*
* Returns
* pointer to newly initialized scanner structure
****************************************************************************/
void *vhdl_flex_init( FILE *f, int mode, int debug )
{
scan_extra_t *extra;
yyscan_t scanner;
/* get our scanner structure */
if (yylex_init( &scanner ) != 0)
{
bsdl_msg( BSDL_MSG_FATAL, _("Scanner could not be initialized\n") );
return NULL;
}
yyset_in( f, scanner );
if (!(extra = (scan_extra_t *)malloc( sizeof( scan_extra_t ) )))
{
bsdl_msg( BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
yylex_destroy( scanner );
return NULL;
}
extra->mode = mode;
extra->debug = debug;
extra->Compile_Errors = 0;
extra->Base = DECIMAL;
yyset_extra( extra, scanner );
return scanner;
}
/*****************************************************************************
* void vhdl_flex_deinit( void *scanner )
*
* Deinitializes the scanner and closes the input file.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
void vhdl_flex_deinit( void *scanner )
{
if (yyget_in( scanner ))
{
/* file might still be open so close it in any case
e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
free( yyget_extra( scanner ) );
yylex_destroy( scanner );
}
/*****************************************************************************
* void yywrap( yyscan_t scanner )
*
* Closes the input file upon EOF condition.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* 1
****************************************************************************/
int yywrap( yyscan_t scanner )
{
if (yyget_in( scanner ))
{
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
return 1;
}
/*****************************************************************************
* char *new_string( const char *str )
*
* Allocates memory for a string and copies the contents of *str.
*
* Parameters
* str : pointer to string to be duplicated
*
* Returns
* pointer to allocated and initialized string memory
****************************************************************************/
static char *new_string( const char *str )
{
char *n_str;
size_t n_str_size;
n_str_size = strlen( str ) + 1;
if ((n_str = (char *)malloc( n_str_size )))
{
strncpy( n_str, str, n_str_size-1 );
n_str[n_str_size-1] = '\0'; /* set very last element to EOS */
}
else
bsdl_msg( BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
return n_str;
}
/*****************************************************************************
* void vhdl_flex_switch_file( yyscan_t scanner, char *filename )
*
* Selects the specified file for further scanning.
*
* Parameters
* scanner : pointer to scanner definition structure
* filename : name of the new file to be scanned
*
* Returns
* void
****************************************************************************/
void vhdl_flex_switch_file( yyscan_t scanner, char *filename )
{
scan_extra_t *extra;
FILE *f;
char *s;
/* convert filename to all upper case */
s = filename;
while (*s)
{
if (islower( *s ))
*s = toupper( *s );
s++;
}
/* file in current directory has precedence */
f = fopen( filename, "r" );
if (!f)
{
const char *db_path = jtag_get_data_dir();
char *db_file;
if ((db_file = (char *)malloc( strlen( db_path ) +
1 + /* "/" */
4 + /* "bsdl" */
1 + /* "/" */
strlen( filename ) +
1 )))
{
strcpy( db_file, db_path );
strcat( db_file, "/" );
strcat( db_file, "bsdl" );
strcat( db_file, "/" );
strcat( db_file, filename );
f = fopen( db_file, "r" );
if (!f)
bsdl_msg( BSDL_MSG_FATAL, _("Cannot open file %s or %s.\n"), filename, db_file );
free( db_file );
if (!f)
return;
}
}
yypush_buffer_state( yy_create_buffer( f, YY_BUF_SIZE, scanner ), scanner );
extra = yyget_extra( scanner );
yyset_lineno( 1, scanner );
}
/*****************************************************************************
* int vhdl_flex_get_compile_errors( yyscan_t scanner )
*
* Retrieves the accumulated number of compile errors encountered so far.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* number of compile errors
****************************************************************************/
int vhdl_flex_get_compile_errors( yyscan_t scanner )
{
scan_extra_t *extra = yyget_extra( scanner );
return extra->Compile_Errors;
}
/*****************************************************************************
* void vhdl_flex_set_compile_errors( int n, yyscan_t scanner )
*
* Sets the number of compile errors to n.
*
* Parameters
* n : preset number
* scanner : pointer to scanner definition structure
*
* Returns
* void
****************************************************************************/
static void vhdl_flex_set_compile_errors( int n, yyscan_t scanner )
{
scan_extra_t *extra = yyget_extra( scanner );
extra->Compile_Errors = n;
}
/*****************************************************************************
* int vhdl_flex_postinc_compile_errors( yyscan_t scanner )
*
* Increments the number of compile errors.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* number of compile errors before increment
****************************************************************************/
int vhdl_flex_postinc_compile_errors( yyscan_t scanner )
{
int errors = vhdl_flex_get_compile_errors( scanner );
vhdl_flex_set_compile_errors( errors+1, scanner );
return errors;
}
/*****************************************************************************
* int vhdl_flex_get_lineno( yyscan_t scanner )
*
* Returns the current line number in the scanned file.
*
* Parameters
* scanner : pointer to scanner definition structure
*
* Returns
* current line number
****************************************************************************/
int vhdl_flex_get_lineno( yyscan_t scanner )
{
return yyget_lineno( scanner );
}
/*
Local Variables:
mode:C
c-default-style:gnu
indent-tabs-mode:nil
End:
*/

@ -0,0 +1,43 @@
/*
* $Id$
*
* Copyright (C) 2008, Arnim Laeuger
*
* This program is free software; you can redistribute it and/or
* modify it 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.
*
* Written by Arnim Laeuger <arniml@users.sourceforge.net>, 2008.
*
*/
#ifndef VHDL_PARSER_H
#define VHDL_PARSER_H
#include "bsdl_types.h"
/* VHDL lexer declarations */
void *vhdl_flex_init( FILE *, int, int );
void vhdl_flex_deinit( void * );
void vhdl_flex_switch_file( void *, char * );
int vhdl_flex_get_compile_errors( void * );
int vhdl_flex_postinc_compile_errors( void * );
int vhdl_flex_get_lineno( void * );
/* VHDL parser declarations */
vhdl_parser_priv_t *vhdl_parser_init( FILE *, jtag_ctrl_t * );
void vhdl_parser_deinit( vhdl_parser_priv_t * );
int vhdlparse( vhdl_parser_priv_t * );
#endif /* VHDL_PARSER_H */
Loading…
Cancel
Save