DirectC: C layer - support for bit and part selects


Subject: DirectC: C layer - support for bit and part selects
From: Andrzej Litwiniuk (Andrzej.Litwiniuk@synopsys.com)
Date: Tue Dec 10 2002 - 14:16:48 PST


Team,

DirectC C layer is continued hereon.

Although I think that the put/get functionality provided for 'bit' and 'logic'
packed arrays is sufficient yet basic, I agree that it requires unnecessary
copying of the whole packed array when perhaps only some bits are needed.

So it makes sense to add a support for bit selects and part-selects, what
should add to the convenience and improve performance at the same time.

Functions for part-select allow to access (read/write) only a narrow subranges
of up to 32 bits. A canonical representation will be used for such narrow
vectors.

For the sake of symmetry a single chunk of an array in the canonical
representation is used both for 'logic' and 'bit'.
One may argue, however, that in the case of 'bit' such small vector
is actually a single int, so perhaps a more intuitive signature could be
used.

Several new definitions are added to "sverilog.h" file; in the text below
those definitions are interspersed with comments and remarks.
Again, all names are provisional and subject to discussion and improvment.

/* common type for 'bit' and 'logic' scalars.
   Shall we rather have two separate types, say, svScalarBit, svScalarLogic?
 */
typedef unsigned char svScalar;

/* functions for bit-select and limited width part-select */

/* Packed arrays are assumed to be indexed n-1:0,
   where 0 is the index of least significant bit */

/* functions for bit-select */
/* s=source, d=destination, i=bit-index */

svScalar svGetSelectBit(svBitPackedArr s, int i);
svScalar svGetSelectLogic(svLogicPackedArr s, int i);

void svPutSelectBit(svBitPackedArr d, int i, scalar s);
void svPutSelectLogic(svLogicPackedArr d, int i, scalar s);

/*
 * functions for part-select
 *
 * a narrow (<=32 bits) part select is copied between
 * the implementation representation and a single chunk of
 * canonical representation
 *
 * s=source, d=destination, i=starting bit index, w=width
 * like for variable part selects; limitations: w <= 32
 */

Please note that for the sake of symmetry a canonical representation
(i.e. an array) is used both for 'bit' and 'logic', though a simpler
int could be used for 'bit' part selects <= 32-bit.

void svGetPartSelectBit(svBitVec32* d, svBitPackedArr s, int i, int w);
void svPartGetSelectLogic(svLogicVec32* d, svLogicPackedArr s, int i, int w);

/*
 * for 'bit' type a part select <= 32-bit is really an int
 * so a function could be used:
 * int svGetPartSelectBit(svBitPackedArr s, int i, int w);
 */

void svPutPartSelectBit(svBitPackedArr d, svBitPackedArr s, int i, int w);
void svPutPartSelectLogic(svLogicPackedArr d, svLogicPackedArr s, int i, int w);

/*
 * for 'bit' type a part select <= 32-bit is really an int
 * so simpler arg could be used:
 * svPutPartSelectBit(svBitPackedArr d, int up_to_32-bits, int i, int w);
 */

----------------------------------------------

Regards,
Andrzej



This archive was generated by hypermail 2b28 : Tue Dec 10 2002 - 14:19:24 PST