Arithmetic in Verilog
unsigned + unsigned = unsigned
1 | function [7:0] satadd_uuu8b; // unsigned + unsigned = unsigned |
1'b1
: overflow
signed + signed = signed
1 | function [7:0] satadd_sss8b; // signed + signed = signed |
2'b01
: overflow
2'b10
: underflow
signed + unsigned = unsigned
1 | function [7:0] satadd_suu8b; // signed + unsigned = unsigned |
signed + unsigned = signed
1 | function signed [7:0] satop_sus8b; //signed +/- unsigned = signed |