From 899061c6cf4153c27eff9b6498fafcd2e2639b16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Romain=20Bron=C3=A8s?= <romain.brones@synchrotron-soleil.fr>
Date: Wed, 31 May 2023 16:12:06 +0200
Subject: [PATCH] fix: Change register bitsize

* Matmul coefs are now on 24 bits (23 effectives)
* Round more after matmul to keep result on 32b
---
 hdl/pkg_corrmatrixpi.vhd | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hdl/pkg_corrmatrixpi.vhd b/hdl/pkg_corrmatrixpi.vhd
index 076fc67..deaac3d 100644
--- a/hdl/pkg_corrmatrixpi.vhd
+++ b/hdl/pkg_corrmatrixpi.vhd
@@ -26,14 +26,14 @@ package pkg_corr_matrixpi is
     constant C_N_MM_BPM         : natural := 122; -- number of bpm (matrix columns)
     constant C_N_MM_PSC         : natural := 100; -- number of psc (matrix lines)
 
-    constant C_W_MM_COEF        : natural := 18;
+    constant C_W_MM_COEF        : natural := 24;
 
-    constant C_W_MM_MULT        : natural := 42; -- C_W_OE+C_W_MM_COEF;
+    constant C_W_MM_MULT        : natural := 48; -- C_W_OE+C_W_MM_COEF;
     constant C_W_MM_IDCNT       : natural := 7;  -- natural(ceil(log2(real(C_N_MM_BPM))));
-    constant C_W_MM_ACCU        : natural := 49; -- C_W_MM_MULT+C_W_MM_IDCNT;
+    constant C_W_MM_ACCU        : natural := 55; -- C_W_MM_MULT+C_W_MM_IDCNT;
 
     constant C_N_MM_SAT         : natural := 0;
-    constant C_N_MM_RND         : natural := 17;
+    constant C_N_MM_RND         : natural := 23;
     constant C_W_MM             : natural := 32; --C_W_MM_ACCU-C_N_MM_SAT-C_N_MM_RND
 
     -- PI corrector
-- 
GitLab