entree de flatbeh....

ne compile pas encore car attente de l'install dans alliance 5.0 de abv...
This commit is contained in:
Francois Donnet 2002-03-21 13:42:00 +00:00
parent ea4f18199c
commit 1538088ed6
11 changed files with 1573 additions and 0 deletions

View File

@ -0,0 +1,3 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = doc src

View File

@ -0,0 +1,33 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/main.c)
FLATBEH_MAJOR_VERSION=1
FLATBEH_MINOR_VERSION=1
FLATBEH_VERSION=$FLATBEH_MAJOR_VERSION.$FLATBEH_MINOR_VERSION
AC_SUBST(FLATBEH_MAJOR_VERSION)
AC_SUBST(FLATBEH_MINOR_VERSION)
AC_SUBST(FLATBEH_VERSION)
# For automake.
VERSION=$FLATBEH_VERSION
PACKAGE=flatbeh
dnl Initialize automake stuff
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
dnl For alliance path lib and includes
AM_ALLIANCE
AC_OUTPUT([
Makefile
doc/Makefile
src/Makefile
])

View File

@ -0,0 +1,4 @@
## Process this file with automake to produce Makefile.in
man_MANS = flatbeh.1
EXTRA_DIST = $(man_MANS)

View File

@ -0,0 +1,64 @@
.\" @(#)abstract.1 1.0 15 mars 1995 UPMC; DICTUS Nathalie
.TH ABSTRACT 1 "15 mars 1995" "Release 1.0" "ALLIANCE USER COMMANDS"
.SH NAME
.PP
\fBabstract\fP \- Synthetizes a behavioral description from a structural description
.SH ORIGIN
This software belongs to the
.B ALLIANCE
CAD system from the
.br
CAO-VLSI team at MASI laboratory, University P. et M. Curie
.br
4, place Jussieu ; 75252 PARIS Cedex 05 ; FRANCE
.br
Fax: (33-1) 44.27.62.86 ; E-mail: cao-vlsi@masi.ibp.fr
.SH SYNOPSIS
.PP
abstract \fIroot_structural_file\fP \fI[behavioral_file]\fP
.SH DESCRIPTION
.PP
\fBabstract\fP synthetizes a VHDL behavioral data-flow description from a multilevel structural description. It flattens the structural description (it can be
a hierarchy of macro block) until the cells which have a behavioral
description. The output is a VHDL data-flow description.
.SH PARAMETERS
.PP
\fBroot_structural_file\fP is the filename of the root of the structural
description file.
\fBbehavioral_file\fP is the optional filename of the generated behavioral description file.
.SH ENVIRONMENT VARIABLES
.TP 20
\fIMBK_WORK_LIB\fP
Path of the directory that contains the structural description and where is generated the behavioral description.
.TP 20
\fIMBK_CATA_LIB\fP
List of directories containing leaf cell descriptions.
The default path is the current directory (see mbk(1)).
.TP 20
\fIMBK_CATAL_NAME\fP
Indicates the file where the behavioral description files are given. This serves
to abstract to stop the flatten of the structural root circuit (see mbk(1)).
.TP 20
\fIMBK_IN_LO\fP
file extension for structural entity (see mbk(1)).
.SH EXAMPLES
.PP
abstract adder32
.PP
abstract adder32 add32
.SH SEE ALSO
.PP
vhdl(5), mbk(1), MBK_WORK_LIB(8), MBK_CATA_LIB(8), MBK_CATAL_NAME(8), MBK_IN_LO(8).
.SH BUGS
.PP
Please e-mail to \fIcao-vlsi@masi.ibp.fr\fP for bug report and suggestions.

View File

@ -0,0 +1,61 @@
.\" @(#)flatbeh.1 1.0 29 january 1993 UPMC; VUONG Huu Nghia
.TH FLATBEH 1 "29 january 1993" "Release 1.0" "ALLIANCE USER COMMANDS"
.SH NAME
.PP
\fBflatbeh\fP \- Synthetize a behavioral description from a structural description
.SH SYNOPSIS
.PP
flatbeh \fIroot_structural_file\fP [ \fIoutput_file\fP ]
.SH ORIGIN
This software belongs to the
.B ALLIANCE
CAD system from the
.br
CAO-VLSI team at MASI laboratory, University P. et M. Curie
.br
4, place Jussieu ; 75252 PARIS Cedex 05 ; FRANCE
.br
Fax: (33-1) 44.27.62.86 ; E-mail: cao-vlsi@masi.ibp.fr
.SH DESCRIPTION
.PP
\fBflatbeh\fP synthetize a VHDL behavioral data-flow description from a
structural description. It flattens the structural description (it can be
a hierarchy of macro block) until the cells which have a behavioral
description. Then it raise all the equations and create a behavioral
description of the root file.
.SH PARAMETERS
.PP
\fBroot_structural_file\fP is the filename of the root of the structural
description file.
\fBoutput_file\fP is the destination filename for behavioural description.
.SH ENVIRONMENT VARIABLES
.TP 20
\fIMBK_CATA_LIB\fP
list of directories containing descriptions.
The default path is the current directory (see mbk(1)).
.TP 20
\fIMBK_CATAL_NAME\fP
Indicates the file where the behavioral description files are given. This serves
to flatbeh to stop the flatten of the structural root circuit.(see mbk(1))
.TP 20
\fIMBK_IN_LO\fP
file extension for structural entity. (see mbk(1))
.SH EXAMPLE
.PP
flatbeh adder_32
.SH SEE ALSO
.PP
vhdl(5), mbk(1).
.SH BUGS
.PP
Please e-mail to \fIcao-vlsi@masi.ibp.fr\fP for bug report and suggestions.

View File

