flipflop.h

00001 /***************************************************************************
00002  *   Copyright (C) 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 FLIPFLOP_H
00012 #define FLIPFLOP_H
00013 
00014 #include "component.h"
00015 #include "logic.h"
00016 
00017 class Simulator;
00018 
00023 class ECDFlipFlop : public CallbackClass, public Component
00024 {
00025 public:
00026         ECDFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id = 0 );
00027         ~ECDFlipFlop();
00028         virtual bool canFlip() const { return true; }
00029         
00030         static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id );
00031         static LibraryItem *libraryItem();
00032         
00033 private:
00034         void inputChanged( bool newState );
00035         void inStateChanged( bool newState );
00036         void asyncChanged(bool newState );
00037         void clockChanged(bool newState );
00038         
00039         LogicIn *m_pD;
00040         LogicIn *m_pClock;
00041         LogicOut *m_pQ;
00042         LogicOut *m_pQBar;
00043         LogicIn *setp;
00044         LogicIn *rstp;
00045         bool m_bPrevClock;
00046         
00047         bool m_prevD[2];
00048         unsigned m_whichPrevD:1;
00049         unsigned long long m_prevDSimTime;
00050         Simulator * m_pSimulator;
00051 };
00052 
00053 
00058 class ECJKFlipFlop : public CallbackClass, public Component
00059 {
00060 public:
00061         ECJKFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id = 0 );
00062         ~ECJKFlipFlop();
00063         virtual bool canFlip() const { return true; }
00064         
00065         static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id );
00066         static LibraryItem *libraryItem();
00067         
00068 private:
00069         void inStateChanged( bool newState );
00070         void asyncChanged(bool newState );
00071         void clockChanged(bool newState );
00072         bool prev_state;
00073         LogicIn *m_pJ;
00074         LogicIn *m_pClock;
00075         LogicIn *m_pK;
00076         LogicIn *setp;
00077         LogicIn *rstp;
00078         LogicOut *m_pQ;
00079         LogicOut *m_pQBar;
00080 };
00081 
00082 
00087 class ECSRFlipFlop : public CallbackClass, public Component
00088 {
00089 public:
00090         ECSRFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id = 0 );
00091         ~ECSRFlipFlop();
00092         virtual bool canFlip() const { return true; }
00093         
00094         static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id );
00095         static LibraryItem *libraryItem();
00096         
00097 protected:
00098         void inStateChanged( bool newState );
00099         LogicIn * m_pS;
00100         LogicIn * m_pR;
00101         LogicOut * m_pQ;
00102         LogicOut * m_pQBar;
00103         bool old_q1;
00104         bool old_q2;
00105 };
00106 
00107 #endif

Generated on Tue May 8 17:05:29 2007 for KTechLab by  doxygen 1.5.1