PyHDI / veriloggen

Veriloggen: A Mixed-Paradigm Hardware Construction Framework
Apache License 2.0
306 stars 58 forks source link

Support for binary operations with _Numeric class in the right term #48

Closed sh-mug closed 1 year ago

sh-mug commented 1 year ago

When trying to perform a binary operation on an int variable and a Parameter variable:

m = Module('blinkled')
width = m.Parameter('WIDTH', 8)
a = m.Input('A', 32)
b = m.Output('B', width)
b.assign(a[32-width:32])

And I expected B to be assigned the following:

assign B = A[31:32-WIDTH];

But I got the following error.

TypeError: unsupported operand type(s) for -: 'int' and 'Parameter'

So I added support for binary operations with _Numeric class in the right term.