[Libre-soc-dev] clamping/saturation semantics

Jacob Lifshay programmerjake at gmail.com
Fri Dec 11 22:24:19 GMT 2020


On Fri, Dec 11, 2020, 14:22 Jacob Lifshay <programmerjake at gmail.com> wrote:

> Say you have gathered stuff to u16 and then want to scale that into
> u8, clamped. That's a u16 * u16 = u8 op - different src and dst
> elwidths.
>
>
I left out scaling for simplicity of understanding.

>
> I interpreted that as:
> u16 in1, in2;
> u64 a = in1;
> u64 b = in2;
> u64 prod = a * b;
> u8 out = min(0xFF, prod);
>
> note that the clamp size == the dest size.
>

Jacob

>


More information about the Libre-soc-dev mailing list