Make functors know their own width.
This commit is contained in:
parent
290c604c62
commit
4cc421b3b7
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include "vvp_priv.h"
|
||||
|
|
@ -28,116 +28,6 @@
|
|||
# include <stdlib.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
|
||||
|
|
@ -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)
|
||||
{
|
||||
unsigned width = ivl_lpm_width(net);
|
||||
|
||||
/* Only support A-B muxes in this function. */
|
||||
assert(ivl_lpm_size(net) == 2);
|
||||
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,1)));
|
||||
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 $
|
||||
* 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
|
||||
* Rework NetRamDq and IVL_LPM_RAM nodes.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include "vvp_priv.h"
|
||||
|
|
@ -1068,11 +1068,11 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr)
|
|||
int inst;
|
||||
for (inst = 0; inst < ninp; inst += 4) {
|
||||
if (ninp > 4)
|
||||
fprintf(vvp_out, "L_%p/%d/%d .functor %s",
|
||||
lptr, level, inst, lcasc);
|
||||
fprintf(vvp_out, "L_%p/%d/%d .functor %s %u",
|
||||
lptr, level, inst, lcasc, vector_width);
|
||||
else {
|
||||
fprintf(vvp_out, "L_%p .functor %s",
|
||||
lptr, ltype);
|
||||
fprintf(vvp_out, "L_%p .functor %s %u",
|
||||
lptr, ltype, vector_width);
|
||||
|
||||
draw_delay(lptr);
|
||||
|
||||
|
|
@ -1955,6 +1955,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
|
|||
|
||||
/*
|
||||
* $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
|
||||
* Do sign extension of structuran nets.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* 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
|
||||
|
|
@ -128,7 +128,7 @@ label is required for functors.
|
|||
|
||||
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
|
||||
inputs of the functor of the statement to the output of other
|
||||
|
|
|
|||
|
|
@ -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.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
|
||||
|
||||
# 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
|
||||
* 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,
|
||||
unsigned ostr1,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
|
|
@ -313,6 +313,9 @@ extern void compile_net(char*label, char*name,
|
|||
|
||||
/*
|
||||
* $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
|
||||
* Add a sign-extension node.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,11 +16,12 @@
|
|||
* 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: 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 "vvp_net.h"
|
||||
# include <stdlib.h>
|
||||
# include <iostream>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
|
@ -48,7 +49,12 @@ void vvp_fun_concat::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
|
|||
{
|
||||
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;
|
||||
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 $
|
||||
* 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
|
||||
* Default behavior for recv_vec8 methods.
|
||||
*
|
||||
|
|
|
|||
16
vvp/logic.cc
16
vvp/logic.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# 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_fun_muxz::vvp_fun_muxz()
|
||||
vvp_fun_muxz::vvp_fun_muxz(unsigned wid)
|
||||
: a_(wid), b_(wid)
|
||||
{
|
||||
count_functors_table += 1;
|
||||
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()
|
||||
|
|
@ -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.
|
||||
*/
|
||||
|
||||
void compile_functor(char*label, char*type,
|
||||
void compile_functor(char*label, char*type, unsigned width,
|
||||
vvp_delay_t*delay, unsigned ostr0, unsigned ostr1,
|
||||
unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
|
|
@ -264,7 +269,7 @@ void compile_functor(char*label, char*type,
|
|||
obj = new table_functor_s(ft_MUXX);
|
||||
|
||||
} else if (strcmp(type, "MUXZ") == 0) {
|
||||
obj = new vvp_fun_muxz();
|
||||
obj = new vvp_fun_muxz(width);
|
||||
|
||||
} else if (strcmp(type, "NMOS") == 0) {
|
||||
obj = new vvp_fun_pmos(true);
|
||||
|
|
@ -346,6 +351,9 @@ void compile_functor(char*label, char*type,
|
|||
|
||||
/*
|
||||
* $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
|
||||
* Support resistive mos devices.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# 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 {
|
||||
|
||||
public:
|
||||
explicit vvp_fun_muxz();
|
||||
explicit vvp_fun_muxz(unsigned width);
|
||||
virtual ~vvp_fun_muxz();
|
||||
|
||||
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 $
|
||||
* 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
|
||||
* Remove unused ft_MOS truth tables.
|
||||
*
|
||||
|
|
|
|||
18
vvp/parse.y
18
vvp/parse.y
|
|
@ -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.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
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -131,14 +131,15 @@ statement
|
|||
label and a type name, and may have operands. The functor may
|
||||
also have a delay specification and output strengths. */
|
||||
|
||||
: T_LABEL K_FUNCTOR T_SYMBOL delay ',' symbols ';'
|
||||
{ compile_functor($1, $3, $4, 6, 6, $6.cnt, $6.vect); }
|
||||
: T_LABEL K_FUNCTOR T_SYMBOL T_NUMBER delay ',' symbols ';'
|
||||
{ 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 ';'
|
||||
{ unsigned str0 = $6;
|
||||
unsigned str1 = $7;
|
||||
compile_functor($1, $3, $4, str0, str1, $10.cnt, $10.vect);
|
||||
{ unsigned str0 = $7;
|
||||
unsigned str1 = $8;
|
||||
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 $
|
||||
* 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
|
||||
* Add a sign-extension node.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue