From d21f76cfd6b993bd0b75f91ca19136eaeaba5284 Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paris.fr>
Date: Fri, 25 Mar 2022 15:29:00 +0100
Subject: [PATCH] Resolving bug on passive delay

---
 simulators/c++2/src_simulator/app/TMLDelayCommand.cpp         | 2 +-
 .../tmltranslator/tomappingsystemc2/MappedSystemCTask.java    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/simulators/c++2/src_simulator/app/TMLDelayCommand.cpp b/simulators/c++2/src_simulator/app/TMLDelayCommand.cpp
index ce22bd8fea..27d254ab96 100644
--- a/simulators/c++2/src_simulator/app/TMLDelayCommand.cpp
+++ b/simulators/c++2/src_simulator/app/TMLDelayCommand.cpp
@@ -47,7 +47,7 @@ TMLDelayCommand::TMLDelayCommand(ID iID, TMLTask* iTask,TMLLength iStatLength, A
 	if (!isActiveDelay){
 	    _isActiveDelay = false;
 	}else {
-	    _length = iStatLength;
+	  //_length = iStatLength;
 	    _isActiveDelay = true;
 	}
 	_type=ACT;
diff --git a/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java b/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java
index c9007790bd..0c0d7a9d1b 100644
--- a/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java
+++ b/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java
@@ -561,7 +561,7 @@ public class MappedSystemCTask {
                         //action += "_endLastTransaction+=tmpDelayxy;"; // Take all delay totally idle for x units of time
                         action += "return tmpDelayxy;";
                     } else {
-                        action += "_endLastTransaction+=0;\nreturn 1;"; //consumes cycles
+                        action += "_endLastTransaction+=tmpDelayxy;\nreturn 1;"; //consumes cycles
                     }
 
                     delayLen = delay.getMaxDelay() + "*" + masterClockFreq + delay.getMasterClockFactor();
@@ -571,7 +571,7 @@ public class MappedSystemCTask {
                         //action += "_endLastTransaction+= myrand(tmpDelayxx,tmpDelayxy)"; // Take all delay totally idle for x units of time
                         action += "return myrand(tmpDelayxx,tmpDelayxy)";
                     } else {
-                        action += "_endLastTransaction+=0;\nreturn 1;"; //consumes cycles
+                        action += "_endLastTransaction+=tmpDelayxy;\nreturn 1;"; //consumes cycles
                     }
                     java.util.Random r = new  java.util.Random();
                     delayLen = String.valueOf(r.nextInt(Integer.valueOf(delay.getMaxDelay())-Integer.valueOf(delay.getMinDelay())) + Integer.valueOf(delay.getMinDelay())) + "*" + masterClockFreq + delay.getMasterClockFactor();
-- 
GitLab