Is it possible to apply scale and offset to output?
I need to apply an offset and then scaling to the output of a matrix computation. Is it possible to do this? I know we can use the "acc_scale" parameter of gemmini_extended2_config_st, but is there a was to also apply an offset?
There's not a great method right now for applying a scalar offset. One way would be to replicate the scalar "offset" value into a vector, and then feed that vector into the accumulator before the accumulator contents are scaled.
Alternatively, there's a trickier solution if you really want a scalar offset, but it doesn't need to be 32-bits wide. We allow users to define exactly how their 32-bit "scale" is interpreted by the hardware. You could configure Gemmini such that 16 bits are used to specify the "scale", and the other 16 bits are used to specify the "offset". (Perhaps with an FP16 format?)
Then, you would change these lines in the config file to specify (in Chisel) exactly how the "scale" and "offset" portions are handled. Note that if you're using floating-point values, then you'll probably need to use a 3rd-party library like Hardfloat (as Gemmini already does), because Chisel doesn't have builtin FP support.