Implement the .resolv syntax.

This commit is contained in:
steve 2001-05-09 02:53:25 +00:00
parent 100bdedac3
commit 4537de8120
10 changed files with 227 additions and 18 deletions

View File

@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.17 2001/05/08 23:59:33 steve Exp $"
#ident "$Id: Makefile.in,v 1.18 2001/05/09 02:53:25 steve Exp $"
#
#
SHELL = /bin/sh
@ -62,7 +62,7 @@ V = vpi_modules.o vpi_const.o vpi_iter.o vpi_mcd.o vpi_priv.o \
vpi_scope.o vpi_signal.o vpi_tasks.o vpi_time.o vpi_memory.o
O = main.o parse.o parse_misc.o lexor.o compile.o debug.o functor.o \
symbols.o codes.o vthread.o schedule.o tables.o udp.o memory.o $V
resolv.o symbols.o codes.o vthread.o schedule.o tables.o udp.o memory.o $V
vvp: $O
$(CXX) $(rdynamic) $(CXXFLAGS) $(LDFLAGS) -o vvp $O $(LIBS) $(dllib)

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: README.txt,v 1.24 2001/05/08 23:58:43 steve Exp $
* $Id: README.txt,v 1.25 2001/05/09 02:53:25 steve Exp $
*/
VVP SIMULATION ENGINE
@ -387,13 +387,14 @@ to make this one go.
RESOLVER STATEMENTS:
Resolver statements are functors with 4 inputs, but their job is to
calculate a resolved output using strength resolution. The type of the
functor is used to select a specific resolution function.
Resolver statements are strength-aware functors with 4 inputs, but
their job typically is to calculate a resolved output using strength
resolution. The type of the functor is used to select a specific
resolution function.
<label> .resolv/tri <symbols_list>;
<label> .resolv/tri0 <symbols_list>;
<label> .resolv/tri1 <symbols_list>;
<label> .resolv tri, <symbols_list>;
<label> .resolv tri0, <symbols_list>;
<label> .resolv tri1, <symbols_list>;
THREAD STATEMENTS:

View File

