/**************************************************************************** Copyright (C) 1987-2005 by Jeffery P. Hansen This program is free software; you can redistribute it and/or modify it 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 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ****************************************************************************/ #include #include #include #include "gsim.h" #define RSHIFT_Z 0 #define RSHIFT_S 1 #define RSHIFT_I 2 #define RSHIFT_DELAY_SZ 0 #define RSHIFT_DELAY_IZ 1 static void Rshift_processEvent(SGate*,EvQueue*,SEvent*); int shift_checkGate(SGate*); static SGateInfo rshift_info = { 0, "rshift",0x0, 3,{{"Z",GIO_OUT,0}, {"S",GIO_IN,0}, {"I",GIO_IN,0}}, {{"S-Z",bit(1),0}, {"I-Z",bit(2),0}, {0}}, Generic_copyGate, Rshift_processEvent, shift_checkGate, Nop_initGate, 0, 0, 0, Generic_propFrwdDelay, Generic_propBackDelay, Generic_delay, }; void init_rshift() { SGateInfo_register(&rshift_info,0); } static void Rshift_processEvent(SGate *g,EvQueue *Q,SEvent *E) { SPort *Z = g->g_ports.port[RSHIFT_Z]; SState *S = SGate_allocPortState(g,RSHIFT_S); SState *I = SGate_allocPortState(g,RSHIFT_I); unsigned smask = (1<<(S->nbits & SSBITMASK))-1; SState *out = alloc_SState(); int delay; SState_reinit(out,Z->p_state.nbits); if ((S->flt[0]&smask)) { SState_unknown(out); } else { SState_shift(out,I,-(S->one[0]&smask),0,1,0); } if (IsChangeOn(E,g,RSHIFT_I)) delay = g->g_delayParms[RSHIFT_DELAY_IZ]; else delay = g->g_delayParms[RSHIFT_DELAY_SZ]; EvQueue_setPort(Q,Z,out,delay); free_SState(out); free_SState(I); free_SState(S); }