@ -0,0 +1,9 @@
## Process this file with automake to produce Makefile.in
bin_PROGRAMS = flatbeh
flatbeh_LDADD = @LIBS@ \
-lAbv -lAbe -lAbt -lMlu -lMcl -lMal -lMsl -lMhl -lMel -lMvl -lMgl -lRcn -lMlo -lBdd -lAbl -lAut -lMut
flatbeh_SOURCES = abstract.c abstract.h utils.c utils.h main.c

View File

@ -0,0 +1,719 @@
/*
* This file is part of the Alliance CAD System
* Copyright (C) Laboratoire LIP6 - Département ASIM
* Universite Pierre et Marie Curie
*
* Home page : http://www-asim.lip6.fr/alliance/
* E-mail support : mailto:alliance-support@asim.lip6.fr
*
* This progam is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* Alliance VLSI CAD System is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the GNU C Library; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <mut.h>
#include <mlo.h>
#include <mlu.h>
#include <abl.h>
#include <abe.h>
#include <abv.h>
#include <aut.h>
#include "abstract.h"
#include "utils.h"
/*------------------------------------------------------------------------------
create : Regenere un ABL en substituant les variables formelles
par les signaux de la lofig
--------------------------------------------------------------------------------
parametres : en ABL, un modele d'instance et une table de hasch.
--------------------------------------------------------------------------------
return : un ABL.
------------------------------------------------------------------------------*/
chain_list *create(expr, model, tableTH)
chain_list *expr;
loins_list *model;
authtable* tableTH;
{
chain_list *ret;
locon_list *con;
if (ABL_ATOM(expr))
{
if (ABL_ATOM_VALUE(expr) == namealloc("'1'"))
return createablatom("'1'");
if (ABL_ATOM_VALUE(expr) == namealloc("'0'"))
return createablatom("'0'");
for(con = model->LOCON; (con && (ABL_ATOM_VALUE(expr) != con->NAME));
con = con->NEXT);
if (con)
{
/* variable de expr est un connecteur de l'interface */
chain_list *lstCon;
chain_list *retour = (chain_list *)NULL;
ptype_list *liste = getptype(con->SIG->USER, (long)LOFIGCHAIN);
if (!liste)
{
printf("ERROR : No lofigchain for %s of %s\n", con->NAME, model->FIGNAME);
exit(-1);
}
if (!(((chain_list *)liste->DATA)->NEXT))
{
printf("ERROR : Nothing connected to %s (Index %ld-TYPE %c) of %s\n\n",
con->NAME, con->SIG->INDEX, con->SIG->TYPE, model->INSNAME);
printf("Please verify your CATAL file !\n\n");
exit(-1);
}
if (con->SIG->TYPE == EXTERNAL)
{
for(lstCon = (chain_list *)liste->DATA; lstCon; lstCon = lstCon->NEXT)
{
locon_list *conAux = (locon_list *)lstCon->DATA;
if (conAux->ROOT != (void *)model)
{
if ((conAux->TYPE == EXTERNAL) && (conAux->DIRECTION == IN || conAux->DIRECTION == INOUT))
retour = createablatom(conAux->NAME);
else
if ((conAux->TYPE == INTERNAL) &&
((conAux->DIRECTION == OUT) ||
(conAux->DIRECTION == INOUT) ||
(conAux->DIRECTION == TRISTATE) ||
(conAux->DIRECTION == TRANSCV)))
{
char * nameAtom = mbkalloc(strlen(getsigname(con->SIG)) + 4);
sprintf(nameAtom, "%s", getsigname(con->SIG));
retour = createablatom(nameAtom);
}
}
}
}
else
{
for(lstCon = (chain_list *)liste->DATA; lstCon; lstCon = lstCon->NEXT)
{
locon_list *conAux = (locon_list *)lstCon->DATA;
/*printf(" %s %c\n",conAux->NAME,conAux->DIRECTION);*/
if (conAux->ROOT != (void *)model)
{
if ((conAux->DIRECTION == OUT) ||
(conAux->DIRECTION == INOUT) ||
(conAux->DIRECTION == TRISTATE) ||
(conAux->DIRECTION == TRANSCV))
{
char * nameAtom = mbkalloc(strlen(getsigname(con->SIG)) + 4);
sprintf(nameAtom, "%s", getsigname(con->SIG));
retour = createablatom(nameAtom);
}
}
else if ((conAux->DIRECTION == INOUT) || (conAux->DIRECTION == OUT))
{
char * nameAtom = mbkalloc(strlen(getsigname(con->SIG)) + 4);
sprintf(nameAtom, "%s", getsigname(con->SIG));
retour = createablatom(nameAtom);
}
}
}
if (!retour)
{
printf("ERROR : nothing for connector %s of %s [%s]\n",
con->NAME, model->INSNAME, model->FIGNAME);
exit(-1);
}
return retour;
}
else
{
/* ce n'est pas un connecteur de l'interface */
authelem *val;
if ((val = searchauthelem(tableTH, ABL_ATOM_VALUE(expr))) != NULL)
return createablatom((char *)val->VALUE);
else
{
char *auxName = (char *)mbkalloc(strlen(model->INSNAME) +
strlen(ABL_ATOM_VALUE(expr)) + 2);
sprintf(auxName, "%s_%s", model->INSNAME, ABL_ATOM_VALUE(expr));
/*printf("WARNING : %s not foundn\n", ABL_ATOM_VALUE(expr));*/
addauthelem(tableTH, ABL_ATOM_VALUE(expr), (long) auxName);
return createablatom(auxName);
}
}
}
else
{
chain_list *arg;
ret = createabloper(ABL_OPER(expr));
for(arg = ABL_CDR(expr); arg; arg = ABL_CDR(arg))
addablqexpr(ret, create(ABL_CAR(arg), model, tableTH));
return ret;
}
}
/*------------------------------------------------------------------------------
searchMod :
-------------------------------------------------------
parametres : une lofig.
-------------------------------------------------------
return : une befig.
------------------------------------------------------------------------------*/
befig_list *searchMod(liste, name)
befig_list *liste;
char *name;
{
befig_list *l;
for(l = liste; l; l = l->NEXT)
{
/*
printf("\tModel %s\n", l->NAME);
*/
if (l->NAME == name)
return l;
}
return (befig_list *)NULL;
}
/*---------------------------------------------------------------------------
addConDirLof : MAJ direction des connecteurs externes (fct de no_system.c)
certains connecteurs deviennent des inout apres mise a plat
-----------------------------------------------------------------------------
retour : lofig physiquement modifiee
---------------------------------------------------------------------------*/
void addConDirLof(lofig)
lofig_list *lofig;
{
locon_list *connect;
for(connect = lofig->LOCON; connect; connect = connect->NEXT)
{
chain_list *l;
ptype_list *liste = getptype(connect->SIG->USER, (long)LOFIGCHAIN);
char dir = ((locon_list *)(((chain_list *)(liste->DATA))->DATA))->DIRECTION;
for (l = (chain_list *)(liste->DATA); l; l = l->NEXT)
if (((locon_list *)(l->DATA))->TYPE != EXTERNAL &&
dir != INOUT && ((locon_list*)(l->DATA))->DIRECTION != dir)
dir = INOUT;
connect->DIRECTION = dir;
}
}
/*------------------------------------------------------------------------------
RestoreDir : met a jour les directions de connecteurs
-------------------------------------------------------
parametres : une loins.
-------------------------------------------------------
return :
------------------------------------------------------------------------------*/
void RestoreDir(ptr_loins, ptr_befig)
loins_list *ptr_loins;
befig_list *ptr_befig;
{
struct bepor *ptr_bepor;
struct locon *ptr_locon;
for (ptr_locon = ptr_loins->LOCON; ptr_locon; ptr_locon = ptr_locon->NEXT)
{
for (ptr_bepor = ptr_befig->BEPOR; ptr_bepor; ptr_bepor = ptr_bepor->NEXT)
{
if (ptr_locon->NAME == ptr_bepor->NAME)
{
switch(ptr_bepor->DIRECTION)
{
case 'I': ptr_locon->DIRECTION = IN ;break;
case 'O': ptr_locon->DIRECTION = OUT ;break;
case 'B': ptr_locon->DIRECTION = INOUT;break;
case 'Z': ptr_locon->DIRECTION = TRISTATE;break;
case 'T': ptr_locon->DIRECTION = TRANSCV;break;
default:;
}
/*printf(" Loins %s Locon %s Direction %c\n",ptr_loins->INSNAME,ptr_locon->NAME, ptr_locon->DIRECTION);*/
}
}
}
}
/*------------------------------------------------------------------------------
laxExtract : retourne une befig a partir d'une lofig et d'une bibliotheque
-------------------------------------------------------
parametres : une lofig.
-------------------------------------------------------
return : une befig.
------------------------------------------------------------------------------*/
befig_list *laxExtract(lofig, trace)
lofig_list *lofig;
int trace;
{
befig_list *befig;
befig_list *ptbefig = NULL;
locon_list *con;
loins_list *inst;
chain_list *mod;
int cptLabel = 0;
authelem* ret;
authtable* busTH = createauthtable(100);
/*--------------- compilation des modeles --------------------------------*/
for(mod = lofig->MODELCHAIN; mod; mod = mod->NEXT)
{
ptbefig = (befig_list *)vhdlloadbefig(ptbefig, (char *)mod->DATA, 0);
printf(" loading %s \n",ptbefig->NAME);
/*beh_depend(ptbefig);*/
}
for(inst = lofig->LOINS; inst; inst = inst->NEXT)
{
befig_list *modBefig = searchMod(ptbefig, inst->FIGNAME);
RestoreDir(inst,modBefig);
}
/*ret = restorealldir(lofig);
if (!ret) exit(1);
printf("restore dir OK \n");*/
/*--------------- mise a jour des directions des conecteurs externes -----*/
addConDirLof(lofig);
/*-------------- creation de la befig resultat --------------------------*/
befig = beh_addbefig(NULL, lofig->NAME);
/* mise a jour des BEPOR, BERIN, BEOUT */
for(con = lofig->LOCON; con; con = con->NEXT)
{
if ((isvdd(con->NAME)) || (isvss(con->NAME)))
befig->BEPOR = beh_addbepor(befig->BEPOR, con->NAME, 'I', 'B');
else
if ((con->DIRECTION == TRISTATE) || (con->DIRECTION == TRANSCV))
/* en fait il faut recuperer le type du modele ... */
befig->BEPOR = beh_addbepor(befig->BEPOR, con->NAME,
con->DIRECTION, 'M');
else
befig->BEPOR = beh_addbepor(befig->BEPOR, con->NAME, con->DIRECTION, 'B');
if (trace)
printf(" POR %s (DIR = %c, TYPE = %c)\n", con->NAME, con->DIRECTION,
con->TYPE);
if ((con->DIRECTION == IN) || (con->DIRECTION == INOUT))
befig->BERIN = beh_addberin(befig->BERIN, con->NAME);
}
/* respect de l'ordre de l'interface */
befig->BEPOR = (bepor_list *)reverse((chain_list*)befig->BEPOR);
/*------------------ parcours des instances de la lofig ----------------------*/
for(inst = lofig->LOINS; inst; inst = inst->NEXT)
{
befig_list *modBefig = searchMod(ptbefig, inst->FIGNAME);
int nbSorties = 0;
for(con = inst->LOCON; con; con = con->NEXT)
if ((con->DIRECTION == OUT) || (con->DIRECTION == INOUT) ||
(con->DIRECTION == TRANSCV) || (con->DIRECTION == TRISTATE))
nbSorties++;
if (trace)
printf("-- Inst %s [%s]\n", inst->INSNAME, inst->FIGNAME);
if (modBefig)
{
authtable* intTH = createauthtable(10); /* TH des signaux internes */
beaux_list *aux;
bereg_list *reg;
bebus_list *bus;
bebux_list *bux;
beout_list *sortie;
/* Gestion des auxiliaires */
for(aux = modBefig->BEAUX; aux; aux = aux->NEXT)
{
chain_list *newExpr;
char *auxName = (char *)mbkalloc(strlen(inst->INSNAME) +
strlen(aux->NAME) + 2);
sprintf(auxName, "%s_%s", inst->INSNAME, aux->NAME);
if (searchauthelem(intTH, aux->NAME) == NULL)
addauthelem(intTH, aux->NAME, (long)auxName);
newExpr = create(aux->ABL, inst, intTH);
if (trace)
{
printf(" AUX %s (%s)\n", aux->NAME, auxName);
printf(" ");
viewablexpr(aux->ABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newExpr,ABL_VIEW_INFIX);
}
befig->BEAUX = beh_addbeaux(befig->BEAUX, auxName,
newExpr, NULL);
}
/*------------------- Gestion des registres ----------------------*/
for(reg = modBefig->BEREG; reg; reg = reg->NEXT)
{
biabl_list *bi;
biabl_list *newBi = (biabl_list *)NULL;
char *regName=NULL;
/*if register of standard cell*/
if (!modBefig->BEBUS && !modBefig->BEBUX && !modBefig->BEREG->NEXT && modBefig->BEOUT && !modBefig->BEOUT->NEXT && ABL_ATOM(modBefig->BEOUT->ABL) && ABL_ATOM_VALUE(modBefig->BEOUT->ABL)==reg->NAME) {
for(con = inst->LOCON; con; con = con->NEXT)
if (modBefig->BEOUT->NAME==con->NAME) break;
if (!con) {
fprintf(stderr,"locon %s not found\n",modBefig->BEOUT->NAME);
exit(1);
}
regName = getsigname(con->SIG);
}
else {
regName = mbkalloc(strlen(inst->INSNAME) +
strlen(reg->NAME) + 2);
/* registre tres interne */
sprintf(regName, "%s_%s", inst->INSNAME, reg->NAME);
} /*end of loop*/
if (trace)
printf(" BEREG %s (%s)\n", reg->NAME, regName);
for(bi = reg->BIABL; bi; bi = bi->NEXT)
{
chain_list *newVal;
chain_list *newCnd;
char *labelName = (char *)mbkalloc(12);
addauthelem(intTH, reg->NAME, (long)regName);
newVal = create(bi->VALABL, inst, intTH);
newCnd = create(bi->CNDABL, inst, intTH);
if (trace)
{
printf(" VAL");
viewablexpr(bi->VALABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newVal,ABL_VIEW_INFIX);
printf(" CMD");
viewablexpr(bi->CNDABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newCnd,ABL_VIEW_INFIX);
}
sprintf(labelName, "label_%d", cptLabel++);
newBi = beh_addbiabl(newBi, labelName, newCnd, newVal);
}
befig->BEREG = beh_addbereg(befig->BEREG, regName, newBi, NULL);
}
/* Gestion des bus externes */
for(bus = modBefig->BEBUS; bus; bus = bus->NEXT)
{
char *busName=NULL;
biabl_list *bi;
biabl_list *newBi = (biabl_list *)NULL;
char *labelName = (char *)mbkalloc(12);
if (trace)
printf(" BUS %s\n", bus->NAME);
for(bi = bus->BIABL; bi; bi = bi->NEXT)
{
chain_list *newVal;
chain_list *newCnd;
newVal = create(bi->VALABL, inst, intTH);
newCnd = create(bi->CNDABL, inst, intTH);
if (trace)
{
printf(" VAL");
viewablexpr(bi->VALABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newVal,ABL_VIEW_INFIX);
printf(" CMD");
viewablexpr(bi->CNDABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newCnd,ABL_VIEW_INFIX);
}
sprintf(labelName, "label_%d", cptLabel++);
newBi = beh_addbiabl(newBi, labelName, newCnd, newVal);
}
for(con = inst->LOCON; con; con = con->NEXT)
if (con->NAME == bus->NAME)
{
int cptInt = 0;
if (con->SIG->TYPE == EXTERNAL)
{
/* on a reellement un bus externe */
chain_list *lstCon;
ptype_list *liste = getptype(con->SIG->USER,
(long)LOFIGCHAIN);
if (liste)
{
for(lstCon = (chain_list *)liste->DATA;
lstCon; lstCon = lstCon->NEXT)
{
locon_list *conAux = (locon_list *)lstCon->DATA;
if (conAux->ROOT != (void *)inst)
{
if ((conAux->TYPE != EXTERNAL) &&
(conAux->DIRECTION == IN))
cptInt++;
if (conAux->TYPE == EXTERNAL)
busName = conAux->NAME;
}
}
if ((ret = searchauthelem(busTH, busName)) == NULL)
{
if (cptInt == 0)
befig->BEBUS = beh_addbebus(befig->BEBUS, busName,
newBi, NULL, bus->TYPE);
else
befig->BEBUS = beh_addbebus(befig->BEBUS, busName,
newBi, NULL, bus->TYPE);
addauthelem(busTH, busName,(long) befig->BEBUS);
}
else
{
/* le bus existe deja :
on accroche le nouveau biabl */
biabl_list *n;
for(n = newBi; n && n->NEXT; n = n->NEXT)
;
n->NEXT = ((bebus_list *)ret->VALUE)->BIABL;
((bebus_list *)ret->VALUE)->BIABL = newBi;
}
}
else
{
printf("ERROR : No LOFIGCHAIN for %s [%s] (%s)\n",
inst->INSNAME, inst->FIGNAME,
getsigname(con->SIG));
exit(-1);
}
}
else
{
/* signal interne dans la lofig = bus interne*/
busName = (char *)mbkalloc(strlen(getsigname(con->SIG)) + 4);
sprintf(busName, "%s", getsigname(con->SIG));
busName = namealloc(busName);
if ((ret = searchauthelem(busTH, busName)) == NULL)
{
befig->BEBUX = beh_addbebux(befig->BEBUX, busName, newBi,
NULL, bus->TYPE);
addauthelem(busTH, busName, (long)befig->BEBUX);
}
else
{
/* le bux existe deja :
on accroche le nouveau biabl */
biabl_list *n;
for(n = newBi; n && n->NEXT; n = n->NEXT)
;
n->NEXT = ((bebux_list *)ret->VALUE)->BIABL;
((bebux_list *)ret->VALUE)->BIABL = newBi;
}
}
}
addauthelem(intTH, bus->NAME, (long)busName);
}
/* Gestion des bus internes */
for(bux = modBefig->BEBUX; bux; bux = bux->NEXT)
{
biabl_list *bi;
biabl_list *newBi = (biabl_list *)NULL;
char *buxName = (char *)mbkalloc(strlen(inst->INSNAME) +
strlen(bux->NAME) + 2);
sprintf(buxName, "%s_%s", inst->INSNAME, bux->NAME);
if (trace)
printf(" BUX %s\n", bux->NAME);
for(bi = bux->BIABL; bi; bi = bi->NEXT)
{
chain_list *newVal;
chain_list *newCnd;
char *labelName = (char *)mbkalloc(12);
addauthelem(intTH, bux->NAME, (long)buxName);
newVal = create(bi->VALABL, inst, intTH);
newCnd = create(bi->CNDABL, inst, intTH);
if (trace)
{
printf(" VAL");
viewablexpr(bi->VALABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newVal,ABL_VIEW_INFIX);
printf(" CMD");
viewablexpr(bi->CNDABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newCnd,ABL_VIEW_INFIX);
}
sprintf(labelName,"label_%d", cptLabel++);
newBi = beh_addbiabl(newBi, labelName, newCnd, newVal);
}
if ((ret = searchauthelem(busTH, buxName)) == NULL)
{
befig->BEBUX = beh_addbebux(befig->BEBUX, buxName, newBi,
NULL, bux->TYPE);
addauthelem(busTH, buxName, (long)befig->BEBUX);
}
else
{
/* le bux existe deja :
on accroche le nouveau biabl */
biabl_list *n;
for(n = newBi; n && n->NEXT; n = n->NEXT)
;
n->NEXT = ((bebux_list *)ret->VALUE)->BIABL;
((bebux_list *)ret->VALUE)->BIABL = newBi;
}
}
/* Gestion des sorties */
for(sortie = modBefig->BEOUT; sortie; sortie = sortie->NEXT)
{
/*absorb beout for register of standard cell*/
if (!modBefig->BEBUS && !modBefig->BEBUX && modBefig->BEREG && !modBefig->BEREG->NEXT && modBefig->BEOUT && !modBefig->BEOUT->NEXT && ABL_ATOM(modBefig->BEOUT->ABL) && ABL_ATOM_VALUE(modBefig->BEOUT->ABL)==modBefig->BEREG->NAME) continue;
for(con = inst->LOCON; con; con = con->NEXT)
if (sortie->NAME == con->NAME)
{
chain_list *newExpr;
char *nameAux = (char *)mbkalloc(strlen(getsigname(con->SIG)) + 4);
sprintf(nameAux, "%s", getsigname(con->SIG));
newExpr = create(sortie->ABL, inst, intTH);
if (trace)
{
printf(" OUT %s\n", sortie->NAME);
printf(" ");
viewablexpr(sortie->ABL,ABL_VIEW_INFIX);
printf(" ");
viewablexpr(newExpr,ABL_VIEW_INFIX);
}
if (con->SIG->TYPE == INTERNAL)
{
befig->BEAUX = beh_addbeaux(befig->BEAUX,
nameAux,
newExpr, NULL);
}
else
{
/* signal interne dans la lofig */
chain_list *lstCon;
int cptInt = 0;
char *outName=NULL;
ptype_list *liste = getptype(con->SIG->USER,
(long)LOFIGCHAIN);
if (liste)
{
for(lstCon = (chain_list *)liste->DATA;
lstCon; lstCon = lstCon->NEXT)
{
locon_list *conAux = (locon_list *)lstCon->DATA;
if (conAux->ROOT != (void *)inst)
{
if ((conAux->TYPE != EXTERNAL) &&
(conAux->DIRECTION == IN))
cptInt++;
if (conAux->TYPE == EXTERNAL)
outName = conAux->NAME;
}
}
if (cptInt == 0)
/* sortie directe */
befig->BEOUT = beh_addbeout(befig->BEOUT, outName,
newExpr, NULL);
else
{
/* cas de la sortie reinjectee */
befig->BEAUX = beh_addbeaux(befig->BEAUX, nameAux,
newExpr, NULL);
befig->BEOUT = beh_addbeout(befig->BEOUT, outName,
createablatom(nameAux), NULL);
}
}
else
{
printf("ERROR : No LOFIGCHAIN for %s [%s] (%s)\n",
inst->INSNAME, inst->FIGNAME,
getsigname(con->SIG));
exit(-1);
}
}
}
}
destroyauthtable(intTH);
}
else
{
printf("Error : le model %s n'existe pas !\n", inst->FIGNAME);
return (befig_list *)NULL;
}
}
/* nettoyage de la bibliotheque : quand ca voudra bien marcher */
/*
beh_frebefig(ptbefig);
*/
destroyauthtable(busTH);
return(befig);
}

