2001-05-31 06:12:43 +02:00
|
|
|
/*
|
2010-05-31 22:12:06 +02:00
|
|
|
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
|
2001-05-31 06:12:43 +02:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-05-31 06:12:43 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "bufif.h"
|
|
|
|
|
# include "schedule.h"
|
2002-07-05 22:08:44 +02:00
|
|
|
# include "statistics.h"
|
2005-04-13 08:34:20 +02:00
|
|
|
# include <iostream>
|
2010-05-31 22:12:06 +02:00
|
|
|
# include <cassert>
|
2002-07-05 22:08:44 +02:00
|
|
|
|
2005-02-07 23:42:42 +01:00
|
|
|
vvp_fun_bufif::vvp_fun_bufif(bool en_invert, bool out_invert,
|
|
|
|
|
unsigned str0, unsigned str1)
|
2002-07-05 22:08:44 +02:00
|
|
|
: pol_(en_invert? 1 : 0), inv_(out_invert? 1 : 0)
|
|
|
|
|
{
|
2005-02-07 23:42:42 +01:00
|
|
|
drive0_ = str0;
|
|
|
|
|
drive1_ = str1;
|
2002-07-05 22:08:44 +02:00
|
|
|
count_functors_bufif += 1;
|
|
|
|
|
}
|
2001-05-31 06:12:43 +02:00
|
|
|
|
2008-10-28 18:52:39 +01:00
|
|
|
void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
|
|
|
|
|
vvp_context_t)
|
2001-05-31 06:12:43 +02:00
|
|
|
{
|
2005-02-07 23:42:42 +01:00
|
|
|
switch (ptr.port()) {
|
|
|
|
|
case 0:
|
2005-06-02 18:02:11 +02:00
|
|
|
bit_ = inv_? ~bit : bit;
|
2005-02-07 23:42:42 +01:00
|
|
|
break;
|
2001-05-31 06:12:43 +02:00
|
|
|
case 1:
|
2005-02-07 23:42:42 +01:00
|
|
|
en_ = pol_? ~bit : bit;
|
2001-05-31 06:12:43 +02:00
|
|
|
break;
|
2005-02-07 23:42:42 +01:00
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
2001-05-31 06:12:43 +02:00
|
|
|
|
2005-02-07 23:42:42 +01:00
|
|
|
vvp_vector8_t out (bit.size());
|
2001-05-31 06:12:43 +02:00
|
|
|
|
2005-02-07 23:42:42 +01:00
|
|
|
for (unsigned idx = 0 ; idx < bit.size() ; idx += 1) {
|
|
|
|
|
vvp_bit4_t b_en = en_.value(idx);
|
|
|
|
|
vvp_bit4_t b_bit = bit_.value(idx);
|
|
|
|
|
|
|
|
|
|
switch (b_en) {
|
|
|
|
|
case BIT4_0:
|
2005-03-12 05:27:42 +01:00
|
|
|
out.set_bit(idx, vvp_scalar_t(BIT4_Z,drive0_,drive1_));
|
2001-05-31 06:12:43 +02:00
|
|
|
break;
|
2005-02-07 23:42:42 +01:00
|
|
|
case BIT4_1:
|
|
|
|
|
if (bit4_is_xz(b_bit))
|
2005-03-12 05:27:42 +01:00
|
|
|
out.set_bit(idx, vvp_scalar_t(BIT4_X,drive0_,drive1_));
|
2005-02-07 23:42:42 +01:00
|
|
|
else
|
2005-03-12 05:27:42 +01:00
|
|
|
out.set_bit(idx, vvp_scalar_t(b_bit,drive0_,drive1_));
|
2001-05-31 06:12:43 +02:00
|
|
|
break;
|
2005-02-07 23:42:42 +01:00
|
|
|
|
2001-05-31 06:12:43 +02:00
|
|
|
default:
|
2005-02-07 23:42:42 +01:00
|
|
|
switch (b_bit) {
|
|
|
|
|
case BIT4_0:
|
2005-03-12 05:27:42 +01:00
|
|
|
out.set_bit(idx, vvp_scalar_t(BIT4_X,drive0_,0));
|
2005-02-07 23:42:42 +01:00
|
|
|
break;
|
|
|
|
|
case BIT4_1:
|
2005-03-12 05:27:42 +01:00
|
|
|
out.set_bit(idx, vvp_scalar_t(BIT4_X,0,drive1_));
|
2005-02-07 23:42:42 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
2005-03-12 05:27:42 +01:00
|
|
|
out.set_bit(idx, vvp_scalar_t(BIT4_X,drive0_,drive1_));
|
2005-02-07 23:42:42 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2001-05-31 06:12:43 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-04 05:40:26 +02:00
|
|
|
ptr.ptr()->send_vec8(out);
|
2001-05-31 06:12:43 +02:00
|
|
|
}
|