* genlib/src/dpgen_RAM.c,

genlib/src/dpgen_ROM.c,
   genlib/src/dpgen_ROM_code.y,
   genlib/src/dpgen_Macro.c,
   genlib/src/dgn.h :
   - Ajout des generateurs de RAM & de ROM. Trois nouvelles fonctions :
       DPGEN_RAM
       DPGEN_ROM
       DPGEN_ROMTS
   - La ROM n'est pas encore utilisable : la filasse de codage est en
       commentaire.
   - La lecture des ".vbe" source de la ROM n'a pas ete testee (c'est
       la reprise de celui de grog).
This commit is contained in:
Jean-Paul Chaput 2002-07-15 22:19:26 +00:00
parent dda1ef9a4d
commit c6793adf4f
10 changed files with 2495 additions and 18 deletions

View File

@ -25,7 +25,7 @@ dnl Almost ten years since I wrote this stuff, I just can't
dnl believe it dnl believe it
dnl Date : 01/02/2002 dnl Date : 01/02/2002
dnl Author : Frederic Petrot <Frederic.Petrot@lip6.fr> dnl Author : Frederic Petrot <Frederic.Petrot@lip6.fr>
dnl $Id: configure.in,v 1.4 2002/05/24 18:34:23 jpc Exp $ dnl $Id: configure.in,v 1.5 2002/07/15 22:19:11 jpc Exp $
dnl dnl
dnl dnl
AC_INIT(src/genlib.c) AC_INIT(src/genlib.c)
@ -38,6 +38,9 @@ AC_C_CONST
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_PROG_RANLIB AC_PROG_RANLIB
AC_CHECK_PROG(SED, sed, sed) AC_CHECK_PROG(SED, sed, sed)
AM_PROG_LEX
AC_PROG_YACC
AC_PROG_MAKE_SET
changequote(,)dnl changequote(,)dnl
if test -z $SED ; then if test -z $SED ; then

View File

@ -0,0 +1,75 @@
.\\" auto-generated by docbook2man-spec $Revision: 1.1 $
.TH "DPGEN_SHROT" "3" "17 June 2002" "ASIM/LIP6" "Alliance - genlib User's Manual"
.SH NAME
DPGEN_SHROT \- Shift/Rotation Macro-Generator
.SH SYNOPSIS
\fB#include <genlib.h>
.sp
void GENLIB_MACRO(
.nf
.ta 7n +20n
DPGEN_SHROT,
char *\fImodelname\fB,
long \fIflags\fB,
long \fIN\fB
);
.fi
\fR.SH "DESCRIPTION"
.PP
Generate a \fIN\fR bits shift/rotation operator with name \fImodelname\fR.
.PP
How it works :
.TP 0.2i
\(bu
if the op[0] signal is set to '1'
right shift/rotation occurs, otherwise left shift/rotation
occurs.
.TP 0.2i
\(bu
if the op[1] signal is set to '1' performs
an arithmetic shift (only meaningful in case of a right shift).
.TP 0.2i
\(bu
if the op[2] signal is set to '1' performs
a rotation, otherwise performs a shift.
.TP 0.2i
\(bu
shamt : specifies the shift amount. The width of this signal
(\fIY\fR) is computed from the operator's width :
Y = ceil(log2(N)) - 1.
.PP
.SS "TERMINAL NAMES"
.IP 1.
op : select the kind of shift/rotation (input, 3 bit).
.IP 2.
shamt : the shift amount (input, \fIY\fR bits).
.IP 3.
: value to shift (input, \fIN\fR bits).
.IP 4.
: output (\fIN\fR bits).
.IP 5.
vdd : power.
.IP 6.
vss : ground.
.SH "EXAMPLE"
.PP
.sp
.nf
GENLIB_MACRO(DPGEN_SHROT, "rot25",
F_BEHAV|F_PLACE,
25);
GENLIB_LOINS("rot25",
"instance1_rot25",
"op[2:0]",
"shamt[4:0]",
"x[31:0]",
"y[31:0]",
"vdd", "vss", NULL);
.sp
.fi
.SH "SEE ALSO"
.PP
\fBGENLIB_MACRO\fR(3),
\fBgenlib\fR(1)

View File

@ -1,4 +1,6 @@
AM_CFLAGS = @ALLIANCE_CFLAGS@ AM_CFLAGS = @ALLIANCE_CFLAGS@
AM_YFLAGS =
AM_LFLAGS =
lib_LIBRARIES = libMgn.a lib_LIBRARIES = libMgn.a
include_HEADERS = mgn.h mbkgen.h genlib.h dgn.h include_HEADERS = mgn.h mbkgen.h genlib.h dgn.h
libMgn_a_SOURCES = genlib.c \ libMgn_a_SOURCES = genlib.c \
@ -14,6 +16,9 @@ libMgn_a_SOURCES = genlib.c \
dpgen_Regular.c \ dpgen_Regular.c \
dpgen_RF1.c \ dpgen_RF1.c \
dpgen_RF2.c \ dpgen_RF2.c \
dpgen_RAM.c \
dpgen_ROM.c \
dpgen_ROM_code.y \
dpgen_Nul.c \ dpgen_Nul.c \
dpgen_Macro.c \ dpgen_Macro.c \
dpgen_Adder.c \ dpgen_Adder.c \
@ -21,10 +26,10 @@ libMgn_a_SOURCES = genlib.c \
dpgen_Shifter.c dpgen_Shifter.c
bin_SCRIPTS = genlib bin_SCRIPTS = genlib
CLEANFILES = genlib CLEANFILES = genlib y.output dpgen_ROM_code.c dpgen_ROM_code.h
genlib : ${srcdir}/genlib.sh genlib : ${srcdir}/genlib.sh
${SED} 's,__ALLIANCE_INSTALL_DIR__,$(ALLIANCE_INSTALL_DIR),' $< > $@ ${SED} 's,__ALLIANCE_INSTALL_DIR__,$(prefix),' $< > $@
chmod a+x $@ chmod a+x $@
EXTRA_DIST = genlib.sh EXTRA_DIST = genlib.sh dpgen_ROM_code.h

View File

@ -1,5 +1,5 @@
/* /*
* $Id: dgn.h,v 1.2 2002/06/17 09:40:27 fred Exp $ * $Id: dgn.h,v 1.3 2002/07/15 22:19:25 jpc Exp $
* *
* /----------------------------------------------------------------\ * /----------------------------------------------------------------\
* | | * | |
@ -91,14 +91,17 @@
# define DPGEN_RF2R0 34 # define DPGEN_RF2R0 34
# define DPGEN_RF2D 35 # define DPGEN_RF2D 35
# define DPGEN_RF2DR0 36 # define DPGEN_RF2DR0 36
# define DPGEN_DFF 37 # define DPGEN_RAM 37
# define DPGEN_DFFT 38 # define DPGEN_ROM 38
# define DPGEN_SFF 39 # define DPGEN_ROMTS 39
# define DPGEN_SFFT 40 # define DPGEN_DFF 40
# define DPGEN_ROM2 41 # define DPGEN_DFFT 41
# define DPGEN_ROM4 42 # define DPGEN_SFF 42
# define DPGEN_SHROT 43 # define DPGEN_SFFT 43
# define DPGEN_UNKNOWN 44 # define DPGEN_ROM2 44
# define DPGEN_ROM4 45
# define DPGEN_SHROT 46
# define DPGEN_UNKNOWN 47
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
/* /*
* $Id: dpgen_Defs.h,v 1.1 2002/04/29 13:40:54 jpc Exp $ * $Id: dpgen_Defs.h,v 1.2 2002/07/15 22:19:25 jpc Exp $
* *
* /----------------------------------------------------------------\ * /----------------------------------------------------------------\
* | | * | |
@ -63,6 +63,27 @@
extern void dpgen_RF2 __FP((long aFunction, va_list aAL)); extern void dpgen_RF2 __FP((long aFunction, va_list aAL));
/* ----------------------------------------------------------------------
* Module : "dpgen_RAM.c"
*/
extern void dpgen_RAM __FP((long aFunction, va_list aAL));
/* ----------------------------------------------------------------------
* Module : "dpgen_ROM.c"
*/
extern void dpgen_ROM __FP((long aFunction, va_list aAL));
extern void dpgen_ROM_code __FP(( char *s
, long nb
, long nw
, long r
, long msb
, long *data
));
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
* Module : "dpgen_Shifter.c" * Module : "dpgen_Shifter.c"
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: dpgen_Macro.c,v 1.2 2002/06/17 09:40:27 fred Exp $ * $Id: dpgen_Macro.c,v 1.3 2002/07/15 22:19:25 jpc Exp $
* *
* /----------------------------------------------------------------\ * /----------------------------------------------------------------\
* | | * | |
@ -69,6 +69,8 @@ extern char *function_To_String(aFunction)
case DPGEN_SHIFT: return ("DPGEN_SHIFT"); case DPGEN_SHIFT: return ("DPGEN_SHIFT");
case DPGEN_NUL: return ("DPGEN_NUL"); case DPGEN_NUL: return ("DPGEN_NUL");
case DPGEN_RF1: return ("DPGEN_RF1"); case DPGEN_RF1: return ("DPGEN_RF1");
case DPGEN_RAM: return ("DPGEN_RAM");
case DPGEN_ROM: return ("DPGEN_ROM");
case DPGEN_FIFO: return ("DPGEN_FIFO"); case DPGEN_FIFO: return ("DPGEN_FIFO");
default: return ("unknown?!"); default: return ("unknown?!");
} }
@ -88,7 +90,7 @@ extern void GENLIB_MACRO __FPV((long aFunction, ...))
if (firstCall) { if (firstCall) {
firstCall = FALSE; firstCall = FALSE;
util_init (C_VerboseLevel0, F_DUMPCORE, "dpgen"); util_init (C_VerboseLevel0, F_DUMPCORE, "genlib");
} }
@ -171,10 +173,19 @@ extern void GENLIB_MACRO __FPV((long aFunction, ...))
case DPGEN_RF2DR0: case DPGEN_RF2DR0:
dpgen_RF2 (aFunction, aAL); dpgen_RF2 (aFunction, aAL);
break; break;
case DPGEN_RAM:
dpgen_RAM (aFunction, aAL);
break;
case DPGEN_ROM:
dpgen_ROM (aFunction, aAL);
break;
case DPGEN_ROMTS:
dpgen_ROM (aFunction, aAL);
break;
default: default:
eprinth (NULL); eprinth (NULL);
eprintf ("GENLIB_MACRO: Unknown function Id: %ld.\n", aFunction); eprintf ("GENLIB_MACRO: Unknown function Id: %ld.\n", aFunction);
eprints (" Please have a look to \"dgnVRR.h\" in which all "); eprints (" Please have a look to \"dgn.h\" in which all ");
eprints ( "authorized\n values are listed.\n"); eprints ( "authorized\n values are listed.\n");
EXIT (1); EXIT (1);
} }

