示例#1
0
static void tristate_component_state_real_update (ComponentState* base) {
	TristateComponentState * self;
	gboolean output = FALSE;
	Connection* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	self = (TristateComponentState*) base;
	_tmp0_ = self->priv->controlWire;
	_tmp1_ = connection_get_signalState (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		Connection* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		Connection* _tmp6_;
		gboolean _tmp7_;
		_tmp3_ = self->priv->inputWire;
		_tmp4_ = connection_get_signalState (_tmp3_);
		_tmp5_ = _tmp4_;
		output = _tmp5_;
		_tmp6_ = self->priv->outputWire;
		_tmp7_ = output;
		connection_set_signalState (_tmp6_, _tmp7_);
	} else {
		Connection* _tmp8_;
		_tmp8_ = self->priv->outputWire;
		connection_disable_signal (_tmp8_);
	}
}
示例#2
0
文件: state-or.c 项目: genba/SmartSim
static void or_component_state_real_update (ComponentState* base) {
	OrComponentState * self;
	gboolean output;
	Connection** _tmp0_;
	gint _tmp0__length1;
	Connection* _tmp5_;
	gboolean _tmp6_;
	self = (OrComponentState*) base;
	output = FALSE;
	_tmp0_ = self->priv->inputWires;
	_tmp0__length1 = self->priv->inputWires_length1;
	{
		Connection** inputWire_collection = NULL;
		gint inputWire_collection_length1 = 0;
		gint _inputWire_collection_size_ = 0;
		gint inputWire_it = 0;
		inputWire_collection = _tmp0_;
		inputWire_collection_length1 = _tmp0__length1;
		for (inputWire_it = 0; inputWire_it < _tmp0__length1; inputWire_it = inputWire_it + 1) {
			Connection* _tmp1_;
			Connection* inputWire = NULL;
			_tmp1_ = _connection_ref0 (inputWire_collection[inputWire_it]);
			inputWire = _tmp1_;
			{
				Connection* _tmp2_;
				gboolean _tmp3_;
				gboolean _tmp4_;
				_tmp2_ = inputWire;
				_tmp3_ = connection_get_signalState (_tmp2_);
				_tmp4_ = _tmp3_;
				if (_tmp4_ == TRUE) {
					output = TRUE;
				}
				_connection_unref0 (inputWire);
			}
		}
	}
	_tmp5_ = self->priv->outputWire;
	_tmp6_ = output;
	connection_set_signalState (_tmp5_, _tmp6_);
}
static void multiplexer_component_state_real_update (ComponentState* base) {
	MultiplexerComponentState * self;
	gboolean output = FALSE;
	gint selected = 0;
	gint _tmp11_ = 0;
	Connection** _tmp12_ = NULL;
	gint _tmp12__length1 = 0;
	Connection* _tmp18_ = NULL;
	gboolean _tmp19_ = FALSE;
	self = (MultiplexerComponentState*) base;
	output = FALSE;
	selected = 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_ = 0;
				Connection** _tmp3_ = NULL;
				gint _tmp3__length1 = 0;
				gint _tmp4_ = 0;
				Connection** _tmp5_ = NULL;
				gint _tmp5__length1 = 0;
				gint _tmp6_ = 0;
				Connection* _tmp7_ = NULL;
				gboolean _tmp8_ = FALSE;
				gboolean _tmp9_ = FALSE;
				if (!_tmp0_) {
					gint _tmp1_ = 0;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = i;
				_tmp3_ = self->priv->selectWires;
				_tmp3__length1 = self->priv->selectWires_length1;
				if (!(_tmp2_ < _tmp3__length1)) {
					break;
				}
				_tmp4_ = selected;
				selected = _tmp4_ << 1;
				_tmp5_ = self->priv->selectWires;
				_tmp5__length1 = self->priv->selectWires_length1;
				_tmp6_ = i;
				_tmp7_ = _tmp5_[_tmp6_];
				_tmp8_ = connection_get_signalState (_tmp7_);
				_tmp9_ = _tmp8_;
				if (_tmp9_) {
					gint _tmp10_ = 0;
					_tmp10_ = selected;
					selected = _tmp10_ | 1;
				}
			}
		}
	}
	_tmp11_ = selected;
	_tmp12_ = self->priv->dataWires;
	_tmp12__length1 = self->priv->dataWires_length1;
	if (_tmp11_ < _tmp12__length1) {
		Connection** _tmp13_ = NULL;
		gint _tmp13__length1 = 0;
		gint _tmp14_ = 0;
		Connection* _tmp15_ = NULL;
		gboolean _tmp16_ = FALSE;
		gboolean _tmp17_ = FALSE;
		_tmp13_ = self->priv->dataWires;
		_tmp13__length1 = self->priv->dataWires_length1;
		_tmp14_ = selected;
		_tmp15_ = _tmp13_[_tmp14_];
		_tmp16_ = connection_get_signalState (_tmp15_);
		_tmp17_ = _tmp16_;
		output = _tmp17_;
	}
	_tmp18_ = self->priv->outputWire;
	_tmp19_ = output;
	connection_set_signalState (_tmp18_, _tmp19_);
}