@ -17,11 +17,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.cc,v 1.59 2001/05/08 23:59:33 steve Exp $"
#ident "$Id: compile.cc,v 1.60 2001/05/09 02:53:25 steve Exp $"
#endif
# include "compile.h"
# include "functor.h"
# include "resolv.h"
# include "udp.h"
# include "memory.h"
# include "symbols.h"
@ -267,6 +268,20 @@ static void inputs_connect(vvp_ipoint_t fdx, unsigned argc, struct symb_s*argv)
continue;
}
if (strcmp(argv[idx].text, "C<x>") == 0) {
free(argv[idx].text);
iobj->ival &= ~(3 << idx*2);
iobj->ival |= 2 << idx*2;
continue;
}
if (strcmp(argv[idx].text, "C<z>") == 0) {
free(argv[idx].text);
iobj->ival &= ~(3 << idx*2);
iobj->ival |= 3 << idx*2;
continue;
}
symbol_value_t val = sym_get_value(sym_functors, argv[idx].text);
vvp_ipoint_t tmp = val.num;
@ -303,7 +318,7 @@ void compile_functor(char*label, char*type, unsigned argc, struct symb_s*argv)
obj->odrive0 = 6;
obj->odrive1 = 6;
obj->mode = 0;
#if defined(WIDH_DEBUG)
#if defined(WITH_DEBUG)
obj->breakpoint = 0;
#endif
@ -360,6 +375,34 @@ void compile_functor(char*label, char*type, unsigned argc, struct symb_s*argv)
free(type);
}
void compile_resolver(char*label, char*type, unsigned argc, struct symb_s*argv)
{
vvp_ipoint_t fdx = functor_allocate(1);
functor_t obj = functor_index(fdx);
define_functor_symbol(label, fdx);
assert(argc <= 4);
obj->ival = 0xaa;
obj->oval = 2;
obj->odrive0 = 6;
obj->odrive1 = 6;
obj->mode = M42;
#if defined(WITH_DEBUG)
obj->breakpoint = 0;
#endif
obj->obj = new vvp_resolv_s;
/* Connect the inputs of this functor to the given symbols. If
there are C<X> inputs, set the ival appropriately. */
inputs_connect(fdx, argc, argv);
free(label);
free(type);
}
void compile_udp_def(int sequ, char *label, char *name,
unsigned nin, unsigned init, char **table)
{
@ -1100,6 +1143,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
/*
* $Log: compile.cc,v $
* Revision 1.60 2001/05/09 02:53:25 steve
* Implement the .resolv syntax.
*
* Revision 1.59 2001/05/08 23:59:33 steve
* Add ivl and vvp.tgt support for memories in
* expressions and l-values. (Stephan Boettcher)

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.h,v 1.20 2001/05/02 04:05:17 steve Exp $"
#ident "$Id: compile.h,v 1.21 2001/05/09 02:53:25 steve Exp $"
#endif
# include <stdio.h>
@ -62,6 +62,14 @@ extern void compile_functor(char*label, char*type,
unsigned argc, struct symb_s*argv);
/*
* This is called by the parser to make a resolver. This is a special
* kind of functor; a strength aware functor.
*/
extern void compile_resolver(char*label, char*type,
unsigned argc, struct symb_s*argv);
extern void compile_vpi_symbol(const char*label, vpiHandle obj);
extern vpiHandle compile_vpi_lookup(const char*label);
@ -174,6 +182,9 @@ extern void compile_dump(FILE*fd);
/*
* $Log: compile.h,v $
* Revision 1.21 2001/05/09 02:53:25 steve
* Implement the .resolv syntax.
*
* Revision 1.20 2001/05/02 04:05:17 steve
* Remove the init parameter of functors, and instead use
* the special C<?> symbols to initialize inputs. This is

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: functor.cc,v 1.17 2001/05/08 23:32:26 steve Exp $"
#ident "$Id: functor.cc,v 1.18 2001/05/09 02:53:25 steve Exp $"
#endif
# include "functor.h"
@ -285,6 +285,12 @@ unsigned functor_get(vvp_ipoint_t ptr)
return fp->oval;
}
unsigned vvp_fobj_s::get(vvp_ipoint_t, functor_t fp)
{
return fp->oval;
}
/*
* This function is used by the scheduler to implement the propagation
* event. The input is the pointer to the functor who's output is to
@ -343,6 +349,9 @@ const unsigned char ft_var[16] = {
/*
* $Log: functor.cc,v $
* Revision 1.18 2001/05/09 02:53:25 steve
* Implement the .resolv syntax.
*
* Revision 1.17 2001/05/08 23:32:26 steve
* Add to the debugger the ability to view and
* break on functors.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: functor.h,v 1.19 2001/05/08 23:32:26 steve Exp $"
#ident "$Id: functor.h,v 1.20 2001/05/09 02:53:25 steve Exp $"
#endif
# include "pointers.h"
@ -159,7 +159,7 @@ typedef struct functor_s *functor_t;
#define M42 42
struct vvp_fobj_s {
virtual unsigned get(vvp_ipoint_t i, functor_t f) =0;
virtual unsigned get(vvp_ipoint_t i, functor_t f);
virtual void set(vvp_ipoint_t i, functor_t f, bool push) =0;
};
@ -260,6 +260,9 @@ extern const unsigned char ft_var[];
/*
* $Log: functor.h,v $
* Revision 1.20 2001/05/09 02:53:25 steve
* Implement the .resolv syntax.
*
* Revision 1.19 2001/05/08 23:32:26 steve
* Add to the debugger the ability to view and
* break on functors.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: lexor.lex,v 1.15 2001/05/01 01:09:39 steve Exp $"
#ident "$Id: lexor.lex,v 1.16 2001/05/09 02:53:25 steve Exp $"
#endif
# include "parse_misc.h"
@ -70,6 +70,7 @@
".functor" { return K_FUNCTOR; }
".net" { return K_NET; }
".net/s" { return K_NET_S; }
".resolv" { return K_RESOLV; }
".scope" { return K_SCOPE; }
".thread" { return K_THREAD; }
".var" { return K_VAR; }
@ -132,6 +133,9 @@ int yywrap()
/*
* $Log: lexor.lex,v $
* Revision 1.16 2001/05/09 02:53:25 steve
* Implement the .resolv syntax.
*
* Revision 1.15 2001/05/01 01:09:39 steve
* Add support for memory objects. (Stephan Boettcher)
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: parse.y,v 1.25 2001/05/02 23:16:50 steve Exp $"
#ident "$Id: parse.y,v 1.26 2001/05/09 02:53:25 steve Exp $"
#endif
# include "parse_misc.h"
@ -54,7 +54,7 @@ extern FILE*yyin;
};
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S K_SCOPE K_THREAD
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S K_RESOLV K_SCOPE K_THREAD
%token K_UDP K_UDP_C K_UDP_S
%token K_MEM K_MEM_P K_MEM_I
%token K_VAR K_VAR_S K_vpi_call K_disable K_fork
@ -144,6 +144,15 @@ statement
| mem_init_stmt
/* Resolver statements are very much like functors. They are
compiled to functors of a different mode. */
| T_LABEL K_RESOLV T_SYMBOL ',' symbols ';'
{ struct symbv_s obj = $5;
compile_resolver($1, $3, obj.cnt, obj.vect);
}
/* Event statements take a label, a type (the first T_SYMBOL) and a
list of inputs. If the type is instead a string, then we have a
named event instead. */
@ -429,6 +438,9 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.26 2001/05/09 02:53:25 steve
* Implement the .resolv syntax.
*
* Revision 1.25 2001/05/02 23:16:50 steve
* Document memory related opcodes,
* parser uses numbv_s structures instead of the

82
vvp/resolv.cc Normal file
View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: resolv.cc,v 1.1 2001/05/09 02:53:53 steve Exp $"
#endif
# include "resolv.h"
# include "schedule.h"
/*
* For now, cheat and resolve the values without using the actual
* strengths. The strengths are not yet available to the inputs, so
* this is all we can do for now.
*/
void vvp_resolv_s::set(vvp_ipoint_t ptr, functor_t fp, bool push)
{
unsigned in1 = (fp->ival >> 0) & 3;
unsigned in2 = (fp->ival >> 2) & 3;
unsigned in3 = (fp->ival >> 4) & 3;
unsigned in4 = (fp->ival >> 5) & 3;
unsigned val = in1;
if (in2 != 3) {
if (val == 3) {
val = in2;
} else if (val != in2) {
val = 2;
} else {
}
}
if (in3 != 3) {
if (val == 3) {
val = in3;
} else if (val != in3) {
val = 2;
} else {
}
}
if (in4 != 3) {
if (val == 3) {
val = in4;
} else if (val != in4) {
val = 2;
} else {
}
}
/* If the output changes, then create a propagation event. */
if (val != fp->oval) {
fp->oval = val;
if (push)
functor_propagate(ptr);
else
schedule_functor(ptr, 0);
}
}
/*
* $Log: resolv.cc,v $
* Revision 1.1 2001/05/09 02:53:53 steve
* Implement the .resolv syntax.
*
*/

41
vvp/resolv.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef __resolv_H
#define __resolv_H
/*
* Copyright (c) 200 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: resolv.h,v 1.1 2001/05/09 02:53:53 steve Exp $"
#endif
# include "functor.h"
class vvp_resolv_s : public vvp_fobj_s {
public:
virtual void set(vvp_ipoint_t i, functor_t f, bool push);
private: // not implemented
};
/*
* $Log: resolv.h,v $
* Revision 1.1 2001/05/09 02:53:53 steve
* Implement the .resolv syntax.
*
*/
#endif