bl.h 5.27 KB
/*
 *  bl.h -- defines, structures used in blend unit
 *
 */

#ifndef BL_UNIT_INCLD
#define BL_UNIT_INCLD

/*  mux selects for multiplier 1,2 a inputs */
typedef enum {
	BL0_BLPREV_CC_CLR,
	BL0_MEM_CLR,
	BL0_BLATTR_CLR,
	BL0_FOG_COLOR
} BLMuxPMsel;

/*  mux selects for multiplier 1 b inputs */
typedef enum {
	BL1_PIXEL_ALPHA,
	BL1_FOG_ALPHA,
	BL1_SHADE_ALPHA,
	BL1_ZERO
} BLMux1Sel;

/*  mux selects for multiplier 2 b inputs */
typedef enum {
	BL2_1_MINUS_A,
	BL2_MEM_ALPHA,
	BL2_ONE,
	BL2_ZERO
} BLMux2Sel;


/*
 *  Structure containing all state of blender, inputs, and outputs
 */
typedef struct
{
  /* R E Q U I R E D    by C-sim */

    char *label;	/* label must be first */
    int argc;
    char **argv;
    int gclk_old;

  /* I N P U T     signals (must be int) */

    int gclk;

    int st_span;
    int ncyc;

    int blend_mask;			/* [7:0] */
    int z_source_select;
    int antialias_enable;
    int z_compare_enable;
    int z_update_enable;
    int z_mode;				/* [1:0] */
    int cvg_dest;			/* [1:0] */
    int color_on_cvg;
    int force_blend;
    int mask15b;

    int bl_p_sel_0_r;			/* [1:0] */
    int bl_m_sel_0_r;			/* [1:0] */
    int bl_a_sel_0_r;			/* [1:0] */
    int bl_b_sel_0_r;			/* [1:0] */
    int bl_p_sel_1_r;			/* [1:0] */
    int bl_m_sel_1_r;			/* [1:0] */
    int bl_a_sel_1_r;			/* [1:0] */
    int bl_b_sel_1_r;			/* [1:0] */

    int blend_r;			/* [7:0] */
    int blend_g;			/* [7:0] */
    int blend_b;			/* [7:0] */

    int fog_r;				/* [7:0] */
    int fog_g;				/* [7:0] */
    int fog_b;				/* [7:0] */
    int fog_a;				/* [7:0] */

    int pixel_r;			/* [7:0] */
    int pixel_g;			/* [7:0] */
    int pixel_b;			/* [7:0] */
    int pixel_a;			/* [8:0] */

    int pixel_cvg;			/* [3:0], 1.3 */

    int shade_a;			/* [7:0] */

    int st_z;				/* [17:0], 15.3 */

    int dzdx;				/* [15:0], s0.15 */
    int dzdy;				/* [15:0], s0.15 */

    int prim_z;				/* [15:0] */
    int prim_delta_z;			/* [15:0] */

    int mem_r;				/* [7:0] */
    int mem_g;				/* [7:0] */
    int mem_b;				/* [7:0] */
    int mem_a;				/* [2:0] */
    int mem_z;				/* [17:0], float format:
					   [17:15] exponent, [14:4] mantissa, 
					   [3:0] delta_z 
					*/

  /* O U T P U T   signals (must be int) */

    int span_r;				/* [7:0] */
    int span_g;				/* [7:0] */
    int span_b;				/* [7:0] */
    int span_a;				/* [2:0] */
    int span_z;				/* [17:0] */
    int span_color_we;
    int span_depth_we;
    
  /* I N T E R N A L    registers */

    /*
     *  Blend Unit Page 1 Registers
     *
     *
     *
     */
    unsigned int cycle: 1;			/* clock -1 */

    unsigned int cycle_d1: 1;			/* clock 0 */
    unsigned int mode_p_r: 2;			/* clock 0 */
    unsigned int mode_m_r: 2;			/* clock 0 */
    unsigned int mode_a_r: 2;			/* clock 0 */
    unsigned int mode_b_r: 2;			/* clock 0 */
    
    unsigned int blended_r: 11;			/* clock 1, 0.11 */
    unsigned int blended_g: 11;			/* clock 1, 0.11 */
    unsigned int blended_b: 11;			/* clock 1, 0.11 */

    unsigned int denom: 4;			/* clock 1, 1.3 */

    unsigned int p_r: 8;			/* clock 1, 0.8 */
    unsigned int p_g: 8;			/* clock 1, 0.8 */
    unsigned int p_b: 8;			/* clock 1, 0.8 */

    unsigned int m_r: 8;			/* clock 1, 0.8 */
    unsigned int m_g: 8;			/* clock 1, 0.8 */
    unsigned int m_b: 8;			/* clock 1, 0.8 */

    unsigned int dividend_r: 8;			/* clock 2, 0.8 */
    unsigned int dividend_g: 8;			/* clock 2, 0.8 */
    unsigned int dividend_b: 8;			/* clock 2, 0.8 */

    unsigned int blended_r_d1: 8;		/* clock 2, 0.8 */
    unsigned int blended_g_d1: 8;		/* clock 2, 0.8 */
    unsigned int blended_b_d1: 8;		/* clock 2, 0.8 */

    unsigned int p_r_d1: 8;			/* clock 2, 0.8 */
    unsigned int p_g_d1: 8;			/* clock 2, 0.8 */
    unsigned int p_b_d1: 8;			/* clock 2, 0.8 */

    unsigned int m_r_d1: 8;			/* clock 2, 0.8 */
    unsigned int m_g_d1: 8;			/* clock 2, 0.8 */
    unsigned int m_b_d1: 8;			/* clock 2, 0.8 */

    unsigned int force_blend_d1: 1;		/* clock 3 */
    int pixel_a_d1;				/* for 2nd cycle of 2 cycle mode */
    int pixel_cvg_d2: 4;			/* for 2nd cycle of 2 cycle mode */

    /*
     *  Blend Unit Page 2 Registers
     *
     *
     *
     */
    unsigned int pixel_cvg_d1: 4;		/* clock 1, 1.3 */
    unsigned int mem_a_d1: 3;			/* clock 1, 0.3 */

    unsigned int zcvg: 4;			/* clock 2, 1.3 */
    unsigned int cvg_wrap: 1;			/* clock 2 */
    unsigned int mem_a_d2: 3;			/* clock 2 */

    /*
     *  Blend Unit Page 3 Registers
     *
     *
     *
     */
    unsigned int norm_a: 4;			/* clock 0 */
    unsigned int norm_b: 4;			/* clock 0 */

    unsigned int new_dz_d1: 16;			/* clock 0 */
    unsigned int new_z: 18;			/* clock 0 */
    unsigned int mem_z_d1: 18;			/* clock 0 */
    unsigned int mem_dz_d1: 16;			/* clock 0 */

    unsigned int z_source_d1;			/* clock 1 */
    unsigned int new_dz_d2: 16;			/* clock 1 */
    unsigned int delta_z: 4;			/* clock 1 */
    unsigned int old_z: 18;			/* clock 1 */

    unsigned int max_z: 1;			/* clock 1 */
    unsigned int farther: 1;			/* clock 1 */
    unsigned int nearer: 1;			/* clock 1 */
    unsigned int in_front: 1;			/* clock 1 */

    unsigned int blend_en: 1;			/* clock 2 */
    unsigned int span_color_we_m1: 1;		/* clock 2 */


} bl_t;




/*
 *  Prototypes
 */

void bl(bl_t **pp0, bl_t **pp1);
void bl_init(bl_t *p0, bl_t *p1);

#endif /* BL_UNIT_INCLD */