Mise a plat de mbkvhdlg
This commit is contained in:
parent
5497ff591d
commit
d26bec03e7
|
@ -0,0 +1 @@
|
|||
SUBDIRS = src
|
|
@ -0,0 +1,47 @@
|
|||
dnl
|
||||
dnl This file is part of the Alliance CAD System
|
||||
dnl Copyright (C) Laboratoire LIP6 - Département ASIM
|
||||
dnl Universite Pierre et Marie Curie
|
||||
dnl
|
||||
dnl Home page : http://www-asim.lip6.fr/alliance/
|
||||
dnl E-mail support : mailto:alliance-support@asim.lip6.fr
|
||||
dnl
|
||||
dnl This library is free software; you can redistribute it and/or modify it
|
||||
dnl under the terms of the GNU Library General Public License as published
|
||||
dnl by the Free Software Foundation; either version 2 of the License, or (at
|
||||
dnl your option) any later version.
|
||||
dnl
|
||||
dnl Alliance VLSI CAD System is distributed in the hope that it will be
|
||||
dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
dnl Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License along
|
||||
dnl with the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
dnl
|
||||
dnl Purpose : Auto stuffing Alliance
|
||||
dnl Almost ten years since I wrote this stuff, I just can't
|
||||
dnl believe it
|
||||
dnl Date : 01/02/2002
|
||||
dnl Author : Frederic Petrot <Frederic.Petrot@lip6.fr>
|
||||
dnl $Id: configure.in,v 1.1 2002/04/26 09:51:07 ludo Exp $
|
||||
dnl
|
||||
dnl
|
||||
AC_INIT(src/mvl_drive.c)
|
||||
AM_INIT_AUTOMAKE(mbkvhdlg, 4.1)
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_CC
|
||||
AC_PROG_YACC
|
||||
AM_PROG_LEX
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(strings.h unistd.h)
|
||||
AC_C_CONST
|
||||
AC_PROG_RANLIB
|
||||
|
||||
AM_ALLIANCE
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
src/Makefile
|
||||
])
|
|
@ -0,0 +1,34 @@
|
|||
YFLAGS = -d
|
||||
AM_CFLAGS = @ALLIANCE_CFLAGS@
|
||||
lib_LIBRARIES = libMvg.a
|
||||
|
||||
libMvg_a_SOURCES = mvl_drive.c mvl_parse.c mvl_util.c mvl_sspec.c \
|
||||
mvl_scomp_y.y mvl_scomp_l.l \
|
||||
mvl_drive.h mvl_parse.h mvl_scomp_y.h mvl_slex.h \
|
||||
mvl_sspec.h mvl_stdef.h mvl_stype.h mvl_syacc.h \
|
||||
mvl_utdef.h mvl_util.h mvl_utype.h \
|
||||
vel_chain.c vel_sort.c vel_vect.c vel_drive.c vel_o.c vel_util.c vel_velo.h \
|
||||
gen_generic.c gen_generic.h gen_print.c
|
||||
|
||||
CLEANFILES = mvl_scomp_y.c mvl_scomp_y.h mvl_scomp_l.c
|
||||
|
||||
mvl_scomp_y.c mvl_scomp_y.h : $(srcdir)/mvl_scomp_y.y
|
||||
$(YACC) $(YFLAGS) $(srcdir)/mvl_scomp_y.y && sed -e "s/yy/mvl_y_/g" -e "s/YY/MVL_Y_/g" y.tab.c > mvl_scomp_y.c && sed -e "s/yy/mvl_y_/g" -e "s/YY/MVL_Y_/g" y.tab.h > mvl_scomp_y.h
|
||||
mvl_scomp_l.c : $(srcdir)/mvl_scomp_l.l mvl_scomp_y.h
|
||||
$(LEX) -t $(srcdir)/mvl_scomp_l.l | sed -e "s/yy/mvl_y_/g" -e "s/YY/MVL_Y_/g" > mvl_scomp_l.c
|
||||
|
||||
bin_PROGRAMS = x2vy
|
||||
x2vy_SOURCES = x2vy_main.c
|
||||
x2vy_LDADD = @ALLIANCE_LIBS@ \
|
||||
-lMlu \
|
||||
-lMcl \
|
||||
-lMel \
|
||||
-lMhl \
|
||||
-lMal \
|
||||
-lMsl \
|
||||
-lMgl \
|
||||
$(top_builddir)/src/libMvg.a \
|
||||
-lMlo \
|
||||
-lMut \
|
||||
-lRcn
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
file : generic.c
|
||||
date : Mar 7 1997
|
||||
version : v2.00
|
||||
author : D.HOMMAIS
|
||||
content : basic functions for logen structure use
|
||||
*/
|
||||
#ident "$Id: gen_generic.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
#include <stdio.h>
|
||||
#include <mut.h>
|
||||
#include "gen_generic.h"
|
||||
|
||||
logen_list *addlogen(logen_list *ptgen,char *name)
|
||||
{
|
||||
logen_list *p;
|
||||
|
||||
if (name) {
|
||||
name=namealloc(name);
|
||||
for (p=ptgen;p;p=p->NEXT) {
|
||||
if (name==p->NAME) {
|
||||
fprintf(stderr,"Generic %s already exists\n",name);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
p=(logen_list *)mbkalloc(sizeof(logen_list));
|
||||
p->NAME=name;
|
||||
p->TYPE=0;
|
||||
p->TAG=0;
|
||||
p->NEXT=ptgen;
|
||||
return p;
|
||||
}
|
||||
|
||||
logen_list *getlogen(logen_list *ptgen, char *name)
|
||||
{
|
||||
name=namealloc(name);
|
||||
while (ptgen) {
|
||||
if (ptgen->NAME==name)
|
||||
return ptgen;
|
||||
ptgen=ptgen->NEXT;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
logen_list *duplogen(logen_list *s, logen_list *d, char *name)
|
||||
{
|
||||
d=addlogen(d,name);
|
||||
d->TYPE=s->TYPE;
|
||||
d->VALUE=s->VALUE;
|
||||
return d;
|
||||
}
|
||||
|
||||
logen_list *dellogen(logen_list *g, char *name)
|
||||
{
|
||||
logen_list *s=NULL;
|
||||
logen_list *p;
|
||||
|
||||
for (p=g;p;p=p->NEXT) {
|
||||
if (p->NAME==name)
|
||||
break;
|
||||
s=p;
|
||||
}
|
||||
if (!p) return g;
|
||||
if (!s)
|
||||
g=p->NEXT;
|
||||
else
|
||||
s->NEXT=p->NEXT;
|
||||
mbkfree(p);
|
||||
return g;
|
||||
}
|
||||
|
||||
logen_list *getprevlogen(logen_list *ptgen, char *name)
|
||||
{
|
||||
logen_list *prev=NULL;
|
||||
|
||||
while (ptgen) {
|
||||
if (ptgen->NAME==name)
|
||||
return prev;
|
||||
prev=ptgen;
|
||||
ptgen=ptgen->NEXT;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
logen_list *logenorder(logen_list *ins, logen_list *mod)
|
||||
{
|
||||
logen_list *save, *prev, *ord=NULL;
|
||||
|
||||
while(mod) {
|
||||
prev=getprevlogen(ins,mod->NAME);
|
||||
save=ord;
|
||||
if (prev) {
|
||||
ord=prev->NEXT;
|
||||
prev->NEXT=ord->NEXT;
|
||||
ord->NEXT=save;
|
||||
} else {
|
||||
ord=ins;
|
||||
ins=ins->NEXT;
|
||||
ord->NEXT=save;
|
||||
}
|
||||
mod=mod->NEXT;
|
||||
}
|
||||
return ord;
|
||||
}
|
||||
|
||||
logen_list *duplogenlist(logen_list *s, logen_list *d, char *name)
|
||||
{
|
||||
logen_list *g;
|
||||
|
||||
d=addlogen(d,name);
|
||||
d->TYPE=s->TYPE;
|
||||
d->VALUE.LIST=NULL;
|
||||
if (s->TYPE==GENTYPE_LIST) {
|
||||
for (g=s->VALUE.LIST; g; g=g->NEXT)
|
||||
d->VALUE.LIST=duplogenlist(g, d->VALUE.LIST, NULL);
|
||||
d->VALUE.LIST=(logen_list *)reverse((chain_list *)d->VALUE.LIST);
|
||||
} else
|
||||
d->VALUE=s->VALUE;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
logen_list *chklogen(logen_list *ins, logen_list *mod, char *insname, char *modname)
|
||||
{
|
||||
logen_list *pins, *pmod;
|
||||
|
||||
if (ins) {
|
||||
if (ins->NAME) {
|
||||
for (pins=ins;pins;pins=pins->NEXT)
|
||||
if (pmod=getlogen(mod,pins->NAME))
|
||||
pmod->TAG=1;
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"Instance %s, no generic called %s in model %s, deleted!\n",
|
||||
insname, pins->NAME, modname);
|
||||
ins=dellogen(ins, pins->NAME);
|
||||
}
|
||||
for (pmod=mod;pmod;pmod=pmod->NEXT)
|
||||
if (!pmod->TAG)
|
||||
ins=duplogenlist(pmod, ins, pmod->NAME);
|
||||
} else {
|
||||
for (pins=ins,pmod=mod;pins&&pmod;pins=pins->NEXT,pmod=pmod->NEXT)
|
||||
pins->NAME=pmod->NAME;
|
||||
if (pins) {
|
||||
fprintf(stderr,
|
||||
"Too many value in generic map of instance %s, exiting !\n",
|
||||
insname);
|
||||
exit(4);
|
||||
}
|
||||
if (pmod) {
|
||||
fprintf(stderr,
|
||||
"Too few value in generic map of instance %s, exiting !\n",
|
||||
insname);
|
||||
exit(5);
|
||||
}
|
||||
}
|
||||
for (pmod=mod;pmod;pmod=pmod->NEXT) pmod->TAG=0;
|
||||
} else
|
||||
for (pmod=mod;pmod;pmod=pmod->NEXT)
|
||||
ins=duplogenlist(pmod,ins,pmod->NAME);
|
||||
|
||||
return logenorder(ins,mod);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#define LOGEN 21
|
||||
|
||||
#define GENTYPE_EMPTY 0
|
||||
#define GENTYPE_BIT 1
|
||||
#define GENTYPE_VAL 2
|
||||
#define GENTYPE_ARG 3
|
||||
#define GENTYPE_TEXT 4
|
||||
#define GENTYPE_LIST 5
|
||||
#define GENTYPE_HEX 6
|
||||
#define GENTYPE_MAX 6
|
||||
|
||||
typedef struct logen
|
||||
{
|
||||
struct logen *NEXT;
|
||||
char *NAME;
|
||||
char TYPE;
|
||||
union {
|
||||
char CHAR;
|
||||
long VAL;
|
||||
char *TEXT;
|
||||
struct logen *LIST;
|
||||
} VALUE;
|
||||
char TAG;
|
||||
} logen_list;
|
||||
|
||||
#ifdef SunOS
|
||||
#define strtoul (unsigned long)strtol
|
||||
#endif
|
||||
|
||||
extern logen_list *addlogen(logen_list *,char *);
|
||||
extern logen_list *getlogen(logen_list *,char *);
|
||||
extern logen_list *duplogen(logen_list *,logen_list *, char *);
|
||||
extern logen_list *chklogen(logen_list *,logen_list *, char *, char *);
|
||||
extern logen_list *dellogen(logen_list *, char *name);
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* $Log: gen_print.c,v $
|
||||
* Revision 1.1 2002/04/26 09:51:07 ludo
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1.1.1 2002/04/11 08:54:52 fred
|
||||
* Importing mbkvhdlg into the new Alliance CVS tree
|
||||
*
|
||||
* Revision 1.1.1.1 2002/02/28 12:58:31 disydent
|
||||
* Creation of Disydent CVS Tree
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/19 16:55:24 pwet
|
||||
* Changing the CVS tree structure of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/24 13:31:38 pwet
|
||||
* cvs tree of part of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/19 14:32:18 pwet
|
||||
* New cvs tree
|
||||
*
|
||||
* Revision 1.4 1998/06/22 07:57:49 pwet
|
||||
* Modify the stdin parser to handle multi dimensional array
|
||||
*
|
||||
* Revision 1.3 1998/02/17 13:23:31 pwet
|
||||
* add multidimensional array feature for generics.
|
||||
*
|
||||
* Revision 1.2 1998/01/26 12:57:25 pwet
|
||||
* add PrintInstances, TestInstances and RessourcesInstances that depend on the
|
||||
* netlist.
|
||||
*
|
||||
* Revision 1.1 1997/09/08 16:59:49 pwet
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
#ident "$Id: gen_print.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mut.h>
|
||||
#include "gen_generic.h"
|
||||
#define MEALY 0x80
|
||||
|
||||
void debuglogenlist(logen_list *g, int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
while (g) {
|
||||
for (i=0;i<level;i++) putc('\t',stdout);
|
||||
switch(g->TYPE) {
|
||||
case GENTYPE_EMPTY:
|
||||
fprintf(stdout," EMPTY\n");
|
||||
break;
|
||||
case GENTYPE_VAL:
|
||||
fprintf(stdout," ( val) %ld\n",g->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_TEXT:
|
||||
fprintf(stdout," (text) %s\n",g->VALUE.TEXT);
|
||||
break;
|
||||
case GENTYPE_LIST:
|
||||
fprintf(stdout," (list)\n");
|
||||
debuglogenlist(g->VALUE.LIST, level+1);
|
||||
break;
|
||||
case GENTYPE_ARG:
|
||||
fprintf(stdout," ( arg) %ld\n",g->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_BIT:
|
||||
fprintf(stdout," ( bit) %c\n",g->VALUE.CHAR);
|
||||
break;
|
||||
case GENTYPE_HEX:
|
||||
fprintf(stdout," ( hex) 0x%lx\n", g->VALUE.VAL);
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout,"Unknown logen type %d\n", g->TYPE);
|
||||
break;
|
||||
}
|
||||
g=g->NEXT;
|
||||
}
|
||||
}
|
||||
|
||||
void debuglogen(logen_list *g, int level)
|
||||
{
|
||||
while (g) {
|
||||
printlogen(g, level);
|
||||
g=g->NEXT;
|
||||
}
|
||||
}
|
||||
|
||||
static void printlogen(logen_list *g, int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<level;i++) putc('\t',stdout);
|
||||
switch(g->TYPE) {
|
||||
case GENTYPE_EMPTY:
|
||||
if (g->NAME)
|
||||
fprintf(stdout," %s := EMPTY\n",g->NAME);
|
||||
else
|
||||
fprintf(stdout," EMPTY\n");
|
||||
break;
|
||||
case GENTYPE_VAL:
|
||||
if (g->NAME)
|
||||
fprintf(stdout," %s := ( val) %ld\n", g->NAME, g->VALUE.VAL);
|
||||
else
|
||||
fprintf(stdout," ( val) %ld\n", g->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_TEXT:
|
||||
if (g->NAME)
|
||||
fprintf(stdout," %s := (text) %s\n", g->NAME, g->VALUE.TEXT);
|
||||
else
|
||||
fprintf(stdout," (text) %s\n", g->VALUE.TEXT);
|
||||
break;
|
||||
case GENTYPE_LIST:
|
||||
if (g->NAME)
|
||||
fprintf(stdout," %s := (list)\n",g->NAME);
|
||||
else
|
||||
fprintf(stdout," (list)\n");
|
||||
debuglogenlist(g->VALUE.LIST, level+1);
|
||||
break;
|
||||
case GENTYPE_ARG:
|
||||
if (g->NAME)
|
||||
fprintf(stdout," %s := ( arg) %ld\n", g->NAME, g->VALUE.VAL);
|
||||
else
|
||||
fprintf(stdout," ( arg) %ld\n", g->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_BIT:
|
||||
if (g->NAME)
|
||||
fprintf(stdout," %s := ( bit) %c\n", g->NAME, g->VALUE.CHAR);
|
||||
else
|
||||
fprintf(stdout," ( bit) %c\n", g->VALUE.CHAR);
|
||||
break;
|
||||
case GENTYPE_HEX:
|
||||
if (g->NAME)
|
||||
fprintf(stdout," %s := ( hex) 0x%lx\n", g->NAME, g->VALUE.VAL);
|
||||
else
|
||||
fprintf(stdout," ( hex) 0x%lx\n", g->VALUE.VAL);
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout,"Unknown logen type %d\n", g->TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void printlogenvalue(logen_list *g)
|
||||
{
|
||||
switch(g->TYPE) {
|
||||
case GENTYPE_EMPTY:
|
||||
break;
|
||||
case GENTYPE_BIT:
|
||||
printf("%c",g->VALUE.CHAR);
|
||||
break;
|
||||
case GENTYPE_VAL:
|
||||
case GENTYPE_ARG:
|
||||
printf("%ld",g->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_HEX:
|
||||
printf("0x%lx",g->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_TEXT:
|
||||
fputs(g->VALUE.TEXT, stdout);
|
||||
break;
|
||||
case GENTYPE_LIST:
|
||||
{
|
||||
logen_list *t;
|
||||
fputs("( ", stdout);
|
||||
for (t=g->VALUE.LIST;t;t=t->NEXT) {
|
||||
printlogenvalue(t);
|
||||
fputc(' ', stdout);
|
||||
}
|
||||
fputs(") ", stdout);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void printlogen(logen_list *g)
|
||||
{
|
||||
while (g) {
|
||||
printf("%s %d ", g->NAME, g->TYPE);
|
||||
printlogenvalue(g);
|
||||
fputc('\n', stdout);
|
||||
g=g->NEXT;
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,449 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_drive.c */
|
||||
/* date : Sep 24 1993 */
|
||||
/* author : VUONG Huu Nghia, D. Hommais */
|
||||
/* description : This file contains a MBK-->VHDL driver : */
|
||||
/* functions : vhdlsavelofig() */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
#ident "$Id: mvl_drive.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include "gen_generic.h"
|
||||
#include "mvl_utype.h"
|
||||
#include "mvl_utdef.h"
|
||||
#include "mvl_drive.h"
|
||||
|
||||
static void drv_genvalue(FILE *ptfile, logen_list *ptgen)
|
||||
{
|
||||
logen_list *l;
|
||||
|
||||
switch (ptgen->TYPE) {
|
||||
case GENTYPE_BIT:
|
||||
fprintf(ptfile, "'%c'", ptgen->VALUE.CHAR);
|
||||
break;
|
||||
case GENTYPE_VAL:
|
||||
fprintf(ptfile, "%d", ptgen->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_ARG:
|
||||
fprintf(ptfile, "%d", ptgen->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_TEXT:
|
||||
fputs(ptgen->VALUE.TEXT, ptfile);
|
||||
break;
|
||||
case GENTYPE_LIST:
|
||||
fputc('(', ptfile);
|
||||
for (l=ptgen->VALUE.LIST; l; l=l->NEXT) {
|
||||
drv_genvalue(ptfile, l);
|
||||
if (l->NEXT)
|
||||
fputc(',', ptfile);
|
||||
}
|
||||
fputc(')', ptfile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void drv_generic(FILE *ptfile, ptype_list *pttype)
|
||||
{
|
||||
struct logen *ptgen;
|
||||
|
||||
if (pttype=getptype(pttype,LOGEN)) {
|
||||
fprintf (ptfile," generic (\n");
|
||||
for (ptgen=pttype->DATA;ptgen;ptgen=ptgen->NEXT) {
|
||||
fprintf (ptfile," CONSTANT %s : ",ptgen->NAME);
|
||||
switch(ptgen->TYPE) {
|
||||
case GENTYPE_BIT:
|
||||
fputs("bit := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_VAL:
|
||||
fputs("natural := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_ARG:
|
||||
fputs("arg := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_TEXT:
|
||||
fputs("string := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_LIST:
|
||||
fputs("list := ", ptfile);
|
||||
break;
|
||||
}
|
||||
drv_genvalue(ptfile, ptgen);
|
||||
if (ptgen->NEXT)
|
||||
fputs(";\n",ptfile);
|
||||
}
|
||||
fputs("\n );\n",ptfile);
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : vhdlsavelofig */
|
||||
/* description : print out a texte file containing a structural VHDL */
|
||||
/* description */
|
||||
/* called func. : mvl_vhdlname , getsigname, mvl_message, mvl_error ,*/
|
||||
/* mvl_toolbug, getptype, reverse, mvl_abl2str */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void xxvhdlsavelofig (ptfig)
|
||||
|
||||
struct lofig *ptfig;
|
||||
{
|
||||
extern char *getsigname ();
|
||||
struct loins *ptins = NULL;
|
||||
struct locon *ptcon = NULL;
|
||||
struct locon *tmp_ptcon = NULL;
|
||||
struct locon *ptscan = NULL;
|
||||
struct losig *ptsig = NULL;
|
||||
struct chain *ptmodel = NULL;
|
||||
struct chain *ptchain = NULL;
|
||||
struct chain *sig_list = NULL;
|
||||
FILE *ptfile ;
|
||||
time_t clock ;
|
||||
char *mode = NULL;
|
||||
char *name ;
|
||||
char *sig_name ;
|
||||
int left ;
|
||||
int right ;
|
||||
int i ;
|
||||
char new_name[200];
|
||||
char first = 1 ;
|
||||
|
||||
if (ptfig == NULL)
|
||||
mvl_toolbug (10, "mvl_decomp", NULL, 0);
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Opening result file */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
if ((ptfile = mbkfopen (ptfig->NAME, "vst", "w")) == NULL)
|
||||
{
|
||||
mvl_error (107, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
time (&clock);
|
||||
fprintf (ptfile,"-- VHDL structural description generated from `%s`\n",
|
||||
ptfig->NAME);
|
||||
fprintf (ptfile,"--\t\tdate : %s\n\n",ctime(&clock));
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Entity declaration */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
fprintf (ptfile,"-- Entity Declaration\n\n");
|
||||
fprintf (ptfile,"ENTITY %s IS\n", mvl_vhdlname (ptfig->NAME));
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Generic declaration */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
drv_generic(ptfile, ptfig->USER);
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Port declaration */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
if (ptfig->LOCON != NULL)
|
||||
{
|
||||
fprintf (ptfile," PORT (\n");
|
||||
ptfig->LOCON = (struct locon *) reverse ((chain_list *)ptfig->LOCON);
|
||||
ptcon = ptfig->LOCON;
|
||||
while (ptcon != NULL)
|
||||
{
|
||||
switch (ptcon->DIRECTION)
|
||||
{
|
||||
case 'I':
|
||||
mode = namealloc ("in");
|
||||
break;
|
||||
case 'O':
|
||||
mode = namealloc ("out");
|
||||
break;
|
||||
case 'B':
|
||||
mode = namealloc ("inout");
|
||||
break;
|
||||
case 'Z':
|
||||
case 'T':
|
||||
case 'X':
|
||||
mode = namealloc ("linkage");
|
||||
break;
|
||||
}
|
||||
ptcon = (struct locon *) mvl_vectnam (ptcon,&left,&right,&name,1);
|
||||
if (left != -1)
|
||||
{
|
||||
fprintf (ptfile," %s : %s BIT_VECTOR (%d %s %d)",
|
||||
mvl_vhdlname (name), mode, left,
|
||||
(left >= right)? "DOWNTO":"TO",right);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (ptfile," %s : %s BIT",mvl_vhdlname(name),mode);
|
||||
}
|
||||
|
||||
if (ptcon->NEXT != NULL)
|
||||
fprintf (ptfile,";\t-- %s\n",name);
|
||||
else
|
||||
fprintf (ptfile,"\t-- %s\n",name);
|
||||
|
||||
ptcon = ptcon->NEXT;
|
||||
mbkfree (name);
|
||||
}
|
||||
fprintf (ptfile, " );\n");
|
||||
}
|
||||
fprintf (ptfile,"END %s;\n\n",mvl_vhdlname(ptfig->NAME));
|
||||
ptfig->LOCON = (struct locon *) reverse ((chain_list *)ptfig->LOCON);
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Architecture declaration */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
fprintf (ptfile,"-- Architecture Declaration\n\n");
|
||||
fprintf (ptfile,"ARCHITECTURE structural_view OF %s IS\n",
|
||||
mvl_vhdlname(ptfig->NAME));
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Component declaration : first make a list of models, then */
|
||||
/* for each model print out a "component declaration" */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
ptmodel = NULL;
|
||||
for (ptins = ptfig->LOINS; ptins; ptins = ptins->NEXT)
|
||||
{
|
||||
for (ptchain = ptmodel ; ptchain ; ptchain = ptchain->NEXT)
|
||||
{
|
||||
if (((struct loins *)ptchain->DATA)->FIGNAME == ptins->FIGNAME)
|
||||
break;
|
||||
}
|
||||
if (ptchain == NULL)
|
||||
ptmodel = addchain(ptmodel,ptins);
|
||||
}
|
||||
|
||||
for (ptchain = ptmodel ; ptchain ; ptchain = ptchain->NEXT)
|
||||
{
|
||||
ptins = (struct loins *)ptchain->DATA;
|
||||
fprintf (ptfile," COMPONENT %s\n",
|
||||
mvl_vhdlname(ptins->FIGNAME));
|
||||
|
||||
/* ###------------------------------------------------------------### */
|
||||
/* For each model, I just look for an instance and write the generic */
|
||||
/* list. So the default value for a generic of the model is the value */
|
||||
/* of the first found instance generic. */
|
||||
/* ###------------------------------------------------------------### */
|
||||
|
||||
drv_generic(ptfile, ((loins_list *)ptchain->DATA)->USER);
|
||||
|
||||
fputs(" port (\n",ptfile);
|
||||
|
||||
ptins->LOCON = (struct locon *) reverse ((chain_list *)ptins->LOCON);
|
||||
ptcon = ptins->LOCON;
|
||||
while (ptcon != NULL)
|
||||
{
|
||||
switch (ptcon->DIRECTION)
|
||||
{
|
||||
case 'I':
|
||||
mode = namealloc ("in");
|
||||
break;
|
||||
case 'O':
|
||||
mode = namealloc ("out");
|
||||
break;
|
||||
case 'B':
|
||||
mode = namealloc ("inout");
|
||||
break;
|
||||
case 'Z':
|
||||
case 'T':
|
||||
case 'X':
|
||||
mode = namealloc ("linkage");
|
||||
break;
|
||||
}
|
||||
ptcon = (struct locon *) mvl_vectnam (ptcon,&left,&right,&name,1);
|
||||
if (left != -1)
|
||||
{
|
||||
fprintf (ptfile," %s : %s BIT_VECTOR(%d %s %d)",
|
||||
mvl_vhdlname(name), mode, left,
|
||||
(left >= right)?"DOWNTO":"TO",right);
|
||||
}
|
||||
else
|
||||
fprintf(ptfile," %s : %s BIT", mvl_vhdlname(name),mode);
|
||||
|
||||
if (ptcon->NEXT != NULL)
|
||||
fprintf(ptfile, ";\t-- %s\n",name);
|
||||
else
|
||||
fprintf(ptfile, "\t-- %s\n",name);
|
||||
|
||||
ptcon = ptcon->NEXT;
|
||||
free(name);
|
||||
}
|
||||
ptins->LOCON = (struct locon *) reverse ((chain_list *)ptins->LOCON);
|
||||
fprintf (ptfile, " );\n END COMPONENT;\n\n");
|
||||
}
|
||||
|
||||
freechain (ptmodel);
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Signal declaration */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
ptsig = ptfig->LOSIG;
|
||||
while (ptsig != NULL)
|
||||
{
|
||||
if (ptsig->TYPE == 'I')
|
||||
{
|
||||
fprintf (ptfile," SIGNAL %s : BIT;\t-- %s\n",
|
||||
mvl_vhdlname(getsigname(ptsig)),getsigname(ptsig));
|
||||
}
|
||||
ptsig = ptsig->NEXT;
|
||||
}
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Description block */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
fprintf (ptfile,"\nBEGIN\n\n");
|
||||
ptfig->LOINS = (struct loins *) reverse ((chain_list *)ptfig->LOINS);
|
||||
|
||||
for (ptins = ptfig->LOINS; ptins; ptins = ptins->NEXT)
|
||||
{
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Instantiation of a model */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
fprintf (ptfile," %s : %s\n",
|
||||
mvl_vhdlname(ptins->INSNAME),mvl_vhdlname(ptins->FIGNAME));
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Generic map */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
{
|
||||
logen_list *g;
|
||||
ptype_list *p;
|
||||
|
||||
p=getptype(ptins->USER,LOGEN);
|
||||
if (p) {
|
||||
fputs(" Generic Map (\n",ptfile);
|
||||
for (g=p->DATA;g;g=g->NEXT) {
|
||||
fprintf(ptfile," %s => ",g->NAME);
|
||||
drv_genvalue(ptfile, g);
|
||||
if (g->NEXT)
|
||||
fputs(",\n",ptfile);
|
||||
}
|
||||
fputs(" )\n",ptfile);
|
||||
}
|
||||
}
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Port map */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
fputs(" PORT MAP (\n",ptfile);
|
||||
ptcon = ptins->LOCON;
|
||||
while (ptcon != NULL)
|
||||
{
|
||||
tmp_ptcon = (struct locon *) mvl_vectnam (ptcon,&left,&right,&name,1);
|
||||
fprintf (ptfile," %s => ",mvl_vhdlname (name));
|
||||
|
||||
if (left != -1)
|
||||
{
|
||||
/* ###------------------------------------------------------### */
|
||||
/* The connected signals are bused */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
for (i=abs(left-right) ; i>=0 ; i--)
|
||||
{
|
||||
ptsig = ptcon->SIG;
|
||||
if (ptsig->TYPE == 'I')
|
||||
{
|
||||
/* ###-------------------------------------------------### */
|
||||
/* The signal is internal */
|
||||
/* ###-------------------------------------------------### */
|
||||
|
||||
sig_name = namealloc (mvl_vhdlname(getsigname(ptsig)));
|
||||
sig_list = addchain (sig_list, sig_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ###-------------------------------------------------### */
|
||||
/* The signal is external */
|
||||
/* ###-------------------------------------------------### */
|
||||
|
||||
for (ptscan = ptfig->LOCON ; ptscan ; ptscan = ptscan->NEXT)
|
||||
{
|
||||
if (ptscan->SIG == ptsig)
|
||||
break;
|
||||
}
|
||||
if (ptscan == NULL)
|
||||
{
|
||||
printf ("\n*** mbk error *** no external connector \n");
|
||||
printf (" driving vhdl file %s\n", ptfig->NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
mvl_name (ptscan->NAME,new_name);
|
||||
sig_name = namealloc (new_name);
|
||||
sig_list = addchain (sig_list, sig_name);
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
ptcon = ptcon->NEXT;
|
||||
}
|
||||
|
||||
first = 1;
|
||||
while (sig_list != NULL)
|
||||
{
|
||||
if (first != 1)
|
||||
{
|
||||
fprintf (ptfile,"& %s",(char *)(sig_list->DATA));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (ptfile,"%s",(char *)(sig_list->DATA));
|
||||
first = 0;
|
||||
}
|
||||
sig_list = sig_list->NEXT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ###------------------------------------------------------### */
|
||||
/* The connected signals is simple */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
ptsig = ptcon->SIG;
|
||||
if (ptsig->TYPE == 'I')
|
||||
{
|
||||
fprintf (ptfile, "%s", mvl_vhdlname (getsigname(ptsig)));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ptscan = ptfig->LOCON ; ptscan ; ptscan = ptscan->NEXT)
|
||||
{
|
||||
if (ptscan->SIG == ptsig)
|
||||
break;
|
||||
}
|
||||
if (ptscan == NULL)
|
||||
{
|
||||
printf ("\n*** mbk error *** no external connector \n");
|
||||
printf (" driving vhdl file %s\n", ptfig->NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
mvl_name (ptscan->NAME,new_name);
|
||||
fprintf(ptfile, "%s", new_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ptcon->NEXT != NULL)
|
||||
fprintf (ptfile, ",\n");
|
||||
ptcon = ptcon->NEXT;
|
||||
free(name);
|
||||
}
|
||||
fprintf(ptfile, ");\n");
|
||||
}
|
||||
ptfig->LOINS = (struct loins *) reverse ((chain_list *)ptfig->LOINS);
|
||||
fprintf (ptfile, "\nend structural_view;\n");
|
||||
fclose (ptfile);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_drive.h */
|
||||
/* date : Nov 12 91 */
|
||||
/* author : L.A. TABUSSE & P. BAZARGAN-SABET & VUONG H.N. */
|
||||
/* */
|
||||
/* content : declaration of functions and global variables used by */
|
||||
/* the structural MBK-> VHDL driver */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
|
||||
extern void mvl_addtab();
|
||||
extern int mvl_chktab();
|
||||
extern void mvl_toolbug();
|
||||
extern void mvl_message();
|
||||
extern void mvl_error();
|
||||
extern char *mvl_vhdlname();
|
||||
extern void *mvl_name();
|
||||
extern char *mvl_abl2str();
|
||||
extern void *mvl_vectnam();
|
||||
extern char mvl_chkconsistency();
|
|
@ -0,0 +1,184 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_parse.c */
|
||||
/* date : Feb 15 1995 */
|
||||
/* author : L.A TABUSSE & H.N. VUONG & P. BAZARGAN-SABET */
|
||||
/* description : Parser VHDL --> MBK */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
#ident "$Id: mvl_parse.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include "mvl_parse.h"
|
||||
#include "mvl_utdef.h"
|
||||
|
||||
void vhdlloadlofig (pt_lofig, figname, mode)
|
||||
|
||||
struct lofig *pt_lofig;
|
||||
char *figname ;
|
||||
char mode ;
|
||||
|
||||
{
|
||||
struct lofig *pt_lofig_tmp;
|
||||
struct loins *pt_loins ;
|
||||
struct loins *pt_loinsaux;
|
||||
struct locon *pt_locon ;
|
||||
struct locon *pt_loconaux;
|
||||
struct losig *pt_losig ;
|
||||
struct losig *pt_losigaux;
|
||||
char filename[120];
|
||||
char local_mbk_fast_mode;
|
||||
static int call_nbr = 0;
|
||||
|
||||
/* Initialization of some variables */
|
||||
MVL_LINNUM = 1;
|
||||
MVL_MBKMOD = mode;
|
||||
strcpy (MVL_CURFIL, figname);
|
||||
|
||||
/* FAST_MODE asked for MBK */
|
||||
local_mbk_fast_mode = FAST_MODE;
|
||||
FAST_MODE = 'Y';
|
||||
|
||||
if ((mode != 'A') && (mode != 'P') && (mode != 'C'))
|
||||
{
|
||||
printf("vhdlloadfig : Bad mode '%c' asked\n", mode);
|
||||
FAST_MODE = local_mbk_fast_mode;
|
||||
EXIT(1);
|
||||
}
|
||||
|
||||
/* Opening file */
|
||||
mvl_y_in = (FILE *) mbkfopen(figname, IN_LO, READ_TEXT);
|
||||
if((mvl_y_in == NULL) && (mode == 'P'))
|
||||
{
|
||||
strcpy(IN_LO, "vbe");
|
||||
mvl_y_in = (FILE *) mbkfopen(figname, IN_LO, READ_TEXT);
|
||||
}
|
||||
|
||||
if(mvl_y_in == NULL)
|
||||
{
|
||||
(void)fprintf(stderr,"\n*** mbk error *** can't open file : %s.%s\n",
|
||||
figname, IN_LO);
|
||||
FAST_MODE = local_mbk_fast_mode;
|
||||
EXIT(1);
|
||||
}
|
||||
|
||||
/* TRACE_MODE asked for MBK */
|
||||
if(TRACE_MODE == 'Y')
|
||||
{
|
||||
(void)printf("\n--- mbk --- parsing file : %s.%s in mode : %c\n",
|
||||
figname, IN_LO, mode);
|
||||
}
|
||||
|
||||
MVL_LOFPNT = pt_lofig; /* passing main parameter */
|
||||
|
||||
if (call_nbr != 0)
|
||||
mvl_y_restart (mvl_y_in);
|
||||
|
||||
call_nbr ++;
|
||||
|
||||
/* -------------------------------------------------------------------*/
|
||||
/* Parsing : If mode is P or A, then normal parsing, if mode is C */
|
||||
/* then parsing of a new figure, then from the new one, we fill the */
|
||||
/* old one. */
|
||||
/* -------------------------------------------------------------------*/
|
||||
|
||||
if((mode == 'P') || (mode == 'A'))
|
||||
{
|
||||
if(mvl_y_parse() != 0)
|
||||
{
|
||||
(void)fprintf(stderr,"\n*** mbk error *** abnormal parsing for : %s\n",filename);
|
||||
FAST_MODE = local_mbk_fast_mode;
|
||||
EXIT(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(mode == 'C')
|
||||
{
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Saving the lofig pointer, creating a new one to allow the */
|
||||
/* parsing of the figure in 'A' mode. */
|
||||
/* ---------------------------------------------------------------- */
|
||||
pt_lofig_tmp = pt_lofig;
|
||||
MVL_LOFPNT = (lofig_list *)mbkalloc(sizeof(lofig_list));
|
||||
MVL_LOFPNT->MODE = 'A';
|
||||
MVL_LOFPNT->NAME = namealloc(figname);
|
||||
MVL_LOFPNT->MODELCHAIN = NULL;
|
||||
MVL_LOFPNT->LOINS = NULL;
|
||||
MVL_LOFPNT->LOTRS = NULL;
|
||||
MVL_LOFPNT->LOCON = NULL;
|
||||
MVL_LOFPNT->LOSIG = NULL;
|
||||
MVL_LOFPNT->BKSIG = NULL;
|
||||
MVL_LOFPNT->USER = NULL;
|
||||
MVL_LOFPNT->NEXT = NULL;
|
||||
|
||||
MVL_MBKMOD = 'A';
|
||||
|
||||
if(mvl_y_parse() != 0)
|
||||
{
|
||||
(void)fprintf(stderr,"\n*** mbk error *** abnormal parsing for : %s\n",filename);
|
||||
FAST_MODE = local_mbk_fast_mode;
|
||||
EXIT(1);
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Now, with the new figure, we duplicate the new informations */
|
||||
/* to fill the old one. */
|
||||
/* ---------------------------------------------------------------- */
|
||||
pt_lofig = mvl_fill(pt_lofig_tmp, MVL_LOFPNT);
|
||||
}
|
||||
|
||||
MVL_MBKMOD = mode;
|
||||
/* Closing file */
|
||||
if(fclose(mvl_y_in) != 0)
|
||||
{
|
||||
(void)fprintf(stderr,"\n*** mbk error *** can't close file : %s\n",filename);
|
||||
FAST_MODE = local_mbk_fast_mode;
|
||||
EXIT(1);
|
||||
}
|
||||
|
||||
if(strcmp(IN_LO,"vbe") == 0)
|
||||
{
|
||||
strcpy(IN_LO,"vst");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == 'P' )
|
||||
{
|
||||
pt_locon = MVL_LOFPNT->LOCON;
|
||||
while (pt_locon != NULL)
|
||||
{
|
||||
if (pt_locon->TYPE == 'I')
|
||||
{
|
||||
pt_loconaux = pt_locon;
|
||||
pt_locon = pt_locon->NEXT;
|
||||
dellocon(MVL_LOFPNT, pt_loconaux->NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* pt_locon->SIG = NULL; */
|
||||
pt_locon = pt_locon->NEXT;
|
||||
}
|
||||
}
|
||||
pt_losig = MVL_LOFPNT->LOSIG;
|
||||
while (pt_losig != NULL)
|
||||
{
|
||||
if (pt_losig->TYPE == 'E')
|
||||
{
|
||||
pt_losig = pt_losig->NEXT;
|
||||
continue;
|
||||
}
|
||||
pt_losigaux = pt_losig;
|
||||
pt_losig = pt_losig->NEXT;
|
||||
dellosig(MVL_LOFPNT, pt_losigaux->INDEX);
|
||||
}
|
||||
pt_loins = MVL_LOFPNT->LOINS;
|
||||
while (pt_loins != NULL)
|
||||
{
|
||||
pt_loinsaux = pt_loins;
|
||||
pt_loins = pt_loins->NEXT;
|
||||
delloins(MVL_LOFPNT, pt_loinsaux->INSNAME);
|
||||
}
|
||||
}
|
||||
FAST_MODE = local_mbk_fast_mode;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_parse.h */
|
||||
/* date : Nov 12 1991 */
|
||||
/* author : L.A. TABUSSE & H.G. VUONG & P. BAZARGAN-SABET */
|
||||
/* description : variable for Parser VHDL --> MBK */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
char MVL_MBKMOD; /* The mode of getlofig */
|
||||
char MVL_ERRFLG = 0; /* if = 1 no structure is made */
|
||||
int MVL_LINNUM = 1; /* file's line number */
|
||||
char MVL_CURFIL[200]; /* current file's name */
|
||||
|
||||
struct dct_entry **MVL_HSHTAB; /* dictionnary's entry points */
|
||||
|
||||
extern void mvl_error();
|
||||
extern struct lofig *mvl_fill();
|
||||
|
||||
extern struct dct_entry **mvl_initab();
|
||||
extern void mvl_fretab();
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
struct lofig *MVL_LOFPNT = NULL; /* current LOFIG pointer */
|
||||
|
||||
extern FILE *mvl_y_in;
|
||||
extern int mvl_y_parse();
|
||||
extern void mvl_decomp();
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
|
@ -0,0 +1,308 @@
|
|||
%{
|
||||
/*###----------------------------------------------------------------###*/
|
||||
/* */
|
||||
/* Filename : mvl_scomp.lex */
|
||||
/* Authors : L.A. TABUSSE */
|
||||
/* VUONG H.N. */
|
||||
/* Date : Jan 29 1992 */
|
||||
/* Contents : Lexical VHDL Analyser */
|
||||
/* For any details refer to the IEEE Standard */
|
||||
/* VHDL LRM Chapter 13 : Lexical Elements */
|
||||
/* Called func. : namealloc <mbk.h>, mbkalloc <mbk>, find_mc*/
|
||||
/* */
|
||||
/*###----------------------------------------------------------------###*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include "gen_generic.h"
|
||||
#include "mvl_slex.h"
|
||||
#include "mvl_stdef.h"
|
||||
#include "mvl_stype.h"
|
||||
#include "mvl_scomp_y.h"
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : search */
|
||||
/* description : check that an identifier is a reserved word or not */
|
||||
/* called func. : addht, addhtitem, gethtitem, namealloc */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
static int search (key)
|
||||
|
||||
char *key;
|
||||
|
||||
{
|
||||
static ht *pt_hash = NULL;
|
||||
|
||||
if (pt_hash == NULL)
|
||||
{
|
||||
pt_hash = addht (107);
|
||||
|
||||
addhtitem (pt_hash, namealloc("abs") , ABS );
|
||||
addhtitem (pt_hash, namealloc("access") , ACCESS );
|
||||
addhtitem (pt_hash, namealloc("after") , AFTER );
|
||||
addhtitem (pt_hash, namealloc("alias") , ALIAS );
|
||||
addhtitem (pt_hash, namealloc("all") , ALL );
|
||||
addhtitem (pt_hash, namealloc("and") , _AND );
|
||||
addhtitem (pt_hash, namealloc("architecture") , ARCHITECTURE );
|
||||
addhtitem (pt_hash, namealloc("arg") , ARG );
|
||||
addhtitem (pt_hash, namealloc("array") , ARRAY );
|
||||
addhtitem (pt_hash, namealloc("assert") , ASSERT );
|
||||
addhtitem (pt_hash, namealloc("attribute") , ATTRIBUTE );
|
||||
|
||||
addhtitem (pt_hash, namealloc("begin") , _BEGIN );
|
||||
addhtitem (pt_hash, namealloc("bit") , BIT );
|
||||
addhtitem (pt_hash, namealloc("bit_vector") , BIT_VECTOR );
|
||||
addhtitem (pt_hash, namealloc("block") , BLOCK );
|
||||
addhtitem (pt_hash, namealloc("body") , BODY );
|
||||
addhtitem (pt_hash, namealloc("buffer") , BUFFER );
|
||||
addhtitem (pt_hash, namealloc("bus") , BUS );
|
||||
|
||||
addhtitem (pt_hash, namealloc("case") , CASE );
|
||||
addhtitem (pt_hash, namealloc("component") , COMPONENT );
|
||||
addhtitem (pt_hash, namealloc("configuration"), CONFIGURATION);
|
||||
addhtitem (pt_hash, namealloc("constant") , CONSTANT );
|
||||
|
||||
addhtitem (pt_hash, namealloc("disconnect") , DISCONNECT );
|
||||
addhtitem (pt_hash, namealloc("downto") , DOWNTO );
|
||||
|
||||
addhtitem (pt_hash, namealloc("else") , ELSE );
|
||||
addhtitem (pt_hash, namealloc("elsif") , ELSIF );
|
||||
addhtitem (pt_hash, namealloc("end") , _END );
|
||||
addhtitem (pt_hash, namealloc("entity") , ENTITY );
|
||||
addhtitem (pt_hash, namealloc("error") , ERROR );
|
||||
addhtitem (pt_hash, namealloc("exit") , _EXIT );
|
||||
|
||||
addhtitem (pt_hash, namealloc("file") , _FILE );
|
||||
addhtitem (pt_hash, namealloc("for") , FOR );
|
||||
addhtitem (pt_hash, namealloc("function") , FUNCTION );
|
||||
|
||||
addhtitem (pt_hash, namealloc("generate") , GENERATE );
|
||||
addhtitem (pt_hash, namealloc("generic") , GENERIC );
|
||||
addhtitem (pt_hash, namealloc("guarded") , GUARDED );
|
||||
|
||||
addhtitem (pt_hash, namealloc("if") , IF );
|
||||
addhtitem (pt_hash, namealloc("in") , _IN );
|
||||
addhtitem (pt_hash, namealloc("inout") , _INOUT );
|
||||
addhtitem (pt_hash, namealloc("integer") , INTEGER );
|
||||
addhtitem (pt_hash, namealloc("is") , IS );
|
||||
|
||||
addhtitem (pt_hash, namealloc("label") , _LABEL );
|
||||
addhtitem (pt_hash, namealloc("library") , LIBRARY );
|
||||
addhtitem (pt_hash, namealloc("linkage") , _LINKAGE );
|
||||
addhtitem (pt_hash, namealloc("list") , _LIST );
|
||||
addhtitem (pt_hash, namealloc("loop") , LOOP );
|
||||
|
||||
addhtitem (pt_hash, namealloc("map") , MAP );
|
||||
addhtitem (pt_hash, namealloc("mod") , MOD );
|
||||
addhtitem (pt_hash, namealloc("mux_bit") , MUX_BIT );
|
||||
addhtitem (pt_hash, namealloc("mux_vector") , MUX_VECTOR );
|
||||
|
||||
addhtitem (pt_hash, namealloc("nand") , _NAND );
|
||||
addhtitem (pt_hash, namealloc("natural") , NATURAL );
|
||||
addhtitem (pt_hash, namealloc("new") , NEW );
|
||||
addhtitem (pt_hash, namealloc("next") , _NEXT );
|
||||
addhtitem (pt_hash, namealloc("nor") , _NOR );
|
||||
addhtitem (pt_hash, namealloc("not") , _NOT );
|
||||
addhtitem (pt_hash, namealloc("null") , _NULL );
|
||||
|
||||
addhtitem (pt_hash, namealloc("of") , OF );
|
||||
addhtitem (pt_hash, namealloc("on") , ON );
|
||||
addhtitem (pt_hash, namealloc("open") , OPEN );
|
||||
addhtitem (pt_hash, namealloc("or") , _OR );
|
||||
addhtitem (pt_hash, namealloc("others") , OTHERS );
|
||||
addhtitem (pt_hash, namealloc("out") , _OUT );
|
||||
|
||||
addhtitem (pt_hash, namealloc("package") , PACKAGE );
|
||||
addhtitem (pt_hash, namealloc("port") , PORT );
|
||||
addhtitem (pt_hash, namealloc("positive") , POSITIVE );
|
||||
addhtitem (pt_hash, namealloc("procedure") , PROCEDURE );
|
||||
addhtitem (pt_hash, namealloc("process") , PROCESS );
|
||||
|
||||
addhtitem (pt_hash, namealloc("range") , RANGE );
|
||||
addhtitem (pt_hash, namealloc("record") , RECORD );
|
||||
addhtitem (pt_hash, namealloc("reg_bit") , REG_BIT );
|
||||
addhtitem (pt_hash, namealloc("reg_vector") , REG_VECTOR );
|
||||
addhtitem (pt_hash, namealloc("register") , REGISTER );
|
||||
addhtitem (pt_hash, namealloc("rem") , REM );
|
||||
addhtitem (pt_hash, namealloc("report") , REPORT );
|
||||
addhtitem (pt_hash, namealloc("return") , RETURN );
|
||||
|
||||
addhtitem (pt_hash, namealloc("select") , SELECT );
|
||||
addhtitem (pt_hash, namealloc("severity") , SEVERITY );
|
||||
addhtitem (pt_hash, namealloc("signal") , SIGNAL );
|
||||
addhtitem (pt_hash, namealloc("stable") , _STABLE );
|
||||
addhtitem (pt_hash, namealloc("string") , STRING );
|
||||
addhtitem (pt_hash, namealloc("subtype") , SUBTYPE );
|
||||
|
||||
addhtitem (pt_hash, namealloc("then") , THEN );
|
||||
addhtitem (pt_hash, namealloc("to") , TO );
|
||||
addhtitem (pt_hash, namealloc("transport") , TRANSPORT );
|
||||
addhtitem (pt_hash, namealloc("type") , _TYPE );
|
||||
|
||||
addhtitem (pt_hash, namealloc("units") , UNITS );
|
||||
addhtitem (pt_hash, namealloc("until") , UNTIL );
|
||||
addhtitem (pt_hash, namealloc("use") , USE );
|
||||
|
||||
addhtitem (pt_hash, namealloc("variable") , VARIABLE );
|
||||
|
||||
addhtitem (pt_hash, namealloc("wait") , WAIT );
|
||||
addhtitem (pt_hash, namealloc("warning") , WARNING );
|
||||
addhtitem (pt_hash, namealloc("when") , WHEN );
|
||||
addhtitem (pt_hash, namealloc("while") , WHILE );
|
||||
addhtitem (pt_hash, namealloc("with") , WITH );
|
||||
addhtitem (pt_hash, namealloc("wor_bit") , WOR_BIT );
|
||||
addhtitem (pt_hash, namealloc("wor_vector") , WOR_VECTOR );
|
||||
|
||||
addhtitem (pt_hash, namealloc("xor") , _XOR );
|
||||
}
|
||||
|
||||
return (gethtitem (pt_hash, namealloc(key)));
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
upper_case_letter [A-Z]
|
||||
digit [0-9]
|
||||
special_character [\#\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\_\|]
|
||||
space_character [ \t]
|
||||
format_effector [\t\v\r\l\f]
|
||||
end_of_line \n
|
||||
lower_case_letter [a-z]
|
||||
other_special_character [\!\$\@\?\[\\\]\^\`\{\}\~]
|
||||
|
||||
graphic_character ({basic_graphic_character}|{lower_case_letter}|{other_special_character})
|
||||
basic_graphic_character ({upper_case_letter}|{digit}|{special_character}|{space_character})
|
||||
letter ({upper_case_letter}|{lower_case_letter})
|
||||
letter_or_digit ({letter}|{digit})
|
||||
decimal_literal {integer}(\.{integer})?({exponent})?
|
||||
integer {digit}(_?{digit})*
|
||||
exponent ([eE][-+]?{integer})
|
||||
base {integer}
|
||||
based_integer {extended_digit}(_?{extended_digit})*
|
||||
extended_digit ({digit}|[a-fA-F])
|
||||
base_specifier (B|b|O|o|X|x)
|
||||
%%
|
||||
{space_character} {
|
||||
/* nothing */
|
||||
/* separators */
|
||||
}
|
||||
\& {
|
||||
return(Ampersand);
|
||||
}
|
||||
\' {
|
||||
return(Apostrophe);
|
||||
}
|
||||
\( {
|
||||
return(LeftParen);
|
||||
}
|
||||
\) {
|
||||
return(RightParen);
|
||||
}
|
||||
"**" {
|
||||
return(DoubleStar);
|
||||
}
|
||||
\* {
|
||||
return(Star);
|
||||
}
|
||||
\+ {
|
||||
return(Plus);
|
||||
}
|
||||
\, {
|
||||
return(Comma);
|
||||
}
|
||||
\- {
|
||||
return(Minus);
|
||||
}
|
||||
":=" {
|
||||
return(VarAsgn);
|
||||
}
|
||||
\: {
|
||||
return(Colon);
|
||||
}
|
||||
\; {
|
||||
return(Semicolon);
|
||||
}
|
||||
"<=" {
|
||||
return(_LESym);
|
||||
}
|
||||
">=" {
|
||||
return(_GESym);
|
||||
}
|
||||
\< {
|
||||
return(_LTSym);
|
||||
}
|
||||
\> {
|
||||
return(_GTSym);
|
||||
}
|
||||
= {
|
||||
return(_EQSym);
|
||||
}
|
||||
\/= {
|
||||
return(_NESym);
|
||||
}
|
||||
"=>" {
|
||||
return(Arrow);
|
||||
}
|
||||
"<>" {
|
||||
return(Box);
|
||||
}
|
||||
\| {
|
||||
return(Bar);
|
||||
}
|
||||
! {
|
||||
return(Bar);
|
||||
}
|
||||
\. {
|
||||
return(Dot);
|
||||
}
|
||||
\/ {
|
||||
return(Slash);
|
||||
}
|
||||
{letter}(_?{letter_or_digit})* {
|
||||
int itoken;
|
||||
|
||||
itoken = search (yytext);
|
||||
if (itoken == EMPTYHT)
|
||||
{
|
||||
yylval.text = namealloc(yytext);
|
||||
return ( Identifier );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( itoken );
|
||||
}
|
||||
}
|
||||
({decimal_literal})|({base}#{based_integer}(\.{based_integer})?#({exponent})?)|({base}:{based_integer}(\.{based_integer})?:({exponent})?) {
|
||||
yylval.text = mbkalloc((unsigned int)strlen(yytext)+1);
|
||||
strcpy(yylval.text,yytext);
|
||||
return ( AbstractLit );
|
||||
}
|
||||
'({graphic_character}|\"|\%)' {
|
||||
yylval.text = mbkalloc((unsigned int)strlen(yytext)+1);
|
||||
strcpy(yylval.text,yytext);
|
||||
return ( CharacterLit );
|
||||
}
|
||||
(\"({graphic_character}|(\"\")|\%)*\")|(\%({graphic_character}|(\%\%)|\")*\%) {
|
||||
yylval.text = mbkalloc((unsigned int)strlen(yytext)+1);
|
||||
strcpy(yylval.text,yytext);
|
||||
return ( StringLit );
|
||||
}
|
||||
{base_specifier}(\"{extended_digit}(_?{extended_digit})*\"|\%{extended_digit}(_?{extended_digit})*\%) {
|
||||
yylval.text = mbkalloc((unsigned int)strlen(yytext)+1);
|
||||
strcpy(yylval.text,yytext);
|
||||
return ( BitStringLit );
|
||||
}
|
||||
\n {
|
||||
/* end of line */
|
||||
MVL_LINNUM++;
|
||||
}
|
||||
\-\-.*$ {
|
||||
/* comment */
|
||||
/* nothing */
|
||||
}
|
||||
. {
|
||||
return (*yytext);
|
||||
}
|
||||
%%
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_slex.h */
|
||||
/* date : Nov 6 91 */
|
||||
/* author : TABUSSE L.A. */
|
||||
/* */
|
||||
/* content : declaration of functions and global variables used by */
|
||||
/* lex */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
#include "mvl_stdef.h"
|
||||
|
||||
extern int MVL_LINNUM; /* file's line number */
|
||||
|
||||
typedef struct {
|
||||
char nom[MVL_LG_MC];
|
||||
int kval;
|
||||
} el_mc;
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_sspec.yac */
|
||||
/* date : Jan 29 1992 */
|
||||
/* author : P. BAZARGAN */
|
||||
/* L.A. TABUSSE */
|
||||
/* VUONG H.N. */
|
||||
/* */
|
||||
/* content : these functions are used to build up MBK's structures */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
#ident "$Id: mvl_sspec.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
#include <stdio.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include "mvl_stype.h"
|
||||
#include "mvl_sspec.h"
|
||||
#include "mvl_stdef.h"
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_addlosig */
|
||||
/* description : create one or more losig structures (for an array a */
|
||||
/* losig is created for each bit) */
|
||||
/* called func. : addlosig, addchain */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
struct losig *mvl_addlosig (ptfig, index, type, ptype, name, left, right)
|
||||
|
||||
lofig_list *ptfig; /* pointer on LOFIG structure */
|
||||
int index; /* index of the first signal */
|
||||
char type ; /* signal's type */
|
||||
char ptype; /* signal's resolution function */
|
||||
char *name ; /* signal's name */
|
||||
short left ; /* array's left bound (= -1 if scalar) */
|
||||
short right; /* array's right bound (= -1 if scalar) */
|
||||
|
||||
{
|
||||
char extname[100];
|
||||
short i ;
|
||||
short inc = 1;
|
||||
struct chain *pt_chlst ;
|
||||
struct losig *ptsig ;
|
||||
|
||||
if ((left==-1) && (right==-1))
|
||||
{
|
||||
pt_chlst = addchain (NULL, name);
|
||||
ptsig = addlosig (ptfig, index, pt_chlst, type);
|
||||
|
||||
if (ptype != '0')
|
||||
ptsig->USER = addptype (ptsig->USER, ptype, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left >= right) /* array */
|
||||
inc = -1;
|
||||
|
||||
for (i=left ; i!=(right+inc) ; i+=inc)
|
||||
{
|
||||
sprintf (extname, "%s %d", name, i);
|
||||
pt_chlst = addchain (NULL, extname);
|
||||
ptsig = addlosig (ptfig, index, pt_chlst, type);
|
||||
|
||||
if (ptype != '0')
|
||||
ptsig->USER = addptype (ptsig->USER, ptype, NULL);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return (ptsig);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_addlocon */
|
||||
/* description : create one or more locon structures (for an array a */
|
||||
/* locon is created for each bit) */
|
||||
/* called func. : addlocon, addchain */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
struct locon *mvl_addlocon (ptfig, ptsig, dir, name, left, right)
|
||||
|
||||
struct lofig *ptfig; /* BEFIG structure's pointer */
|
||||
struct losig *ptsig; /* external signal's pointer */
|
||||
char dir ; /* port's mode */
|
||||
char *name ; /* port's name */
|
||||
short left ; /* array left bound (= -1 if scalar) */
|
||||
short right; /* array right bound (= -1 if scalar) */
|
||||
|
||||
{
|
||||
char extname[100];
|
||||
short i ;
|
||||
short inc = 1;
|
||||
struct locon *ptcon ;
|
||||
struct locon *ptcontmp ;
|
||||
|
||||
if ((left==-1) && (right==-1))
|
||||
{
|
||||
ptcon = addlocon (ptfig, name, ptsig, dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left >= right)
|
||||
inc = -1;
|
||||
|
||||
for (i=left ; i!=(right+inc) ; i+=inc)
|
||||
{
|
||||
sprintf (extname, "%s %d", name, i);
|
||||
ptcon = addlocon (ptfig, extname, NULL, dir);
|
||||
}
|
||||
|
||||
if (ptsig != NULL)
|
||||
{
|
||||
ptcontmp = ptcon;
|
||||
for (i=left ; i!=(right+inc) ; i+=inc)
|
||||
{
|
||||
ptcontmp->SIG = ptsig;
|
||||
ptcontmp = ptcontmp->NEXT;
|
||||
ptsig = ptsig->NEXT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ptcon);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_sspec.h */
|
||||
/* authors : VUONG H.N., L.A. TABUSSE, P. BAZARGAN */
|
||||
/* date : Aug 31 91 */
|
||||
/* content : contains all specific functions used to build */
|
||||
/* structural data structures, unless they are in <mbk> */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
losig_list *mvl_addlosig ();
|
||||
locon_list *mvl_addlocon ();
|
|
@ -0,0 +1,63 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_stdef.h */
|
||||
/* date : Nov 6 1991 */
|
||||
/* author : P.BAZARGAN, L.A.TABUSSE, VUONG H.N., D.HOMMAIS */
|
||||
/* content : declaration of defines used in asimut 's structural */
|
||||
/* function */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
#define MVL_LG_MC 15
|
||||
#define MVL_NB_MC ((tab_mc-1 + sizeof(tab_mc)/(sizeof(tab_mc[0])) - tab_mc+1))
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
#define MVL_UKNDFN 0 /* unknown port map mode */
|
||||
#define MVL_EXPDFN 1 /* explicit port map */
|
||||
#define MVL_IMPDFN 2 /* implicit port map */
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
#define MVL_ROTDFN 1 /* root model */
|
||||
#define MVL_CHDDFN 2 /* child model */
|
||||
|
||||
#define MVL_ICNDFN 1 /* input port */
|
||||
#define MVL_OCNDFN 2 /* output port */
|
||||
#define MVL_BCNDFN 3 /* inout port */
|
||||
#define MVL_XCNDFN 4 /* linkage port */
|
||||
|
||||
#define MVL_BITDFN 8 /* bit type */
|
||||
#define MVL_MUXDFN 16 /* mux_bit type */
|
||||
#define MVL_WORDFN 24 /* wor_bit type */
|
||||
#define MVL_BTVDFN 40 /* bit_vector type */
|
||||
#define MVL_MXVDFN 48 /* mux_vector type */
|
||||
#define MVL_WRVDFN 56 /* wor_vector type */
|
||||
#define MVL_RGVDFN 64 /* reg_vector type */
|
||||
#define MVL_CVTDFN 72 /* convertion type */
|
||||
#define MVL_BOLDFN 80 /* boolean type */
|
||||
|
||||
#define MVL_NATDFN 88 /* natural type */
|
||||
#define MVL_NAVDFN 96 /* nat_vector type */
|
||||
#define MVL_STRDFN 104 /* string type */
|
||||
#define MVL_LSTDFN 112 /* list type */
|
||||
#define MVL_ARGDFN 120 /* arg type */
|
||||
|
||||
#define MVL_NORDFN 128 /* non guarded signal */
|
||||
#define MVL_BUSDFN 256 /* guarded signal (bus) */
|
||||
|
||||
#define MVL_MODMSK 7 /* signal mode mask (3 bits) */
|
||||
#define MVL_TYPMSK 120 /* signal type mask (4 bits) */
|
||||
#define MVL_GRDMSK 896 /* signal guard mask (3 bits) */
|
||||
|
||||
#define MVL_MODDFN 0 /* mod_val field of dct_recrd */
|
||||
#define MVL_SIGDFN 1 /* sig_val field of dct_recrd */
|
||||
#define MVL_CCNDFN 2 /* ccn_val field of dct_recrd */
|
||||
#define MVL_RNGDFN 3 /* rng_val field of dct_recrd */
|
||||
#define MVL_LBLDFN 4 /* lbl_val field of dct_recrd */
|
||||
#define MVL_RGTDFN 5 /* rgt_val field of dct_recrd */
|
||||
#define MVL_LFTDFN 6 /* lft_val field of dct_recrd */
|
||||
#define MVL_PNTDFN 7 /* pnt_val field of dct_recrd */
|
||||
|
||||
#define MVL_UPTDFN 1 /* direction is up */
|
||||
#define MVL_DWTDFN 0 /* direction is down */
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_stype.h */
|
||||
/* date : Oct 15 1991 */
|
||||
/* author : P. BAZARGAN, L.A. TABUSSE, VUONG H.N. */
|
||||
/* */
|
||||
/* contents : This file contains defines and structure definitions */
|
||||
/* for the structural compiler */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *NAME; /* identifier name */
|
||||
short LEFT; /* vector's left index */
|
||||
short RIGHT; /* vector's right index */
|
||||
short ERR_FLG;
|
||||
}
|
||||
mvl_name;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short WIDTH; /* expression's width */
|
||||
struct chain *LIST; /* list of losig pointers */
|
||||
}
|
||||
mvl_expr;
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_syacc.h */
|
||||
/* date : Nov 07 1991 */
|
||||
/* author : P.BAZARGAN, L.A.TABUSSE, VUONG H.N. */
|
||||
/* content : declaration of external functions and global variables*/
|
||||
/* used by yacc */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
extern char MVL_MBKMOD; /* 'A' or 'P' or 'C') */
|
||||
extern char MVL_ERRFLG; /* if = 1 no structure is made */
|
||||
extern struct lofig *MVL_LOFPNT; /* current LOFIG pointer */
|
||||
|
||||
|
||||
extern struct dct_entry **MVL_HSHTAB; /* dictionnary's entry points */
|
||||
|
||||
extern struct dct_entry **mvl_initab();
|
||||
extern void mvl_addtab();
|
||||
extern int mvl_chktab();
|
||||
extern void mvl_fretab();
|
||||
extern void mvl_error();
|
||||
extern void mvl_warning();
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
extern losig_list *mvl_addlosig ();
|
||||
extern locon_list *mvl_addlocon ();
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
/* ###---------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_utdef.h */
|
||||
/* date : Nov 6 91 */
|
||||
/* author : L.A.TABUSSE */
|
||||
/* */
|
||||
/* content : declaration of external functions and global variables */
|
||||
/* used by yacc */
|
||||
/* */
|
||||
/* ###---------------------------------------------------------------### */
|
||||
|
||||
|
||||
#define MVL_ROTDFN 1 /* root model */
|
||||
#define MVL_CHDDFN 2 /* child model */
|
||||
|
||||
|
||||
#define MVL_ICNDFN 1 /* input port */
|
||||
#define MVL_OCNDFN 2 /* output port */
|
||||
#define MVL_BCNDFN 3 /* inout port */
|
||||
|
||||
#define MVL_BITDFN 8 /* bit type */
|
||||
#define MVL_MUXDFN 16 /* mux_bit type */
|
||||
#define MVL_WORDFN 24 /* wor_bit type */
|
||||
#define MVL_RBIDFN 32 /* reg_bit type */
|
||||
#define MVL_BTVDFN 40 /* bit_vector type */
|
||||
#define MVL_MXVDFN 48 /* mux_vector type */
|
||||
#define MVL_WRVDFN 56 /* wor_vector type */
|
||||
#define MVL_RGVDFN 64 /* reg_vector type */
|
||||
#define MVL_CVTDFN 72 /* convertion type */
|
||||
#define MVL_BOLDFN 80 /* boolean type */
|
||||
|
||||
#define MVL_NORDFN 128 /* non guarded signal */
|
||||
#define MVL_BUSDFN 256 /* guarded signal (bus) */
|
||||
#define MVL_REGDFN 384 /* guarded signal (register)*/
|
||||
|
||||
#define MVL_MODMSK 7 /* signal mode mask (3 bits) */
|
||||
#define MVL_TYPMSK 120 /* signal type mask (4 bits) */
|
||||
#define MVL_GRDMSK 896 /* signal guard mask (3 bits) */
|
||||
|
||||
#define MVL_NAMDFN 0
|
||||
#define MVL_NEWDFN 1
|
||||
|
||||
#define MVL_MODDFN 0 /* mod_val field of dct_recrd */
|
||||
#define MVL_SIGDFN 1 /* sig_val field of dct_recrd */
|
||||
#define MVL_CCNDFN 2 /* ccn_val field of dct_recrd */
|
||||
#define MVL_RNGDFN 3 /* rng_val field of dct_recrd */
|
||||
#define MVL_LBLDFN 4 /* lbl_val field of dct_recrd */
|
||||
#define MVL_WMXDFN 5 /* wmx_val field of dct_recrd */
|
||||
#define MVL_WMNDFN 6 /* wmn_val field of dct_recrd */
|
||||
#define MVL_PNTDFN 7 /* pnt_val field of dct_recrd */
|
||||
|
||||
#define MVL_ALODFN 60 /* minimal size of allocation */
|
||||
/* for dct_entry and dct_recrd */
|
||||
#define MVL_HSZDFN 97 /* number of entry points in the */
|
||||
/* dictionnary */
|
||||
#define MVL_MXRDFN 30
|
|
@ -0,0 +1,940 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_util.c */
|
||||
/* date : Jan 06 1993 */
|
||||
/* author : P. BAZARGAN-SABET */
|
||||
/* update : VUONG H.N. */
|
||||
/* */
|
||||
/* description : This file contains some utility functions : */
|
||||
/* mvl_addtab , mvl_chktab , mvl_fretab , mvl_error , */
|
||||
/* mvl_addent , mvl_addrcd , yy_b_error , mvl_y_error , */
|
||||
/* yy_v_error , yy_b_wrap , mvl_y_wrap , yy_v_wrap , */
|
||||
/* mvl_toolbug, mvl_message, mvl_reverse, mvl_warning, */
|
||||
/* mvl_initab , mvl_deltab, */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
#ident "$Id: mvl_util.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include "mvl_utype.h"
|
||||
#include "mvl_util.h"
|
||||
#include "mvl_utdef.h"
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_deltab */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
void mvl_deltab (head,key_str,ctx_str)
|
||||
|
||||
struct dct_entry **head;
|
||||
char *key_str;
|
||||
char *ctx_str;
|
||||
|
||||
{
|
||||
int found = 0;
|
||||
int index;
|
||||
struct dct_entry *entry_pnt;
|
||||
struct dct_entry *last_entry = NULL;
|
||||
struct dct_recrd *recrd_pnt;
|
||||
struct dct_recrd *last_recrd = NULL;
|
||||
|
||||
index = (int)key_str % MVL_HSZDFN;
|
||||
entry_pnt = head [index];
|
||||
|
||||
while (entry_pnt != NULL)
|
||||
{
|
||||
if (entry_pnt->key == key_str)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
last_entry = entry_pnt;
|
||||
entry_pnt = entry_pnt->next;
|
||||
}
|
||||
|
||||
if (found == 1)
|
||||
{
|
||||
found = 0;
|
||||
recrd_pnt = entry_pnt->data;
|
||||
while (recrd_pnt != NULL)
|
||||
{
|
||||
if (recrd_pnt->key == ctx_str)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
last_recrd = recrd_pnt;
|
||||
recrd_pnt = recrd_pnt->next;
|
||||
}
|
||||
|
||||
if (found == 1)
|
||||
{
|
||||
if (last_recrd == NULL)
|
||||
entry_pnt->data = recrd_pnt->next;
|
||||
else
|
||||
last_recrd->next = recrd_pnt->next;
|
||||
|
||||
recrd_pnt->next = MVL_DCRHED;
|
||||
MVL_DCRHED = recrd_pnt;
|
||||
|
||||
if (entry_pnt->data == NULL)
|
||||
{
|
||||
if (last_entry == NULL)
|
||||
head[index] = entry_pnt->next;
|
||||
else
|
||||
last_entry->next = entry_pnt->next;
|
||||
|
||||
entry_pnt->next = MVL_DCEHED;
|
||||
MVL_DCEHED = entry_pnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_initab */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
struct dct_entry **mvl_initab ()
|
||||
|
||||
{
|
||||
struct dct_entry **head;
|
||||
int i;
|
||||
|
||||
head = (struct dct_entry **)
|
||||
mbkalloc (sizeof(struct dct_entry *) * MVL_HSZDFN);
|
||||
|
||||
for (i=0 ; i<MVL_HSZDFN ; i++)
|
||||
head[i] = NULL;
|
||||
|
||||
return (head);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_warning */
|
||||
/* content : print out warning messages on the standard error output */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_warning (code,str1)
|
||||
int code;
|
||||
char *str1;
|
||||
{
|
||||
static char first_time = 0;
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case 2:
|
||||
if (first_time != 1)
|
||||
{
|
||||
(void)fprintf (stderr,"Warning %d : ",code);
|
||||
(void)fprintf(stderr,"consistency checks will be disabled\n");
|
||||
first_time = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 42:
|
||||
(void) fprintf (stderr,"Warning : connection missing on port `%s`\n",
|
||||
str1);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
(void)fprintf(stderr,"Warning %d : ",code);
|
||||
(void)fprintf(stderr,"unknown Warning code\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_toolbug */
|
||||
/* content : print out bugs messages on the standard error output */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_toolbug (code,str1,str2,nbr1)
|
||||
|
||||
int code;
|
||||
char *str1;
|
||||
char *str2;
|
||||
int nbr1;
|
||||
|
||||
{
|
||||
(void) fprintf (stderr,"Fatal error %d executing `%s`: ", code,str1);
|
||||
switch (code)
|
||||
{
|
||||
case 10:
|
||||
(void) fprintf (stderr,"decompiler called on empty lofig\n");
|
||||
break;
|
||||
}
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_message */
|
||||
/* content : print out messages on the standard error output */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_message (code,str1,nmb1)
|
||||
|
||||
int code;
|
||||
char *str1;
|
||||
int nmb1;
|
||||
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
default:
|
||||
(void) fprintf (stderr,"mvl_message : code %d unknown.\n",code);
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_addtab */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_addtab (head,key_str,ctx_str,field,valu)
|
||||
|
||||
struct dct_entry **head;
|
||||
char *key_str;
|
||||
char *ctx_str;
|
||||
int field;
|
||||
int valu;
|
||||
|
||||
{
|
||||
int found = 0;
|
||||
int index;
|
||||
struct dct_entry *entry_pnt;
|
||||
struct dct_recrd *recrd_pnt;
|
||||
|
||||
index = (int) key_str % MVL_HSZDFN;
|
||||
entry_pnt = head[index];
|
||||
|
||||
while (entry_pnt != NULL)
|
||||
{
|
||||
if (entry_pnt->key == key_str)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
entry_pnt = entry_pnt->next;
|
||||
}
|
||||
|
||||
if (found == 0)
|
||||
{
|
||||
head[index] = mvl_addent (head[index],key_str);
|
||||
entry_pnt = head[index];
|
||||
}
|
||||
|
||||
found = 0;
|
||||
recrd_pnt = entry_pnt->data;
|
||||
while (recrd_pnt != NULL)
|
||||
{
|
||||
if (recrd_pnt->key == ctx_str)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
recrd_pnt = recrd_pnt->next;
|
||||
}
|
||||
|
||||
if (found == 0)
|
||||
{
|
||||
entry_pnt->data = mvl_addrcd (entry_pnt->data,ctx_str);
|
||||
recrd_pnt = entry_pnt->data ;
|
||||
}
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case 0 :
|
||||
recrd_pnt->fd0_val = valu;
|
||||
break;
|
||||
case 1 :
|
||||
recrd_pnt->fd1_val = valu;
|
||||
break;
|
||||
case 2 :
|
||||
recrd_pnt->fd2_val = valu;
|
||||
break;
|
||||
case 3 :
|
||||
recrd_pnt->fd3_val = valu;
|
||||
break;
|
||||
case 4 :
|
||||
recrd_pnt->fd4_val = valu;
|
||||
break;
|
||||
case 5 :
|
||||
recrd_pnt->fd5_val = valu;
|
||||
break;
|
||||
case 6 :
|
||||
recrd_pnt->fd6_val = valu;
|
||||
break;
|
||||
case 7 :
|
||||
recrd_pnt->pnt_val = valu;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_chktab */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
int mvl_chktab (head,key_str,ctx_str,field)
|
||||
|
||||
struct dct_entry **head;
|
||||
char *key_str;
|
||||
char *ctx_str;
|
||||
int field;
|
||||
|
||||
{
|
||||
int found = 0;
|
||||
int valu = 0;
|
||||
struct dct_entry *entry_pnt;
|
||||
struct dct_recrd *recrd_pnt;
|
||||
|
||||
entry_pnt = head [(int)key_str % MVL_HSZDFN];
|
||||
|
||||
while (entry_pnt != NULL)
|
||||
{
|
||||
if (entry_pnt->key == key_str)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
entry_pnt = entry_pnt->next;
|
||||
}
|
||||
|
||||
if (found == 1)
|
||||
{
|
||||
found = 0;
|
||||
recrd_pnt = entry_pnt->data;
|
||||
while (recrd_pnt != NULL)
|
||||
{
|
||||
if (recrd_pnt->key == ctx_str)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
recrd_pnt = recrd_pnt->next;
|
||||
}
|
||||
if (found == 1)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case 0 :
|
||||
valu = recrd_pnt->fd0_val;
|
||||
break;
|
||||
case 1 :
|
||||
valu = recrd_pnt->fd1_val;
|
||||
break;
|
||||
case 2 :
|
||||
valu = recrd_pnt->fd2_val;
|
||||
break;
|
||||
case 3 :
|
||||
valu = recrd_pnt->fd3_val;
|
||||
break;
|
||||
case 4 :
|
||||
valu = recrd_pnt->fd4_val;
|
||||
break;
|
||||
case 5 :
|
||||
valu = recrd_pnt->fd5_val;
|
||||
break;
|
||||
case 6 :
|
||||
valu = recrd_pnt->fd6_val;
|
||||
break;
|
||||
case 7 :
|
||||
valu = recrd_pnt->pnt_val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (valu);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_fretab */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_fretab (pt_hash)
|
||||
|
||||
struct dct_entry **pt_hash;
|
||||
{
|
||||
struct dct_entry *pt_entry;
|
||||
struct dct_entry *pt_nxtentry;
|
||||
struct dct_recrd *pt_record;
|
||||
int i;
|
||||
|
||||
if (pt_hash != NULL)
|
||||
{
|
||||
for (i=0 ; i<MVL_HSZDFN ; i++)
|
||||
{
|
||||
if ((pt_entry = pt_hash[i]) != NULL)
|
||||
{
|
||||
while (pt_entry != NULL)
|
||||
{
|
||||
pt_record = pt_entry->data;
|
||||
|
||||
while (pt_record->next != NULL)
|
||||
pt_record = pt_record->next;
|
||||
|
||||
pt_record->next = MVL_DCRHED;
|
||||
MVL_DCRHED = pt_entry->data;
|
||||
|
||||
pt_nxtentry = pt_entry->next;
|
||||
pt_entry->next = MVL_DCEHED;
|
||||
MVL_DCEHED = pt_entry;
|
||||
pt_entry = pt_nxtentry;
|
||||
}
|
||||
}
|
||||
}
|
||||
free (pt_hash);
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_error */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_error (code,str1)
|
||||
|
||||
int code;
|
||||
char *str1;
|
||||
|
||||
{
|
||||
MVL_ERRFLG++;
|
||||
if (code < 100)
|
||||
(void)fprintf (stderr,"`%s` Error %d line %d :",MVL_CURFIL,code,MVL_LINNUM);
|
||||
else
|
||||
{
|
||||
if (code < 200)
|
||||
(void)fprintf (stderr,"Error %d :",code);
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case 1:
|
||||
(void) fprintf (stderr,"`%s` is incompatible with the entity name\n",str1);
|
||||
break;
|
||||
case 2:
|
||||
(void) fprintf (stderr,"bad entity declaration\n");
|
||||
break;
|
||||
case 3:
|
||||
(void) fprintf (stderr,"bad port clause declaration\n");
|
||||
break;
|
||||
case 4:
|
||||
(void) fprintf (stderr,"port `%s` already declared\n",str1);
|
||||
break;
|
||||
case 5:
|
||||
(void) fprintf (stderr,"illegal port declaration `%s` (mode, type, guard mark)\n",str1);
|
||||
break;
|
||||
case 6:
|
||||
(void) fprintf (stderr,"bad port declaration\n");
|
||||
break;
|
||||
case 7:
|
||||
(void) fprintf (stderr,"`%s` is incompatible with the architecture name\n",str1);
|
||||
break;
|
||||
case 8:
|
||||
(void) fprintf (stderr,"bad architecture declaration\n");
|
||||
break;
|
||||
case 9:
|
||||
(void) fprintf (stderr,"illegal declaration\n");
|
||||
break;
|
||||
case 10:
|
||||
(void) fprintf (stderr,"signal `%s` already declared\n",str1);
|
||||
break;
|
||||
case 11:
|
||||
(void) fprintf (stderr,"illegal signal declaration `%s` (type, guard mark)\n",str1);
|
||||
break;
|
||||
case 12:
|
||||
(void) fprintf (stderr,"component `%s` already declared\n",str1);
|
||||
break;
|
||||
case 13:
|
||||
(void) fprintf (stderr,"instance `%s` already declared\n",str1);
|
||||
break;
|
||||
case 14:
|
||||
(void) fprintf (stderr,"`%s` unknown component\n",str1);
|
||||
break;
|
||||
case 15:
|
||||
(void) fprintf (stderr,"illegal usage of implicit port map description\n");
|
||||
break;
|
||||
case 16:
|
||||
(void) fprintf (stderr,"`%s` unknown local port\n",str1);
|
||||
break;
|
||||
case 17:
|
||||
(void) fprintf (stderr,"`%s` unknown port or signal\n",str1);
|
||||
break;
|
||||
case 18:
|
||||
(void) fprintf (stderr,"illegal concurrent statement\n");
|
||||
break;
|
||||
case 31:
|
||||
(void) fprintf (stderr,"bad signal association\n");
|
||||
break;
|
||||
case 32:
|
||||
(void) fprintf (stderr,"null array not supported\n");
|
||||
break;
|
||||
case 33:
|
||||
(void) fprintf (stderr,"illegal constraint in declaration of type\n");
|
||||
break;
|
||||
case 36:
|
||||
(void) fprintf (stderr,"signal `%s` used out of declared range\n",str1);
|
||||
break;
|
||||
case 38:
|
||||
(void) fprintf (stderr,"width or/and type mismatch\n");
|
||||
break;
|
||||
case 41:
|
||||
(void) fprintf (stderr,"port `%s` connected to more than one signal\n",str1);
|
||||
break;
|
||||
case 76:
|
||||
(void) fprintf (stderr,"instance %s mismatch with the model\n",str1);
|
||||
break;
|
||||
case 107:
|
||||
(void) fprintf (stderr,"Cannot open result file\n");
|
||||
break;
|
||||
case 200:
|
||||
(void) fprintf (stderr,"\n cannot continue further more.\n");
|
||||
(void) fprintf (stderr,"\n Have a nice day...\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
(void) fprintf (stderr,"syntax error\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (MVL_ERRFLG > MVL_MXRDFN)
|
||||
{
|
||||
(void) fprintf (stderr,"Too many errors. Cannot continue further more\n");
|
||||
(void) fprintf (stderr,"\n Have a nice day...\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_addent */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
static struct dct_entry *mvl_addent (head , key)
|
||||
|
||||
struct dct_entry *head;
|
||||
char *key;
|
||||
|
||||
{
|
||||
struct dct_entry *entry;
|
||||
int i;
|
||||
|
||||
if (MVL_DCEHED == NULL)
|
||||
{
|
||||
MVL_DCEHED = (struct dct_entry *)
|
||||
mbkalloc (sizeof(struct dct_entry) * MVL_ALODFN);
|
||||
|
||||
entry = MVL_DCEHED;
|
||||
for (i=1 ; i<MVL_ALODFN ; i++)
|
||||
{
|
||||
entry->next = entry + 1;
|
||||
entry++;
|
||||
}
|
||||
entry->next = NULL;
|
||||
}
|
||||
|
||||
entry = MVL_DCEHED;
|
||||
MVL_DCEHED = MVL_DCEHED->next;
|
||||
|
||||
entry->next = head;
|
||||
entry->data = NULL;
|
||||
entry->key = key;
|
||||
|
||||
return (entry);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_addrcd */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
static struct dct_recrd *mvl_addrcd (head , key)
|
||||
|
||||
struct dct_recrd *head;
|
||||
char *key;
|
||||
|
||||
{
|
||||
struct dct_recrd *recrd;
|
||||
int i;
|
||||
|
||||
if (MVL_DCRHED == NULL)
|
||||
{
|
||||
MVL_DCRHED = (struct dct_recrd *)
|
||||
mbkalloc (sizeof(struct dct_recrd) * MVL_ALODFN);
|
||||
|
||||
recrd = MVL_DCRHED;
|
||||
for (i=1 ; i<MVL_ALODFN ; i++)
|
||||
{
|
||||
recrd->next = recrd + 1;
|
||||
recrd++;
|
||||
}
|
||||
recrd->next = NULL;
|
||||
}
|
||||
|
||||
recrd = MVL_DCRHED;
|
||||
MVL_DCRHED = MVL_DCRHED->next;
|
||||
|
||||
recrd->next = head;
|
||||
recrd->fd0_val = 0;
|
||||
recrd->fd1_val = 0;
|
||||
recrd->fd2_val = 0;
|
||||
recrd->fd3_val = 0;
|
||||
recrd->fd4_val = 0;
|
||||
recrd->fd5_val = 0;
|
||||
recrd->fd6_val = 0;
|
||||
recrd->pnt_val = 0;
|
||||
recrd->key = key;
|
||||
|
||||
return (recrd);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl__y_error */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_y_error (str)
|
||||
|
||||
char *str;
|
||||
{
|
||||
MVL_ERRFLG++;
|
||||
(void)fprintf (stderr,"`%s` Error line %d : %s\n",MVL_CURFIL,MVL_LINNUM,str);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_y_wrap */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
int mvl_y_wrap ()
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_avers */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
char *mvl_avers ()
|
||||
{
|
||||
return ("-- V 1.3 --");
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_vhdlname */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
char *mvl_vhdlname (name)
|
||||
|
||||
char *name;
|
||||
|
||||
{
|
||||
char *new_name;
|
||||
char *prv_name;
|
||||
char *tmp_name;
|
||||
char buffer[200];
|
||||
int i,j,flag,number;
|
||||
static struct dct_entry **namtab=NULL;
|
||||
|
||||
if (namtab == NULL)
|
||||
namtab = mvl_initab ();
|
||||
|
||||
tmp_name = namealloc (name);
|
||||
new_name = (char *) mvl_chktab (namtab,tmp_name,NULL,MVL_PNTDFN);
|
||||
|
||||
if (mvl_chktab (namtab,tmp_name,NULL,MVL_NAMDFN) == 0)
|
||||
{
|
||||
i = 0;
|
||||
j = 0;
|
||||
number = 0;
|
||||
flag = 1;
|
||||
while (tmp_name[i] != '\0')
|
||||
{
|
||||
buffer[j] = tmp_name[i];
|
||||
if ( ((tmp_name[i] >= 'a') && (tmp_name[i] <= 'z')) ||
|
||||
((tmp_name[i] >= 'A') && (tmp_name[i] <= 'Z')) ||
|
||||
((tmp_name[i] >= '0') && (tmp_name[i] <= '9') && (i != 0)) ||
|
||||
((tmp_name[i] == '(') || (tmp_name[i] == ')')) )
|
||||
flag = 0;
|
||||
else
|
||||
{
|
||||
if (flag == 1)
|
||||
buffer[j++] = 'v';
|
||||
buffer[j] = '_';
|
||||
flag = 1;
|
||||
}
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
if (buffer[j-1] == '_')
|
||||
buffer[j++] = '0';
|
||||
buffer[j] = '\0';
|
||||
new_name = namealloc (buffer);
|
||||
|
||||
prv_name = new_name;
|
||||
while (mvl_chktab (namtab,new_name,NULL,MVL_NEWDFN) != 0)
|
||||
{
|
||||
new_name = prv_name;
|
||||
sprintf (buffer,"%s_%d",new_name,number++);
|
||||
prv_name = new_name;
|
||||
new_name = namealloc (buffer);
|
||||
}
|
||||
mvl_addtab (namtab,new_name,NULL,MVL_NEWDFN,1);
|
||||
mvl_addtab (namtab,tmp_name,NULL,MVL_PNTDFN,(int)new_name);
|
||||
mvl_addtab (namtab,tmp_name,NULL,MVL_NAMDFN,1);
|
||||
}
|
||||
|
||||
return (new_name);
|
||||
}
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_name */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void mvl_name (name,new_name)
|
||||
|
||||
char *name;
|
||||
char *new_name;
|
||||
|
||||
{
|
||||
char *blank_space;
|
||||
|
||||
/* Transformation des blancs en parentheses */
|
||||
strcpy(new_name,name);
|
||||
blank_space = strchr(new_name,' ');
|
||||
if(blank_space != NULL)
|
||||
{
|
||||
*blank_space = '(';
|
||||
blank_space = strchr(new_name,'\0');
|
||||
/* Transformation du dernier caractere en ) */
|
||||
if(blank_space != NULL)
|
||||
{
|
||||
*blank_space = ')';
|
||||
blank_space++;
|
||||
*blank_space = '\0';
|
||||
}
|
||||
}
|
||||
strcpy(new_name,mvl_vhdlname(new_name));
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_vectnam */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
void *mvl_vectnam(pt_list,left,right,name,type)
|
||||
|
||||
void *pt_list;
|
||||
int *left, *right;
|
||||
char **name;
|
||||
char type;
|
||||
|
||||
{
|
||||
char *blank_space;
|
||||
char *sig_name;
|
||||
char name_tmp[200];
|
||||
char number[200];
|
||||
losig_list *ptsig;
|
||||
locon_list *ptcon;
|
||||
char END = 0;
|
||||
|
||||
/* Case losig_list */
|
||||
if(type==0)
|
||||
{
|
||||
ptsig = (losig_list *)pt_list;
|
||||
if (ptsig->TYPE == 'I')
|
||||
{
|
||||
*left = *right = -1;
|
||||
sig_name = getsigname(ptsig);
|
||||
*name = (char*)mbkalloc(strlen(sig_name) + 1);
|
||||
strcpy(*name,sig_name);
|
||||
blank_space = strchr(*name,' ');
|
||||
if (blank_space != NULL)
|
||||
{
|
||||
strcpy(number,blank_space);
|
||||
*right = atoi(number);
|
||||
*left = *right;
|
||||
*blank_space = '\0';
|
||||
}
|
||||
|
||||
while(!END)
|
||||
{
|
||||
if(ptsig->NEXT != NULL)
|
||||
{
|
||||
strcpy(name_tmp,getsigname(ptsig->NEXT));
|
||||
blank_space = strchr(name_tmp,' ');
|
||||
if(blank_space!=NULL)
|
||||
{
|
||||
strcpy(number,blank_space);
|
||||
*blank_space = '\0';
|
||||
if(!strcmp(*name,name_tmp))
|
||||
{
|
||||
*left = atoi(number);
|
||||
ptsig = ptsig->NEXT;
|
||||
}
|
||||
else
|
||||
END = 1;
|
||||
}
|
||||
else
|
||||
END = 1;
|
||||
}
|
||||
else
|
||||
END = 1;
|
||||
}
|
||||
return(ptsig);
|
||||
}
|
||||
else
|
||||
{
|
||||
*name = NULL;
|
||||
return(ptsig);
|
||||
}
|
||||
}
|
||||
|
||||
/*case locon_list */
|
||||
if(type==1)
|
||||
{
|
||||
ptcon = (locon_list *)pt_list;
|
||||
/* Extract the name and number of an element */
|
||||
*left = *right = -1;
|
||||
sig_name = ptcon->NAME;
|
||||
*name = (char *)mbkalloc(strlen(sig_name) + 1);
|
||||
strcpy(*name,sig_name);
|
||||
blank_space = strchr(*name,' ');
|
||||
if (blank_space != NULL)
|
||||
{
|
||||
strcpy(number,blank_space);
|
||||
*right = atoi(number);
|
||||
*left = *right;
|
||||
*blank_space = '\0';
|
||||
}
|
||||
|
||||
while(END != 1)
|
||||
{
|
||||
if(ptcon->NEXT != NULL)
|
||||
{
|
||||
strcpy(name_tmp,ptcon->NEXT->NAME);
|
||||
blank_space = strchr(name_tmp,' ');
|
||||
if(blank_space!=NULL)
|
||||
{
|
||||
strcpy(number,blank_space);
|
||||
*blank_space = '\0';
|
||||
if(!strcmp(*name,name_tmp))
|
||||
{
|
||||
*right = atoi(number);
|
||||
ptcon = ptcon->NEXT;
|
||||
}
|
||||
else
|
||||
END = 1;
|
||||
}
|
||||
else
|
||||
END = 1;
|
||||
}
|
||||
else
|
||||
END = 1;
|
||||
}
|
||||
return(ptcon);
|
||||
}
|
||||
/* To avoid Warning from GCC */
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_reverse */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
struct chain *mvl_reverse (head)
|
||||
|
||||
struct chain *head;
|
||||
|
||||
{
|
||||
struct chain *last_pnt = NULL;
|
||||
struct chain *curr_pnt = NULL;
|
||||
struct chain *next_pnt = NULL;
|
||||
|
||||
if (head != NULL)
|
||||
{
|
||||
last_pnt = head;
|
||||
curr_pnt = head->NEXT;
|
||||
last_pnt->NEXT = NULL;
|
||||
|
||||
if (curr_pnt != NULL)
|
||||
{
|
||||
next_pnt = curr_pnt->NEXT;
|
||||
|
||||
while (next_pnt != NULL)
|
||||
{
|
||||
curr_pnt->NEXT = last_pnt;
|
||||
|
||||
/* ###------------------------------------------------------### */
|
||||
/* Now shift the window to the next structure */
|
||||
/* ###------------------------------------------------------### */
|
||||
|
||||
last_pnt = curr_pnt;
|
||||
curr_pnt = next_pnt;
|
||||
next_pnt = next_pnt->NEXT;
|
||||
}
|
||||
|
||||
curr_pnt->NEXT = last_pnt;
|
||||
}
|
||||
else
|
||||
curr_pnt = head;
|
||||
}
|
||||
|
||||
return (curr_pnt);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------### */
|
||||
/* function : mvl_fill */
|
||||
/* content : Fill a lofig of mode 'P' with another lofig of mode 'A' */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
struct lofig *mvl_fill (lofig_P, lofig_A)
|
||||
|
||||
struct lofig *lofig_P;
|
||||
struct lofig *lofig_A;
|
||||
|
||||
{
|
||||
struct locon *ptlocon_P, *ptlocon_A;
|
||||
struct chain *ptchain;
|
||||
struct lofig *ptlofig;
|
||||
struct losig *ptlosig;
|
||||
|
||||
/* MODELCHAIN */
|
||||
ptchain = lofig_P->MODELCHAIN;
|
||||
lofig_P->MODELCHAIN = lofig_A->MODELCHAIN;
|
||||
|
||||
/* LOCON */
|
||||
ptlocon_P = lofig_P->LOCON;
|
||||
ptlocon_A = lofig_A->LOCON;
|
||||
|
||||
while(ptlocon_A != NULL)
|
||||
{
|
||||
if(ptlocon_A->NAME == ptlocon_P->NAME)
|
||||
{
|
||||
ptlocon_P->SIG = ptlocon_A->SIG;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)fprintf(stderr,"\n*** mbk error *** bad consistency in figure %s,\n external interface are different\n", lofig_P->NAME);
|
||||
}
|
||||
ptlocon_A = ptlocon_A->NEXT;
|
||||
ptlocon_P = ptlocon_P->NEXT;
|
||||
}
|
||||
|
||||
/* LOSIG */
|
||||
ptlosig = lofig_P->LOSIG;
|
||||
lofig_P->LOSIG = lofig_A->LOSIG;
|
||||
|
||||
/* LOINS */
|
||||
lofig_P->LOINS = lofig_A->LOINS;
|
||||
|
||||
/* LOTRS */
|
||||
lofig_P->LOTRS = lofig_A->LOTRS;
|
||||
|
||||
/* USER */
|
||||
lofig_P->USER = lofig_A->USER;
|
||||
|
||||
/* MODE */
|
||||
lofig_P->MODE = 'A';
|
||||
|
||||
/* Freeing the memory zone unusable */
|
||||
|
||||
freechain(ptchain);
|
||||
|
||||
while (lofig_A->LOCON != NULL)
|
||||
{
|
||||
(void)dellocon(lofig_A, lofig_A->LOCON->NAME);
|
||||
}
|
||||
|
||||
ptlofig = addlofig(" bidon");
|
||||
ptlofig->LOSIG = ptlosig;
|
||||
(void)dellofig(ptlofig->NAME);
|
||||
|
||||
|
||||
|
||||
return(lofig_P);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/* ###--------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_util.h */
|
||||
/* date : Oct 4 1991 */
|
||||
/* author : P. BAZARGAN-SABET */
|
||||
/* */
|
||||
/* description : This file contains declaration of global and external */
|
||||
/* variables and, functions used in `mvl_util.c` */
|
||||
/* */
|
||||
/* ###--------------------------------------------------------------### */
|
||||
|
||||
extern int MVL_LINNUM; /* file's line number */
|
||||
extern char MVL_ERRFLG; /* Error flag */
|
||||
extern char MVL_CURFIL[]; /* current file name */
|
||||
|
||||
static struct dct_entry *MVL_DCEHED; /* free dct_entry's head */
|
||||
static struct dct_recrd *MVL_DCRHED; /* free dct_recrd's head */
|
||||
|
||||
static struct dct_entry *mvl_addent();
|
||||
static struct dct_recrd *mvl_addrcd();
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
/* ###---------------------------------------------------------------### */
|
||||
/* */
|
||||
/* file : mvl_utype.h */
|
||||
/* date : Aug 8 91 */
|
||||
/* author : P.BAZARGAN L.A.TABUSSE VUONG H.N. */
|
||||
/* */
|
||||
/* content : declaration of external functions and global variables */
|
||||
/* used by yacc */
|
||||
/* */
|
||||
/* ###---------------------------------------------------------------### */
|
||||
|
||||
struct dct_entry
|
||||
{
|
||||
struct dct_entry *next;
|
||||
struct dct_recrd *data;
|
||||
char *key;
|
||||
};
|
||||
|
||||
struct dct_recrd
|
||||
{
|
||||
struct dct_recrd *next;
|
||||
char *key;
|
||||
short fd0_val;
|
||||
short fd1_val;
|
||||
short fd2_val;
|
||||
short fd3_val;
|
||||
short fd4_val;
|
||||
short fd5_val;
|
||||
short fd6_val;
|
||||
int pnt_val;
|
||||
};
|
|
@ -0,0 +1,84 @@
|
|||
#ident "$Id: vel_chain.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
#include <stdio.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include <mlu.h>
|
||||
#include "vel_velo.h"
|
||||
|
||||
void debugChain(lofig_list *f)
|
||||
{
|
||||
ptype_list *p;
|
||||
velosig *vs;
|
||||
velocon *vc;
|
||||
chain_list *ch;
|
||||
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
for (vs=(velosig *)p->DATA; vs; vs=vs->NEXT) {
|
||||
printf("+-%s[%ld:%ld]\n", vs->NAME, vs->LEFT, vs->RIGHT);
|
||||
if (vs->TYPE=='M')
|
||||
printf(" <%s[%ld:%ld]>\n", vs->SUPER->NAME,
|
||||
vs->SUPER->LEFT, vs->SUPER->RIGHT);
|
||||
p=getptype(vs->USER, VEL_CHAIN);
|
||||
for (ch=(chain_list *)p->DATA; ch; ch=ch->NEXT) {
|
||||
vc=(velocon *)ch->DATA;
|
||||
printf(" *-%s[%ld:%ld]\n", vc->NAME, vc->LEFT, vc->RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void velofigChain(lofig_list *f)
|
||||
{
|
||||
velocon *vc;
|
||||
velosig *vs;
|
||||
ptype_list *p;
|
||||
loins_list *i;
|
||||
chain_list *c;
|
||||
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
if (!p) {
|
||||
fprintf(stderr, "No velosig found!");
|
||||
}
|
||||
for (vs=(velosig *)p->DATA; vs; vs=vs->NEXT) {
|
||||
p=getptype(vs->USER, VEL_CHAIN);
|
||||
if (p != NULL) {
|
||||
freechain((chain_list *)p->DATA);
|
||||
p->DATA=NULL;
|
||||
} else
|
||||
vs->USER=addptype(vs->USER, VEL_CHAIN, NULL);
|
||||
}
|
||||
|
||||
p=getptype(f->USER, VEL_CON);
|
||||
if (p!=NULL) {
|
||||
for (vc=(velocon *)p->DATA; vc; vc=vc->NEXT) {
|
||||
for (c=vc->VSIG; c; c=c->NEXT) {
|
||||
vs=(velosig *)c->DATA;
|
||||
p=getptype(vs->USER, VEL_CHAIN);
|
||||
p->DATA=addchain(p->DATA, vc);
|
||||
if (vs->TYPE=='M') {
|
||||
p=getptype(vs->SUPER->USER, VEL_CHAIN);
|
||||
p->DATA=addchain(p->DATA, vc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
if (p!=NULL) {
|
||||
for (vc=(velocon *)p->DATA; vc; vc=vc->NEXT) {
|
||||
for (c=vc->VSIG; c; c=c->NEXT) {
|
||||
vs=(velosig *)c->DATA;
|
||||
p=getptype(vs->USER, VEL_CHAIN);
|
||||
p->DATA=addchain(p->DATA, vc);
|
||||
if (vs->TYPE=='M') {
|
||||
p=getptype(vs->SUPER->USER, VEL_CHAIN);
|
||||
p->DATA=addchain(p->DATA, vc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getenv("VEL_DEBUG"))
|
||||
debugChain(f);
|
||||
}
|
||||
|
|
@ -0,0 +1,713 @@
|
|||
/* ###--------------------------------------------------------------------### */
|
||||
/* # # */
|
||||
/* # file : vel_drive.c # */
|
||||
/* | date : Jul 3 1997 | */
|
||||
/* | version : 1.00 | */
|
||||
/* | author : Denis Hommais | */
|
||||
/* | | */
|
||||
/* # contents : vhdl driver # */
|
||||
/* # # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/*
|
||||
* $Log: vel_drive.c,v $
|
||||
* Revision 1.1 2002/04/26 09:51:07 ludo
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 2002/04/16 07:24:51 fred
|
||||
* Adding modifications to handle limited generics in VHDL files.
|
||||
*
|
||||
* Revision 1.1.1.1 2002/04/11 08:54:53 fred
|
||||
* Importing mbkvhdlg into the new Alliance CVS tree
|
||||
*
|
||||
* Revision 1.1.1.1 2002/02/28 12:58:31 disydent
|
||||
* Creation of Disydent CVS Tree
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/19 16:55:27 pwet
|
||||
* Changing the CVS tree structure of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/24 13:31:42 pwet
|
||||
* cvs tree of part of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/19 14:32:20 pwet
|
||||
* New cvs tree
|
||||
*
|
||||
* Revision 1.9 1998/11/12 10:41:26 pwet
|
||||
* Add indentation in the driver
|
||||
*
|
||||
* Revision 1.8 1998/11/12 10:39:26 pwet
|
||||
* add makevelofig function.
|
||||
*
|
||||
* Revision 1.7 1998/01/06 09:53:40 denis
|
||||
* merge the two drivers in one function.
|
||||
* use an array instead of a case for connector type
|
||||
*
|
||||
* Revision 1.6 1997/12/17 16:41:33 denys
|
||||
* add 'M' type check for partial vector connection
|
||||
*
|
||||
* Revision 1.5 1997/12/10 10:42:01 denys
|
||||
* Change bit_vector to stdlogic_vector
|
||||
*
|
||||
* Revision 1.4 1997/12/05 10:25:23 denys
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.3 1997/09/24 09:46:48 denys
|
||||
* rename the signal when it is connected to a external connector by the
|
||||
* name of the connector
|
||||
*
|
||||
* Revision 1.2 1997/09/23 09:42:15 denys
|
||||
* change , to & when concatened signals
|
||||
*
|
||||
*/
|
||||
|
||||
#ident "$Id: vel_drive.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include <mlu.h>
|
||||
#include "vel_velo.h"
|
||||
#include "gen_generic.h"
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Static Variables # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static int strlength;
|
||||
static int first;
|
||||
static int dim;
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function prototype # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void debugvelocon(lofig_list *);
|
||||
void debugvelosig(lofig_list *);
|
||||
void debugveloins(lofig_list *);
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Macro definition # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
#define getvectordirection(c) ((c)->LEFT>=(c)->RIGHT)?"downto":"to"
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function printconnector # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static const char *bittab[2][7]= {
|
||||
{
|
||||
" %s : inout bit%s\n", /* 0 B */
|
||||
"", /* 1 ! */
|
||||
" %s : in bit%s\n", /* 2 I */
|
||||
" %s : out bit%s\n", /* 3 O */
|
||||
" %s : inout mux_bit bus%s\n", /* 4 T */
|
||||
" %s : linkage bit%s\n", /* 5 X */
|
||||
" %s : out mux_bit bus%s\n", /* 6 Z */
|
||||
}, {
|
||||
" %s : inout std_logic%s\n", /* 0 B */
|
||||
"", /* 1 ! */
|
||||
" %s : in std_logic%s\n", /* 2 I */
|
||||
" %s : out std_logic%s\n", /* 3 O */
|
||||
" %s : inout std_logic%s\n", /* 4 T */
|
||||
" %s : inout std_logic%s\n", /* 5 X */
|
||||
" %s : out std_logic%s\n", /* 6 Z */
|
||||
}
|
||||
};
|
||||
|
||||
static const char *vecttab[2][7]= {
|
||||
{
|
||||
" %s : inout bit_vector(%ld %s %ld)%s\n", /* 0 B */
|
||||
"", /* 1 ! */
|
||||
" %s : in bit_vector(%ld %s %ld)%s\n", /* 2 I */
|
||||
" %s : out bit_vector(%ld %s %ld)%s\n", /* 3 O */
|
||||
" %s : inout mux_vector(%ld %s %ld) bus%s\n", /* 4 T */
|
||||
" %s : linkage bit_vector(%ld %s %ld)%s\n", /* 5 X */
|
||||
" %s : out mux_vector(%ld %s %ld) bus%s\n", /* 6 Z */
|
||||
}, {
|
||||
" %s : inout std_logic_vector(%ld %s %ld)%s\n", /* 0 B */
|
||||
"", /* 1 ! */
|
||||
" %s : in std_logic_vector(%ld %s %ld)%s\n", /* 2 I */
|
||||
" %s : out std_logic_vector(%ld %s %ld)%s\n", /* 3 O */
|
||||
" %s : inout std_logic_vector(%ld %s %ld) %s\n", /* 4 T */
|
||||
" %s : inout std_logic_vector(%ld %s %ld)%s\n", /* 5 X */
|
||||
" %s : out std_logic_vector(%ld %s %ld) %s\n", /* 6 Z */
|
||||
}
|
||||
};
|
||||
|
||||
static void printconnector(FILE *file, velocon *c, int mode, int maxlength)
|
||||
{
|
||||
int i, length=strlen(c->NAME);
|
||||
char *buf=(char *)mbkalloc((maxlength+1)*sizeof(char));
|
||||
if (mode) mode=1;
|
||||
|
||||
strcpy(buf, c->NAME);
|
||||
for (i=length; i<maxlength; i++)
|
||||
buf[i]=' ';
|
||||
buf[maxlength]='\0';
|
||||
|
||||
if (c->LEFT==-1) {
|
||||
fprintf(file,
|
||||
bittab[mode][(((locon_list *)c->ROOT->DATA)->DIRECTION-'A')/4],
|
||||
buf, (c->NEXT)?";":"\n );");
|
||||
} else {
|
||||
fprintf(file,
|
||||
vecttab[mode][(((locon_list *)c->ROOT->DATA)->DIRECTION-'A')/4],
|
||||
buf, c->LEFT, getvectordirection(c), c->RIGHT,
|
||||
(c->NEXT)?";":"\n );");
|
||||
}
|
||||
mbkfree(buf);
|
||||
}
|
||||
|
||||
static void drv_genvalue(FILE *ptfile, logen_list *ptgen)
|
||||
{
|
||||
logen_list *l;
|
||||
int i;
|
||||
|
||||
switch (ptgen->TYPE) {
|
||||
case GENTYPE_BIT:
|
||||
fprintf(ptfile, "'%c'", ptgen->VALUE.CHAR);
|
||||
break;
|
||||
case GENTYPE_HEX:
|
||||
fprintf(ptfile, "16#%08lx#", ptgen->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_VAL:
|
||||
fprintf(ptfile, "%ld", ptgen->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_ARG:
|
||||
fprintf(ptfile, "%ld", ptgen->VALUE.VAL);
|
||||
break;
|
||||
case GENTYPE_TEXT:
|
||||
fputs(ptgen->VALUE.TEXT, ptfile);
|
||||
break;
|
||||
case GENTYPE_LIST:
|
||||
fputc('(', ptfile);
|
||||
dim--;
|
||||
if (first
|
||||
&& ptgen->VALUE.LIST && ptgen->VALUE.LIST->TYPE!=GENTYPE_LIST) {
|
||||
strlength++;
|
||||
first=0;
|
||||
dim=1;
|
||||
}
|
||||
for (l=ptgen->VALUE.LIST; l; l=l->NEXT) {
|
||||
drv_genvalue(ptfile, l);
|
||||
if (l->NEXT)
|
||||
if (dim==2) {
|
||||
fputs(",\n", ptfile);
|
||||
for (i=0; i<strlength; i++) putc(' ', ptfile);
|
||||
} else
|
||||
fputc(',', ptfile);
|
||||
}
|
||||
fputc(')', ptfile);
|
||||
dim++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void drv_generic(FILE *ptfile, ptype_list *pttype)
|
||||
{
|
||||
struct logen *ptgen;
|
||||
int maxlength=0, length, j;
|
||||
char *buf;
|
||||
|
||||
if ((pttype=getptype(pttype,LOGEN))) {
|
||||
fprintf (ptfile," generic (\n");
|
||||
for (ptgen=pttype->DATA;ptgen;ptgen=ptgen->NEXT)
|
||||
if (maxlength<strlen(ptgen->NAME))
|
||||
maxlength=strlen(ptgen->NAME);
|
||||
|
||||
buf=(char *)mbkalloc((maxlength+1)*sizeof(char));
|
||||
|
||||
for (ptgen=pttype->DATA;ptgen;ptgen=ptgen->NEXT) {
|
||||
length=strlen(ptgen->NAME);
|
||||
strcpy(buf, ptgen->NAME);
|
||||
for (j=length; j<maxlength; j++)
|
||||
buf[j]=' ';
|
||||
buf[maxlength]='\0';
|
||||
|
||||
strlength+=fprintf (ptfile," CONSTANT %s : ",buf);
|
||||
switch(ptgen->TYPE) {
|
||||
case GENTYPE_BIT:
|
||||
strlength+=fputs("bit := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_HEX:
|
||||
strlength+=fputs("natural := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_VAL:
|
||||
strlength+=fputs("natural := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_ARG:
|
||||
strlength+=fputs("arg := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_TEXT:
|
||||
strlength+=fputs("string := ", ptfile);
|
||||
break;
|
||||
case GENTYPE_LIST:
|
||||
strlength+=fputs("list := ", ptfile);
|
||||
break;
|
||||
}
|
||||
first=1;
|
||||
dim=0;
|
||||
drv_genvalue(ptfile, ptgen);
|
||||
if (ptgen->NEXT) {
|
||||
fputs(";\n", ptfile);
|
||||
strlength=0;
|
||||
}
|
||||
}
|
||||
fputs("\n );\n",ptfile);
|
||||
strlength=0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function vhdsavevelofig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void vhdsavevelofig (lofig_list *f, int mode)
|
||||
{
|
||||
FILE *file;
|
||||
ptype_list *p;
|
||||
chain_list *m, *mod=NULL;
|
||||
loins_list *i;
|
||||
velocon *c;
|
||||
velosig *s, *ss;
|
||||
int maxlength;
|
||||
char *buf;
|
||||
int length, j;
|
||||
|
||||
if (!(file=mbkfopen(f->NAME, mode?"vhd":"vst", "w"))) {
|
||||
fprintf(stderr,"Can't open file %s.%s", f->NAME, mode?"vhd":"vst");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (mode&4)
|
||||
fputs("library work;\nuse work.all;\n",file);
|
||||
#if 0
|
||||
fputs("library WORK;\nuse WORK.P6_PKG.all;\n",file);
|
||||
#endif
|
||||
if (mode)
|
||||
fputs("library ieee;\nuse ieee.std_logic_1164.all;\n",file);
|
||||
|
||||
/*
|
||||
* Entity Declaration
|
||||
*/
|
||||
fprintf(file, "entity %s is\n", f->NAME);
|
||||
|
||||
/*
|
||||
* Generic Declaration
|
||||
*/
|
||||
drv_generic(file, f->USER);
|
||||
|
||||
/*
|
||||
* Port Declaration
|
||||
*/
|
||||
p=getptype(f->USER, VEL_CON);
|
||||
if (p && p->DATA) {
|
||||
maxlength=0;
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT)
|
||||
if (maxlength<strlen(c->NAME))
|
||||
maxlength=strlen(c->NAME);
|
||||
fputs(" port (\n", file);
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT)
|
||||
printconnector(file, c, mode, maxlength);
|
||||
}
|
||||
fprintf(file, "end %s;\n", f->NAME);
|
||||
fprintf(file, "\narchitecture structural of %s is\n", f->NAME);
|
||||
|
||||
/*
|
||||
* Make a list of the used components
|
||||
*/
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
for (m=mod; m; m=m->NEXT)
|
||||
if (((loins_list *)m->DATA)->FIGNAME == i->FIGNAME) break;
|
||||
if (!m)
|
||||
mod=addchain(mod, i);
|
||||
}
|
||||
/*
|
||||
* Write the list as component declaration
|
||||
*/
|
||||
for (m=mod; m; m=m->NEXT) {
|
||||
i=(loins_list *)m->DATA;
|
||||
fprintf(file, "Component %s\n", i->FIGNAME);
|
||||
/*
|
||||
* Generic Declaration
|
||||
*/
|
||||
drv_generic(file, i->USER);
|
||||
|
||||
/*
|
||||
* Port Declaration
|
||||
*/
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
if (p->DATA) {
|
||||
maxlength=0;
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT)
|
||||
if (maxlength<strlen(c->NAME))
|
||||
maxlength=strlen(c->NAME);
|
||||
fputs(" port (\n", file);
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT)
|
||||
printconnector(file, c, mode, maxlength);
|
||||
}
|
||||
fputs("end component;\n\n", file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Signal declaration
|
||||
*/
|
||||
{
|
||||
char *bittype, *vecttype;
|
||||
bittype =(mode)? "std_logic" : "bit";
|
||||
vecttype=(mode)? "std_logic_vector" : "bit_vector";
|
||||
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
maxlength=0;
|
||||
if (p) {
|
||||
for (s=(velosig *)p->DATA; s; s=s->NEXT)
|
||||
if (maxlength<strlen(s->NAME))
|
||||
maxlength=strlen(s->NAME);
|
||||
for (s=(velosig *)p->DATA; s; s=s->NEXT)
|
||||
if (s->TYPE=='I' || s->TYPE=='S' || s->TYPE=='R') {
|
||||
int i, length=strlen(s->NAME);
|
||||
char *buf=(char *)mbkalloc((maxlength+1)*sizeof(char));
|
||||
strcpy(buf, s->NAME);
|
||||
for (i=length; i<maxlength; i++)
|
||||
buf[i]=' ';
|
||||
buf[maxlength]='\0';
|
||||
if (s->LEFT==-1)
|
||||
fprintf(file, "signal %s : %s;\n", buf, bittype);
|
||||
else
|
||||
fprintf(file, "signal %s : %s( %ld %s %ld);\n",
|
||||
buf, vecttype,
|
||||
s->LEFT, getvectordirection(s), s->RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fputs("\nbegin\n\n", file);
|
||||
|
||||
/*
|
||||
* Signals concatenation
|
||||
*/
|
||||
if (mode&1 && p)
|
||||
for (s=(velosig *)p->DATA; s; s=s->NEXT)
|
||||
if (s->TYPE=='S') {
|
||||
fprintf(file, " %s <= (", s->NAME);
|
||||
for (m=s->VSIG; m; m=m->NEXT) {
|
||||
ss=(velosig *)m->DATA;
|
||||
fputs(ss->NAME, file);
|
||||
if (ss->TYPE=='V' || ss->TYPE=='M')
|
||||
if (ss->LEFT==ss->RIGHT)
|
||||
fprintf(file, "(%ld)", ss->LEFT);
|
||||
else
|
||||
fprintf(file, "(%ld %s %ld)",
|
||||
ss->LEFT, getvectordirection(ss), ss->RIGHT);
|
||||
if (m->NEXT)
|
||||
fputs("& ",file);
|
||||
}
|
||||
fputs(");\n", file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Components instanciation
|
||||
*/
|
||||
f->LOINS=(loins_list *)reverse((chain_list *)f->LOINS);
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
fprintf(file, "%s : %s\n", mkvhdlname(i->INSNAME), i->FIGNAME);
|
||||
/*
|
||||
* Generic Map
|
||||
*/
|
||||
{
|
||||
logen_list *g;
|
||||
ptype_list *p;
|
||||
|
||||
p=getptype(i->USER,LOGEN);
|
||||
if (p) {
|
||||
fputs(" Generic Map (\n",file);
|
||||
for (g=p->DATA, maxlength=0; g; g=g->NEXT)
|
||||
if (maxlength<strlen(g->NAME))
|
||||
maxlength=strlen(g->NAME);
|
||||
|
||||
buf=(char *)mbkalloc((maxlength+1)*sizeof(char));
|
||||
for (g=p->DATA;g;g=g->NEXT) {
|
||||
length=strlen(g->NAME);
|
||||
strcpy(buf, g->NAME);
|
||||
for (j=length; j<maxlength; j++)
|
||||
buf[j]=' ';
|
||||
buf[maxlength]='\0';
|
||||
|
||||
strlength+=fprintf(file," %s => ",buf);
|
||||
first=1;
|
||||
dim=0;
|
||||
drv_genvalue(file, g);
|
||||
if (g->NEXT) {
|
||||
fputs(",\n",file);
|
||||
strlength=0;
|
||||
}
|
||||
}
|
||||
fputs("\n )\n",file);
|
||||
strlength=0;
|
||||
mbkfree(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Port Map
|
||||
*/
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
if (p->DATA) {
|
||||
fputs(" port map (\n", file);
|
||||
if (!(mode&2)) {
|
||||
maxlength=0;
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT) {
|
||||
if (maxlength<strlen(c->NAME))
|
||||
maxlength=strlen(c->NAME);
|
||||
}
|
||||
buf=(char *)mbkalloc((maxlength+1)*sizeof(char));
|
||||
}
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT) {
|
||||
if (mode&2) {
|
||||
m=c->VSIG;
|
||||
if (m->NEXT) {
|
||||
long b, inc;
|
||||
inc=(c->LEFT>c->RIGHT)? -1 : 1;
|
||||
for (b=c->LEFT; m; m=m->NEXT, b+=inc) {
|
||||
s=(velosig *)m->DATA;
|
||||
if (s->LEFT==s->RIGHT) {
|
||||
fprintf(file, " %s(%ld) => ", c->NAME, b);
|
||||
fputs(s->NAME, file);
|
||||
if (s->LEFT!=-1)
|
||||
fprintf(file, "(%ld)", s->LEFT);
|
||||
} else {
|
||||
fprintf(file, " %s(%ld %s %ld) => ", c->NAME,
|
||||
b, getvectordirection(c), b+s->RIGHT-s->LEFT);
|
||||
fputs(s->NAME, file);
|
||||
fprintf(file, "(%ld %s %ld)",
|
||||
s->LEFT, getvectordirection(s), s->RIGHT);
|
||||
b+=s->RIGHT-s->LEFT;
|
||||
}
|
||||
if (m->NEXT)
|
||||
fputs(",\n",file);
|
||||
}
|
||||
} else {
|
||||
fprintf(file," %s => ", c->NAME);
|
||||
s=(velosig *)m->DATA;
|
||||
fputs(s->NAME, file);
|
||||
if (s->TYPE=='V' || s->TYPE=='M') {
|
||||
if (s->LEFT==s->RIGHT)
|
||||
fprintf(file, "(%ld)", s->LEFT);
|
||||
else
|
||||
fprintf(file, "(%ld %s %ld)",
|
||||
s->LEFT, getvectordirection(s), s->RIGHT);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
length=strlen(c->NAME);
|
||||
strcpy(buf, c->NAME);
|
||||
for (j=length; j<maxlength; j++)
|
||||
buf[j]=' ';
|
||||
buf[maxlength]='\0';
|
||||
|
||||
fprintf(file," %s => ", buf);
|
||||
for (m=c->VSIG; m; m=m->NEXT) {
|
||||
s=(velosig *)m->DATA;
|
||||
fputs(s->NAME, file);
|
||||
if (s->TYPE=='V' || s->TYPE=='M') {
|
||||
if (s->LEFT==s->RIGHT)
|
||||
fprintf(file, "(%ld)", s->LEFT);
|
||||
else
|
||||
fprintf(file, "(%ld %s %ld)",
|
||||
s->LEFT, getvectordirection(s), s->RIGHT);
|
||||
}
|
||||
if (m->NEXT)
|
||||
fputc('&', file);
|
||||
}
|
||||
}
|
||||
if (c->NEXT)
|
||||
fputs(",\n", file);
|
||||
}
|
||||
fputs("\n )", file);
|
||||
if (!(mode&2))
|
||||
mbkfree(buf);
|
||||
}
|
||||
fputs(";\n\n", file);
|
||||
}
|
||||
fputs("\nend structural;\n", file);
|
||||
|
||||
if (mode&4) {
|
||||
fprintf(file, "configuration cfg_%s of %s is\n", f->NAME, f->NAME);
|
||||
fputs("for structural\n", file);
|
||||
for (i=f->LOINS; i; i=i->NEXT)
|
||||
fprintf(file, "for %s:%s use entity work.%s(%s); end for;\n",
|
||||
i->INSNAME, i->FIGNAME, i->FIGNAME,
|
||||
incatalog(i->FIGNAME)?"behavioural":"structural");
|
||||
fputs("end for;\n",file);
|
||||
fprintf(file, "end cfg_%s;\n",f->NAME);
|
||||
}
|
||||
|
||||
f->LOINS=(loins_list *)reverse((chain_list *)f->LOINS);
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void vhdlsavelofig(lofig_list *f)
|
||||
{
|
||||
vhdlsavevelofig(f, 0);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function makevelofig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void makevelofig(lofig_list *f)
|
||||
{
|
||||
ptype_list *p;
|
||||
loins_list *i;
|
||||
|
||||
buildvelo(f);
|
||||
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
vectorize_velosig(f);
|
||||
|
||||
p=getptype(f->USER, VEL_CON);
|
||||
vectorize_velocon(f, p);
|
||||
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
vectorize_velocon(f, p);
|
||||
}
|
||||
|
||||
chkdir(f);
|
||||
|
||||
if (getenv("VEL_DEBUG")) {
|
||||
debugvelocon(f);
|
||||
debugvelosig(f);
|
||||
debugveloins(f);
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function vhdlsavevelofig # */
|
||||
/* # mode = 0 : it drives an alliance vhdl netlist (vst) # */
|
||||
/* # mode = 1 : it drives a vhdl netlist (vhd) # */
|
||||
/* # mode = 2 : it drives a vhdl netlist (vhd) adding signals # */
|
||||
/* # to concatenate # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
int vhdlsavevelofig(lofig_list *f, int mode)
|
||||
{
|
||||
ptype_list *p;
|
||||
loins_list *i;
|
||||
velocon *c;
|
||||
velosig *s;
|
||||
chain_list *ch;
|
||||
long index, signalSize;
|
||||
|
||||
makevelofig(f);
|
||||
|
||||
p=getptype(f->USER, VEL_CON);
|
||||
for (c=(velocon *)p->DATA;c;c=c->NEXT) {
|
||||
c->NAME=mkvhdlname(c->NAME);
|
||||
if (c->LEFT!=-1) {
|
||||
if (c->LEFT>=c->RIGHT) {
|
||||
index=c->LEFT;
|
||||
for (ch=c->VSIG; ch; ch=ch->NEXT) {
|
||||
s=(velosig *)ch->DATA;
|
||||
signalSize=s->LEFT-s->RIGHT+1;
|
||||
s->NAME=c->NAME;
|
||||
s->LEFT=index;
|
||||
s->RIGHT=index-signalSize+1;
|
||||
s->TYPE='V';
|
||||
index-=signalSize;
|
||||
}
|
||||
} else {
|
||||
index=c->LEFT;
|
||||
for (ch=c->VSIG; ch; ch=ch->NEXT) {
|
||||
s=(velosig *)ch->DATA;
|
||||
signalSize=s->RIGHT-s->LEFT+1;
|
||||
s->NAME=c->NAME;
|
||||
s->LEFT=index;
|
||||
s->RIGHT=index+signalSize-1;
|
||||
s->TYPE='V';
|
||||
index+=signalSize;
|
||||
}
|
||||
}
|
||||
} else
|
||||
for (ch=c->VSIG; ch; ch=ch->NEXT) {
|
||||
s=(velosig *)ch->DATA;
|
||||
s->NAME=c->NAME;
|
||||
s->LEFT=-1;
|
||||
s->RIGHT=-1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
for (c=((velocon *)p->DATA);c;c=c->NEXT)
|
||||
c->NAME=mkvhdlname(c->NAME);
|
||||
}
|
||||
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
for (s=((velosig *)p->DATA);s;s=s->NEXT)
|
||||
if (s->TYPE=='I' || s->TYPE=='S')
|
||||
s->NAME=mkvhdlname(s->NAME);
|
||||
|
||||
p=getptype(f->USER, VEL_CON);
|
||||
for (c=((velocon *)p->DATA);c;c=c->NEXT)
|
||||
c->NAME=mkvhdlname(c->NAME);
|
||||
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
for (c=((velocon *)p->DATA);c;c=c->NEXT)
|
||||
c->NAME=mkvhdlname(c->NAME);
|
||||
}
|
||||
|
||||
|
||||
if (getenv("VEL_DEBUG")) {
|
||||
debugvelocon(f);
|
||||
debugvelosig(f);
|
||||
debugveloins(f);
|
||||
}
|
||||
|
||||
if (mode==1) {
|
||||
addsignals(f);
|
||||
}
|
||||
vhdsavevelofig(f, mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Debug function # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void debugvelocon (lofig_list *f)
|
||||
{
|
||||
ptype_list *p;
|
||||
|
||||
puts(" External connectors:");
|
||||
p=getptype(f->USER, VEL_CON);
|
||||
printveloconlist(p->DATA);
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
void debugvelosig(lofig_list *f)
|
||||
{
|
||||
ptype_list *p;
|
||||
|
||||
puts(" Signals:");
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
printvelosiglist(p->DATA);
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
void debugveloins(lofig_list *f)
|
||||
{
|
||||
loins_list *i;
|
||||
ptype_list *p;
|
||||
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
printf(" Instance %s:%s\n", i->INSNAME, i->FIGNAME);
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
printveloconlist(p->DATA);
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
/* ###--------------------------------------------------------------------### */
|
||||
/* # # */
|
||||
/* # file : velo.c # */
|
||||
/* | date : Jun 03 1997 | */
|
||||
/* | version : 1.00 | */
|
||||
/* | author : Denis Hommais | */
|
||||
/* | | */
|
||||
/* # contents : basical functions to used VEL structures # */
|
||||
/* # # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/*
|
||||
* $Log: vel_o.c,v $
|
||||
* Revision 1.1 2002/04/26 09:51:07 ludo
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1.1.1 2002/04/11 08:54:53 fred
|
||||
* Importing mbkvhdlg into the new Alliance CVS tree
|
||||
*
|
||||
* Revision 1.1.1.1 2002/02/28 12:58:31 disydent
|
||||
* Creation of Disydent CVS Tree
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/19 16:55:27 pwet
|
||||
* Changing the CVS tree structure of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/24 13:31:42 pwet
|
||||
* cvs tree of part of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/19 14:32:19 pwet
|
||||
* New cvs tree
|
||||
*
|
||||
* Revision 1.1 1997/12/10 16:40:22 denys
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 1997/09/23 09:43:48 denys
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.2 1997/09/23 09:43:48 denys
|
||||
* *** empty log message ***
|
||||
*
|
||||
*/
|
||||
|
||||
#ident "$Id: vel_o.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include <mlu.h>
|
||||
#include "vel_velo.h"
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function addvelosig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
velosig *addvelosig (ptype_list *tsig, char *name,
|
||||
long left, long right, char type)
|
||||
{
|
||||
velosig *s;
|
||||
|
||||
name = namealloc(name);
|
||||
s = (velosig *)mbkalloc(sizeof(velosig));
|
||||
s->NEXT=(velosig *)tsig->DATA;
|
||||
s->NAME=name;
|
||||
s->LEFT=left;
|
||||
s->RIGHT=right;
|
||||
s->VSIG=NULL;
|
||||
s->NAMECHAIN=NULL;
|
||||
s->USER=NULL;
|
||||
s->TYPE=type;
|
||||
s->SUPER=NULL;
|
||||
tsig->DATA=s;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function addvelocon # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
velocon *addvelocon (ptype_list *tcon, char *name, long left, long right)
|
||||
{
|
||||
velocon *c;
|
||||
|
||||
name = namealloc(name);
|
||||
c=(velocon *)mbkalloc(sizeof(velocon));
|
||||
c->NEXT=(velocon *)tcon->DATA;
|
||||
c->NAME=name;
|
||||
c->LEFT=left;
|
||||
c->RIGHT=right;
|
||||
c->VSIG=NULL;
|
||||
c->ROOT=NULL;
|
||||
c->USER=NULL;
|
||||
tcon->DATA=c;
|
||||
return c;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function dupvelosig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
velosig *dupvelosig(ptype_list *p, velosig *s)
|
||||
{
|
||||
velosig *d;
|
||||
|
||||
d=(velosig *)mbkalloc(sizeof(velosig));
|
||||
memcpy(d,s,sizeof(velosig));
|
||||
d->NEXT=(velosig *)p->DATA;
|
||||
p->DATA=d;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function getvelosig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
velosig *getvelosig(ptype_list *p, char *name, long left, long right)
|
||||
{
|
||||
velosig *s;
|
||||
|
||||
for (s=(velosig *)p->DATA; s; s=s->NEXT) {
|
||||
if (s->NAME == name && ( s->LEFT == left && s->RIGHT == right))
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function delvelocon # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
int delvelocon(ptype_list *p, velocon *d)
|
||||
{
|
||||
velocon *c, *s;
|
||||
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT) {
|
||||
if (c==d)
|
||||
break;
|
||||
s=c;
|
||||
}
|
||||
if (!c)
|
||||
return 0;
|
||||
if (c==p->DATA)
|
||||
p->DATA=c->NEXT;
|
||||
else
|
||||
s->NEXT=c->NEXT;
|
||||
mbkfree(c);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function delvelosig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
int delvelosig(ptype_list *p, velosig *d)
|
||||
{
|
||||
velosig *c, *s;
|
||||
|
||||
for (c=(velosig *)p->DATA; c; c=c->NEXT) {
|
||||
if (c==d)
|
||||
break;
|
||||
s=c;
|
||||
}
|
||||
if (!c)
|
||||
return 0;
|
||||
if (c==p->DATA)
|
||||
p->DATA=c->NEXT;
|
||||
else
|
||||
s->NEXT=c->NEXT;
|
||||
mbkfree(c);
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/* ###--------------------------------------------------------------------### */
|
||||
/* # # */
|
||||
/* # file : vel_sort.c # */
|
||||
/* | date : Jun 03 1997 | */
|
||||
/* | version : 1.00 | */
|
||||
/* | author : Frederic Petrot, Denis Hommais | */
|
||||
/* | | */
|
||||
/* # contents : modified sortlosig function # */
|
||||
/* # # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/*
|
||||
* $Log: vel_sort.c,v $
|
||||
* Revision 1.1 2002/04/26 09:51:07 ludo
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 2002/04/16 07:24:51 fred
|
||||
* Adding modifications to handle limited generics in VHDL files.
|
||||
*
|
||||
* Revision 1.1.1.1 2002/04/11 08:54:53 fred
|
||||
* Importing mbkvhdlg into the new Alliance CVS tree
|
||||
*
|
||||
* Revision 1.1.1.1 2002/02/28 12:58:31 disydent
|
||||
* Creation of Disydent CVS Tree
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/19 16:55:27 pwet
|
||||
* Changing the CVS tree structure of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/24 13:31:42 pwet
|
||||
* cvs tree of part of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/19 14:32:19 pwet
|
||||
* New cvs tree
|
||||
*
|
||||
* Revision 1.1 1998/09/16 16:11:35 pwet
|
||||
* passage a cvs
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
|
||||
#ident "$Id: vel_sort.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
|
||||
static char buffer[BUFSIZ];
|
||||
static char str[BUFSIZ];
|
||||
|
||||
#if 0
|
||||
/*******************************************************************************
|
||||
* generic compaison function : *
|
||||
* unlike strcmp, ensure that 10 > 2 for vectorized strings. *
|
||||
* first, check strings, then check numerical values as numbers, not strings. *
|
||||
*******************************************************************************/
|
||||
static int naturalstrcmp(s, t)
|
||||
char *s, *t;
|
||||
{
|
||||
char *spt, *tpt , *st = s, *tt = t;
|
||||
int u, ls, lt;
|
||||
|
||||
spt = buffer, tpt = str;
|
||||
|
||||
while ((!isspace(*st)) && *st)
|
||||
*spt++ = *st++;
|
||||
*spt = '\0';
|
||||
|
||||
while ((!isspace(*tt)) && *tt)
|
||||
*tpt++ = *tt++;
|
||||
*tpt = '\0';
|
||||
|
||||
if ((u = strcmp(buffer, str)) != 0)
|
||||
return u;
|
||||
|
||||
if ((ls = strlen(s)) == (lt = strlen(t)))
|
||||
return strcmp(s, t);
|
||||
|
||||
return ls - lt;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
signalcmp(fls, sls)
|
||||
losig_list **fls, **sls;
|
||||
{
|
||||
return naturalstrcmp(getsigname(*fls), getsigname(*sls));
|
||||
}
|
||||
|
||||
void
|
||||
sortlosigv(signals)
|
||||
losig_list **signals;
|
||||
{
|
||||
long n, i;
|
||||
losig_list *lc, **tc;
|
||||
|
||||
if (!signals || !(*signals))
|
||||
return;
|
||||
|
||||
/* first :
|
||||
count signals. */
|
||||
for (n = 0, lc = *signals; lc; lc = lc->NEXT)
|
||||
n++;
|
||||
tc = (losig_list **)mbkalloc(n * sizeof(losig_list *));
|
||||
for (n = 0, lc = *signals; lc; lc = lc->NEXT)
|
||||
tc[n++] = lc;
|
||||
/* second :
|
||||
sort them. */
|
||||
qsort((void *)tc, n, sizeof(losig_list *), signalcmp);
|
||||
/* tables :
|
||||
the last element of the table is t[n - 1].
|
||||
relink the list in the sorted order. */
|
||||
n--;
|
||||
*signals = tc[0];
|
||||
for (i = 0; i < n; i++)
|
||||
tc[i]->NEXT = tc[i + 1];
|
||||
tc[n]->NEXT = (losig_list *)NULL;
|
||||
mbkfree((void *)tc);
|
||||
}
|
|
@ -0,0 +1,539 @@
|
|||
/* ###--------------------------------------------------------------------### */
|
||||
/* # # */
|
||||
/* # file : vel_util.c # */
|
||||
/* | date : Jun 03 1997 | */
|
||||
/* | version : 1.00 | */
|
||||
/* | author : Denis Hommais | */
|
||||
/* | | */
|
||||
/* # contents : netlist vectorization function using VEL structures # */
|
||||
/* # # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/*
|
||||
* $Log: vel_util.c,v $
|
||||
* Revision 1.1 2002/04/26 09:51:07 ludo
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1.1.1 2002/04/11 08:54:53 fred
|
||||
* Importing mbkvhdlg into the new Alliance CVS tree
|
||||
*
|
||||
* Revision 1.1.1.1 2002/02/28 12:58:31 disydent
|
||||
* Creation of Disydent CVS Tree
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/19 16:55:27 pwet
|
||||
* Changing the CVS tree structure of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/24 13:31:42 pwet
|
||||
* cvs tree of part of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/19 14:32:20 pwet
|
||||
* New cvs tree
|
||||
*
|
||||
* Revision 1.7 1998/11/12 10:39:26 pwet
|
||||
* add makevelofig function.
|
||||
*
|
||||
* Revision 1.6 1998/01/06 09:54:27 denis
|
||||
* change strdup to namealloc in mkvhdlname
|
||||
*
|
||||
* Revision 1.5 1997/12/17 16:41:33 denys
|
||||
* add chkdir to check signal direction
|
||||
*
|
||||
* Revision 1.4 1997/12/10 10:43:05 denys
|
||||
* Don't know
|
||||
*
|
||||
* Revision 1.3 1997/09/24 09:46:48 denys
|
||||
* rename the signal when it is connected to a external connector by the
|
||||
* name of the connector
|
||||
*
|
||||
* Revision 1.2 1997/09/23 09:42:46 denys
|
||||
* add reverse in mkvector
|
||||
* change mkvector to verify the vector
|
||||
*
|
||||
*/
|
||||
#ident "$Id: vel_util.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include <mlu.h>
|
||||
#include "vel_velo.h"
|
||||
|
||||
static int signalindex;
|
||||
static char buf[BUFSIZ];
|
||||
|
||||
static void printvelosig(velosig *, char *);
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function buildvelo # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
void buildvelo(lofig_list *f)
|
||||
{
|
||||
losig_list *s;
|
||||
locon_list *c;
|
||||
loins_list *i;
|
||||
velosig *vs;
|
||||
velocon *vc;
|
||||
ptype_list *ps, *pc;
|
||||
char *name;
|
||||
long idx;
|
||||
|
||||
ps=f->USER=addptype(f->USER, VEL_SIG, NULL);
|
||||
for (s=f->LOSIG;s;s=s->NEXT) {
|
||||
name=getsigname(s);
|
||||
idx=vectorindex(name);
|
||||
vs=addvelosig(ps, vectorradical(name), idx, idx, s->TYPE);
|
||||
vs->NAMECHAIN=s->NAMECHAIN;
|
||||
s->USER=addptype(s->USER, VEL_SIG, vs);
|
||||
}
|
||||
pc=f->USER=addptype(f->USER, VEL_CON, NULL);
|
||||
for (c=f->LOCON;c;c=c->NEXT) {
|
||||
idx=vectorindex(c->NAME);
|
||||
vc=addvelocon(pc, vectorradical(c->NAME), idx, idx);
|
||||
vc->ROOT=addchain(NULL,c);
|
||||
ps=getptype(c->SIG->USER, VEL_SIG);
|
||||
vc->VSIG=addchain(NULL, ps->DATA);
|
||||
}
|
||||
for (i=f->LOINS;i;i=i->NEXT) {
|
||||
pc=i->USER=addptype(i->USER, VEL_CON, NULL);
|
||||
for (c=i->LOCON;c;c=c->NEXT) {
|
||||
idx=vectorindex(c->NAME);
|
||||
vc=addvelocon(pc, vectorradical(c->NAME), idx, idx);
|
||||
vc->ROOT=addchain(NULL,c);
|
||||
ps=getptype(c->SIG->USER, VEL_SIG);
|
||||
vc->VSIG=addchain(NULL, ps->DATA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function vectorize_velosig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void vectorize_velosig(lofig_list *f)
|
||||
{
|
||||
ptype_list *p;
|
||||
velosig *vs, *vv=NULL;
|
||||
chain_list *ch;
|
||||
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
for (vs=(velosig *)p->DATA;vs;vs=vs->NEXT) {
|
||||
if (vv && vv->NAME==vs->NAME && abs(vv->RIGHT-vs->RIGHT)==1 ) {
|
||||
vv->RIGHT=vs->RIGHT;
|
||||
vv->VSIG=addchain(vv->VSIG, vs);
|
||||
vs->TYPE='V';
|
||||
vs->SUPER=vv;
|
||||
} else {
|
||||
if (vv) {
|
||||
if (vs->NAME==vv->NAME) {
|
||||
/* the vector isn't a valid one */
|
||||
for (ch=vv->VSIG; ch; ch=ch->NEXT)
|
||||
((velosig *)ch->DATA)->TYPE=vv->TYPE;
|
||||
} else
|
||||
vv->VSIG=(chain_list *)reverse(vv->VSIG);
|
||||
vv=NULL;
|
||||
}
|
||||
if (vs->LEFT!=-1) {
|
||||
vv=dupvelosig(p, vs);
|
||||
vv->VSIG=addchain(vv->VSIG, vs);
|
||||
vs->TYPE='V';
|
||||
vs->SUPER=vv;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vv)
|
||||
vv->VSIG=(chain_list *)reverse(vv->VSIG);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void vectorize_velosig(lofig_list *f)
|
||||
{
|
||||
ptype_list *p;
|
||||
velosig *vs, vv, *vm;
|
||||
chain_list *ch;
|
||||
|
||||
vv.NAME=NULL;
|
||||
p=getptype(f->USER, VEL_SIG);
|
||||
for (vs=(velosig *)p->DATA;vs;vs=vs->NEXT) {
|
||||
if (vv.NAME && vv.NAME==vs->NAME) {
|
||||
vv.RIGHT=vs->RIGHT;
|
||||
vv.VSIG=addchain(vv.VSIG, vs);
|
||||
vs->TYPE='V';
|
||||
} else {
|
||||
if (vv.NAME) {
|
||||
for(ch=getvelosigbyname(p,vv.NAME); ch; ch=ch->NEXT) {
|
||||
vm=(velosig *)ch->DATA;
|
||||
if ((vm->RIGHT==vv.RIGHT && vm->LEFT == vv.LEFT)
|
||||
|| (vm->RIGHT==vv.LEFT && vm->LEFT == vv.RIGHT)) {
|
||||
vm->TYPE=vv.TYPE;
|
||||
vm->VSIG=(chain_list *)reverse(vv.VSIG);
|
||||
}
|
||||
}
|
||||
vv.VSIG=(chain_list *)reverse(vv.VSIG);
|
||||
vv.NAME=NULL;
|
||||
}
|
||||
if (vs->LEFT!=-1) {
|
||||
memcpy(&vv,vs,sizeof(velosig));
|
||||
vv.VSIG=addchain(vv.VSIG, vs);
|
||||
vs->TYPE='V';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vv.NAME)
|
||||
vv.VSIG=(chain_list *)reverse(vv.VSIG);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function mkvector # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static chain_list *mkvector(lofig_list *f, chain_list *c)
|
||||
{
|
||||
velosig *s, *e;
|
||||
char *name=NULL;
|
||||
long left, right;
|
||||
char type;
|
||||
chain_list *r=NULL, *sigchain;
|
||||
ptype_list *ps;
|
||||
|
||||
ps=getptype(f->USER, VEL_SIG);
|
||||
while(c) {
|
||||
s=(velosig *)c->DATA;
|
||||
if (name && s->NAME == name && abs(s->RIGHT-right)==1 ) {
|
||||
right=s->RIGHT;
|
||||
sigchain=addchain(sigchain, s);
|
||||
} else {
|
||||
if (name) {
|
||||
if (!(e=getvelosig(ps, name, left, right))) {
|
||||
e=addvelosig(ps, name, left, right, 'M');
|
||||
e->VSIG=reverse(sigchain);
|
||||
e->SUPER=getvelosigbyname(ps, name);
|
||||
}
|
||||
r=addchain(r,e);
|
||||
}
|
||||
name=s->NAME;
|
||||
left=s->LEFT;
|
||||
right=s->RIGHT;
|
||||
type=s->TYPE;
|
||||
sigchain=addchain(NULL, s);
|
||||
}
|
||||
c=c->NEXT;
|
||||
}
|
||||
if (!(e=getvelosig(ps, name, left, right))) {
|
||||
e=addvelosig(ps, name, left, right, 'M');
|
||||
e->VSIG=reverse(sigchain);
|
||||
e->SUPER=getvelosigbyname(ps, name);
|
||||
}
|
||||
r=addchain(r,e);
|
||||
|
||||
return reverse(r);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function vectorize_velocon # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void vectorize_velocon(lofig_list *f, ptype_list *p)
|
||||
{
|
||||
velocon *vc, *vv=NULL;
|
||||
|
||||
for (vc=(velocon *)p->DATA;vc;) {
|
||||
if (vv && vv->NAME==vc->NAME) {
|
||||
vv->RIGHT=vc->RIGHT;
|
||||
vc->VSIG->NEXT=vv->VSIG;
|
||||
vv->VSIG=vc->VSIG;
|
||||
delvelocon(p, vc);
|
||||
vc=vv->NEXT;
|
||||
} else {
|
||||
if (vv) {
|
||||
vv->VSIG=(chain_list *)reverse(vv->VSIG);
|
||||
vv->VSIG=mkvector(f, vv->VSIG);
|
||||
vv=NULL;
|
||||
}
|
||||
if (vc->LEFT!=-1) {
|
||||
vv=vc;
|
||||
}
|
||||
vc=vc->NEXT;
|
||||
}
|
||||
}
|
||||
if (vv) {
|
||||
vv->VSIG=(chain_list *)reverse(vv->VSIG);
|
||||
vv->VSIG=mkvector(f, vv->VSIG);
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function sigcmp # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static velosig *sigcmp(ptype_list *p, chain_list *c)
|
||||
{
|
||||
velosig *s;
|
||||
chain_list *ms, *mc;
|
||||
|
||||
for(s=(velosig *)p->DATA; s; s=s->NEXT)
|
||||
if (s->TYPE=='S') {
|
||||
for (ms=s->VSIG, mc=c; ms&&mc; ms=ms->NEXT, mc=mc->NEXT)
|
||||
if (ms->DATA != mc->DATA) break;
|
||||
if (!ms && !mc)
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function addsignals # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void addsignals(lofig_list *f)
|
||||
{
|
||||
velocon *c;
|
||||
velosig *s;
|
||||
loins_list *i;
|
||||
ptype_list *p, *ps;
|
||||
|
||||
ps=getptype(f->USER, VEL_SIG);
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
p=getptype(i->USER, VEL_CON);
|
||||
for (c=(velocon *)p->DATA; c; c=c->NEXT) {
|
||||
if (c->VSIG->NEXT!=NULL) {
|
||||
if (!(s=sigcmp(ps,c->VSIG))) {
|
||||
sprintf(buf, "velo%d%s", signalindex++, c->NAME);
|
||||
s=addvelosig(ps, buf, c->LEFT, c->RIGHT, 'S');
|
||||
s->VSIG=c->VSIG;
|
||||
}
|
||||
c->VSIG=addchain(NULL, s);
|
||||
c->VSIG=reverse(c->VSIG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function getvelosigbyname # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
velosig *getvelosigbyname(ptype_list *p, char *name)
|
||||
{
|
||||
velosig *vs;
|
||||
|
||||
for (vs=(velosig *)p->DATA; vs; vs=vs->NEXT)
|
||||
if (vs->NAME==name && (vs->TYPE=='E' || vs->TYPE=='I' || vs->TYPE=='R'))
|
||||
return vs;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function getdir # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static int getdir (velosig *vs)
|
||||
{
|
||||
long dir;
|
||||
|
||||
dir=vs->RIGHT-vs->LEFT;
|
||||
|
||||
if (dir!=0)
|
||||
if (dir<0)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function chkdir # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void chkdir (lofig_list *f)
|
||||
{
|
||||
loins_list *ins;
|
||||
ptype_list *ps;
|
||||
ptype_list *pc;
|
||||
velocon *c;
|
||||
chain_list *ch, **prevch;
|
||||
velosig *vs, *vr;
|
||||
int vsdir,vrdir,i;
|
||||
|
||||
ps=getptype(f->USER, VEL_SIG);
|
||||
pc=getptype(f->USER, VEL_CON);
|
||||
for (c=(velocon *)pc->DATA; c; c=c->NEXT) {
|
||||
prevch=&(c->VSIG);
|
||||
for (ch=c->VSIG; ch; prevch=&(ch->NEXT), ch=ch->NEXT) {
|
||||
vs=(velosig *)ch->DATA;
|
||||
if (vs->TYPE=='M' && (vr=getvelosigbyname(ps, vs->NAME))) {
|
||||
vsdir=getdir(vs);
|
||||
vrdir=getdir(vr);
|
||||
if (vsdir && vrdir && vsdir!=vrdir)
|
||||
if (vr->LEFT==vs->RIGHT && vs->LEFT==vr->RIGHT) {
|
||||
vs->TYPE=vr->TYPE;
|
||||
vr->TYPE='V';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ins=f->LOINS; ins; ins=ins->NEXT) {
|
||||
pc=getptype(ins->USER, VEL_CON);
|
||||
for (c=(velocon *)pc->DATA; c; c=c->NEXT) {
|
||||
prevch=&(c->VSIG);
|
||||
for (ch=c->VSIG; ch; prevch=&(ch->NEXT), ch=ch->NEXT) {
|
||||
vs=(velosig *)ch->DATA;
|
||||
if (vs->TYPE=='M' && (vr=getvelosigbyname(ps, vs->NAME))) {
|
||||
vsdir=getdir(vs);
|
||||
vrdir=getdir(vr);
|
||||
if (vsdir && vrdir && vsdir!=vrdir)
|
||||
if (vr->TYPE=='I') {
|
||||
if (vr->LEFT==vs->RIGHT && vs->LEFT==vr->RIGHT) {
|
||||
vs->TYPE='R';
|
||||
vs->VSIG=vr->VSIG;
|
||||
} else {
|
||||
addvelosig(ps, vr->NAME, vr->RIGHT, vr->LEFT, 'R');
|
||||
}
|
||||
vr->TYPE='V';
|
||||
} else {
|
||||
printvelosig(vs,">>>");
|
||||
ch->DATA=getvelosig(ps, vs->NAME, vs->RIGHT, vs->RIGHT);
|
||||
printvelosig(ch->DATA,">>>");
|
||||
if (vsdir<0)
|
||||
for (i=vs->RIGHT+1; i<=vs->LEFT; i=i+1)
|
||||
*prevch=addchain(*prevch,
|
||||
getvelosig(ps, vs->NAME,i,i));
|
||||
else
|
||||
for (i=vs->RIGHT-1; i>=vs->LEFT; i=i-1)
|
||||
*prevch=addchain(*prevch,
|
||||
getvelosig(ps, vs->NAME,i,i));
|
||||
}
|
||||
else
|
||||
if (vsdir && vr->TYPE=='I')
|
||||
vr->TYPE='R';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function addoffset # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static char *addoffset(char *offset, char *add)
|
||||
{
|
||||
char *no;
|
||||
|
||||
no=(char *)mbkalloc(sizeof(char)*(strlen(offset)+strlen(add)+1));
|
||||
strcpy(no,offset);
|
||||
strcat(no,add);
|
||||
|
||||
return no;
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function mkvhdlname # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
char *mkvhdlname(char *name)
|
||||
{
|
||||
char *n, *c;
|
||||
int f=0;
|
||||
|
||||
|
||||
c=buf;
|
||||
if (!isalpha(*name)) {
|
||||
sprintf(c,"v_", signalindex++);
|
||||
c+=2;
|
||||
f=1;
|
||||
}
|
||||
|
||||
for (n=name; *n; n++)
|
||||
if (!isalnum(*n)) {
|
||||
if (*n!='_') {
|
||||
if (c!=buf && *(c-1)=='_')
|
||||
*c++='x';
|
||||
*c++='_';
|
||||
f=1;
|
||||
} else {
|
||||
if (c!=buf && *(c-1)=='_') {
|
||||
*c++='x';
|
||||
f=1;
|
||||
} else
|
||||
*c++=*n;
|
||||
}
|
||||
} else
|
||||
*c++=*n;
|
||||
|
||||
|
||||
if (f) {
|
||||
*c='\0';
|
||||
while (namefind(buf))
|
||||
sprintf(buf, "d%s", buf);
|
||||
return namealloc(buf);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function printvelosig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static void printvelosig(velosig *s, char *offset)
|
||||
{
|
||||
chain_list *c;
|
||||
char *no;
|
||||
|
||||
printf("%s +-%s[%ld:%ld] %c\n", offset, s->NAME, s->LEFT, s->RIGHT, s->TYPE);
|
||||
/* printf("%s +-%s[%8x][%ld:%ld] %c\n", offset, s->NAME, s, s->LEFT, s->RIGHT, s->TYPE);
|
||||
*/
|
||||
no=addoffset(offset, " |");
|
||||
for (c=s->VSIG;c;c=c->NEXT)
|
||||
printvelosig(c->DATA, no);
|
||||
mbkfree(no);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function printvelosiglist # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void printvelosiglist(velosig *s)
|
||||
{
|
||||
while (s) {
|
||||
printvelosig(s," ");
|
||||
s=s->NEXT;
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function printvelocon # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static void printvelocon(velocon *s, char *offset)
|
||||
{
|
||||
chain_list *c;
|
||||
char *no;
|
||||
|
||||
printf("%s *-%s[%ld:%ld]\n", offset, s->NAME, s->LEFT, s->RIGHT);
|
||||
/* printf("%s *-%s[%8x][%ld:%ld]\n", offset, s->NAME, s, s->LEFT, s->RIGHT);
|
||||
*/
|
||||
no=addoffset(offset, " |");
|
||||
for (c=s->VSIG;c;c=c->NEXT)
|
||||
printvelosig(c->DATA, no);
|
||||
mbkfree(no);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function printveloconlist # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void printveloconlist(velocon *c)
|
||||
{
|
||||
while (c) {
|
||||
printvelocon(c," ");
|
||||
c=c->NEXT;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
/* ###--------------------------------------------------------------------### */
|
||||
/* # # */
|
||||
/* # file : vel_vect.c # */
|
||||
/* | date : Jun 03 1997 | */
|
||||
/* | version : 1.00 | */
|
||||
/* | author : Denis Hommais | */
|
||||
/* | | */
|
||||
/* # contents : losig vectorization functions # */
|
||||
/* # # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/*
|
||||
* $Log: vel_vect.c,v $
|
||||
* Revision 1.1 2002/04/26 09:51:07 ludo
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1.1.1 2002/04/11 08:54:53 fred
|
||||
* Importing mbkvhdlg into the new Alliance CVS tree
|
||||
*
|
||||
* Revision 1.1.1.1 2002/02/28 12:58:31 disydent
|
||||
* Creation of Disydent CVS Tree
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/19 16:55:27 pwet
|
||||
* Changing the CVS tree structure of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/24 13:31:42 pwet
|
||||
* cvs tree of part of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/19 14:32:20 pwet
|
||||
* New cvs tree
|
||||
*
|
||||
* Revision 1.5 1998/11/12 10:39:27 pwet
|
||||
* add makevelofig function.
|
||||
*
|
||||
* Revision 1.4 1998/01/06 09:54:50 denis
|
||||
* rewrite vectlosig function. The new function take care of
|
||||
* the good sequenciality of the vector.
|
||||
*
|
||||
* Revision 1.3 1997/12/17 16:41:33 denys
|
||||
* ..
|
||||
*
|
||||
* Revision 1.2 1997/09/23 09:43:38 denys
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.2 1997/09/23 09:43:38 denys
|
||||
* *** empty log message ***
|
||||
*
|
||||
*/
|
||||
|
||||
#ident "$Id: vel_vect.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include <mlu.h>
|
||||
|
||||
static char buffer[BUFSIZ];
|
||||
|
||||
#define Signame(sig) ((sig)->NAMECHAIN->DATA)
|
||||
#define Delvectorname(s) (s)->NAMECHAIN=delchain((s)->NAMECHAIN,(s)->NAMECHAIN)
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function addvectorname # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static void addvectorname(losig_list *s)
|
||||
{
|
||||
char *sn, *en, *name;
|
||||
while (s) {
|
||||
name=getsigname(s);
|
||||
if ((sn=strrchr(name, '_'))) {
|
||||
strtol(sn+1, &en, 10);
|
||||
if (*en=='\0') {
|
||||
strcpy(buffer, name);
|
||||
buffer[sn-name]=' ';
|
||||
name=namealloc(buffer);
|
||||
}
|
||||
}
|
||||
s->NAMECHAIN=addchain(s->NAMECHAIN, name);
|
||||
s=s->NEXT;
|
||||
}
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function delvectnames # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static void delvectnames(chain_list *ch)
|
||||
{
|
||||
losig_list *s;
|
||||
|
||||
while (ch) {
|
||||
s=(losig_list *)ch->DATA;
|
||||
s->NAMECHAIN=delchain(s->NAMECHAIN, s->NAMECHAIN);
|
||||
ch=ch->NEXT;
|
||||
}
|
||||
freechain(ch);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function vectorelm # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static char *vectorelm(char *name, long *idx)
|
||||
{
|
||||
char *sn;
|
||||
if ((sn=strchr(name, ' '))) {
|
||||
*idx=atoi(sn+1);
|
||||
strncpy(buffer, name, sn-name);
|
||||
buffer[sn-name]='\0';
|
||||
return namealloc(buffer);
|
||||
}
|
||||
*idx=-2;
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function chkvectors # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
static void chkvectors(losig_list *s)
|
||||
{
|
||||
chain_list *vchain=NULL;
|
||||
char *cur_name=NULL, *new_name;
|
||||
long cur_index, new_index;
|
||||
|
||||
while(s) {
|
||||
new_name=vectorelm(Signame(s), &new_index);
|
||||
if (s->TYPE=='E') {
|
||||
if (new_name==cur_name) /* the vector has the same name */
|
||||
delvectnames(vchain); /* than an external signal */
|
||||
else {
|
||||
if (vchain && vchain->NEXT)
|
||||
freechain(vchain);
|
||||
else
|
||||
delvectnames(vchain);
|
||||
cur_name=new_name;
|
||||
}
|
||||
Delvectorname(s);
|
||||
vchain=NULL;
|
||||
} else
|
||||
if (!vchain)
|
||||
if (new_name==cur_name)
|
||||
Delvectorname(s);
|
||||
else {
|
||||
cur_name=new_name;
|
||||
cur_index=new_index;
|
||||
vchain=addchain(NULL, s);
|
||||
}
|
||||
else {
|
||||
if (new_name==cur_name) {
|
||||
if (new_index-cur_index!=1) { /* the name are the same but */
|
||||
delvectnames(vchain); /* the index aren't consecutive */
|
||||
vchain=NULL;
|
||||
Delvectorname(s);
|
||||
} else { /* good vector element */
|
||||
cur_index=new_index;
|
||||
vchain=addchain(vchain, s);
|
||||
}
|
||||
} else { /* next vector name, if the */
|
||||
if (vchain && vchain->NEXT) /* previous is valid and the */
|
||||
freechain(vchain); /* vector have more than one */
|
||||
else /* element, a vector is found. */
|
||||
delvectnames(vchain);
|
||||
cur_name=new_name;
|
||||
cur_index=new_index;
|
||||
vchain=addchain(NULL, s);
|
||||
}
|
||||
}
|
||||
s=s->NEXT;
|
||||
}
|
||||
if (vchain && vchain->NEXT)
|
||||
freechain(vchain);
|
||||
else
|
||||
delvectnames(vchain);
|
||||
}
|
||||
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
/* # Function vectlosig # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
void vectlosig(losig_list **s)
|
||||
{
|
||||
addvectorname(*s);
|
||||
sortlosigv(s);
|
||||
chkvectors(*s);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/* ###--------------------------------------------------------------------### */
|
||||
/* # # */
|
||||
/* # file : velo.h # */
|
||||
/* | date : Jun 27 1997 | */
|
||||
/* | version : 0.00 | */
|
||||
/* | author : Denis Hommais | */
|
||||
/* | | */
|
||||
/* # contents : structure definitions used in VEL library # */
|
||||
/* # # */
|
||||
/* ###--------------------------------------------------------------------### */
|
||||
|
||||
#ifndef _VEL_H_
|
||||
#define _VEL_H_
|
||||
|
||||
#define VEL_SIG 296651 /* ptype identifier for velosig */
|
||||
#define VEL_CON 296217 /* ptype identifier for velocon */
|
||||
#define VEL_CHAIN 296121 /* ptype identifier for chain */
|
||||
|
||||
typedef struct Velosig {
|
||||
struct Velosig * NEXT;
|
||||
char * NAME;
|
||||
long LEFT;
|
||||
long RIGHT;
|
||||
char TYPE;
|
||||
struct chain * VSIG;
|
||||
struct Velosig * SUPER;
|
||||
struct chain * NAMECHAIN;
|
||||
struct ptype * USER;
|
||||
} velosig;
|
||||
|
||||
typedef struct Velocon {
|
||||
struct Velocon * NEXT;
|
||||
char * NAME;
|
||||
long LEFT;
|
||||
long RIGHT;
|
||||
struct chain * VSIG;
|
||||
struct chain * ROOT;
|
||||
struct ptype * USER;
|
||||
} velocon;
|
||||
|
||||
/* prototype of functions that come from velo.c */
|
||||
extern velosig *addvelosig (ptype_list *, char *, long, long, char);
|
||||
extern velocon *addvelocon (ptype_list *, char *, long, long);
|
||||
extern velosig *dupvelosig (ptype_list *, velosig *);
|
||||
extern velosig *getvelosig (ptype_list *, char *, long, long);
|
||||
extern int delvelocon (ptype_list *, velocon *);
|
||||
|
||||
/* prototype of functions that come from vel_util.c */
|
||||
extern void buildvelo (lofig_list *);
|
||||
extern void vectorize_velo (lofig_list *);
|
||||
extern char *mkvhdlname (char *);
|
||||
extern void printvelosiglist (velosig *);
|
||||
extern void printveloconlist (velocon *);
|
||||
extern void makevelofig(lofig_list *);
|
||||
extern velosig *getvelosigbyname(ptype_list *, char *);
|
||||
#endif
|
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* $Log: x2vy_main.c,v $
|
||||
* Revision 1.1 2002/04/26 09:51:07 ludo
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1.1.1 2002/04/11 08:54:53 fred
|
||||
* Importing mbkvhdlg into the new Alliance CVS tree
|
||||
*
|
||||
* Revision 1.1.1.1 2002/02/28 12:58:31 disydent
|
||||
* Creation of Disydent CVS Tree
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/19 16:55:27 pwet
|
||||
* Changing the CVS tree structure of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/24 13:31:41 pwet
|
||||
* cvs tree of part of disydent
|
||||
*
|
||||
* Revision 1.1.1.1 2001/07/19 14:32:19 pwet
|
||||
* New cvs tree
|
||||
*
|
||||
* Revision 1.5 1999/02/23 15:19:18 pwet
|
||||
* add -g option. This option is used to remove generic statements.
|
||||
*
|
||||
* Revision 1.4 1998/11/12 10:39:25 pwet
|
||||
* add makevelofig function.
|
||||
*
|
||||
* Revision 1.3 1998/01/06 09:52:58 denis
|
||||
* invert mode , so now 0 is vst and 1 is vhd
|
||||
*
|
||||
* Revision 1.2 1997/12/17 16:41:33 denys
|
||||
* remove the netlist.vst driven if the VEL_DEBUG flag was set.
|
||||
*
|
||||
* Revision 1.1 1997/10/16 14:22:05 denys
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
#ident "$Id: x2vy_main.c,v 1.1 2002/04/26 09:51:07 ludo Exp $"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mut.h>
|
||||
#include <mlo.h>
|
||||
#include <mlu.h>
|
||||
#include "gen_generic.h"
|
||||
#include "vel_velo.h"
|
||||
|
||||
#define NOALIM 0x01
|
||||
#define RENINS 0x02
|
||||
#define VECCON 0x04
|
||||
#define VSTDRV 0x08
|
||||
#define MBKDRV 0x10
|
||||
#define NOVECT 0x20
|
||||
#define ADDSIG 0x40
|
||||
#define NOLOGEN 0x80
|
||||
|
||||
static void printusage(void)
|
||||
{
|
||||
fputs("** Usage : x2vy [-nrvc] file [outputfile]\n", stderr);
|
||||
fputs("** -n : remove power connectors\n", stderr);
|
||||
fputs("** -g : remove generic statements\n", stderr);
|
||||
fputs("** -r : rename instance\n", stderr);
|
||||
fputs("** -c : vectorize connectors\n", stderr);
|
||||
fputs("** -v : alliance VHDL output (.vst)\n", stderr);
|
||||
fputs("** -m : use mbkdriver (don't vectorize signals)\n", stderr);
|
||||
fputs("** -u : don't vectorize signals\n", stderr);
|
||||
}
|
||||
|
||||
static void removepowers(lofig_list *f)
|
||||
{
|
||||
locon_list *c, *cc;
|
||||
loins_list *i;
|
||||
|
||||
cc=NULL;
|
||||
for (c=f->LOCON; c;) {
|
||||
if (isvdd(c->NAME) || isvss(c->NAME)) {
|
||||
if (cc) {
|
||||
cc->NEXT=c->NEXT;
|
||||
mbkfree(c);
|
||||
c=cc->NEXT;
|
||||
} else {
|
||||
f->LOCON=c->NEXT;
|
||||
mbkfree(c);
|
||||
c=f->LOCON;
|
||||
}
|
||||
} else {
|
||||
cc=c;
|
||||
c=c->NEXT;
|
||||
}
|
||||
}
|
||||
for (i=f->LOINS; i; i=i->NEXT) {
|
||||
cc=NULL;
|
||||
for (c=i->LOCON; c;) {
|
||||
if (isvdd(c->NAME) || isvss(c->NAME)) {
|
||||
if (cc) {
|
||||
cc->NEXT=c->NEXT;
|
||||
mbkfree(c);
|
||||
c=cc->NEXT;
|
||||
} else {
|
||||
i->LOCON=c->NEXT;
|
||||
mbkfree(c);
|
||||
c=i->LOCON;
|
||||
}
|
||||
} else {
|
||||
cc=c;
|
||||
c=c->NEXT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void removelogen(lofig_list *f)
|
||||
{
|
||||
loins_list *i;
|
||||
|
||||
if (f->USER)
|
||||
delptype(f->USER, LOGEN); /* I know, it's dirty */
|
||||
|
||||
for (i=f->LOINS; i; i=i->NEXT)
|
||||
if (i->USER)
|
||||
delptype(i->USER, LOGEN); /* still dirty */
|
||||
|
||||
}
|
||||
|
||||
static void renameinstance(lofig_list *f)
|
||||
{
|
||||
loins_list *i;
|
||||
char tab[512];
|
||||
|
||||
for (i=f->LOINS;i;i=i->NEXT) {
|
||||
strcpy(tab, "v_");
|
||||
strcat(tab, i->INSNAME);
|
||||
i->INSNAME=namealloc(tab);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
lofig_list *f;
|
||||
char *filein=NULL, *fileout=NULL;
|
||||
int i,j;
|
||||
int opt=0;
|
||||
|
||||
if (argc<2) {
|
||||
printusage();
|
||||
exit(1);
|
||||
}
|
||||
mbkenv();
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
if (argv[i][0]=='-')
|
||||
for (j=1; argv[i][j]!='\0'; j++) {
|
||||
switch (argv[i][j]) {
|
||||
case 'a':
|
||||
opt|=ADDSIG;
|
||||
break;
|
||||
case 'n':
|
||||
opt|=NOALIM;
|
||||
break;
|
||||
case 'g':
|
||||
opt|=NOLOGEN;
|
||||
break;
|
||||
case 'r':
|
||||
opt|=RENINS;
|
||||
break;
|
||||
case 'v':
|
||||
opt|=VSTDRV;
|
||||
break;
|
||||
case 'c':
|
||||
opt|=VECCON;
|
||||
break;
|
||||
case 'm':
|
||||
opt|=MBKDRV;
|
||||
break;
|
||||
case 'u':
|
||||
opt|=NOVECT;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "** Unknown option -%c\n", argv[i][1]);
|
||||
printusage();
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!filein)
|
||||
filein=argv[i];
|
||||
else
|
||||
if (!fileout)
|
||||
fileout=argv[i];
|
||||
else {
|
||||
fputs("** Too many filenames\n", stderr);
|
||||
printusage();
|
||||
exit(4);
|
||||
}
|
||||
|
||||
if (!filein) {
|
||||
fputs("** Filename expected!\n", stderr);
|
||||
printusage();
|
||||
exit(3);
|
||||
}
|
||||
|
||||
f=getlofig(filein,'A');
|
||||
|
||||
guessextdir(f);
|
||||
|
||||
if (opt & NOALIM)
|
||||
removepowers(f);
|
||||
|
||||
if (opt & RENINS)
|
||||
renameinstance(f);
|
||||
|
||||
if (opt & NOLOGEN)
|
||||
removelogen(f);
|
||||
|
||||
#if 0
|
||||
if (opt & VECCON) {
|
||||
vectlocon(f);
|
||||
sortlocon(&f->LOCON);
|
||||
f->LOCON=(locon_list *)reverse(f->LOCON);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fileout)
|
||||
f->NAME=namealloc(fileout);
|
||||
|
||||
if (!(opt & NOVECT))
|
||||
vectlosig(&f->LOSIG);
|
||||
|
||||
if (opt & MBKDRV)
|
||||
savelofig(f);
|
||||
else {
|
||||
if (opt&VSTDRV)
|
||||
vhdlsavevelofig(f, 0);
|
||||
else if (opt&ADDSIG)
|
||||
vhdlsavevelofig(f, 1);
|
||||
else
|
||||
vhdlsavevelofig(f, 2);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifdef VEL_DEBUG
|
||||
f->NAME=namealloc("netlist");
|
||||
vhdlsavevelofig(f,1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
exit(0);
|
||||
}
|
Loading…
Reference in New Issue