Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.fr
*
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package syscamstranslator;
import javax.swing.DefaultListModel;
* Class SysCAMSTBlockTDF
* Parameters of a SystemC-AMS block TDF
* Creation: 19/05/2018
* @version 1.0 19/05/2018
Rodrigo Cortes
committed
* @version 1.1 06/08/2018
* @author Rodrigo CORTES PORTO
*/
public class SysCAMSTBlockTDF extends SysCAMSTComponent {
Rodrigo Cortes
committed
private double period;
private DefaultListModel<String> listStruct;
private String nameTemplate;
private String typeTemplate;
private DefaultListModel<String> listTypedef;
private SysCAMSTCluster cluster;
private LinkedList<SysCAMSTPortTDF> portTDF;
private LinkedList<SysCAMSTPortConverter> portConverter;
Rodrigo Cortes
committed
private SysCAMSTPortConverter localPortConverter;
Rodrigo Cortes
committed
private int n;
Rodrigo Cortes
committed
private boolean isTimestepPropagated;
public SysCAMSTBlockTDF(String _name, double _period, String _time, String _processCode, String _constructorCode, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) {
listStruct = _listStruct;
nameTemplate = _nameTemplate;
typeTemplate = _typeTemplate;
portTDF = new LinkedList<SysCAMSTPortTDF>();
portConverter = new LinkedList<SysCAMSTPortConverter>();
Rodrigo Cortes
committed
n = 0;
Rodrigo Cortes
committed
isTimestepPropagated = false;
public String getName() {
return name;
}
Rodrigo Cortes
committed
public double getPeriod() {
Rodrigo Cortes
committed
public void setPeriod(double _period) {
period = _period;
}
public void setDynamic(Boolean _dynamic) {
public String getTime() {
return time;
}
public String getProcessCode() {
return processCode;
}
public String getConstructorCode() {
return constructorCode;
}
public DefaultListModel<String> getListStruct() {
return listStruct;
}
public String getNameTemplate() {
return nameTemplate;
}
public String getTypeTemplate() {
return typeTemplate;
}
public String getValueTemplate() {
return valueTemplate;
}
public DefaultListModel<String> getListTypedef() {
return listTypedef;
public SysCAMSTCluster getCluster() {
return cluster;
public LinkedList<SysCAMSTPortTDF> getPortTDF(){
return portTDF;
}
public void addPortTDF(SysCAMSTPortTDF tdf){
portTDF.add(tdf);
}
public LinkedList<SysCAMSTPortConverter> getPortConverter(){
return portConverter;
}
public void addPortConverter(SysCAMSTPortConverter converter){
portConverter.add(converter);
}
Rodrigo Cortes
committed
public boolean getIsTimestepPropagated() {
return isTimestepPropagated;
}
public void setIsTimestepPropagated() {
isTimestepPropagated = true;
}
Rodrigo Cortes
committed
public void syncTDFBlockDEBlock(double[] time_prev) throws SysCAMSValidateException {
double tp;
try{
//Order list to have input converter ports first, in case of multirate-multiport single-modules
localPortConverterList.clear();
Rodrigo Cortes
committed
for(int i = 0; i < portConverter.size(); i++) {
localPortConverter = portConverter.get(i);
if(localPortConverter.getOrigin() == 0) { //Input
localPortConverterList.addFirst(localPortConverter);
} else if (localPortConverter.getOrigin() == 1) { //Output
localPortConverterList.addLast(localPortConverter);
}
}
for(int i = 0; i < localPortConverterList.size(); i++) {
localPortConverter = localPortConverterList.get(i);
Rodrigo Cortes
committed
if(localPortConverter.getOrigin() == 0) { //Input
check_causality_in(time_prev);
} else if (localPortConverter.getOrigin() == 1) { //Output
check_causality_out(time_prev);
}
}
Rodrigo Cortes
committed
//Increase number of times block has been executed
n++;
Rodrigo Cortes
committed
} catch (SysCAMSValidateException se){
throw new SysCAMSValidateException(se.getMessage());
}
}
private void check_causality_in(double[] time_prev_max) throws SysCAMSValidateException {
Rodrigo Cortes
committed
double tm = 0.0;
double tp = 0.0;
Rodrigo Cortes
committed
int r = 1;
Rodrigo Cortes
committed
int d = 0;
int k = 1;
if(period > 0)
tm = period;
if(localPortConverter.getPeriod() > 0)
tp = localPortConverter.getPeriod();
if(localPortConverter.getRate() > 0)
r = localPortConverter.getRate();
if(localPortConverter.getDelay() > 0)
d = localPortConverter.getDelay();
Rodrigo Cortes
committed
/*if(time_now_min_tdf2 < time_prev_max[1]) {
localPortConverter.setDelay((int)Math.ceil((time_prev_max[1]-time_now_min_tdf2)/tp) + d);
Rodrigo Cortes
committed
localPortConverter.setRecompute(true);
Rodrigo Cortes
committed
throw new SysCAMSValidateException("Timestamp of previous write port executed module is: " + time_prev_max[1]
Rodrigo Cortes
committed
+ " and current timestamp is: " + time_now_min_tdf + ".\n"
+ "Suggested delay in port \"" + localPortConverter.getName() + "\" using time_now_min_tdf: " + (Math.ceil((time_prev_max[1]-time_now_min_tdf)/tp) + d)
+ " and using time_now_min_de: " + (Math.ceil((time_prev_max[1]-time_now_min_de)/tp) + d));
}*/
Rodrigo Cortes
committed
time_prev_max[0] = Double.valueOf(Math.max(time_prev_max[0],time_now_max_de));
}
private void check_causality_out(double[] time_prev_max) throws SysCAMSValidateException {
Rodrigo Cortes
committed
double tm = 0.0;
double tp = 0.0;
Rodrigo Cortes
committed
int r = 1;
Rodrigo Cortes
committed
int d = 0;
int k = 1;
if(period > 0)
tm = period;
if(localPortConverter.getPeriod() > 0)
tp = localPortConverter.getPeriod();
if(localPortConverter.getRate() > 0)
r = localPortConverter.getRate();
if(localPortConverter.getDelay() > 0)
d = localPortConverter.getDelay();
time_now_min_tdf = (n*tm)+((1-1)*tp)+(d*tp);
time_now_max_de2 = (n*tm)+((r-1)*tp)-(d*tp);
Rodrigo Cortes
committed
if(time_now_min_tdf < time_prev_max[0]) {
localPortConverter.setDelay((int)Math.ceil((time_prev_max[0]-time_now_min_tdf)/tp) + d);
Rodrigo Cortes
committed
localPortConverter.setRecompute(true);
Rodrigo Cortes
committed
throw new SysCAMSValidateException("Timestamp of previous read port executed module is: " + time_prev_max[0]
+ " and current timestamp is: " + time_now_min_tdf + ".\n"
+ "Suggested delay in port " + localPortConverter.getName() + ": " + (Math.ceil((time_prev_max[0]-time_now_min_tdf)/tp) + d));
Rodrigo Cortes
committed
}
time_prev_max[1] = Double.valueOf(Math.max(time_prev_max[1],time_now_max_de2));
Rodrigo Cortes
committed
}
Rodrigo Cortes
committed
public void setN(int _n) {
n = _n;
}