From 1db8319bce8fb6ee2f2f8a1426c447fe9c036bcb Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 28 Aug 2002 17:15:06 +0000 Subject: [PATCH] Add the %load/nx opcode to index vpi nets. --- vvp/codes.h | 6 +++++- vvp/compile.cc | 19 ++++++++++++++++++- vvp/opcodes.txt | 9 ++++++++- vvp/vthread.cc | 24 +++++++++++++++++++++++- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/vvp/codes.h b/vvp/codes.h index dada3ca31..9b1764834 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: codes.h,v 1.47 2002/08/22 03:38:40 steve Exp $" +#ident "$Id: codes.h,v 1.48 2002/08/28 17:15:06 steve Exp $" #endif @@ -73,6 +73,7 @@ extern bool of_JMP1(vthread_t thr, vvp_code_t code); extern bool of_JOIN(vthread_t thr, vvp_code_t code); extern bool of_LOAD(vthread_t thr, vvp_code_t code); extern bool of_LOAD_MEM(vthread_t thr, vvp_code_t code); +extern bool of_LOAD_NX(vthread_t thr, vvp_code_t code); extern bool of_LOAD_X(vthread_t thr, vvp_code_t code); extern bool of_MOD(vthread_t thr, vvp_code_t code); extern bool of_MOV(vthread_t thr, vvp_code_t code); @@ -153,6 +154,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr); /* * $Log: codes.h,v $ + * Revision 1.48 2002/08/28 17:15:06 steve + * Add the %load/nx opcode to index vpi nets. + * * Revision 1.47 2002/08/22 03:38:40 steve * Fix behavioral eval of x?a:b expressions. * diff --git a/vvp/compile.cc b/vvp/compile.cc index ed38d4872..38bc65f73 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: compile.cc,v 1.138 2002/08/22 03:38:40 steve Exp $" +#ident "$Id: compile.cc,v 1.139 2002/08/28 17:15:06 steve Exp $" #endif # include "arith.h" @@ -69,6 +69,8 @@ enum operand_e { OA_FUNC_PTR2, /* The operand is a pointer to a memory */ OA_MEM_PTR, + /* The operand is a VPI handle */ + OA_VPI_PTR, }; struct opcode_table_s { @@ -116,6 +118,7 @@ const static struct opcode_table_s opcode_table[] = { { "%join", of_JOIN, 0, {OA_NONE, OA_NONE, OA_NONE} }, { "%load", of_LOAD, 2, {OA_BIT1, OA_FUNC_PTR, OA_NONE} }, { "%load/m", of_LOAD_MEM,2, {OA_BIT1, OA_MEM_PTR, OA_NONE} }, + { "%load/nx",of_LOAD_NX,3, {OA_BIT1, OA_VPI_PTR, OA_BIT2} }, { "%load/x", of_LOAD_X, 3, {OA_BIT1, OA_FUNC_PTR, OA_BIT2} }, { "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, @@ -1256,6 +1259,17 @@ void compile_code(char*label, char*mnem, comp_operands_t opa) free(opa->argv[idx].symb.text); break; + case OA_VPI_PTR: + /* The operand is a functor. Resolve the label to + a functor pointer, or postpone the resolution + if it is not defined yet. */ + if (opa->argv[idx].ltype != L_SYMB) { + yyerror("operand format"); + break; + } + + compile_vpi_lookup(&code->handle, opa->argv[idx].symb.text); + break; } } @@ -1434,6 +1448,9 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag, /* * $Log: compile.cc,v $ + * Revision 1.139 2002/08/28 17:15:06 steve + * Add the %load/nx opcode to index vpi nets. + * * Revision 1.138 2002/08/22 03:38:40 steve * Fix behavioral eval of x?a:b expressions. * diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index 81fe55232..89f5e10c4 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) * - * $Id: opcodes.txt,v 1.38 2002/08/27 05:39:57 steve Exp $ + * $Id: opcodes.txt,v 1.39 2002/08/28 17:15:06 steve Exp $ */ @@ -313,6 +313,13 @@ Bit address zero is the LSB of the first memory word. This instruction loads only a single bit. +* %load/nx , , + +This instruction load a value from a .net object bit. Since .net +objects don't really exist (they are only named indirection into the +netlist) this instruction indexes into the .net list of bits. + + * %load/x , , This is an indexed load. It uses the contents of the specified index diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 54e97a271..5ab9bc6c3 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vthread.cc,v 1.82 2002/08/27 05:39:57 steve Exp $" +#ident "$Id: vthread.cc,v 1.83 2002/08/28 17:15:06 steve Exp $" #endif # include "vthread.h" @@ -1353,6 +1353,25 @@ bool of_LOAD_MEM(vthread_t thr, vvp_code_t cp) return true; } +/* + * Load net/indexed. + */ +bool of_LOAD_NX(vthread_t thr, vvp_code_t cp) +{ + assert(cp->bit_idx[0] >= 4); + assert(cp->bit_idx[1] < 4); + assert(cp->handle->vpi_type->type_code == vpiNet); + + struct __vpiSignal*sig = + reinterpret_cast(cp->handle); + + unsigned idx = thr->index[cp->bit_idx[1]]; + + vvp_ipoint_t ptr = vvp_fvector_get(sig->bits, idx); + thr_put_bit(thr, cp->bit_idx[0], functor_get(ptr)); + return true; +} + bool of_LOAD_X(vthread_t thr, vvp_code_t cp) { assert(cp->bit_idx[0] >= 4); @@ -2248,6 +2267,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp) /* * $Log: vthread.cc,v $ + * Revision 1.83 2002/08/28 17:15:06 steve + * Add the %load/nx opcode to index vpi nets. + * * Revision 1.82 2002/08/27 05:39:57 steve * Fix l-value indexing of memories and vectors so that * an unknown (x) index causes so cell to be addresses.