
//#define MAXLUT 600        /* Maximum number of inputs per LUT */
#define MAXLUT 5500        /* Maximum number of inputs per LUT */

//#define MAXEB 5500        /* Maximum number of inputs per LUT */
                       /* Has to be a pretty big number for DSPs since even a MAC for 4 18x18 mults will have 218 */
//#define HASHSIZE 4095
#define HASHSIZE 5000

#define NAMELENGTH 400  /* Length of the name stored for each net */ 
#define DEBUG 1         /* Echoes input & checks error conditions */
/*#define VERBOSE 1*/   /* Prints all sorts of intermediate data */


#define NO_CLUSTER -1
#define NEVER_CLUSTER -2
#define NOT_VALID -10000  /* Marks gains that aren't valid */
                          /* Ensure no gain can ever be this negative! */
#define UNDEFINED -1    

#define DRIVER 0     /* Is a pin driving a net or in the fanout? */
#define RECEIVER 1
#define OPEN -1      /* Pin is unconnected. */

#define MIN_BLOCK_NUM_NET 16
#define LUT_IN_POS	 15

#define VEB_IN		286
#define VEB_OUT		258

/*------------------------------------------------------------
 *  Copyright 2002 By Kara K.W. Poon and Steve Wilton
 *
 * Permission to use, copy, and modify this software and its documentation is
 * hereby granted only under the following terms and conditions.  Both the
 * above copyright notice and this permission notice must appear in all copies
 * of the software, derivative works or modified versions, and any portions
 * thereof, and both notices must appear in supporting documentation.
 * Permission is granted ONLY for non-commercial use.  For
 * commercial use, please contact the authors.
 *
 * This software may be distributed (but not offered for sale or transferred
 * for compensation) to third parties, provided such third parties agree to
 * abide by the terms and conditions of this notice.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS, AS
 * WELL AS THE UNIVERSITY OF BRITISH COLUMBIA AND THE
 * UNIVERSITY OF TORONTO DISCLAIM ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL THE
 * AUTHORS OR THE UNIVERSITY OF BRITISH COLUMBIA OR THE
 * UNIVERSITY OF TORONTO BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *------------------------------------------------------------*/
/*
  T-Vpack was written by Vaughn Betz at the University of Toronto.
  
  May 2001   Modified by Dr. Steve Wilton at the University 
             of British Columbia to propagate signal 
             activities
  July 2001  Further modified by Kara Poon at the University 
             of British Columbia to propagate both
             static probability and transition density

 */
/*
  November 2006		Modified by Yu Chi Wai at the Imperial
					College of London to support adding 
					virtual embedded block (VEB) to the circuit
 */

//enum block_types {INPAD = -2, OUTPAD, LUT, LATCH, EMPTY, LUT_AND_LATCH, DSP, MEMORY, VEB};
enum block_types {
	INPAD = -2, 
	OUTPAD, 
	GND,
	VCC,
	/*LUT, */
	LATCH, 
	EMPTY, 
	LUT_AND_LATCH, 
	DSP, 
	DSPS, 
	MEMORY, 
	VEB, 
	LUT, 
	LUT_L, 
	FD, 
	FDP,
	FDS,
	FDC, 
	FDCE, 
	FDPE, 
	FDE, 
	FDR,
   	FDCP,
	FDRS,
	LDC,	
	XORCY, 
	MUXCY, 
	MUXCY_L, 
	MUXF,
	INV, 
	MULT_AND};

enum PIN_POS {
	LUT_D = 0,
	LUT_DI,
	LUT_MC15,

	FF_D,
	FF_Q,
	FF_CLK,
	FF_CE,
	FF_SR,

	INV_IN,
	INV_O,

	MUXCY_S,
	MUXCY_DI,
	MUXCY_CI,
	MUXCY_O,

	MUXF_S,
	MUXF_I0,
	MUXF_I1,
	MUXF_O,

	XORCY_LI,
	XORCY_CI,
	XORCY_O,

	MULTAND_I0,
	MULTAND_I1,
	MULTAND_O,

