crossroadsfpga / pigasus

100Gbps Intrusion Detection and Prevention System
663 stars 73 forks source link

Support pow (**) operator in Fluid VTL #13

Closed NAtre closed 2 years ago

NAtre commented 2 years ago

Adding support for the power () operator to Fluid. Currently, using in the RHS of a VTL expression doesn't translate to the right operand in the resulting SystemVerilog code. For instance, compiling HEAP_NUM_PRIORITIES = Param(HEAP_BITMAP_WIDTH ** 2) yields parameter HEAP_NUM_PRIORITIES = (HEAP_BITMAP_WIDTH + 2);. After this change: parameter HEAP_NUM_PRIORITIES = (HEAP_BITMAP_WIDTH ** 2);.

Testing:

PS: Looks like the compiler doesn't currently complain about unrecognized binary operands, but simply defaults to +. This might make it hard to distinguish actual RTL bugs from unimplemented compiler functionality (leading to, e.g., incorrect params). Perhaps we should just error out with a "File a bug" message instead?

zhipengzhaocmu commented 2 years ago

Looks good to me.

hsadok commented 2 years ago

Isn’t it better to throw a NotImplementedError when it doesn’t recognize the operator? I think it’s probably better to have the program crash than just assume + and move on.

sidsahay commented 2 years ago

Oops, yes I agree it should throw a NotImplementedError. I'll change it.