This commit is contained in:
Ludovic Jacomme 2002-04-04 15:44:53 +00:00
parent df555b5de6
commit a123e60633
84 changed files with 20534 additions and 0 deletions

View File

@ -0,0 +1 @@
SUBDIRS = src man1

View File

@ -0,0 +1,48 @@
dnl
dnl This file is part of the Alliance CAD System
dnl Copyright (C) Laboratoire LIP6 - Département ASIM
dnl Universite Pierre et Marie Curie
dnl
dnl Home page : http://www-asim.lip6.fr/alliance/
dnl E-mail support : mailto:alliance-support@asim.lip6.fr
dnl
dnl This library is free software; you can redistribute it and/or modify it
dnl under the terms of the GNU Library General Public License as published
dnl by the Free Software Foundation; either version 2 of the License, or (at
dnl your option) any later version.
dnl
dnl Alliance VLSI CAD System is distributed in the hope that it will be
dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
dnl Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License along
dnl with the GNU C Library; see the file COPYING. If not, write to the Free
dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dnl
dnl Purpose : Auto stuffing Alliance
dnl Almost ten years since I wrote this stuff, I just can't
dnl believe it
dnl Date : 01/02/2002
dnl Author : Frederic Petrot <Frederic.Petrot@lip6.fr>
dnl $Id: configure.in,v 1.1 2002/04/04 15:44:22 ludo Exp $
dnl
dnl
AC_INIT(src/vh_simulad.c)
AM_INIT_AUTOMAKE(asimut, 3.2)
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_YACC
AM_PROG_LEX
AC_HEADER_STDC
AC_CHECK_HEADERS(strings.h unistd.h)
AC_C_CONST
AC_PROG_RANLIB
AM_ALLIANCE
AC_OUTPUT([
Makefile
src/Makefile
man1/Makefile
])

View File

@ -0,0 +1,2 @@
man_MANS = asimut.1
EXTRA_DIST = $(man_MANS)

View File

