Add the .part/pv node and related functionality.

This commit is contained in:
steve 2005-01-09 20:11:15 +00:00
parent d5c33420ab
commit 9735b0e8b3
9 changed files with 162 additions and 17 deletions

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: README.txt,v 1.51 2004/12/31 06:00:06 steve Exp $
* $Id: README.txt,v 1.52 2005/01/09 20:11:15 steve Exp $
*/
VVP SIMULATION ENGINE
@ -449,10 +449,19 @@ vector. The other inputs specify what those parts are, as a cannonical
bit number, and a width. Normally, those bits are constant values.
<label> .part <symbol>, <base>, <wid>;
<label> .part/pv <symbol>, <base>, <wid>, <vector_wid>;
The input is typically a .reg or .net, but can be any vector node in
the netlist.
The .part/pv variation is the inverse of the .part version, in that
the output is actually written to a *part* of the output. The node
uses special part-select-write functions to propagate a part of a
network. The <vector_wid> is the total width of the destination net
that part is written to. Destination nodes use this value to check
further output widths.
PART CONCATENATION STATEMENTS:
The opposite of the part select statement is the part concatenation

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: compile.h,v 1.58 2004/12/29 23:45:13 steve Exp $"
#ident "$Id: compile.h,v 1.59 2005/01/09 20:11:15 steve Exp $"
#endif
# include <stdio.h>
@ -100,6 +100,9 @@ extern void compile_concat(char*label, unsigned w0, unsigned w1,
*/
extern void compile_part_select(char*label, char*src,
unsigned base, unsigned wid);
extern void compile_part_select_pv(char*label, char*src,
unsigned base, unsigned wid,
unsigned vec_wid);
/*
* This is called by the parser to make force functors.
@ -282,6 +285,9 @@ extern void compile_net(char*label, char*name,
/*
* $Log: compile.h,v $
* Revision 1.59 2005/01/09 20:11:15 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.58 2004/12/29 23:45:13 steve
* Add the part concatenation node (.concat).
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: lexor.lex,v 1.45 2004/12/29 23:45:13 steve Exp $"
#ident "$Id: lexor.lex,v 1.46 2005/01/09 20:11:15 steve Exp $"
#endif
# include "parse_misc.h"
@ -103,6 +103,7 @@
".net/s" { return K_NET_S; }
".param" { return K_PARAM; }
".part" { return K_PART; }
".part/pv" { return K_PART_PV; }
".resolv" { return K_RESOLV; }
".scope" { return K_SCOPE; }
".shift/l" { return K_SHIFTL; }
@ -184,6 +185,9 @@ int yywrap()
/*
* $Log: lexor.lex,v $
* Revision 1.46 2005/01/09 20:11:15 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.45 2004/12/29 23:45:13 steve
* Add the part concatenation node (.concat).
*

View File

@ -1,7 +1,7 @@
%{
/*
* Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2005 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: parse.y,v 1.62 2004/12/29 23:45:13 steve Exp $"
#ident "$Id: parse.y,v 1.63 2005/01/09 20:11:15 steve Exp $"
#endif
# include "parse_misc.h"
@ -61,7 +61,7 @@ extern FILE*yyin;
%token K_ARITH_SUB K_ARITH_SUM
%token K_CMP_EQ K_CMP_NE K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
%token K_CONCAT
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S K_PARAM K_PART
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S K_PARAM K_PART K_PART_PV
%token K_RESOLV K_SCOPE K_SHIFTL K_SHIFTR K_THREAD K_TIMESCALE K_UFUNC
%token K_UDP K_UDP_C K_UDP_S
%token K_MEM K_MEM_P K_MEM_I
@ -188,6 +188,9 @@ statement
| T_LABEL K_PART T_SYMBOL ',' T_NUMBER ',' T_NUMBER ';'
{ compile_part_select($1, $3, $5, $7); }
| T_LABEL K_PART_PV T_SYMBOL ',' T_NUMBER ',' T_NUMBER ',' T_NUMBER ';'
{ compile_part_select_pv($1, $3, $5, $7, $9); }
| T_LABEL K_CONCAT '[' T_NUMBER T_NUMBER T_NUMBER T_NUMBER ']' ','
symbols ';'
{ compile_concat($1, $4, $5, $6, $7, $10.cnt, $10.vect); }
@ -642,6 +645,9 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.63 2005/01/09 20:11:15 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.62 2004/12/29 23:45:13 steve
* Add the part concatenation node (.concat).
*

View File

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ident "$Id: part.cc,v 1.2 2004/12/29 23:44:39 steve Exp $"
#ident "$Id: part.cc,v 1.3 2005/01/09 20:11:16 steve Exp $"
# include "compile.h"
# include "vvp_net.h"
@ -51,11 +51,28 @@ void vvp_fun_part::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
vvp_send_vec4(port.ptr()->out, res);
}
void compile_part_select(char*label, char*source,
unsigned base, unsigned wid)
vvp_fun_part_pv::vvp_fun_part_pv(unsigned b, unsigned w, unsigned v)
: base_(b), wid_(w), vwid_(v)
{
vvp_fun_part*fun = new vvp_fun_part(base, wid);
}
vvp_fun_part_pv::~vvp_fun_part_pv()
{
}
void vvp_fun_part_pv::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
{
assert(port.port() == 0);
assert(bit.size() == wid_);
vvp_send_vec4_pv(port.ptr()->out, bit, base_, wid_, vwid_);
}
/*
* Given a node functor, create a network node and link it into the
* netlist. This form assumes nodes with a single input.
*/
void link_node_1(char*label, char*source, vvp_net_fun_t*fun)
{
vvp_net_t*net = new vvp_net_t;
net->fun = fun;
@ -65,8 +82,26 @@ void compile_part_select(char*label, char*source,
input_connect(net, 0, source);
}
void compile_part_select(char*label, char*source,
unsigned base, unsigned wid)
{
vvp_fun_part*fun = new vvp_fun_part(base, wid);
link_node_1(label, source, fun);
}
void compile_part_select_pv(char*label, char*source,
unsigned base, unsigned wid,
unsigned vector_wid)
{
vvp_fun_part_pv*fun = new vvp_fun_part_pv(base, wid, vector_wid);
link_node_1(label, source, fun);
}
/*
* $Log: part.cc,v $
* Revision 1.3 2005/01/09 20:11:16 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.2 2004/12/29 23:44:39 steve
* Fix missing output propagation of part node.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: resolv.cc,v 1.19 2004/12/31 06:00:06 steve Exp $"
#ident "$Id: resolv.cc,v 1.20 2005/01/09 20:11:16 steve Exp $"
#endif
# include "resolv.h"
@ -41,6 +41,24 @@ void resolv_functor::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
recv_vec8(port, vvp_vector8_t(bit, 6 /* STRONG */));
}
void resolv_functor::recv_vec4_pv(vvp_net_ptr_t port, vvp_vector4_t bit,
unsigned base, unsigned wid, unsigned vwid)
{
assert(bit.size() == wid);
vvp_vector4_t res (vwid);
for (unsigned idx = 0 ; idx < base ; idx += 1)
res.set_bit(idx, BIT4_Z);
for (unsigned idx = 0 ; idx < wid ; idx += 1)
res.set_bit(idx+base, bit.value(idx));
for (unsigned idx = base+wid ; idx < vwid ; idx += 1)
res.set_bit(idx, BIT4_Z);
recv_vec4(port, res);
}
void resolv_functor::recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit)
{
unsigned pdx = port.port();
@ -65,6 +83,9 @@ void resolv_functor::recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit)
/*
* $Log: resolv.cc,v $
* Revision 1.20 2005/01/09 20:11:16 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.19 2004/12/31 06:00:06 steve
* Implement .resolv functors, and stub signals recv_vec8 method.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: resolv.h,v 1.11 2005/01/01 02:12:34 steve Exp $"
#ident "$Id: resolv.h,v 1.12 2005/01/09 20:11:16 steve Exp $"
#endif
# include "config.h"
@ -46,6 +46,9 @@ class resolv_functor : public vvp_net_fun_t {
void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
void recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit);
void recv_vec4_pv(vvp_net_ptr_t port, vvp_vector4_t bit,
unsigned base, unsigned wid, unsigned vwid);
private:
vvp_vector8_t val_[4];
vvp_scaler_t hiz_;
@ -53,6 +56,9 @@ class resolv_functor : public vvp_net_fun_t {
/*
* $Log: resolv.h,v $
* Revision 1.12 2005/01/09 20:11:16 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.11 2005/01/01 02:12:34 steve
* vvp_fun_signal propagates vvp_vector8_t vectors when appropriate.
*

View File

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ident "$Id: vvp_net.cc,v 1.4 2005/01/01 02:12:34 steve Exp $"
#ident "$Id: vvp_net.cc,v 1.5 2005/01/09 20:11:16 steve Exp $"
# include "vvp_net.h"
# include <stdio.h>
@ -62,6 +62,19 @@ void vvp_send_vec4(vvp_net_ptr_t ptr, vvp_vector4_t val)
}
}
void vvp_send_vec4_pv(vvp_net_ptr_t ptr, vvp_vector4_t val,
unsigned base, unsigned wid, unsigned vwid)
{
while (struct vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_vec4_pv(ptr, val, base, wid, vwid);
ptr = next;
}
}
void vvp_send_vec8(vvp_net_ptr_t ptr, vvp_vector8_t val)
{
while (struct vvp_net_t*cur = ptr.ptr()) {
@ -296,6 +309,14 @@ void vvp_net_fun_t::recv_vec4(vvp_net_ptr_t, vvp_vector4_t)
assert(0);
}
void vvp_net_fun_t::recv_vec4_pv(vvp_net_ptr_t, vvp_vector4_t,
unsigned, unsigned, unsigned)
{
fprintf(stderr, "internal error: %s: recv_vec4_pv not implemented\n",
typeid(*this).name());
assert(0);
}
void vvp_net_fun_t::recv_vec8(vvp_net_ptr_t, vvp_vector8_t)
{
fprintf(stderr, "internal error: %s: recv_vec8 not implemented\n",
@ -644,6 +665,9 @@ vvp_vector4_t reduce4(const vvp_vector8_t&that)
/*
* $Log: vvp_net.cc,v $
* Revision 1.5 2005/01/09 20:11:16 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.4 2005/01/01 02:12:34 steve
* vvp_fun_signal propagates vvp_vector8_t vectors when appropriate.
*

View File

@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ident "$Id: vvp_net.h,v 1.5 2005/01/01 02:12:34 steve Exp $"
#ident "$Id: vvp_net.h,v 1.6 2005/01/09 20:11:16 steve Exp $"
# include <assert.h>
@ -266,6 +266,12 @@ extern void vvp_send_vec8(vvp_net_ptr_t ptr, vvp_vector8_t val);
extern void vvp_send_real(vvp_net_ptr_t ptr, double val);
extern void vvp_send_long(vvp_net_ptr_t ptr, long val);
/*
* Part-vector versions of above functions.
*/
extern void vvp_send_vec4_pv(vvp_net_ptr_t ptr, vvp_vector4_t val,
unsigned base, unsigned wid, unsigned vwid);
/*
* Instances of this class represent the functionality of a
* node. vvp_net_t objects hold pointers to the vvp_net_fun_t
@ -292,6 +298,10 @@ class vvp_net_fun_t {
virtual void recv_real(vvp_net_ptr_t port, double bit);
virtual void recv_long(vvp_net_ptr_t port, long bit);
// Part select variants of above
virtual void recv_vec4_pv(vvp_net_ptr_t p, vvp_vector4_t bit,
unsigned base, unsigned wid, unsigned vwid);
private: // not implemented
vvp_net_fun_t(const vvp_net_fun_t&);
vvp_net_fun_t& operator= (const vvp_net_fun_t&);
@ -301,9 +311,9 @@ class vvp_net_fun_t {
/* vvp_fun_concat
* This node function creates vectors (vvp_vector4_t) from the
* concatenation of the inputs. The inputs (4) may be scalers or other
* vectors. Scalers are turned into vectors of size==1 before
* concatenating.
* concatenation of the inputs. The inputs (4) may be vector or
* vector8 objects, but they are reduced to vector4 values and
* strength information lost.
*
* The expected widths of the input vectors must be given up front so
* that the positions in the output vector (and also the size of the
@ -318,6 +328,7 @@ class vvp_fun_concat : public vvp_net_fun_t {
~vvp_fun_concat();
void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
void recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit);
private:
unsigned wid_[4];
@ -365,6 +376,26 @@ class vvp_fun_part : public vvp_net_fun_t {
unsigned wid_;
};
/* vvp_fun_part_pv
* This node takes a vector input and turns it into the part select of
* a wider output network. It used the recv_vec4_pv methods of the
* destination nodes to propagate the part select.
*/
class vvp_fun_part_pv : public vvp_net_fun_t {
public:
vvp_fun_part_pv(unsigned base, unsigned wid, unsigned vec_wid);
~vvp_fun_part_pv();
public:
void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
private:
unsigned base_;
unsigned wid_;
unsigned vwid_;
};
/* vvp_fun_signal
* This node is the place holder in a vvp network for signals,
* including nets of various sort. The output from a signal follows
@ -454,6 +485,9 @@ class vvp_fun_signal : public vvp_net_fun_t {
/*
* $Log: vvp_net.h,v $
* Revision 1.6 2005/01/09 20:11:16 steve
* Add the .part/pv node and related functionality.
*
* Revision 1.5 2005/01/01 02:12:34 steve
* vvp_fun_signal propagates vvp_vector8_t vectors when appropriate.
*