	//output
	B_COUT,
	B_SHIFTOUT,
	B_Y,
	B_Q,
	B_YB,
	B_SOPOUT,
	B_DIG,
	B_FX,
	
	//input 
	B_CLK,
	B_CIN,
	B_SHIFTIN,
	B_CE,
	B_SR,	
	B_BY,
	B_SOPIN,
	B_DY,
	B_ALTDIG,
	B_GND,
	B_VCC,
	B_FXINA,
	B_FXINB,
	B_LUT_IN
};

enum e_cluster_seed {POWER, TIMING, MAX_INPUTS};

struct hash_nets {char *name; int index; int count; 
   struct hash_nets *next;}; 
/* count is the number of pins on this net so far. */


struct s_net {char *name; 
              int num_pins; 
	      int num_packed;
	      int num_clusters;
              int *pins; 
              float probability;
              float density;
              int mark;
             };
/* name:  ASCII net name for informative annotations in the output.  *
 * num_pins:  Number of pins on this net.                            *
 * pins[]: Array containing the blocks to which the pins of this net *
 *         connect.  Output in pins[0], inputs in other entries.     */
 

struct s_block {char *name; 
                enum block_types type; 
                int num_nets;
				int num_input;
				int num_output;
                int nets[MAXLUT+2];		

				//net order
				//Output net
					//cout, shiftout, y, q, yb, sopout, dig
				//Input net
					//clk, cin, ce, sr,by sopin, dy, altdig, lut in ...
				int cluster_order;
                float probability;
                float density;
                char *function;
				int use_lut;
				int use_ff;
				int use_xorcy;
				int use_muxcy;
				int use_inv;
				int use_inv_clk;
				int use_inv_ce;
				int use_inv_sr;
				int use_ff_int_conn;
				int use_mult_and;
				int use_muxf;
                
				enum block_types lut_type;
				enum block_types ff_type;
/* The following are used only for DSP or MEMORY or VEB types:
   used to indicate how many nets of each type are in the block. */

                int num_of_each_type[3];

/* The following indicates if this node should be attached to 
   another node via a carry-out signal.  A -1 means no, otherwise,
   it indicates the index of the carry-out block */

                char *carryout_to_name;
                int carryout_to;
               };

/* name:  Taken from the net which it drives.                        *
 * type:  LUT, INPAD, OUTPAD or LATCH.                               *
 * num_nets:  number of nets connected to this block.                *
 * num_input : number of input to this block						 *
 * num_output : number of output from this block					 *
 * nets[]:  List of nets connected to this block.  Net[0] is the     *
 *          output, others are inputs, except for OUTPAD.  OUTPADs   *
 *          only have an input, so this input is in net[0].          */


/*slice pin postion */
enum SLICE_PINLIST 
{
	/* share pin*/
	SLICE_SOPIN = 0,
	SLICE_ALTDIG = 1,	
	SLICE_CE =2,
	SLICE_CLK = 3,
	SLICE_SR = 4,
	SLICE_DIG = 5,
	SLICE_SOPOUT = 6,
	SLICE_CIN = 7,
	SLICE_COUT = 8,

	/*start of subblock*/
	SLICE_SUBBLOCK = 9
};




//structure to store the net connect to output buffer directly 
struct oname_convert
{	
	char *output_name;
	char *net_name;
};
	

/*subblock pin position*/
enum SUB_PIN_POS {
	SUB_SHIFTIN = 0,
	SUB_SHIFTOUT =1,
	//SUB_CIN =2,
	//SUB_COUT =3,		
	SUB_BY= 2, 
	SUB_BYOUT= 3,
	SUB_YB=4,
	SUB_Y=5,
	SUB_DY=6,
	SUB_YQ=7,
	SUB_FXINA=8,
	SUB_FXINB=9,
	SUB_FX =10,	
	//SUB_CE,
	//SUB_SR,
	//SUB_CLK,
	SUB_LUT_IN =11
};

#define SUB_CIN 2
#define SUB_COUT 3	
	