@ -0,0 +1,200 @@
.\" $Id: asimut.1,v 1.1 2002/04/04 15:44:24 ludo Exp $
.\" @(#)asimut.1 1.92 Nov 30 1995 UPMC; Pirouz BAZARGAN SABET
.TH ASIMUT 1 "October 1, 1997" "ASIM/LIP6" "cao\-vlsi reference manual"
.SH NAME
.PP
\fBasimut\fP \- A simulation tool for hardware descriptions
.so man1/alc_origin.1
.SH SYNOPSIS
.PP
asimut \fI[options] [root_file] [pattern_file] [result_file]\fP
.SH DESCRIPTION
.PP
\fBasimut\fP is a logical simulation tool for hardware descriptions. It
compiles and loads a complete hardware description written in VHDL (Very
high speed integrated circuits Hardware Description Language). The hardware
description may be structural (a hierarchy of instances) or behavioural.
Only a subset of VHDL is supported. Descriptions that do not
match this subset cause a syntax error during compilation. See \fBvhdl(5)\fP
for detailed information about the supported subset of VHDL.
.PP
Once a hardware description is loaded, \fBasimut\fP looks for a simulation
pattern description file. This file is to be written in \fBpat\fP format.
The file is compiled, loaded and linked with the hardware description. Then,
the simulation is started. When patterns are processed, a result file in
\fBpat\fP format is produced.
.PP
If a save action has been requested in the pattern description file (see
\fBpat (5)\fP), \fBasimut\fP creates also a save file representing the state
of the description at the end of the simulation of the last pattern. The save
file is named \fIroot_file\fP.sav, where \fIroot_file\fP is the name of the
description.
.PP
The save file can be used in a later simulation sequence to initialize the
state of the (same) hardware description before the simulation begins.
Using this mechanism, a large sequence of patterns can be breaked onto
several small sequences, each one initializing the hardware description with
the save file resulted from the previous sequence.
.PP
\fBasimut\fP reads several parameters from the environment variables :
.TP 20
\fIMBK_CATA_LIB\fP
list of directories containing description and pattern files (using $PATH
syntax). The default path is the current directory (see mbk(1)).
.TP 20
\fIMBK_WORK_LIB\fP
specifies the current working directory. The working directory idicates the
place where all output files are written.
.TP 20
\fIMBK_CATAL_NAME\fP
Indicates the file where the behavioral description files are listed. This
file is used to leaf cells of a structural description.(see mbk(1))
.TP 20
\fIMBK_IN_LO\fP
file extension for structural entity. (see mbk(1))
.TP 20
\fIVH_BEHSFX\fP
list of file extensions for behavioural entities (using $PATH syntax). The
default file extension is \fBvbe\fP.
.TP 20
\fIVH_PATSFX\fP
list of file extensions for pattern description entities (using $PATH syntax).
The default file extension is \fBpat\fP.
.TP 20
\fIVH_DLYSFX\fP
list of file extensions for delays description entities (using $PATH syntax).
The default file extension is \fBdly\fP.
.TP 20
\fIVH_MAXERR\fP
maximum number of errors allowed during simulation phase. If the number of
errors occured during simulation reaches VH_MAXERR, \fBasimut\fP stops
the simulation at the end of processing the current pattern. Patterns following
the current pattern remain unprocessed and are reproduced in the result file.
The default value of \fIVH_MAXERR\fP is 10.
.PP
\fIroot_file\fP is the name of the description.
.PP
By default \fBasimut\fP looks for a structural description. It uses the
\fIMBK_IN_LO\fP environment variables to identify both the format and the
extension of structural description files. To load structural VHDL files
\fIMBK_IN_LO\fP must be set to \fBvst\fP.
.PP
To load a pure behavioural description \fB\-b\fP option must be specified. In
such a case \fBasimut\fP loads a data flow VHDL description file. The
\fIVH_BEHSFX\fP environment variable gives the extensions to be used.
.PP
\fIpattern_file\fP is the entity name of the pattern description. The file
containing this entity must be named \fIpattern_file.ext\fP , where \fIext\fP
is one of the extension specified in \fIVH_PATSFX\fP.
.PP
\fIresult_file\fP is the result file produced by \fBasimut\fP. The result file
is a pattern description file with the extension specified by \fIVH_PATSFX\fP.
.SH OPTIONS
.TP 20
\fI\-b\fP
consider the \fIroot_file\fP description as a behavioural description
.TP 20
\fI\-backdelay [min, max, typ] delay_file\fP
use file \fIdelay_file.ext\fP for delays backannotation, where \fIext\fP
is one of the extension specified in \fIVH_DLYSFX\fP.
.TP 20
\fI\-bdd\fP
use BDDs (Binary Decision Diagram) to represent expressions. Using this option
makes the simulation be two times faster but increases memory requirement
.TP 20
\fI\-c\fP
run only the compilation stage
.TP 20
\fI\-core core_file\fP
at the first error encountered, dump the state of the circuit in both an
ascii file (suffixed .cor) and a binary save file (suffixed .sav) which can
be used as initialization file in a further session. If the \fI\-nores\fP
option is specified a pattern file is also produced.
.TP 20
\fI\-dbg[sbpldc]\fP
call the debugger (developper usage)
.TP 20
\fI\-defaultdelay (\-dd)\fP
only null delays (no after clause in the VHDL file) are changed if
backannotated delays or fixed delays are specified.
.TP 20
\fI\-fixeddelay value (\-fd value)\fP
all delays of the description are fixed to \fIvalue\fP.
.TP 20
\fI\-h\fP
display this help file
.TP 20
\fI\-i value\fP
initialize all signals of the description with \fIvalue\fP. \fIValue\fP can
be 0 or 1
.TP 20
\fI\-i save_file\fP
read a save file and use it to initialize the state of the description before
processing the first pattern (the file name cannot be 1 nor 0)
.TP 20
\fI\-inspect instance_name\fP
produce a pattern file corresponding to the interface of the instance
identified by \fIinstance-name\fP
.TP 20
\fI\-l n\fP
print at most \fIn\fP characters for pattern labels. The default value for
\fIn\fP is 15.
.TP 20
\fI\-nores\fP
do not generate result file
.TP 20
\fI\-p n\fP
load at most \fIn\fP patterns from input pattern file each time. Using this
feature reduces memory allocation when a great number of patterns are to be
simulated. In addition after the \fIn\fP patterns have been processed, the
simulation result is printed in the result pattern file. The default value
for \fIn\fP is 0 which makes the whole pattern
file be loaded.
.TP 20
\fI\-t\fP
trace signals when making BDDs (developper usage).
.TP 20
\fI\-transport\fP
use transport delay model (default is inertial).
.TP 20
\fI\-zerodelay (\-zd)\fP
all the delays of the VHDL description are supposed to be null delays.
.SH EXAMPLE
.PP
asimut \-b \-i init_add adder_32 adder_patterns res_add
.PP
simulates a behavioural description held in the file named 'adder_32.vbe
using the pattern file `adder_patterns.pat'. The simulation results is
written into 'res_add.pat' and the description is initialized with the
values contained in 'init_add.sav'.
.SH DIAGNOSTICS
.PP
Register initializations in the pattern file allows changing the value of
a register into a known value. However, using this feature to initialize a
register before executing the first pattern is not recommended. Registers
value (defined by the initialization statement) may be overwritten since
description has not a coherent state before the first pattern.
.SH SEE ALSO
.PP
vhdl(5), pat(5), genpat(1), mbk(1)
.so man1/alc_bug_report.1

View File

@ -0,0 +1,35 @@
CFLAGS = @ALLIANCE_CFLAGS@
lib_LIBRARIES = libCst.a libSch.a
include_HEADERS = cst.h sch.h
libCst_a_SOURCES = \
cst_AddSetElt.c cst_error.c cst_globals.c \
cst_CrtCompSet.c cst_GetFirstElt.c cst.h \
cst_CrtInterSet.c cst_GetLastElt.c cst_IsInSetElt.c \
cst_CrtUnionSet.c cst_GetNextElt.c cst_RemSetElt.c \
cst_DisjunctSet.c cst_GetPrevElt.c cst_SetCmp.c
libSch_a_SOURCES = \
sch_addshent.c sch_CrtSch.c sch_GetCTim.c sch.h sch_rmventry.c \
sch_addshtra.c sch_debug.c sch_GetCTra.c sch_hash.c sch_SetCTim.c \
sch_addshwav.c sch_debug.h sch_GetNTim.c sch_insentry.c \
sch_AddTra.c sch_error.c sch_globals.c sch_inswave.c \
sch_bug.c sch_Free.c sch_GoNTim.c sch_message.c
bin_PROGRAMS = asimut
asimut_LDADD = @ALLIANCE_LIBS@ \
-L. -lMlu -lMal -lMcl -lMel -lMhl -lMgl -lMsl -lMvl -lMlo -lRcn \
-lBvl -lBhl -lBeh -lPpt -lPhl -lPat -lSch -lLog -lMut
asimut_SOURCES = \
beh_delay.h c_fsyn_sr1k_56.c vh_debug.c vh_lspec.c vh_util.h \
beh_setdelay.c c_fsyn_sr4k_10.c vh_debug.h vh_lspec.h vh_xcomm.c \
c_fsyn_sr1k_10.c c_hada_repondeur.c vh_dtype.h vh_ltype.h vh_xcomm.h \
c_fsyn_sr1k_1.c c_sr1k_8a.c vh_globals.c vh_simulad.c vh_xspec.c \
c_fsyn_sr1k_24.c c_sr1k_8b.c vh_globals.h vh_simulad.h vh_xspec.h \
c_fsyn_sr1k_4.c c_sr8k_8a.c vh_init.c vh_util.c

View File

@ -0,0 +1,24 @@
/* ###--------------------------------------------------------------### */
/* file : beh_delay.h */
/* date : Oct 30 1995 */
/* version : v109 */
/* author : Pirouz BAZARGAN SABET & Julien DUNOYER */
/* contents : defines delay definitions used in BEH library */
/* ###--------------------------------------------------------------### */
/* ###------------------------------------------------------### */
/* defines */
/* ###------------------------------------------------------### */
#define BEH_DELAY_FIXED 0x01 /* Fixed delay behavior */
#define BEH_DELAY_RANDOM 0x02 /* Random delay behavior */
#define BEH_DELAY_BACKANOTATED 0x04 /* Backanotated delay behavior */
#define BEH_DELAY_BUFREG 0x08 /* Add Buffer delay after reg */
#define BEH_DELAY_DEFAULT 0x10 /* Default delay behavior */
#define BEH_DELAY_MIN 0x20 /* Minimum delay mode */
#define BEH_DELAY_MAX 0x40 /* Maximum delay mode */
#define BEH_DELAY_TYP 0x80 /* Typical delay mode */
#define BEH_DELAY_FIELD 7 /* delay dico field */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,124 @@
/* ###--------------------------------------------------------------### */
/* file : c_fsyn_sr1k_1.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_fsyn_sr1k_1 */
/* description : 1K synchronous (clock's falling edge) static 1-bit */
/* Ram */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_fsyn_sr1k_1 (pt_lkdins)
struct lkdins *pt_lkdins;
{
char ck ; /* clock */
unsigned int d_out ; /* output 1-bit data */
unsigned int d_in ; /* input 1-bit data */
unsigned int adr ; /* 10-bit address */
char oe ; /* output enable */
char we ; /* write enable */
#define POSI_we 0
#define POSI_oe POSI_we + 1
#define POSI_adr POSI_oe + 1
#define POSI_d_in POSI_adr + 10
#define POSI_ck POSI_d_in + 1
#define POSO_d_out 0
struct local_mem
{
unsigned int LAST_CK ;
unsigned char RAM [1024];
};
struct local_mem *local ;
static void init () ;
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &local, sizeof(struct local_mem), init);
/* ###------------------------------------------------------### */
/* read the current value of input signals (ck) */
/* ###------------------------------------------------------### */
ck = vhx_readinput (pt_lkdins, POSI_ck, 1);
if (ck == 1)
local->LAST_CK = 1;
else
{
/* ###------------------------------------------------------### */
/* check for the falling edge of the clock */
/* ###------------------------------------------------------### */
if (local->LAST_CK == 1)
{
local->LAST_CK = 0;
oe = vhx_readinput (pt_lkdins, POSI_oe , 1);
we = vhx_readinput (pt_lkdins, POSI_we , 1);
adr = vhx_readinput (pt_lkdins, POSI_adr , 10);
if (we == 1)
{
/* ###------------------------------------------------------### */
/* write the input data into the ram */
/* ###------------------------------------------------------### */
d_in = vhx_readinput (pt_lkdins, POSI_d_in, 1);
local->RAM [adr] = d_in;
}
else
{
/* ###------------------------------------------------------### */
/* read the content of the ram and write the result into the */
/* projected value of ouput data */
/* ###------------------------------------------------------### */
if (oe == 1)
d_out = local->RAM [adr];
else
d_out = 0;
vhx_writeout (d_out, pt_lkdins, POSO_d_out, 1);
}
}
}
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,124 @@
/* ###--------------------------------------------------------------### */
/* file : c_fsyn_sr1k_10.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_fsyn_sr1k_10 */
/* description : 1K synchronous (clock's falling edge) static 10-bit */
/* Ram */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_fsyn_sr1k_10 (pt_lkdins)
struct lkdins *pt_lkdins;
{
char ck ; /* clock */
unsigned int d_out ; /* output 10-bit data */
unsigned int d_in ; /* input 10-bit data */
unsigned int adr ; /* 10-bit address */
char oe ; /* output enable */
char we ; /* write enable */
#define POSI_we 0
#define POSI_oe POSI_we + 1
#define POSI_adr POSI_oe + 1
#define POSI_d_in POSI_adr + 10
#define POSI_ck POSI_d_in + 10
#define POSO_d_out 0
struct local_mem
{
unsigned int LAST_CK ;
unsigned short RAM [1024];
};
struct local_mem *local ;
static void init () ;
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &local, sizeof(struct local_mem), init);
/* ###------------------------------------------------------### */
/* read the current value of input signals (ck) */
/* ###------------------------------------------------------### */
ck = vhx_readinput (pt_lkdins, POSI_ck, 1);
if (ck == 1)
local->LAST_CK = 1;
else
{
/* ###------------------------------------------------------### */
/* check for the falling edge of the clock */
/* ###------------------------------------------------------### */
if (local->LAST_CK == 1)
{
local->LAST_CK = 0;
oe = vhx_readinput (pt_lkdins, POSI_oe , 1);
we = vhx_readinput (pt_lkdins, POSI_we , 1);
adr = vhx_readinput (pt_lkdins, POSI_adr , 10);
if (we == 1)
{
/* ###------------------------------------------------------### */
/* write the input data into the ram */
/* ###------------------------------------------------------### */
d_in = vhx_readinput (pt_lkdins, POSI_d_in, 10);
local->RAM [adr] = d_in;
}
else
{
/* ###------------------------------------------------------### */
/* read the content of the ram and write the result into the */
/* projected value of ouput data */
/* ###------------------------------------------------------### */
if (oe == 1)
d_out = local->RAM [adr];
else
d_out = 0;
vhx_writeout (d_out, pt_lkdins, POSO_d_out, 10);
}
}
}
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,125 @@
/* ###--------------------------------------------------------------### */
/* file : c_fsyn_sr1k_24.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_fsyn_sr1k_24 */
/* description : 1K synchronous (clock's falling edge) static 24-bit */
/* Ram */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_fsyn_sr1k_24 (pt_lkdins)
struct lkdins *pt_lkdins;
{
char ck ; /* clock */
unsigned int d_out ; /* output 24-bit data */
unsigned int d_in ; /* input 24-bit data */
unsigned int adr ; /* 10-bit address */
char oe ; /* output enable */
char we ; /* write enable */
#define POSI_we 0
#define POSI_oe POSI_we + 1
#define POSI_adr POSI_oe + 1
#define POSI_d_in POSI_adr + 10
#define POSI_ck POSI_d_in + 24
#define POSO_d_out 0
struct local_mem
{
unsigned int LAST_CK ;
unsigned int RAM [1024];
};
struct local_mem *local ;
static void init () ;
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &local, sizeof(struct local_mem), init);
/* ###------------------------------------------------------### */
/* read the current value of input signals (ck) */
/* ###------------------------------------------------------### */
ck = vhx_readinput (pt_lkdins, POSI_ck, 1);
if (ck == 1)
local->LAST_CK = 1;
else
{
/* ###------------------------------------------------------### */
/* check for the falling edge of the clock */
/* ###------------------------------------------------------### */
if (local->LAST_CK == 1)
{
local->LAST_CK = 0;
oe = vhx_readinput (pt_lkdins, POSI_oe , 1);
we = vhx_readinput (pt_lkdins, POSI_we , 1);
adr = vhx_readinput (pt_lkdins, POSI_adr , 10);
if (we == 1)
{
/* ###------------------------------------------------------### */
/* write the input data into the ram */
/* ###------------------------------------------------------### */
d_in = vhx_readinput (pt_lkdins, POSI_d_in, 24);
local->RAM [adr] = d_in;
}
else
{
/* ###------------------------------------------------------### */
/* read the content of the ram and write the result into the */
/* projected value of ouput data */
/* ###------------------------------------------------------### */
if (oe == 1)
d_out = local->RAM [adr];
else
d_out = 0;
vhx_writeout (d_out, pt_lkdins, POSO_d_out, 24);
}
}
}
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,124 @@
/* ###--------------------------------------------------------------### */
/* file : c_fsyn_sr1k_4.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_fsyn_sr1k_4 */
/* description : 1K synchronous (clock's falling edge) static 4-bit */
/* Ram */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_fsyn_sr1k_4 (pt_lkdins)
struct lkdins *pt_lkdins;
{
char ck ; /* clock */
unsigned int d_out ; /* output 4-bit data */
unsigned int d_in ; /* input 4-bit data */
unsigned int adr ; /* 10-bit address */
char oe ; /* output enable */
char we ; /* write enable */
#define POSI_we 0
#define POSI_oe POSI_we + 1
#define POSI_adr POSI_oe + 1
#define POSI_d_in POSI_adr + 10
#define POSI_ck POSI_d_in + 4
#define POSO_d_out 0
struct local_mem
{
unsigned int LAST_CK ;
unsigned char RAM [1024];
};
struct local_mem *local ;
static void init () ;
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &local, sizeof(struct local_mem), init);
/* ###------------------------------------------------------### */
/* read the current value of input signals (ck) */
/* ###------------------------------------------------------### */
ck = vhx_readinput (pt_lkdins, POSI_ck, 1);
if (ck == 1)
local->LAST_CK = 1;
else
{
/* ###------------------------------------------------------### */
/* check for the falling edge of the clock */
/* ###------------------------------------------------------### */
if (local->LAST_CK == 1)
{
local->LAST_CK = 0;
oe = vhx_readinput (pt_lkdins, POSI_oe , 1);
we = vhx_readinput (pt_lkdins, POSI_we , 1);
adr = vhx_readinput (pt_lkdins, POSI_adr , 10);
if (we == 1)
{
/* ###------------------------------------------------------### */
/* write the input data into the ram */
/* ###------------------------------------------------------### */
d_in = vhx_readinput (pt_lkdins, POSI_d_in, 4);
local->RAM [adr] = d_in;
}
else
{
/* ###------------------------------------------------------### */
/* read the content of the ram and write the result into the */
/* projected value of ouput data */
/* ###------------------------------------------------------### */
if (oe == 1)
d_out = local->RAM [adr];
else
d_out = 0;
vhx_writeout (d_out, pt_lkdins, POSO_d_out, 4);
}
}
}
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,139 @@
/* ###--------------------------------------------------------------### */
/* file : c_fsyn_sr1k_56.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_fsyn_sr1k_56 */
/* description : 1K synchronous (clock's falling edge) static 56-bit */
/* Ram */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_fsyn_sr1k_56 (pt_lkdins)
struct lkdins *pt_lkdins;
{
char ck ; /* clock */
unsigned int dh_out ; /* output 24 higher bits data */
unsigned int dl_out ; /* output 32 lower bits data */
unsigned int dh_in ; /* input 24 higher bits data */
unsigned int dl_in ; /* input 32 lower bits data */
unsigned int adr ; /* 10-bit address */
char oe ; /* output enable */
char we ; /* write enable */
#define POSI_we 0
#define POSI_oe POSI_we + 1
#define POSI_adr POSI_oe + 1
#define POSI_dl_in POSI_adr + 10
#define POSI_dh_in POSI_dl_in + 32
#define POSI_ck POSI_dh_in + 24
#define POSO_dl_out 0
#define POSO_dh_out POSO_dl_out + 32
struct local_mem
{
unsigned int LAST_CK ;
unsigned int HI_RAM [1024];
unsigned int LO_RAM [1024];
};
struct local_mem *local ;
static void init () ;
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &local, sizeof(struct local_mem), init);
/* ###------------------------------------------------------### */
/* read the current value of input signals (ck) */
/* ###------------------------------------------------------### */
ck = vhx_readinput (pt_lkdins, POSI_ck, 1);
if (ck == 1)
local->LAST_CK = 1;
else
{
/* ###------------------------------------------------------### */
/* check for the falling edge of the clock */
/* ###------------------------------------------------------### */
if (local->LAST_CK == 1)
{
local->LAST_CK = 0;
oe = vhx_readinput (pt_lkdins, POSI_oe , 1);
we = vhx_readinput (pt_lkdins, POSI_we , 1);
adr = vhx_readinput (pt_lkdins, POSI_adr , 10);
if (we == 1)
{
/* ###------------------------------------------------------### */
/* write the input data into the ram */
/* ###------------------------------------------------------### */
dl_in = vhx_readinput (pt_lkdins, POSI_dl_in, 32);
dh_in = vhx_readinput (pt_lkdins, POSI_dh_in, 24);
local->HI_RAM [adr] = dh_in;
local->LO_RAM [adr] = dl_in;
}
else
{
if (oe == 1)
{
/* ###------------------------------------------------------### */
/* read the content of the ram and write the result into the */
/* projected value of ouput data */
/* ###------------------------------------------------------### */
dh_out = local->HI_RAM [adr];
dl_out = local->LO_RAM [adr];
}
else
{
dh_out = 0;
dl_out = 0;
}
vhx_writeout (dh_out, pt_lkdins, POSO_dh_out, 24);
vhx_writeout (dl_out, pt_lkdins, POSO_dl_out, 32);
}
}
}
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,124 @@
/* ###--------------------------------------------------------------### */
/* file : c_fsyn_sr4k_10.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_fsyn_sr4k_10 */
/* description : 4K synchronous (clock's falling edge) static 10-bit */
/* Ram */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_fsyn_sr4k_10 (pt_lkdins)
struct lkdins *pt_lkdins;
{
char ck ; /* clock */
unsigned int d_out ; /* output 10-bit data */
unsigned int d_in ; /* input 10-bit data */
unsigned int adr ; /* 12-bit address */
char oe ; /* output enable */
char we ; /* write enable */
#define POSI_we 0
#define POSI_oe POSI_we + 1
#define POSI_adr POSI_oe + 1
#define POSI_d_in POSI_adr + 12
#define POSI_ck POSI_d_in + 10
#define POSO_d_out 0
struct local_mem
{
unsigned int LAST_CK ;
unsigned short RAM [4096];
};
struct local_mem *local ;
static void init () ;
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &local, sizeof(struct local_mem), init);
/* ###------------------------------------------------------### */
/* read the current value of input signals (ck) */
/* ###------------------------------------------------------### */
ck = vhx_readinput (pt_lkdins, POSI_ck, 1);
if (ck == 1)
local->LAST_CK = 1;
else
{
/* ###------------------------------------------------------### */
/* check for the falling edge of the clock */
/* ###------------------------------------------------------### */
if (local->LAST_CK == 1)
{
local->LAST_CK = 0;
oe = vhx_readinput (pt_lkdins, POSI_oe , 1);
we = vhx_readinput (pt_lkdins, POSI_we , 1);
adr = vhx_readinput (pt_lkdins, POSI_adr , 12);
if (we == 1)
{
/* ###------------------------------------------------------### */
/* write the input data into the ram */
/* ###------------------------------------------------------### */
d_in = vhx_readinput (pt_lkdins, POSI_d_in, 10);
local->RAM [adr] = d_in;
}
else
{
/* ###------------------------------------------------------### */
/* read the content of the ram and write the result into the */
/* projected value of ouput data */
/* ###------------------------------------------------------### */
if (oe == 1)
d_out = local->RAM [adr];
else
d_out = 0;
vhx_writeout (d_out, pt_lkdins, POSO_d_out, 10);
}
}
}
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,166 @@
/* ###--------------------------------------------------------------### */
/* file : c_hada_repondeur.c */
/* date : Nov 18 1997 */
/* author : Sebatien Lozac'h */
/* content : C model of hadamard's test bench */
/* warning : This model can only be instancied once */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xspec.h"
#define MAX 64
#define ENTREE "fic_entree"
#define ENTREE2 "fic_entree2"
#define SORTIE "fic_sortie"
void c_hada_repondeur (pt_lkdins)
struct lkdins *pt_lkdins;
{
#define RMAX 1000
#define PROB 900
static int deja_ouvert=0;
static int deja_ouvert2=0;
static int nb_entrees=0;
static int nb_sorties=0;
static int ck_old=0;
static int empty_old=0;
static int full_old=0;
static FILE *fouvrir;
static FILE *fecrire;
/*------- Declaration des entrees -----------*/
char ck ;
char reset ;
char read ;
char write ;
int hadout; /* Entree sur 14 bits */
char vdd ;
char vss ;
char empty ;
char full ;
unsigned int data ; /* Sortie sur 8 bits */
#define POSI_vss 0
#define POSI_vdd POSI_vss + 1
#define POSI_hadout POSI_vdd + 1
#define POSI_write POSI_hadout + 14
#define POSI_read POSI_write + 1
#define POSI_reset POSI_read + 1
#define POSI_ck POSI_reset + 1
/*------- Declaration des sorties -----------*/
#define POSO_data 0
#define POSO_full POSO_data + 8
#define POSO_empty POSO_full + 1
/*------- Affectation des entrees -----------*/
ck = vhx_readinput (pt_lkdins, POSI_ck , 1);
read = vhx_readinput (pt_lkdins, POSI_read , 1);
reset = vhx_readinput (pt_lkdins, POSI_reset , 1);
write = vhx_readinput (pt_lkdins, POSI_write , 1);
hadout = vhx_readinput (pt_lkdins, POSI_hadout, 14);
/*------- Ouverture des 2 Fichiers -----------*/
if (deja_ouvert == 0)
{
if ((fouvrir = fopen (ENTREE,"r")) == NULL)
{ fprintf(stderr,"CANNOT OPEN FILE : %s \n", ENTREE);exit (3);}
if ( (fecrire=fopen(SORTIE,"w"))== NULL )
{ fprintf(stderr,"CANNOT OPEN FILE : %s \n", SORTIE);exit (3);}
deja_ouvert = 1;
}
/*------- Description du comportement -----------*/
if ((ck_old==0) && (ck==1))
{
if (reset == 1)
{
nb_entrees=MAX;
nb_sorties=0;
empty=1;
full=0;
}
else if ((nb_entrees == MAX) && (nb_sorties == 0))
{
empty=0;
full=0;
if (fscanf(fouvrir,"%d",&data) == EOF)
{
rewind(fouvrir);
fscanf(fouvrir,"%d",&data);
}
fprintf(stderr,"NEW INPUT FIFO VALUE : %d\n", data);
vhx_writeout(data,pt_lkdins,POSO_data,8);
nb_entrees--;
}
else
{
if (( (random() % RMAX) > PROB) || ((nb_entrees==0) && (nb_sorties != 0)))
{ empty=1; }
else
{ empty=0; }
if (( (random() % RMAX) < PROB) || ((nb_sorties==0) && (nb_entrees != 0)))
{ full=0; }
else
{ full=1; }
if ((empty_old == 0) && (read == 1) && (nb_entrees == 0))
{
nb_sorties=MAX;
}
if ((empty_old == 0) && (read == 1) && (nb_entrees != 0))
{
if (fscanf(fouvrir,"%d",&data) == EOF)
{
rewind(fouvrir);
fscanf(fouvrir,"%d",&data);
}
fprintf(stderr,"NEW INPUT FIFO VALUE : %d\n", data);
vhx_writeout(data,pt_lkdins,POSO_data,8);
nb_entrees--;
}
if ((full_old == 0) && (write == 1) && (nb_sorties != 0))
{
fprintf(stderr,"NEW OUPUT FIFO VALUE : %d\n", hadout);
fprintf(fecrire,"0x%x\t",hadout);
nb_sorties--;
if ( (nb_sorties%8) == 0 ) fprintf(fecrire,"\n",hadout);
if ( (nb_sorties == 0))
{
nb_entrees=MAX;
fprintf(fecrire,"\n",hadout);
fflush(fecrire);
}
}
}
vhx_writeout(empty,pt_lkdins,POSO_empty,1);
vhx_writeout(full,pt_lkdins,POSO_full,1);
full_old=full;
empty_old=empty;
}
ck_old=ck;
}

View File

@ -0,0 +1,110 @@
/* ###--------------------------------------------------------------### */
/* file : c_sr1k_8a.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_sr1k_8a */
/* description : A 1 KByte static Ram with a chip select pin */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_sr1k_8a (pt_lkdins)
struct lkdins *pt_lkdins;
{
char e_n ; /* chip select */
char w_n ; /* write enable */
unsigned int dat ; /* input-output 8-bit data */
unsigned int adr ; /* 10-bit address */
char vdd ; /* power supply */
char vss ; /* power supply */
#define POSI_vss 0
#define POSI_vdd POSI_vss + 1
#define POSI_adr POSI_vdd + 1
#define POSI_dat POSI_adr + 10
#define POSI_w_n POSI_dat + 8
#define POSI_e_n POSI_w_n + 1
#define POSO_dat 0
unsigned char *mem ;
unsigned int cond = 0;
static void init () ;
/* ###------------------------------------------------------### */
/* read the current value of input signals (e_n) */
/* ###------------------------------------------------------### */
e_n = vhx_readinput (pt_lkdins, POSI_e_n, 1);
/* ###------------------------------------------------------### */
/* read the current value of input signals */
/* ###------------------------------------------------------### */
if (e_n == 0)
{
w_n = vhx_readinput (pt_lkdins, POSI_w_n, 1);
adr = vhx_readinput (pt_lkdins, POSI_adr, 10);
dat = vhx_readinput (pt_lkdins, POSI_dat, 8);
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &mem, 1024, init);
/* ###------------------------------------------------------### */
/* read or write the data from the memory */
/* ###------------------------------------------------------### */
if (w_n == 0)
mem [adr] = dat;
else
dat = mem [adr];
}
/* ###------------------------------------------------------### */
/* write the result into the projected value of ouput signals */
/* ###------------------------------------------------------### */
if ((e_n == 0) && (w_n == 1))
cond = 0x000000ff;
else
cond = 0x00000000;
vhx_writebus (dat, cond, pt_lkdins, POSO_dat, 8);
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,270 @@
/*
* 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.
*/
/* ###--------------------------------------------------------------### */
/* file : c_sr1k_8b.c */
/* date : Dec 13 1999 */
/* version : v2.03 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_lspec.h"
#include "vh_xspec.h"
/* ###--------------------------------------------------------------### */
/* function : c_sr1k_8b */
/* description : A 1 KByte static Ram with a chip select pin */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_sr1k_8b (pt_lkdins)
struct lkdins *pt_lkdins;
{
char e_n ; /* chip select */
char w_n ; /* write enable */
unsigned int dat ; /* input-output 8-bit data */
unsigned int adr ; /* 10-bit address */
char vdd ; /* power supply */
char vss ; /* power supply */
#define POSI_vss 0
#define POSI_vdd POSI_vss + 1
#define POSI_adr POSI_vdd + 1
#define POSI_dat POSI_adr + 10
#define POSI_w_n POSI_dat + 8
#define POSI_e_n POSI_w_n + 1
#define POSO_dat 0
unsigned char *mem ;
unsigned int cond = 0;
static void init () ;
/* ###------------------------------------------------------### */
/* read the current value of input signals (e_n) */
/* ###------------------------------------------------------### */
e_n = vhx_readinput (pt_lkdins, POSI_e_n, 1);
/* ###------------------------------------------------------### */
/* read the current value of input signals */
/* ###------------------------------------------------------### */
if (e_n == 0)
{
w_n = vhx_readinput (pt_lkdins, POSI_w_n, 1);
adr = vhx_readinput (pt_lkdins, POSI_adr, 10);
dat = vhx_readinput (pt_lkdins, POSI_dat, 8);
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &mem, 1024, init);
/* ###------------------------------------------------------### */
/* read or write the data from the memory */
/* ###------------------------------------------------------### */
if (w_n == 0)
mem [adr] = dat;
else
dat = mem [adr];
}
/* ###------------------------------------------------------### */
/* write the result into the projected value of ouput signals */
/* ###------------------------------------------------------### */
if ((e_n == 0) && (w_n == 1))
cond = 0x000000ff;
else
cond = 0x00000000;
vhx_writebus (dat, cond, pt_lkdins, POSO_dat, 8);
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
#define READ_ADR 0
#define READ_VAL 1
#define ADR_MASK 0xfffff000 /* 1 k byte */
#define BYT_MASK 0x00000003 /* byte address inside a word */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
unsigned char *pt_mem ;
{
static void splitname ();
char *name ;
char fil_name [128];
unsigned int fil_addr = 0;
unsigned int fil_byte = 0;
FILE *fp ;
unsigned int cur_adr = 0;
unsigned int cur_val = 0;
unsigned int red_c = 0;
unsigned int red_val = 0;
unsigned int state = READ_ADR;
name = vhx_GetInstanceName (pt_lkdins);
splitname (name, fil_name, &fil_addr, &fil_byte);
if ((fp = mbkfopen (fil_name, "ini", READ_TEXT)) == NULL)
{
fprintf (stderr, "cannot open RAM initialization file: %s.ini\n", fil_name);
exit (1);
}
printf ("loading RAM initialization file: %s.ini , %.8x , %d\n",
fil_name, fil_addr, fil_byte);
while ((red_c = fgetc (fp)) != EOF)
{
switch (red_c)
{
case ' ' :
case '\t':
break;
case '\n':
if (((cur_adr & ADR_MASK) == fil_addr) &&
((cur_adr & BYT_MASK) == fil_byte) )
pt_mem [(cur_adr & (~ADR_MASK)) >> 2] = cur_val;
state = READ_ADR;
cur_adr = 0;
cur_val = 0;
break;
case ':' :
state = READ_VAL;
break;
default :
if ((red_c >= '0') && (red_c <= '9'))
red_val = red_c - '0';
if ((red_c >= 'a') && (red_c <= 'f'))
red_val = red_c - 'a' + 10;
if ((red_c >= 'A') && (red_c <= 'F'))
red_val = red_c - 'A' + 10;
if (state == READ_ADR)
cur_adr = (cur_adr << 4) + red_val;
else
cur_val = (cur_val << 4) + red_val;
}
}
fclose (fp);
}
/* ###--------------------------------------------------------------### */
/* function : splitname */
/* description : split the instance's name in file name, address and */
/* byte position: xxxx.filname_address.xxx_b */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void splitname (name, fil_name, adr_pnt, byt_pnt)
char *name ;
char *fil_name;
unsigned int *adr_pnt ;
unsigned int *byt_pnt ;
{
unsigned int state = 0;
unsigned int i = 0;
unsigned int j = 0;
unsigned int l_idx = 0;
unsigned int adr = 0;
unsigned int byt = 0;
strcpy (fil_name, name);
for (i=0 ; name [i] != '\0' ; i++)
{
switch (state)
{
case 0:
if (name [i] == '_')
{
state = 1;
l_idx = i;
}
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
state ++;
if ((name [i] >= '0') && (name [i] <= '9'))
adr = (adr << 4) + (name [i] - '0');
else
{
if ((name [i] >= 'a') && (name [i] <= 'f'))
adr = (adr << 4) + (name [i] - 'a' + 10);
else
{
adr = 0;
if (name [i] == '_')
state = 1;
else
state = 0;
l_idx = i;
}
}
break;
default:
break;
}
}
fil_name [l_idx] = '\0';
*adr_pnt = adr ;
*byt_pnt = name [i-1] - '0';
}

View File

@ -0,0 +1,110 @@
/* ###--------------------------------------------------------------### */
/* file : c_sr8k_8a.c */
/* date : Jun 3 1997 */
/* version : v2.02 */
/* author : Pirouz Bazargan Sabet */
/* content : C model of a circuit */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_xcomm.h"
/* ###--------------------------------------------------------------### */
/* function : c_sr8k_8a */
/* description : A 8 KByte static Ram with a chip select pin */
/* called func. : vhx_getvalu, vhx_readinput, vhx_writebus */
/* ###--------------------------------------------------------------### */
void c_sr8k_8a (pt_lkdins)
struct lkdins *pt_lkdins;
{
char e_n ; /* chip select */
char w_n ; /* write enable */
unsigned int dat ; /* input-output 8-bit data */
unsigned int adr ; /* 13-bit address */
char vdd ; /* power supply */
char vss ; /* power supply */
#define POSI_vss 0
#define POSI_vdd POSI_vss + 1
#define POSI_adr POSI_vdd + 1
#define POSI_dat POSI_adr + 13
#define POSI_w_n POSI_dat + 8
#define POSI_e_n POSI_w_n + 1
#define POSO_dat 0
unsigned char *mem ;
unsigned int cond = 0;
static void init () ;
/* ###------------------------------------------------------### */
/* read the current value of input signals (e_n) */
/* ###------------------------------------------------------### */
e_n = vhx_readinput (pt_lkdins, POSI_e_n, 1);
/* ###------------------------------------------------------### */
/* read the current value of input signals */
/* ###------------------------------------------------------### */
if (e_n == 0)
{
w_n = vhx_readinput (pt_lkdins, POSI_w_n, 1);
adr = vhx_readinput (pt_lkdins, POSI_adr, 13);
dat = vhx_readinput (pt_lkdins, POSI_dat, 8);
/* ###------------------------------------------------------### */
/* get the memory space reserved for the current instance */
/* ###------------------------------------------------------### */
vhx_getvalu (pt_lkdins, &mem, 1024 * 8, init);
/* ###------------------------------------------------------### */
/* read or write the data from the memory */
/* ###------------------------------------------------------### */
if (w_n == 0)
mem [adr] = dat;
else
dat = mem [adr];
}
/* ###------------------------------------------------------### */
/* write the result into the projected value of ouput signals */
/* ###------------------------------------------------------### */
if ((e_n == 0) && (w_n == 1))
cond = 0x000000ff;
else
cond = 0x00000000;
vhx_writebus (dat, cond, pt_lkdins, POSO_dat, 8);
}
/* ###--------------------------------------------------------------### */
/* function : init */
/* description : initializations */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void init (pt_lkdins, pt_mem)
struct lkdins *pt_lkdins;
char *pt_mem ;
{
char *name;
name = vhx_GetInstanceName (pt_lkdins);
printf ("coucou %s\n", name);
}

View File

@ -0,0 +1,75 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst100.h */
/* date : Dec 20 1994 */
/* version : v107 */
/* author : DUNOYER Julien */
/* contents : defines and structure definitions used in CST library */
/* */
/* ###--------------------------------------------------------------### */
#ifndef CST_CSTDEF
#define CST_CSTDEF
/* ###------------------------------------------------------### */
/* defines */
/* ###------------------------------------------------------### */
#define CST_SUCCEED 0x00 /* function call : succeed */
#define CST_FAILED 0x01 /* function call : failed */
#define CST_WARNING 0x80 /* function call : warning */
#define CST_ERROR 0x40 /* function call : error */
#define CST_BUG 0x20 /* function call : bug */
#define CST_EXIT 0x10 /* function call : exit */
#define CST_MSG__BUG 0x01 /* message level : bug */
#define CST_MSG__ERR 0x02 /* message level : error */
#define CST_MSG__WARN 0x04 /* message level : warning */
#define CST_MSG__MESG 0x08 /* message level : message */
/* ###------------------------------------------------------### */
/* global variables definition */
/* ###------------------------------------------------------### */
extern unsigned long CST_STATUS; /* function calls status */
extern unsigned long CST_MSGLVL; /* message level */
extern unsigned int CST_ERRCOD; /* error code */
extern unsigned int CST_ERRCNT; /* error count */
extern unsigned int CST_MAXERR; /* maximum error count */
/* ###------------------------------------------------------### */
/* structure definitions */
/* ###------------------------------------------------------### */
/* ###------------------------------------------------------### */
/* macros definitions */
/* ###------------------------------------------------------### */
#define CST_ELEMENT_COMPARE( elt1, elt2 ) \
(long)((unsigned long)(elt1) - (unsigned long)(elt2))
/* ###------------------------------------------------------### */
/* functions */
/* ###------------------------------------------------------### */
extern void cst_error ();
extern chain_list *cst_AddSetElement ();
extern chain_list *cst_RemSetElement ();
extern int cst_IsInSetElement ();
extern int cst_SetCompare ();
extern int cst_DisjunctiveSet ();
extern chain_list *cst_CreateUnionSet ();
extern chain_list *cst_CreateIntersectionSet ();
extern chain_list *cst_CreateComplementSet ();
extern void *cst_GetFirstElement ();
extern void *cst_GetNextElement ();
extern void *cst_GetLastElement ();
extern void *cst_GetPreviousElement ();
#endif

View File

@ -0,0 +1,75 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_AddSetElt.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_AddSetElement */
/* description : Add a pointer element in a pointer set. */
/* called func. : */
/* ###--------------------------------------------------------------### */
chain_list *cst_AddSetElement (set,element)
chain_list *set ;
void *element ;
{
chain_list *set_pnt = NULL;
chain_list *sav_pnt = NULL;
CST_STATUS = CST_SUCCEED;
if ( set == NULL )
{
set = addchain ( set, element );
return( set );
}
if ( CST_ELEMENT_COMPARE(element,set->DATA) == 0 )
{
return( set );
}
if ( CST_ELEMENT_COMPARE(element,set->DATA) < 0 )
{
set = addchain ( set, element );
return( set );
}
sav_pnt = set;
set_pnt = set->NEXT;
while ( set_pnt != NULL )
{
if ( CST_ELEMENT_COMPARE(element,set_pnt->DATA) == 0 )
{
return( set );
}
if ( CST_ELEMENT_COMPARE(element,set_pnt->DATA) < 0 )
{
set_pnt = addchain ( set_pnt, element );
sav_pnt->NEXT = set_pnt;
return( set );
}
sav_pnt = set_pnt;
set_pnt = set_pnt->NEXT;
}
set_pnt = addchain ( set_pnt, element );
sav_pnt->NEXT = set_pnt;
return (set);
}

View File

@ -0,0 +1,69 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_CrtCompSet.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_CreateComplementSet */
/* description : Create The Complement between two pointers sets. */
/* This mean set1 - set2. */
/* called func. : */
/* ###--------------------------------------------------------------### */
chain_list *cst_CreateComplementSet (set1, set2)
chain_list *set1 ;
chain_list *set2 ;
{
chain_list *set_pnt = NULL;
CST_STATUS = CST_SUCCEED;
while ((set1 != NULL) && (set2 != NULL))
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) < 0 )
{
set_pnt = addchain (set_pnt, set1->DATA);
set1 = set1->NEXT;
}
else
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) == 0 )
{
set1 = set1->NEXT;
set2 = set2->NEXT;
}
else
{
cst_error(5, "cst_CreateComplementSet", NULL, 0);
set2 = set2->NEXT;
}
}
}
while (set1 != NULL)
{
set_pnt = addchain (set_pnt, set1->DATA);
set1 = set1->NEXT;
}
if (set2 != NULL)
{
cst_error(5, "cst_CreateComplementSet", NULL, 0);
}
set_pnt = reverse (set_pnt);
return (set_pnt);
}

View File

@ -0,0 +1,57 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_CrtInterSet.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_CreateIntersectionSet */
/* description : Create The Intersection between two pointers sets. */
/* called func. : */
/* ###--------------------------------------------------------------### */
chain_list *cst_CreateIntersectionSet (set1, set2)
chain_list *set1 ;
chain_list *set2 ;
{
chain_list *set_pnt = NULL;
CST_STATUS = CST_SUCCEED;
while ((set1 != NULL) && ( set2 != NULL))
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) == 0 )
{
set_pnt = addchain (set_pnt, set1->DATA);
set1 = set1->NEXT;
set2 = set2->NEXT;
}
else
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) < 0 )
{
set1 = set1->NEXT;
}
else
{
set2 = set2->NEXT;
}
}
}
set_pnt = reverse( set_pnt);
return (set_pnt);
}

View File

@ -0,0 +1,71 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_CrtUnionSet.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_CreateUnionSet */
/* description : Create The Union between two pointers sets. */
/* called func. : */
/* ###--------------------------------------------------------------### */
chain_list *cst_CreateUnionSet (set1, set2)
chain_list *set1 ;
chain_list *set2 ;
{
chain_list *set_pnt = NULL;
CST_STATUS = CST_SUCCEED;
while ((set1 != NULL) && ( set2 != NULL))
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) == 0 )
{
set_pnt = addchain (set_pnt, set1->DATA);
set1 = set1->NEXT;
set2 = set2->NEXT;
}
else
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) < 0 )
{
set_pnt = addchain (set_pnt, set1->DATA);
set1 = set1->NEXT;
}
else
{
set_pnt = addchain (set_pnt, set2->DATA);
set2 = set2->NEXT;
}
}
}
while (set1 != NULL)
{
set_pnt = addchain (set_pnt, set1->DATA);
set1 = set1->NEXT;
}
while (set2 != NULL)
{
set_pnt = addchain (set_pnt, set2->DATA);
set2 = set2->NEXT;
}
set_pnt = reverse(set_pnt);
return (set_pnt);
}

View File

@ -0,0 +1,51 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_DisjunctSet.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_DisjunctiveSet */
/* description : check The Disjunction between two pointers sets. */
/* called func. : */
/* ###--------------------------------------------------------------### */
int cst_DisjunctiveSet (set1, set2)
chain_list *set1 ;
chain_list *set2 ;
{
CST_STATUS = CST_SUCCEED;
while ((set1 != NULL) && ( set2 != NULL))
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) == 0 )
{
return (0);
}
else
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) < 0 )
{
set1 = set1->NEXT;
}
else
{
set2 = set2->NEXT;
}
}
}
return (1);
}

View File

@ -0,0 +1,42 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_GetFirstElt.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_GetFirstElement */
/* description : Get the first pointer element in a pointer set. */
/* called func. : */
/* ###--------------------------------------------------------------### */
void *cst_GetFirstElement (set)
chain_list *set ;
{
void *element = NULL;
CST_STATUS = CST_SUCCEED;
if ( set == NULL )
{
CST_STATUS = CST_FAILED;
}
else
{
element = set->DATA;
}
return ( element );
}

View File

@ -0,0 +1,46 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_GetLastElt.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_GetLastElement */
/* description : Get the last pointer element in a pointer set. */
/* called func. : */
/* ###--------------------------------------------------------------### */
void *cst_GetLastElement (set)
chain_list *set ;
{
void *element = NULL;
CST_STATUS = CST_SUCCEED;
if ( set == NULL )
{
CST_STATUS = CST_FAILED;
}
else
{
while (set->NEXT != NULL)
{
set = set->NEXT;
}
element = set->DATA;
}
return ( element );
}

View File

@ -0,0 +1,55 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_GetNextElt.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_GetNextElement */
/* description : Get the next pointer element in a pointer set. */
/* called func. : */
/* ###--------------------------------------------------------------### */
void *cst_GetNextElement (set, current)
chain_list *set ;
void *current ;
{
void *element = NULL;
CST_STATUS = CST_SUCCEED;
if ( set == NULL )
{
cst_error(2,"cst_GetNextElement",NULL,0);
return ( element );
}
while (set != NULL)
{
if ( CST_ELEMENT_COMPARE(current,set->DATA) < 0 )
{
element = set->DATA;
break;
}
set = set->NEXT;
}
if (element == NULL)
{
CST_STATUS = CST_FAILED;
}
return ( element );
}

View File

@ -0,0 +1,59 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_GetPrevElt.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_GetPreviousElement */
/* description : Get the previous pointer element in a pointer set. */
/* called func. : */
/* ###--------------------------------------------------------------### */
void *cst_GetPreviousElement (set, current)
chain_list *set ;
void *current ;
{
void *element = NULL;
chain_list *sav_pnt = NULL;
CST_STATUS = CST_SUCCEED;
if ( set == NULL )
{
cst_error(2,"cst_GetPreviousElement",NULL,0);
}
while (set != NULL)
{
if ( CST_ELEMENT_COMPARE(current,set->DATA) <= 0 )
{
break;
}
sav_pnt = set;
set = set->NEXT;
}
if (sav_pnt == NULL)
{
CST_STATUS = CST_FAILED;
}
else
{
element = sav_pnt->DATA;
}
return ( element );
}

View File

@ -0,0 +1,57 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_IsInSetElt.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_IsInSetElement */
/* description : Is a pointer element in a pointer set. */
/* called func. : */
/* ###--------------------------------------------------------------### */
int cst_IsInSetElement (set,element)
chain_list *set ;
void *element ;
{
chain_list *set_pnt = NULL;
CST_STATUS = CST_SUCCEED;
if ( set == NULL )
{
cst_error(2,"cst_IsInSetElement",NULL,0);
return( 0 );
}
set_pnt = set;
while ( set_pnt != NULL )
{
if ( CST_ELEMENT_COMPARE(element,set_pnt->DATA) == 0 )
{
return( 1 );
}
if ( CST_ELEMENT_COMPARE(element,set_pnt->DATA) < 0 )
{
return( 0 );
}
set_pnt = set_pnt->NEXT;
}
return ( 0 );
}

View File

@ -0,0 +1,60 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_RemSetElt.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_RemSetElement */
/* description : Remove a pointer element in a pointer set. */
/* called func. : */
/* ###--------------------------------------------------------------### */
chain_list *cst_RemSetElement (set,element)
chain_list *set ;
void *element ;
{
chain_list *set_pnt = NULL;
CST_STATUS = CST_SUCCEED;
if ( set == NULL )
{
cst_error(2,"cst_RemSetElement",NULL,0);
return( set );
}
set_pnt = set;
while ( set_pnt != NULL )
{
if ( CST_ELEMENT_COMPARE(element,set_pnt->DATA) == 0 )
{
set = delchain (set, set_pnt);
return( set );
}
if ( CST_ELEMENT_COMPARE(element,set_pnt->DATA) < 0 )
{
cst_error(4,"cst_RemSetElement",NULL,0);
return( set );
}
set_pnt = set_pnt->NEXT;
}
cst_error(4,"cst_RemSetElement",NULL,0);
return (set);
}

View File

@ -0,0 +1,46 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_CmpSet.c */
/* date : Dec 20 1994 */
/* version : v100 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : high level function */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_SetCompare */
/* description : compare two sets. */
/* called func. : */
/* ###--------------------------------------------------------------### */
int cst_SetCompare (set1, set2)
chain_list *set1 ;
chain_list *set2 ;
{
CST_STATUS = CST_SUCCEED;
while ((set1 != NULL) && ( set2 != NULL))
{
if ( CST_ELEMENT_COMPARE(set1->DATA, set2->DATA) == 0 )
{
set1 = set1->NEXT;
set2 = set2->NEXT;
}
else
return(1);
}
if ((set1 != NULL) || (set2 != NULL))
return(1);
return (0);
}

View File

@ -0,0 +1,48 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_error.c */
/* date : Dec 24 1994 */
/* version : v000 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : system level functions */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
/* ###--------------------------------------------------------------### */
/* function : cst_error */
/* description : print an error message on standard error output */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void cst_error (code, str1, str2, dat1)
int code;
char *str1;
char *str2;
int dat1;
{
CST_ERRCNT++;
CST_ERRCOD = code;
CST_STATUS = CST_ERROR;
if (((CST_MSGLVL & CST_MSG__ERR) != 0) && ((CST_ERRCNT < CST_MAXERR)))
{
fprintf (stderr, "Cst Error %d in func. `%s`: ", code, str1);
switch (code)
{
default:
fprintf (stderr,"unknown error: %d\n", code);
break;
}
}
if (CST_ERRCNT == CST_MAXERR)
fprintf (stderr ,"Too many errors : cant explain them further more");
}

View File

@ -0,0 +1,22 @@
/* ###--------------------------------------------------------------### */
/* */
/* file : cst_globals.c */
/* date : Dec 17 1994 */
/* version : v000 */
/* authors : DUNOYER Julien & ABDALLAH Nizar */
/* description : global variables */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "cst.h"
unsigned long CST_STATUS = CST_SUCCEED; /* function call status */
unsigned long CST_MSGLVL = CST_MSG__ERR; /* message level */
unsigned int CST_ERRCOD = 0; /* error code */
unsigned int CST_ERRCNT = 0; /* error count */
unsigned int CST_MAXERR = 10; /* maximum error count */

View File

@ -0,0 +1,108 @@
/* ###--------------------------------------------------------------### */
/* file : sch110.h */
/* date : Aug 10 1999 */
/* version : v110 */
/* author : Nizar ABDALLAH, Pirouz BAZARGAN SABET */
/* contents : defines and structure definitions used in SCH library */
/* ###--------------------------------------------------------------### */
#ifndef SCH_SCHDEF
#define SCH_SCHDEF
/* ###------------------------------------------------------### */
/* basic defines */
/* ###------------------------------------------------------### */
#define SCH_DFN_TRABLOCK 1024 /* size of block */
#define SCH_DFN_ENTBLOCK 256 /* size of block */
#define SCH_DFN_WAVBLOCK 256 /* size of block */
#define SCH_TRA_DELNONE 0x00 /* transcation flag: no action */
#define SCH_TRA_DELAFTER 0x01 /* transcation flag: del after */
#define SCH_TRA_DELBEFORE 0x02 /* transcation flag: del before */
#define SCH_TRA_ENTFIRST 0x04 /* transcation flag: 1 of list */
/* ###------------------------------------------------------### */
/* complexe defines */
/* ###------------------------------------------------------### */
#define SCH_TRA_DELALL SCH_TRA_DELAFTER | SCH_TRA_DELBEFORE
/* ###------------------------------------------------------### */
/* structure definitions */
/* ###------------------------------------------------------### */
struct shdul /* scheduler */
{
struct shdul *NEXT ; /* next scheduler */
void *LABEL ; /* scheduler's label */
struct shent **TTABLE ; /* time table */
struct shwav **ITABLE ; /* identifier table */
unsigned int CURTIME ; /* current absolute time */
};
struct shtra /* transaction */
{
struct shtra *NEXT ; /* next transaction */
struct shtra *PREV ; /* previous transaction */
struct shtra *WAVE ; /* waveform for the same identifier */
unsigned int DATE ; /* transaction's date */
void *IDENT ; /* main identifier */
void *SCDID ; /* second identifier */
unsigned int UFLAG ; /* user's flags */
unsigned char COND ; /* condition value */
unsigned char VALU ; /* value */
unsigned short FLAGS ; /* flags */
};
struct shent /* scheduler entry */
{
struct shent *NEXT ; /* next entry */
unsigned int DATE ; /* entry's date (high order bits) */
struct shtra *TRANS [8]; /* list of transactions */
};
struct shwav /* waveform */
{
struct shwav *NEXT ; /* next waveform */
void *IDENT ; /* main identifier */
struct shtra *TRANS ; /* list of transactions */
};
/* ###------------------------------------------------------### */
/* global variables */
/* ###------------------------------------------------------### */
extern struct shtra *SCH_FREE_SHTRA ;
extern struct shent *SCH_FREE_SHENT ;
extern struct shwav *SCH_FREE_SHWAV ;
/* ###------------------------------------------------------### */
/* functions */
/* ###------------------------------------------------------### */
extern void sch_bug ();
extern int sch_error ();
extern void sch_message ();
extern void sch_debug ();
extern unsigned int sch_hash ();
extern struct shtra *sch_addshtra ();
extern struct shwav *sch_addshwav ();
extern struct shent *sch_addshent ();
extern struct shtra *sch_rmventry ();
extern void sch_insentry ();
extern void sch_inswave ();
extern struct shdul *sch_CreateScheduler ();
extern void sch_AddTranscation ();
extern struct shtra *sch_GetCurrentTransactions ();
extern int sch_GotoNextTime ();
extern int sch_GetNextTime ();
extern void sch_FreeTransactions ();
extern unsigned int sch_GetCurrentTime ();
#endif

View File

@ -0,0 +1,38 @@
/* ###--------------------------------------------------------------### */
/* file : sch_AddTra.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_AddTranscation */
/* description : insert a new transaction into the scheduler */
/* called func. : sch_addshent, sch_addshtra */
/* ###--------------------------------------------------------------### */
void sch_AddTransaction (pt_shdul, ident, scdid, date, cond, valu, uflag, flags)
struct shdul *pt_shdul;
void *ident ;
void *scdid ;
unsigned int date ;
unsigned char cond ;
unsigned char valu ;
unsigned int uflag ;
unsigned short flags ;
{
struct shtra *pt_shtra;
date += pt_shdul->CURTIME;
pt_shtra = sch_addshtra (ident, scdid, date, cond, valu, uflag, flags);
sch_insentry (pt_shdul, pt_shtra );
sch_inswave (pt_shdul, pt_shtra, flags);
}

View File

@ -0,0 +1,49 @@
/* ###--------------------------------------------------------------### */
/* file : sch_CrtSch.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_CreatScheduler */
/* description : create a new scheduler and initialize its time table */
/* and identifier table */
/* called func. : mbkalloc */
/* ###--------------------------------------------------------------### */
struct shdul *sch_CreateScheduler (old_shdul, label)
struct shdul *old_shdul;
void *label ;
{
unsigned int i ;
struct shdul *pt_shdul;
struct shent **pt_time ;
struct shwav **pt_ident;
pt_shdul = (struct shdul *) mbkalloc (sizeof (struct shdul ) );
pt_time = (struct shent **) mbkalloc (sizeof (struct shent *) * 256);
pt_ident = (struct shwav **) mbkalloc (sizeof (struct shwav *) * 256);
for (i=0 ; i<256 ; i++)
pt_time [i] = NULL;
for (i=0 ; i<256 ; i++)
pt_ident [i] = NULL;
pt_shdul->LABEL = label ;
pt_shdul->TTABLE = pt_time ;
pt_shdul->ITABLE = pt_ident ;
pt_shdul->CURTIME = 0 ;
pt_shdul->NEXT = old_shdul;
return (pt_shdul);
}

View File

@ -0,0 +1,34 @@
/* ###--------------------------------------------------------------### */
/* file : sch_Free.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_FreeTranscations */
/* description : release a list of transactions extracted from the */
/* scheduler */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void sch_FreeTransactions (pt_shtra)
struct shtra *pt_shtra;
{
struct shtra *pt_last;
pt_last = pt_shtra;
while (pt_last->NEXT != NULL)
pt_last = pt_last->NEXT;
pt_last->NEXT = SCH_FREE_SHTRA;
SCH_FREE_SHTRA = pt_shtra ;
}

View File

@ -0,0 +1,25 @@
/* ###--------------------------------------------------------------### */
/* file : sch_GetCTim.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_GetCurrentTime */
/* description : returns the scheduler's current time */
/* called func. : none */
/* ###--------------------------------------------------------------### */
unsigned int sch_GetCurrentTime (pt_shdul)
struct shdul *pt_shdul;
{
return (pt_shdul->CURTIME);
}

View File

@ -0,0 +1,83 @@
/* ###--------------------------------------------------------------### */
/* file : sch_GetCTra.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_GetCurrentTransactions */
/* description : return all transactions at current date and remove */
/* them from the scheduler */
/* called func. : sch_bug */
/* ###--------------------------------------------------------------### */
struct shtra *sch_GetCurrentTransactions (pt_shdul)
struct shdul *pt_shdul;
{
struct shtra *pt_shtra = NULL;
struct shwav *pt_shwav = NULL;
struct shent *pt_shent = NULL;
unsigned int time_window ;
unsigned int wind_offset ;
unsigned int wind_number ;
void *ident ;
unsigned int index ;
time_window = (pt_shdul->CURTIME >> 3) & 0x000000ff;
wind_number = (pt_shdul->CURTIME >> 11) & 0x001fffff;
wind_offset = (pt_shdul->CURTIME ) & 0x00000007;
pt_shent = pt_shdul->TTABLE [time_window];
if ((pt_shent == NULL) || (pt_shent->DATE != wind_number))
{
sch_bug (1, "sch_GetCurrentTranscations", NULL);
}
else
{
pt_shtra = pt_shent->TRANS [wind_offset];
if (pt_shtra == NULL)
{
printf ("sch_bug amar 2 : %x\n", pt_shtra);
sch_bug (1, "sch_GetCurrentTranscations", NULL);
}
else
{
while (pt_shtra != NULL)
{
ident = pt_shtra->IDENT;
index = sch_hash (ident);
pt_shwav = pt_shdul->ITABLE [index];
while (pt_shwav->IDENT != ident)
pt_shwav = pt_shwav->NEXT;
if ((pt_shwav == NULL) || (pt_shwav->TRANS != pt_shtra))
{
printf ("wav : %x, tra : %x\n", pt_shwav->TRANS, pt_shtra);
sch_debug (pt_shtra, "shtra");
sch_debug (pt_shwav, "shwav");
sch_bug (2, "sch_GetCurrentTranscations", NULL);
}
else
pt_shwav->TRANS = pt_shtra->WAVE;
pt_shtra = pt_shtra->NEXT;
}
pt_shtra = pt_shent->TRANS [wind_offset];
pt_shent->TRANS [wind_offset] = NULL;
}
}
return (pt_shtra);
}

View File

@ -0,0 +1,86 @@
/* ###--------------------------------------------------------------### */
/* file : sch_GetNTim.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_GetNextTime */
/* description : return the date of the first transaction as an */
/* argument. If the scheduler is empty the function */
/* returns the value 0. The functions also releases */
/*/ empty time-entries in the scheduler */
/* called func. : none */
/* ###--------------------------------------------------------------### */
int sch_GetNextTime (pt_shdul, pt_date)
struct shdul *pt_shdul;
unsigned int *pt_date ;
{
struct shtra *pt_shtra ;
struct shent *pt_shent ;
struct shent *pt_nxtent ;
unsigned int min_window = 0;
unsigned int min_offset = 0;
unsigned int min_number = 0;
unsigned int time_window ;
unsigned int wind_number ;
unsigned int i ;
unsigned int j ;
unsigned int index ;
int glob_found = 0;
time_window = (pt_shdul->CURTIME >> 3) & 0x000000ff;
wind_number = (pt_shdul->CURTIME >> 11) & 0x001fffff;
for (i=0 ; i<256 ; i++)
{
index = (i + time_window) % 256;
pt_shent = pt_shdul->TTABLE [index];
while (pt_shent != NULL)
{
for (j=0 ; j<8 ; j++)
{
if (pt_shent->TRANS [j] != NULL)
{
if ( (glob_found == 0 ) ||
(pt_shent->DATE < min_number) ||
((pt_shent->DATE == min_number) && (index < min_window)))
{
min_window = index ;
min_offset = j ;
min_number = pt_shent->DATE;
glob_found = 1 ;
}
break;
}
}
if (j == 8)
{
pt_nxtent = pt_shent->NEXT;
pt_shdul->TTABLE [index] = pt_nxtent ;
pt_shent->NEXT = SCH_FREE_SHENT;
SCH_FREE_SHENT = pt_shent ;
pt_shent = pt_nxtent ;
}
else
break;
}
if ((glob_found == 1) && (min_number == wind_number))
break;
}
if (glob_found == 1)
(*pt_date) = (min_number << 11) + (min_window << 3) + min_offset;
return (glob_found);
}

View File

@ -0,0 +1,36 @@
/* ###--------------------------------------------------------------### */
/* file : sch_Goto.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_GotoNextTime */
/* description : set the current absolute time to the date of the */
/* first transaction and return it as an argument. If */
/* the scheduler is empty the function returns the value */
/* 0. The functions also releases empty time-entries in */
/* the scheduler */
/* called func. : sch_GetNextTime */
/* ###--------------------------------------------------------------### */
int sch_GotoNextTime (pt_shdul)
struct shdul *pt_shdul;
{
int found = 0;
unsigned int n_date ;
found = sch_GetNextTime (pt_shdul, &n_date);
if (found != 0)
pt_shdul->CURTIME = n_date;
return (found);
}

View File

@ -0,0 +1,26 @@
/* ###--------------------------------------------------------------### */
/* file : sch_SetCTim.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_SetCurrentTime */
/* description : Set the scheduler's current time. */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void sch_SetCurrentTime (pt_shdul, date)
struct shdul *pt_shdul;
unsigned int date ;
{
pt_shdul->CURTIME = date;
}

View File

@ -0,0 +1,52 @@
/* ###--------------------------------------------------------------### */
/* file : sch_addshent.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_addshent */
/* description : create a time entry point to the scheduler */
/* called func. : mbkalloc */
/* ###--------------------------------------------------------------### */
struct shent *sch_addshent (old_ent, date)
struct shent *old_ent;
unsigned int date ;
{
struct shent *pt_shent;
unsigned int i ;
if (SCH_FREE_SHENT == NULL)
{
SCH_FREE_SHENT = (struct shent *)
mbkalloc (sizeof (struct shent) * SCH_DFN_ENTBLOCK);
pt_shent = SCH_FREE_SHENT;
for (i=0 ; i<SCH_DFN_ENTBLOCK ; i++)
{
pt_shent->NEXT = pt_shent + 1;
pt_shent ++;
}
(pt_shent - 1)->NEXT = NULL;
}
pt_shent = SCH_FREE_SHENT;
SCH_FREE_SHENT = pt_shent->NEXT;
for (i=0 ; i<8 ; i++)
pt_shent->TRANS [i] = NULL;
pt_shent->DATE = date ;
pt_shent->NEXT = old_ent;
return (pt_shent);
}

View File

@ -0,0 +1,59 @@
/* ###--------------------------------------------------------------### */
/* file : sch_addshtra.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_addshtra */
/* description : create a transaction and initilize its field */
/* called func. : mbkalloc */
/* ###--------------------------------------------------------------### */
struct shtra *sch_addshtra (ident, scdid, date, cond, valu, uflag, flags)
void *ident;
void *scdid;
unsigned int date ;
unsigned char cond ;
unsigned char valu ;
unsigned int uflag;
unsigned short flags;
{
struct shtra *pt_shtra;
unsigned int i ;
if (SCH_FREE_SHTRA == NULL)
{
SCH_FREE_SHTRA = (struct shtra *)
mbkalloc (sizeof (struct shtra) * SCH_DFN_TRABLOCK);
pt_shtra = SCH_FREE_SHTRA;
for (i=0 ; i<SCH_DFN_TRABLOCK ; i++)
{
pt_shtra->NEXT = pt_shtra + 1;
pt_shtra ++;
}
(pt_shtra - 1)->NEXT = NULL;
}
pt_shtra = SCH_FREE_SHTRA;
SCH_FREE_SHTRA = pt_shtra->NEXT;
pt_shtra->DATE = date ;
pt_shtra->IDENT = ident;
pt_shtra->SCDID = scdid;
pt_shtra->UFLAG = uflag;
pt_shtra->COND = cond ;
pt_shtra->VALU = valu ;
pt_shtra->FLAGS = flags;
return (pt_shtra);
}

View File

@ -0,0 +1,50 @@
/* ###--------------------------------------------------------------### */
/* file : sch_addshwav.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_addshwav */
/* description : create an identifier entry point to the scheduler */
/* called func. : mbkalloc */
/* ###--------------------------------------------------------------### */
struct shwav *sch_addshwav (old_wav, ident)
struct shwav *old_wav;
void *ident ;
{
struct shwav *pt_shwav;
unsigned int i ;
if (SCH_FREE_SHWAV == NULL)
{
SCH_FREE_SHWAV = (struct shwav *)
mbkalloc (sizeof (struct shwav) * SCH_DFN_WAVBLOCK);
pt_shwav = SCH_FREE_SHWAV;
for (i=0 ; i<SCH_DFN_WAVBLOCK ; i++)
{
pt_shwav->NEXT = pt_shwav + 1;
pt_shwav ++;
}
(pt_shwav - 1)->NEXT = NULL;
}
pt_shwav = SCH_FREE_SHWAV;
SCH_FREE_SHWAV = pt_shwav->NEXT;
pt_shwav->IDENT = ident ;
pt_shwav->NEXT = old_wav;
pt_shwav->TRANS = NULL ;
return (pt_shwav);
}

View File

@ -0,0 +1,41 @@
/* ###--------------------------------------------------------------### */
/* file : sch_bug.c */
/* date : Aug 10 1997 */
/* version : v101 */
/* authors : Nizar ABDALLAH, Pirouz BAZARGAN SABET */
/* content : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
/* ###--------------------------------------------------------------### */
/* function : sch_bug */
/* description : print a bug message depending on the argument code */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void sch_bug (code, str1, str2)
int code;
char *str1;
char *str2;
{
fprintf (stderr,"bug %d in `%s`:", code, str1);
switch (code)
{
case 1:
fprintf (stderr, "unconsistency: no transaction at current time\n");
break;
case 2:
fprintf (stderr, "unconsistency: not the first transaction\n");
break;
default:
fprintf (stderr,"unknown bug\n");
break;
}
exit (1);
}

View File

@ -0,0 +1,849 @@
/* ###--------------------------------------------------------------### */
/* file : sch_debug.c */
/* date : Aug 10 1997 */
/* version : v101 */
/* authors : Nizar ABDALLAH, Pirouz BAZARGAN SABET */
/* content : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "sch.h"
#include "sch_debug.h"
/* ###--------------------------------------------------------------### */
/* function : sch_debug */
/* description : display any structure */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void sch_debug (head_pnt, type)
void *head_pnt; /* structure's pointer */
char *type; /* structure's type */
{
static int translate ();
static int splitline ();
static void disp_immd ();
static void get_size ();
static void read_field ();
static void push ();
static void pop ();
static struct chain *go_forward ();
char line [128]; /* buffer to read a cmd line */
char buffer [128]; /* buffer to split the cmd line */
char *words [ 10]; /* number of words on a line */
int nmbrs [ 10]; /* words translated into number */
char flags [ 10]; /* set if words is a number */
int indxs [ 10]; /* index of words */
struct stack jtab [ 10]; /* list of memorized addresses */
int idx, i;
int readflg = 0;
int code;
unsigned int size;
char *pntr = NULL;
long pshtype;
int wrdcnt = 1;
struct stack stk [STKSIZ_DFN];
int stkpnt = -1;
union value pnt [MAXCMD_DFN];
long typ [MAXCMD_DFN];
unsigned int siz [MAXCMD_DFN];
static char *str [] = {
"_back" , "_exit" , "_jump" , "_save" ,
"_stop" , "_top" , "_up" , "_display" ,
"character" , "short" , "integer" , "long" ,
"float" , "void" , "string" ,
"shdul" , "shent" , "shtra" , "shwav" ,
"cond" , "curtime" , "date" , "flags" ,
"ident" , "itable" , "label" , "next" ,
"prev" , "scdid" , "trans" , "ttable" ,
"uflag" , "valu" , "wave"
};
/* ###------------------------------------------------------### */
/* initialisation : */
/* - allocate a buffer for read words */
/* - break the argument that identifies the structure (type) */
/* into words */
/* - search that words among recognized strings */
/* ###------------------------------------------------------### */
words [0] = buffer;
get_size (siz);
wrdcnt = splitline (words, type);
idx = translate (words, wrdcnt, str, nmbrs, flags, indxs);
typ [idx] = POINTER_DFN | s_DFN | idx;
pnt [idx].dat = head_pnt;
/* ###------------------------------------------------------### */
/* process the command line until the _exit command */
/* ###------------------------------------------------------### */
while ((idx & TYPE_DFN) != _exit_DFN)
{
/* ###------------------------------------------------------### */
/* if the first word of the line has not been recognized, */
/* print an error message. Otherwise, proccess the command line */
/* (generally it is a request for displaying a specific field). */
/* */
/* At this point : */
/* - pnt [] contains all available pointers */
/* - typ [] contains the type of availabale pointers */
/* ###------------------------------------------------------### */
if (idx == _error_DFN)
sch_error (118, "sch_debug", NULL, 0);
else
{
/* ###------------------------------------------------------### */
/* define the type of the structure that may be pushed on */
/* the stack : */
/* - if the pointer is a VOID pointer the type must be */
/* defined on the command line (last word of the command) */
/* ###------------------------------------------------------### */
pshtype = POINTER_DFN | s_DFN | void_DFN;
if ((typ [idx] & TYPE_DFN) == void_DFN)
{
if ((wrdcnt >= 2) && (indxs [wrdcnt - 1] != _error_DFN))
pshtype = POINTER_DFN | s_DFN | indxs [wrdcnt - 1];
else
sch_error (119, "sch_debug", NULL, 0);
}
else
pshtype = typ [idx];
/* ###------------------------------------------------------### */
/* depending on the kind of the first word of the command */
/* activate actions : */
/* - COMMAND (_top, _up, ...) */
/* - POINTER */
/* - for NEXT go forward until the Nth element of the */
/* list. Then, push it on the stack and read fields */
/* - for others push and read fields */
/* - ARRAY */
/* - push the Nth element of the array and read its */
/* fields */
/* - ARRAY OF POINTER */
/* - push the object which address is the Nth element of */
/* the array and read its fields */
/* ###------------------------------------------------------### */
switch (typ [idx] & KIND_DFN)
{
/* ###------------------------------------------------------### */
/* COMMANDS ... */
/* ###------------------------------------------------------### */
case COMMAND_DFN :
switch (typ [idx] & TYPE_DFN)
{
/* ###------------------------------------------------------### */
/* _top COMMAND : reset the stack pointer, call read_field */
/* to read the structure on the top of stack */
/* ###------------------------------------------------------### */
case _top_DFN :
stkpnt = 0;
readflg = 1;
break;
/* ###------------------------------------------------------### */
/* _stop COMMAND : set the stop mark for the structure on */
/* the top of stack */
/* ###------------------------------------------------------### */
case _stop_DFN :
stk [stkpnt].mark = 1;
sch_message (19, "sch_debug", 0);
break;
/* ###------------------------------------------------------### */
/* _back COMMAND : pop structures from the stack until a */
/* marked structure is found. Call read_field to read the */
/* structure on the top of stack */
/* ###------------------------------------------------------### */
case _back_DFN :
while ((stkpnt != 0) && (stk[--stkpnt].mark != 1));
readflg = 1;
break;
/* ###------------------------------------------------------### */
/* _jump COMMAND : push on the stack the structure saved in */
/* the jump table. Call read_field to read the structure on the */
/* top of stack */
/* ###------------------------------------------------------### */
case _jump_DFN :
if ((wrdcnt == 2) && (flags [1] == 1) && (nmbrs [1] < 10))
{
push (stk, &stkpnt, jtab[nmbrs[1]].data, jtab[nmbrs[1]].type);
readflg = 1;
}
else
sch_error (118, "sch_debug", NULL, 0);
break;
/* ###------------------------------------------------------### */
/* _up COMMAND : pop structure from the stack. Call */
/* read_field to read the structure on the top of stack */
/* ###------------------------------------------------------### */
case _up_DFN :
if (wrdcnt == 1)
{
pop (&stkpnt, 1);
readflg = 1;
}
else
{
if ((wrdcnt == 2) && (flags [1] == 1))
{
pop (&stkpnt, nmbrs [1] + 1);
readflg = 1;
}
else
sch_error (118, "sch_debug", NULL, 0);
}
break;
/* ###------------------------------------------------------### */
/* _save COMMAND : save the structure on the top of stack in */
/* the jump table */
/* ###------------------------------------------------------### */
case _save_DFN :
if ((wrdcnt == 2) && (flags [1] == 1) && (nmbrs [1] < 10))
jtab [nmbrs[1]] = stk [stkpnt];
else
sch_error (118, "sch_debug", NULL, 0);
break;
/* ###------------------------------------------------------### */
/* _display COMMAND : display a specified field as an */
/* immediate */
/* ###------------------------------------------------------### */
case _display_DFN :
if ((wrdcnt == 3) && (indxs [1] != _error_DFN))
disp_immd (str, pnt [indxs [1]], indxs [2]);
else
sch_error (118, "sch_debug", NULL, 0);
break;
}
break;
/* ###------------------------------------------------------### */
/* POINTERS ... */
/* ###------------------------------------------------------### */
case POINTER_DFN :
if (idx == next_DFN)
{
if ((wrdcnt == 1) || ((wrdcnt == 2) && (flags [1] == 0)))
{
push (stk, &stkpnt, pnt [idx].dat, pshtype);
readflg = 1;
}
else
{
if (((wrdcnt == 3) || (wrdcnt == 2)) && (flags [1] == 1))
{
pnt [idx].dat = (void *) go_forward (pnt [idx].dat, nmbrs [1]);
push (stk, &stkpnt, pnt [idx].dat, pshtype);
readflg = 1;
}
else
sch_error (118, "sch_debug", NULL, 0);
}
}
else
{
push (stk, &stkpnt, pnt [idx].dat, pshtype);
readflg = 1;
}
break;
/* ###------------------------------------------------------### */
/* ARRAIES of structure */
/* ###------------------------------------------------------### */
case ARRAY_DFN :
if ((wrdcnt > 1) && (flags [1] == 1))
{
size = siz [(typ [idx] & TYPE_DFN)];
pntr = (void *)
(((unsigned int) pnt [idx].dat) + (size * nmbrs [1]));
push (stk, &stkpnt, pntr, pshtype);
readflg = 1;
}
else
sch_error (118, "sch_debug", NULL, 0);
break;
/* ###------------------------------------------------------### */
/* ARRAIES of pointers */
/* ###------------------------------------------------------### */
case ARYOFPNT_DFN :
if ((wrdcnt > 1) && (flags [1] == 1))
{
size = sizeof (void *);
pntr = * (void **)
(((unsigned int) pnt [idx].dat) + (size * nmbrs [1]));
push (stk, &stkpnt, pntr, pshtype);
readflg = 1;
}
else
sch_error (118, "sch_debug", NULL, 0);
break;
}
if (readflg == 1)
{
readflg = 0;
read_field (stk [stkpnt], pnt, typ, str);
}
}
printf ("\n\nCOMMAND > ");
gets (line);
if (strcmp (line ,"."))
{
wrdcnt = splitline (words, line);
idx = translate (words, wrdcnt, str, nmbrs, flags, indxs);
}
}
}
/* ###--------------------------------------------------------------### */
/* function : read_field */
/* description : read the content of a data structure */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void read_field (curpnt, pnt, typ, str)
struct stack curpnt; /* current struct. to be read */
union value *pnt ; /* child structures or data */
long *typ ; /* child struct. or data type */
char **str ; /* recognized strings */
{
unsigned int i ;
struct shdul *shdul_pnt ;
struct shent *shent_pnt ;
struct shtra *shtra_pnt ;
struct shwav *shwav_pnt ;
char **string_pnt;
char *character_pnt;
int *integer_pnt;
/* ###------------------------------------------------------### */
/* initialization */
/* ###------------------------------------------------------### */
for (i=0 ; i<MAXCMD_DFN ; i++)
{
typ [i] = _error_DFN;
pnt [i].dat = NULL;
}
typ [_exit_DFN] = COMMAND_DFN | _exit_DFN ;
typ [_up_DFN] = COMMAND_DFN | _up_DFN ;
typ [_top_DFN] = COMMAND_DFN | _top_DFN ;
typ [_stop_DFN] = COMMAND_DFN | _stop_DFN ;
typ [_back_DFN] = COMMAND_DFN | _back_DFN ;
typ [_jump_DFN] = COMMAND_DFN | _jump_DFN ;
typ [_save_DFN] = COMMAND_DFN | _save_DFN ;
typ [_display_DFN] = COMMAND_DFN | _display_DFN;
switch (curpnt.type & TYPE_DFN)
{
/* ###------------------------------------------------------### */
/* depending on the type of the current structure : */
/* */
/* - define the type of each field : */
/* - the field contains an immediate or a pointer */
/* - what format must be used to print it */
/* - kind of data it contains */
/* */
/* - register the data contained in the field */
/* ###------------------------------------------------------### */
/* ###------------------------------------------------------### */
/* shdul */
/* ###------------------------------------------------------### */
case shdul_DFN :
shdul_pnt = (struct shdul *) curpnt.data;
typ [next_DFN] = POINTER_DFN | s_DFN | shdul_DFN ;
typ [label_DFN] = POINTER_DFN | s_DFN | void_DFN ;
typ [ttable_DFN] = ARYOFPNT_DFN | s_DFN | shent_DFN ;
typ [itable_DFN] = ARYOFPNT_DFN | s_DFN | shwav_DFN ;
typ [curtime_DFN] = IMMEDIATE_DFN | u_DFN | integer_DFN;
pnt [next_DFN].dat = shdul_pnt->NEXT ;
pnt [label_DFN].dat = shdul_pnt->LABEL ;
pnt [ttable_DFN].dat = shdul_pnt->TTABLE ;
pnt [itable_DFN].dat = shdul_pnt->ITABLE ;
pnt [curtime_DFN].imd = shdul_pnt->CURTIME;
break;
/* ###------------------------------------------------------### */
/* shtra */
/* ###------------------------------------------------------### */
case shtra_DFN :
shtra_pnt = (struct shtra *) curpnt.data;
typ [next_DFN] = POINTER_DFN | s_DFN | shtra_DFN ;
typ [prev_DFN] = POINTER_DFN | s_DFN | void_DFN ;
typ [wave_DFN] = POINTER_DFN | s_DFN | shtra_DFN ;
typ [date_DFN] = IMMEDIATE_DFN | u_DFN | integer_DFN ;
typ [ident_DFN] = POINTER_DFN | s_DFN | void_DFN ;
typ [scdid_DFN] = POINTER_DFN | s_DFN | void_DFN ;
typ [uflag_DFN] = IMMEDIATE_DFN | x_DFN | integer_DFN ;
typ [cond_DFN] = IMMEDIATE_DFN | x_DFN | character_DFN;
typ [valu_DFN] = IMMEDIATE_DFN | x_DFN | character_DFN;
typ [flags_DFN] = IMMEDIATE_DFN | x_DFN | short_DFN ;
pnt [next_DFN].dat = shtra_pnt->NEXT ;
pnt [prev_DFN].dat = shtra_pnt->PREV ;
pnt [wave_DFN].dat = shtra_pnt->WAVE ;
pnt [date_DFN].imd = shtra_pnt->DATE ;
pnt [ident_DFN].dat = shtra_pnt->IDENT;
pnt [scdid_DFN].dat = shtra_pnt->SCDID;
pnt [uflag_DFN].imd = shtra_pnt->UFLAG;
pnt [cond_DFN].imd = shtra_pnt->COND ;
pnt [valu_DFN].imd = shtra_pnt->VALU ;
pnt [flags_DFN].imd = shtra_pnt->FLAGS;
break;
/* ###------------------------------------------------------### */
/* shwav */
/* ###------------------------------------------------------### */
case shwav_DFN :
shwav_pnt = (struct shwav *) curpnt.data;
typ [next_DFN] = POINTER_DFN | s_DFN | shwav_DFN ;
typ [ident_DFN] = POINTER_DFN | s_DFN | void_DFN ;
typ [trans_DFN] = POINTER_DFN | s_DFN | shtra_DFN ;
pnt [next_DFN].dat = shwav_pnt->NEXT ;
pnt [ident_DFN].dat = shwav_pnt->IDENT;
pnt [trans_DFN].dat = shwav_pnt->TRANS;
break;
/* ###------------------------------------------------------### */
/* shent */
/* ###------------------------------------------------------### */
case shent_DFN :
shent_pnt = (struct shent *) curpnt.data;
typ [next_DFN] = POINTER_DFN | s_DFN | shent_DFN ;
typ [date_DFN] = IMMEDIATE_DFN | u_DFN | integer_DFN;
typ [trans_DFN] = ARYOFPNT_DFN | s_DFN | shtra_DFN ;
pnt [next_DFN].dat = shent_pnt->NEXT;
pnt [date_DFN].imd = shent_pnt->DATE;
pnt [trans_DFN].dat = shent_pnt->TRANS;
break;
/* ###------------------------------------------------------### */
/* string */
/* ###------------------------------------------------------### */
case string_DFN :
string_pnt = (char **) curpnt.data;
typ [string_DFN] = IMMEDIATE_DFN | s_DFN | string_DFN;
pnt [string_DFN].dat = *string_pnt;
break;
/* ###------------------------------------------------------### */
/* character */
/* ###------------------------------------------------------### */
case character_DFN :
character_pnt = (char *) curpnt.data;
typ [character_DFN] = IMMEDIATE_DFN | x_DFN | character_DFN;
pnt [character_DFN].imd = *character_pnt;
break;
/* ###------------------------------------------------------### */
/* integer */
/* ###------------------------------------------------------### */
case integer_DFN :
integer_pnt = (int *) curpnt.data;
typ [integer_DFN] = IMMEDIATE_DFN | d_DFN | integer_DFN;
pnt [integer_DFN].imd = *integer_pnt;
break;
}
/* ###------------------------------------------------------### */
/* scan the list of recongnized strings to print those */
/* values that are not empty (different form _error_DFN) : */
/* */
/* - if it contains an immediate, print it following the */
/* required format */
/* */
/* - if it contains a pointer, just print the pointer */
/* indication, ->, and "availbale" */
/* */
/* - if it contains an array, just print the array */
/* indication, =>, and "availbale" */
/* ###------------------------------------------------------### */
printf ("--------- current structure : %s ---------\n\n",
str [curpnt.type & TYPE_DFN]);
for (i=0 ; i<MAXCMD_DFN ; i++)
{
if ((typ [i] & KIND_DFN) == IMMEDIATE_DFN)
{
printf (" %-15s: ", str [i]);
switch (typ [i] & FORMAT_DFN)
{
case s_DFN :
if (pnt[i].dat != NULL)
printf ("%s", pnt[i].dat);
printf ("\n");
break;
case f_DFN :
printf ("%f\n", pnt[i].imd);
break;
case u_DFN :
printf ("%u\n", pnt[i].imd);
break;
case c_DFN :
printf ("%c\n", pnt[i].imd);
break;
case d_DFN :
printf ("%d\n", pnt[i].imd);
break;
case l_DFN :
printf ("%ld\n", pnt[i].imd);
break;
case x_DFN :
printf ("0x%x\n", pnt[i].imd);
break;
}
}
if ((typ [i] & KIND_DFN) == POINTER_DFN)
{
printf ("-> %-15s: ", str [i]);
if (pnt[i].dat != NULL)
printf ("available");
printf ("\n");
}
if ( ((typ [i] & KIND_DFN) == ARRAY_DFN ) ||
((typ [i] & KIND_DFN) == ARYOFPNT_DFN) )
{
printf ("=> %-15s: ", str [i]);
if (pnt[i].dat != NULL)
printf ("available");
printf ("\n");
}
}
}
/* ###--------------------------------------------------------------### */
/* function : splitline */
/* description : read a line (the space must have been reserved by the */
/* caller - *words) from the standard input and split it */
/* into seperate words. Return the number of words read. */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static int splitline (words, line)
char **words;
char *line ;
{
char *heap = *words;
int new = 1;
int wrdcnt = 0;
int i = 0;
int j = 0;
/* ###------------------------------------------------------### */
/* copy the line read from input into the words until a */
/* space has been found. Then, increment the word count and */
/* begin filling the next word */
/* ###------------------------------------------------------### */
while ((heap[j] = line[i++]) != '\0')
{
if ((heap[j] != ' ') && (heap[j] != '\t'))
{
new = 0;
j++;
}
else
{
if (new != 1)
{
heap [j++] = '\0';
words [++wrdcnt] = heap + j;
new = 1;
}
}
}
if (new != 1)
wrdcnt++;
return (wrdcnt);
}
/* ###--------------------------------------------------------------### */
/* function : push */
/* description : push a structure on the stack */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void push (stk, stkpnt, data, type)
struct stack *stk;
int *stkpnt;
void *data;
short type;
{
int stkidx = *stkpnt;
if (stkidx == STKSIZ_DFN)
sch_message (20, "sch_debug", 0);
else
{
if (data != NULL)
{
stkidx++;
stk [stkidx].data = data;
stk [stkidx].type = type;
stk [stkidx].mark = 0;
*stkpnt = stkidx;
}
else
sch_error (120, "sch_debug", NULL, 0);
}
}
/* ###--------------------------------------------------------------### */
/* function : pop */
/* description : pop N structures from the stack */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void pop (stkpnt, count)
int *stkpnt;
int count;
{
int stkidx = *stkpnt;
if (stkidx <= count)
stkidx = 0;
else
stkidx -= count;
*stkpnt = stkidx;
}
/* ###--------------------------------------------------------------### */
/* function : go_forward */
/* description : go forward through the NEXT field to find the Nth */
/* structure in the list and return it */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static struct chain *go_forward (pnt, count)
struct chain *pnt ;
int count;
{
while ((count > 0) && (pnt != NULL) && (pnt->NEXT != NULL))
{
pnt = pnt->NEXT;
count--;
}
return (pnt);
}
/* ###--------------------------------------------------------------### */
/* function : translate */
/* description : find the index of each word read from the command */
/* line. For each word check if it is a number. Return */
/* the index of the first word. */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static int translate (words, wrdcnt, strgs, nmbrs, flags, indxs)
char **words ; /* list of words */
int wrdcnt; /* number of words */
char **strgs ; /* list of recognized strings */
int *nmbrs ; /* words translated to numbers */
char *flags ; /* set if word is a number */
int *indxs ; /* words' index in strgs table */
{
int i , j;
/* ###------------------------------------------------------### */
/* initialize flags and indxs */
/* ###------------------------------------------------------### */
for (i=0 ; i<10 ; i++)
{
flags [i] = 0;
indxs [i] = _error_DFN;
}
/* ###------------------------------------------------------### */
/* for each word : */
/* - check if it is a number */
/* - try to locate the word among the recognized strings. */
/* If found save it's index */
/* ###------------------------------------------------------### */
for (i=0 ; i<wrdcnt ; i++)
{
flags [i] = sscanf (words [i], "%u", &nmbrs [i]);
for (j=0; j<MAXCMD_DFN ; j++)
{
if (!strcmp (strgs [j], words [i]))
{
indxs [i] = j;
break;
}
}
}
return (indxs [0]);
}
static void get_size (siz)
unsigned int siz [];
{
int i;
for (i=0 ; i<MAXCMD_DFN ; i++)
siz [i] = 0;
siz [character_DFN] = sizeof (char);
siz [short_DFN] = sizeof (short);
siz [integer_DFN] = sizeof (int);
siz [long_DFN] = sizeof (long);
siz [string_DFN] = sizeof (char *);
siz [shent_DFN] = sizeof (struct shent);
siz [shwav_DFN] = sizeof (struct shwav);
siz [shtra_DFN] = sizeof (struct shtra);
}
/* ###--------------------------------------------------------------### */
/* function : disp_immd */
/* description : display a specific field as an immediate */
/* called func. : none */
/* ###--------------------------------------------------------------### */
static void disp_immd (str, pnt , type)
char **str;
union value pnt ;
int type ;
{
char *lcl_str;
printf (" %-15s: ", str [type]);
switch (type)
{
case string_DFN :
if (((char *) pnt.dat) != NULL)
printf ("%s", (char *) pnt.dat);
printf ("\n");
break;
case float_DFN :
printf ("%f\n", pnt.imd);
break;
case character_DFN :
printf ("%c\n", pnt.imd);
break;
case short_DFN :
case integer_DFN :
case long_DFN :
printf ("0x%x\n", pnt.imd);
break;
default :
sch_error (118, "sch_debug", NULL, 0);
}
}

View File

@ -0,0 +1,83 @@
/* ###--------------------------------------------------------------### */
/* file : sch_debug.h */
/* date : Aug 10 1997 */
/* version : v101 */
/* author : Pirouz BAZARGAN SABET */
/* description : declaration of diefines, global variables and, */
/* functions used in the debugger */
/* ###--------------------------------------------------------------### */
struct stack /* debugger's stack's structure */
{
short type; /* type of the current ponter */
short mark; /* stop mark */
void *data; /* current pointer */
};
union value
{
void *dat;
long imd;
};
#define STKSIZ_DFN 500 /* debugger's stack size */
#define KIND_DFN 0xff000000
#define COMMAND_DFN 0x01000000
#define IMMEDIATE_DFN 0x02000000
#define POINTER_DFN 0x03000000
#define ARRAY_DFN 0x04000000
#define ARYOFPNT_DFN 0x05000000
#define FORMAT_DFN 0x00ff0000
#define s_DFN 0x00010000
#define u_DFN 0x00020000
#define d_DFN 0x00030000
#define l_DFN 0x00040000
#define x_DFN 0x00050000
#define c_DFN 0x00060000
#define f_DFN 0x00070000
#define _error_DFN 0x0000ffff
#define TYPE_DFN 0x0000ffff
#define _back_DFN 0
#define _exit_DFN _back_DFN + 1
#define _jump_DFN _exit_DFN + 1
#define _save_DFN _jump_DFN + 1
#define _stop_DFN _save_DFN + 1
#define _top_DFN _stop_DFN + 1
#define _up_DFN _top_DFN + 1
#define _display_DFN _up_DFN + 1
#define character_DFN _display_DFN + 1
#define short_DFN character_DFN + 1
#define integer_DFN short_DFN + 1
#define long_DFN integer_DFN + 1
#define float_DFN long_DFN + 1
#define void_DFN float_DFN + 1
#define string_DFN void_DFN + 1
#define shdul_DFN string_DFN + 1
#define shent_DFN shdul_DFN + 1
#define shtra_DFN shent_DFN + 1
#define shwav_DFN shtra_DFN + 1
#define cond_DFN shwav_DFN + 1
#define curtime_DFN cond_DFN + 1
#define date_DFN curtime_DFN + 1
#define flags_DFN date_DFN + 1
#define ident_DFN flags_DFN + 1
#define itable_DFN ident_DFN + 1
#define label_DFN itable_DFN + 1
#define next_DFN label_DFN + 1
#define prev_DFN next_DFN + 1
#define scdid_DFN prev_DFN + 1
#define trans_DFN scdid_DFN + 1
#define ttable_DFN trans_DFN + 1
#define uflag_DFN ttable_DFN + 1
#define valu_DFN uflag_DFN + 1
#define wave_DFN valu_DFN + 1
#define MAXCMD_DFN wave_DFN + 1

View File

@ -0,0 +1,44 @@
/* ###--------------------------------------------------------------### */
/* file : sch_error.c */
/* date : Aug 10 1997 */
/* version : v101 */
/* authors : Nizar ABDALLAH, Pirouz BAZARGAN SABET */
/* content : high level function */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
/* ###--------------------------------------------------------------### */
/* function : sch_error */
/* description : print an error message depending on the argument code */
/* called func. : none */
/* ###--------------------------------------------------------------### */
int sch_error (code, str1, str2)
int code;
char *str1;
char *str2;
{
fprintf (stderr,"Error %d in `%s`:", code, str1);
switch (code)
{
case 118:
fprintf (stderr,"command not understood\n");
break;
case 119:
fprintf (stderr,"cannot display VOID pointer\n");
break;
case 120:
fprintf (stderr,"cannot push NULL pointer\n");
break;
default:
fprintf (stderr,"unknown error code\n");
break;
}
return (1);
}

View File

@ -0,0 +1,18 @@
/* ###--------------------------------------------------------------### */
/* file : sch_globals.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
struct shtra *SCH_FREE_SHTRA = NULL;
struct shent *SCH_FREE_SHENT = NULL;
struct shwav *SCH_FREE_SHWAV = NULL;
struct shent **SCH_TIME_ENTRY = NULL;
struct shwav **SCH_IDENT_ENTRY = NULL;

View File

@ -0,0 +1,29 @@
/* ###--------------------------------------------------------------### */
/* file : sch_hash.c */
/* date : Aug 10 1997 */
/* version : v101 */
/* authors : Nizar ABDALLAH, Pirouz BAZARGAN SABET */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
/* ###--------------------------------------------------------------### */
/* function : sch_hash */
/* description : return a hash code */
/* called func. : none */
/* ###--------------------------------------------------------------### */
unsigned int sch_hash (ident)
void *ident;
{
unsigned int index;
index = (unsigned int) ident;
index = (((index >> 2) ^ (index >> 10)) + (index >> 12) + (index >> 20));
index &= index & 0x000000ff;
return (index);
}

View File

@ -0,0 +1,72 @@
/* ###--------------------------------------------------------------### */
/* file : sch_insentry.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_insentry */
/* description : insert a new transaction into the scheduler (time */
/* access) */
/* called func. : sch_addshent */
/* ###--------------------------------------------------------------### */
void sch_insentry (pt_shdul, pt_shtra)
struct shdul *pt_shdul;
struct shtra *pt_shtra;
{
struct shent *pt_shent ;
struct shent *pt_prvent ;
unsigned int time_window;
unsigned int wind_number;
unsigned int wind_offset;
time_window = (pt_shtra->DATE >> 3) & 0x000000ff;
wind_number = (pt_shtra->DATE >> 11) & 0x001fffff;
wind_offset = (pt_shtra->DATE ) & 0x00000007;
pt_shent = pt_shdul->TTABLE [time_window];
if ((pt_shent == NULL) || (pt_shent->DATE > wind_number))
{
pt_shdul->TTABLE [time_window] = sch_addshent (pt_shent, wind_number);
pt_shent = pt_shdul->TTABLE [time_window];
}
else
{
pt_prvent = pt_shent;
while ((pt_shent != NULL) && (pt_shent->DATE < wind_number))
{
pt_prvent = pt_shent ;
pt_shent = pt_shent->NEXT;
}
if ((pt_shent == NULL) || (pt_shent->DATE > wind_number))
{
pt_shent = sch_addshent (pt_shent, wind_number);
pt_prvent->NEXT = pt_shent;
}
}
pt_shtra->FLAGS |= SCH_TRA_ENTFIRST;
pt_shtra->PREV = (struct shtra *) pt_shent;
pt_shtra->NEXT = pt_shent->TRANS [wind_offset] ;
if (pt_shtra->NEXT != NULL)
{
pt_shtra->NEXT->FLAGS ^= SCH_TRA_ENTFIRST ;
pt_shtra->NEXT->PREV = (void *) pt_shtra;
}
pt_shent->TRANS [wind_offset] = pt_shtra;
}

View File

@ -0,0 +1,82 @@
/* ###--------------------------------------------------------------### */
/* file : sch_inswave.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_inswave */
/* description : insert a new transaction into the scheduler (main */
/* identifier access) */
/* called func. : sch_rmventry */
/* ###--------------------------------------------------------------### */
void sch_inswave (pt_shdul, pt_shtra, flags)
struct shdul *pt_shdul;
struct shtra *pt_shtra;
unsigned short flags ;
{
struct shtra *pt_afttra;
struct shtra *pt_deltra;
struct shtra *pt_lsttra;
struct shtra *pt_tmptra;
struct shwav *pt_shwav ;
unsigned int index ;
index = sch_hash (pt_shtra->IDENT);
pt_shwav = pt_shdul->ITABLE [index];
while ((pt_shwav != NULL) && (pt_shwav->IDENT != pt_shtra->IDENT))
pt_shwav = pt_shwav->NEXT;
if (pt_shwav == NULL)
{
pt_shwav = sch_addshwav (pt_shdul->ITABLE [index],
pt_shtra->IDENT );
pt_shdul->ITABLE [index] = pt_shwav;
}
pt_lsttra = NULL;
pt_deltra = NULL;
pt_afttra = pt_shwav->TRANS;
while ((pt_afttra != NULL) && (pt_afttra->DATE < pt_shtra->DATE))
{
pt_lsttra = pt_afttra;
if ((pt_afttra->COND != pt_shtra->COND) ||
(pt_afttra->VALU != pt_shtra->VALU) )
pt_deltra = pt_afttra;
pt_afttra = pt_afttra->WAVE;
}
if ((flags & SCH_TRA_DELAFTER) != 0)
{
while (pt_afttra != NULL)
pt_afttra = sch_rmventry (pt_afttra);
}
if (pt_lsttra != NULL)
pt_lsttra->WAVE = pt_shtra;
else
pt_shwav->TRANS = pt_shtra;
pt_shtra->WAVE = pt_afttra;
if ((pt_deltra != NULL) && ((flags & SCH_TRA_DELBEFORE) != 0))
{
pt_tmptra = pt_shwav->TRANS;
while (pt_tmptra != pt_deltra)
pt_tmptra = sch_rmventry (pt_tmptra);
pt_shwav->TRANS = sch_rmventry (pt_tmptra);
}
}

View File

@ -0,0 +1,38 @@
/* ###--------------------------------------------------------------### */
/* file : sch_message.c */
/* date : Aug 10 1997 */
/* version : v101 */
/* authors : Nizar ABDALLAH, Pirouz BAZARGAN SABET */
/* content : high level function */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
/* ###--------------------------------------------------------------### */
/* function : sch_message */
/* description : print a message corresponding to the argument code */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void sch_message (code, str1, nmb1)
int code;
char *str1;
int nmb1;
{
fprintf (stdout, "`%s` :", str1);
switch (code)
{
case 19:
fprintf (stdout, "stop mark on current structure\n");
break;
case 20:
fprintf (stdout, "--- STACK OVERFLOW !! ---\n");
break;
default:
fprintf (stderr,"unknown code %d\n", code);
}
}

View File

@ -0,0 +1,56 @@
/* ###--------------------------------------------------------------### */
/* file : sch_rmventry.c */
/* date : Aug 5 1997 */
/* version : v101 */
/* author : Nizar ABDALLAH, Pirouz BARAGAN SABET */
/* description : scheduler */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "sch.h"
/* ###--------------------------------------------------------------### */
/* function : sch_rmventry */
/* description : remove a transaction from the time entry of the */
/* scheduler */
/* called func. : none */
/* ###--------------------------------------------------------------### */
struct shtra *sch_rmventry (pt_shtra)
struct shtra *pt_shtra;
{
struct shent *pt_shent ;
struct shtra *pt_nxttra ;
unsigned int wind_offset;
pt_nxttra = pt_shtra->WAVE;
if ((pt_shtra->FLAGS & SCH_TRA_ENTFIRST) != 0)
{
pt_shent = (struct shent *) pt_shtra->PREV;
wind_offset = pt_shtra->DATE & 0x00000007;
pt_shent->TRANS [wind_offset] = pt_shtra->NEXT;
if (pt_shtra->NEXT != NULL)
{
pt_shtra->NEXT->FLAGS |= SCH_TRA_ENTFIRST ;
pt_shtra->NEXT->PREV = (struct shtra *) pt_shent;
}
}
else
{
pt_shtra->PREV->NEXT = pt_shtra->NEXT;
if (pt_shtra->NEXT != NULL)
pt_shtra->NEXT->PREV = pt_shtra->PREV;
}
pt_shtra->NEXT = SCH_FREE_SHTRA;
SCH_FREE_SHTRA = pt_shtra ;
return (pt_nxttra);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,205 @@
/* ###--------------------------------------------------------------### */
/* file : vh_debug.h */
/* date : Aug 20 1997 */
/* version : v3.0 */
/* author : Pirouz BAZARGAN SABET */
/* description : declaration of diefines, global variables and, */
/* functions used in the debugger */
/* ###--------------------------------------------------------------### */
struct stack /* debugger's stack's structure */
{
short type; /* type of the current ponter */
short mark; /* stop mark */
void *data; /* current pointer */
};
union value
{
void *dat;
long imd;
};
#define STKSIZ_DFN 500 /* debugger's stack size */
#define KIND_DFN 0xff000000
#define COMMAND_DFN 0x01000000
#define IMMEDIATE_DFN 0x02000000
#define POINTER_DFN 0x03000000
#define ARRAY_DFN 0x04000000
#define ARYOFPNT_DFN 0x05000000
#define FORMAT_DFN 0x00ff0000
#define s_DFN 0x00010000
#define u_DFN 0x00020000
#define d_DFN 0x00030000
#define l_DFN 0x00040000
#define x_DFN 0x00050000
#define c_DFN 0x00060000
#define f_DFN 0x00070000
#define ABL_DFN 0x00080000
#define BDD_DFN 0x00090000
#define GEX_DFN 0x000a0000
#define _error_DFN 0x0000ffff
#define TYPE_DFN 0x0000ffff
#define _back_DFN 0
#define _exit_DFN (_back_DFN + 1)
#define _jump_DFN (_exit_DFN + 1)
#define _save_DFN (_jump_DFN + 1)
#define _stop_DFN (_save_DFN + 1)
#define _top_DFN (_stop_DFN + 1)
#define _up_DFN (_top_DFN + 1)
#define _display_DFN (_up_DFN + 1)
#define character_DFN (_display_DFN + 1)
#define short_DFN (character_DFN + 1)
#define integer_DFN (short_DFN + 1)
#define long_DFN (integer_DFN + 1)
#define float_DFN (long_DFN + 1)
#define void_DFN (float_DFN + 1)
#define string_DFN (void_DFN + 1)
#define chain_DFN (string_DFN + 1)
#define ptype_DFN (chain_DFN + 1)
#define lofig_DFN (ptype_DFN + 1)
#define locon_DFN (lofig_DFN + 1)
#define losig_DFN (locon_DFN + 1)
#define loins_DFN (losig_DFN + 1)
#define befig_DFN (loins_DFN + 1)
#define bereg_DFN (befig_DFN + 1)
#define bemsg_DFN (bereg_DFN + 1)
#define berin_DFN (bemsg_DFN + 1)
#define beout_DFN (berin_DFN + 1)
#define bebus_DFN (beout_DFN + 1)
#define beaux_DFN (bebus_DFN + 1)
#define bedly_DFN (beaux_DFN + 1)
#define bebux_DFN (bedly_DFN + 1)
#define bepor_DFN (bebux_DFN + 1)
#define begen_DFN (bepor_DFN + 1)
#define biabl_DFN (begen_DFN + 1)
#define binode_DFN (biabl_DFN + 1)
#define paseq_DFN (binode_DFN + 1)
#define pagrp_DFN (paseq_DFN + 1)
#define paiol_DFN (pagrp_DFN + 1)
#define papat_DFN (paiol_DFN + 1)
#define pacom_DFN (papat_DFN + 1)
#define paini_DFN (pacom_DFN + 1)
#define paevt_DFN (paini_DFN + 1)
#define pains_DFN (paevt_DFN + 1)
#define bussig_DFN (pains_DFN + 1)
#define lkdfig_DFN (bussig_DFN + 1)
#define lkdins_DFN (lkdfig_DFN + 1)
#define simsig_DFN (lkdins_DFN + 1)
#define wrbsig_DFN (simsig_DFN + 1)
#define wriaux_DFN (wrbsig_DFN + 1)
#define wribux_DFN (wriaux_DFN + 1)
#define wrireg_DFN (wribux_DFN + 1)
#define wrssig_DFN (wrireg_DFN + 1)
#define wrimsg_DFN (wrssig_DFN + 1)
#define shdul_DFN (wrimsg_DFN + 1)
#define shent_DFN (shdul_DFN + 1)
#define shtra_DFN (shent_DFN + 1)
#define shwav_DFN (shtra_DFN + 1)
#define abl_DFN (shwav_DFN + 1)
#define bdd_DFN (abl_DFN + 1)
#define gex_DFN (bdd_DFN + 1)
#define actflag_DFN (gex_DFN + 1)
#define aux_ref_DFN (actflag_DFN + 1)
#define blank_DFN (aux_ref_DFN + 1)
#define buffer_DFN (blank_DFN + 1)
#define bus_ref_DFN (buffer_DFN + 1)
#define bux_ref_DFN (bus_ref_DFN + 1)
#define capa_DFN (bux_ref_DFN + 1)
#define cndabl_DFN (capa_DFN + 1)
#define cndnode_DFN (cndabl_DFN + 1)
#define cndval_DFN (cndnode_DFN + 1)
#define cond_DFN (cndval_DFN + 1)
#define curcom_DFN (cond_DFN + 1)
#define curpat_DFN (curcom_DFN + 1)
#define curtime_DFN (curpat_DFN + 1)
#define curval_DFN (curtime_DFN + 1)
#define data_DFN (curval_DFN + 1)
#define date_DFN (data_DFN + 1)
#define deccom_DFN (date_DFN + 1)
#define depend_DFN (deccom_DFN + 1)
#define direction_DFN (depend_DFN + 1)
#define dly_ref_DFN (direction_DFN + 1)
#define drvseq_DFN (dly_ref_DFN + 1)
#define drvval_DFN (drvseq_DFN + 1)
#define endflg_DFN (drvval_DFN + 1)
#define errflg_DFN (endflg_DFN + 1)
#define eval_DFN (errflg_DFN + 1)
#define figname_DFN (eval_DFN + 1)
#define filname_DFN (figname_DFN + 1)
#define findex_DFN (filname_DFN + 1)
#define flag_DFN (findex_DFN + 1)
#define flags_DFN (flag_DFN + 1)
#define format_DFN (flags_DFN + 1)
#define glnext_DFN (format_DFN + 1)
#define ident_DFN (glnext_DFN + 1)
#define index_DFN (ident_DFN + 1)
#define insname_DFN (index_DFN + 1)
#define instance_DFN (insname_DFN + 1)
#define iolnbr_DFN (instance_DFN + 1)
#define itable_DFN (iolnbr_DFN + 1)
#define label_DFN (itable_DFN + 1)
#define length_DFN (label_DFN + 1)
#define level_DFN (length_DFN + 1)
#define line_DFN (level_DFN + 1)
#define lineno_DFN (line_DFN + 1)
#define message_DFN (lineno_DFN + 1)
#define mode_DFN (message_DFN + 1)
#define model_DFN (mode_DFN + 1)
#define modelchain_DFN (model_DFN + 1)
#define msg_ref_DFN (modelchain_DFN + 1)
#define name_DFN (msg_ref_DFN + 1)
#define namechain_DFN (name_DFN + 1)
#define next_DFN (namechain_DFN + 1)
#define node_DFN (next_DFN + 1)
#define nxtpat_DFN (node_DFN + 1)
#define oldcom_DFN (nxtpat_DFN + 1)
#define oldpat_DFN (oldcom_DFN + 1)
#define out_ref_DFN (oldpat_DFN + 1)
#define patnbr_DFN (out_ref_DFN + 1)
#define position_DFN (patnbr_DFN + 1)
#define prev_DFN (position_DFN + 1)
#define prjbvl_DFN (prev_DFN + 1)
#define prjrvl_DFN (prjbvl_DFN + 1)
#define prjval_DFN (prjrvl_DFN + 1)
#define redins_DFN (prjval_DFN + 1)
#define redlst_DFN (redins_DFN + 1)
#define reg_ref_DFN (redlst_DFN + 1)
#define root_DFN (reg_ref_DFN + 1)
#define savflg_DFN (root_DFN + 1)
#define scdid_DFN (savflg_DFN + 1)
#define sig_DFN (scdid_DFN + 1)
#define simflag_DFN (sig_DFN + 1)
#define simval_DFN (simflag_DFN + 1)
#define subseq_DFN (simval_DFN + 1)
#define text_DFN (subseq_DFN + 1)
#define time_DFN (text_DFN + 1)
#define time_unit_DFN (time_DFN + 1)
#define trans_DFN (time_unit_DFN + 1)
#define ttable_DFN (trans_DFN + 1)
#define type_DFN (ttable_DFN + 1)
#define uflag_DFN (type_DFN + 1)
#define user_DFN (uflag_DFN + 1)
#define usrval_DFN (user_DFN + 1)
#define valabl_DFN (usrval_DFN + 1)
#define valnode_DFN (valabl_DFN + 1)
#define valsiz_DFN (valnode_DFN + 1)
#define valu_DFN (valsiz_DFN + 1)
#define value_DFN (valu_DFN + 1)
#define wave_DFN (value_DFN + 1)
#define MAXCMD_DFN (wave_DFN + 1)

View File

@ -0,0 +1,7 @@
struct typoin /* structure used by dast_dbg */
{ /* to store its state */
short type; /* code of current structure */
short mark; /* stop mark */
void *data; /* pointer of the structure */
};

View File

@ -0,0 +1,42 @@
/* ###--------------------------------------------------------------### */
/* file : vh_globals.c */
/* date : Nov 15 1995 */
/* version : v2.01 */
/* author : Pirouz BARAGAN SABET */
/* description : VHDL compiler and simulation tool. */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include <string.h>
#include "mut.h"
#include "mlo.h"
#include "log.h"
#include "beh.h"
#include "sch.h"
#include "vh_ltype.h"
struct lofig *VHS_LOFPNT = NULL;
struct lkdfig *VHL_HEDLKF = NULL;
struct shdul *VHX_SHDUL = NULL;
struct ptype *VHX_EXECUTE = NULL;
struct chain *VHX_SIGUPD = NULL;
struct chain *VHX_BUSUPD = NULL;
struct chain *VHX_BUXUPD = NULL;
struct chain *VHX_REGUPD = NULL;
struct chain *VHX_AUXUPD = NULL;
unsigned int VHX_BUSERR = 0 ;
unsigned int VHX_BUXERR = 0 ;
unsigned int VHX_REGERR = 0 ;
unsigned int VHX_MSGERR = 0 ;
unsigned int *VHX_VECTOR_TRANS = NULL;
unsigned char *VHX_VECTOR_VALUE = NULL;
unsigned int *VHX_VECTOR_PROBA = NULL;
struct lkdmdl *VHL_MODELS = NULL;
unsigned char VHX_SCH_TRA_MODE = SCH_TRA_DELAFTER | SCH_TRA_DELBEFORE ;

View File

@ -0,0 +1,35 @@
/* ###--------------------------------------------------------------### */
/* file : vh_globals.h */
/* date : Aug 20 1997 */
/* version : v3.0 */
/* author : Pirouz BAZARGAN SABET */
/* content : declaration of functions and global variables used by */
/* the simulator */
/* ###--------------------------------------------------------------### */
extern struct lofig *VHS_LOFPNT ;
extern struct lkdfig *VHL_HEDLKF ;
extern struct shdul *VHX_SHDUL ;
extern struct ptype *VHX_EXECUTE ;
extern struct chain *VHX_SIGUPD ;
extern struct chain *VHX_BUSUPD ;
extern struct chain *VHX_BUXUPD ;
extern struct chain *VHX_REGUPD ;
extern struct chain *VHX_AUXUPD ;
extern unsigned int VHX_BUSERR ;
extern unsigned int VHX_BUXERR ;
extern unsigned int VHX_REGERR ;
extern unsigned int VHX_MSGERR ;
extern unsigned int *VHX_VECTOR_TRANS ;
extern unsigned char *VHX_VECTOR_VALUE ;
extern unsigned int *VHX_VECTOR_PROBA ;
extern struct lkdmdl *VHL_MODELS ;
extern unsigned char VHX_SCH_TRA_MODE ;

View File

@ -0,0 +1,73 @@
/* ###--------------------------------------------------------------### */
/* file : vh_init.c */
/* date : Dec 13 1999 */
/* version : v3.02 */
/* author : Pirouz BAZARGAN SABET */
/* description : this file contains the following functions */
/* vhi_addcmodel, vhi_models */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "vh_ltype.h"
#include "vh_globals.h"
#include "vh_util.h"
/* ###--------------------------------------------------------------### */
/* function : vhi_addcmodel */
/* description : create a data structure that associate the c model's */
/* name and the pointer of the function that represents */
/* that C model */
/* called func. : vhu_alloc, namealloc */
/* ###--------------------------------------------------------------### */
void vhi_addcmodel (str, fonc_pnt)
char *str ;
void ( *fonc_pnt) ();
{
struct lkdmdl *model;
model = (struct lkdmdl *) vhu_alloc (sizeof (struct lkdmdl), VHU_ALIGN);
model->NAME = namealloc (str);
model->FONC = fonc_pnt ;
model->NEXT = VHL_MODELS ;
VHL_MODELS = model;
}
/* ###--------------------------------------------------------------### */
/* function : vhi_models */
/* description : declare available C models */
/* called func. : vhi_addcmodel */
/* ###--------------------------------------------------------------### */
void vhi_models ()
{
extern void c_sr1k_8a ();
extern void c_sr1k_8b ();
extern void c_sr8k_8a ();
extern void c_fsyn_sr1k_1 ();
extern void c_fsyn_sr1k_4 ();
extern void c_fsyn_sr1k_10 ();
extern void c_fsyn_sr1k_24 ();
extern void c_fsyn_sr1k_56 ();
extern void c_fsyn_sr4k_10 ();
extern void c_hada_repondeur ();
vhi_addcmodel ("c_sr1k_8a" , c_sr1k_8a );
vhi_addcmodel ("c_sr1k_8b" , c_sr1k_8b );
vhi_addcmodel ("c_sr8k_8a" , c_sr8k_8a );
vhi_addcmodel ("c_fsyn_sr1k_1" , c_fsyn_sr1k_1 );
vhi_addcmodel ("c_fsyn_sr1k_4" , c_fsyn_sr1k_4 );
vhi_addcmodel ("c_fsyn_sr1k_10" , c_fsyn_sr1k_10 );
vhi_addcmodel ("c_fsyn_sr1k_24" , c_fsyn_sr1k_24 );
vhi_addcmodel ("c_fsyn_sr1k_56" , c_fsyn_sr1k_56 );
vhi_addcmodel ("c_fsyn_sr4k_10" , c_fsyn_sr4k_10 );
vhi_addcmodel ("c_hada_repondeur", c_hada_repondeur);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
/* ###--------------------------------------------------------------### */
/* file : vh_lspec.h */
/* date : Aug 20 1997 */
/* version : v3.0 */
/* authors : VUONG H.N., Pirouz BAZARGAN SABET */
/* content : contains defines, external variables and funtions used*/
/* by the linker */
/* ###--------------------------------------------------------------### */
extern struct prjbvl *vhl_addprjbvl ();
extern struct prjrvl *vhl_addprjrvl ();
extern struct redlst *vhl_addredlst ();
extern struct simsig *vhl_addsimsig ();
extern struct bussig *vhl_addbussig ();
extern struct wrbsig *vhl_addwrbsig ();
extern struct wrireg *vhl_addwrireg ();
extern struct wribux *vhl_addwribux ();
extern struct wrimsg *vhl_addwrimsg ();
extern struct wriaux *vhl_addwriaux ();
extern struct wrssig *vhl_addwrssig ();
extern struct lkdfig *vhl_addlkdfig ();
extern struct lkdins *vhl_addlkdins ();
extern struct lkdspy *vhl_addlkdspy ();
extern struct ptype *vhl_makdepend ();
extern struct lofig *vhl_makgst ();
extern int vhl_linker ();
extern int vhl_restor ();
extern void vhl_resord ();
void ( *vhl_iscmodel ()) ();

View File

@ -0,0 +1,211 @@
/* ###--------------------------------------------------------------### */
/* file : vh_ltype.h */
/* date : Aug 30 1996 */
/* version : v3.0 */
/* author : Pirouz BAZARGAN SABET */
/* contents : This file contains data structure definitions */
/* generated by the linker */
/* ###--------------------------------------------------------------### */
/* ###------------------------------------------------------### */
/* defines */
/* ###------------------------------------------------------### */
#define MAD_GEXBLK 50 /* magex struct allocation size */
#define VHL_CMODEL 1 /* instance type : C models */
#define VHL_VMODEL 2 /* instance type : VHDL models */
#define VHL_UKNDFN 8
#define VHL_DECDFN 4
#define VHL_REDDFN 2
#define VHL_WRTDFN 1
#define VHL_MODDFN 0
#define VHL_SIGDFN 1
#define VHL_CNBDFN 2
#define VHL_RNBDFN 3
#define VHL_WNBDFN 4
#define VHL_PNTDFN 7
#define VHL_LVLDFN 1
/* ###------------------------------------------------------### */
/* Data Structure Definitions */
/* ###------------------------------------------------------### */
typedef struct lkdfig /* linked figure */
{
struct lkdfig *NEXT ; /* next figure */
char *NAME ; /* figure's name */
struct lkdins *LKDINS; /* list of instances */
struct simsig *SIMSIG; /* list of simple signals */
struct bussig *BUSSIG; /* list of bused signals */
unsigned int VALSIZ; /* # of bytes needed for values */
}
lkdfig_list;
typedef struct lkdins /* linked instance */
{
struct lkdins *NEXT ; /* next instance */
char *INSNAME; /* instance's name */
struct befig *BEFIG ; /* instance model */
struct wrssig *WRSSIG ; /* written output ports */
struct wriaux *WRIAUX ; /* written internal signals */
struct wribux *WRIBUX ; /* written internal bused sig. */
struct wrbsig *WRBSIG ; /* written bused ports */
struct wrireg *WRIREG ; /* written registers */
struct wrimsg *WRIMSG ; /* written asserts */
struct redlst *REDLST ; /* read values */
struct circuit *CIRCUI ; /* Circuit pointer used for BDDs*/
unsigned char LEVEL ; /* level */
char EVAL ; /* Evaluation's flag */
char FLAG ; /* model type */
}
lkdins_list;
typedef struct simsig /* simple signal */
{
struct simsig *NEXT ; /* next simple signal */
struct chain *NAMECHAIN; /* signal's name */
struct ptype *DEPEND ; /* dependency list */
unsigned char *CURVAL ; /* signal's current value */
unsigned char PRJVAL ; /* signal's projected value */
}
simsig_list;
typedef struct bussig /* bused signal */
{
struct bussig *NEXT ; /* next simple signal */
struct chain *NAMECHAIN; /* signal's name */
struct ptype *DEPEND ; /* dependency list */
unsigned char *CURVAL ; /* signal's current value */
struct prjbvl *PRJBVL ; /* list of projected bi-values */
char TYPE ; /* signal's type */
char ERRFLG ; /* error flag */
}
bussig_list;
typedef struct wrbsig /* written bused signal */
{
struct wrbsig *NEXT ; /* next signal */
struct lkdins *LKDINS ; /* instance */
struct bebus *BEBUS ; /* formal bused signal (model) */
struct bussig *BUSSIG ; /* actual bused signal */
struct prjbvl *PRJBVL ; /* list of projected bi-values */
unsigned char LEVEL ; /* level */
char EVAL ; /* evaluation flag */
}
wrbsig_list;
typedef struct wriaux /* written auxiliary signal */
{
struct wriaux *NEXT ; /* next auxiliary signal */
struct ptype *DEPEND ; /* dependency list */
struct lkdins *LKDINS ; /* instance */
struct beaux *BEAUX ; /* formal internal sig. (model) */
unsigned char *CURVAL ; /* aux. signal current value */
unsigned char PRJVAL ; /* aux. signal projected value */
unsigned char LEVEL ; /* level */
char EVAL ; /* evaluation flag */
char FLAG ; /* signal type (delayed) */
}
wriaux_list;
typedef struct wrimsg /* assert */
{
struct wrimsg *NEXT ; /* next assert */
struct bemsg *BEMSG ; /* formal assert (model) */
struct lkdins *LKDINS ; /* instance */
unsigned char LEVEL ; /* level */
char EVAL ; /* evaluation flag */
char ERRFLG ; /* assert violation flag */
}
wrimsg_list;
typedef struct wrireg /* written register */
{
struct wrireg *NEXT ; /* next register */
struct ptype *DEPEND ; /* dependency list */
struct lkdins *LKDINS ; /* instance */
struct bereg *BEREG ; /* formal register (model) */
unsigned char *CURVAL ; /* register's current value */
struct prjrvl *PRJRVL ; /* list of projected bi-values */
char EVAL ; /* evaluation flag */
char ERRFLG ; /* error flag */
}
wrireg_list;
typedef struct wribux /* written internal bused sig. */
{
struct wribux *NEXT ; /* next signal */
struct ptype *DEPEND ; /* dependency list */
struct lkdins *LKDINS ; /* instance */
struct bebux *BEBUX ; /* formal bused signal (model) */
unsigned char *CURVAL ; /* register's current value */
struct prjbvl *PRJBVL ; /* list of projected bi-values */
unsigned char LEVEL ; /* level */
char EVAL ; /* evaluation flag */
char ERRFLG ; /* error flag */
}
wribux_list;
typedef struct wrssig /* written simple signal */
{
struct wrssig *NEXT ; /* next object */
struct beout *BEOUT ; /* formal output port (model) */
struct lkdins *LKDINS ; /* instance */
struct simsig *SIMSIG ; /* actual signal */
unsigned char LEVEL ; /* level */
char EVAL ; /* evaluation flag */
}
wrssig_list;
typedef struct redlst /* list of read values */
{
struct redlst *NEXT; /* next value */
unsigned char *VALU; /* pointer on the value */
}
redlst_list;
typedef struct prjbvl /* projected bi-value */
{
struct prjbvl *NEXT ; /* next bi-value (local) */
struct prjbvl *GLNEXT; /* next bi-value (global) */
unsigned char CNDVAL; /* driver's condition value */
unsigned char DRVVAL; /* drove value */
}
prjbvl_list;
typedef struct prjrvl /* projected bi-value */
{
struct prjrvl *NEXT ; /* next bi-value */
unsigned char CNDVAL; /* driver's condition value */
unsigned char DRVVAL; /* drove value */
}
prjrvl_list;
typedef struct magex /* general expression */
{
struct chain *OPERAND; /* operands or NULL for terms */
unsigned int TERM ; /* operator or terminal's index */
unsigned short TYPE ; /* expression's type index */
}
magex_list;
typedef struct lkdmdl /* list od C models */
{
struct lkdmdl *NEXT ; /* next model */
char *NAME ; /* model's name */
void (*FONC) (); /* pointer of the C function */
}
lkdmdl_list;
typedef struct lkdspy /* spied signals */
{
struct lkdspy *NEXT ; /* next spy */
unsigned int IOLNBR ; /* spy's iol number (ident) */
struct paiol *PAIOL ; /* spied paiol */
}
lkdspy_list;

View File

@ -0,0 +1,974 @@
/* ###--------------------------------------------------------------### */
/* file : vh_simulad.c */
/* date : Dec 13 1999 */
/* version : v3.02 */
/* author : Huu Nghia VUONG, Pirouz BAZARGAN SABET */
/* description : VHDL simulation tool */
/* ###--------------------------------------------------------------### */
#ident "@(#) SIMULAD : SIMULAtion tool with Delays V3.02"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mut.h"
#include "mlo.h"
#include "mlu.h"
#include "log.h"
#include "beh.h"
#include "bhl.h"
#include "bvl.h"
#include "pat.h"
#include "ppt.h"
#include "sch.h"
#include "vh_ltype.h"
#include "vh_globals.h"
#include "vh_util.h"
#include "vh_lspec.h"
#include "vh_xspec.h"
#include "vh_xcomm.h"
#include "vh_simulad.h"
#include "beh_delay.h"
extern char MVL_ERRFLG;
static char *VH_TUNIT_TABLE [] = { "vu", "fs", "ps", "ns", "us", "ms" };
main (argc, argv)
int argc;
char **argv;
{
int i ;
int j ;
int patindx ;
char error_flag ;
int nbr_errlft ; /* how many errors left */
/* before aborting */
unsigned int max_delta = VHX_DLTDFN; /* max # of delta cyc. */
char usage_flg = 0 ; /* print usage */
char help_flg = 0 ; /* display help */
char init_flg = 0 ; /* description's init. */
char core_flg = 0 ; /* core file at error */
char sdebug_flg = 0 ; /* debug structural */
char bdebug_flg = 0 ; /* debug behavioural */
char pdebug_flg = 0 ; /* debug pattern */
char ldebug_flg = 0 ; /* debug linker */
char cdebug_flg = 0 ; /* dbeug cycle by cycle */
char ddebug_flg = 0 ; /* debug delta by delta */
char behav_flg = 0 ; /* behav. description */
char nosim_flg = 0 ; /* no simulation */
char nores_flg = 0 ; /* no result file */
char makbdd_flg = 0 ; /* trace bdd making */
char bdd_flg = 0 ; /* use bdd or gex */
char xmess_flg = 0 ; /* no execution message */
char randly_flg = 0 ; /* random delays */
char fixdly_flg = 0 ; /* fixed delays */
char defdly_flg = 0 ; /* default delays */
char bckdly_flg = 0 ; /* backanotated delays */
char trans_flg = 0 ; /* transport delays */
char inert_flg = 1 ; /* inertial delays */
char bufreg_flg = 0 ; /* bufreg delays */
char stat_flg = 0 ; /* stat */
char sav_end ; /* saved end flag */
int max_err = 10 ; /* # of simul. errors */
unsigned int max_pat = 0 ; /* # of patterns */
unsigned int labelsiz = 32 ; /* longest patt. label */
char *arg_flg = NULL ; /* recongnized arg. flg */
unsigned int last_opt = 0 ; /* last option's index */
unsigned int frst_fil = 0 ; /* first file's index */
unsigned int init_val = 0 ; /* init. constant */
unsigned int comp_mode = 0 ; /* beh compiler mode */
struct lofig *ptlofig ;
struct befig *ptbefig = NULL ;
struct befig *ptbef ;
struct chain *ptchain ;
struct papat *pt_papat ;
struct papat *lst_papat ;
struct paseq *pt_paseq ;
struct pains *pt_pains = NULL ; /* inspected instances */
struct lkdspy *pt_lkdspy = NULL ; /* inspected signals */
struct pains *tmp_pains = NULL ;
struct shdul *pt_shdul ; /* scheduler */
struct shtra *pt_shtra ; /* transactions */
unsigned int delay_max = 0 ;
unsigned int next_date = 0 ;
unsigned int cur_date = 0 ;
unsigned int ref_date = 0 ;
unsigned int num_cycle = 0 ;
int sch_empty = 0 ;
char *str ;
char filename [200];
char buffer [200];
FILE *filepnt ;
struct beden **hshtab ;
struct beden **stat_dic ;
struct beden **delay_dic ;
unsigned char delay_mode = 0x00 ;
struct paiol *pt_paiol ;
unsigned int iolnbr = 0 ;
/* ###------------------------------------------------------### */
/* analyse the command line, set option flags and find the */
/* first file in the argument list */
/* ###------------------------------------------------------### */
mbkenv ();
arg_flg = (char *) vhu_alloc (argc * sizeof (char), VHU_NOALIGN);
arg_flg [0] = 1;
for (i=1 ; i<argc ; i++)
arg_flg [i] = 0;
for (i=1 ; i<argc ; i++)
{
if (arg_flg [i] == 0)
{
if (!strcmp (argv [i], "-h"))
{
help_flg = 1;
arg_flg [i] = 1;
}
if ((!strcmp (argv [i], "-randomdelay"))
|| (!strcmp (argv [i], "-rd")))
{
randly_flg = 1;
delay_mode |= BEH_DELAY_RANDOM;
delay_max = 128;
arg_flg [i ] = 1;
}
if ((!strcmp (argv [i], "-zerodelay"))
|| (!strcmp (argv [i], "-zd")))
{
fixdly_flg = 1;
delay_mode |= BEH_DELAY_FIXED;
delay_max = 0;
arg_flg [i ] = 1;
}
if ((!strcmp (argv [i], "-fixeddelay"))
|| (!strcmp (argv [i], "-fd")))
{
fixdly_flg = 1;
delay_mode |= BEH_DELAY_FIXED;
sscanf (argv [i+1], "%u", &delay_max);
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
}
if ((!strcmp (argv [i], "-backdelay"))
|| (!strcmp (argv [i], "-bd")))
{
bckdly_flg = i + 2;
delay_mode |= BEH_DELAY_BACKANOTATED;
if (!strcmp (argv [i+1], "max"))
{
delay_mode |= BEH_DELAY_MAX;
}
else if (!strcmp (argv [i+1], "min"))
{
delay_mode |= BEH_DELAY_MIN;
}
else if (!strcmp (argv [i+1], "typ"))
{
delay_mode |= BEH_DELAY_TYP;
}
delay_max = 128;
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
arg_flg [i+2] = 1;
}
if ((!strcmp (argv [i], "-defaultdelay"))
|| (!strcmp (argv [i], "-dd")))
{
defdly_flg = 1;
delay_mode |= BEH_DELAY_DEFAULT;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-transport"))
{
trans_flg = 1;
inert_flg = 0;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-inertial"))
{
inert_flg = 1;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-bufreg"))
{
bufreg_flg = 1;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-noxmessage"))
{
xmess_flg = 1;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-p"))
{
sscanf (argv [i+1], "%u", &max_pat);
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
}
if (!strcmp (argv [i], "-l"))
{
sscanf (argv [i+1], "%u", &labelsiz);
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
}
if (!strcmp (argv [i], "-t"))
{
makbdd_flg = 1;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-stat"))
{
stat_flg = i + 2;
sscanf (argv [i+1], "%u", &ref_date);
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
arg_flg [i+2] = 1;
}
if (!strcmp (argv [i], "-i"))
{
init_flg = i + 1;
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
}
if (!strcmp (argv [i], "-core"))
{
core_flg = i + 1;
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
}
if (!strcmp (argv [i], "-inspect"))
{
str = namealloc (argv [i+1]);
pt_pains = pat_addpains (pt_pains, str, str);
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
}
/* The spy option has been supressed (09 Sep 1999). */
/* Spied signals are now specified in the pattern file. */
/*---------------
if (!strcmp (argv [i], "-spy"))
{
str = namealloc (argv [i+1]);
pt_lkdspy = vhl_addlkdspy (pt_lkdspy, str);
arg_flg [i ] = 1;
arg_flg [i+1] = 1;
}
----------------*/
if (!strcmp (argv [i], "-nores"))
{
nores_flg = 1;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-c"))
{
nosim_flg = 1;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-bdd"))
{
bdd_flg = 1;
arg_flg [i] = 1;
}
if (!strcmp (argv [i], "-b"))
{
behav_flg = 1;
arg_flg [i] = 1;
}
if (!strncmp (argv [i], "-dbg", 4))
{
arg_flg [i] = 1;
for (j=4 ; argv [i][j] != '\0' ; j++)
{
switch (argv [i][j])
{
case 's':
sdebug_flg = 1; break;
case 'b':
bdebug_flg = 1; break;
case 'l':
ldebug_flg = 1; break;
case 'p':
pdebug_flg = 1; break;
case 'c':
cdebug_flg = 1; break;
case 'd':
ddebug_flg = 1; break;
}
}
}
}
}
for (i=0 ; i<argc ; i++)
{
if (arg_flg [i] == 1)
last_opt = i;
}
for (frst_fil=0 ; frst_fil < argc ; frst_fil++)
{
if (arg_flg [frst_fil] == 0)
break;
}
/* ###------------------------------------------------------### */
/* cases of error in the command line: */
/* - no argument */
/* - argument unrecognized as an option */
/* - number of files do not match: */
/* - simulation with result => 3 files needed */
/* - simulation without result => 2 files needed */
/* - no simulation => 1 file needed */
/* ###------------------------------------------------------### */
if (help_flg == 1)
{
vhu_message (0, NULL, 0);
system ("man asimut");
exit (0);
}
if ((argc == 1) || (last_opt != (frst_fil - 1)))
usage_flg = 1;
if (((nosim_flg == 0) && (nores_flg == 0) && (argc != (frst_fil + 3))) ||
((nosim_flg == 0) && (nores_flg == 1) && (argc != (frst_fil + 2))) ||
((nosim_flg == 1) && (argc != (frst_fil + 1))))
usage_flg = 1;
if ((inert_flg == 1) && (trans_flg == 1))
usage_flg = 1;
if (((bckdly_flg != 0) && (fixdly_flg != 0)) ||
((randly_flg != 0) && (fixdly_flg != 0)) ||
((bckdly_flg != 0) && (randly_flg != 0)))
usage_flg = 1;
if ((bckdly_flg != 0) && ((delay_mode & BEH_DELAY_MAX) != BEH_DELAY_MAX)
&& ((delay_mode & BEH_DELAY_MIN) != BEH_DELAY_MIN)
&& ((delay_mode & BEH_DELAY_TYP) != BEH_DELAY_TYP))
usage_flg = 1;
if (usage_flg == 1)
{
vhu_message (100, NULL, 0);
vhu_message (101, NULL, 0);
exit (1);
}
alliancebanner ("ASimuT", vhu_avers (), "A SIMUlation Tool",
"1991...1999", ALLIANCE_VERSION);
vhu_message (21, NULL, 0);
/* ###------------------------------------------------------### */
/* initialize : */
/* - get MBK environment variables */
/* - initialize C models' pointer */
/* - create a scheduler */
/* - initialize BDD hash tables */
/* - initialize the linker's hash table */
/* - set the fast mode on MBK functions */
/* - set the behavioural compiler's mode */
/* - set BEH_TIMEUNIT to BEH_TU__PS */
/* - set PAT_TIMEUNIT to PAT_TU__PS */
/* ###------------------------------------------------------### */
vhu_message (2, NULL, 0);
vhi_models ();
initializeBdd (0);
hshtab = beh_initab ();
stat_dic = beh_initab ();
pt_shdul = sch_CreateScheduler (NULL, NULL);
VHX_SHDUL = pt_shdul;
BEH_TIMEUNIT = BEH_TU__PS;
PAT_TIMEUNIT = PAT_TU__PS;
FAST_MODE = 'Y';
comp_mode = BVL_TRACE | BVL_KEEPAUX;
if (trans_flg == 1)
{
VHX_SCH_TRA_MODE = SCH_TRA_DELAFTER ;
}
if (inert_flg == 1)
{
VHX_SCH_TRA_MODE = SCH_TRA_DELBEFORE | SCH_TRA_DELAFTER ;
}
/* ###------------------------------------------------------### */
/* read the maximum number of simulation errors from the */
/* environment variable VH_MAXERR */
/* ###------------------------------------------------------### */
str = mbkgetenv ("VH_MAXERR");
if (str != NULL)
{
if (sscanf (str, "%u", &max_err) == 0)
max_err = 10;
}
/* ###------------------------------------------------------### */
/* searching the root file */
/* ###------------------------------------------------------### */
vhu_message (5, argv [frst_fil], 0);
/* ###------------------------------------------------------### */
/* if there is no structural level call directly the */
/* behaviour compiler */
/* ###------------------------------------------------------### */
if (behav_flg == 1)
{
/* ###------------------------------------------------------### */
/* run the behavioural compiler on the current file. Call */
/* the debugger is necessary */
/* ###------------------------------------------------------### */
if (vhl_iscmodel (argv [frst_fil]) == NULL)
comp_mode = BVL_TRACE | BVL_KEEPAUX ;
else
comp_mode = BVL_TRACE | BVL_KEEPAUX | BVL_CHECKEMPTY;
ptbefig = vhdlloadbefig (ptbefig, argv [frst_fil], comp_mode);
error_flag = ptbefig->ERRFLG;
if (bdebug_flg == 1)
dast_dbg (ptbefig, "befig");
/* ###------------------------------------------------------### */
/* if the architecture of the compiled description is VHDL */
/* and if there is no error in the description : */
/* */
/* - identify dependencies in the description */
/* - transform boolean expression into BDDs or GEXs */
/* ###------------------------------------------------------### */
if ((ptbefig->ERRFLG == 0) && (ptbefig->FLAG & BEH_ARC_VHDL))
{
delay_dic = beh_initab ();
if (bckdly_flg != 0)
{
error_flag += beh_backdelay (delay_dic, argv [bckdly_flg], delay_mode);
}
if ((bckdly_flg != 0) || (fixdly_flg != 0) || (randly_flg != 0))
{
beh_setdelay (ptbefig, delay_max, delay_mode, delay_dic);
}
if (bufreg_flg != 0)
{
beh_chkregdly (ptbefig, 2);
}
else
{
beh_chkregdly (ptbefig, 1);
}
beh_fretab (delay_dic);
beh_depend (ptbefig);
if (bdd_flg == 1)
{
vhu_message (15, "BDD", 0);
beh_makbdd (ptbefig);
}
else
{
vhu_message (15, "GEX", 0);
beh_makgex (ptbefig);
}
beh_freabl (ptbefig);
error_flag += ptbefig->ERRFLG;
}
ptlofig = vhl_makgst (ptbefig);
}
else
{
/* ###------------------------------------------------------### */
/* run the structural compiler on the root file and call the */
/* debugger if it has been asked. Flatten the root description */
/* and call the structural compiler as many times as necessary */
/* to reach leaf cells (behavioural description) */
/* ###------------------------------------------------------### */
vhu_message (4, argv [frst_fil], 0);
VHS_LOFPNT = getlofig (argv [frst_fil], 'A');
error_flag = MVL_ERRFLG;
if (sdebug_flg == 1)
dast_dbg (HEAD_LOFIG, "lofig");
if (error_flag != 0)
{
error_flag = vhu_error (200, NULL, NULL);
exit (1);
}
vhu_message (18, NULL, 0);
lofigchain (VHS_LOFPNT);
rflattenlofig (VHS_LOFPNT, YES, YES);
if (sdebug_flg == 1)
dast_dbg (HEAD_LOFIG, "lofig");
ptchain = VHS_LOFPNT->MODELCHAIN;
while (ptchain != NULL)
{
/* ###------------------------------------------------------### */
/* for each leaf cell of the description search the */
/* behavioural file */
/* ###------------------------------------------------------### */
vhu_message (5, ptchain->DATA, 0);
/* ###------------------------------------------------------### */
/* run the behavioural compiler on the current file */
/* ###------------------------------------------------------### */
ptbef = ptbefig;
if (vhl_iscmodel ((char *)ptchain->DATA) == NULL)
comp_mode = BVL_TRACE | BVL_KEEPAUX ;
else
comp_mode = BVL_TRACE | BVL_KEEPAUX | BVL_CHECKEMPTY;
ptbefig = vhdlloadbefig (ptbefig, ptchain->DATA, comp_mode);
ptbefig->NEXT = ptbef;
error_flag += ptbefig->ERRFLG;
/* ###------------------------------------------------------### */
/* if the architecture of the compiled description is VHDL */
/* and if there is no error in the description ; */
/* */
/* - identify dependencies in the description */
/* - transform boolean expression into BDDs or GEXs */
/* ###------------------------------------------------------### */
if ((error_flag == 0) && (ptbefig->FLAG & BEH_ARC_VHDL))
{
delay_dic = beh_initab ();
if (bckdly_flg != 0)
{
error_flag += beh_backdelay (delay_dic, ptbefig->NAME, delay_mode);
}
if ((bckdly_flg != 0) || (fixdly_flg) || (randly_flg))
{
beh_setdelay (ptbefig, delay_max, delay_mode, delay_dic);
}
if (bufreg_flg != 0)
{
beh_chkregdly (ptbefig, 2);
}
else
{
beh_chkregdly (ptbefig, 1);
}
beh_fretab (delay_dic);
beh_depend (ptbefig);
if (bdd_flg == 1)
{
vhu_message (15, "BDD", 0);
beh_makbdd (ptbefig);
}
else
{
vhu_message (15, "GEX", 0);
beh_makgex (ptbefig);
}
beh_freabl (ptbefig);
error_flag += ptbefig->ERRFLG;
}
ptchain = ptchain->NEXT;
}
}
/* ###------------------------------------------------------### */
/* call the debugger if necessary */
/* ###------------------------------------------------------### */
if (bdebug_flg == 1)
dast_dbg (ptbefig, "befig");
if (error_flag != 0)
{
error_flag = vhu_error (200, NULL, NULL);
exit (1);
}
if (nosim_flg == 1)
exit (0);
/* ###------------------------------------------------------### */
/* running the pattern description compiler on the current */
/* file */
/* ###------------------------------------------------------### */
vhu_message (6, argv [frst_fil + 1], 0);
pt_paseq = pat_lodpaseq (argv [frst_fil+1], NULL, max_pat, 0);
if ((pt_paseq == NULL) || (pt_paseq->ERRFLG != 0))
{
error_flag = vhu_error (200, NULL, NULL);
exit (1);
}
/* ###------------------------------------------------------### */
/* add the spied signals specified in the pattern file to */
/* the list of spy : pt_lkdspy. */
/* ###------------------------------------------------------### */
for (pt_paiol = pt_paseq->PAIOL, iolnbr = 0; pt_paiol !=NULL; pt_paiol = pt_paiol->NEXT,iolnbr++)
{
if (pt_paiol->FLAG == PAT_IOL__SPY)
{
pt_lkdspy = vhl_addlkdspy (pt_lkdspy, pt_paiol, iolnbr);
}
}
vhx_commentspytable(pt_paseq,pt_lkdspy);
/* ###------------------------------------------------------### */
/* add the list of inspected instances passed as argument to */
/* the list of inspected instances found in the pattern file */
/* ###------------------------------------------------------### */
if (pt_pains != NULL)
{
tmp_pains = pt_pains;
while (tmp_pains->NEXT != NULL)
tmp_pains = tmp_pains->NEXT;
tmp_pains->NEXT = pt_paseq->PAINS;
pt_paseq->PAINS = pt_pains;
}
if (pdebug_flg == 1)
dast_dbg (pt_paseq, "paseq");
/* ###------------------------------------------------------### */
/* link previous structures to create the simulator's data */
/* base structures */
/* ###------------------------------------------------------### */
vhu_message (16, NULL, 0);
if (behav_flg == 0)
vhl_resord (hshtab, HEAD_LOFIG, ptbefig);
if (sdebug_flg == 1)
dast_dbg (HEAD_LOFIG, "lofig");
error_flag = vhl_restor (hshtab, HEAD_LOFIG, ptbefig);
if (sdebug_flg == 1)
dast_dbg (HEAD_LOFIG, "lofig");
if (error_flag != 0)
{
error_flag = vhu_error (200, NULL, NULL);
exit (1);
}
vhu_message (9, NULL, 0);
error_flag = vhl_linker (hshtab, pt_paseq);
if (error_flag != 0)
{
error_flag = vhu_error (200, NULL, NULL);
exit (1);
}
/* ###------------------------------------------------------### */
/* initialize the circuit with a .sav file or a constant. */
/* ###------------------------------------------------------### */
if (init_flg != 0)
{
if ((sscanf (argv [init_flg], "%u", &init_val) == 1) && (init_val <= 1))
vhx_initval (VHL_HEDLKF, init_val + '0');
else
{
if ((filepnt = mbkfopen (argv [init_flg], "sav", READ_TEXT)) == NULL)
vhu_error (116, argv [init_flg], NULL);
else
{
error_flag = vhx_initfig (VHL_HEDLKF, filepnt);
fclose (filepnt);
}
}
}
else
vhx_initval (VHL_HEDLKF, 'u');
if (ldebug_flg == 1)
dast_dbg (VHL_HEDLKF, "lkdfig");
if (pdebug_flg == 1)
dast_dbg (pt_paseq, "paseq");
if (error_flag != 0)
{
error_flag = vhu_error (200, NULL, NULL);
exit (1);
}
/* ###------------------------------------------------------### */
/* execute the current figure */
/* ###------------------------------------------------------### */
vhu_message (11, NULL, 0);
vhx_execall (VHL_HEDLKF);
patindx = 0;
nbr_errlft = max_err;
while (1)
{
pt_papat = pt_paseq->CURPAT;
while ((pt_papat != NULL) && (pt_papat != pt_paseq->NXTPAT) &&
(nbr_errlft > 0 ))
{
max_delta = VHX_DLTDFN;
/* ###------------------------------------------------------### */
/* read a new pattern */
/* ###------------------------------------------------------### */
if ((sch_empty == 0) || (pt_papat->TIME <= next_date))
{
if ((sch_empty != 0) && (cdebug_flg == 1))
{
vhu_warning (5, NULL, NULL);
}
cur_date = pt_papat->TIME;
sch_SetCurrentTime (pt_shdul, cur_date);
if (xmess_flg == 0)
{
/* ###------------------------------------------------------### */
/* Are we in virtual time unit or real time unit ? */
/* ###------------------------------------------------------### */
if (pt_paseq->TIME_UNIT == PAT_TU__VU)
{
vhu_message (10, NULL, patindx);
}
else
{
sprintf (buffer,"%u %s", cur_date, VH_TUNIT_TABLE [PAT_TIMEUNIT]);
vhu_message (22, buffer, patindx);
}
}
if (pt_papat->ACTFLAG == 'I')
{
vhx_inireg (hshtab, pt_papat->PAINI);
}
vhx_redpat (pt_paseq, pt_papat);
}
if ((sch_empty != 0) && (next_date <= pt_papat->TIME))
{
cur_date = next_date;
sch_SetCurrentTime (pt_shdul, cur_date);
pt_shtra = sch_GetCurrentTransactions (pt_shdul);
vhx_redtra (pt_shtra);
}
while (1)
{
vhx_supdate (stat_dic, cur_date);
vhx_execute (pt_shdul, bdd_flg );
sch_empty = sch_GetNextTime (pt_shdul, &next_date);
if ((sch_empty != 0) && (next_date == cur_date))
{
pt_shtra = sch_GetCurrentTransactions (pt_shdul);
vhx_redtra (pt_shtra);
}
else
break;
}
if (max_delta <= 0)
break;
if (pt_papat->TIME == cur_date)
{
if (stat_flg != 0)
{
if (cur_date == 0)
{
num_cycle++;
vhx_vectorinit ( VHL_HEDLKF );
}
else if ((cur_date % ref_date) == 0)
{
num_cycle++;
vhx_vectorstat ( VHL_HEDLKF );
}
}
nbr_errlft -= vhx_wrtpat (pt_paseq, pt_papat);
lst_papat = pt_papat;
pt_papat = pt_papat->NEXT;
patindx ++;
}
/* ###------------------------------------------------------### */
/* When pattern time < simulation time, */
/* insert one pattern if a spy event occurs. */
/* ###------------------------------------------------------### */
else
{
lst_papat = vhx_insertspypat (pt_paseq, lst_papat, pt_lkdspy, cur_date, labelsiz);
}
/* ###------------------------------------------------------### */
/* If a fatal error has been occured during the simulation */
/* (Assert Violation, Bus conflict), set the end flag of the */
/* pattern sequence to avoid loading new patterns and break the */
/* simulation cycle */
/* */
/* Otherwies, continue the simulation cycle */
/* ###------------------------------------------------------### */
if (vhx_chkerr (cur_date) == 1)
{
pt_paseq->ENDFLG = 'Y';
break;
}
}
/* ###------------------------------------------------------### */
/* After all the patterns of a set have been processed ... */
/* ###------------------------------------------------------### */
if (pdebug_flg == 1)
dast_dbg (pt_paseq, "paseq");
if (nores_flg == 0)
pat_savpaseq (argv [frst_fil + 2], pt_paseq, labelsiz);
if (max_delta <= 0)
break;
if ((pt_paseq->ENDFLG != 'Y') && (pt_paseq->ERRFLG == 0))
{
pt_paseq = pat_lodpaseq (argv [frst_fil+1], pt_paseq, max_pat, 0);
if (pdebug_flg == 1)
dast_dbg (pt_paseq, "paseq");
}
else
break;
}
if (max_delta <= 0)
error_flag = vhu_error (105, NULL, NULL);
if (nbr_errlft < 0)
error_flag = vhu_error (106, NULL, NULL);
else
{
if (stat_flg != 0)
{
st_wrtsta (stat_dic, VHL_HEDLKF, pt_paseq, num_cycle, argv [stat_flg]);
st_wrtstadly (stat_dic, VHL_HEDLKF, pt_paseq, cur_date, ref_date, argv [stat_flg]);
st_wrtstabis (stat_dic, VHL_HEDLKF, pt_paseq, cur_date, ref_date, argv [stat_flg]);
}
}
/* ###------------------------------------------------------### */
/* if the save flag is set create a save file */
/* ###------------------------------------------------------### */
if (nores_flg == 0)
{
if (pt_paseq->SAVFLG == 'Y')
{
if ((filepnt = mbkfopen (argv [frst_fil+1], "sav", WRITE_TEXT)) == NULL)
{
sprintf (filename, "%s.sav", argv [frst_fil + 1]);
error_flag = vhu_error (116, filename, NULL);
exit (1);
}
vhx_savall (filepnt, VHL_HEDLKF);
fclose (filepnt);
}
}
beh_fretab (hshtab);
beh_fretab (stat_dic);
if (nbr_errlft < max_err)
exit (2);
else
exit (0);
}

View File

@ -0,0 +1,11 @@
/* ###--------------------------------------------------------------### */
/* file : vh_simulad.h */
/* date : Aug 18 1997 */
/* version : v3.0 */
/* author : Pirouz BAZARGAN SABET */
/* content : declaration of functions and global variables used by */
/* the simulator */
/* ###--------------------------------------------------------------### */
#define VHX_DLTDFN 10000

View File

@ -0,0 +1,390 @@
/* ###--------------------------------------------------------------### */
/* file : vh_util.c */
/* date : Dec 13 1999 */
/* author : Pirouz BAZARGAN SABET */
/* version : v3.02 */
/* description : This file contains some utility functions : */
/* vhu_splitname, vhu_alloc, vhu_message, vhu_warning, */
/* vhu_toolbug , vhu_error, vhu_avers */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "vh_util.h"
/* ###--------------------------------------------------------------### */
/* function : vhu_splitname */
/* description : split a name onto an instance name and a signal name */
/* called func. : namalloc */
/* ###--------------------------------------------------------------### */
void vhu_splitname (name, ins_name, sig_name)
char *name ;
char **ins_name;
char **sig_name;
{
unsigned int i = 0;
unsigned int j = 0;
char buf [256] ;
for (i=0 ; name [i] != '\0' ; i++)
{
if (name [i] == '.')
j = i + 1;
}
if ((j != 0) && (j != i))
{
strcpy (buf, name);
buf [j-1] = '\0';
*ins_name = namealloc (buf );
*sig_name = namealloc (buf + j);
}
else
{
*ins_name = NULL;
*sig_name = name;
}
}
/* ###--------------------------------------------------------------### */
/* function : vhu_alloc */
/* description : make memory allocation */
/* called func. : mbkalloc */
/* ###--------------------------------------------------------------### */
char *vhu_alloc (size, mode)
unsigned int size;
char mode;
{
static char *mem_pt = NULL;
static unsigned int mem_idx = 0 ;
char *res_pt = NULL;
/* ###------------------------------------------------------### */
/* align the size on a multiple of 4 */
/* ###------------------------------------------------------### */
if (size >= VHU_MEMALC)
res_pt = (char *) mbkalloc (size);
else
{
if (mode == VHU_ALIGN)
{
mem_idx = (mem_idx + 3) & 0xfffffffc;
size = (size + 3) & 0xfffffffc;
}
if ((mem_pt == NULL) || ((mem_idx + size) > VHU_MEMALC))
{
mem_pt = (char *) mbkalloc (VHU_MEMALC);
mem_idx = 0;
}
res_pt = mem_pt + mem_idx;
mem_idx += size ;
}
return (res_pt);
}
/* ###--------------------------------------------------------------### */
/* function : vhu_avers */
/* description : return the current version */
/* called func. : none */
/* ###--------------------------------------------------------------### */
char *vhu_avers ()
{
return ("v3.02");
}
/* ###--------------------------------------------------------------### */
/* function : vhu_warning */
/* description : print a warning message corresponding to the argument */
/* code */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void vhu_warning (code, str1, str2)
int code;
char *str1;
char *str2;
{
fprintf (stderr, "Warning %d : ", code);
switch (code)
{
case 1:
fprintf (stderr, "cannot find register `%s`\n", str1);
break;
case 2:
fprintf (stderr, "consistency checks will be disabled\n");
break;
case 3:
fprintf (stderr, "signal `%s` never used\n", str1);
break;
case 4:
fprintf (stderr, "cannot restore the mode of port `%s`\n", str1);
break;
case 5:
fprintf (stderr, "pattern is loaded while the scheduler isn't empty\n");
break;
case 112:
fprintf (stderr, "driver conflict on `%s`\n", str1);
break;
case 121:
fprintf (stderr, "driver conflict on `%s` in `%s`\n", str2, str1);
break;
}
}
/* ###--------------------------------------------------------------### */
/* function : vhu_toolbug */
/* description : print a fatal error message corresponding to the */
/* argument code and exit */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void vhu_toolbug (code, str1, str2, nbr1)
int code;
char *str1;
char *str2;
int nbr1;
{
fprintf (stderr, "Fatal error %d executing `%s`: ", code, str1);
switch (code)
{
case 1:
fprintf (stderr, "unknown operator\n");
break;
case 2:
fprintf (stderr, "cannot create empty atom\n");
break;
case 7:
fprintf (stderr, "unknown type `%c` for IO `%s`\n", nbr1, str2);
break;
case 8:
fprintf (stderr, "illegal signal value : hex `%x`\n", nbr1);
break;
case 13 :
fprintf (stderr, "cannot find model of `%s`\n", str2);
break;
case 18:
fprintf (stderr, "unknown mode `%c` for port `%s`\n", nbr1, str2);
break;
case 19:
fprintf (stderr, "unknown type `%c` for input `%s`\n", nbr1, str2);
break;
case 20:
fprintf (stderr, "`%s` no such locon\n", str2);
break;
case 21:
fprintf (stderr, "illegal direction `%c` for `%s`\n", nbr1, str2);
break;
case 22:
fprintf (stderr, "`%s`: `%c` unknown resolution func.\n", str2, nbr1);
break;
default:
fprintf (stderr, "BUG\n");
}
exit (1);
}
/* ###--------------------------------------------------------------### */
/* function : vhu_message */
/* description : print a message corresponding to the argument code */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void vhu_message (code, str1, nmb1)
int code;
char *str1;
int nmb1;
{
switch (code)
{
case 0:
fprintf (stdout, "\nasimut %s\n", vhu_avers());
break;
case 1:
fprintf (stdout, "usage : asimut [options] [files]\n");
fprintf (stdout, " : asimut -h\n");
break;
case 2:
fprintf (stdout, "initializing ...\n");
break;
case 3:
fprintf (stdout, "compiling `%s` (Behaviour) ...\n",str1);
break;
case 4:
fprintf (stdout, "compiling `%s` (Structural) ...\n\n",str1);
break;
case 5:
fprintf (stdout, "searching `%s` ...\n",str1);
break;
case 6:
fprintf (stdout, "searching pattern file : `%s` ...\n",str1);
break;
case 8:
fprintf (stdout, "compiling `%s` (Pattern) ...\n\n",str1);
break;
case 9:
fprintf (stdout, "linking ...\n");
break;
case 10:
fprintf (stdout, "###----- processing pattern %d -----###\n",nmb1);
break;
case 11:
fprintf (stdout, "executing ...\n");
break;
case 12:
fprintf (stdout, "generating the file '%s' ...\n",str1);
break;
case 13:
fprintf (stdout, "of the figure '%s'.\n",str1);
break;
case 14:
fprintf (stdout, "file '%s' has been generated.\n",str1);
break;
case 15:
fprintf (stdout, "making %s ...\n\n", str1);
break;
case 16:
fprintf (stdout, "restoring ...\n\n");
break;
case 17:
fprintf (stdout, "creating the core file ...\n\n");
break;
case 18:
fprintf (stdout, "flattening the root figure ...\n\n");
break;
case 19:
fprintf (stdout, "stop mark set on the current structure\n");
break;
case 20:
fprintf (stdout, "--- STACK OVERFLOW !! ---\n");
break;
case 21:
fprintf (stdout, "\tParis, France, Europe, Earth, Solar system, Milky Way, ...\n");
break;
case 22:
fprintf (stdout, "###----- processing pattern %d : %s -----###\n",nmb1, str1);
break;
case 100:
fprintf (stdout, "\nasimut %s\n", vhu_avers());
break;
case 101:
fprintf (stdout, "usage : asimut [options] [files]\n");
fprintf (stdout, " : asimut -h\n");
break;
default:
fprintf (stderr, "vhu_message : code %d unknown.\n",code);
}
}
/* ###--------------------------------------------------------------### */
/* function : vhu_error */
/* description : print an error message depending on the argument code */
/* called func. : none */
/* ###--------------------------------------------------------------### */
int vhu_error (code, str1, str2)
int code;
char *str1;
char *str2;
{
if (code < 200)
fprintf (stderr, "Error %d: ", code);
switch (code)
{
case 100:
fprintf (stderr, "cannot find `%s`\n", str1);
break;
case 101:
fprintf (stderr, "cannot find signal `%s`\n", str1);
break;
case 102:
fprintf (stderr, "instance and model of `%s` mismatch\n", str1);
break;
case 103:
fprintf (stderr, "incompatible input/output mode for `%s`\n", str1);
break;
case 104:
fprintf (stderr, "input/output `%s` doesn't exist\n", str1);
break;
case 105:
fprintf (stderr, "possible combinatory loop. Simulation aborted\n");
break;
case 106:
fprintf (stderr, "too many errors. Simulation aborted\n");
break;
case 107:
fprintf (stderr, "cannot open result file\n");
break;
case 109:
fprintf (stderr, "signal `%s` never assigned\n", str1);
break;
case 110:
fprintf (stderr, "signal `%s` not connected to any port\n", str1);
break;
case 111:
fprintf (stderr, "illegal connections on signal `%s`\n", str1);
break;
case 112:
fprintf (stderr, "drivers conflict on `%s`\n", str1);
break;
case 113:
fprintf (stderr, "expected value differs from the simulation's result on `%s`\n", str1);
break;
case 114:
fprintf (stderr, "multiple driver on unguarded signal `%s`\n", str1);
break;
case 115:
fprintf (stderr, "save file doesn't match with the description\n");
break;
case 116:
fprintf (stderr, "cannot open file `%s`\n", str1);
break;
case 117:
fprintf (stderr, "instance `%s` doesn't exist or cannot be inspected\n", str1);
break;
case 118:
fprintf (stderr, "command not understood\n");
break;
case 119:
fprintf (stderr, "cannot display VOID pointer\n");
break;
case 120:
fprintf (stderr, "cannot push NULL pointer\n");
break;
case 121:
fprintf (stderr, "driver conflict on `%s` in `%s`\n", str2, str1);
break;
case 200:
fprintf (stderr, "\n\tcannot continue further more.\n");
fprintf (stderr, "\n\t\thave a nice day...\n");
break;
default:
fprintf (stderr, "unknown error code\n");
break;
}
return (1);
}

View File

@ -0,0 +1,30 @@
/* ###--------------------------------------------------------------### */
/* file : vh_util.h */
/* date : Nov 13 1995 */
/* version : v3.0 */
/* authors : VUONG H.N., L.A. TABUSSE, P. BAZARGAN */
/* content : contains defines, external variables and funtions used*/
/* by utility functions */
/* ###--------------------------------------------------------------### */
/* ###------------------------------------------------------### */
/* defines */
/* ###------------------------------------------------------### */
#define VHU_NOALIGN 0
#define VHU_ALIGN 1
#define VHU_MEMALC 4096
/* ###------------------------------------------------------### */
/* functions */
/* ###------------------------------------------------------### */
extern char *vhu_alloc ();
extern void vhu_splitname ();
extern char *vhu_avers ();
extern void vhu_warning ();
extern void vhu_toolbug ();
extern void vhu_message ();
extern int vhu_error ();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
/* ###--------------------------------------------------------------### */
/* file : vh_xcomm.h */
/* date : Aug 20 1997 */
/* version : v3.0 */
/* author : Pirouz BAZARGAN SABET */
/* content : declaration of functions and global variables used by */
/* the simulation funciotns */
/* ###--------------------------------------------------------------### */
extern unsigned int vhx_getvalu ();
extern unsigned int vhx_getsize ();
extern char vhx_gexeval ();
extern char vhx_muxbit ();
extern char vhx_worbit ();
extern char vhx_regbit ();
extern char vhx_bddeval ();
extern void vhx_savall ();
extern void vhx_inireg ();
extern void vhx_redpat ();
extern int vhx_wrtpat ();
extern struct papat *vhx_insertspypat ();
extern void vhx_update ();
extern int vhx_chkerr ();
extern char vhx_initfig ();
extern void vhx_initval ();
extern void vhx_core ();
extern unsigned int vhx_readinput ();
extern void vhx_writeout ();
extern void vhx_writebus ();
extern char *vhx_GetInstanceName ();
extern void vhx_vectorstat ();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
/* ###--------------------------------------------------------------### */
/* file : vh_xspec.h */
/* date : Aug 20 1997 */
/* version : v3.0 */
/* author : Pirouz BAZARGAN SABET */
/* content : declaration of functions and global variables used by */
/* the simulation funciotns */
/* ###--------------------------------------------------------------### */
#define CTXEVT 6
#define CTXPRB 7
#define CTXLST 8
#define CTXSEV 9
#define CTXMEV 10
extern void traceX ();
extern unsigned int getXcount ();
extern void vhx_execall ();
extern void vhx_addexec ();
extern int vhx_execute ();
extern unsigned int vhx_addtra ();
extern void vhx_redtra ();
extern void st_wrtsta ();
extern void st_wrtstadly ();
extern void st_wrtstabis ();

View File

@ -0,0 +1 @@
SUBDIRS = src

View File

@ -0,0 +1,47 @@
dnl
/*
dnl This file is part of the Alliance CAD System
dnl Copyright (C) Laboratoire LIP6 - Département ASIM
dnl Universite Pierre et Marie Curie
dnl
dnl Home page : http://www-asim.lip6.fr/alliance/
dnl E-mail support : mailto:alliance-support@asim.lip6.fr
dnl
dnl This library is free software; you can redistribute it and/or modify it
dnl under the terms of the GNU Library General Public License as published
dnl by the Free Software Foundation; either version 2 of the License, or (at
dnl your option) any later version.
dnl
dnl Alliance VLSI CAD System is distributed in the hope that it will be
dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
dnl Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License along
dnl with the GNU C Library; see the file COPYING. If not, write to the Free
dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dnl
dnl Purpose : Auto stuffing Alliance
dnl Almost ten years since I wrote this stuff, I just can't
dnl believe it
dnl Date : 01/02/2002
dnl Author : Frederic Petrot <Frederic.Petrot@lip6.fr>
dnl $Id: configure.in,v 1.1 2002/04/04 15:44:53 ludo Exp $
dnl
dnl
AC_INIT(src/bvl.h)
AM_INIT_AUTOMAKE(bvl, 1.14)
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_YACC
AM_PROG_LEX
AC_HEADER_STDC
AC_C_CONST
AC_PROG_RANLIB
AM_ALLIANCE
AC_OUTPUT([
Makefile
src/Makefile
])

View File

@ -0,0 +1,53 @@
include $(ALLIANCE_TOP)/etc/$(ALLIANCE_OS).mk
include $(ALLIANCE_TOP)/etc/libraries.mk
#TARGET_LIB = $(HOME)/dev/archi/$(ALLIANCE_OS)/lib
#TARGET_INCLUDE = $(HOME)/dev/archi/$(ALLIANCE_OS)/lib
LOCAL_INC = ../include
LOCAL_CFLAGS = $(CFLAGS) -c -g
LOCAL_CPPFLAGS = $(CPPFLAGS) -I$(LOCAL_INC) \
-I$(ALLIANCE_INCLUDE) \
-DMUT_H='<$(MUT_H)>' \
-DBEH_H='<$(BEH_H)>' \
-DBHL_H='<$(BHL_H)>' \
-DBVL_H='<bvl114.h>' \
-DLOG_H='<$(LOG_H)>'
LOCAL_YACCFLAGS = $(YACCFLAGS) -d
LOCAL_LEXFLAGS = $(LEXFLAGS)
LOCAL_ARFLAGS = $(ARFLAGS)
LOCAL_OBJECTS = bvl_globals.o bvl_parse.o bvl_drive.o \
bvl_util.o bvl_yac.o bvl_lex.o
.c.o :
$(CC) $(LOCAL_CFLAGS) $(LOCAL_CPPFLAGS) $<
$(TARGET_LIB)/libBvl114.a : $(LOCAL_OBJECTS)
$(CP) $(LOCAL_INC)/bvl114.h $(TARGET_INCLUDE)
$(AR) $(LOCAL_ARFLAGS) $(TARGET_LIB)/libBvl114.a $(LOCAL_OBJECTS)
-$(RANLIB) $(TARGET_LIB)/libBvl114.a
bvl_lex.c : bvl_bcomp.lex bvl_yac.c
$(LEX) $(LOCAL_LEXFLAGS) bvl_bcomp.lex
$(SED) -e 's/YY/BVL_Y_/g' -e 's/yy/bvl_y_/g' lex.yy.c > bvl_lex.c
$(RM) lex.yy.c
bvl_yac.c : bvl_bcomp.yac
$(YACC) $(LOCAL_YACCFLAGS) bvl_bcomp.yac
$(SED) -e 's/YY/BVL_Y_/g' -e 's/yy/bvl_y_/g' y.tab.c > bvl_yac.c
$(RM) y.tab.c
$(SED) -e 's/YY/BVL_Y_/g' -e 's/yy/bvl_y_/g' y.tab.h > bvl_yac.h
$(RM) y.tab.h
distrib : $(TARGET_LIB)/libBvl114.a
clean :
$(RM) -f bvl_yac.h bvl_yac.c bvl_lex.c
$(RM) -f $(LOCAL_OBJECTS)
realclean : clean
$(RM) -f $(TARGET_LIB)/libBvl114.a $(TARGET_INCLUDE)/bvl114.h

View File

@ -0,0 +1,14 @@
CFLAGS = @ALLIANCE_CFLAGS@ \
-DALLIANCE_TOP=\"${ALLIANCE_TOP}\"
lib_LIBRARIES = libBvl.a
include_HEADERS = bvl.h
libBvl_a_SOURCES = bvl_bcomp_y.y bvl_bcomp_l.l \
bvl_bedef.h bvl_drive.c bvl.h bvl_util.c \
bvl_byacc.h bvl_globals.c bvl_parse.c
CLEANFILES = bvl_bcomp_y.c bvl_bcomp_y.h bvl_bcomp_l.c
bvl_bcomp_y.c bvl_bcomp_y.h : $(srcdir)/bvl_bcomp_y.y
$(YACC) -d $(YFLAGS) $(srcdir)/bvl_bcomp_y.y && sed -e "s/yy/bvl_y_/g" -e "s/YY/BVL_Y_/g" y.tab.c > bvl_bcomp_y.c && sed -e "s/yy/bvl_y_/g" -e "s/YY/BVL_Y_/g" y.tab.h > bvl_bcomp_y.h
bvl_bcomp_l.c : $(srcdir)/bvl_bcomp_l.l bvl_bcomp_y.h
$(LEX) -t $(srcdir)/bvl_bcomp_l.l | sed -e "s/yy/bvl_y_/g" -e "s/YY/BVL_Y_/g" > bvl_bcomp_l.c

View File

@ -0,0 +1,77 @@
/* ###--------------------------------------------------------------### */
/* file : bvl114.h */
/* date : Feb 28 2000 */
/* version : v114 */
/* author : Pirouz BAZARGAN SABET */
/* contents : defines and structure definitions used in BVL library */
/* ###--------------------------------------------------------------### */
#ifndef BEH_BVLDEF
#define BEH_BVLDEF
/* ###------------------------------------------------------### */
/* defines */
/* ###------------------------------------------------------### */
#define BVL_TRACE 0x00000001 /* print messages when parsing */
#define BVL_KEEPAUX 0x00000002 /* keep internal signals */
#define BVL_CHECKEMPTY 0x00000004 /* check for empty architecture */
/* ###------------------------------------------------------### */
/* data structures */
/* ###------------------------------------------------------### */
typedef struct bvl_expr /* a signal's expression */
{
char *IDENT ; /* identifier or constant name */
unsigned int TIME ; /* waveform's delay */
struct chain *LIST_ABL; /* pointer on a list of ABL */
short WIDTH ; /* width of bit vector */
}
bvl_ablstr;
typedef struct /* an object name */
{
char *NAME ; /* identifier name */
short LEFT ; /* vector's left index */
short RIGHT ; /* vector's right index */
char FLAG ; /* scalar ('S') or array 'A' */
}
bvl_name;
struct g_type
{
int VALU;
char FLAG;
};
/* ###------------------------------------------------------### */
/* global variables */
/* ###------------------------------------------------------### */
extern int BVL_AUXMOD ; /* don't keep internal sig (=1) */
extern char BVL_ERRFLG ; /* error flag */
extern char BVL_CURFIL []; /* current file name */
extern struct befig *BVL_HEDFIG ; /* list of descriptions */
/* ###------------------------------------------------------### */
/* functions */
/* ###------------------------------------------------------### */
extern char *bvl_getvers ();
extern void bvl_error ();
extern char *bvl_abl2str ();
extern struct bepor *bvl_vpor ();
extern struct beaux *bvl_vaux ();
extern struct bebux *bvl_vbux ();
extern struct bereg *bvl_vreg ();
extern char *bvl_printabl ();
extern void bvl_message ();
extern struct befig *vhdlloadbefig ();
extern int vhdlsavebefig ();
#endif

View File

@ -0,0 +1,245 @@
%{
#include <stdio.h>
#include <string.h>
#include "mut.h"
#include "beh.h"
#include "bvl.h"
#include "bvl_bcomp_y.h"
%}
upper_case_letter [A-Z]
digit [0-9]
special_character [\#\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\_\|]
space_character [ \t]
format_effector [\t\v\r\l\f]
end_of_line \n
lower_case_letter [a-z]
other_special_character [\!\$\@\?\[\\\]\^\`\{\}\~]
graphic_character ({basic_graphic_character}|{lower_case_letter}|{other_special_character})
basic_graphic_character ({upper_case_letter}|{digit}|{special_character}|{space_character})
letter ({upper_case_letter}|{lower_case_letter})
letter_or_digit ({letter}|{digit})
decimal_literal {integer}(\.{integer})?({exponent})?
integer {digit}(_?{digit})*
exponent ([eE][-+]?{integer})
base {integer}
based_integer {extended_digit}(_?{extended_digit})*
extended_digit ({digit}|[a-fA-F])
base_specifier (B|b|O|o|X|x)
%%
[ \t] ;
\n { BEH_LINNUM++; }
\& { return (Ampersand ); }
\' { return (Apostrophe); }
\( { return (LeftParen ); }
\) { return (RightParen); }
"**" { return (DoubleStar); }
\* { return (Star ); }
\+ { return (Plus ); }
\, { return (Comma ); }
\- { return (Minus ); }
":=" { return (VarAsgn ); }
\: { return (Colon ); }
\; { return (Semicolon ); }
"<=" { return (_LESym ); }
">=" { return (_GESym ); }
\< { return (_LTSym ); }
\> { return (_GTSym ); }
= { return (_EQSym ); }
\/= { return (_NESym ); }
"=>" { return (Arrow ); }
"<>" { return (Box ); }
\| { return (Bar ); }
! { return (Bar ); }
\. { return (Dot ); }
\/ { return (Slash ); }
{letter}(_?{letter_or_digit})* {
int itoken;
static int search ();
itoken = search (yytext);
if (itoken == EMPTYHT)
{
yylval.text = namealloc (yytext);
return (Identifier);
}
else
{
return (itoken);
}
}
({decimal_literal})|({base}#{based_integer}(\.{based_integer})?#({exponent})?)|({base}:{based_integer}(\.{based_integer})?:({exponent})?) {
yylval.text = mbkalloc ((unsigned int)strlen(yytext)+1);
strcpy (yylval.text, yytext);
return (AbstractLit);
}
'({graphic_character}|\"|\%)' {
yylval.text = namealloc (yytext);
return (CharacterLit);
}
(\"({graphic_character}|(\"\")|\%)*\")|(\%({graphic_character}|(\%\%)|\")*\%) {
yylval.text = namealloc (yytext);
return (StringLit);
}
{base_specifier}((\"{extended_digit}(_?{extended_digit})*\")|(\%{extended_digit}(_?{extended_digit})*\%)) {
yylval.text = namealloc (yytext);
return (BitStringLit);
}
\-\-.*$ ;
. { return (*yytext); }
%%
/* ###--------------------------------------------------------------### */
/* function : yywrap */
/* description : return 1 */
/* called func. : none */
/* ###--------------------------------------------------------------### */
int yywrap ()
{
return (1);
}
/* ###--------------------------------------------------------------### */
/* function : search */
/* description : check that an identifier is a reserved word or not */
/* called func. : addht, addhtitem, gethtitem, namealloc */
/* ###--------------------------------------------------------------### */
static int search (key)
char *key;
{
static ht *pt_hash = NULL;
if (pt_hash == NULL)
{
pt_hash = addht (107);
addhtitem (pt_hash, namealloc("abs") , ABS );
addhtitem (pt_hash, namealloc("access") , ACCESS );
addhtitem (pt_hash, namealloc("after") , AFTER );
addhtitem (pt_hash, namealloc("alias") , ALIAS );
addhtitem (pt_hash, namealloc("all") , ALL );
addhtitem (pt_hash, namealloc("and") , _AND );
addhtitem (pt_hash, namealloc("architecture") , ARCHITECTURE );
addhtitem (pt_hash, namealloc("array") , ARRAY );
addhtitem (pt_hash, namealloc("assert") , ASSERT );
addhtitem (pt_hash, namealloc("attribute") , ATTRIBUTE );
addhtitem (pt_hash, namealloc("begin") , _BEGIN );
addhtitem (pt_hash, namealloc("bit") , BIT );
addhtitem (pt_hash, namealloc("bit_vector") , BIT_VECTOR );
addhtitem (pt_hash, namealloc("block") , BLOCK );
addhtitem (pt_hash, namealloc("body") , BODY );
addhtitem (pt_hash, namealloc("buffer") , BUFFER );
addhtitem (pt_hash, namealloc("bus") , BUS );
addhtitem (pt_hash, namealloc("case") , CASE );
addhtitem (pt_hash, namealloc("component") , COMPONENT );
addhtitem (pt_hash, namealloc("configuration"), CONFIGURATION);
addhtitem (pt_hash, namealloc("constant") , CONSTANT );
addhtitem (pt_hash, namealloc("disconnect") , DISCONNECT );
addhtitem (pt_hash, namealloc("downto") , DOWNTO );
addhtitem (pt_hash, namealloc("else") , ELSE );
addhtitem (pt_hash, namealloc("elsif") , ELSIF );
addhtitem (pt_hash, namealloc("end") , _END );
addhtitem (pt_hash, namealloc("entity") , ENTITY );
addhtitem (pt_hash, namealloc("error") , ERROR );
addhtitem (pt_hash, namealloc("exit") , _EXIT );
addhtitem (pt_hash, namealloc("file") , _FILE );
addhtitem (pt_hash, namealloc("for") , FOR );
addhtitem (pt_hash, namealloc("fs") , FS );
addhtitem (pt_hash, namealloc("function") , FUNCTION );
addhtitem (pt_hash, namealloc("generate") , GENERATE );
addhtitem (pt_hash, namealloc("generic") , GENERIC );
addhtitem (pt_hash, namealloc("guarded") , GUARDED );
addhtitem (pt_hash, namealloc("if") , IF );
addhtitem (pt_hash, namealloc("in") , _IN );
addhtitem (pt_hash, namealloc("inout") , _INOUT );
addhtitem (pt_hash, namealloc("is") , IS );
addhtitem (pt_hash, namealloc("label") , _LABEL );
addhtitem (pt_hash, namealloc("library") , LIBRARY );
addhtitem (pt_hash, namealloc("linkage") , _LINKAGE );
addhtitem (pt_hash, namealloc("loop") , LOOP );
addhtitem (pt_hash, namealloc("map") , MAP );
addhtitem (pt_hash, namealloc("mod") , MOD );
addhtitem (pt_hash, namealloc("ms") , MS );
addhtitem (pt_hash, namealloc("mux_bit") , MUX_BIT );
addhtitem (pt_hash, namealloc("mux_vector") , MUX_VECTOR );
addhtitem (pt_hash, namealloc("nand") , _NAND );
addhtitem (pt_hash, namealloc("natural") , NATURAL );
addhtitem (pt_hash, namealloc("new") , NEW );
addhtitem (pt_hash, namealloc("next") , _NEXT );
addhtitem (pt_hash, namealloc("nor") , _NOR );
addhtitem (pt_hash, namealloc("not") , _NOT );
addhtitem (pt_hash, namealloc("ns") , NS );
addhtitem (pt_hash, namealloc("null") , _NULL );
addhtitem (pt_hash, namealloc("of") , OF );
addhtitem (pt_hash, namealloc("on") , ON );
addhtitem (pt_hash, namealloc("open") , OPEN );
addhtitem (pt_hash, namealloc("or") , _OR );
addhtitem (pt_hash, namealloc("others") , OTHERS );
addhtitem (pt_hash, namealloc("out") , _OUT );
addhtitem (pt_hash, namealloc("package") , PACKAGE );
addhtitem (pt_hash, namealloc("port") , PORT );
addhtitem (pt_hash, namealloc("procedure") , PROCEDURE );
addhtitem (pt_hash, namealloc("process") , PROCESS );
addhtitem (pt_hash, namealloc("ps") , PS );
addhtitem (pt_hash, namealloc("range") , RANGE );
addhtitem (pt_hash, namealloc("record") , RECORD );
addhtitem (pt_hash, namealloc("reg_bit") , REG_BIT );
addhtitem (pt_hash, namealloc("reg_vector") , REG_VECTOR );
addhtitem (pt_hash, namealloc("register") , REGISTER );
addhtitem (pt_hash, namealloc("rem") , REM );
addhtitem (pt_hash, namealloc("report") , REPORT );
addhtitem (pt_hash, namealloc("return") , RETURN );
addhtitem (pt_hash, namealloc("select") , SELECT );
addhtitem (pt_hash, namealloc("severity") , SEVERITY );
addhtitem (pt_hash, namealloc("signal") , SIGNAL );
addhtitem (pt_hash, namealloc("stable") , _STABLE );
addhtitem (pt_hash, namealloc("subtype") , SUBTYPE );
addhtitem (pt_hash, namealloc("then") , THEN );
addhtitem (pt_hash, namealloc("to") , TO );
addhtitem (pt_hash, namealloc("transport") , TRANSPORT );
addhtitem (pt_hash, namealloc("type") , _TYPE );
addhtitem (pt_hash, namealloc("units") , UNITS );
addhtitem (pt_hash, namealloc("until") , UNTIL );
addhtitem (pt_hash, namealloc("us") , US );
addhtitem (pt_hash, namealloc("use") , USE );
addhtitem (pt_hash, namealloc("variable") , VARIABLE );
addhtitem (pt_hash, namealloc("wait") , WAIT );
addhtitem (pt_hash, namealloc("warning") , WARNING );
addhtitem (pt_hash, namealloc("when") , WHEN );
addhtitem (pt_hash, namealloc("while") , WHILE );
addhtitem (pt_hash, namealloc("with") , WITH );
addhtitem (pt_hash, namealloc("wor_bit") , WOR_BIT );
addhtitem (pt_hash, namealloc("wor_vector") , WOR_VECTOR );
addhtitem (pt_hash, namealloc("xor") , _XOR );
}
return (gethtitem (pt_hash, namealloc(key)));
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
/* ###--------------------------------------------------------------### */
/* file : bvl_bedef.h */
/* date : Jan 18 1993 */
/* version : v106 */
/* author : P.BAZARGAN, L.A.TABUSSE, VUONG H.N. */
/* content : declaration of define used by yacc */
/* ###--------------------------------------------------------------### */
#define BVL_ICNDFN 1 /* input port */
#define BVL_OCNDFN 2 /* output port */
#define BVL_BCNDFN 3 /* inout port */
#define BVL_CSTDFN 4 /* constant */
#define BVL_BITDFN 8 /* bit type */
#define BVL_MUXDFN 16 /* mux_bit type */
#define BVL_WORDFN 24 /* wor_bit type */
#define BVL_RBIDFN 32 /* reg_bit type */
#define BVL_BTVDFN 40 /* bit_vector type */
#define BVL_MXVDFN 48 /* mux_vector type */
#define BVL_WRVDFN 56 /* wor_vector type */
#define BVL_RGVDFN 64 /* reg_vector type */
#define BVL_NATDFN 88 /* natural type */
#define BVL_NTVDFN 96 /* nat_vector type */
#define BVL_NORDFN 128 /* non guarded signal */
#define BVL_BUSDFN 256 /* guarded signal (bus) */
#define BVL_REGDFN 384 /* guarded signal (register)*/
#define BVL_MODDFN 0 /* field # 0 of dictionnary */
#define BVL_SIGDFN 1 /* field # 1 of dictionnary */
#define BVL_STBDFN 3 /* field # 3 of dictionnary */
#define BVL_LBLDFN 4 /* field # 4 of dictionnary */
#define BVL_WMXDFN 5 /* field # 5 of dictionnary */
#define BVL_WMNDFN 6 /* field # 6 of dictionnary */
#define BVL_PNTDFN 7 /* field # 7 of dictionnary */
#define BVL_UPTDFN 1 /* direction is up */
#define BVL_DWTDFN 0 /* direction is down */
#define NE 9
#define EQ 10
#define NOPI 11
#define NOPS 12
#define ANDM 13
#define CONC 14
#define CONVRT 15
#define BVL_UNGDFN 0
#define BVL_GRDDFN 1

View File

@ -0,0 +1,31 @@
/* ###--------------------------------------------------------------### */
/* file : bvl_byacc.h */
/* date : Mar 8 2000 */
/* version : v114 */
/* author : Pirouz BAZARGAN SABET */
/* content : declaration of external functions and global variables*/
/* used by yacc */
/* ###--------------------------------------------------------------### */
static pNode BVL_BDDPNT = NULL;/* BDD pointer */
static char *BVL_MODNAM; /* curnennt model name */
static bvl_ablstr BVL_SLCEXP; /* structure filled with the */
static bvl_ablstr BVL_EMPSTR; /* empty structure used with NOT*/
static char *BVL_LBLNAM = NULL;/* label */
static struct chain *BVL_NM1LST = NULL;/* 1-st name liste */
static struct chain *BVL_GRDLST = NULL;/* list of guard's ABL */
static struct chain *BVL_CNDLST = NULL;/* list of conditions (ABL) */
static struct chain *BVL_VALLST = NULL;/* list of waveforms (ABL) */
static struct befig *BVL_BEFPNT = NULL;/* current BEFIG pointer */
static struct begen *BVL_GENPNT = NULL;
static struct beden **dic = NULL;/* dictionary */
static float BVL_CNVFS = 1.0 ;/* convert Fs */
static float BVL_CNVPS = 1.0 ;/* convert Ps */
static float BVL_CNVNS = 1.0 ;/* convert Ns */
static float BVL_CNVUS = 1.0 ;/* convert Us */
static float BVL_CNVMS = 1.0 ;/* convert Ms */
static struct chain *BVL_INTLST = NULL;

View File

@ -0,0 +1,603 @@
/* ###--------------------------------------------------------------### */
/* file : bvl_drive.c */
/* date : Feb 28 2000 */
/* version : v114 */
/* author : VUONG H.N., Pirouz BAZARGAN SABET */
/* description : This file contains VHDL drivers : */
/* vhdlsavebefig */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "bhl.h"
#include "bvl.h"
/* ###--------------------------------------------------------------### */
/* function : vhdlsavebefig */
/* description : print out a text file containing a data-flow VHDL */
/* description */
/* called func. : beh_vhdlname, mbkalloc, beh_message, beh_error , */
/* beh_toolbug , getptype, reverse , bvl_abl2str */
/* bvl_getvers */
/* ###--------------------------------------------------------------### */
int vhdlsavebefig (pt_fig, trace_mode)
struct befig *pt_fig ;
int trace_mode;
{
struct begen *pt_gen = NULL; /* current ptype pnt (generic) */
struct bereg *pt_reg = NULL; /* current BEREG pointer */
struct bemsg *pt_msg = NULL; /* current BEMSG pointer */
struct beout *pt_out = NULL; /* current BEOUT pointer */
struct bebus *pt_bus = NULL; /* current BEBUS pointer */
struct beaux *pt_aux = NULL; /* current BEAUX pointer */
struct bebux *pt_bux = NULL; /* current BEBUX pointer */
struct bepor *pt_por = NULL; /* correctly ordered port list */
struct biabl *ptbiabl = NULL; /* current BIABL pointer */
char *suffix ;
char *str ;
char *mode ;
char *type ;
char *kind ;
char *direct ;
char *transp ;
int nrlabel = 0;
int buff_size = 128;
char *buffer ;
FILE *fp ;
time_t clock ;
int left ;
int right ;
char name [256];
char *time_unit ;
unsigned int time_step ;
int err_flg = 0;
if ((pt_fig == NULL) || (pt_fig->ERRFLG != 0))
beh_toolbug (10, "vhdlsavebefig", NULL, 0);
time_step = pt_fig->TIME_STEP;
buffer = mbkalloc (buff_size);
buffer [0] = '\0';
/* ###------------------------------------------------------### */
/* open result file */
/* ###------------------------------------------------------### */
if ((str = mbkgetenv ("VH_BEHSFX")) != NULL)
suffix = strtok (str, ":");
else
suffix = "vbe";
if ((fp = mbkfopen (pt_fig->NAME, suffix, WRITE_TEXT)) == NULL)
err_flg = beh_error (107, NULL);
else
{
if (trace_mode == 1)
beh_message (13, pt_fig->NAME);
time (&clock);
fprintf (fp, "-- VHDL description generated from `%s`\n", pt_fig->NAME);
fprintf (fp, "--\t\tdate : %s" , ctime (&clock));
fprintf (fp, "--\t\trevision : %s\n\n", bvl_getvers ());
/* ###------------------------------------------------------### */
/* entity declaration */
/* ###------------------------------------------------------### */
fprintf (fp, "-- Entity Declaration\n\n");
fprintf (fp, "ENTITY %s IS\n", beh_vhdlname (pt_fig->NAME));
/* ###------------------------------------------------------### */
/* generic declaration */
/* ###------------------------------------------------------### */
if ((pt_gen = pt_fig->BEGEN) != NULL)
{
pt_gen = (struct begen *) reverse ((struct chain *) pt_gen);
fprintf (fp, " GENERIC (\n");
while (pt_gen != NULL)
{
fprintf (fp, " CONSTANT %s : NATURAL := %ld",
beh_vhdlname (pt_gen->NAME), *((long *)pt_gen->VALUE));
if (pt_gen->NEXT != NULL)
fprintf (fp, ";\t-- %s\n", pt_gen->NAME);
else
fprintf (fp, "\t-- %s\n" , pt_gen->NAME);
pt_gen = pt_gen->NEXT;
}
fprintf (fp, " );\n");
}
/* ###------------------------------------------------------### */
/* port declaration */
/* ###------------------------------------------------------### */
pt_por = pt_fig->BEPOR;
if (pt_por != NULL)
{
fprintf (fp, " PORT (\n");
pt_fig->BEPOR = (struct bepor *) reverse ((struct chain *) pt_fig->BEPOR);
pt_por = pt_fig->BEPOR;
while (pt_por != NULL)
{
switch (pt_por->DIRECTION)
{
case 'I':
mode = "IN" ; break;
case 'O':
case 'Z':
mode = "OUT" ; break;
case 'B':
case 'T':
mode = "INOUT"; break;
default :
err_flg = beh_error (69, pt_por->NAME);
mode = "IN" ;
}
pt_por = bvl_vpor (pt_por, &left, &right, name);
if (left != -1)
{
switch (pt_por->TYPE)
{
case 'B':
type = "BIT_VECTOR";
kind = "";
break;
case 'W':
type = "WOR_VECTOR";
kind = "BUS";
break;
case 'M':
type = "MUX_VECTOR";
kind = "BUS";
break;
default :
err_flg = beh_error (68, pt_por->NAME);
type = "BIT_VECTOR";
kind = "";
}
if (left >= right)
direct = "DOWNTO";
else
direct = "TO" ;
fprintf (fp, " SIGNAL %s : %s %s (%d %s %d) %s", beh_vhdlname (name),
mode, type, left, direct, right, kind);
}
else
{
switch (pt_por->TYPE)
{
case 'B':
type = "BIT" ; break;
case 'W':
type = "WOR_BIT BUS"; break;
case 'M':
type = "MUX_BIT BUS"; break;
default :
err_flg = beh_error (68, pt_por->NAME);
type = "BIT" ;
}
fprintf (fp, " SIGNAL %s : %s %s", beh_vhdlname (name), mode, type);
}
if (pt_por->NEXT != NULL)
fprintf (fp, ";\t-- %s\n" , name);
else
fprintf (fp, "\t-- %s\n );\n", name);
pt_por = pt_por->NEXT;
}
pt_fig->BEPOR = (struct bepor *) reverse ((struct chain *) pt_fig->BEPOR);
}
fprintf (fp, "END %s;\n\n\n", beh_vhdlname (pt_fig->NAME));
/* ###------------------------------------------------------### */
/* architecture declaration */
/* ###------------------------------------------------------### */
fprintf (fp, "-- Architecture Declaration\n\n");
fprintf (fp, "ARCHITECTURE behavioural OF %s IS\n",
beh_vhdlname (pt_fig->NAME));
/* ###------------------------------------------------------### */
/* registers' decalration */
/* ###------------------------------------------------------### */
pt_fig->BEREG = (struct bereg *) reverse ((struct chain *) pt_fig->BEREG);
pt_reg = pt_fig->BEREG;
while (pt_reg != NULL)
{
pt_reg = bvl_vreg (pt_reg, &left, &right, name);
if (left != -1)
{
if (left >= right)
direct = "DOWNTO";
else
direct = "TO" ;
fprintf (fp, " SIGNAL %s : REG_VECTOR (%d %s %d) REGISTER;\t-- %s\n",
beh_vhdlname (name), left, direct, right, name);
}
else
{
fprintf (fp, " SIGNAL %s : REG_BIT REGISTER;\t-- %s\n",
beh_vhdlname (name), name);
}
pt_reg = pt_reg->NEXT;
}
pt_fig->BEREG = (struct bereg *) reverse ((struct chain *) pt_fig->BEREG);
/* ###------------------------------------------------------### */
/* internal buses' declaration */
/* ###------------------------------------------------------### */
pt_fig->BEBUX = (struct bebux *) reverse ((struct chain *) pt_fig->BEBUX);
pt_bux = pt_fig->BEBUX;
while (pt_bux != NULL)
{
pt_bux = bvl_vbux (pt_bux, &left, &right, name);
if (left != -1)
{
switch (pt_bux->TYPE)
{
case 'W':
type = "WOR_VECTOR";
break;
case 'M':
type = "MUX_VECTOR";
break;
default :
err_flg = beh_error (67, pt_bux->NAME);
type = "MUX_VECTOR";
}
if (left >= right)
direct = "DOWNTO";
else
direct = "TO" ;
fprintf (fp, " SIGNAL %s : %s (%d %s %d) BUS;\t-- %s\n",
beh_vhdlname (name), type, left, direct, right, name);
}
else
{
switch (pt_bux->TYPE)
{
case 'W':
type = "WOR_BIT";
break;
case 'M':
type = "MUX_BIT";
break;
default :
err_flg = beh_error (67, pt_bux->NAME);
type = "MUX_BIT";
}
fprintf (fp, " SIGNAL %s : %s BUS;\t\t-- %s\n", beh_vhdlname (name),
type, name);
}
pt_bux = pt_bux->NEXT;
}
pt_fig->BEBUX = (struct bebux *) reverse ((struct chain *) pt_fig->BEBUX);
/* ###------------------------------------------------------### */
/* simple internal signals' declaration */
/* ###------------------------------------------------------### */
pt_fig->BEAUX = (struct beaux *) reverse ((struct chain *) pt_fig->BEAUX);
pt_aux = pt_fig->BEAUX;
while (pt_aux != NULL)
{
pt_aux = bvl_vaux (pt_aux, &left, &right, name);
if (left != -1)
{
if (left >= right)
direct = "DOWNTO";
else
direct = "TO" ;
fprintf (fp, " SIGNAL %s : BIT_VECTOR (%d %s %d);\t-- %s\n",
beh_vhdlname (name), left, direct, right, name);
}
else
{
fprintf (fp, " SIGNAL %s : BIT;\t\t-- %s\n", beh_vhdlname(name), name);
}
pt_aux = pt_aux->NEXT;
}
pt_fig->BEAUX = (struct beaux *)reverse ((struct chain *) pt_fig->BEAUX);
/* ###------------------------------------------------------### */
/* description part */
/* ###------------------------------------------------------### */
fprintf (fp, "\nBEGIN\n");
time_unit = beh_gettimeunit (pt_fig);
/* ###------------------------------------------------------### */
/* print out a concurrent assert statement for each BEMSG */
/* ###------------------------------------------------------### */
pt_msg = pt_fig->BEMSG;
while (pt_msg != NULL)
{
if (pt_msg->LABEL != NULL)
fprintf (fp, " %s :", pt_msg->LABEL);
buffer = bvl_abl2str (pt_msg->ABL, buffer, &buff_size);
fprintf (fp, " ASSERT (%s = '1')\n", bvl_printabl (buffer));
buffer [0] = '\0';
if (pt_msg->MESSAGE != NULL)
fprintf (fp, " REPORT %s\n", pt_msg->MESSAGE);
if (pt_msg->LEVEL == 'W')
fprintf (fp, " SEVERITY WARNING;\n\n");
else
fprintf (fp, " SEVERITY ERROR;\n\n" );
pt_msg = pt_msg->NEXT;
}
/* ###------------------------------------------------------### */
/* concurrent signal assignment for simple internal signals */
/* ###------------------------------------------------------### */
pt_aux = pt_fig->BEAUX;
while (pt_aux != NULL)
{
if (pt_aux->ABL == NULL)
err_flg = beh_error (40, pt_aux->NAME);
else
{
buffer = bvl_abl2str (pt_aux->ABL, buffer, &buff_size);
if ((pt_aux->FLAG & BEH_ASG_TRANSPORT) != 0)
transp = "TRANSPORT";
else
transp = "" ;
fprintf (fp, " %s <= %s %s", beh_vhvector (pt_aux->NAME), transp,
bvl_printabl (buffer));
if (pt_aux->TIME == 0)
fprintf (fp, ";\n");
else
fprintf (fp, " after %u %s;\n", pt_aux->TIME*time_step, time_unit);
buffer [0] = '\0';
}
pt_aux = pt_aux->NEXT;
}
/* ###------------------------------------------------------### */
/* print out a block statement with one guarded concurrent */
/* signal assignment for each driver of each register */
/* ###------------------------------------------------------### */
pt_reg = pt_fig->BEREG;
while (pt_reg != NULL)
{
ptbiabl = pt_reg->BIABL;
while (ptbiabl != NULL)
{
fprintf (fp, " label%d : BLOCK ", nrlabel);
if (ptbiabl->CNDABL == NULL)
beh_toolbug (19, "vhdlsavebefig", pt_reg->NAME, 0);
else
{
buffer = bvl_abl2str (ptbiabl->CNDABL, buffer, &buff_size);
fprintf (fp, "(%s = '1')\n", bvl_printabl (buffer));
buffer [0] = '\0';
}
if ((ptbiabl->FLAG & BEH_ASG_TRANSPORT) != 0)
transp = "TRANSPORT";
else
transp = "" ;
fprintf (fp, " BEGIN\n");
fprintf (fp, " %s <= ", beh_vhvector (pt_reg->NAME));
if (ptbiabl->VALABL == NULL)
beh_toolbug (20, "vhdlsavebefig", pt_reg->NAME, 0);
else
{
buffer = bvl_abl2str (ptbiabl->VALABL, buffer, &buff_size);
fprintf (fp, "GUARDED %s %s ", transp, bvl_printabl (buffer));
if (ptbiabl->TIME == 0)
fprintf (fp, ";\n");
else
fprintf (fp, "after %u %s;\n", ptbiabl->TIME*time_step, time_unit);
buffer[0] = '\0';
}
fprintf (fp, " END BLOCK label%d;\n", nrlabel);
ptbiabl = ptbiabl->NEXT;
nrlabel++;
}
pt_reg = pt_reg->NEXT;
}
/* ###------------------------------------------------------### */
/* Print out a block statement with one guarded concurrent */
/* signal assignment for each driver of each internal bus */
/* ###------------------------------------------------------### */
pt_bux = pt_fig->BEBUX;
while (pt_bux != NULL)
{
ptbiabl = pt_bux->BIABL;
while (ptbiabl != NULL)
{
fprintf (fp, " label%d : BLOCK ", nrlabel);
if (ptbiabl->CNDABL == NULL)
beh_toolbug (19, "vhdlsavebefig", pt_bux->NAME, 0);
else
{
buffer = bvl_abl2str (ptbiabl->CNDABL, buffer, &buff_size);
fprintf (fp, "(%s = '1')\n", bvl_printabl (buffer));
buffer[0] = '\0';
}
if ((ptbiabl->FLAG & BEH_ASG_TRANSPORT) != 0)
transp = "TRANSPORT";
else
transp = "" ;
fprintf (fp, " BEGIN\n");
fprintf (fp, " %s <= ", beh_vhvector (pt_bux->NAME));
if (ptbiabl->VALABL == NULL)
beh_toolbug (20, "vhdlsavebefig",pt_bux->NAME,0);
else
{
buffer = bvl_abl2str (ptbiabl->VALABL, buffer, &buff_size);
fprintf (fp, "GUARDED %s %s ", transp, bvl_printabl (buffer));
if (ptbiabl->TIME == 0)
fprintf (fp, ";\n");
else
fprintf (fp, "after %u %s;\n", ptbiabl->TIME*time_step, time_unit);
buffer[0] = '\0';
}
fprintf (fp, " END BLOCK label%d;\n",nrlabel);
ptbiabl = ptbiabl->NEXT;
nrlabel++;
}
pt_bux = pt_bux->NEXT;
}
/* ###------------------------------------------------------### */
/* Print out a block statement with one guarded concurrent */
/* signal assignment for each driver of each bussed output */
/* signal */
/* ###------------------------------------------------------### */
pt_bus = pt_fig->BEBUS;
while (pt_bus != NULL)
{
ptbiabl = pt_bus->BIABL;
while (ptbiabl != NULL)
{
fprintf (fp, " label%d : BLOCK ", nrlabel);
if (ptbiabl->CNDABL == NULL)
beh_toolbug (19, "vhdlsavebefig", pt_bus->NAME, 0);
else
{
buffer = bvl_abl2str (ptbiabl->CNDABL, buffer, &buff_size);
fprintf (fp, "(%s = '1')\n", bvl_printabl (buffer));
buffer [0] = '\0';
}
if ((ptbiabl->FLAG & BEH_ASG_TRANSPORT) != 0)
transp = "TRANSPORT";
else
transp = "" ;
fprintf (fp, " BEGIN\n");
fprintf (fp, " %s <= ", beh_vhvector (pt_bus->NAME));
if (ptbiabl->VALABL == NULL)
beh_toolbug (20, "vhdlsavebefig", pt_bus->NAME, 0);
else
{
buffer = bvl_abl2str (ptbiabl->VALABL, buffer, &buff_size);
fprintf (fp, "GUARDED %s %s ", transp, bvl_printabl (buffer));
if (ptbiabl->TIME == 0)
fprintf (fp, ";\n");
else
fprintf (fp, "after %u %s;\n", ptbiabl->TIME*time_step, time_unit);
buffer [0] = '\0';
}
fprintf (fp, "\tEND BLOCK label%d;\n", nrlabel);
ptbiabl = ptbiabl->NEXT;
nrlabel++;
}
pt_bus = pt_bus->NEXT;
}
/* ###------------------------------------------------------### */
/* print a concurrent signal assignment for each ouput port */
/* ###------------------------------------------------------### */
pt_out = pt_fig->BEOUT;
while (pt_out != NULL)
{
if (pt_out->ABL == NULL)
err_flg = beh_error (40, pt_out->NAME);
else
{
buffer = bvl_abl2str (pt_out->ABL, buffer, &buff_size);
if ((pt_out->FLAG & BEH_ASG_TRANSPORT) != 0)
transp = "TRANSPORT";
else
transp = "" ;
fprintf (fp, " %s <= %s %s", beh_vhvector (pt_out->NAME), transp,
bvl_printabl (buffer));
if (pt_out->TIME == 0)
fprintf (fp, ";\n");
else
fprintf (fp, " after %u %s;\n", pt_out->TIME*time_step, time_unit);
buffer [0] = '\0';
}
pt_out = pt_out->NEXT;
}
fprintf (fp, "END;\n");
fclose (fp);
}
return (err_flg);
}

View File

@ -0,0 +1,18 @@
/* ###--------------------------------------------------------------### */
/* file : bvl_globals.c */
/* date : Feb 28 2000 */
/* version : v114 */
/* author : Pirouz BAZARGAN SABET */
/* description : This file contains declaration of global variables */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
int BVL_AUXMOD ; /* don't keep internal sig (=1) */
char BVL_ERRFLG = 0 ; /* error flag */
char BVL_CURFIL [256]; /* current file name */
struct befig *BVL_HEDFIG = NULL; /* list of descriptions */

View File

@ -0,0 +1,125 @@
/* ###--------------------------------------------------------------### */
/* file : bvl_parse.c */
/* date : Oct 30 1995 */
/* version : v11 */
/* author : L.A TABUSSE & H.N. VUONG & P. BAZARGAN-SABET */
/* content : vhdlloadbefig */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "bhl.h"
#include "bvl.h"
/* ###--------------------------------------------------------------### */
/* function : vhdlloadbefig */
/* description : analyze a behavioural VHDL description and produce a */
/* set of data structure. The function returns a pointer */
/* on a BEFIG. Errors are repported in the returned */
/* structure. */
/* ###--------------------------------------------------------------### */
struct befig *vhdlloadbefig (pt_befig, figname, trace_mode)
struct befig *pt_befig ;
char *figname ;
unsigned int trace_mode;
{
extern FILE *bvl_y_in ;
extern int bvl_y_parse ();
char *tok ;
char *str ;
unsigned int check_mode ;
struct chain *behsfx_lst = NULL;
struct chain *suffix = NULL;
static unsigned int call_nbr = 0 ;
/* ###------------------------------------------------------### */
/* read the environment variable VH_BEHSFX to create a list */
/* of suffix for behavioural files. */
/* ###------------------------------------------------------### */
if ((str = mbkgetenv ("VH_BEHSFX")) != NULL)
{
tok = strtok (str, ":");
while (tok != NULL)
{
behsfx_lst = addchain (behsfx_lst, tok);
tok = strtok (NULL, ":");
}
behsfx_lst = (struct chain *) reverse (behsfx_lst);
}
else
behsfx_lst = addchain (NULL, "vbe");
/* ###------------------------------------------------------### */
/* searching the root file */
/* ###------------------------------------------------------### */
suffix = behsfx_lst;
while (suffix != NULL)
{
if ((bvl_y_in = mbkfopen (figname, suffix->DATA, READ_TEXT)) != NULL)
{
sprintf (BVL_CURFIL, "%s.%s", figname, (char *)suffix->DATA);
break;
}
suffix = suffix->NEXT;
}
if (bvl_y_in == NULL)
{
beh_error (100, figname);
EXIT (1);
}
/* ###------------------------------------------------------### */
/* call the compiler on the current file */
/* - print a message if the trace mode is actif */
/* - add internal signals to the primary input list if */
/* "keep auxiliary" mode is actif */
/* ###------------------------------------------------------### */
if ((trace_mode & BVL_TRACE) != 0)
beh_message (3, BVL_CURFIL);
if ((trace_mode & BVL_KEEPAUX) != 0)
BVL_AUXMOD = 1;
else
BVL_AUXMOD = 0;
BEH_LINNUM = 1;
if (call_nbr != 0)
bvl_y_restart (bvl_y_in);
call_nbr++;
bvl_y_parse ();
fclose (bvl_y_in);
bvl_y_in = NULL;
/* ###------------------------------------------------------### */
/* check the consistency of the compiled description */
/* ###------------------------------------------------------### */
if ((trace_mode & BVL_CHECKEMPTY) != 0)
{
check_mode = BEH_CHK_EMPTY;
BVL_HEDFIG->FLAG |= BEH_ARC_C ;
}
else
{
check_mode = BEH_CHK_DRIVERS;
BVL_HEDFIG->FLAG |= BEH_ARC_VHDL ;
}
BVL_HEDFIG->ERRFLG = beh_chkbefig (BVL_HEDFIG, check_mode);
return (BVL_HEDFIG);
}

View File

@ -0,0 +1,518 @@
/* ###--------------------------------------------------------------### */
/* file : bvl_util.c */
/* date : Mar 8 2000 */
/* version : v114 */
/* author : Pirouz BAZARGAN SABET */
/* description : This file contains some utility functions : */
/* bvl_getvers, bvl_error, bvl_vpor, */
/* bvl_vaux , bvl_vbux , bvl_vreg, */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mut.h"
#include "log.h"
#include "beh.h"
#include "bvl.h"
/* ###--------------------------------------------------------------### */
/* function : bvl_getvers */
/* description : return the revision number */
/* called func. : none */
/* ###--------------------------------------------------------------### */
char *bvl_getvers ()
{
return ("v114");
}
/* ###--------------------------------------------------------------### */
/* function : bvl_error */
/* description : print an error message */
/* called func. : none */
/* ###--------------------------------------------------------------### */
void bvl_error (code, str1)
int code;
char *str1;
{
BVL_ERRFLG++;
fprintf (stderr, "`%s` Error %d line %d :", BVL_CURFIL, code, BEH_LINNUM);
switch (code)
{
case 1:
fprintf (stderr, "`%s` is incompatible with the entity name\n", str1);
break;
case 2:
fprintf (stderr, "bad entity declaration\n");
break;
case 3:
fprintf (stderr, "bad port clause declaration\n");
break;
case 4:
fprintf (stderr, "port `%s` already declared\n", str1);
break;
case 5:
fprintf (stderr, "illegal port declaration (mode, type, kind)\n");
break;
case 6:
fprintf (stderr, "bad port declaration\n");
break;
case 7:
fprintf (stderr, "`%s` is incompatible with the architecture name\n", str1);
break;
case 8:
fprintf (stderr, "bad architecture declaration\n");
break;
case 9:
fprintf (stderr, "illegal declaration\n");
break;
case 10:
fprintf (stderr, "signal `%s` already declared\n", str1);
break;
case 11:
fprintf (stderr, "illegal signal declaration (type, kind)\n");
break;
case 17:
fprintf (stderr, "`%s` unknown port or signal\n", str1);
break;
case 18:
fprintf (stderr, "illegal concurrent statement\n");
break;
case 19:
fprintf (stderr, "label `%s` already declared\n", str1);
break;
case 20:
fprintf (stderr, "`%s` is incompatible with the block's label\n", str1);
break;
case 21:
fprintf (stderr, "input port `%s` cannot be assigned\n", str1);
break;
case 22:
fprintf (stderr, "illegal unguarded signal assignment for `%s`\n", str1);
break;
case 23:
fprintf (stderr, "ilegal guarded signal assignment `%s`\n", str1);
break;
case 25:
fprintf (stderr, "some choices missing in the selected signal assignment\n");
break;
case 26:
fprintf (stderr, "output port `%s` cannot be read\n", str1);
break;
case 28:
fprintf (stderr, "duplicate choice in selected signal assignment\n");
break;
case 30:
fprintf (stderr, "illegal use of OTHERS in selected signal assignment\n");
break;
case 32:
fprintf (stderr, "null array not supported\n");
break;
case 33:
fprintf (stderr, "incompatible constraint and type\n");
break;
case 35:
fprintf (stderr, "illegal assignment of `%s` (widths mismatch)\n", str1);
break;
case 36:
fprintf (stderr, "signal `%s` used out of declared range\n", str1);
break;
case 38:
fprintf (stderr, "width or/and type mismatch\n");
break;
case 39:
fprintf (stderr, "signal `%s` assigned more than once\n", str1);
break;
case 40:
fprintf (stderr, "signal `%s` never assigned\n", str1);
break;
case 68:
fprintf (stderr, "BEPOR type is unknown\n");
break;
case 73:
fprintf (stderr, "`%s` is not a bit string litteral\n", str1);
break;
case 74:
fprintf (stderr, "bad generic declaration\n");
break;
case 75:
fprintf (stderr, "bad generic element\n");
break;
case 76:
fprintf (stderr, "`%s`: when expression must be a constant\n", str1);
break;
case 77:
fprintf (stderr, "illegal generic declaration (type, kind)\n");
break;
case 78:
fprintf (stderr, "illegal constant declaration (type, kind)\n");
break;
case 79:
fprintf (stderr, "illegal use of attribute STABLE on `%s`\n", str1);
break;
case 80:
fprintf (stderr, "different delays not supported on waveforms\n");
break;
case 81:
fprintf (stderr, "unknown time unit\n");
break;
default:
fprintf (stderr, "syntax error\n");
break;
}
if (BVL_ERRFLG > 30)
{
fprintf (stderr, "Too many errors. Cannot continue further more\n");
fprintf (stderr, "\n Have a nice day ...\n");
exit (1);
}
}
/* ###--------------------------------------------------------------### */
/* function : bvl_vpor */
/* description : check a list of ports to identify a vector */
/* called func. : none */
/* ###--------------------------------------------------------------### */
struct bepor *bvl_vpor (pt_por, pt_lft, pt_rit, name)
struct bepor *pt_por ;
int *pt_lft ;
int *pt_rit ;
char *name ;
{
struct bepor *prv_por = NULL;
int left = -1 ;
int right = -1 ;
int index = -1 ;
char tmp_nam [256] ;
prv_por = pt_por;
if (pt_por != NULL)
{
if (sscanf (pt_por->NAME, "%s %u", name, &left) == 1)
left = -1;
else
{
right = left ;
pt_por = pt_por->NEXT;
while (pt_por != NULL)
{
if (sscanf (pt_por->NAME, "%s %u", tmp_nam, &index) == 1)
break;
else
{
if (strcmp (name, tmp_nam))
break;
}
right = index ;
prv_por = pt_por ;
pt_por = pt_por->NEXT;
}
}
}
*pt_lft = left ;
*pt_rit = right;
return (prv_por);
}
/* ###--------------------------------------------------------------### */
/* function : bvl_vaux */
/* description : check a list of simple internal signals to identify a */
/* vector */
/* called func. : none */
/* ###--------------------------------------------------------------### */
struct beaux *bvl_vaux (pt_aux, pt_lft, pt_rit, name)
struct beaux *pt_aux ;
int *pt_lft ;
int *pt_rit ;
char *name ;
{
struct beaux *prv_aux = NULL;
int left = -1 ;
int right = -1 ;
int index = -1 ;
char tmp_nam [256] ;
prv_aux = pt_aux;
if (pt_aux != NULL)
{
if (sscanf (pt_aux->NAME, "%s %u", name, &left) == 1)
left = -1;
else
{
right = left ;
pt_aux = pt_aux->NEXT;
while (pt_aux != NULL)
{
if (sscanf (pt_aux->NAME, "%s %u", tmp_nam, &index) == 1)
break;
else
{
if (strcmp (name, tmp_nam))
break;
}
right = index ;
prv_aux = pt_aux ;
pt_aux = pt_aux->NEXT;
}
}
}
*pt_lft = left ;
*pt_rit = right;
return (prv_aux);
}
/* ###--------------------------------------------------------------### */
/* function : bvl_vbux */
/* description : check a list of bussed internal signals to identify a */
/* vector */
/* called func. : none */
/* ###--------------------------------------------------------------### */
struct bebux *bvl_vbux (pt_bux, pt_lft, pt_rit, name)
struct bebux *pt_bux ;
int *pt_lft ;
int *pt_rit ;
char *name ;
{
struct bebux *prv_bux = NULL;
int left = -1 ;
int right = -1 ;
int index = -1 ;
char tmp_nam [256] ;
prv_bux = pt_bux;
if (pt_bux != NULL)
{
if (sscanf (pt_bux->NAME, "%s %u", name, &left) == 1)
left = -1;
else
{
right = left ;
pt_bux = pt_bux->NEXT;
while (pt_bux != NULL)
{
if (sscanf (pt_bux->NAME, "%s %u", tmp_nam, &index) == 1)
break;
else
{
if (strcmp (name, tmp_nam))
break;
}
right = index ;
prv_bux = pt_bux ;
pt_bux = pt_bux->NEXT;
}
}
}
*pt_lft = left ;
*pt_rit = right;
return (prv_bux);
}
/* ###--------------------------------------------------------------### */
/* function : bvl_vreg */
/* description : check a list of internal registers to identify a */
/* vector */
/* called func. : none */
/* ###--------------------------------------------------------------### */
struct bereg *bvl_vreg (pt_reg, pt_lft, pt_rit, name)
struct bereg *pt_reg ;
int *pt_lft ;
int *pt_rit ;
char *name ;
{
struct bereg *prv_reg = NULL;
int left = -1 ;
int right = -1 ;
int index = -1 ;
char tmp_nam [256] ;
prv_reg = pt_reg;
if (pt_reg != NULL)
{
if (sscanf (pt_reg->NAME, "%s %u", name, &left) == 1)
left = -1;
else
{
right = left ;
pt_reg = pt_reg->NEXT;
while (pt_reg != NULL)
{
if (sscanf (pt_reg->NAME, "%s %u", tmp_nam, &index) == 1)
break;
else
{
if (strcmp (name, tmp_nam))
break;
}
right = index ;
prv_reg = pt_reg ;
pt_reg = pt_reg->NEXT;
}
}
}
*pt_lft = left ;
*pt_rit = right;
return (prv_reg);
}
/* ###--------------------------------------------------------------### */
/* function : bvl_printabl */
/* content : put a \n for a better presentation of an abl */
/* ###--------------------------------------------------------------### */
char *bvl_printabl (chaine)
char *chaine;
{
char *chaine_tmp = NULL;
char *blanc = NULL;
chaine_tmp = chaine;
while (strlen(chaine_tmp) > 60)
{
chaine_tmp = &chaine_tmp[60];
blanc = strchr (chaine_tmp, ' ');
if(blanc != NULL)
{
*blanc = '\n';
chaine_tmp = blanc;
}
}
return (chaine);
}
/* ###--------------------------------------------------------------### */
/* function : bvl_abl2str */
/* description : return a string corresponding to an expression */
/* called func. : */
/* ###--------------------------------------------------------------### */
char *bvl_abl2str (expr, chaine, size_pnt)
struct chain *expr ; /* expression */
char *chaine ; /* target string */
int *size_pnt; /* size of available space */
{
int operator;
char *oper ;
struct chain *operand ;
static char *str_z = NULL;
static char *str_o = NULL;
static char *str_d = NULL;
if (str_z == NULL)
{
str_z = namealloc ("'0'");
str_o = namealloc ("'1'");
str_d = namealloc ("'d'");
}
/* ###------------------------------------------------------### */
/* if there is not enough space left allocate a bigger block */
/* ###------------------------------------------------------### */
if (*size_pnt < (strlen (chaine) + 50))
{
*size_pnt = *size_pnt + 256;
chaine = (char *) realloc (chaine, *size_pnt);
}
/* ###------------------------------------------------------### */
/* if the expression is a terminal (atom) add its name to */
/* the previous string */
/* ###------------------------------------------------------### */
if (expr->NEXT == NULL)
{
if ((expr->DATA == (void *) str_z) ||
(expr->DATA == (void *) str_o) ||
(expr->DATA == (void *) str_d) )
strcat (chaine, expr->DATA);
else
strcat (chaine, beh_vhvector (expr->DATA));
}
else
{
/* ###------------------------------------------------------### */
/* if the expression is not a terminal : */
/* - for unary operators (not, stable) add */
/* "operator ( operand )" to the previous string */
/* */
/* - for binary operators (and, or, nor, xor, ...) add */
/* "(operand operator operand operator operand ...)" */
/* ###------------------------------------------------------### */
operator = (int) ((struct chain *) expr->DATA)->DATA;
operand = (struct chain *) expr->NEXT->DATA;
if (operator == STABLE)
{
strcat (chaine, beh_vhvector (operand->DATA));
strcat (chaine, "'STABLE");
}
else
{
if (operator == NOT)
{
strcat (chaine, "not (");
chaine = bvl_abl2str (operand, chaine, size_pnt);
}
else
{
oper = operToChar (operator);
strcat (chaine,"(");
while ((expr = expr->NEXT) != NULL)
{
chaine = bvl_abl2str (expr->DATA, chaine, size_pnt);
if ((expr->NEXT) != NULL)
{
strcat (chaine, " ");
strcat (chaine, oper);
strcat (chaine, " ");
}
}
}
strcat (chaine, ")");
}
}
return (chaine);
}