Make functors know their own width.

This commit is contained in:
steve 2005-06-17 03:46:52 +00:00
parent 290c604c62
commit 4cc421b3b7
8 changed files with 61 additions and 136 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: draw_mux.c,v 1.9 2005/04/06 05:29:09 steve Exp $" #ident "$Id: draw_mux.c,v 1.10 2005/06/17 03:46:52 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -28,116 +28,6 @@
# include <stdlib.h> # include <stdlib.h>
# include <string.h> # include <string.h>
#if 0
/*
* This draws a general mux, a slice at a time. Use MUXX so that
* unknows lead to unknown output.
*/
static void draw_lpm_mux_bitslice(ivl_lpm_t net, unsigned slice)
{
unsigned sel = ivl_lpm_selects(net);
unsigned size = ivl_lpm_size(net);
unsigned sel_from_size;
unsigned seldx, idx;
ivl_nexus_t s;
sel_from_size = 0;
seldx = size - 1;
while (seldx > 0) {
seldx >>= 1;
sel_from_size += 1;
}
if (sel_from_size > sel) {
fprintf(stderr, "internal error: MUX size=%u, selects=%u\n",
size, sel);
}
assert(sel_from_size <= sel);
s = ivl_lpm_select(net, 0);
/* Draw the leaf mux devices that take inputs from the
net. These also use up the least significant bit of the
select vector. */
for (idx = 0 ; idx < size ; idx += 2) {
fprintf(vvp_out, "L_%s.%s/%u/%u/%u .functor MUXX, ",
vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))),
vvp_mangle_id(ivl_lpm_basename(net)), slice, sel, idx);
{
ivl_nexus_t a = ivl_lpm_data2(net, idx+0, slice);
draw_input_from_net(a);
fprintf(vvp_out, ", ");
}
if ((idx+1) < size) {
ivl_nexus_t b = ivl_lpm_data2(net, idx+1, slice);
draw_input_from_net(b);
fprintf(vvp_out, ", ");
} else {
fprintf(vvp_out, "C<x>, ");
}
draw_input_from_net(s);
fprintf(vvp_out, ", C<1>;\n");
}
/* Draw the tree of MUXX devices to connect the inner tree
nodes. */
for (seldx = 1 ; seldx < (sel-1) ; seldx += 1) {
unsigned level = sel - seldx;
unsigned span = 2 << seldx;
s = ivl_lpm_select(net, seldx);
for (idx = 0 ; idx < size ; idx += span) {
fprintf(vvp_out, "L_%s.%s/%u/%u/%u .functor MUXX, ",
vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))),
vvp_mangle_id(ivl_lpm_basename(net)),
slice, level, idx);
fprintf(vvp_out, "L_%s.%s/%u/%u/%u, ",
vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))),
vvp_mangle_id(ivl_lpm_basename(net)),
slice, level+1, idx);
if ((idx + span/2) < size) {
fprintf(vvp_out, "L_%s.%s/%u/%u/%u, ",
vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))),
vvp_mangle_id(ivl_lpm_basename(net)),
slice, level+1, idx+span/2);
} else {
fprintf(vvp_out, "C<x>, ");
}
draw_input_from_net(s);
fprintf(vvp_out, ", C<1>;\n");
}
}
s = ivl_lpm_select(net, sel-1);
fprintf(vvp_out, "L_%s.%s/%u .functor MUXX, ",
vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))),
vvp_mangle_id(ivl_lpm_basename(net)), slice);
fprintf(vvp_out, "L_%s.%s/%u/2/0, ",
vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))),
vvp_mangle_id(ivl_lpm_basename(net)), slice);
if ((2U << (sel-1))/2 < size) {
fprintf(vvp_out, "L_%s.%s/%u/2/%u, ",
vvp_mangle_id(ivl_scope_name(ivl_lpm_scope(net))),
vvp_mangle_id(ivl_lpm_basename(net)),
slice, (2U << (sel-1))/2);
} else {
fprintf(vvp_out, "C<x>, ");
}
draw_input_from_net(s);
fprintf(vvp_out, ", C<1>;\n");
}
#endif
/* /*
* This draws a simple A/B mux. The mux can have any width, enough * This draws a simple A/B mux. The mux can have any width, enough
@ -145,11 +35,13 @@ static void draw_lpm_mux_bitslice(ivl_lpm_t net, unsigned slice)
*/ */
static void draw_lpm_mux_ab(ivl_lpm_t net) static void draw_lpm_mux_ab(ivl_lpm_t net)
{ {
unsigned width = ivl_lpm_width(net);
/* Only support A-B muxes in this function. */ /* Only support A-B muxes in this function. */
assert(ivl_lpm_size(net) == 2); assert(ivl_lpm_size(net) == 2);
assert(ivl_lpm_selects(net) == 1); assert(ivl_lpm_selects(net) == 1);
fprintf(vvp_out, "L_%p .functor MUXZ", net); fprintf(vvp_out, "L_%p .functor MUXZ %u", net, width);
fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,0))); fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,0)));
fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,1))); fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,1)));
fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_select(net))); fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_select(net)));
@ -174,6 +66,9 @@ void draw_lpm_mux(ivl_lpm_t net)
/* /*
* $Log: draw_mux.c,v $ * $Log: draw_mux.c,v $
* Revision 1.10 2005/06/17 03:46:52 steve
* Make functors know their own width.
*
* Revision 1.9 2005/04/06 05:29:09 steve * Revision 1.9 2005/04/06 05:29:09 steve
* Rework NetRamDq and IVL_LPM_RAM nodes. * Rework NetRamDq and IVL_LPM_RAM nodes.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vvp_scope.c,v 1.128 2005/05/24 01:44:28 steve Exp $" #ident "$Id: vvp_scope.c,v 1.129 2005/06/17 03:46:52 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -1068,11 +1068,11 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr)
int inst; int inst;
for (inst = 0; inst < ninp; inst += 4) { for (inst = 0; inst < ninp; inst += 4) {
if (ninp > 4) if (ninp > 4)
fprintf(vvp_out, "L_%p/%d/%d .functor %s", fprintf(vvp_out, "L_%p/%d/%d .functor %s %u",
lptr, level, inst, lcasc); lptr, level, inst, lcasc, vector_width);
else { else {
fprintf(vvp_out, "L_%p .functor %s", fprintf(vvp_out, "L_%p .functor %s %u",
lptr, ltype); lptr, ltype, vector_width);
draw_delay(lptr); draw_delay(lptr);
@ -1955,6 +1955,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/* /*
* $Log: vvp_scope.c,v $ * $Log: vvp_scope.c,v $
* Revision 1.129 2005/06/17 03:46:52 steve
* Make functors know their own width.
*
* Revision 1.128 2005/05/24 01:44:28 steve * Revision 1.128 2005/05/24 01:44:28 steve
* Do sign extension of structuran nets. * Do sign extension of structuran nets.
* *

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com) * Copyright (c) 2001 Stephen Williams (steve@icarus.com)
* *
* $Id: README.txt,v 1.67 2005/05/24 01:43:27 steve Exp $ * $Id: README.txt,v 1.68 2005/06/17 03:46:52 steve Exp $
*/ */
VVP SIMULATION ENGINE VVP SIMULATION ENGINE
@ -128,7 +128,7 @@ label is required for functors.
The general syntax of a functor is: The general syntax of a functor is:
<label> .functor <type>, symbol_list ; <label> .functor <type> [ (<delay>) ], symbol_list ;
The symbol list is 4 names of labels of other functors. These connect The symbol list is 4 names of labels of other functors. These connect
inputs of the functor of the statement to the output of other inputs of the functor of the statement to the output of other

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: compile.h,v 1.72 2005/05/24 01:43:27 steve Exp $" #ident "$Id: compile.h,v 1.73 2005/06/17 03:46:52 steve Exp $"
#endif #endif
# include <stdio.h> # include <stdio.h>
@ -85,7 +85,7 @@ extern void compile_vpi_time_precision(long pre);
* of the functor. The compile should match those port parameters up * of the functor. The compile should match those port parameters up
* to existing functors to manage the linking. * to existing functors to manage the linking.
*/ */
extern void compile_functor(char*label, char*type, extern void compile_functor(char*label, char*type, unsigned width,
vvp_delay_t*delay, unsigned ostr0, vvp_delay_t*delay, unsigned ostr0,
unsigned ostr1, unsigned ostr1,
unsigned argc, struct symb_s*argv); unsigned argc, struct symb_s*argv);
@ -313,6 +313,9 @@ extern void compile_net(char*label, char*name,
/* /*
* $Log: compile.h,v $ * $Log: compile.h,v $
* Revision 1.73 2005/06/17 03:46:52 steve
* Make functors know their own width.
*
* Revision 1.72 2005/05/24 01:43:27 steve * Revision 1.72 2005/05/24 01:43:27 steve
* Add a sign-extension node. * Add a sign-extension node.
* *

View File

@ -16,11 +16,12 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ident "$Id: concat.cc,v 1.3 2005/04/09 05:30:38 steve Exp $" #ident "$Id: concat.cc,v 1.4 2005/06/17 03:46:52 steve Exp $"
# include "compile.h" # include "compile.h"
# include "vvp_net.h" # include "vvp_net.h"
# include <stdlib.h> # include <stdlib.h>
# include <iostream>
#ifdef HAVE_MALLOC_H #ifdef HAVE_MALLOC_H
# include <malloc.h> # include <malloc.h>
#endif #endif
@ -48,7 +49,12 @@ void vvp_fun_concat::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
{ {
unsigned pdx = port.port(); unsigned pdx = port.port();
assert(bit.size() == wid_[pdx]); if (bit.size() != wid_[pdx]) {
cerr << "internal error: port " << pdx
<< " expects wid=" << wid_[pdx]
<< ", got wid=" << bit.size() << endl;
assert(0);
}
unsigned off = 0; unsigned off = 0;
for (unsigned idx = 0 ; idx < pdx ; idx += 1) for (unsigned idx = 0 ; idx < pdx ; idx += 1)
@ -118,6 +124,9 @@ void compile_repeat(char*label, long width, long repeat, struct symb_s arg)
/* /*
* $Log: concat.cc,v $ * $Log: concat.cc,v $
* Revision 1.4 2005/06/17 03:46:52 steve
* Make functors know their own width.
*
* Revision 1.3 2005/04/09 05:30:38 steve * Revision 1.3 2005/04/09 05:30:38 steve
* Default behavior for recv_vec8 methods. * Default behavior for recv_vec8 methods.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: logic.cc,v 1.26 2005/06/12 15:13:37 steve Exp $" #ident "$Id: logic.cc,v 1.27 2005/06/17 03:46:52 steve Exp $"
#endif #endif
# include "logic.h" # include "logic.h"
@ -149,10 +149,15 @@ void vvp_fun_bufz::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
vvp_send_vec4(ptr.ptr()->out, bit); vvp_send_vec4(ptr.ptr()->out, bit);
} }
vvp_fun_muxz::vvp_fun_muxz() vvp_fun_muxz::vvp_fun_muxz(unsigned wid)
: a_(wid), b_(wid)
{ {
count_functors_table += 1; count_functors_table += 1;
select_ = 2; select_ = 2;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
a_.set_bit(idx, BIT4_X);
b_.set_bit(idx, BIT4_X);
}
} }
vvp_fun_muxz::~vvp_fun_muxz() vvp_fun_muxz::~vvp_fun_muxz()
@ -225,7 +230,7 @@ void vvp_fun_muxz::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
* functor. Also resolve the inputs to the functor. * functor. Also resolve the inputs to the functor.
*/ */
void compile_functor(char*label, char*type, void compile_functor(char*label, char*type, unsigned width,
vvp_delay_t*delay, unsigned ostr0, unsigned ostr1, vvp_delay_t*delay, unsigned ostr0, unsigned ostr1,
unsigned argc, struct symb_s*argv) unsigned argc, struct symb_s*argv)
{ {
@ -264,7 +269,7 @@ void compile_functor(char*label, char*type,
obj = new table_functor_s(ft_MUXX); obj = new table_functor_s(ft_MUXX);
} else if (strcmp(type, "MUXZ") == 0) { } else if (strcmp(type, "MUXZ") == 0) {
obj = new vvp_fun_muxz(); obj = new vvp_fun_muxz(width);
} else if (strcmp(type, "NMOS") == 0) { } else if (strcmp(type, "NMOS") == 0) {
obj = new vvp_fun_pmos(true); obj = new vvp_fun_pmos(true);
@ -346,6 +351,9 @@ void compile_functor(char*label, char*type,
/* /*
* $Log: logic.cc,v $ * $Log: logic.cc,v $
* Revision 1.27 2005/06/17 03:46:52 steve
* Make functors know their own width.
*
* Revision 1.26 2005/06/12 15:13:37 steve * Revision 1.26 2005/06/12 15:13:37 steve
* Support resistive mos devices. * Support resistive mos devices.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: logic.h,v 1.17 2005/06/12 21:56:16 steve Exp $" #ident "$Id: logic.h,v 1.18 2005/06/17 03:46:53 steve Exp $"
#endif #endif
# include "vvp_net.h" # include "vvp_net.h"
@ -109,7 +109,7 @@ class vvp_fun_bufz: public vvp_net_fun_t {
class vvp_fun_muxz : public vvp_net_fun_t { class vvp_fun_muxz : public vvp_net_fun_t {
public: public:
explicit vvp_fun_muxz(); explicit vvp_fun_muxz(unsigned width);
virtual ~vvp_fun_muxz(); virtual ~vvp_fun_muxz();
void recv_vec4(vvp_net_ptr_t p, vvp_vector4_t bit); void recv_vec4(vvp_net_ptr_t p, vvp_vector4_t bit);
@ -135,6 +135,9 @@ extern const unsigned char ft_XOR[];
/* /*
* $Log: logic.h,v $ * $Log: logic.h,v $
* Revision 1.18 2005/06/17 03:46:53 steve
* Make functors know their own width.
*
* Revision 1.17 2005/06/12 21:56:16 steve * Revision 1.17 2005/06/12 21:56:16 steve
* Remove unused ft_MOS truth tables. * Remove unused ft_MOS truth tables.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: parse.y,v 1.75 2005/05/24 01:43:27 steve Exp $" #ident "$Id: parse.y,v 1.76 2005/06/17 03:46:53 steve Exp $"
#endif #endif
# include "parse_misc.h" # include "parse_misc.h"
@ -131,14 +131,15 @@ statement
label and a type name, and may have operands. The functor may label and a type name, and may have operands. The functor may
also have a delay specification and output strengths. */ also have a delay specification and output strengths. */
: T_LABEL K_FUNCTOR T_SYMBOL delay ',' symbols ';' : T_LABEL K_FUNCTOR T_SYMBOL T_NUMBER delay ',' symbols ';'
{ compile_functor($1, $3, $4, 6, 6, $6.cnt, $6.vect); } { compile_functor($1, $3, $4, $5, 6, 6, $7.cnt, $7.vect); }
| T_LABEL K_FUNCTOR T_SYMBOL delay | T_LABEL K_FUNCTOR T_SYMBOL T_NUMBER delay
'[' T_NUMBER T_NUMBER ']' ',' symbols ';' '[' T_NUMBER T_NUMBER ']' ',' symbols ';'
{ unsigned str0 = $6; { unsigned str0 = $7;
unsigned str1 = $7; unsigned str1 = $8;
compile_functor($1, $3, $4, str0, str1, $10.cnt, $10.vect); compile_functor($1, $3, $4, $5, str0, str1,
$11.cnt, $11.vect);
} }
@ -689,6 +690,9 @@ int compile_design(const char*path)
/* /*
* $Log: parse.y,v $ * $Log: parse.y,v $
* Revision 1.76 2005/06/17 03:46:53 steve
* Make functors know their own width.
*
* Revision 1.75 2005/05/24 01:43:27 steve * Revision 1.75 2005/05/24 01:43:27 steve
* Add a sign-extension node. * Add a sign-extension node.
* *