00001 /*************************************************************************** 00002 * Copyright (C) 2003-2005 by David Saxton * 00003 * david@bluehaze.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 ***************************************************************************/ 00010 00011 #ifndef EC4BITCOUNTER_H 00012 #define EC4BITCOUNTER_H 00013 00014 #include "component.h" 00015 #include "logic.h" 00016 00033 class BinaryCounter : public CallbackClass, public Component 00034 { 00035 public: 00036 BinaryCounter( ICNDocument *icnDocument, bool newItem, const char *id = 0 ); 00037 ~BinaryCounter(); 00038 00039 virtual bool canFlip() const { return true; } 00040 static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id ); 00041 static LibraryItem *libraryItem(); 00042 00043 protected: 00044 void inStateChanged( bool state ); // Input 00045 void rStateChanged( bool state ); // Reset 00046 void enStateChanged( bool state ); // Enable 00047 void udStateChanged( bool state ); // Up/Down 00048 void outputValue(); 00049 void dataChanged(); 00050 void initPins( unsigned numBits ); 00051 00052 LogicIn *enLogic, *inLogic, *rLogic, *udLogic; 00053 LogicOut * m_pLogicOut[26]; 00054 00055 unsigned m_numBits; 00056 00057 00058 // um, why are we remembering the pin states? Shouldn't we be reading these from the 00059 // simulator for each step? 00060 bool b_triggerHigh; 00061 bool b_en; // Enable 00062 bool b_ud; // Up/Down 00063 bool b_oldIn; 00064 bool b_reset; 00065 long m_value; 00066 long m_maxValue; 00067 bool m_bDoneLogicIn; 00068 }; 00069 00070 #endif
1.5.1