importing a2sdf ....
This commit is contained in:
parent
08080f650b
commit
94ed9f1a45
|
@ -0,0 +1,3 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = src
|
|
@ -0,0 +1,35 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(src/IOPath.cpp)
|
||||
|
||||
A2SDF_MAJOR_VERSION=0
|
||||
A2SDF_MINOR_VERSION=9b
|
||||
A2SDF_VERSION=$A2SDF_MAJOR_VERSION.$A2SDF_MINOR_VERSION
|
||||
|
||||
AC_SUBST(A2SDF_MAJOR_VERSION)
|
||||
AC_SUBST(A2SDF_MINOR_VERSION)
|
||||
AC_SUBST(A2SDF_VERSION)
|
||||
|
||||
# For automake.
|
||||
VERSION=$A2SDF_VERSION
|
||||
PACKAGE=emmaus
|
||||
|
||||
dnl Initialize automake stuff
|
||||
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CXX
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
||||
AM_PATH_POPT
|
||||
AM_ALLIANCE
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
src/Makefile
|
||||
])
|
|
@ -0,0 +1,56 @@
|
|||
dnl AM_PATH_POPT([ACTION-IF-FOUND])
|
||||
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
|
||||
AC_DEFUN(AM_PATH_POPT,[
|
||||
AC_ARG_WITH(popt-prefix,
|
||||
[ --with-popt-prefix=PFX Prefix where popt is installed (optional)],
|
||||
popt_prefix="$withval", popt_prefix="")
|
||||
|
||||
if test x$popt_prefix != x ; then
|
||||
POPT_CFLAGS="-I$popt_prefix/include"
|
||||
POPT_LIBS="-L$popt_prefix/lib -lpopt"
|
||||
else
|
||||
POPT_CFLAGS=""
|
||||
POPT_LIBS="-lpopt"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for popt library)
|
||||
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $POPT_CFLAGS"
|
||||
LIBS="$POPT_LIBS $LIBS"
|
||||
|
||||
AC_TRY_RUN([
|
||||
#include <popt.h>
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
struct poptOption options[] = {
|
||||
POPT_AUTOHELP
|
||||
{ NULL, 0, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
poptContext context = poptGetContext("popt-test", argc, argv, options, 0);
|
||||
poptGetNextOpt(context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
],, no_popt=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
|
||||
if test "x$no_popt" = x ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$1], , :, [$1])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([This version of $PACKAGE requires libpopt:
|
||||
ftp://ftp.redhat.com/pub/redhat/code/popt])
|
||||
POPT_CFLAGS=""
|
||||
POPT_LIBS=""
|
||||
dnl ifelse([$2], , :, [$2])
|
||||
fi
|
||||
|
||||
AC_SUBST(POPT_CFLAGS)
|
||||
AC_SUBST(POPT_LIBS)
|
||||
])
|
|
@ -0,0 +1,123 @@
|
|||
#include "A2Sdf.h"
|
||||
|
||||
#include <mut.h>
|
||||
#include <abl.h>
|
||||
#include <mlo.h>
|
||||
#include <mlu.h>
|
||||
#include <abe.h>
|
||||
#include <abv.h>
|
||||
|
||||
/*for inputs to output: Tphl_i_t */
|
||||
#define Tphl "tphl"
|
||||
#define Tpll "tpll"
|
||||
#define Tplh "tplh"
|
||||
#define Tphh "tphh"
|
||||
|
||||
/*for flip-flop*/
|
||||
#define Tsr "tsr" /* tsr_i_ck */
|
||||
#define Tsf "tsf" /* tsf_i_ck */
|
||||
#define Thr "thr" /* thr_i_ck */
|
||||
#define Thf "thf" /* thf_i_ck */
|
||||
#define Tar "tar" /* tar_ck_q */
|
||||
#define Taf "taf" /* taf_ck_q */
|
||||
|
||||
|
||||
A2Sdf::~A2Sdf()
|
||||
{
|
||||
for (TimingCells::iterator it = _timingCells.begin();
|
||||
it != _timingCells.end();
|
||||
it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
A2Sdf::CreateTimingCell(const char* name)
|
||||
{
|
||||
char* Thl, *Tll, *Tlh, *Thh, *tar, *taf;
|
||||
TimingCell* timingCell = new TimingCell(name);
|
||||
_timingCells.push_back(timingCell);
|
||||
|
||||
befig_list* befig = vhdlloadbefig(NULL,const_cast<char*>(name),0/*don't dump message*/);
|
||||
assert(befig);
|
||||
list<const char*> outs;
|
||||
for (const bepor_list* bepor=befig->BEPOR; bepor; bepor=bepor->NEXT)
|
||||
{
|
||||
if (isvdd(bepor->NAME) || isvss(bepor->NAME)) continue;
|
||||
if (bepor->DIRECTION == OUT || bepor->DIRECTION == INOUT)
|
||||
{
|
||||
outs.push_back(bepor->NAME);
|
||||
}
|
||||
}
|
||||
|
||||
if (outs.size() > 1)
|
||||
{
|
||||
cerr << name << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for (list<const char*>::const_iterator lit = outs.begin();
|
||||
lit != outs.end();
|
||||
lit++)
|
||||
{
|
||||
const char* output = *lit;
|
||||
for (const bepor_list* bepor=befig->BEPOR; bepor; bepor=bepor->NEXT)
|
||||
{
|
||||
char* newCon = bepor->NAME;
|
||||
if (newCon == output) continue;
|
||||
if (isvdd(newCon) || isvss(newCon)) continue;
|
||||
if (bepor->DIRECTION == IN || bepor->DIRECTION == INOUT)
|
||||
{
|
||||
char memo=SEPAR;
|
||||
SEPAR='_';
|
||||
Thl=concatname(Tphl,newCon);
|
||||
Tll=concatname(Tpll,newCon);
|
||||
Thh=concatname(Tphh,newCon);
|
||||
Tlh=concatname(Tplh,newCon);
|
||||
tar=concatname(Tar,newCon);
|
||||
taf=concatname(Taf,newCon);
|
||||
Thl=concatname(Thl,output);
|
||||
Tll=concatname(Tll,output);
|
||||
Thh=concatname(Thh,output);
|
||||
Tlh=concatname(Tlh,output);
|
||||
tar=concatname(tar,output);
|
||||
taf=concatname(taf,output);
|
||||
SEPAR=memo;
|
||||
|
||||
for (const begen_list* begen=befig->BEGEN; begen; begen=begen->NEXT)
|
||||
{
|
||||
if (begen->NAME==Tlh || begen->NAME==Thh)
|
||||
{
|
||||
IOPath* ioPath = timingCell->AddIOPath(newCon, output);
|
||||
ioPath->CreateRisingPath(*(int*)begen->VALUE);
|
||||
}
|
||||
if (begen->NAME==Thl || begen->NAME==Tll)
|
||||
{
|
||||
IOPath* ioPath = timingCell->AddIOPath(newCon, output);
|
||||
ioPath->CreateFallingPath(*(int*)begen->VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
A2Sdf::Dump() const
|
||||
{
|
||||
ofstream out(_fileName);
|
||||
out << "(DELAYFILE" << endl
|
||||
<< " (SDFVERSION \"3.0\")" << endl
|
||||
<< " (VENDOR \"ASIM/LIP6\")" << endl
|
||||
<< " (VERSION \"1.0b\")" << endl
|
||||
<< " (TIMESCALE 1 ps)" << endl;
|
||||
for (TimingCells::const_iterator it = _timingCells.begin();
|
||||
it != _timingCells.end();
|
||||
it++)
|
||||
{
|
||||
(*it)->Dump(out);
|
||||
}
|
||||
out << ")" << endl;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef __A2SDF_H
|
||||
#define __A2SDF_H
|
||||
|
||||
#include <list>
|
||||
#include "TimingCell.h"
|
||||
using namespace std;
|
||||
|
||||
class A2Sdf
|
||||
{
|
||||
public:
|
||||
typedef list<TimingCell*> TimingCells;
|
||||
private:
|
||||
const char* _fileName;
|
||||
TimingCells _timingCells;
|
||||
public:
|
||||
A2Sdf(const char* filename):
|
||||
_fileName(filename), _timingCells()
|
||||
{}
|
||||
|
||||
~A2Sdf();
|
||||
void CreateTimingCell(const char* name);
|
||||
void Dump() const;
|
||||
};
|
||||
|
||||
#endif /* __A2SDF_H */
|
|
@ -0,0 +1,58 @@
|
|||
#include "IOPath.h"
|
||||
|
||||
IOPath::~IOPath()
|
||||
{
|
||||
if (_risingPath)
|
||||
delete _risingPath;
|
||||
if (_fallingPath)
|
||||
delete _fallingPath;
|
||||
}
|
||||
|
||||
void
|
||||
IOPath::CreateRisingPath(const int value)
|
||||
{
|
||||
if (!_risingPath)
|
||||
_risingPath = new TimePath(value);
|
||||
else
|
||||
_risingPath->PutValue(value);
|
||||
}
|
||||
|
||||
void
|
||||
IOPath::CreateFallingPath(const int value)
|
||||
{
|
||||
if (!_fallingPath)
|
||||
_fallingPath = new TimePath(value);
|
||||
else
|
||||
_fallingPath->PutValue(value);
|
||||
}
|
||||
|
||||
ofstream&
|
||||
IOPath::Dump(ofstream& out) const
|
||||
{
|
||||
out << " (IOPATH "
|
||||
<< _input
|
||||
<< " "
|
||||
<< _output
|
||||
<< " ";
|
||||
if (_risingPath)
|
||||
{
|
||||
out << "(" << _risingPath->GetWorstValue()
|
||||
<< "::"
|
||||
<< _risingPath->GetBestValue()
|
||||
<< ") ";
|
||||
}
|
||||
else
|
||||
out << "() ";
|
||||
if (_fallingPath)
|
||||
{
|
||||
out << "(" << _fallingPath->GetWorstValue()
|
||||
<< "::"
|
||||
<< _fallingPath->GetBestValue()
|
||||
<< ") ";
|
||||
}
|
||||
else
|
||||
out << "() ";
|
||||
|
||||
out << ")" << endl;
|
||||
return out;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef __IO_PATH_H
|
||||
#define __IO_PATH_H
|
||||
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
class TimePath
|
||||
{
|
||||
friend class IOPath;
|
||||
private:
|
||||
int _worstValue;
|
||||
int _bestValue;
|
||||
TimePath(const int value):
|
||||
_worstValue(value), _bestValue(value)
|
||||
{}
|
||||
void PutValue(const int value)
|
||||
{
|
||||
if (value < _worstValue)
|
||||
_worstValue = value;
|
||||
else
|
||||
if (value > _bestValue)
|
||||
_bestValue = value;
|
||||
}
|
||||
int GetWorstValue() const { return _worstValue; }
|
||||
int GetBestValue() const { return _bestValue; }
|
||||
};
|
||||
|
||||
class IOPath
|
||||
{
|
||||
private:
|
||||
const char* _input;
|
||||
const char* _output;
|
||||
TimePath* _risingPath;
|
||||
TimePath* _fallingPath;
|
||||
public:
|
||||
IOPath(const char* input, const char* output):
|
||||
_input(input), _output(output),
|
||||
_risingPath(NULL), _fallingPath(NULL)
|
||||
{}
|
||||
~IOPath();
|
||||
void CreateRisingPath(const int value);
|
||||
void CreateFallingPath(const int value);
|
||||
ofstream& Dump(ofstream& out) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __IO_PATH_H */
|
|
@ -0,0 +1,16 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
AM_CXXFLAGS = @ALLIANCE_CFLAGS@ @POPT_CFLAGS@
|
||||
|
||||
bin_PROGRAMS = a2sdf
|
||||
|
||||
a2sdf_SOURCES = IOPath.cpp IOPath.h \
|
||||
TimingCell.cpp TimingCell.h \
|
||||
A2Sdf.cpp A2Sdf.h \
|
||||
a2sdf.cpp
|
||||
|
||||
a2sdf_LDADD = @ALLIANCE_LIBS@ @POPT_LIBS@ \
|
||||
-lAbv -lAbe -lAbt -lMlu \
|
||||
-lMcl -lMal -lMsl -lMhl \
|
||||
-lMel -lMvl -lMgl -lRcn \
|
||||
-lMlo -lBdd -lAbl -lAut -lMut
|
|
@ -0,0 +1,42 @@
|
|||
#include "TimingCell.h"
|
||||
|
||||
TimingCell::~TimingCell()
|
||||
{
|
||||
for (IOPaths::iterator it = _ioPaths.begin();
|
||||
it != _ioPaths.end();
|
||||
it++)
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
IOPath*
|
||||
TimingCell::AddIOPath(const char* input, const char* output)
|
||||
{
|
||||
IOPathKey key(input, output);
|
||||
IOPath* ioPath = _ioPaths[key];
|
||||
if (ioPath)
|
||||
return ioPath;
|
||||
ioPath = new IOPath(input, output);
|
||||
_ioPaths[key] = ioPath;
|
||||
return ioPath;
|
||||
}
|
||||
|
||||
ofstream&
|
||||
TimingCell::Dump(ofstream& out)
|
||||
{
|
||||
if (_ioPaths.empty())
|
||||
return out;
|
||||
out << " (CELL" << endl
|
||||
<< " (CELLTYPE \"" << _cellName << "\")" << endl
|
||||
<< " (DELAY" << endl
|
||||
<< " (ABSOLUTE" << endl;
|
||||
for (IOPaths::iterator it = _ioPaths.begin();
|
||||
it != _ioPaths.end();
|
||||
it++)
|
||||
{
|
||||
it->second->Dump(out);
|
||||
}
|
||||
out << " )" << endl
|
||||
<< " )" << endl
|
||||
<< " )" << endl;
|
||||
return out;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef __TIMING_CELL_H
|
||||
#define __TIMING_CELL_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include "IOPath.h"
|
||||
using namespace std;
|
||||
|
||||
struct CompIoPaths
|
||||
{
|
||||
bool operator()(const pair<const char*, const char*> p1,
|
||||
const pair<const char*, const char*> p2) const
|
||||
{
|
||||
return (((int)(p1.first) < (int)(p2.first))
|
||||
|| ((int)(p1.second) < (int)(p2.second)));
|
||||
}
|
||||
};
|
||||
|
||||
class TimingCell
|
||||
{
|
||||
public:
|
||||
typedef pair<const char*, const char*> IOPathKey;
|
||||
typedef map<IOPathKey, IOPath*, CompIoPaths> IOPaths;
|
||||
private:
|
||||
string _cellName;
|
||||
IOPaths _ioPaths;
|
||||
public:
|
||||
TimingCell(const char* name):
|
||||
_cellName(name), _ioPaths()
|
||||
{}
|
||||
~TimingCell();
|
||||
IOPath* AddIOPath(const char* input, const char* output);
|
||||
ofstream& Dump(ofstream& out);
|
||||
};
|
||||
|
||||
#endif /* __TIMING_CELL_H */
|
|
@ -0,0 +1,100 @@
|
|||
#include <dirent.h>
|
||||
#include <iostream>
|
||||
#include <popt.h>
|
||||
#include "mut.h"
|
||||
#include "A2Sdf.h"
|
||||
using namespace std;
|
||||
|
||||
#define EXTENSION ".vbe"
|
||||
|
||||
static void version(void)
|
||||
{
|
||||
cout << "a2sdf(" PACKAGE ") " VERSION << endl;
|
||||
cout << "The " PACKAGE " package comes with NO WARRANTY" << endl;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int showUsage = 0;
|
||||
int showVersion = 0;
|
||||
const char* cellsDir = NULL;
|
||||
const char* sdfFileName = NULL;
|
||||
poptOption options[] = {
|
||||
{ "help", 'h', POPT_ARG_NONE, &showUsage, 0, "print this message", 0},
|
||||
{ "version", 'v', POPT_ARG_NONE, &showVersion, 0, "print the version information", 0},
|
||||
{ 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
poptContext context = poptGetContext("a2sdf", argc, (const char**)argv, options, 0);
|
||||
poptSetOtherOptionHelp(context, "<cellsdir> <sdffilename> ");
|
||||
|
||||
if (int rc = poptGetNextOpt(context) < -1)
|
||||
{
|
||||
cerr << "simann: bad argument " << poptBadOption(context, POPT_BADOPTION_NOALIAS) << ": " << poptStrerror(rc) << endl;
|
||||
cerr << "Try `" << argv[0] << " --help' for more information" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (showVersion)
|
||||
{
|
||||
version();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (showUsage)
|
||||
{
|
||||
version();
|
||||
cout << endl;
|
||||
poptPrintHelp(context, stdout, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cellsDir = poptGetArg(context)) == 0 || poptPeekArg(context) == 0)
|
||||
{
|
||||
poptPrintUsage(context, stderr, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((sdfFileName = poptGetArg(context)) == 0 || poptPeekArg(context) != 0)
|
||||
{
|
||||
poptPrintUsage(context, stderr, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
poptFreeContext(context);
|
||||
|
||||
alliancebanner ("A2Sdf", VERSION, "Alliance to SDF format translator", "2002", ALLIANCE_VERSION);
|
||||
|
||||
|
||||
DIR* dir = opendir (cellsDir);
|
||||
if (!dir)
|
||||
{
|
||||
cerr << "No directory " << cellsDir << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
A2Sdf a2sdf(sdfFileName);
|
||||
|
||||
int extensionlength = strlen(EXTENSION);
|
||||
|
||||
struct dirent* entry = NULL;
|
||||
|
||||
while ((entry = readdir (dir)) != NULL)
|
||||
{
|
||||
char* filename = entry->d_name;
|
||||
int filenamelength = strlen (filename);
|
||||
|
||||
if (filenamelength <= extensionlength) continue;
|
||||
/* is extension of filename accepted */
|
||||
if (strncmp (filename + filenamelength - extensionlength,
|
||||
EXTENSION, extensionlength)) continue;
|
||||
string cellName(filename);
|
||||
cellName.erase( cellName.find(EXTENSION));
|
||||
a2sdf.CreateTimingCell(cellName.c_str());
|
||||
}
|
||||
|
||||
a2sdf.Dump();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue