Non blocking assign to memory words.

This commit is contained in:
steve 2005-03-06 17:07:48 +00:00
parent 0fb1fd36ee
commit 8e135a1020
5 changed files with 96 additions and 20 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vvp_process.c,v 1.103 2005/03/05 05:47:42 steve Exp $"
#ident "$Id: vvp_process.c,v 1.104 2005/03/06 17:07:48 steve Exp $"
#endif
# include "vvp_priv.h"
@ -164,12 +164,13 @@ static void assign_to_lvector(ivl_lval_t lval, unsigned idx,
}
static void assign_to_memory(ivl_memory_t mem, unsigned idx,
unsigned bit, unsigned delay)
static void assign_to_memory_word(ivl_memory_t mem, unsigned bit,
unsigned delay, unsigned wid)
{
if (idx)
fprintf(vvp_out, " %%ix/add 3, 1;\n");
fprintf(vvp_out, " %%assign/m M_%s, %u, %u;\n",
assert(wid = ivl_memory_width(mem));
fprintf(vvp_out, " %%ix/load 0, %u;\n", wid);
fprintf(vvp_out, " %%assign/mv M_%s, %u, %u;\n",
vvp_memory_label(mem), delay, bit);
}
@ -472,14 +473,22 @@ static int show_stmt_assign_nb(ivl_statement_t net)
assign_to_lvector(lval, 0, bidx, delay, bit_limit);
cur_rbit += bit_limit;
} else if (mem) {
/* XXXX don't yes know what to do with a delay
in an index variable. */
assert(del == 0);
assign_to_memory_word(mem, res.base, delay, bit_limit);
} else {
assert(!mem);
/* XXXX This is obsolete, the
assign_to_lvariable should be removed for the
vector version. */
for (idx = 0 ; idx < bit_limit ; idx += 1) {
unsigned bidx = res.base < 4
? res.base
: (res.base+cur_rbit);
if (mem)
assign_to_memory(mem, idx, bidx, delay);
else if (del != 0)
if (del != 0)
assign_to_lvariable(lval, idx, bidx,
1, 1);
else
@ -488,16 +497,15 @@ static int show_stmt_assign_nb(ivl_statement_t net)
cur_rbit += 1;
}
}
for (idx = bit_limit; idx < ivl_lval_width(lval); idx += 1)
if (mem)
assign_to_memory(mem, idx, 0, delay);
else if (del != 0)
for (idx = bit_limit; idx < ivl_lval_width(lval); idx += 1)
if (del != 0)
assign_to_lvariable(lval, idx, 0, 1, 1);
else
assign_to_lvariable(lval, idx, 0, delay, 0);
}
if (skip_set_flag) {
fprintf(vvp_out, "t_%u ;\n", skip_set);
@ -1461,6 +1469,9 @@ int draw_func_definition(ivl_scope_t scope)
/*
* $Log: vvp_process.c,v $
* Revision 1.104 2005/03/06 17:07:48 steve
* Non blocking assign to memory words.
*
* Revision 1.103 2005/03/05 05:47:42 steve
* Handle memory words in l-value concatenations.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: memory.cc,v 1.24 2005/03/05 05:44:32 steve Exp $"
#ident "$Id: memory.cc,v 1.25 2005/03/06 17:07:48 steve Exp $"
#endif
#include "memory.h"
@ -175,7 +175,15 @@ long memory_right_range(vvp_memory_t mem, unsigned ix)
vvp_vector4_t memory_get_word(vvp_memory_t mem, unsigned addr)
{
// XXXX For now, assume this can't happen
/* If the address is out of range, then return a vector of all
X bits. */
if (addr >= mem->word_count) {
vvp_vector4_t val (mem->width);
for (unsigned idx = 0 ; idx < mem->width ; idx += 1)
val.set_bit(idx, BIT4_X);
return val;
}
assert(addr <= mem->word_count);
if (mem->words[addr].size() == 0) {
@ -526,6 +534,9 @@ static void run_mem_assign(vvp_gen_event_t obj, unsigned char val)
/*
* $Log: memory.cc,v $
* Revision 1.25 2005/03/06 17:07:48 steve
* Non blocking assign to memory words.
*
* Revision 1.24 2005/03/05 05:44:32 steve
* Get read width of unitialized memory words right.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: schedule.cc,v 1.31 2005/02/12 03:26:14 steve Exp $"
#ident "$Id: schedule.cc,v 1.32 2005/03/06 17:07:48 steve Exp $"
#endif
# include "schedule.h"
@ -108,6 +108,19 @@ void assign_vector8_event_s::run_run(void)
vvp_send_vec8(ptr, val);
}
struct assign_memory_word_s : public event_s {
vvp_memory_t mem;
unsigned adr;
vvp_vector4_t val;
void run_run(void);
};
void assign_memory_word_s::run_run(void)
{
count_assign_events += 1;
memory_set_word(mem, adr, val);
}
struct generic_event_s : public event_s {
vvp_gen_event_t obj;
unsigned char val;
@ -424,6 +437,18 @@ void schedule_assign_vector(vvp_net_ptr_t ptr,
schedule_event_(cur, delay, SEQ_NBASSIGN);
}
void schedule_assign_memory_word(vvp_memory_t mem,
unsigned word_addr,
vvp_vector4_t val,
vvp_time64_t delay)
{
struct assign_memory_word_s*cur = new struct assign_memory_word_s;
cur->mem = mem;
cur->adr = word_addr;
cur->val = val;
schedule_event_(cur, delay, SEQ_NBASSIGN);
}
void schedule_set_vector(vvp_net_ptr_t ptr, vvp_vector4_t bit)
{
struct assign_vector4_event_s*cur = new struct assign_vector4_event_s;
@ -578,6 +603,9 @@ void schedule_simulate(void)
/*
* $Log: schedule.cc,v $
* Revision 1.32 2005/03/06 17:07:48 steve
* Non blocking assign to memory words.
*
* Revision 1.31 2005/02/12 03:26:14 steve
* Support scheduling vvp_vector8_t objects.
*

View File

@ -19,12 +19,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: schedule.h,v 1.19 2005/02/12 03:26:14 steve Exp $"
#ident "$Id: schedule.h,v 1.20 2005/03/06 17:07:48 steve Exp $"
#endif
# include "vthread.h"
# include "pointers.h"
# include "vvp_net.h"
# include "memory.h"
/*
* This causes a thread to be scheduled for execution. The schedule
@ -48,6 +49,10 @@ extern void schedule_assign_vector(vvp_net_ptr_t ptr,
vvp_vector4_t val,
vvp_time64_t delay);
extern void schedule_assign_memory_word(vvp_memory_t mem,
unsigned word_address,
vvp_vector4_t val,
vvp_time64_t delay);
/*
* This is very similar to schedule_assign_vector, but generates an
* event in the active queue. It is used at link time to set an initial
@ -121,6 +126,9 @@ extern unsigned long count_event_pool;
/*
* $Log: schedule.h,v $
* Revision 1.20 2005/03/06 17:07:48 steve
* Non blocking assign to memory words.
*
* Revision 1.19 2005/02/12 03:26:14 steve
* Support scheduling vvp_vector8_t objects.
*

View File

@ -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.131 2005/03/05 05:45:18 steve Exp $"
#ident "$Id: vthread.cc,v 1.132 2005/03/06 17:07:48 steve Exp $"
#endif
# include "config.h"
@ -622,9 +622,24 @@ bool of_ASSIGN_MEM(vthread_t thr, vvp_code_t cp)
return true;
}
/* %assign/mv <memory>, <delay>, <bit>
* This generates an assignment event to a memory. Index register 0
* contains the width of the vector (and the word) and index register
* 3 contains the cannonical address of the word in memory.
*/
bool of_ASSIGN_MV(vthread_t thr, vvp_code_t cp)
{
fprintf(stderr, "XXXX %%assign/mv not implemented yet\n");
unsigned wid = thr->words[0].w_int;
unsigned adr = thr->words[3].w_int;
assert(wid > 0);
unsigned delay = cp->bit_idx[0];
unsigned bit = cp->bit_idx[1];
vvp_vector4_t value = vthread_bits_to_vector(thr, bit, wid);
schedule_assign_memory_word(cp->mem, adr, value, delay);
return true;
}
@ -3099,6 +3114,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.132 2005/03/06 17:07:48 steve
* Non blocking assign to memory words.
*
* Revision 1.131 2005/03/05 05:45:18 steve
* Check that lead.mv vector width matches word.
*