Implement the vvp_fun_muxz functor.

This commit is contained in:
steve 2005-02-12 22:50:52 +00:00
parent d74177634c
commit 85d9ebded8
3 changed files with 103 additions and 8 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: draw_tt.c,v 1.18 2005/01/29 17:52:06 steve Exp $"
#ident "$Id: draw_tt.c,v 1.19 2005/02/12 22:50:52 steve Exp $"
#endif
# include <stdio.h>
@ -328,6 +328,7 @@ static void draw_MUXX(void)
printf("};\n");
}
#if 0
static void draw_MUXZ(void)
{
unsigned i0, i1, i2, i3;
@ -368,6 +369,7 @@ static void draw_MUXZ(void)
printf("};\n");
}
#endif
static void draw_EEQ(void)
{
@ -744,7 +746,6 @@ main()
draw_PMOS();
draw_NMOS();
draw_MUXX();
draw_MUXZ();
draw_EEQ();
draw_NAND();
draw_NOR();
@ -761,6 +762,9 @@ main()
/*
* $Log: draw_tt.c,v $
* Revision 1.19 2005/02/12 22:50:52 steve
* Implement the vvp_fun_muxz functor.
*
* Revision 1.18 2005/01/29 17:52:06 steve
* move AND to buitin instead of table.
*

View File

@ -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.18 2005/02/07 22:42:42 steve Exp $"
#ident "$Id: logic.cc,v 1.19 2005/02/12 22:50:52 steve Exp $"
#endif
# include "logic.h"
@ -148,6 +148,76 @@ 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()
{
count_functors_table += 1;
select_ = 2;
}
vvp_fun_muxz::~vvp_fun_muxz()
{
}
void vvp_fun_muxz::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
{
switch (ptr.port()) {
case 0:
a_ = bit;
break;
case 1:
b_ = bit;
break;
case 2:
assert(bit.size() == 1);
switch (bit.value(0)) {
case BIT4_0:
select_ = 0;
break;
case BIT4_1:
select_ = 1;
break;
default:
select_ = 2;
}
break;
default:
return;
}
switch (select_) {
case 0:
vvp_send_vec4(ptr.ptr()->out, a_);
break;
case 1:
vvp_send_vec4(ptr.ptr()->out, b_);
break;
default:
{
unsigned min_size = a_.size();
unsigned max_size = a_.size();
if (b_.size() < min_size)
min_size = b_.size();
if (b_.size() > max_size)
max_size = b_.size();
vvp_vector4_t res (max_size);
for (unsigned idx = 0 ; idx < min_size ; idx += 1) {
if (a_.value(idx) == b_.value(idx))
res.set_bit(idx, a_.value(idx));
else
res.set_bit(idx, BIT4_X);
}
for (unsigned idx = min_size ; idx < max_size ; idx += 1)
res.set_bit(idx, BIT4_X);
vvp_send_vec4(ptr.ptr()->out, res);
}
break;
}
}
/*
* The parser calls this function to create a logic functor. I allocate a
* functor, and map the name to the vvp_ipoint_t address for the
@ -194,7 +264,7 @@ void compile_functor(char*label, char*type,
obj = new table_functor_s(ft_MUXX);
} else if (strcmp(type, "MUXZ") == 0) {
obj = new table_functor_s(ft_MUXZ);
obj = new vvp_fun_muxz();
} else if (strcmp(type, "EEQ") == 0) {
obj = new table_functor_s(ft_EEQ);
@ -244,6 +314,9 @@ void compile_functor(char*label, char*type,
/*
* $Log: logic.cc,v $
* Revision 1.19 2005/02/12 22:50:52 steve
* Implement the vvp_fun_muxz functor.
*
* Revision 1.18 2005/02/07 22:42:42 steve
* Add .repeat functor and BIFIF functors.
*

View File

@ -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.11 2005/01/29 17:52:06 steve Exp $"
#ident "$Id: logic.h,v 1.12 2005/02/12 22:50:52 steve Exp $"
#endif
# include "vvp_net.h"
@ -91,13 +91,28 @@ class vvp_fun_bufz: public vvp_net_fun_t {
private:
};
/*
* The muxz functor is an A-B mux device, with the data inputs on
* ports 0 and 1. port 2 is the select input.
*/
class vvp_fun_muxz : public vvp_net_fun_t {
public:
explicit vvp_fun_muxz();
virtual ~vvp_fun_muxz();
void recv_vec4(vvp_net_ptr_t p, vvp_vector4_t bit);
private:
vvp_vector4_t a_;
vvp_vector4_t b_;
int select_;
};
// table functor types
extern const unsigned char ft_AND[];
extern const unsigned char ft_BUF[];
extern const unsigned char ft_BUFIF0[];
extern const unsigned char ft_BUFIF1[];
extern const unsigned char ft_BUFZ[];
extern const unsigned char ft_PMOS[];
extern const unsigned char ft_NMOS[];
extern const unsigned char ft_MUXX[];
@ -115,6 +130,9 @@ extern const unsigned char ft_var[];
/*
* $Log: logic.h,v $
* Revision 1.12 2005/02/12 22:50:52 steve
* Implement the vvp_fun_muxz functor.
*
* Revision 1.11 2005/01/29 17:52:06 steve
* move AND to buitin instead of table.
*