From 19491ea0b532996d3ad57951681c39ad63ef1cd3 Mon Sep 17 00:00:00 2001 From: lucasng32 <60285534+lucasng32@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:46:49 +0800 Subject: [PATCH] #283 Fixed n bit NOT wrong bitwidth (#342) * Fix n bit NOT wrong bitwidth * Fix for 32 bit NOT * Fix n bit not mask * Fix bigint n bit NOT --- src/Renderer/Simulator/Fast/FastReduce.fs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Renderer/Simulator/Fast/FastReduce.fs b/src/Renderer/Simulator/Fast/FastReduce.fs index 056f2d889..8ee9d7d54 100644 --- a/src/Renderer/Simulator/Fast/FastReduce.fs +++ b/src/Renderer/Simulator/Fast/FastReduce.fs @@ -796,7 +796,12 @@ let fastReduce (maxArraySize: int) (numStep: int) (isClockedReduction: bool) (co putBigInt 0 res | NbitsNot numberOfBits, false -> let a = insUInt32 0 - let res = ~~~a + let w = comp.InputWidth 0 + let minusOne = (1u <<< w) - 1u + let res = + match w with + | 32 -> ~~~a + | _ -> minusOne &&& (~~~a) putUInt32 0 res | NbitsNot numberOfBits, true -> let a = insBigInt 0 @@ -804,8 +809,8 @@ let fastReduce (maxArraySize: int) (numStep: int) (isClockedReduction: bool) (co // BigWord (System.Numerics.BigInteger.op_OnesComplement a) FIX: 2^n-1-a let w = comp.InputWidth 0 // (bigint^w) - let (minusOne: bigint) = ((bigint 2) <<< w) - (bigint 1) - let res = minusOne - a + let mask = ((bigint 1) <<< w) - (bigint 1) + let res = mask - (a &&& mask) putBigInt 0 res | NbitSpreader numberOfBits, false ->