View File

@ -0,0 +1,26 @@
/*
* This file is part of the Alliance CAD System
* Copyright (C) Laboratoire LIP6 - Département ASIM
* Universite Pierre et Marie Curie
*
* Home page : http://www-asim.lip6.fr/alliance/
* E-mail support : mailto:alliance-support@asim.lip6.fr
*
* This progam is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* Alliance VLSI CAD System is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the GNU C Library; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
extern chain_list *create();
extern befig_list *searchMod();
extern befig_list *laxExtract();

View File

@ -0,0 +1,147 @@
/*
* This file is part of the Alliance CAD System
* Copyright (C) Laboratoire LIP6 - Département ASIM
* Universite Pierre et Marie Curie
*
* Home page : http://www-asim.lip6.fr/alliance/
* E-mail support : mailto:alliance-support@asim.lip6.fr
*
* This progam is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* Alliance VLSI CAD System is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the GNU C Library; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/****************************************************************************/
/* */
/* Chaine de CAO & VLSI Alliance */
/* */
/* Produit : Extracteur de vue comportementale */
/* Fichier : main.c */
/* */
/* (c) copyright 1991 Laboratoire MASI equipe CAO & VLSI */
/* Tous droits reserves */
/* Support : e-mail cao-vlsi@masi.ibp.fr */
/* */
/* */
/****************************************************************************/
#include <stdlib.h>
#include <mut.h>
#include <mlo.h>
#include <mlu.h>
#include <abl.h>
#include <abe.h>
#include <abv.h>
#include <aut.h>
#include <bdd.h>
#include "utils.h"
#include "abstract.h"
/* ********* MAIN ********* */
extern int main(argc, argv)
int argc;
char *argv[];
{
befig_list *befig;
lofig_list *lofig;
int trace = 0;
char *outputFile;
alliancebanner_with_authors("FlatBeh", VERSION " [2000/11/01]", "a netlist abstractor", "1993",
"5.0", "François DONNET, Huu Nghia VUONG");
if ((argc < 2) || (argc > 3))
{
printf("\nflatbeh %s\n", VERSION);
printf("\nUsage\t: flatbeh input_file [output_file]\n\n");
printf("\t input_file = circuit at gate level\n");
printf("\t output_file = circuit at logic level (default name = input_file + abs)\n\n");
exit(1);
}
/*init*/
mbkenv(); /*mbk*/
ablenv(); /*abl*/
autenv(); /*hash table*/
bddenv(); /*for vhdlloadbefig() */
if (mbkgetenv("MBK_TRACE"))
trace = atoi(mbkgetenv("MBK_TRACE"));
if (argc == 2)
{
outputFile = mbkalloc(strlen(argv[1]) + 4);
sprintf(outputFile, "%sabs", argv[1]);
}
else
outputFile = argv[2];
printf(" ========================= Environnement =========================\n");
printf(" MBK_WORK_LIB = %s\n", WORK_LIB);
printf(" MBK_CATA_LIB = %s\n", mbkgetenv("MBK_CATA_LIB"));
printf(" MBK_CATAL_NAME = %s\n", mbkgetenv("MBK_CATAL_NAME"));
if (trace > 0)
printf(" MBK_TRACE = %d\n", trace);
printf(" ============================== Files ==============================\n");
printf(" Netlist file = %s.%s\n", argv[1], IN_LO);
printf(" Output file = %s.vbe\n", outputFile);
printf(" ===================================================================\n");
printf("\n");
/* mise a plat de la figure */
lofig = getlofig(argv[1], 'A');
fprintf (stdout,"Loading '%s/%s.%s'\n", WORK_LIB, lofig->NAME, IN_LO);
/*------------------ mise a plat de la figure -------------------- */
printf("flattening figure %s \n",lofig->NAME);
rflattenlofig(lofig, YES, YES);
if ((!(lofig->LOINS)) || (lofig->LOTRS))
{
printf("ERROR : Transistor level description in %s : verify your CATAL file !\n",
lofig->NAME);
#ifdef LAX
LXU_Error("Transistor level description : verify your CATAL file !");
#endif
exit(0);;
}
/*------------------ chainage de la figure -------------------------*/
lofigchain(lofig);
befig = laxExtract(lofig, trace);
fprintf(stdout,"Restoring array's orders \n");
RestoreIndexes(befig);
if (!befig)
{
fprintf(stderr,"Some error has occurred\n");
exit(1);
}
befig->NAME = outputFile;
/* if (trace) displayBehMap(befig, 1); */
vhdlsavebefig(befig, 1);
exit(0);
}

