// Simulation.h: interface for the Simulation class.
//
//////////////////////////////////////////////////////////////////////

#ifndef __ATALANTA_SIMULATION_H__
#define __ATALANTA_SIMULATION_H__

#include "ReadableNet.h"


namespace atalantadll {
	class SHARE_EXPORT Simulation:public ReadableNet
	{
	protected:
		char compact;
		int maxCompact;
		char fillMode;
		level testVectors[MAXTEST/10][MAXPI+1];
		level testVectors1[MAXTEST/10][MAXPI+1];
		level testStore[MAXTEST/10][MAXPI+1];
		level testStore1[MAXTEST/10][MAXPI+1];

		void setBit(int *word,int nth);
		void resetBit(int *word,int nth);
		void setb0(int *word0, int *word1, int nth) ;
		void setb1(int *word0, int *word1, int nth) ; 
		void setbx(int *word0, int *word1, int nth) ;

		int		randomFsim(int levels,int nStem,Gate **stem,level *lfsr,int limit,int maxBit,int maxDetect,int *nTest,int *nPacket,int *nBit);
		int		randomHope(level *lfsr,int limit,int maxBit,int maxDetect,int *nTest,int *nPacket,int *nBit);
		void	randomTestFsim(level (*testSt)[2001],level (*testVect)[2001],int pack,int noBit);
		void	randomTestHope(level (*testSt0)[2001],level (*testSt1)[2001],level (*testVect0)[2001],level (*testVect1)[2001],int pack,int noBit);
		int		reverseFsim(int levels,int nStem,Gate **stem,int *nDet,int nPacket,int nBit,int maxBits);
		int		reverseHope(int *nDet,int nPacket,int nBit,int maxBits);
		int		shuffleFsim(int levels,int nStem,Gate **stem,int *nShuf,int *nDet,int nPacket,int nBit,int maxBits);
		int		shuffleHope(int *nShuf,int *nDet,int nPacket,int nBit,int maxBits);
		void	fillPatternsFsim(char mode,int nPacket,int nBit);
		void	fillPatternsHope(char mode,int nPacket,int nBit);

	public:
		Simulation(){
			compact = 's';
			maxCompact = 2;
			fillMode = 'r';
		};

		int compactTest(int levels,int nStem,Gate **stem,int *nShuf,int *nDet,int nPacket,int nBit,int maxBits);
		void fillPatterns(int mode,int nPacket,int nBit);
		int randomSim(int levels,int nStem,Gate **stem,level *lfsr,int limit,int maxBit,int maxDetect,int *nTest,int *nPacket,int *nBit);
		int simulateHope(int *nPacket,int *nBit);
		int tGenSim(int levels,int nStem,Gate **stem,int nTest,int *profile);
		int testGen(int levels,int maxBits,int nStem,Gate **stem,int maxBackTrack,int phase,int *nRedundant,int *nOverBackTrack,int *nBackTrack,int *nTest,int *nPacket,int *nBit,double *fanTime);

		virtual ~Simulation(){};
	};

}
#endif // __ATALANTA_SIMULATION_H__
