ameetgohil / signalflip-js

verilator testbench w/ Javascript using N-API
MIT License
18 stars 3 forks source link

BigInt for signals longer then 32bit #37

Closed drom closed 4 years ago

drom commented 4 years ago

In JavaScript the numbers wider than 32-bit can't be safely used with any bitwise operations.

JavaScript have BigInt type: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt

NodeJS 10.7+ and NAPI also has support https://nodejs.org/api/n-api.html#n_api_napi_create_bigint_words

BigInt type has an appropriate set of bitwise operators and clamp methods: asUintN, asIntN

ameetgohil commented 4 years ago

The latest version(v0.11.0 now makes all signals for width > 32 require BigInt)