View File

@ -0,0 +1,467 @@
/*
* This file is part of the Alliance CAD System
* Copyright (C) Laboratoire LIP6 - Département ASIM
* Universite Pierre et Marie Curie
*
* Home page : http://www-asim.lip6.fr/alliance/
* E-mail support : mailto:alliance-support@asim.lip6.fr
*
* This progam is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* Alliance VLSI CAD System is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the GNU C Library; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mut.h>
#include <mlo.h>
#include <abl.h>
#include <abe.h>
#include <aut.h>
#include "utils.h"
long max_index;
char *itostr(str,nbr)
char *str;
int nbr;
{
char *s = (char *)mbkalloc(strlen(str)+5);
strcpy(s,str);
strcat(s,"%d");
sprintf(s,s,nbr);
return ((char *)s);
}
void Usage(nom)
char *nom;
{
printf("\n");
printf("Usage : %s <input_file> [-b -P] [-a <output_file>] \n",nom);
printf(" [-R <ratio value>] [-S <SEED value>]\n");
printf(" [-N <number of parts>] \n");
printf("\n");
printf("-b Loading Behavioral description .\n");
printf("-a makes the abstraction of the structural desription.\n");
printf("-p perform partitionning.\n");
printf("-S SEED value .\n");
printf("-R Partitionning ratio.\n");
printf("-N number of parts (0->2, 1->4, 2->8, 3->16, 4->32 )\n");
printf("\n");
exit (1);
}
char *busname(name)
char *name;
{
char *tmp_name;
char *s, *t;
if (!name) {
printf("error in procedure busname\n");
return NULL;
}
tmp_name = (char *)mbkalloc(strlen(name)+1);
s = name;
t = tmp_name;
while((*s != ' ') && (*s != '\0'))
{
*t++ = *s++;
}
*t = '\0';
return (tmp_name);
}
char *Changename(sufix,name)
char *sufix,*name;
{
char *tmp_name ;
char *s, *s1, *t;
if (!name) {
printf("error in procedure busname\n");
return NULL;
}
tmp_name = (char *)mbkalloc(strlen(name)+strlen(sufix)+1);
s = name;
s1 = sufix;
t = tmp_name;
while((*s != ' ') && (*s != '\0'))
{
*t++ = *s++;
}
while(*s1 != '\0')
{
*t++ = *s1++;
}
while(*s != '\0')
{
*t++ = *s++;
}
*t = '\0';
return (tmp_name);
}
int busindex(name)
char *name;
{
char *tmp_index;
char *s, *t;
char blank_found = 0;
int ind;
tmp_index=(char *)mbkalloc(strlen(name)+1);
if (!name) {
printf("error in procedure busname\n");
exit(1);
}
t = tmp_index;
s = name;
while (*s != '\0')
{
if (*s == ' ') {s++;blank_found =1;break;}
else ++s;
}
if (blank_found)
while (*s !='\0') { *t++=*s++;}
*t = '\0';
sscanf(tmp_index,"%d",&ind);
return(ind);
}
char *RemoveIndex(name)
char *name;
{
char *new_name;
char *s, *t;
new_name=(char *)mbkalloc(strlen(name)+1);
if (!name) {
printf("error in procedure busname\n");
return NULL;
}
t = new_name;
s = name;
while (*s != '\0')
{
if (*s == ' ') {*t++='_';s++;}
else *t++ = *s++;
}
*t = '\0';
return(namealloc(new_name));
}
/*------------------------------------------------------
Useful function to display locon and loins lists
------------------------------------------------------*/
void display_locon_list(p)
chain_list *p;
{
chain_list *ptr;
for(ptr = p ; ptr!=NULL ; ptr = ptr->NEXT)
{
printf(" %s\n",((locon_list *)(ptr->DATA))->NAME);
}
}
void display_loins_list(p)
chain_list *p;
{
chain_list *ptr;
for(ptr = p ; ptr!=NULL ;ptr = ptr->NEXT)
{
printf(" %s\n",((loins_list *)(ptr->DATA))->INSNAME);
}
}
/*void display_lists()
{
printf(" Liste des connecteurs en entree\n");
display_locon_list(in_ptr);
printf("Liste des connecteurs en sortie \n");
display_locon_list(out_ptr);
printf("Liste des points memoire de la netliste\n");
display_loins_list(mem_ptr);
printf("Liste des points memoire du chemin de test\n");
display_loins_list(scan_ptr);
}*/
/***********************************************************************************/
/* This function Gets the pointer to the LOCON connector in the instance pointed by ptri */
/***********************************************************************************/
locon_list *get_con(ptri,connector)
loins_list *ptri;
char *connector;
{
locon_list *ptr1;
for ( ptr1 = ptri->LOCON ; ptr1 != NULL ; ptr1 = ptr1->NEXT)
{
if ( ptr1->NAME == namealloc(connector)) return ptr1;
}
printf("no connector %s in model %s \n",connector,ptri->FIGNAME);
exit(1);
}
/*******************************************************************************************************************/
/* */
/* changes the old SIG->TYPE to INTERNAL, appends bist_ to SIGNAMECHAIN and sets SIG to a new signal pointer */
/* */
/*******************************************************************************************************************/
void update_con(ptrc,new_ptr_sig)
locon_list *ptrc;
losig_list *new_ptr_sig;
{
chain_list *name_list=ptrc->SIG->NAMECHAIN;
char *st = (char *)mbkalloc(strlen((char *)name_list->DATA) + strlen("_bist")+1) ;
sprintf(st,"bist_%s",(char *)name_list->DATA);
ptrc->SIG->TYPE = INTERNAL ; /* update signals TYPE */
name_list = delchain(name_list,name_list);
ptrc->SIG->NAMECHAIN = addchain(name_list,(void *)namealloc(st));/* update signals name */
ptrc->SIG = new_ptr_sig;/* set SIG connectors field to a new signal */
}
/*******************************************************************************************************************/
/* */
/* search of the maximum signals INDEX */
/* */
/*******************************************************************************************************************/
long get_max_index(ptfig)
lofig_list *ptfig;
{
losig_list *pts;
long i = 0;
for(pts = ptfig->LOSIG ; pts ; pts = pts->NEXT)
{
if ((pts->INDEX) > i)
{
i = pts->INDEX;
}
}
return(i);
}
/*******************************************************************************************************************/
/* */
/* gets a new number of signal INDEX */
/* */
/*******************************************************************************************************************/
long get_index()
{
max_index = max_index +1;
/* printf("index \n",max_index);*/
return(max_index-1);
}
/*------------------------------------------------------------------------------
restore_Indexes : reconstitue les signaux busses sur une befig
-----------------------------------------------------------------
parametres : une befig .
-----------------------------------------------------------------
return : .
------------------------------------------------------------------------------*/
void RestoreIndexes(ptr_befig)
befig_list *ptr_befig;
{
struct bepor *ptr_bepor;
struct bepor *ptr_bepor1;
struct bepor *save_bepor;
struct bepor *new_bepor = NULL;
struct beaux *ptr_beaux;
struct beaux *ptr_beaux1;
struct beaux *save_beaux;
struct beaux *new_beaux = NULL;
struct bereg *ptr_bereg;
struct bereg *ptr_bereg1;
struct bereg *save_bereg;
struct bereg *new_bereg = NULL;
void *sort[512] ;
char *prefix;
authtable * porTH, *regTH, *auxTH, *buxTH;
int index, i, permut=0;
porTH = createauthtable(100);
regTH = createauthtable(100);
auxTH = createauthtable(100);
buxTH = createauthtable(100);
/* restore indexes for bepor */
for (ptr_bepor = ptr_befig->BEPOR; ptr_bepor; ptr_bepor = ptr_bepor->NEXT)
{
index = 0;
prefix = namealloc(busname(ptr_bepor->NAME));
if (searchauthelem(porTH,prefix) == NULL)
{
addauthelem(porTH, prefix,1);
sort[index++] = ptr_bepor;
for (ptr_bepor1 = ptr_bepor->NEXT; ptr_bepor1; ptr_bepor1 = ptr_bepor1->NEXT)
{
if (strcmp(busname(ptr_bepor1->NAME),prefix) == 0 )
sort[index++] = ptr_bepor1;
}
/* sort the connectors */
do
{
permut =0;
for (i=0; i<index-1; i++)
{
if (busindex(((bepor_list *)sort[i])->NAME) > busindex(((bepor_list *)sort[i+1])->NAME))
{
save_bepor = sort[i];
sort[i] = sort[i+1];
sort[i+1] = save_bepor;
permut =1;
}
}
}
while (permut);
}
for (i =index-1 ; i>=0 ;i--)
{
new_bepor = beh_addbepor(new_bepor,((bepor_list *)sort[i])->NAME,((bepor_list *)sort[i])->DIRECTION,((bepor_list *)sort[i])->TYPE);
/*printf("------>%s\n",sort[i]->NAME);*/
}
}
/* sorting internal simple signals */
for (ptr_beaux = ptr_befig->BEAUX; ptr_beaux; ptr_beaux = ptr_beaux->NEXT)
{
index = 0;
prefix = namealloc(busname(ptr_beaux->NAME));
if (searchauthelem(auxTH,prefix) == NULL)
{
addauthelem(auxTH, prefix,1);
sort[index++] = ptr_beaux;
for (ptr_beaux1 = ptr_beaux->NEXT; ptr_beaux1; ptr_beaux1 = ptr_beaux1->NEXT)
{
if (strcmp(busname(ptr_beaux1->NAME),prefix) == 0 )
sort[index++] = ptr_beaux1;
}
/* sort the connectors */
do
{
permut =0;
for (i=0; i<index-1; i++)
{
if (busindex(((beaux_list *)sort[i])->NAME) > busindex(((beaux_list *)sort[i+1])->NAME))
{
save_beaux = sort[i];
sort[i] = sort[i+1];
sort[i+1] = save_beaux;
permut =1;
}
}
}
while (permut);
}
for (i =index-1 ; i>=0 ;i--)
{
new_beaux = beh_addbeaux(new_beaux,((beaux_list *)sort[i])->NAME,((beaux_list *)sort[i])->ABL);
/*printf("------>%s\n",sort[i]->NAME);*/
}
}
/* sorting internal registers */
for (ptr_bereg = ptr_befig->BEREG; ptr_bereg; ptr_bereg = ptr_bereg->NEXT)
{
index = 0;
prefix = namealloc(busname(ptr_bereg->NAME));
if (searchauthelem(regTH,prefix) == NULL)
{
addauthelem(regTH, prefix,1);
sort[index++] = ptr_bereg;
for (ptr_bereg1 = ptr_bereg->NEXT; ptr_bereg1; ptr_bereg1 = ptr_bereg1->NEXT)
{
if (strcmp(busname(ptr_bereg1->NAME),prefix) == 0 )
sort[index++] = ptr_bereg1;
}
/* sort the connectors */
do
{
permut =0;
for (i=0; i<index-1; i++)
{
if (busindex(((bereg_list *)sort[i])->NAME) > busindex(((bereg_list *)sort[i+1])->NAME))
{
save_bereg = sort[i];
sort[i] = sort[i+1];
sort[i+1] = save_bereg;
permut =1;
}
}
}
while (permut);
}
for (i =index-1 ; i>=0 ;i--)
{
new_bereg = beh_addbereg(new_bereg,((bereg_list *)sort[i])->NAME,((bereg_list *)sort[i])->BIABL);
/*printf("------>%s\n",sort[i]->NAME);*/
}
}
destroyauthtable(porTH);
destroyauthtable(regTH);
destroyauthtable(auxTH);
destroyauthtable(buxTH);
ptr_befig->BEPOR = new_bepor;
ptr_befig->BEREG = new_bereg;
ptr_befig->BEAUX = new_beaux;
/*return(ptr_befig);*/
}

View File

@ -0,0 +1,40 @@
/*
* This file is part of the Alliance CAD System
* Copyright (C) Laboratoire LIP6 - Département ASIM
* Universite Pierre et Marie Curie
*
* Home page : http://www-asim.lip6.fr/alliance/
* E-mail support : mailto:alliance-support@asim.lip6.fr
*
* This progam is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* Alliance VLSI CAD System is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the GNU C Library; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
extern char *itostr();
extern void Usage();
extern char *busname();
extern int busindex();
extern long get_index();
extern char *RemoveIndex();
extern void RestoreIndexes();
/*extern void display_locon_list();
extern void display_loins_list();
extern void display_lists();
extern locon_list *get_con();
extern long get_max_index();*/