zxtd function

  • Thread starter sridhartv25@gmail.com
  • Start date
S

sridhartv25@gmail.com

Guest
Hello all,
What does this function do
I tried to understand its output I did not get it,
I cannot even understand its description in the docu.

Zero-extends the number represented by the rightmost specified number
of bits in the given integer.

Zero-extends the rightmost x_bits bits of x_number. Executes faster
than doing x_number<x_bits - 1:0>.

Cheers,
Sridhar.
 
sridhartv25@gmail.com wrote, on 01/23/09 07:00:
Hello all,
What does this function do
I tried to understand its output I did not get it,
I cannot even understand its description in the docu.

Zero-extends the number represented by the rightmost specified number
of bits in the given integer.

Zero-extends the rightmost x_bits bits of x_number. Executes faster
than doing x_number<x_bits - 1:0>.

Cheers,
Sridhar.
It does what it says. You need to think about an integer as being an array of
bits (called bit-fields in SKILL). Imagine (or try) this:

a=-1

This is (in binary) 32 1's (a twos-complement -1).

If I do:

zxtd(a 1) => 1
zxtd(a 2) => 3
zxtd(a 3) => 7
zxtd(a 8) => 255

then it effectively is like doing:

a&((1<<x)-1)

i.e. keeping just the x rightmost bits, and leaving the rest.

Or using:

a<7:0> => 255
a<1:0> => 3

Note you can use the <> syntax with an integer to pull out certain bit-fields.

So equivalent definitions are:

procedure(abZxtd1(a x)
a&((1<<x)-1)
)

or

; can't use a<x-1:0> because it gets interpreted as (a<x-1):0> and is then
; waiting for something after the final > sign. So use the equivalent
; bitfield function instead.
procedure(abZxtd2(a x)
bitfield(a x-1 0)
)

Is that clearer?

Regards,

Andrew.

--
Andrew Beckett
Senior Solution Architect - Cadence Design Systems Ltd (UK)
 
Thanks Andrew,
I got it now.
You are a hero in the skill language.

Cheers,
Sridhar.
 

Welcome to EDABoard.com

Sponsor

Back
Top