Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/Operation/src/Operation.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/Operation/src/Operation.cpp	(revision 81)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/Operation/src/Operation.cpp	(revision 88)
@@ -8,14 +8,5 @@
 
 #include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/Operation/include/Operation.h"
-
-#define neg(data)                  (~(data)+1)
-#define sign(data)                 ((data)>>(param->_size_data-1))
-#define unsigned(data)             (data)
-#define signed(data)               ((sign(data)==0)?(data):neg(data))
-#define ovf(op1, op2, res)         ((sign(op1) == sign(op2))?(sign(op1) xor sign(res)):0)
-#define carry(op1, op2, res)       (((res)<(op1)) or ((res)<(op2)))
-#define set_flag(data,flag,is_set) (((is_set)==1)?((data)|(flag)):((data)&~(flag)))
-#define get_flag(data,flag)	   (((data)&(flag))!=0)
-#define concatenation_bool(a,b)    (((a)<<1) | (b))
+#include "Behavioural/include/Operation.h"
 
 namespace morpheo                    {
@@ -43,11 +34,11 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_add");
 
-    Tgeneral_data_t gpr1      = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2      = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1      = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2      = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     
     Tgeneral_data_t gpr3      = param->_mask_data & (gpr1 + gpr2);
 
-    bool            overflow  = ovf  (gpr1,gpr2,gpr3);
-    bool            carry_out = carry(gpr1,gpr2,gpr3);
+    bool            overflow  = ovf  (param->_size_data,gpr1,gpr2,gpr3);
+    bool            carry_out = carry(param->_size_data,gpr1,gpr2,gpr3);
 
     // Result
@@ -70,10 +61,10 @@
     Tgeneral_data_t carry_in   = get_flag(op->_data_rc,FLAG_CY);
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = param->_mask_data & (gpr1 + gpr2 + carry_in);
 
-    bool            overflow   = ovf  (gpr1,gpr2,gpr3);
-    bool            carry_out  = carry(gpr1,gpr2,gpr3);
+    bool            overflow   = ovf  (param->_size_data,gpr1,gpr2,gpr3);
+    bool            carry_out  = carry(param->_size_data,gpr1,gpr2,gpr3);
 
     // Result
@@ -94,10 +85,10 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sub");
 
-    Tgeneral_data_t gpr1      =     unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2      = neg(unsigned(op->_data_rb));
+    Tgeneral_data_t gpr1      =                       unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2      = neg(param->_size_data,unsigned(param->_size_data,op->_data_rb));
     Tgeneral_data_t gpr3      = param->_mask_data & (gpr1 + gpr2);
 
-    bool            overflow  = ovf  (gpr1,gpr2,gpr3);
-    bool            carry_out = carry(gpr1,gpr2,gpr3);
+    bool            overflow  = ovf  (param->_size_data,gpr1,gpr2,gpr3);
+    bool            carry_out = carry(param->_size_data,gpr1,gpr2,gpr3);
 
     // Result
@@ -118,6 +109,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_and");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = (gpr1 & gpr2);
 
@@ -137,6 +128,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_or");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = (gpr1 | gpr2);
 
@@ -156,6 +147,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_xor");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = (gpr1 ^ gpr2);
 
@@ -175,5 +166,5 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_movhi");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_immediat);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_immediat);
     Tgeneral_data_t gpr2       = param->_mask_data & (gpr1<<16);
 
@@ -195,6 +186,6 @@
     Tgeneral_data_t f_in       = get_flag(op->_data_rc,FLAG_F);
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned(op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,op->_data_rb);
     Tgeneral_data_t gpr3       = ((f_in==0)?gpr2:gpr1);
 
@@ -215,5 +206,5 @@
 
     Tgeneral_data_t f_in       = get_flag(op->_data_rc,FLAG_F);
-    Tgeneral_data_t imm        = unsigned(op->_immediat);
+    Tgeneral_data_t imm        = unsigned(param->_size_data,op->_immediat);
 
     // Result
@@ -233,5 +224,5 @@
 
     Tgeneral_data_t f_in       = get_flag(op->_data_rc,FLAG_F);
-    Tgeneral_data_t imm        = unsigned(op->_immediat);
+    Tgeneral_data_t imm        = unsigned(param->_size_data,op->_immediat);
 
     // Result
@@ -254,6 +245,6 @@
 
 
-    Tgeneral_data_t gpr        = unsigned(op->_data_rb);
-    Tgeneral_data_t imm        = unsigned(op->_immediat);
+    Tgeneral_data_t gpr        = unsigned(param->_size_data,op->_data_rb);
+    Tgeneral_data_t imm        = unsigned(param->_size_data,op->_immediat);
 
     // Result
@@ -272,6 +263,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_extend_s");
 
-    Tgeneral_data_t imm        = unsigned(op->_immediat);
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
+    Tgeneral_data_t imm        = unsigned(param->_size_data,op->_immediat);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
     Tgeneral_data_t gpr2       = extend<Tgeneral_data_t>(param->_size_data, gpr1, true , imm);
 
@@ -291,6 +282,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_extend_z");
 
-    Tgeneral_data_t imm        = unsigned(op->_immediat);
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
+    Tgeneral_data_t imm        = unsigned(param->_size_data,op->_immediat);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
     Tgeneral_data_t gpr2       = extend<Tgeneral_data_t>(param->_size_data, gpr1, false , imm);
 
@@ -310,6 +301,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sll");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = shift_logic_left<Tgeneral_data_t>(param->_size_data, gpr1, gpr2);
 
@@ -329,6 +320,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_srl");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = shift_logic_right<Tgeneral_data_t>(param->_size_data, gpr1, gpr2);
 
@@ -348,6 +339,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sra");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = shift_arithmetic_right<Tgeneral_data_t>(param->_size_data, gpr1, gpr2);
 
@@ -367,6 +358,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_ror");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = param->_mask_shift & unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     Tgeneral_data_t gpr3       = rotate_right<Tgeneral_data_t>(param->_size_data, gpr1, gpr2);
 
@@ -386,5 +377,5 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_ff1");
 
-    Tgeneral_data_t gpr        = unsigned(op->_data_ra);
+    Tgeneral_data_t gpr        = unsigned(param->_size_data,op->_data_ra);
     Tgeneral_data_t index;
 
@@ -406,5 +397,5 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_fl1");
 
-    Tgeneral_data_t gpr        = unsigned(op->_data_ra);
+    Tgeneral_data_t gpr        = unsigned(param->_size_data,op->_data_ra);
     Tgeneral_data_t index;
 
@@ -426,6 +417,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sfeq");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
 
     bool            f_out      = (gpr1 == gpr2);
@@ -446,6 +437,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sfne");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
 
     bool            f_out      = (gpr1 != gpr2);
@@ -466,6 +457,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sfgeu");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
 
     bool            f_out      = (gpr1 >= gpr2);
@@ -486,6 +477,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sfgtu");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
 
     bool            f_out      = (gpr1 >  gpr2);
@@ -506,6 +497,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sfleu");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
 
     bool            f_out      = (gpr1 <= gpr2);
@@ -526,6 +517,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_sfltu");
 
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
 
     bool            f_out      = (gpr1 <  gpr2);
@@ -549,16 +540,16 @@
     Tgeneral_data_t gpr2       =   (op->_has_immediat==1)?op->_immediat:op->_data_rb;
     
-    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_ra  : %.8x",unsigned(op->_data_ra));
-    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_ras : %.8x",  signed(op->_data_ra));
-    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_rb  : %.8x",unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb));
-    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_rbs : %.8x",  signed((op->_has_immediat==1)?op->_immediat:op->_data_rb));
+    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_ra  : %.8x",unsigned(param->_size_data,op->_data_ra));
+    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_ras : %.8x",  signed(param->_size_data,op->_data_ra));
+    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_rb  : %.8x",unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb));
+    log_printf(TRACE,Functionnal_unit,FUNCTION," * data_rbs : %.8x",  signed(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb));
     
     bool            f_out;
 
-    switch (concatenation_bool(sign(gpr1),sign(gpr2)))
+    switch (concatenation_bool(sign(param->_size_data,gpr1),sign(param->_size_data,gpr2)))
       {
       case 1 /*b01*/ : f_out = 1                               ; break;
       case 2 /*b10*/ : f_out = 0                               ; break;
-      default        : f_out = signed(gpr1) >= signed(gpr2); break;
+      default        : f_out = signed(param->_size_data,gpr1) >= signed(param->_size_data,gpr2); break;
       }
 
@@ -585,9 +576,9 @@
     bool            f_out;
 
-    switch (concatenation_bool(sign(gpr1),sign(gpr2)))
+    switch (concatenation_bool(sign(param->_size_data,gpr1),sign(param->_size_data,gpr2)))
       {
       case 1 /*b01*/ : f_out = 1; break;
       case 2 /*b10*/ : f_out = 0; break;
-      default        : f_out = signed(gpr1) >  signed(gpr2); break;
+      default        : f_out = signed(param->_size_data,gpr1) >  signed(param->_size_data,gpr2); break;
       }
 
@@ -612,9 +603,9 @@
     bool            f_out;
 
-    switch (concatenation_bool(sign(gpr1),sign(gpr2)))
+    switch (concatenation_bool(sign(param->_size_data,gpr1),sign(param->_size_data,gpr2)))
       {
       case 1 /*b01*/ : f_out = 0; break;
       case 2 /*b10*/ : f_out = 1; break;
-      default        : f_out = signed(gpr1) <= signed(gpr2); break;
+      default        : f_out = signed(param->_size_data,gpr1) <= signed(param->_size_data,gpr2); break;
       }
     
@@ -639,9 +630,9 @@
     bool            f_out;
 
-    switch (concatenation_bool(sign(gpr1),sign(gpr2)))
+    switch (concatenation_bool(sign(param->_size_data,gpr1),sign(param->_size_data,gpr2)))
       {
       case 1 /*b01*/ : f_out = 0; break;
       case 2 /*b10*/ : f_out = 1; break;
-      default        : f_out = signed(gpr1) <  signed(gpr2); break;
+      default        : f_out = signed(param->_size_data,gpr1) <  signed(param->_size_data,gpr2); break;
       }
 
@@ -661,7 +652,7 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_mtspr");
 
-    Tgeneral_data_t imm        = unsigned(op->_immediat);
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2       = unsigned(op->_data_rb);
+    Tgeneral_data_t imm        = unsigned(param->_size_data,op->_immediat);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2       = unsigned(param->_size_data,op->_data_rb);
     Tgeneral_data_t addr       = range<Tgeneral_data_t>(gpr1|imm,16);
 
@@ -694,5 +685,5 @@
     else
       {
-	exception = EXCEPTION_ALU_SPR_ACCESS_NOT_COMPLETE;
+	exception = EXCEPTION_ALU_SPR_ACCESS_MUST_WRITE;
       }
     
@@ -712,6 +703,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_mfspr");
 
-    Tgeneral_data_t imm        = unsigned(op->_immediat);
-    Tgeneral_data_t gpr1       = unsigned(op->_data_ra);
+    Tgeneral_data_t imm        = unsigned(param->_size_data,op->_immediat);
+    Tgeneral_data_t gpr1       = unsigned(param->_size_data,op->_data_ra);
     Tgeneral_data_t gpr2       = 0;
     Tgeneral_data_t addr       = range<Tgeneral_data_t>(gpr1|imm,16);
@@ -745,5 +736,5 @@
     else
       {
-	exception = EXCEPTION_ALU_SPR_ACCESS_NOT_COMPLETE;
+	exception = EXCEPTION_ALU_SPR_ACCESS_MUST_READ;
       }
 
@@ -784,6 +775,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_mac");
 
-    Tgeneral_data_t gpr1 = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2 = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1 = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2 = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     uint64_t        temp = range<uint64_t>(gpr1 * gpr2, 32);
 
@@ -808,6 +799,6 @@
     log_printf(TRACE,Functionnal_unit,FUNCTION,"Operation : l_msb");
 
-    Tgeneral_data_t gpr1 = unsigned(op->_data_ra);
-    Tgeneral_data_t gpr2 = unsigned((op->_has_immediat==1)?op->_immediat:op->_data_rb);
+    Tgeneral_data_t gpr1 = unsigned(param->_size_data,op->_data_ra);
+    Tgeneral_data_t gpr2 = unsigned(param->_size_data,(op->_has_immediat==1)?op->_immediat:op->_data_rb);
     uint64_t        temp = range<uint64_t>(gpr1 * gpr2, 32);
 
