riscv / riscv-bitmanip

Working draft of the proposed RISC-V Bitmanipulation extension

Home Page:https://jira.riscv.org/browse/RVG-122

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bit 31 is always zero in these 64-bit test values (non-uniform random). Also - must these be nonnegative?

mjosaarinen opened this issue · comments

uint_xlen_t value = ((uint64_t)random() << 32) | random();

Bit 31 is always zero in these 64-bit test values. Also - must these be nonnegative?

@mjosaarinen

Bit 31 is always zero in these 64-bit test values

well spotted!
it appears that RAND_MAX is (2**31 - 1), therefore this function (random()) returns a number between 0x00000000 0x7FFFFFFF
could you look at creating a fix and issuing a PR ?

Also - must these be nonnegative?

I don't understand the question, this function should generate a value between 0 and (2**XLEN - 1)

thx
Lee

@eroom1966

.. could you look at creating a fix and issuing a PR ?

I'm not sure if I know how to test the testing thing as I've never used it, but sure I can try..

.. this function should generate a value between 0 and (2**XLEN - 1)

It creates a number between 0 and 2**(XLEN-1)-1. The sign bit is also always zero.

Well, it is a trivial bug to fix but unfortunately, I don't have the tooling available at the moment to test that everything works after the fix; so I suggest that someone else does it. Note that the missing bits at critical locations of stimulus words significantly lessens the coverage of this particular testing suite, so I'd suggest giving this some priority.