intel / rohd

The Rapid Open Hardware Development (ROHD) framework is a framework for describing and verifying hardware in the Dart programming language.
https://intel.github.io/rohd-website
BSD 3-Clause "New" or "Revised" License
374 stars 67 forks source link

Issue #336: Added power functionality #356

Closed Sanchit-kumar closed 1 year ago

Sanchit-kumar commented 1 year ago

Description & Motivation

In SystemVerilog, power (a**b) is a useful function.

It would be nice to have a synthesizable Module and associated functions for generating hardware and SystemVerilog with powers as per issue #336

Testing

Added necessary test cases to test/logic_value_test.dart and test/math_test.dart

Documentation

Does the change require any updates to documentation? If so, where? Are they included?

Yes. Updated both README.md and doc/tutorials/chapter_2/00_basic_logic.md

Sanchit-kumar commented 1 year ago

Hi @mkorbel1

There is a test case where LogicValue.ofBigInt(BigInt.zero, width) for any width > 64 leads to throw an error in case of arithmetic +,-,* operations when applied to the same LogicValue. It throws an error only when both are valued zero.

E.g., LogicValue.ofBigInt(BigInt.zero, 128) + (LogicValue.ofBigInt(BigInt.zero, 128)) throws an error.

Can you please confirm if this is an issue or I misunderstood something. If it's an issue, we need to handle _FilledLogicValue with width>64 also for arithmetic operations.

mkorbel1 commented 1 year ago

There is a test case where LogicValue.ofBigInt(BigInt.zero, width) for any width > 64 leads to throw an error in case of arithmetic +,-,* operations when applied to the same LogicValue. It throws an error only when both are valued zero.

E.g., LogicValue.ofBigInt(BigInt.zero, 128) + (LogicValue.ofBigInt(BigInt.zero, 128)) throws an error.

Can you please confirm if this is an issue or I misunderstood something. If it's an issue, we need to handle _FilledLogicValue with width>64 also for arithmetic operations.

@Sanchit-kumar, yes this looks like a bug, thanks for raising it! I think this is a manifestation of #299 which is WIP being addressed in PR #319 (which has been WIP for a while, should probably poke on that). Your test case that reproduces the issue is pretty simple, so I'll make a note on that issue to suggest using that as an additional test case. Sorry you ran into this!