Subject: [sv-cc] Re: nitpick with svGetPartSelectBit() - svGetBits() ?
From: Stickley, John (john_stickley@mentorg.com)
Date: Mon Mar 17 2003 - 11:36:48 PST
Andrzej,
Comments embedded (johnS: prefix).
Andrzej Litwiniuk wrote:
> > I remember originally I think you had this function return
> > its value as the function return argument, then later decided
> > to pass its output by reference in the interest of symetry
> > with svGetSelectLogic().
> >
> > It would be really nice if this function could be part of
> > a C expression rather have to call it to store the result
> > in a temp variable then use the temp variable in the C
> > expression.
>
> John,
>
> I absolutely agree. What I'm not clear about is what a name should
> be used such that it would not confuse the user.
>
> What we need is a function:
>
> svBitVec32 get_bit_part_select(const svBitPackedArrRef s, int i, int w);
>
> and the issue is what should be its name. Another issue: should the
> procedure
> 'svGetPartSelectBit' be kept for the sake of mere symetry?
>
>
> > But in thinking about it, I think this symetric buys us very little
>
> Agree. If nobody objects, I'll remove the current version of
> svGetPartSelectBit,
> although we may want to keep the name with a different functionality.
>
> So, a dilemma seems to be as follows:
>
> 1) keep the same name 'svGetPartSelectBit'
> 2) use different name, say svGetBits, in order to avoid confusion:
> svBitVec32 svGetBits(const svBitPackedArrRef s, int i, int w);
>
>
> I suppose that cases of extracting 32 bits or 64 bits (in two chunks)
> may be
> pretty common. What would you think about adding two specialized functions
> just for those cases? Something like this:
>
> svBitVec32 svGet32Bits(const svBitPackedArrRef s, int i); // fixed
> width=32
> long long svGet64Bits(const svBitPackedArrRef s, int i); // width
> width=64
>
johnS:
This would be great. I like the addition of the 64 bit variant too.
I would have no objection to keeping svGetPartSelectBit() as is
if we can have these two additional functions on in addition to it.
> > This version,
> >
> > // imported C function:
> > void ReceivePacketHeader( svBitPackedArrRef etherHeader ){
> > svBitPackedArrRef etherHeaderHandle;
> >
> > // Unpack ether header:
> > long long dest_addr
> > = svGetPartSelectBit( etherHeader, 32, 32 ) |
> > (svGetPartSelectBit( etherHeader, 64, 16 ) << 32);
> > long long src_addr
> > = svGetPartSelectBit( etherHeader, 80, 32 ) |
> > (svGetPartSelectBit( etherHeader, 112, 16 ) << 32);
>
>
> Putting the main issue aside, shouldn't those pieces of a a long
> address be casted to 'long long' before performing shifting and or-ing?
johnS:
I think you're right about this. In my hastiness I left
the cast out.
__
______ | \
______________________/ \__ / \
\ H Dome ___/ |
John Stickley E | a __ ___/ / \____
Principal Engineer l | l | \ /
Verification Solutions Group | f | \/ ____
Mentor Graphics Corp. - MED C \ -- / /
17 E. Cedar Place a \ __/ / /
Ramsey, NJ 07446 p | / ___/
| / /
mailto:John_Stickley@mentor.com \ /
Phone: (201)818-2585 \ /
---------
This archive was generated by hypermail 2b28 : Mon Mar 17 2003 - 11:38:02 PST