sylefeb / Silice

Silice is an easy-to-learn, powerful hardware description language, that simplifies designing hardware algorithms with parallelism and pipelines.
Other
1.28k stars 77 forks source link

Extracting bits from a bitfield results in a segmentation fault #243

Closed rob-ng15 closed 1 year ago

rob-ng15 commented 1 year ago

Using a bitfield,

bitfield fp64{ uint1 sign, uint11 exponent, uint52 fraction }

and trying to select a part of one of the fields results in a segmentation fault.

e.g.

fp64( a ).exponent[0,8] causes a segmentation fault, whereas a[52,8] (effectively the same), works.

Will not build: uint64 aRET <:: df ? a : { 32hffffffff, fp64( a ).sign, fp64( a ).exponent[0,8], fp64( a ).fraction[29,23] }; // RETURN a ( as double ) or a ( as float repacked )

Works, effectively selecting the same bits:

uint64 aRET <:: df ? a : { 32hffffffff, a[63,1], a[52,8], a[29,23] }; // RETURN a ( as double ) or a ( as float repacked )

Not too much of an issue, but does help with code readability.

sylefeb commented 1 year ago

Hi Rob, great catch, just pushed a fix. Thanks!

rob-ng15 commented 1 year ago

Cheers,

All seems to working fine. Nice quick fix, thank you!