View File

@ -0,0 +1,629 @@
// auteur Alain Greiner
//
// Derniere modification 20/05/2001
//
// Memoire statique simple acces respectant le gabarit SXLIB
// pour pouvoir etre utilise dans un chemin de donnees.
// Le programme genere une net-list et un placement optimise.
// Il y a 2 parametres :
// - nmot definit le nombre de mots
// il doit etre multiple de 8, >= 32 et =< 256
// - nbit definit le nombre de bits
// il doit etre pair, non nul et =< 64
//
// On utilise les cellules suivantes :
// colonne d'entree
// - ram_prech_data
// - ram_prech_buf0
// - ram_prech_buf1
// - ram_prech_dec
// - ram_mem_data
// - ram_mem_buf0
// - ram_mem_buf1
// - ram_mem_deci
// - ram_mem_dec2
// - ram_mem_dec3
// - ram_mem_dec4
// - ram_mem_dec5
// - ram_sense_data
// - ram_sense_buf0
// - ram_sense_buf1
// - ram_sense_decad12
// - ram_sense_decad2
// - ram_sense_decad3
// - ram_sense_decad4
// - ram_sense_decad5
#include "util_Defs.h"
#include "dpgen_Defs.h"
#define genNAME s64printf
//----------------------------------------------------------------
// DEBUT PROGRAMME PRINCIPAL
//----------------------------------------------------------------
// aFunction : le type :
// DPGEN_RAM
//
// aAL : liste des parametres :
// model_name : nom de modele.
// flags : indexation des connecteurs.
// nbit : nombre de bits (largeur du bus).
// nmot : nombre de mots.
// - le nombre de mots doit etre un multiple de 8 compris entre 32 et 256
// - le nombre de bits doit etre pair, non nul et =< 64
//----------------------------------------------------------------
extern void dpgen_RAM (aFunction, aAL)
long aFunction;
va_list aAL;
{
int nmot; /* nombre de mots */
int nbit; /* nombre de bits */
char *model_name; /* nom de modele */
long flags;
int HCELL = 50;
int bottom,i,j,k;
int sym1,sym2;
int adrange;
char x3[10];
char x4[10];
char x5[10];
char x6[10];
char x7[10];
//////////////////////////////////////////////////////////
//
// acquisition et verification des parametres
//
//////////////////////////////////////////////////////////
model_name = va_arg (aAL, char*);
flags = va_arg (aAL, long );
nbit = va_arg (aAL, long );
nmot = va_arg (aAL, long );
if ((nmot%8 != 0) || (nmot > 256) || (nmot < 32)) {
eprinth ("GENLIB_MACRO (DPGEN_RAM, ...)");
eprintf ("\n The word number (nword := %d) ", nmot);
eprints ("must be multiple of 8, at least 32");
eprints ("\n and no larger than 256.\n");
EXIT (1);
}
if ((nbit%2 == 1) || (nbit > 64) || (nbit < 2)) {
eprinth ("GENLIB_MACRO (DPGEN_RAM, ...)");
eprintf ("\n The bus width (nbit := %d) ", nbit);
eprints ("must be even and no larger than 64.\n");
EXIT (1);
}
GENLIB_DEF_PHFIG(model_name);
GENLIB_DEF_LOFIG(model_name);
///////////////////////////////////////////////////////////////////
//
// Definition de l'interface logique
//
///////////////////////////////////////////////////////////////////
if (nmot > 128) adrange = 8;
else if (nmot > 64) adrange = 7;
else if (nmot > 32) adrange = 6;
else adrange = 5;
GENLIB_LOCON("ck",IN,"ck");
GENLIB_LOCON("w",IN,"w");
GENLIB_LOCON("selram",IN,"selram");
for (i=0;i<adrange;i++){
GENLIB_LOCON(GENLIB_NAME("ad[%d]",adrange-1-i),IN,
GENLIB_NAME("ad%d",adrange-1-i));
}
for (i=0;i<nbit;i++){
GENLIB_LOCON(GENLIB_NAME("datain[%d]",nbit-1-i),IN,
GENLIB_NAME("datain%d",nbit-1-i));
}
for (i=0;i<nbit;i++){
GENLIB_LOCON(GENLIB_NAME("dataout[%d]",nbit-1-i),TRISTATE,
GENLIB_NAME("dataout%d",nbit-1-i));
}
GENLIB_LOCON("vdd",IN,"vdd");
GENLIB_LOCON("vss",IN,"vss");
///////////////////////////////////////////////////////////////////
//
// placement des lignes de bit
//
///////////////////////////////////////////////////////////////////
bottom = 0;
for(i=0;i<nbit;i++){
switch(i%2){
case 0: // lignes paires
sym1 = NOSYM;
sym2 = SYM_X;
break;
case 1: // lignes impaires
sym1 = SYM_Y;
sym2 = SYMXY;
break;
}
GENLIB_PLACE("ram_prech_data",GENLIB_NAME("prech%d",i),sym1,0,bottom+i*HCELL);
GENLIB_LOINS("ram_prech_data",GENLIB_NAME("prech%d",i),
"prech",
GENLIB_NAME("bus0_%d",i),
GENLIB_NAME("nbus0_%d",i),
GENLIB_NAME("bus1_%d",i),
GENLIB_NAME("nbus1_%d",i),
"vdd",
"vss",NULL);
for (j=0 ; j<nmot ; j+=4){
GENLIB_PLACE_RIGHT("ram_mem_data",GENLIB_NAME("bit_%d_%d",i,j),sym2);
GENLIB_LOINS("ram_mem_data",GENLIB_NAME("bit_%d_%d",i,j),
GENLIB_NAME("selx%d",j),
GENLIB_NAME("bus0_%d",i),
GENLIB_NAME("nbus0_%d",i),
GENLIB_NAME("bus1_%d",i),
GENLIB_NAME("nbus1_%d",i),
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("ram_mem_data",GENLIB_NAME("bit_%d_%d",i,j+2),sym1);
GENLIB_LOINS("ram_mem_data",GENLIB_NAME("bit_%d_%d",i,j+2),
GENLIB_NAME("selx%d",j+2),
GENLIB_NAME("bus0_%d",i),
GENLIB_NAME("nbus0_%d",i),
GENLIB_NAME("bus1_%d",i),
GENLIB_NAME("nbus1_%d",i),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_data",GENLIB_NAME("sense%d",i),sym1);
GENLIB_LOINS("ram_sense_data",GENLIB_NAME("sense%d",i),
GENLIB_NAME("bus0_%d",i),
GENLIB_NAME("nbus0_%d",i),
GENLIB_NAME("bus1_%d",i),
GENLIB_NAME("nbus1_%d",i),
"ad0x",
"nad0x",
"sensex",
"nsensex",
"prechbis",
"writex",
GENLIB_NAME("datain%d",i),
GENLIB_NAME("dataout%d",i),
"vdd",
"vss",NULL);
}
///////////////////////////////////////////////////////////////////
//
// placement de la premiere ligne de la zone des buffers
//
///////////////////////////////////////////////////////////////////
bottom = nbit * HCELL;
GENLIB_PLACE("ram_prech_buf0","prechbuf0",NOSYM,0,bottom);
GENLIB_LOINS("ram_prech_buf0","prechbuf0",
"nckx",
"prech",
"vdd",
"vss",NULL);
for (j=0 ; j<nmot ; j+=4){
GENLIB_PLACE_RIGHT("ram_mem_buf0",GENLIB_NAME("buf0_%d",j),SYM_X);
GENLIB_LOINS("ram_mem_buf0",GENLIB_NAME("buf0_%d",j),
GENLIB_NAME("nsel%d",j),
GENLIB_NAME("selx%d",j),
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("ram_mem_buf0",GENLIB_NAME("buf0_%d",j+2),NOSYM);
GENLIB_LOINS("ram_mem_buf0",GENLIB_NAME("buf0_%d",j+2),
GENLIB_NAME("nsel%d",j+2),
GENLIB_NAME("selx%d",j+2),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_buf0","sensebuf0",NOSYM);
GENLIB_LOINS("ram_sense_buf0","sensebuf0",
"ad0",
"nsense",
"nckxbis",
"nwrite",
"ad0x",
"nad0x",
"sensex",
"nsensex",
"prechbis",
"writex",
"vdd",
"vss",NULL);
///////////////////////////////////////////////////////////////////
//
// placement de la deuxieme ligne de la zone des buffers
//
///////////////////////////////////////////////////////////////////
bottom = (nbit+1) * HCELL;
GENLIB_PLACE("ram_prech_buf1","prechbuf1",SYM_Y,0,bottom);
GENLIB_LOINS("ram_prech_buf1","prechbuf1",
"nck",
"nckx",
"vdd",
"vss",NULL);
for (j=0 ; j<nmot ; j+=4){
GENLIB_PLACE_RIGHT("ram_mem_buf1",GENLIB_NAME("buf1_%d",j),SYMXY);
GENLIB_LOINS("ram_mem_buf1",GENLIB_NAME("buf1_%d",j),
GENLIB_NAME("sel%d",j),
"nck",
"selramx",
GENLIB_NAME("nsel%d",j),
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("ram_mem_buf1",GENLIB_NAME("buf1_%d",j+2),SYM_Y);
GENLIB_LOINS("ram_mem_buf1",GENLIB_NAME("buf1_%d",j+2),
GENLIB_NAME("sel%d",j+2),
"nck",
"selramx",
GENLIB_NAME("nsel%d",j+2),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_buf1","sensebuf1",SYM_Y);
GENLIB_LOINS("ram_sense_buf1","sensebuf1",
"ck",
"selram",
"w",
"nck",
"selramx",
"nsense",
"nwrite",
"nckxbis",
"vdd",
"vss",NULL);
///////////////////////////////////////////////////////////////////
//
// placement de la premiere ligne de la zone du decodeur
//
///////////////////////////////////////////////////////////////////
bottom = (nbit+2) * HCELL;
GENLIB_PLACE("ram_prech_dec0","prechdecb",NOSYM,0,bottom);
GENLIB_LOINS("ram_prech_dec0","prechdecb",
"vdd",
"vss",NULL);
for (j=0 ; j<nmot ; j+=8){
GENLIB_PLACE_RIGHT("ram_mem_deci",GENLIB_NAME("dec_%d",j),SYM_X);
GENLIB_LOINS("ram_mem_deci",GENLIB_NAME("dec_%d",j),
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"ndec00",
GENLIB_NAME("sel%d",j),
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("ram_mem_deci",GENLIB_NAME("dec_%d",j+2),NOSYM);
GENLIB_LOINS("ram_mem_deci",GENLIB_NAME("dec_%d",j+2),
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"ndec01",
GENLIB_NAME("sel%d",j+2),
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("ram_mem_deci",GENLIB_NAME("dec_%d",j+4),SYM_X);
GENLIB_LOINS("ram_mem_deci",GENLIB_NAME("dec_%d",j+4),
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"ndec10",
GENLIB_NAME("sel%d",j+4),
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("ram_mem_deci",GENLIB_NAME("dec_%d",j+6),NOSYM);
GENLIB_LOINS("ram_mem_deci",GENLIB_NAME("dec_%d",j+6),
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"ndec11",
GENLIB_NAME("sel%d",j+6),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_decad12","sensedecad12",NOSYM);
GENLIB_LOINS("ram_sense_decad12","sensedecad12",
"ad1",
"ad2",
"ndec00",
"ndec01",
"ndec10",
"ndec11",
"vdd",
"vss",NULL);
///////////////////////////////////////////////////////////////////
//
// placement de la deuxieme ligne de la zone du decodeur
//
///////////////////////////////////////////////////////////////////
bottom = (nbit+3) * HCELL;
if (adrange == 8) { /* adresse sur 8 bits : on decode 5 bits */
GENLIB_PLACE("ram_prech_dec0","prechdecu",SYM_Y,0,bottom);
GENLIB_LOINS("ram_prech_dec0","prechdecu",
"vdd",
"vss",NULL);
for(j=0 ; j<nmot ; j+=8) {
if ((j >> 3) % 2 == 0) strcpy(x3,"nad3x");
else strcpy(x3,"ad3x");
if ((j >> 4) % 2 == 0) strcpy(x4,"nad4x");
else strcpy(x4,"ad4x");
if ((j >> 5) % 2 == 0) strcpy(x5,"nad5x");
else strcpy(x5,"ad5x");
if ((j >> 6) % 2 == 0) strcpy(x6,"nad6x");
else strcpy(x6,"ad6x");
if ((j >> 7) % 2 == 0) strcpy(x7,"nad7x");
else strcpy(x7,"ad7x");
GENLIB_PLACE_RIGHT("ram_mem_dec5",GENLIB_NAME("memdec%d",j),SYM_Y);
GENLIB_LOINS("ram_mem_dec5",GENLIB_NAME("memdec%d",j),
x3,
x4,
x5,
x6,
x7,
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_decad5","sensedecad",SYM_Y);
GENLIB_LOINS("ram_sense_decad5","sensedecad",
"ad3",
"ad4",
"ad5",
"ad6",
"ad7",
"ad3x",
"nad3x",
"ad4x",
"nad4x",
"ad5x",
"nad5x",
"ad6x",
"nad6x",
"ad7x",
"nad7x",
"vdd",
"vss",NULL);
}
if (adrange == 7) { /* adresse sur 7 bits : on decode 4 bits */
GENLIB_PLACE("ram_prech_dec0","prechdecu",SYM_Y,0,bottom);
GENLIB_LOINS("ram_prech_dec0","prechdecu",
"vdd",
"vss",NULL);
for(j=0 ; j<nmot ; j+=8) {
if ((j >> 3) % 2 == 0) strcpy(x3,"nad3x");
else strcpy(x3,"ad3x");
if ((j >> 4) % 2 == 0) strcpy(x4,"nad4x");
else strcpy(x4,"ad4x");
if ((j >> 5) % 2 == 0) strcpy(x5,"nad5x");
else strcpy(x5,"ad5x");
if ((j >> 6) % 2 == 0) strcpy(x6,"nad6x");
else strcpy(x6,"ad6x");
GENLIB_PLACE_RIGHT("ram_mem_dec4",GENLIB_NAME("memdec%d",j),SYM_Y);
GENLIB_LOINS("ram_mem_dec4",GENLIB_NAME("memdec%d",j),
x3,
x4,
x5,
x6,
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_decad4","sensedecad",SYM_Y);
GENLIB_LOINS("ram_sense_decad4","sensedecad",
"ad3",
"ad4",
"ad5",
"ad6",
"ad3x",
"nad3x",
"ad4x",
"nad4x",
"ad5x",
"nad5x",
"ad6x",
"nad6x",
"vdd",
"vss",NULL);
}
if (adrange == 6) { /* adresse sur 6 bits : on decode 3 bits */
GENLIB_PLACE("ram_prech_dec0","prechdecu",SYM_Y,0,bottom);
GENLIB_LOINS("ram_prech_dec0","prechdecu",
"vdd",
"vss",NULL);
for(j=0 ; j<nmot ; j+=8) {
if ((j >> 3) % 2 == 0) strcpy(x3,"nad3x");
else strcpy(x3,"ad3x");
if ((j >> 4) % 2 == 0) strcpy(x4,"nad4x");
else strcpy(x4,"ad4x");
if ((j >> 5) % 2 == 0) strcpy(x5,"nad5x");
else strcpy(x5,"ad5x");
GENLIB_PLACE_RIGHT("ram_mem_dec3",GENLIB_NAME("memdec%d",j),SYM_Y);
GENLIB_LOINS("ram_mem_dec3",GENLIB_NAME("memdec%d",j),
x3,
x4,
x5,
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_decad3","sensedecad",SYM_Y);
GENLIB_LOINS("ram_sense_decad3","sensedecad",
"ad3",
"ad4",
"ad5",
"ad3x",
"nad3x",
"ad4x",
"nad4x",
"ad5x",
"nad5x",
"vdd",
"vss",NULL);
}
if (adrange == 5) { /* adresse sur 5 bits : on decode 2 bits */
GENLIB_PLACE("ram_prech_dec0","prechdecu",SYM_Y,0,bottom);
GENLIB_LOINS("ram_prech_dec0","prechdecu",
"vdd",
"vss",NULL);
for(j=0 ; j<nmot ; j+=8) {
if ((j >> 3) % 2 == 0) strcpy(x3,"nad3x");
else strcpy(x3,"ad3x");
if ((j >> 4) % 2 == 0) strcpy(x4,"nad4x");
else strcpy(x4,"ad4x");
GENLIB_PLACE_RIGHT("ram_mem_dec2",GENLIB_NAME("memdec%d",j),SYM_Y);
GENLIB_LOINS("ram_mem_dec2",GENLIB_NAME("memdec%d",j),
x3,
x4,
GENLIB_NAME("ndeca%d",j),
GENLIB_NAME("ndecb%d",j),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("ram_sense_decad2","sensedecad",SYM_Y);
GENLIB_LOINS("ram_sense_decad2","sensedecad",
"ad3",
"ad4",
"ad3x",
"nad3x",
"ad4x",
"nad4x",
"vdd",
"vss",NULL);
}
///////////////////////////////////////////////////////////////////
//
// connecteurs d'alimemtation
//
///////////////////////////////////////////////////////////////////
// Metal 1 face ouest
GENLIB_COPY_UP_SEG("vss","prechdecu","vss");
GENLIB_COPY_UP_SEG("vdd","prechdecu","vdd");
GENLIB_COPY_UP_SEG("vss","prechdecb","vss");
GENLIB_COPY_UP_SEG("vdd","prechdecb","vdd");
GENLIB_COPY_UP_SEG("vss","prechbuf1","vss");
GENLIB_COPY_UP_SEG("vdd","prechbuf1","vdd");
GENLIB_COPY_UP_SEG("vss","prechbuf0","vss");
GENLIB_COPY_UP_SEG("vdd","prechbuf0","vdd");
for(i=0;i<nbit;i++){
GENLIB_COPY_UP_SEG("vss",GENLIB_NAME("prech%d",i),"vss");
GENLIB_COPY_UP_SEG("vdd",GENLIB_NAME("prech%d",i),"vdd");
}
// Metal 1 face est
GENLIB_COPY_UP_SEG("vss","sensedecad","vss");
GENLIB_COPY_UP_SEG("vdd","sensedecad","vdd");
GENLIB_COPY_UP_SEG("vss","sensedecad12","vss");
GENLIB_COPY_UP_SEG("vdd","sensedecad12","vdd");
GENLIB_COPY_UP_SEG("vss","sensebuf1","vss");
GENLIB_COPY_UP_SEG("vdd","sensebuf1","vdd");
GENLIB_COPY_UP_SEG("vss","sensebuf0","vss");
GENLIB_COPY_UP_SEG("vdd","sensebuf0","vdd");
for(i=0;i<nbit;i++){
GENLIB_COPY_UP_SEG("vss",GENLIB_NAME("sense%d",i),"vss");
GENLIB_COPY_UP_SEG("vdd",GENLIB_NAME("sense%d",i),"vdd");
}
// Rappels verticaux Metal 3
GENLIB_PHSEG(CALU3, 12, "vdd", 10, 0, 10, (nbit+4)*HCELL);
GENLIB_PHSEG(CALU3, 12, "vss", 30, 0, 30, (nbit+4)*HCELL);
for(i=0 ; i<(nmot/2) ; i+=2) {
GENLIB_PHSEG(CALU3, 12, "vdd", 55+(25*i), 0, 55+(25*i), (nbit+4)*HCELL);
GENLIB_PHSEG(CALU3, 12, "vss", 80+(25*i), 0, 80+(25*i), (nbit+4)*HCELL);
}
GENLIB_PHSEG(CALU3, 12, "vdd", 155+25*(nmot/2), 0, 155+(25*nmot/2), (nbit+4)*HCELL);
// Rappels horizontaux metal 2
for(i=0;i<nbit;i+=2){
GENLIB_PHSEG(CALU2, 2, "vss", 0, HCELL*i, 200+25*(nmot/2), HCELL*i);
GENLIB_PHSEG(CALU2, 2, "vdd", 0, HCELL*(i+1), 200+25*(nmot/2), HCELL*(i+1));
}
GENLIB_PHSEG(CALU2, 2, "vss", 0, HCELL*nbit, 200+25*(nmot/2), HCELL*nbit);
GENLIB_PHSEG(CALU2, 12, "vdd", 0, HCELL*(nbit+1), 200+25*(nmot/2), HCELL*(nbit+1));
GENLIB_PHSEG(CALU2, 12, "vss", 0, HCELL*(nbit+2), 200+25*(nmot/2), HCELL*(nbit+2));
GENLIB_PHSEG(CALU2, 2, "vdd", 0, HCELL*(nbit+3), 200+25*(nmot/2), HCELL*(nbit+3));
GENLIB_PHSEG(CALU2, 2, "vss", 0, HCELL*(nbit+4), 200+25*(nmot/2), HCELL*(nbit+4));
// la premiere colonne de bigviasa vdd
for(i=0 ; i<nbit ; i+=2) {
GENLIB_PHBIGVIA(VIA12, 10, 50+i*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA23, 10, 50+i*HCELL, 12, 2, "vdd");
}
GENLIB_PHBIGVIA(VIA12, 10, 50+nbit*HCELL, 12, 12, "vdd");
GENLIB_PHBIGVIA(VIA23, 10, 50+nbit*HCELL, 12, 12, "vdd");
GENLIB_PHBIGVIA(VIA12, 10, 150+nbit*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA23, 10, 150+nbit*HCELL, 12, 2, "vdd");
// la premiere colonne de bigviasa vss
for(i=0 ; i<nbit ; i+=2) {
GENLIB_PHBIGVIA(VIA12, 30, i*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA23, 30, i*HCELL, 12, 2, "vss");
}
GENLIB_PHBIGVIA(VIA12, 30, nbit*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA23, 30, nbit*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA12, 30, 100+nbit*HCELL, 12, 12, "vss");
GENLIB_PHBIGVIA(VIA23, 30, 100+nbit*HCELL, 12, 12, "vss");
GENLIB_PHBIGVIA(VIA12, 30, 200+nbit*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA23, 30, 200+nbit*HCELL, 12, 2, "vss");
// les colonnes alternees de bigvia vss et vdd
for(j=0 ; j<nmot/2 ; j+=2) {
for(i=0 ; i<nbit ; i+=2) {
GENLIB_PHBIGVIA(VIA12, 55+j*25, 50+i*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA23, 55+j*25, 50+i*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA12, 80+j*25, i*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA23, 80+j*25, i*HCELL, 12, 2, "vss");
}
GENLIB_PHBIGVIA(VIA12, 55+j*25, 50+nbit*HCELL, 12, 12, "vdd");
GENLIB_PHBIGVIA(VIA23, 55+j*25, 50+nbit*HCELL, 12, 12, "vdd");
GENLIB_PHBIGVIA(VIA12, 55+j*25, 150+nbit*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA23, 55+j*25, 150+nbit*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA12, 80+j*25, nbit*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA23, 80+j*25, nbit*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA12, 80+j*25, 100+nbit*HCELL, 12, 12, "vss");
GENLIB_PHBIGVIA(VIA23, 80+j*25, 100+nbit*HCELL, 12, 12, "vss");
GENLIB_PHBIGVIA(VIA12, 80+j*25, 200+nbit*HCELL, 12, 2, "vss");
GENLIB_PHBIGVIA(VIA23, 80+j*25, 200+nbit*HCELL, 12, 2, "vss");
}
// la derniere colonne de bigviasa vdd
for(i=0 ; i<nbit ; i+=2) {
GENLIB_PHBIGVIA(VIA12, 155+(nmot/2*25), 50+i*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA23, 155+(nmot/2*25), 50+i*HCELL, 12, 2, "vdd");
}
GENLIB_PHBIGVIA(VIA12, 155+(nmot/2*25), 50+nbit*HCELL, 12, 12, "vdd");
GENLIB_PHBIGVIA(VIA23, 155+(nmot/2*25), 50+nbit*HCELL, 12, 12, "vdd");
GENLIB_PHBIGVIA(VIA12, 155+(nmot/2*25), 150+nbit*HCELL, 12, 2, "vdd");
GENLIB_PHBIGVIA(VIA23, 155+(nmot/2*25), 150+nbit*HCELL, 12, 2, "vdd");
GENLIB_DEF_AB(0,0,0,0);
GENLIB_SAVE_PHFIG(model_name);
GENLIB_SAVE_LOFIG(model_name);
}

View File

@ -0,0 +1,988 @@
//
//
// auteur Alain Greiner
//
// Derniere modification 08/05/2001
//
// Generateur de ROM au gabarit SXLIB
// Le programme genere une net-list et un placement optimise.
//
// Le nombre de mots peut prendre cinq valeurs : 64, 128, 256, 512, 1024
// Le nombre de bits est un multiple de 4 et doit etre inferieur ou egal a 64
// On peut avoir une sortie tri-state en option (pour construire des ROMs
// de capacite superieure a 1024 mots.
// La largeur est egale a (nmot/64 * 50) + 150 (+ 20 si option tristate)
// La hauteur est egale a (nbit + 8) * 50 pour 64 ou 128 mots
// (nbit + 9) * 50 pour 256, 512 ou 1024 mots
//
// Les valeurs a encoder dans la ROM sont recuperees dans le tableau data[2048]
// qui contient des "mots" de 32 bits : une valeur est stockee dans deux cases
// consecutives de ce tableau, ce qui permet d'avoir des mots de 64 bits.
// Les poids faibles de la valeur i sont a l'adresse data[2*i]
// Les poids forts de la valeur i sont a l'adresse data[2*i+1]
//
// Les lignes de bit horizontales en ALU2 sont hors grilles et pre-routees
// la ROM respecte le gabarit SXLIB pour ce qui concerne les caissons et les
// alimentations en ALU1 sur les faces est et ouest, mais il n'y a pas
// de continuite des alimentations en ALU1 dans la zone data.
// Pour la partie "donnees", on utilise les cellules suivantes :
// - rom_data_invss
// - rom_data_insel
// - rom_data_midvss
// - rom_data_midsel
// - rom_data_outvss
// - rom_data_outsel
// - rom_data_outvss_ts
// - rom_data_outsel_ts
//
// Pour le decodeur, on utilise les cellules suivantes :
// - rom_dec_adbuf
// - rom_dec_nop
// - rom_dec_prech
// - rom_dec_col2
// - rom_dec_col3
// - rom_dec_col4
// - rom_dec_colbuf
// - rom_dec_line01
// - rom_dec_line23
// - rom_dec_line45
// - rom_dec_line67
// - rom_dec_selmux01
// - rom_dec_selmux23
// - rom_dec_selmux45
// - rom_dec_selmux67
// - rom_dec_selmux67_128
// - rom_dec_selmux01_ts
// - rom_dec_selmux23_ts
// - rom_dec_selmux45_ts
// - rom_dec_selmux67_ts
// - rom_dec_selmux67_128_ts
# include "util_Defs.h"
# include "dpgen_Defs.h"
# include "dgn.h"
# define genNAME s64printf
//----------------------------------------------------------------
// DEBUT PROGRAMME PRINCIPAL
//----------------------------------------------------------------
// aFunction : le type :
// DPGEN_ROM (sans tri-state de sortie)
// DPGEN_ROMTS (avec tri-state de sortie)
//
// aAL : liste des parametres :
// model_name : nom de modele.
// flags : indexation des connecteurs.
// nbit : nombre de bits (largeur du bus).
// nmot : nombre de mots.
//----------------------------------------------------------------
extern void dpgen_ROM (aFunction, aAL)
long aFunction;
va_list aAL;
{
long nmot; /* nombre de mots */
long nbit; /* nombre de bits */
long flags; /* indexation : bit 0 en bas si flags = 0 */
long type;
long HCELL = 50;
long i,j,k,l,iter;
long x1,y1;
long x2,y2;
long sym;
long adrange;
long data[2048];
long value;
char *model_name;
char signame[30];
char cellin[30];
char cellmid[30];
char cellout[30];
char x6[30];
char x7[30];
char x8[30];
char x9[30];
//////////////////////////////////////////////////////////
//
// Lecture et verification des parametres
//
//////////////////////////////////////////////////////////
model_name = va_arg (aAL, char*);
flags = va_arg (aAL, long );
nbit = va_arg (aAL, long );
nmot = va_arg (aAL, long );
switch(aFunction) {
case DPGEN_ROM: type = 0; break;
case DPGEN_ROMTS: type = 1; break;
default :
eprinth ("GENLIB_MACRO (DPGEN_ROM, ...)");
eprintf ("\n Internal error invalid function code := %d.\n", type);
EXIT (1);
}
switch(nmot) {
case 64: adrange = 6; break;
case 128: adrange = 7; break;
case 256: adrange = 8; break;
case 512: adrange = 9; break;
case 1024: adrange = 10; break;
default :
eprinth ("GENLIB_MACRO (DPGEN_ROM, ...)");
eprintf ("\n The word number (nword := %d) ", nmot);
eprints ("can only takes values\n 32, 64, 128, 256, 512 or 1024.\n");
EXIT (1);
}
if ((nbit%4 != 0) || (nbit > 64) || (nbit < 4)) {
eprinth ("GENLIB_MACRO (DPGEN_ROM, ...)");
eprintf ("\n The bus width (nbit := %d) ", nbit);
eprints ("must be even and no larger than 64.\n");
EXIT (1);
}
///////////////////////////////////////////////////////////////////
//
// Acquisition du tableau des valeurs a encoder
//
///////////////////////////////////////////////////////////////////
/* ICI IL FAUT APPELER LE PARSER DE FICHIER .vbe */
/*
for(i=0 ; i<1024 ; i++) {
data[2*i] = i;
data[2*i+1] = 1024 - i;
}
*/
dpgen_ROM_code (model_name, nbit, nmot, 0, 0, data);
///////////////////////////////////////////////////////////////////
//
// Definition de l'interface logique
//
///////////////////////////////////////////////////////////////////
GENLIB_DEF_PHFIG(model_name);
GENLIB_DEF_LOFIG(model_name);
GENLIB_LOCON("ck",IN,"ck");
GENLIB_LOCON("selrom",IN,"selrom");
GENLIB_LOCON(GENLIB_BUS("ad",adrange-1,0),IN,GENLIB_BUS("ad",adrange-1,0));
GENLIB_LOCON(GENLIB_BUS("data",nbit-1,0),IN,GENLIB_BUS("data",nbit-1,0));
GENLIB_LOCON("vdd",IN,"vdd");
GENLIB_LOCON("vss",IN,"vss");
///////////////////////////////////////////////////////////////////
//
// Placement des lignes du plan memoire
//
///////////////////////////////////////////////////////////////////
for(i=0;i<nbit;i++){
switch(i%4){
case 0:
sym = NOSYM;
strcpy(cellin,"rom_data_invss");
strcpy(cellmid,"rom_data_midvss");
if (type == 0) strcpy(cellout,"rom_data_outvss");
else strcpy(cellout,"rom_data_outvss_ts");
break;
case 1:
sym = SYM_Y;
strcpy(cellin,"rom_data_insel");
strcpy(cellmid,"rom_data_midsel");
if (type == 0) strcpy(cellout,"rom_data_outsel");
else strcpy(cellout,"rom_data_outsel_ts");
break;
case 2:
sym = NOSYM;
strcpy(cellin,"rom_data_insel");
strcpy(cellmid,"rom_data_midsel");
if (type == 0) strcpy(cellout,"rom_data_outsel");
else strcpy(cellout,"rom_data_outsel_ts");
break;
case 3:
sym = SYM_Y;
strcpy(cellin,"rom_data_invss");
strcpy(cellmid,"rom_data_midvss");
if (type == 0) strcpy(cellout,"rom_data_outvss");
else strcpy(cellout,"rom_data_outvss_ts");
break;
}
GENLIB_PLACE(cellin,GENLIB_NAME("in%d",i),sym,0,i*HCELL);
GENLIB_LOINS(cellin,GENLIB_NAME("in%d",i),
"prech",
GENLIB_NAME("bit0_%d",i),
GENLIB_NAME("bit1_%d",i),
GENLIB_NAME("bit2_%d",i),
GENLIB_NAME("bit3_%d",i),
GENLIB_NAME("bit4_%d",i),
GENLIB_NAME("bit5_%d",i),
GENLIB_NAME("bit6_%d",i),
GENLIB_NAME("bit7_%d",i),
"vdd",
"vss",NULL);
for (j=0;j<nmot;j+=64){
GENLIB_PLACE_RIGHT(cellmid,GENLIB_NAME("bit%d_%d",i,j),sym);
GENLIB_LOINS(cellmid,GENLIB_NAME("bit%d_%d",i,j),
GENLIB_NAME("line0_%d",j),
GENLIB_NAME("line2_%d",j),
GENLIB_NAME("line4_%d",j),
GENLIB_NAME("line6_%d",j),
GENLIB_NAME("bit0_%d",i),
GENLIB_NAME("bit1_%d",i),
GENLIB_NAME("bit2_%d",i),
GENLIB_NAME("bit3_%d",i),
GENLIB_NAME("bit4_%d",i),
GENLIB_NAME("bit5_%d",i),
GENLIB_NAME("bit6_%d",i),
GENLIB_NAME("bit7_%d",i),
"vss",NULL);
GENLIB_PLACE_RIGHT(cellmid,GENLIB_NAME("bit%d_%d",i,j+32),sym);
GENLIB_LOINS(cellmid,GENLIB_NAME("bit%d_%d",i,j+32),
GENLIB_NAME("line1_%d",j),
GENLIB_NAME("line3_%d",j),
GENLIB_NAME("line5_%d",j),
GENLIB_NAME("line7_%d",j),
GENLIB_NAME("bit0_%d",i),
GENLIB_NAME("bit1_%d",i),
GENLIB_NAME("bit2_%d",i),
GENLIB_NAME("bit3_%d",i),
GENLIB_NAME("bit4_%d",i),
GENLIB_NAME("bit5_%d",i),
GENLIB_NAME("bit6_%d",i),
GENLIB_NAME("bit7_%d",i),
"vss",NULL);
}
GENLIB_PLACE_RIGHT(cellout,GENLIB_NAME("out%d",i),sym);
if (type == 0) {
GENLIB_LOINS(cellout,GENLIB_NAME("out%d",i),
"nprech",
"mux0",
"mux1",
"mux2",
"mux3",
"mux4",
"mux5",
"mux6",
"mux7",
GENLIB_NAME("bit0_%d",i),
GENLIB_NAME("bit1_%d",i),
GENLIB_NAME("bit2_%d",i),
GENLIB_NAME("bit3_%d",i),
GENLIB_NAME("bit4_%d",i),
GENLIB_NAME("bit5_%d",i),
GENLIB_NAME("bit6_%d",i),
GENLIB_NAME("bit7_%d",i),
GENLIB_NAME("data[%d]",i),
"vdd",
"vss",NULL);
}
else {
GENLIB_LOINS(cellout,GENLIB_NAME("out%d",i),
"enx",
"nenx",
"nprech",
"mux0",
"mux1",
"mux2",
"mux3",
"mux4",
"mux5",
"mux6",
"mux7",
GENLIB_NAME("bit0_%d",i),
GENLIB_NAME("bit1_%d",i),
GENLIB_NAME("bit2_%d",i),
GENLIB_NAME("bit3_%d",i),
GENLIB_NAME("bit4_%d",i),
GENLIB_NAME("bit5_%d",i),
GENLIB_NAME("bit6_%d",i),
GENLIB_NAME("bit7_%d",i),
GENLIB_NAME("data[%d]",i),
"vdd",
"vss",NULL);
}
}
///////////////////////////////////////////////////////////////////
//
// Placement des cellules decodeur
//
///////////////////////////////////////////////////////////////////
// Lignes 0 et 1
GENLIB_PLACE("rom_dec_prech","prech",NOSYM,0,nbit*HCELL);
GENLIB_LOINS("rom_dec_prech","prech",
"nck",
"prech",
"nprech",
"vdd",
"vss",NULL);
for (j=0;j<nmot;j+=64) {
if (nmot != 64) strcpy(signame,GENLIB_NAME("col_%d",j));
else strcpy(signame,"vdd");
GENLIB_PLACE_RIGHT("rom_dec_line01",GENLIB_NAME("and01_%d",j),NOSYM);
GENLIB_LOINS("rom_dec_line01",GENLIB_NAME("and01_%d",j),
"nck",
"nck",
"sel0",
"sel1",
signame,
GENLIB_NAME("line0_%d",j),
GENLIB_NAME("line1_%d",j),
"vdd",
"vss",NULL);
}
if(type == 0) {
GENLIB_PLACE_RIGHT("rom_dec_selmux01","selmux01",NOSYM);
GENLIB_LOINS("rom_dec_selmux01","selmux01",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux0",
"sel0",
"mux1",
"sel1",
"vdd",
"vss",NULL);
}
else {
GENLIB_PLACE_RIGHT("rom_dec_selmux01_ts","selmux01",NOSYM);
GENLIB_LOINS("rom_dec_selmux01_ts","selmux01",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux0",
"sel0",
"mux1",
"sel1",
"enx",
"nenx",
"vdd",
"vss",NULL);
}
// Lignes 2 et 3
GENLIB_PLACE("rom_dec_adbuf","ad4",SYM_Y,0,(nbit+3)*HCELL);
GENLIB_LOINS("rom_dec_adbuf","ad4",
"ad[4]",
"a4",
"na4",
"vdd",
"vss",NULL);
GENLIB_PLACE("rom_dec_adbuf","ad5",NOSYM,0,(nbit+2)*HCELL);
GENLIB_LOINS("rom_dec_adbuf","ad5",
"ad[5]",
"a5",
"na5",
"vdd",
"vss",NULL);
for (j=0;j<nmot;j+=64) {
if (nmot != 64) strcpy(signame,GENLIB_NAME("col_%d",j));
else strcpy(signame,"vdd");
GENLIB_PLACE_RIGHT("rom_dec_line23",GENLIB_NAME("and23_%d",j),NOSYM);
GENLIB_LOINS("rom_dec_line23",GENLIB_NAME("and23_%d",j),
"nck",
"nck",
"sel2",
"sel3",
signame,
GENLIB_NAME("line2_%d",j),
GENLIB_NAME("line3_%d",j),
"vdd",
"vss",NULL);
}
if(type == 0) {
GENLIB_PLACE_RIGHT("rom_dec_selmux23","selmux23",NOSYM);
GENLIB_LOINS("rom_dec_selmux23","selmux23",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux2",
"sel2",
"mux3",
"sel3",
"vdd",
"vss",NULL);
}
else {
GENLIB_PLACE_RIGHT("rom_dec_selmux23_ts","selmux23",NOSYM);
GENLIB_LOINS("rom_dec_selmux23_ts","selmux23",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux2",
"sel2",
"mux3",
"sel3",
"enx",
"nenx",
"vdd",
"vss",NULL);
}
// Lignes 4 et 5
GENLIB_PLACE("rom_dec_adbuf","ad2",SYM_Y,0,(nbit+5)*HCELL);
GENLIB_LOINS("rom_dec_adbuf","ad2",
"ad[2]",
"a2",
"na2",
"vdd",
"vss",NULL);
GENLIB_PLACE("rom_dec_adbuf","ad3",NOSYM,0,(nbit+4)*HCELL);
GENLIB_LOINS("rom_dec_adbuf","ad3",
"ad[3]",
"a3",
"na3",
"vdd",
"vss",NULL);
for (j=0;j<nmot;j+=64) {
if (nmot != 64) strcpy(signame,GENLIB_NAME("col_%d",j));
else strcpy(signame,"vdd");
GENLIB_PLACE_RIGHT("rom_dec_line45",GENLIB_NAME("and45_%d",j),NOSYM);
GENLIB_LOINS("rom_dec_line45",GENLIB_NAME("and45_%d",j),
"nck",
"nck",
"sel4",
"sel5",
signame,
GENLIB_NAME("line4_%d",j),
GENLIB_NAME("line5_%d",j),
"vdd",
"vss",NULL);
}
if(type == 0) {
GENLIB_PLACE_RIGHT("rom_dec_selmux45","selmux45",NOSYM);
GENLIB_LOINS("rom_dec_selmux45","selmux45",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux4",
"sel4",
"mux5",
"sel5",
"vdd",
"vss",NULL);
}
else {
GENLIB_PLACE_RIGHT("rom_dec_selmux45_ts","selmux45",NOSYM);
GENLIB_LOINS("rom_dec_selmux45_ts","selmux45",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux4",
"sel4",
"mux5",
"sel5",
"enx",
"nenx",
"vdd",
"vss",NULL);
}
// Lignes 6 et 7
GENLIB_PLACE("rom_dec_adbuf","ad0",SYM_Y,0,(nbit+7)*HCELL);
GENLIB_LOINS("rom_dec_adbuf","ad0",
"ad[0]",
"a0",
"na0",
"vdd",
"vss",NULL);
GENLIB_PLACE("rom_dec_adbuf","ad1",NOSYM,0,(nbit+6)*HCELL);
GENLIB_LOINS("rom_dec_adbuf","ad1",
"ad[1]",
"a1",
"na1",
"vdd",
"vss",NULL);
for (j=0;j<nmot;j+=64) {
if (nmot != 64) strcpy(signame,GENLIB_NAME("col_%d",j));
else strcpy(signame,"vdd");
GENLIB_PLACE_RIGHT("rom_dec_line67",GENLIB_NAME("and67_%d",j),NOSYM);
GENLIB_LOINS("rom_dec_line67",GENLIB_NAME("and67_%d",j),
"nck",
"nck",
"sel6",
"sel7",
signame,
GENLIB_NAME("line6_%d",j),
GENLIB_NAME("line7_%d",j),
"vdd",
"vss",NULL);
}
if((type == 0) && (nmot != 128)) { // pas de sortie tristate
GENLIB_PLACE_RIGHT("rom_dec_selmux67","selmux67",NOSYM);
GENLIB_LOINS("rom_dec_selmux67","selmux67",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux6",
"sel6",
"mux7",
"sel7",
"vdd",
"vss",NULL);
}
if((type != 0) && (nmot != 128)) { // avec sortie tristate
GENLIB_PLACE_RIGHT("rom_dec_selmux67_ts","selmux67",NOSYM);
GENLIB_LOINS("rom_dec_selmux67_ts","selmux67",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ck",
"selrom",
"nck",
"mux6",
"sel6",
"mux7",
"sel7",
"enx",
"nenx",
"vdd",
"vss",NULL);
}
if((type == 0) && (nmot == 128)) { // pas de sortie tristate - 128 mots
GENLIB_PLACE_RIGHT("rom_dec_selmux67_128","selmux67",NOSYM);
GENLIB_LOINS("rom_dec_selmux67_128","selmux67",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ad[6]",
"selrom",
"col_64",
"col_0",
"mux6",
"sel6",
"mux7",
"sel7",
"vdd",
"vss",NULL);
}
if((type != 0) && (nmot == 128)) { // avec sortie tristate - 128 mots
GENLIB_PLACE_RIGHT("rom_dec_selmux67_128_ts","selmux67",NOSYM);
GENLIB_LOINS("rom_dec_selmux67_128_ts","selmux67",
"a0",
"na0",
"a1",
"na1",
"a2",
"na2",
"a3",
"na3",
"a4",
"na4",
"a5",
"na5",
"ad[6]",
"selrom",
"col_64",
"col_0",
"mux6",
"sel6",
"mux7",
"sel7",
"enx",
"nenx",
"vdd",
"vss",NULL);
}
// Ligne 9 dans le cas 1024 mots
if (nmot == 1024) {
GENLIB_PLACE("rom_dec_nop","nop",NOSYM, 0, (nbit+8)*HCELL);
GENLIB_LOINS("rom_dec_nop","nop", "vdd", "vss", NULL);
for (j=0;j<nmot;j+=64) {
if ((j >> 6) % 2 == 0) strcpy(x6,"na6x");
else strcpy(x6,"a6x");
if ((j >> 7) % 2 == 0) strcpy(x7,"na7x");
else strcpy(x7,"a7x");
if ((j >> 8) % 2 == 0) strcpy(x8,"na8x");
else strcpy(x8,"a8x");
if ((j >> 9) % 2 == 0) strcpy(x9,"na9x");
else strcpy(x9,"a9x");
GENLIB_PLACE_RIGHT("rom_dec_col4",GENLIB_NAME("col_%d",j),NOSYM);
GENLIB_LOINS("rom_dec_col4",GENLIB_NAME("col_%d",j),
x6,
x7,
x8,
x9,
GENLIB_NAME("col_%d",j),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf6",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf6",
"ad[6]",
"a6x",
"na6x",
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf7",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf7",
"ad[7]",
"a7x",
"na7x",
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf8",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf8",
"ad[8]",
"a8x",
"na8x",
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf9",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf9",
"ad[9]",
"a9x",
"na9x",
"vdd",
"vss",NULL);
}
// Ligne 9 dans le cas 512 mots
if (nmot == 512) {
GENLIB_PLACE("rom_dec_nop","nop",NOSYM, 0, (nbit+8)*HCELL);
GENLIB_LOINS("rom_dec_nop","nop", "vdd", "vss", NULL);
for (j=0;j<nmot;j+=64) {
if ((j >> 6) % 2 == 0) strcpy(x6,"na6x");
else strcpy(x6,"a6x");
if ((j >> 7) % 2 == 0) strcpy(x7,"na7x");
else strcpy(x7,"a7x");
if ((j >> 8) % 2 == 0) strcpy(x8,"na8x");
else strcpy(x8,"a8x");
GENLIB_PLACE_RIGHT("rom_dec_col3",GENLIB_NAME("col_%d",j),NOSYM);
GENLIB_LOINS("rom_dec_col3",GENLIB_NAME("col_%d",j),
x6,
x7,
x8,
GENLIB_NAME("col_%d",j),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf6",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf6",
"ad[6]",
"a6x",
"na6x",
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf7",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf7",
"ad[7]",
"a7x",
"na7x",
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf8",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf8",
"ad[8]",
"a8x",
"na8x",
"vdd",
"vss",NULL);
}
// Ligne 9 dans le cas 256 mots
if (nmot == 256) {
GENLIB_PLACE("rom_dec_nop","nop",NOSYM, 0, (nbit+8)*HCELL);
GENLIB_LOINS("rom_dec_nop","nop", "vdd", "vss", NULL);
for (j=0;j<nmot;j+=64) {
if ((j >> 6) % 2 == 0) strcpy(x6,"na6x");
else strcpy(x6,"a6x");
if ((j >> 7) % 2 == 0) strcpy(x7,"na7x");
else strcpy(x7,"a7x");
GENLIB_PLACE_RIGHT("rom_dec_col2",GENLIB_NAME("col_%d",j),NOSYM);
GENLIB_LOINS("rom_dec_col2",GENLIB_NAME("col_%d",j),
x6,
x7,
GENLIB_NAME("col_%d",j),
"vdd",
"vss",NULL);
}
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf6",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf6",
"ad[6]",
"a6x",
"na6x",
"vdd",
"vss",NULL);
GENLIB_PLACE_RIGHT("rom_dec_colbuf","colbuf7",NOSYM);
GENLIB_LOINS("rom_dec_colbuf","colbuf7",
"ad[7]",
"a7x",
"na7x",
"vdd",
"vss",NULL);
}
///////////////////////////////////////////////////////////////////
//
// Routage des rappels d'alimentation et des signaux hors grille
//
///////////////////////////////////////////////////////////////////
y1 = nbit*HCELL;
if(nmot > 128) y2 = (nbit + 9)*HCELL;
else y2 = (nbit + 8)*HCELL;
if(type == 0) x2 = (nmot/64*50) + 150;
else x2 = (nmot/64*50) + 170;
// alimentations verticales ALU3
GENLIB_PHSEG(CALU3,12,"vdd", 10, 0, 10, y2);
GENLIB_PHSEG(CALU3, 2,"vss", 20, 0, 20, y2);
GENLIB_PHSEG(CALU3, 2,"vss", 30, 0, 30, y2);
for(j=0 ; j<nmot ; j+=64) {
GENLIB_PHSEG(CALU3, 2,"vss", 55+(50*j/64), 0, 55+(50*j/64), y2);
GENLIB_PHSEG(CALU3, 2,"vss", 80+(50*j/64), 0, 80+(50*j/64), y2);
}
if(type == 0) {
GENLIB_PHSEG(CALU3, 2,"vss", 125+(nmot/64*50), 0, 125+(nmot/64*50), y1);
GENLIB_PHSEG(CALU3, 2,"vdd", 135+(nmot/64*50), 0, 135+(nmot/64*50), y1);
GENLIB_PHSEG(CALU3, 2,"vdd", 145+(nmot/64*50), 0, 145+(nmot/64*50), y1);
}
else {
GENLIB_PHSEG(CALU3, 2,"vss", 135+(nmot/64*50), 0, 135+(nmot/64*50), y1);
GENLIB_PHSEG(CALU3, 2,"vdd", 145+(nmot/64*50), 0, 145+(nmot/64*50), y1);
GENLIB_PHSEG(CALU3, 2,"vss", 155+(nmot/64*50), 0, 155+(nmot/64*50), y2);
GENLIB_PHSEG(CALU3, 2,"vdd", 165+(nmot/64*50), 0, 165+(nmot/64*50), y2);
}
// alimemtations horizontales ALU2
for(i = 0 ; i < nbit ; i+=4) {
GENLIB_PHSEG(CALU2, 2,"vss", 0, i*HCELL, x2, i*HCELL);
}
for(l=0 ; l<8 ; l+=2) {
GENLIB_PHSEG(CALU2, 2,"vss", 0, (nbit+l )*HCELL, x2, (nbit+l )*HCELL);
GENLIB_PHSEG(CALU2, 2,"vdd", 0, (nbit+l+1)*HCELL, x2, (nbit+l+1)*HCELL);
}
GENLIB_PHSEG(CALU2, 2,"vss", 0, (nbit+8)*HCELL, x2, (nbit+8)*HCELL);
if(nmot > 128) GENLIB_PHSEG(CALU2, 2,"vdd", 0, (nbit+9)*HCELL, x2, (nbit+9)*HCELL);
// alimentations horizontales ALU1
for(i=0 ; i<nbit ; i+=2) {
GENLIB_PHSEG(CALU1, 6,"vss", 0 , HCELL*i+ 3, 5, HCELL*i+ 3);
GENLIB_PHSEG(CALU1, 6,"vss", x2-5, HCELL*i+ 3, x2, HCELL*i+ 3);
GENLIB_PHSEG(CALU1, 6,"vdd", 0 , HCELL*i+47, 5, HCELL*i+47);
GENLIB_PHSEG(CALU1, 6,"vdd", x2-5, HCELL*i+47, x2, HCELL*i+47);
GENLIB_PHSEG(CALU1, 6,"vdd", 0 , HCELL*i+53, 5, HCELL*i+53);
GENLIB_PHSEG(CALU1, 6,"vdd", x2-5, HCELL*i+53, x2, HCELL*i+53);
GENLIB_PHSEG(CALU1, 6,"vss", 0 , HCELL*i+97, 5, HCELL*i+97);
GENLIB_PHSEG(CALU1, 6,"vss", x2-5, HCELL*i+97, x2, HCELL*i+97);
}
for(l=0 ; l<8 ; l+=2) {
GENLIB_PHSEG(CALU1, 6,"vss", 0, y1+HCELL*l+ 3, x2, y1+HCELL*l+ 3);
GENLIB_PHSEG(CALU1, 6,"vdd", 0, y1+HCELL*l+47, x2, y1+HCELL*l+47);
GENLIB_PHSEG(CALU1, 6,"vdd", 0, y1+HCELL*l+53, x2, y1+HCELL*l+53);
GENLIB_PHSEG(CALU1, 6,"vss", 0, y1+HCELL*l+97, x2, y1+HCELL*l+97);
}
if(nmot > 128) {
GENLIB_PHSEG(CALU1, 6,"vss", 0, y1+403, x2, y1+403);
GENLIB_PHSEG(CALU1, 6,"vdd", 0, y1+447, x2, y1+447);
}
// routage des lignes de bit horizontales hors grille
for(i=0 ; i<nbit ; i++) {
for(l=0 ; l<8 ; l++) {
x1 = GENLIB_GET_REF_X(GENLIB_NAME("in%d",i),GENLIB_NAME("bit%d",l));
y1 = GENLIB_GET_REF_Y(GENLIB_NAME("in%d",i),GENLIB_NAME("bit%d",l));
x2 = GENLIB_GET_REF_X(GENLIB_NAME("out%d",i),GENLIB_NAME("bit%d",l));
y2 = GENLIB_GET_REF_Y(GENLIB_NAME("out%d",i),GENLIB_NAME("bit%d",l));
GENLIB_PHSEG(ALU2,2,GENLIB_NAME("bit%d_%d",l,i),x1,y1,x2,y2);
}
}
// cablage a 1 de l'entree col dans le cas 64 mots
if(nmot == 64) {
x1 = GENLIB_GET_REF_X("and01_0","refcol");
y1 = GENLIB_GET_REF_Y("and01_0","refcol");
GENLIB_PHBIGVIA(CONT_VIA2,x1,y1,0,0,"vdd");
x1 = GENLIB_GET_REF_X("and23_0","refcol");
y1 = GENLIB_GET_REF_Y("and23_0","refcol");
GENLIB_PHBIGVIA(CONT_VIA2,x1,y1,0,0,"vdd");
x1 = GENLIB_GET_REF_X("and45_0","refcol");
y1 = GENLIB_GET_REF_Y("and45_0","refcol");
GENLIB_PHBIGVIA(CONT_VIA2,x1,y1,0,0,"vdd");
x1 = GENLIB_GET_REF_X("and67_0","refcol");
y1 = GENLIB_GET_REF_Y("and67_0","refcol");
GENLIB_PHBIGVIA(CONT_VIA2,x1,y1,0,0,"vdd");
}
///////////////////////////////////////////////////////////////////
//
// Codage Plan Memoire (codage diffusion)
//
///////////////////////////////////////////////////////////////////
/* a modifier pour creer ces segments dans une figure separee
for(j=0 ; j<nmot ; j+=32) { // boucle sur les cellules
for(k=0 ; k<4 ; k++) { // boucle sur les colonnes
for(l=0 ; l<8 ; l++) { // boucle sur le multiplexeur de sortie
for(i=0 ; i<nbit ; i++) { // boucle sur les bits du mot
x1 = GENLIB_GET_REF_X(GENLIB_NAME("bit%d_%d",i,j),GENLIB_NAME("ref%d%d",k,l));
y1 = GENLIB_GET_REF_Y(GENLIB_NAME("bit%d_%d",i,j),GENLIB_NAME("ref%d%d",k,l));
if(i < 32) {
value = data[2*(j + 8*k + l)];
if((value>>i) % 2 == 0) GENLIB_PHSEG(NTRANS,1,"",x1,y1-3,x1,y1+3);
else GENLIB_PHSEG(POLY ,1,"",x1,y1-3,x1,y1+3);
}
else {
value = data[2*(j + 8*k + l)+1];
if((value>>(i-32)) % 2 == 0) GENLIB_PHSEG(NTRANS,1,"",x1,y1-3,x1,y1+3);
else GENLIB_PHSEG(POLY ,1,"",x1,y1-3,x1,y1+3);
}
}
}
}
}
*/
GENLIB_DEF_AB(0,0,0,0);
GENLIB_SAVE_PHFIG(model_name);
GENLIB_SAVE_LOFIG(model_name);
}

View File

@ -0,0 +1,739 @@
/*
* This file has been stolen from the old full custom ROM generator : Grog...
* Courtesy of Mr Fred Petrot.
*
*/
%{
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <mut.h>
typedef struct vhdl_constant {
struct vhdl_constant *NEXT;
char *string;
char *value;
} dptr;
static char oct2bin[8][4] = {
"000",
"001",
"010",
"011",
"100",
"101",
"110",
"111"
};
static char hex2bin[16][5] = {
"0000",
"0001",
"0010",
"0011",
"0100",
"0101",
"0110",
"0111",
"1000",
"1001",
"1010",
"1011",
"1100",
"1101",
"1110",
"1111"
};
static char *vhdl_line;
static dptr *asc = NULL;
static int line = 0;
static int notempty = 0;
static char datbuf[65];
static char adrbuf[33];
static long nwords, nbits, rf, ibmbull;
static long *ydata;
static long used[8912];
static char aorder; /* vector order for addresses */
static char forder; /* vector order for data out */
static void readvhdlfile();
static int yylex();
static int yyerror();
/* danger :
These three functions use an internal buffer when called, so
avoid calling them twice in the same function call. */
static char *octbin(s)
char *s;
{
static char b[256];
char t[2];
b[0] = t[1] = '\0';
while (*s) {
*t = *s;
strcat(b, oct2bin[strtol(t, (char **)NULL, 8)]);
s++;
}
return b;
}
static char *hexbin(s)
char *s;
{
static char b[256];
char t[2];
b[0] = t[1] = '\0';
while (*s) {
*t = *s;
strcat(b, hex2bin[strtol(t, (char **)NULL, 16)]);
s++;
}
return b;
}
static char *binvert(s)
char *s;
{
static char b[256];
int l = strlen(s) - 1, i = 0;
while (l >= 0)
b[i++] = s[l--];
b[i] = '\0';
return b;
}
static dptr *adddptr(h, s, v)
dptr *h;
char *s, *v;
{
dptr *p;
p = (dptr *)mbkalloc(sizeof(dptr));
p->string = (char *)mbkalloc(strlen(s) + 1);
(void)strcpy(p->string, s);
p->value = (char *)mbkalloc(strlen(v) + 1);
(void)strcpy(p->value, v);
p->NEXT = h;
return p;
}
static char *getdptr(h, s)
dptr *h;
char *s;
{
while (h != NULL) {
if (!strcmp(h->string, s))
return h->value;
h = h->NEXT;
}
return NULL;
}
%}
%union {
int integer;
char string[256];
}
%token CONSTANT OTHERS WHEN SELECT WITH
%token <string> STRING BSTRING OSTRING XSTRING
%type <string> value dvalues avalues
/* needed only to avoid bison `type clash', as I do not care about it */
%type <string> line constant
%%
line : constant
| STRING /* forget it */
| WITH STRING '(' STRING STRING STRING ')' SELECT
{
if (atoi($4) != 0 && atoi($6) != 0)
yyerror("illegal vector boundaries for GRoG");
/* address order choice :
depends upon the bit ordering convention, and what is read
from the file. */
if ((!ibmbull && !strcmp($5, "TO"))
|| (ibmbull && !strcmp($5, "DOWNTO")))
aorder = -1;
else
aorder = 1;
}
| STRING '(' STRING STRING STRING ')' '<' '=' dvalues WHEN avalues ','
{
int i;
#ifdef PARSEOUT
fprintf(stdout, "\n%s when %s\n", datbuf, adrbuf);
#endif
if (atoi($3) != 0 && atoi($5) != 0)
yyerror("illegal vector boundaries for GRoG");
/* output ordering :
internally, the data is seen in the ibmbull convention, since
the generator was designed with this convention I hate
demanded. */
if ((rf && !strcmp($4, "TO")) || (!rf && !strcmp($4, "DOWNTO")))
forder = -1;
else
forder = 1;
notempty = 1;
if (strlen(datbuf) > nbits)
yyerror("data too wide for the number of bits");
if (strlen(adrbuf) > nwords)
yyerror("address too high for the number of words");
if (aorder == -1)
strcpy(adrbuf, binvert(adrbuf));
if (forder == -1)
strcpy(datbuf, binvert(datbuf));
if (nbits < 32) {
i = strtol(adrbuf, 0, 2);
ydata[(i << 1) ] = strtol(datbuf, 0, 2);
ydata[(i << 1) + 1] = 0;
} else {
i = strtol(adrbuf, 0, 2);
ydata[(i << 1) ] = strtol(&datbuf[nbits - 32], 0, 2);
datbuf[nbits - 32] = '\0';
ydata[(i << 1) + 1] = strtol(datbuf, 0, 2);
}
if (!used[i])
used[i] = 1;
else
yyerror("same address used twice");
}
| dvalues WHEN avalues ','
{
int i;
#ifdef PARSEOUT
fprintf(stdout, "\n%s when %s\n", datbuf, adrbuf);
#endif
if (strlen(datbuf) > nbits)
yyerror("data too wide for the number of bits");
if (strlen(adrbuf) > nwords)
yyerror("address too high for the number of words");
if (aorder == -1)
strcpy(adrbuf, binvert(adrbuf));
if (forder == -1)
strcpy(datbuf, binvert(datbuf));
if (nbits < 32) {
i = strtol(adrbuf, 0, 2);
ydata[(i << 1) ] = strtol(datbuf, 0, 2);
ydata[(i << 1) + 1] = 0;
} else {
i = strtol(adrbuf, 0, 2);
ydata[(i << 1) ] = strtol(&datbuf[nbits - 32], 0, 2);
datbuf[nbits - 32] = '\0';
ydata[(i << 1) + 1] = strtol(datbuf, 0, 2);
}
if (!used[i])
used[i] = 1;
else
yyerror("same address used twice");
}
| dvalues WHEN avalues ';'
{
int i;
#ifdef PARSEOUT
fprintf(stdout, "\n%s when %s\n", datbuf, adrbuf);
#endif
if (strlen(datbuf) > nbits)
yyerror("data too wide for the number of bits");
if (strlen(adrbuf) > nwords)
yyerror("address too high for the number of words");
if (aorder == -1)
strcpy(adrbuf, binvert(adrbuf));
if (forder == -1)
strcpy(datbuf, binvert(datbuf));
if (nbits < 32) {
i = strtol(adrbuf, 0, 2);
ydata[(i << 1) ] = strtol(datbuf, 0, 2);
ydata[(i << 1) + 1] = 0;
} else {
i = strtol(adrbuf, 0, 2);
ydata[(i << 1) ] = strtol(&datbuf[nbits - 32], 0, 2);
datbuf[nbits - 32] = '\0';
ydata[(i << 1) + 1] = strtol(datbuf, 0, 2);
}
if (!used[i])
used[i] = 1;
else
yyerror("same address used twice");
}
| dvalues WHEN OTHERS ';'
{
int i;
long j[2];
#ifdef PARSEOUT
fprintf(stdout, "\n%s when others\n", datbuf);
#endif
if (strlen(datbuf) > nbits)
yyerror("data too wide for the number of bits");
if (strlen(adrbuf) > nwords)
yyerror("address too high for the number of words");
if (forder == -1)
strcpy(datbuf, binvert(datbuf));
if (nbits < 32) {
j[0] = strtol(datbuf, 0, 2);
j[1] = 0;
} else {
j[0] = strtol(&datbuf[nbits - 32], 0, 2);
datbuf[nbits - 32] = '\0';
j[1] = strtol(datbuf, 0, 2);
}
for (i = 0; i < nwords; i++)
if (!used[i])
ydata[(i << 1) ] = j[0],
ydata[(i << 1) + 1] = j[1];
}
| {strcpy($$, "Just to have bison shut up");}
;
constant : CONSTANT STRING '=' value ';'
{
asc = adddptr(asc, $2, $4);
}
;
value : BSTRING {strcpy($$, $1);}
| OSTRING {strcpy($$, octbin($1));}
| XSTRING {strcpy($$, hexbin($1));}
;
dvalues : value {strcat(datbuf, $1);}
| value {strcat(datbuf, $1);} '&' dvalues
| STRING
{
char *p = getdptr(asc, $1);
if (p == NULL) {
sprintf(datbuf, "unknown constant %s", $1);
yyerror(datbuf);
}
strcat(datbuf, p);
}
| STRING {
char *p = getdptr(asc, $1);
if (p == NULL) {
sprintf(datbuf, "unknown constant %s", $1);
yyerror(datbuf);
}
strcat(datbuf, p);
} '&' dvalues
;
avalues : value {strcat(adrbuf, $1);}
| value {strcat(adrbuf, $1);} '&' avalues
| STRING
{
char *p = getdptr(asc, $1);
if (p == NULL) {
sprintf(adrbuf, "unknown constant %s", $1);
yyerror(adrbuf);
}
strcat(adrbuf, p);
}
| STRING {
char *p = getdptr(asc, $1);
if (p == NULL) {
sprintf(adrbuf, "unknown constant %s", $1);
yyerror(adrbuf);
}
strcat(adrbuf, p);
} '&' avalues
;
%%
void dpgen_ROM_code(s, nb, nw, r, msb, data)
char *s;
long nb, nw, r, msb;
long *data;
{
FILE *f;
if ((f = mbkfopen(s, "vbe", "r")) == NULL) {
fprintf(stderr, "DPGEN_ROM error : cannot open file %s.vbe\n", s);
EXIT(1);
}
readvhdlfile(f, s, nb, nw, r, msb, data);
if (!notempty) {
(void)fflush(stdout);
(void)fprintf(stdout, "DPGEN_ROM : the file was empty of usable data\n");
(void)fprintf(stdout, " the generated ROM will contain zeros\n");
}
fclose(f);
}
static FILE *vhdlfile;
static void nextvhdlline(f, str)
FILE *f;
char *str;
{
char *s, *t;
int space;
if (fgets(str, 512, f) == (char *)NULL)
return;
s = t = str;
space = isspace(*t) ? 0 : 1;
while (*t)
if (!isspace(*t) || space) {
space = isspace(*t) || *t == ':' ? 0 : 1;
if (islower(*t))
*t = toupper(*t);
*s++ = *t++;
} else {
t++;
space = 0;
}
*s = '\0';
}
static char *nextline()
{
static char str[256];
nextvhdlline(vhdlfile, str);
return str;
}
static void readvhdlfile(f, s, nb, nw, r, msb, data)
FILE *f;
char *s;
long nb, nw, r, msb;
long *data;
{
char str[256];
char *t;
int space, i;
/* globalize variables for yacc */
nwords = nw;
nbits = nb;
rf = r;
ibmbull = msb;
ydata = data;
vhdlfile = f;
/* initialize stuff for OTHERS */
for (i = 0; i < 8912; i++)
used[i] = 0;
while (!feof(f)) {
line++;
nextvhdlline(f, str);
vhdl_line = str;
datbuf[0] = adrbuf[0] = '\0';
yyparse();
}
}
/* lexical analyser */
static int yylex()
{
static int c;
int i = 0;
char *s = vhdl_line; /* remember where to start from */
while (*s && isspace(*s))
s++;
switch (*s) {
case '\0':
#ifdef PARSEOUT
printf("\n");
#endif
return -1; /* expected by yacc as end of entries */
case ';':
c = '\0'; /* reset to nul state */
case '<':
case '=':
case ',':
case '&':
case '(':
case ')':
#ifdef PARSEOUT
printf("(%c)", *s);
#endif
if (*s == '<' && c == SELECT)
c = WITH;
vhdl_line = s;
return *vhdl_line++;
case ':':
s++;
while (*s && *s != '=')
s++;
#ifdef PARSEOUT
printf("(%c)", *s);
#endif
vhdl_line = ++s;
return '=';
case '-':
if (*++s == '-') {
#ifdef PARSEOUT
printf("COMMENT\n");
#endif
return -1;
}
return *vhdl_line++;
case 'C':
while (*s && (isalnum(*s) || *s == '_'))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
if (!strcmp(yylval.string, "CONSTANT")) {
#ifdef PARSEOUT
printf("TOKEN[%s]", yylval.string);
#endif
return c = CONSTANT;
}
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
if (c != SELECT && c != WITH && c != CONSTANT)
*vhdl_line = '\0';
return STRING;
case 'G':
while (*s && (isalnum(*s) || *s == '_'))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
if (!strcmp(yylval.string, "GENERIC")) {
while (1) {
if (!*s)
s = nextline();
if (*s++ == '(') {
s--;
i = 0;
break;
}
}
while (1) {
if (!*s)
s = nextline();
switch (*s++) {
case '(':
i++;
break;
case ')':
i--;
break;
case '\n':
line++;
}
if (i == 0)
break;
}
*vhdl_line = '\0';
return STRING;
}
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
if (c != SELECT && c != WITH && c != CONSTANT)
*vhdl_line = '\0';
return STRING;
case 'W':
while (*s && (isalnum(*s) || *s == '_'))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
if (!strcmp(yylval.string, "WHEN")) {
#ifdef PARSEOUT
printf("TOKEN[%s]", yylval.string);
#endif
return WHEN;
} else if (!strcmp(yylval.string, "WITH")) {
#ifdef PARSEOUT
printf("TOKEN[%s]", yylval.string);
#endif
c = SELECT;
return WITH;
} else {
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
if (c != SELECT && c != WITH && c != CONSTANT)
*vhdl_line = '\0';
return STRING;
}
case 'S':
while (*s && (isalnum(*s) || *s == '_'))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
if (!strcmp(yylval.string, "SELECT")) {
#ifdef PARSEOUT
printf("TOKEN[%s]", yylval.string);
#endif
*vhdl_line = '\0';
return SELECT;
} else {
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
if (c != SELECT && c != WITH && c != CONSTANT)
*vhdl_line = '\0';
return STRING;
}
case 'B':
if (c != SELECT && c != WITH && c != CONSTANT) {
*vhdl_line = '\0';
return STRING;
}
if (*(s + 1) == '"') {
s += 2;
while (*s && *s != '"')
if (*s != '0' && *s != '1')
yyerror("bad binary number");
else
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = ++s;
#ifdef PARSEOUT
printf("BSTRING{%s}", yylval.string);
#endif
return BSTRING;
}
while (*s && (isalnum(*s) || *s == '_'))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
return STRING;
case 'O':
if (c != SELECT && c != WITH && c != CONSTANT) {
*vhdl_line = '\0';
return STRING;
}
if (*(s + 1) == '"') {
s += 2;
while (*s && *s != '"')
if (!isdigit(*s) && *s != '8' && *s != '9')
yyerror("bad octal number");
else
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = ++s;
#ifdef PARSEOUT
printf("OSTRING{%s}", yylval.string);
#endif
return OSTRING;
}
while (*s && (isalnum(*s) || *s == '_'))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
if (!strcmp(yylval.string, "OTHERS")) {
#ifdef PARSEOUT
printf("TOKEN[%s]", yylval.string);
#endif
return OTHERS;
}
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
return STRING;
case 'X':
if (c != SELECT && c != WITH && c != CONSTANT) {
*vhdl_line = '\0';
return STRING;
}
if (*(s + 1) == '"') {
s += 2;
while (*s && *s != '"')
if (!isxdigit(*s))
yyerror("bad hexadecimal number");
else
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = ++s;
#ifdef PARSEOUT
printf("XSTRING{%s}", yylval.string);
#endif
return XSTRING;
}
while (*s && (isalnum(*s) || *s == '_'))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
return STRING;
default:
if (c == SELECT)
while (*s && !isspace(*s) && *s != '(' && *s != ')')
yylval.string[i++] = *s++;
else
while (*s && !isspace(*s))
yylval.string[i++] = *s++;
yylval.string[i] = '\0';
vhdl_line = s;
if (c != SELECT && c != WITH && c != CONSTANT)
*vhdl_line = '\0';
#ifdef PARSEOUT
printf("STRING{%s}", yylval.string);
#endif
return STRING;
}
}
static int yyerror(s)
char *s;
{
fflush(stdout);
fprintf(stderr, "DPGEN_ROM : %s on line %d (%s), '%c'\n",
s, line, vhdl_line, yychar);
exit(1);
}

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# $Id: genlib.sh,v 1.5 2002/06/06 15:46:49 fred Exp $ # $Id: genlib.sh,v 1.6 2002/07/15 22:19:26 jpc Exp $
# #
# /------------------------------------------------------------------\ # /------------------------------------------------------------------\
# | | # | |
@ -218,6 +218,9 @@
ALLIANCE_DEVEL_INCLUDE="-I${ALLIANCE_INSTALL_DIR}/include" ALLIANCE_DEVEL_INCLUDE="-I${ALLIANCE_INSTALL_DIR}/include"
ALLIANCE_DEVEL_LIB="-L${ALLIANCE_INSTALL_DIR}/lib" ALLIANCE_DEVEL_LIB="-L${ALLIANCE_INSTALL_DIR}/lib"
export ALLIANCE_INSTALL_DIR ALLIANCE_DEVEL_INCLUDE ALLIANCE_DEVEL_LIB export ALLIANCE_INSTALL_DIR ALLIANCE_DEVEL_INCLUDE ALLIANCE_DEVEL_LIB
vecho 0 " o Switching to development environment :"
vecho 0 " - ALLIANCE_INSTALL_DIR : ${ALLIANCE_INSTALL_DIR-not set}"
fi fi