Behavioral ternary operators for vvp.

This commit is contained in:
steve 2001-05-17 04:37:02 +00:00
parent 5aee3b866a
commit 0872ad34cf
7 changed files with 131 additions and 70 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: ivl_target.h,v 1.61 2001/05/12 03:18:44 steve Exp $"
#ident "$Id: ivl_target.h,v 1.62 2001/05/17 04:37:02 steve Exp $"
#endif
#ifdef __cplusplus
@ -167,6 +167,7 @@ typedef enum ivl_expr_type_e {
IVL_EX_SIGNAL,
IVL_EX_STRING,
IVL_EX_SUBSIG,
IVL_EX_TERNARY,
IVL_EX_UFUNC,
IVL_EX_ULONG,
IVL_EX_UNARY
@ -382,11 +383,11 @@ extern ivl_scope_t ivl_expr_def(ivl_expr_t net);
extern const char* ivl_expr_name(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY */
extern char ivl_expr_opcode(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY */
/* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper1(ivl_expr_t net);
/* IVL_EX_BINARY */
/* IVL_EX_BINARY IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net);
/* */
/* IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper3(ivl_expr_t net);
/* IVL_EX_CONCAT IVL_EX_UFUNC */
extern ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx);
@ -851,6 +852,9 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.62 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
* Revision 1.61 2001/05/12 03:18:44 steve
* Make sure LPM devices have drives on outputs.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-api.cc,v 1.44 2001/05/08 23:59:33 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.45 2001/05/17 04:37:02 steve Exp $"
#endif
# include "t-dll.h"
@ -239,6 +239,9 @@ extern "C" ivl_expr_t ivl_expr_oper1(ivl_expr_t net)
case IVL_EX_MEMORY:
return net->u_.memory_.idx_;
case IVL_EX_TERNARY:
return net->u_.ternary_.cond;
default:
assert(0);
}
@ -253,6 +256,9 @@ extern "C" ivl_expr_t ivl_expr_oper2(ivl_expr_t net)
case IVL_EX_BINARY:
return net->u_.binary_.rig_;
case IVL_EX_TERNARY:
return net->u_.ternary_.true_e;
default:
assert(0);
}
@ -263,6 +269,14 @@ extern "C" ivl_expr_t ivl_expr_oper2(ivl_expr_t net)
extern "C" ivl_expr_t ivl_expr_oper3(ivl_expr_t net)
{
assert(net);
switch (net->type_) {
case IVL_EX_TERNARY:
return net->u_.ternary_.false_e;
default:
assert(0);
}
return 0;
}
@ -1129,6 +1143,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.45 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
* Revision 1.44 2001/05/08 23:59:33 steve
* Add ivl and vvp.tgt support for memories in
* expressions and l-values. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) & !defined(macintosh)
#ident "$Id: t-dll-expr.cc,v 1.12 2001/05/08 23:59:33 steve Exp $"
#ident "$Id: t-dll-expr.cc,v 1.13 2001/05/17 04:37:02 steve Exp $"
#endif
# include "t-dll.h"
@ -166,6 +166,34 @@ void dll_target::expr_sfunc(const NetESFunc*net)
expr_->u_.sfunc_.name_ = strdup(net->name());
}
void dll_target::expr_ternary(const NetETernary*net)
{
assert(expr_ == 0);
ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
assert(expr);
expr->type_ = IVL_EX_TERNARY;
expr->width_ = net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
net->cond_expr()->expr_scan(this);
assert(expr_);
expr->u_.ternary_.cond = expr_;
expr_ = 0;
net->true_expr()->expr_scan(this);
assert(expr_);
expr->u_.ternary_.true_e = expr_;
expr_ = 0;
net->false_expr()->expr_scan(this);
assert(expr_);
expr->u_.ternary_.false_e = expr_;
expr_ = expr;
}
void dll_target::expr_signal(const NetESignal*net)
{
assert(expr_ == 0);
@ -226,6 +254,9 @@ void dll_target::expr_unary(const NetEUnary*net)
/*
* $Log: t-dll-expr.cc,v $
* Revision 1.13 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
* Revision 1.12 2001/05/08 23:59:33 steve
* Add ivl and vvp.tgt support for memories in
* expressions and l-values. (Stephan Boettcher)

12
t-dll.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.h,v 1.43 2001/05/08 23:59:33 steve Exp $"
#ident "$Id: t-dll.h,v 1.44 2001/05/17 04:37:02 steve Exp $"
#endif
# include "target.h"
@ -107,6 +107,7 @@ struct dll_target : public target_t, public expr_scan_t {
void expr_const(const NetEConst*);
void expr_scope(const NetEScope*);
void expr_sfunc(const NetESFunc*);
void expr_ternary(const NetETernary*);
void expr_ufunc(const NetEUFunc*);
void expr_unary(const NetEUnary*);
void expr_signal(const NetESignal*);
@ -173,6 +174,12 @@ struct ivl_expr_s {
ivl_expr_t lsb_;
} subsig_;
struct {
ivl_expr_t cond;
ivl_expr_t true_e;
ivl_expr_t false_e;
} ternary_;
struct {
ivl_memory_t mem_;
ivl_expr_t idx_;
@ -513,6 +520,9 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
* Revision 1.44 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
* Revision 1.43 2001/05/08 23:59:33 steve
* Add ivl and vvp.tgt support for memories in
* expressions and l-values. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: eval_expr.c,v 1.25 2001/05/10 00:26:53 steve Exp $"
#ident "$Id: eval_expr.c,v 1.26 2001/05/17 04:37:02 steve Exp $"
#endif
# include "vvp_priv.h"
@ -810,6 +810,44 @@ static struct vector_info draw_memory_expr(ivl_expr_t exp, unsigned wid)
return res;
}
static struct vector_info draw_ternary_expr(ivl_expr_t exp, unsigned wid)
{
struct vector_info res, tmp;
unsigned lab_false, lab_out;
ivl_expr_t cond = ivl_expr_oper1(exp);
ivl_expr_t true_ex = ivl_expr_oper2(exp);
ivl_expr_t false_ex = ivl_expr_oper3(exp);
lab_false = local_count++;
lab_out = local_count++;
tmp = draw_eval_expr(cond);
clr_vector(tmp);
res.base = allocate_vector(wid);
res.wid = wid;
fprintf(vvp_out, " %%jmp/0xz T_%d.%d, %u;\n",
thread_count, lab_false, tmp.base);
tmp = draw_eval_expr_wid(true_ex, wid);
fprintf(vvp_out, " %%mov %u, %u, %u;\n", res.base, tmp.base, wid);
fprintf(vvp_out, " %%jmp T_%d.%d;\n", thread_count, lab_out);
clr_vector(tmp);
fprintf(vvp_out, "T_%d.%d ;\n", thread_count, lab_false);
tmp = draw_eval_expr_wid(false_ex, wid);
fprintf(vvp_out, " %%mov %u, %u, %u;\n", res.base, tmp.base, wid);
clr_vector(tmp);
fprintf(vvp_out, "T_%d.%d ;\n", thread_count, lab_out);
return res;
}
/*
* A call to a user defined function generates a result that is the
* result of this expression.
@ -944,6 +982,10 @@ struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned wid)
res = draw_signal_expr(exp, wid);
break;
case IVL_EX_TERNARY:
res = draw_ternary_expr(exp, wid);
break;
case IVL_EX_MEMORY:
res = draw_memory_expr(exp, wid);
break;
@ -967,6 +1009,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
/*
* $Log: eval_expr.c,v $
* Revision 1.26 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
* Revision 1.25 2001/05/10 00:26:53 steve
* VVP support for memories in expressions,
* including general support for thread bit
@ -989,63 +1034,5 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
*
* Revision 1.20 2001/04/29 20:47:39 steve
* Evalulate logical or (||)
*
* Revision 1.19 2001/04/21 03:26:23 steve
* Right shift by constant.
*
* Revision 1.18 2001/04/21 01:49:17 steve
* Left shift by a constant amount.
*
* Revision 1.17 2001/04/18 05:12:03 steve
* Use the new %fork syntax.
*
* Revision 1.16 2001/04/15 16:37:48 steve
* add XOR support.
*
* Revision 1.15 2001/04/15 04:07:56 steve
* Add support for behavioral xnor.
*
* Revision 1.14 2001/04/06 02:28:03 steve
* Generate vvp code for functions with ports.
*
* Revision 1.13 2001/04/05 01:12:28 steve
* Get signed compares working correctly in vvp.
*
* Revision 1.12 2001/04/02 03:47:49 steve
* Evaluate binary & and | operators.
*
* Revision 1.11 2001/04/01 22:26:21 steve
* Unary ! is a reduction operator.
*
* Revision 1.10 2001/04/01 21:47:29 steve
* Implement the unary ! operator.
*
* Revision 1.9 2001/04/01 07:22:42 steve
* Generate code for < and <=.
*
* Revision 1.8 2001/04/01 06:49:32 steve
* Evaluate the logical AND operator.
*
* Revision 1.7 2001/03/31 17:36:39 steve
* Generate vvp code for case statements.
*
* Revision 1.6 2001/03/31 02:00:44 steve
* Generate code for + and concat expressions.
*
* Revision 1.5 2001/03/29 05:16:25 steve
* Handle truncation/padding of numbers.
*
* Revision 1.4 2001/03/29 02:52:39 steve
* Add unary ~ operator to tgt-vvp.
*
* Revision 1.3 2001/03/27 06:43:27 steve
* Evaluate === and !==
*
* Revision 1.2 2001/03/23 01:10:24 steve
* Assure that operands are the correct width.
*
* Revision 1.1 2001/03/22 05:06:21 steve
* Geneate code for conditional statements.
*
*/

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vvp_priv.h,v 1.9 2001/05/06 17:54:33 steve Exp $"
#ident "$Id: vvp_priv.h,v 1.10 2001/05/17 04:37:02 steve Exp $"
#endif
# include "ivl_target.h"
@ -73,8 +73,17 @@ extern void draw_memory_index_expr(ivl_memory_t mem, ivl_expr_t exp);
extern void clr_vector(struct vector_info vec);
/*
* These are used to count labels as I generate code.
*/
extern unsigned local_count;
extern unsigned thread_count;
/*
* $Log: vvp_priv.h,v $
* Revision 1.10 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
* Revision 1.9 2001/05/06 17:54:33 steve
* Behavioral code to read memories. (Stephan Boettcher)
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vvp_process.c,v 1.33 2001/05/10 00:26:53 steve Exp $"
#ident "$Id: vvp_process.c,v 1.34 2001/05/17 04:37:02 steve Exp $"
#endif
# include "vvp_priv.h"
@ -27,8 +27,8 @@
static int show_statement(ivl_statement_t net, ivl_scope_t sscope);
static unsigned local_count = 0;
static unsigned thread_count = 0;
unsigned local_count = 0;
unsigned thread_count = 0;
/*
* This file includes the code needed to generate VVP code for
@ -854,6 +854,9 @@ int draw_func_definition(ivl_scope_t scope)
/*
* $Log: vvp_process.c,v $
* Revision 1.34 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
* Revision 1.33 2001/05/10 00:26:53 steve
* VVP support for memories in expressions,
* including general support for thread bit