Remove the vvp_cpoint_t indirect code pointer.
This commit is contained in:
parent
272dc749da
commit
dccd7ec7e2
141
vvp/codes.cc
141
vvp/codes.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: codes.cc,v 1.12 2002/08/12 01:35:07 steve Exp $"
|
||||
#ident "$Id: codes.cc,v 1.13 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "codes.h"
|
||||
|
|
@ -25,97 +25,79 @@
|
|||
# include <string.h>
|
||||
# include <assert.h>
|
||||
|
||||
/*
|
||||
* The code space is broken into chunks, to make for efficient
|
||||
* allocation of large amounts. Each chunk is an array of vvp_code_s
|
||||
* structures, with the last opcode loaded with an of_CHUNK_LINK
|
||||
* instruction to branch to the next chunk. This handles the case
|
||||
* where the program counter steps off the end of a chunk.
|
||||
*/
|
||||
const unsigned code_chunk_size = 1024;
|
||||
|
||||
const unsigned code_index0_size = 2 << 9;
|
||||
const unsigned code_index1_size = 2 << 11;
|
||||
const unsigned code_index2_size = 2 << 10;
|
||||
|
||||
struct code_index0 {
|
||||
struct vvp_code_s table[code_index0_size];
|
||||
};
|
||||
|
||||
struct code_index1 {
|
||||
struct code_index0* table[code_index1_size];
|
||||
};
|
||||
|
||||
static vvp_cpoint_t code_count = 0;
|
||||
static struct code_index1*code_table[code_index2_size] = { 0 };
|
||||
static struct vvp_code_s *first_chunk = 0;
|
||||
static struct vvp_code_s *current_chunk = 0;
|
||||
static unsigned current_within_chunk = 0;
|
||||
|
||||
/*
|
||||
* This initializes the code space. It sets up a code table and places
|
||||
* at address 0 a ZOMBIE instruction.
|
||||
* This initializes the code space. It sets up the first code chunk,
|
||||
* and places at address 0 a ZOMBIE instruction.
|
||||
*/
|
||||
void codespace_init(void)
|
||||
{
|
||||
code_table[0] = new struct code_index1;
|
||||
memset(code_table[0], 0, sizeof (struct code_index1));
|
||||
code_table[0]->table[0] = new struct code_index0;
|
||||
memset(code_table[0]->table[0], 0, sizeof(struct code_index0));
|
||||
assert(current_chunk == 0);
|
||||
first_chunk = new struct vvp_code_s [code_chunk_size];
|
||||
current_chunk = first_chunk;
|
||||
|
||||
vvp_code_t cp = code_table[0]->table[0]->table + 0;
|
||||
cp->opcode = &of_ZOMBIE;
|
||||
current_chunk[0].opcode = &of_ZOMBIE;
|
||||
|
||||
code_count = 1;
|
||||
size_opcodes += sizeof(struct code_index1);
|
||||
size_opcodes += sizeof(struct code_index0);
|
||||
current_chunk[code_chunk_size-1].opcode = &of_CHUNK_LINK;
|
||||
current_chunk[code_chunk_size-1].cptr = 0;
|
||||
|
||||
current_within_chunk = 1;
|
||||
|
||||
count_opcodes = 0;
|
||||
size_opcodes += code_chunk_size * sizeof (struct vvp_code_s);
|
||||
}
|
||||
|
||||
vvp_cpoint_t codespace_allocate(void)
|
||||
vvp_code_t codespace_next(void)
|
||||
{
|
||||
vvp_cpoint_t idx = code_count;
|
||||
if (current_within_chunk == (code_chunk_size-1)) {
|
||||
current_chunk[code_chunk_size-1].cptr
|
||||
= new struct vvp_code_s [code_chunk_size];
|
||||
current_chunk = current_chunk[code_chunk_size-1].cptr;
|
||||
|
||||
idx /= code_index0_size;
|
||||
/* Put a link opcode on the end of the chunk. */
|
||||
current_chunk[code_chunk_size-1].opcode = &of_CHUNK_LINK;
|
||||
current_chunk[code_chunk_size-1].cptr = 0;
|
||||
|
||||
unsigned index1 = idx % code_index1_size;
|
||||
idx /= code_index1_size;
|
||||
current_within_chunk = 0;
|
||||
|
||||
assert(idx < code_index2_size);
|
||||
|
||||
if (code_table[idx] == 0) {
|
||||
code_table[idx] = new struct code_index1;
|
||||
memset(code_table[idx], 0, sizeof(struct code_index1));
|
||||
size_opcodes += sizeof(struct code_index1);
|
||||
size_opcodes += code_chunk_size * sizeof (struct vvp_code_s);
|
||||
}
|
||||
|
||||
if (code_table[idx]->table[index1] == 0) {
|
||||
code_table[idx]->table[index1] = new struct code_index0;
|
||||
memset(code_table[idx]->table[index1],
|
||||
0, sizeof(struct code_index0));
|
||||
size_opcodes += sizeof(struct code_index0);
|
||||
}
|
||||
|
||||
vvp_cpoint_t res = code_count;
|
||||
code_count += 1;
|
||||
count_opcodes += 1;
|
||||
vvp_code_t res = current_chunk + current_within_chunk;
|
||||
return res;
|
||||
}
|
||||
|
||||
vvp_cpoint_t codespace_next(void)
|
||||
vvp_code_t codespace_allocate(void)
|
||||
{
|
||||
return code_count;
|
||||
vvp_code_t res = codespace_next();
|
||||
current_within_chunk += 1;
|
||||
count_opcodes += 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
unsigned code_limit(void)
|
||||
vvp_code_t codespace_null(void)
|
||||
{
|
||||
return code_count;
|
||||
return first_chunk + 0;
|
||||
}
|
||||
|
||||
vvp_code_t codespace_index(vvp_cpoint_t point)
|
||||
{
|
||||
assert(point < code_count);
|
||||
|
||||
unsigned index0 = point % code_index0_size;
|
||||
point /= code_index0_size;
|
||||
|
||||
unsigned index1 = point % code_index1_size;
|
||||
point /= code_index1_size;
|
||||
|
||||
return code_table[point]->table[index1]->table + index0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log: codes.cc,v $
|
||||
* Revision 1.13 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.12 2002/08/12 01:35:07 steve
|
||||
* conditional ident string using autoconfig.
|
||||
*
|
||||
|
|
@ -124,34 +106,5 @@ vvp_code_t codespace_index(vvp_cpoint_t point)
|
|||
*
|
||||
* Revision 1.10 2002/07/05 02:50:58 steve
|
||||
* Remove the vpi object symbol table after compile.
|
||||
*
|
||||
* Revision 1.9 2002/03/01 05:43:59 steve
|
||||
* Initialize all the codes tables.
|
||||
*
|
||||
* Revision 1.8 2001/05/09 04:23:18 steve
|
||||
* Now that the interactive debugger exists,
|
||||
* there is no use for the output dump.
|
||||
*
|
||||
* Revision 1.7 2001/04/13 03:55:18 steve
|
||||
* More complete reap of all threads.
|
||||
*
|
||||
* Revision 1.6 2001/04/01 06:40:44 steve
|
||||
* Support empty statements for hanging labels.
|
||||
*
|
||||
* Revision 1.5 2001/03/22 05:28:41 steve
|
||||
* Add code label forward references.
|
||||
*
|
||||
* Revision 1.4 2001/03/22 05:08:00 steve
|
||||
* implement %load, %inv, %jum/0 and %cmp/u
|
||||
*
|
||||
* Revision 1.3 2001/03/20 06:16:23 steve
|
||||
* Add support for variable vectors.
|
||||
*
|
||||
* Revision 1.2 2001/03/11 23:06:49 steve
|
||||
* Compact the vvp_code_s structure.
|
||||
*
|
||||
* Revision 1.1 2001/03/11 00:29:38 steve
|
||||
* Add the vvp engine to cvs.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
33
vvp/codes.h
33
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.63 2003/06/18 03:55:19 steve Exp $"
|
||||
#ident "$Id: codes.h,v 1.64 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -27,7 +27,6 @@
|
|||
# include "memory.h"
|
||||
# include "vthread.h"
|
||||
|
||||
typedef struct vvp_code_s *vvp_code_t;
|
||||
typedef bool (*vvp_code_fun)(vthread_t thr, vvp_code_t code);
|
||||
|
||||
/*
|
||||
|
|
@ -122,6 +121,8 @@ extern bool of_ZOMBIE(vthread_t thr, vvp_code_t code);
|
|||
extern bool of_FORK_UFUNC(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t code);
|
||||
|
||||
extern bool of_CHUNK_LINK(vthread_t thr, vvp_code_t code);
|
||||
|
||||
/*
|
||||
* This is the format of a machine code instruction.
|
||||
*/
|
||||
|
|
@ -131,7 +132,7 @@ struct vvp_code_s {
|
|||
union {
|
||||
unsigned long number;
|
||||
vvp_ipoint_t iptr;
|
||||
vvp_cpoint_t cptr;
|
||||
vvp_code_t cptr;
|
||||
vvp_memory_t mem;
|
||||
struct __vpiHandle*handle;
|
||||
struct __vpiScope*scope;
|
||||
|
|
@ -141,7 +142,7 @@ struct vvp_code_s {
|
|||
union {
|
||||
unsigned bit_idx[2];
|
||||
vvp_ipoint_t iptr2;
|
||||
vvp_cpoint_t cptr2;
|
||||
vvp_code_t cptr2;
|
||||
struct ufunc_core*ufunc_core_ptr;
|
||||
};
|
||||
};
|
||||
|
|
@ -155,25 +156,21 @@ extern void codespace_init(void);
|
|||
|
||||
/*
|
||||
* This function returns a pointer to the next free instruction in the
|
||||
* code address space.
|
||||
* code address space. The codespace_next returns a pointer to the
|
||||
* next opcode that will be allocated. This is used by label
|
||||
* statements to get the address that will be attached to a label in
|
||||
* the code.
|
||||
*/
|
||||
extern vvp_cpoint_t codespace_allocate(void);
|
||||
|
||||
extern vvp_cpoint_t codespace_next(void);
|
||||
|
||||
|
||||
/*
|
||||
* Return a pointer to the indexed instruction in the codespace. The
|
||||
* ptr must be a value returned from codespace_allocate. The compiler
|
||||
* can use this to get a handle on the instruction to be created, and
|
||||
* the runtime uses this to get the instruction addressed by the PC or
|
||||
* by a branch instruction.
|
||||
*/
|
||||
extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
|
||||
extern vvp_code_t codespace_allocate(void);
|
||||
extern vvp_code_t codespace_next(void);
|
||||
extern vvp_code_t codespace_null(void);
|
||||
|
||||
|
||||
/*
|
||||
* $Log: codes.h,v $
|
||||
* Revision 1.64 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.63 2003/06/18 03:55:19 steve
|
||||
* Add arithmetic shift operators.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.166 2003/06/18 03:55:19 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.167 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -495,9 +495,9 @@ bool code_label_resolv_list_s::resolve(bool mes)
|
|||
symbol_value_t val = sym_get_value(sym_codespace, label);
|
||||
if (val.num) {
|
||||
if (code->opcode == of_FORK)
|
||||
code->cptr2 = val.num;
|
||||
code->cptr2 = reinterpret_cast<vvp_code_t>(val.ptr);
|
||||
else
|
||||
code->cptr = val.num;
|
||||
code->cptr = reinterpret_cast<vvp_code_t>(val.ptr);
|
||||
free(label);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1218,8 +1218,6 @@ void compile_code(char*label, char*mnem, comp_operands_t opa)
|
|||
if (label)
|
||||
compile_codelabel(label);
|
||||
|
||||
vvp_cpoint_t ptr = codespace_allocate();
|
||||
|
||||
/* Lookup the opcode in the opcode table. */
|
||||
struct opcode_table_s*op = (struct opcode_table_s*)
|
||||
bsearch(mnem, opcode_table, opcode_count,
|
||||
|
|
@ -1233,7 +1231,7 @@ void compile_code(char*label, char*mnem, comp_operands_t opa)
|
|||
|
||||
/* Build up the code from the information about the opcode and
|
||||
the information from the compiler. */
|
||||
vvp_code_t code = codespace_index(ptr);
|
||||
vvp_code_t code = codespace_allocate();
|
||||
code->opcode = op->opcode;
|
||||
|
||||
if (op->argc != (opa? opa->argc : 0)) {
|
||||
|
|
@ -1362,9 +1360,9 @@ void compile_code(char*label, char*mnem, comp_operands_t opa)
|
|||
void compile_codelabel(char*label)
|
||||
{
|
||||
symbol_value_t val;
|
||||
vvp_cpoint_t ptr = codespace_next();
|
||||
vvp_code_t ptr = codespace_next();
|
||||
|
||||
val.num = ptr;
|
||||
val.ptr = ptr;
|
||||
sym_set_value(sym_codespace, label, val);
|
||||
|
||||
free(label);
|
||||
|
|
@ -1376,10 +1374,8 @@ void compile_disable(char*label, struct symb_s symb)
|
|||
if (label)
|
||||
compile_codelabel(label);
|
||||
|
||||
vvp_cpoint_t ptr = codespace_allocate();
|
||||
|
||||
/* Fill in the basics of the %disable in the instruction. */
|
||||
vvp_code_t code = codespace_index(ptr);
|
||||
vvp_code_t code = codespace_allocate();
|
||||
code->opcode = of_DISABLE;
|
||||
|
||||
compile_vpi_lookup(&code->handle, symb.text);
|
||||
|
|
@ -1396,10 +1392,9 @@ void compile_fork(char*label, struct symb_s dest, struct symb_s scope)
|
|||
if (label)
|
||||
compile_codelabel(label);
|
||||
|
||||
vvp_cpoint_t ptr = codespace_allocate();
|
||||
|
||||
/* Fill in the basics of the %fork in the instruction. */
|
||||
vvp_code_t code = codespace_index(ptr);
|
||||
vvp_code_t code = codespace_allocate();
|
||||
code->opcode = of_FORK;
|
||||
|
||||
/* Figure out the target PC. */
|
||||
|
|
@ -1414,10 +1409,8 @@ void compile_vpi_call(char*label, char*name, unsigned argc, vpiHandle*argv)
|
|||
if (label)
|
||||
compile_codelabel(label);
|
||||
|
||||
vvp_cpoint_t ptr = codespace_allocate();
|
||||
|
||||
/* Create an instruction in the code space. */
|
||||
vvp_code_t code = codespace_index(ptr);
|
||||
vvp_code_t code = codespace_allocate();
|
||||
code->opcode = &of_VPI_CALL;
|
||||
|
||||
/* Create a vpiHandle that bundles the call information, and
|
||||
|
|
@ -1437,10 +1430,8 @@ void compile_vpi_func_call(char*label, char*name,
|
|||
if (label)
|
||||
compile_codelabel(label);
|
||||
|
||||
vvp_cpoint_t ptr = codespace_allocate();
|
||||
|
||||
/* Create an instruction in the code space. */
|
||||
vvp_code_t code = codespace_index(ptr);
|
||||
vvp_code_t code = codespace_allocate();
|
||||
code->opcode = &of_VPI_CALL;
|
||||
|
||||
/* Create a vpiHandle that bundles the call information, and
|
||||
|
|
@ -1461,7 +1452,7 @@ void compile_vpi_func_call(char*label, char*name,
|
|||
void compile_thread(char*start_sym)
|
||||
{
|
||||
symbol_value_t tmp = sym_get_value(sym_codespace, start_sym);
|
||||
vvp_cpoint_t pc = tmp.num;
|
||||
vvp_code_t pc = reinterpret_cast<vvp_code_t>(tmp.ptr);
|
||||
if (pc == 0) {
|
||||
yyerror("unresolved address");
|
||||
return;
|
||||
|
|
@ -1541,6 +1532,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.167 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.166 2003/06/18 03:55:19 steve
|
||||
* Add arithmetic shift operators.
|
||||
*
|
||||
|
|
@ -1561,40 +1555,5 @@ void compile_param_string(char*label, char*name, char*str, char*value)
|
|||
*
|
||||
* Revision 1.160 2003/04/23 03:09:25 steve
|
||||
* VPI Access to named events.
|
||||
*
|
||||
* Revision 1.159 2003/04/11 05:15:38 steve
|
||||
* Add signed versions of .cmp/gt/ge
|
||||
*
|
||||
* Revision 1.158 2003/03/28 02:33:56 steve
|
||||
* Add support for division of real operands.
|
||||
*
|
||||
* Revision 1.157 2003/03/13 04:36:57 steve
|
||||
* Remove the obsolete functor delete functions.
|
||||
*
|
||||
* Revision 1.156 2003/03/10 23:37:07 steve
|
||||
* Direct support for string parameters.
|
||||
*
|
||||
* Revision 1.155 2003/02/27 20:36:29 steve
|
||||
* Add the cvt/vr instruction.
|
||||
*
|
||||
* Revision 1.154 2003/02/09 23:33:26 steve
|
||||
* Spelling fixes.
|
||||
*
|
||||
* Revision 1.153 2003/02/06 17:41:47 steve
|
||||
* Add the %sub/wr instruction.
|
||||
*
|
||||
* Revision 1.152 2003/02/03 01:09:20 steve
|
||||
* Allow $display of $simtime.
|
||||
*
|
||||
* Revision 1.151 2003/02/01 05:50:04 steve
|
||||
* Make $time and $realtime available to $display uniquely.
|
||||
*
|
||||
* Revision 1.150 2003/01/27 00:14:37 steve
|
||||
* Support in various contexts the $realtime
|
||||
* system task.
|
||||
*
|
||||
* Revision 1.149 2003/01/26 18:16:22 steve
|
||||
* Add %cvt/ir and %cvt/ri instructions, and support
|
||||
* real values passed as arguments to VPI tasks.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: pointers.h,v 1.9 2002/08/12 01:35:08 steve Exp $"
|
||||
#ident "$Id: pointers.h,v 1.10 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -88,8 +88,6 @@ inline unsigned ipoint_port(vvp_ipoint_t func)
|
|||
return func & 3;
|
||||
}
|
||||
|
||||
typedef unsigned vvp_cpoint_t;
|
||||
|
||||
/*
|
||||
* The functor event mode uses a pointer of this type to point to the
|
||||
* extended event data.
|
||||
|
|
@ -111,6 +109,9 @@ typedef struct vvp_delay_s *vvp_delay_t;
|
|||
|
||||
/*
|
||||
* $Log: pointers.h,v $
|
||||
* Revision 1.10 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.9 2002/08/12 01:35:08 steve
|
||||
* conditional ident string using autoconfig.
|
||||
*
|
||||
|
|
|
|||
26
vvp/ufunc.cc
26
vvp/ufunc.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2002-2003 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
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: ufunc.cc,v 1.3 2003/05/07 03:39:12 steve Exp $"
|
||||
#ident "$Id: ufunc.cc,v 1.4 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
ufunc_core::ufunc_core(unsigned ow, vvp_ipoint_t ob, vvp_ipoint_t*op,
|
||||
unsigned np, vvp_ipoint_t*p,
|
||||
vvp_cpoint_t start_address,
|
||||
vvp_code_t start_address,
|
||||
struct __vpiScope*run_scope)
|
||||
: owid_(ow), obase_(ob), oports_(op), nports_(np), ports_(p)
|
||||
{
|
||||
|
|
@ -186,24 +186,19 @@ void compile_ufunc(char*label, char*code, unsigned wid,
|
|||
$join_ufunc then copies the output values to the
|
||||
destination net functors. */
|
||||
|
||||
vvp_cpoint_t start_address = codespace_allocate();
|
||||
vvp_code_t start_code = codespace_index(start_address);
|
||||
vvp_code_t start_code = codespace_allocate();
|
||||
start_code->opcode = of_FORK_UFUNC;
|
||||
code_label_lookup(start_code, code);
|
||||
|
||||
{ vvp_cpoint_t cur = codespace_allocate();
|
||||
vvp_code_t codep = codespace_index(cur);
|
||||
{ vvp_code_t codep = codespace_allocate();
|
||||
codep->opcode = &of_JOIN;
|
||||
}
|
||||
|
||||
vvp_code_t ujoin_code;
|
||||
{ vvp_cpoint_t cur = codespace_allocate();
|
||||
ujoin_code = codespace_index(cur);
|
||||
ujoin_code->opcode = &of_JOIN_UFUNC;
|
||||
}
|
||||
ujoin_code = codespace_allocate();
|
||||
ujoin_code->opcode = &of_JOIN_UFUNC;
|
||||
|
||||
{ vvp_cpoint_t cur = codespace_allocate();
|
||||
vvp_code_t codep = codespace_index(cur);
|
||||
{ vvp_code_t codep = codespace_allocate();
|
||||
codep->opcode = &of_END;
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +208,7 @@ void compile_ufunc(char*label, char*code, unsigned wid,
|
|||
point to this core to deliver input. */
|
||||
ufunc_core*core = new ufunc_core(wid, obase, rets,
|
||||
portc, ports,
|
||||
start_address,
|
||||
start_code,
|
||||
vpip_peek_current_scope());
|
||||
start_code->ufunc_core_ptr = core;
|
||||
ujoin_code->ufunc_core_ptr = core;
|
||||
|
|
@ -241,6 +236,9 @@ void compile_ufunc(char*label, char*code, unsigned wid,
|
|||
|
||||
/*
|
||||
* $Log: ufunc.cc,v $
|
||||
* Revision 1.4 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.3 2003/05/07 03:39:12 steve
|
||||
* ufunc calls to functions can have scheduling complexities.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: ufunc.h,v 1.2 2002/08/12 01:35:08 steve Exp $"
|
||||
#ident "$Id: ufunc.h,v 1.3 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "pointers.h"
|
||||
|
|
@ -45,7 +45,7 @@ class ufunc_core {
|
|||
public:
|
||||
ufunc_core(unsigned ow, vvp_ipoint_t ob, vvp_ipoint_t*op,
|
||||
unsigned np, vvp_ipoint_t*p,
|
||||
vvp_cpoint_t start_address,
|
||||
vvp_code_t start_address,
|
||||
struct __vpiScope*run_scope);
|
||||
~ufunc_core();
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ class ufunc_core {
|
|||
// function.
|
||||
vthread_t thread_;
|
||||
struct __vpiScope*scope_;
|
||||
vvp_cpoint_t code_;
|
||||
vvp_code_t code_;
|
||||
|
||||
// Save the input bits as I receive them.
|
||||
unsigned char*ibits_;
|
||||
|
|
@ -78,6 +78,9 @@ class ufunc_core {
|
|||
|
||||
/*
|
||||
* $Log: ufunc.h,v $
|
||||
* Revision 1.3 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.2 2002/08/12 01:35:08 steve
|
||||
* conditional ident string using autoconfig.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.111 2003/06/18 03:55:19 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.112 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -93,7 +93,7 @@
|
|||
|
||||
struct vthread_s {
|
||||
/* This is the program counter. */
|
||||
unsigned long pc;
|
||||
vvp_code_t pc;
|
||||
/* These hold the private thread bits. */
|
||||
unsigned long *bits;
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ static unsigned long* vector_to_array(struct vthread_s*thr,
|
|||
/*
|
||||
* Create a new thread with the given start address.
|
||||
*/
|
||||
vthread_t vthread_new(unsigned long pc, struct __vpiScope*scope)
|
||||
vthread_t vthread_new(vvp_code_t pc, struct __vpiScope*scope)
|
||||
{
|
||||
vthread_t thr = new struct vthread_s;
|
||||
thr->pc = pc;
|
||||
|
|
@ -236,7 +236,7 @@ vthread_t vthread_new(unsigned long pc, struct __vpiScope*scope)
|
|||
easier to work with. */
|
||||
if (scope->threads == 0) {
|
||||
scope->threads = new struct vthread_s;
|
||||
scope->threads->pc = 0;
|
||||
scope->threads->pc = codespace_null();
|
||||
scope->threads->bits = 0;
|
||||
scope->threads->nbits = 0;
|
||||
scope->threads->child = 0;
|
||||
|
|
@ -291,7 +291,7 @@ static void vthread_reap(vthread_t thr)
|
|||
thr->scope_next->scope_prev = thr->scope_prev;
|
||||
thr->scope_prev->scope_next = thr->scope_next;
|
||||
|
||||
thr->pc = 0;
|
||||
thr->pc = codespace_null();
|
||||
|
||||
/* If this thread is not scheduled, then is it safe to delete
|
||||
it now. Otherwise, let the schedule event (which will
|
||||
|
|
@ -327,7 +327,7 @@ void vthread_run(vthread_t thr)
|
|||
thr->is_scheduled = 0;
|
||||
|
||||
for (;;) {
|
||||
vvp_code_t cp = codespace_index(thr->pc);
|
||||
vvp_code_t cp = thr->pc;
|
||||
thr->pc += 1;
|
||||
|
||||
assert(cp);
|
||||
|
|
@ -345,6 +345,17 @@ void vthread_run(vthread_t thr)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The CHUNK_LINK instruction is a specla next pointer for linking
|
||||
* chunks of code space. It's like a simplified %jmp.
|
||||
*/
|
||||
bool of_CHUNK_LINK(vthread_t thr, vvp_code_t code)
|
||||
{
|
||||
assert(code->cptr);
|
||||
thr->pc = code->cptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is called by an event functor to wake up all the threads on
|
||||
* its list. I in fact created that list in the %wait instruction, and
|
||||
|
|
@ -868,7 +879,7 @@ static bool do_disable(vthread_t thr, vthread_t match)
|
|||
|
||||
/* Turn the thread off by setting is program counter to
|
||||
zero and setting an OFF bit. */
|
||||
thr->pc = 0;
|
||||
thr->pc = codespace_null();
|
||||
thr->i_have_ended = 1;
|
||||
|
||||
/* Turn off all the children of the thread. Simulate a %join
|
||||
|
|
@ -1288,7 +1299,7 @@ bool of_END(vthread_t thr, vvp_code_t)
|
|||
assert(! thr->waiting_for_event);
|
||||
assert( thr->fork_count == 0 );
|
||||
thr->i_have_ended = 1;
|
||||
thr->pc = 0;
|
||||
thr->pc = codespace_null();
|
||||
|
||||
/* If I have a parent who is waiting for me, then mark that I
|
||||
have ended, and schedule that parent. Also, finish the
|
||||
|
|
@ -2691,7 +2702,7 @@ bool of_XOR(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
bool of_ZOMBIE(vthread_t thr, vvp_code_t)
|
||||
{
|
||||
thr->pc = 0;
|
||||
thr->pc = codespace_null();
|
||||
if ((thr->parent == 0) && (thr->child == 0))
|
||||
delete thr;
|
||||
|
||||
|
|
@ -2745,6 +2756,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.112 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.111 2003/06/18 03:55:19 steve
|
||||
* Add arithmetic shift operators.
|
||||
*
|
||||
|
|
@ -2780,44 +2794,5 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
|
|||
*
|
||||
* Revision 1.100 2003/02/06 17:41:47 steve
|
||||
* Add the %sub/wr instruction.
|
||||
*
|
||||
* Revision 1.99 2003/01/27 00:14:37 steve
|
||||
* Support in various contexts the $realtime
|
||||
* system task.
|
||||
*
|
||||
* Revision 1.98 2003/01/26 18:16:22 steve
|
||||
* Add %cvt/ir and %cvt/ri instructions, and support
|
||||
* real values passed as arguments to VPI tasks.
|
||||
*
|
||||
* Revision 1.97 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.96 2003/01/06 23:57:26 steve
|
||||
* Schedule wait lists of threads as a single event,
|
||||
* to save on events. Also, improve efficiency of
|
||||
* event_s allocation. Add some event statistics to
|
||||
* get an idea where performance is really going.
|
||||
*
|
||||
* Revision 1.95 2002/11/22 00:01:50 steve
|
||||
* Careful of left operands to shift that are constant.
|
||||
*
|
||||
* Revision 1.94 2002/11/21 22:43:14 steve
|
||||
* %set/x0 instruction to support bounds checking.
|
||||
*
|
||||
* Revision 1.93 2002/11/08 04:59:58 steve
|
||||
* Add the %assign/v0 instruction.
|
||||
*
|
||||
* Revision 1.92 2002/11/07 03:11:43 steve
|
||||
* functor_set takes bit and strength, not 2 strengths.
|
||||
*
|
||||
* Revision 1.91 2002/11/07 02:32:39 steve
|
||||
* Add vector set and load instructions.
|
||||
*
|
||||
* Revision 1.90 2002/11/05 03:46:44 steve
|
||||
* Fix mask calculate when MOV_b is right on the word boundary.
|
||||
*
|
||||
* Revision 1.89 2002/09/21 23:47:30 steve
|
||||
* Remove some now useless asserts.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __vthread_H
|
||||
#define __vthread_H
|
||||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2003 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
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vthread.h,v 1.10 2003/01/27 00:14:37 steve Exp $"
|
||||
#ident "$Id: vthread.h,v 1.11 2003/07/03 20:03:36 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -33,14 +33,15 @@
|
|||
* fetching the next instruction.
|
||||
*/
|
||||
|
||||
typedef struct vthread_s*vthread_t;
|
||||
typedef struct vthread_s* vthread_t;
|
||||
typedef struct vvp_code_s*vvp_code_t;
|
||||
|
||||
/*
|
||||
* This creates a new simulation thread, with the given start
|
||||
* address. The generated thread is ready to run, but is not yet
|
||||
* scheduled.
|
||||
*/
|
||||
extern vthread_t vthread_new(unsigned long sa, struct __vpiScope*scope);
|
||||
extern vthread_t vthread_new(vvp_code_t sa, struct __vpiScope*scope);
|
||||
|
||||
/*
|
||||
* This function marks the thread as scheduled. It is used only by the
|
||||
|
|
@ -76,6 +77,9 @@ extern void vthread_put_real(struct vthread_s*thr, unsigned addr, double val);
|
|||
|
||||
/*
|
||||
* $Log: vthread.h,v $
|
||||
* Revision 1.11 2003/07/03 20:03:36 steve
|
||||
* Remove the vvp_cpoint_t indirect code pointer.
|
||||
*
|
||||
* Revision 1.10 2003/01/27 00:14:37 steve
|
||||
* Support in various contexts the $realtime
|
||||
* system task.
|
||||
|
|
|
|||
Loading…
Reference in New Issue