[Libre-soc-dev] clamping/saturation semantics

Hendrik Boom hendrik at topoi.pooq.com
Sat Dec 12 16:55:16 GMT 2020


On Sat, Dec 12, 2020 at 06:33:57PM +0200, Lauri Kasanen wrote:
> On Sat, 12 Dec 2020 10:53:34 +0000
> Luke Kenneth Casson Leighton <lkcl at lkcl.net> wrote:
> 
> > also should op be always done at src width?
> >
> > in SV spec it states ops to be done at dest width.  clearly not for
> > sat ops.  which has me wondering if all ops should be done at
> > srcwidth.
> >
> > including FP.
> 
> All ops should be done "as if" they were done at srcwidth. This means
> all results will be correct, but the hw can optimize and go faster in
> some cases.
> 
> Ex: u16+u16=u8 can be done at 8-bit width and the result is still
> correct.
> 
> But s16-s16=s8 cannot. Consider 1-256 - if that op was done at 8-bit
> width, it would become 1-0=1. When the correct result is -255 (0xfeff),

Would the correct result not be 0xff01 ?

-- hendrik

> which then gets chopped preserving sign to -1 (0xff).
> 
> - Lauri
> 
> _______________________________________________
> Libre-soc-dev mailing list
> Libre-soc-dev at lists.libre-soc.org
> http://lists.libre-soc.org/mailman/listinfo/libre-soc-dev



More information about the Libre-soc-dev mailing list