src_dmem.h 6.29 KB

/*
 * src_dmem.h
 *
 * This file lays out the DMEM usage for the RSP resampling task.
 *
 */

#ifndef _src_dmem_h_
#define _src_dmem_h_ 1

/*
 * usage of the 'eval' macro below implies that this code must pass
 * throught the 'm4' macro processor. The RSP assembler does this,
 * by default, but any C program including this might have trouble with this.
 * Protect them by defining the eval() macro...
 */
#ifdef _LANGUAGE_C
# ifndef eval
#    define eval(s)	(s)
# endif /* eval */
#endif /* _LANGUAGE_C */


/*
 * IMPORTANT NOTE:
 *
 * Many of the following fields require some alignment, for the ld/st to
 * work as efficiently as possible... Add this someday...
 *
 */


/*
 * Memory layout of DMEM:
 *
 * The strategy is to divide up DMEM into a bunch of known regions
 * that we can get to quickly to store/retrieve stuff.
 *
 *      -------------------------------------------------
 *      | useful constants:			        |
 *	|                                               |
 *	|                                               |
 *	|                                               |
 *	|                                               |
 *	|                                               |
 *	|-----------------------------------------------|
 *	| sinc table                   1024 bytes       |
 *	|                                               |
 *      |-----------------------------------------------|
 *	| current buffer of input sound data            |
 *      |                	       1024 bytes       |
 *	|                                               |
 *	|-----------------------------------------------|
 *	| current buffer of output sound data           |
 *      |                	       1024 bytes       |
 *	|                                               |
 *	|-----------------------------------------------|
 * 
 */

/*
 * Memory addressing Strategy:
 *
 * We'll probably always keep the base address of DMEM around in
 * a register. We'll define all the fixed areas as offsets from
 * there. We'll also try to keep things clean and flexible as they
 * _will_ change during development.
 *
 */

#ifndef DCACHEBASE
#   define DCACHEBASE	0x00000000
#endif

#ifndef DCACHEBASEHI
#   define DCACHEBASEHI	0x0000
#endif
#ifndef DCACHEBASELO
#   define DCACHEBASELO	0x0000
#endif

/* these relate to the illustration above... */
#define BYTES_PER_SHORT           2
#define BYTES_PER_VECTOR         16
#define COEF_TAB_SIZE           256
#define SND_BUFF_SIZE           512
#define COEF_TAB_SIZEB          eval(COEF_TAB_SIZE * BYTES_PER_SHORT)
#define SND_BUFF_SIZEB          eval(SND_BUFF_SIZE * BYTES_PER_SHORT)

/* these relate to the illustration above... */
#define RSP_DATA_OFFSET		eval(0)
#define C_MULINC		eval(RSP_DATA_OFFSET)
#define C_ONE			eval(C_MULINC + BYTES_PER_VECTOR)
#define C_SHIFT			eval(C_ONE + BYTES_PER_VECTOR)
#define C_ZEROFOUR		eval(C_SHIFT + BYTES_PER_VECTOR)
#define C_ONEFIVE		eval(C_ZEROFOUR + BYTES_PER_VECTOR)
#define C_TWOSIX		eval(C_ONEFIVE + BYTES_PER_VECTOR)
#define C_THREESEVEN		eval(C_TWOSIX + BYTES_PER_VECTOR)
#define C_RAMP			eval(C_THREESEVEN + BYTES_PER_VECTOR)
#define NUM_OF_CONSTS		eval(RSP_DATA_OFFSET + C_RAMP + BYTES_PER_VECTOR)

/* FIXME: some state, which should go away eventually... */
#define ICA			eval(C_RAMP + BYTES_PER_VECTOR)
#define CPH			eval(ICA + BYTES_PER_VECTOR)
#define FCVOL			eval(CPH + BYTES_PER_VECTOR)
#define ICVOL			eval(FCVOL + BYTES_PER_VECTOR)

#define VT			eval(ICVOL + BYTES_PER_VECTOR)
#define VR			eval(VT + BYTES_PER_SHORT)
#define SND_PTR			eval(VR + BYTES_PER_SHORT)
#define COEF_PTR		eval(SND_PTR + BYTES_PER_SHORT)
#define PITCH			eval(COEF_PTR + BYTES_PER_SHORT)
#define PHCOUNT			eval(PITCH + BYTES_PER_SHORT)
#define OUTPUT_COUNT		eval(PHCOUNT + BYTES_PER_SHORT)
#define NUM_OF_CH_PARMS		eval(OUTPUT_COUNT - NUM_OF_CONSTS)

#define COEF_TAB		eval(PHCOUNT + BYTES_PER_SHORT + 4) /* needs alignment */
#define INPUT_SND_DATA		eval(COEF_TAB + (COEF_TAB_SIZE * BYTES_PER_SHORT))
#define OUTPUT_SND_DATA		eval(INPUT_SND_DATA + (SND_BUFF_SIZE * BYTES_PER_SHORT))
#define TOP_OF_DMEM		eval(OUTPUT_SND_DATA + (SND_BUFF_SIZE * BYTES_PER_SHORT))


/* During compilation, report an informative message about DMEM allocation: */
#ifdef _LANGUAGE_ASSEMBLY
#   define _DumpDMEMOffset(o,s)  errprint(#o	: eval(DCACHEBASE + (o), 16)	eval(s) )

     errprint(--------------------------------------------------------------------

)
    errprint(    substr(__FILE__, 3, eval(len(__FILE__)-4)) : Total DMEM Size Allocated is eval(TOP_OF_DMEM) bytes.
)
    errprint(    substr(__FILE__, 3, eval(len(__FILE__)-4)) : DMEM Map:

)

	     _DumpDMEMOffset(C_MULINC, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(C_ONE, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(C_SHIFT, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(C_ZEROFOUR, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(C_ONEFIVE, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(C_TWOSIX, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(C_THREESEVEN, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(C_RAMP, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(ICA, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(CPH, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(FCVOL, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(ICVOL, BYTES_PER_VECTOR)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(VT, BYTES_PER_SHORT)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(VR, BYTES_PER_SHORT)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(SND_PTR, BYTES_PER_SHORT)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(COEF_PTR, BYTES_PER_SHORT)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(PITCH, BYTES_PER_SHORT)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(PHCOUNT, BYTES_PER_SHORT)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(OUTPUT_COUNT, BYTES_PER_SHORT)
	     errprint(	bytes.
)
	     _DumpDMEMOffset(COEF_TAB, (COEF_TAB_SIZE * BYTES_PER_SHORT))
	     errprint(bytes.
)
	     _DumpDMEMOffset(INPUT_SND_DATA, (SND_BUFF_SIZE * BYTES_PER_SHORT))
	     errprint(bytes.
)
	     _DumpDMEMOffset(OUTPUT_SND_DATA, (SND_BUFF_SIZE * BYTES_PER_SHORT))
	     errprint(bytes.
)

     errprint(--------------------------------------------------------------------

)

#   undef _DumpDMEMOffset
#endif

#endif /* _src_dmem_h_ */