diff --git a/src/tmltranslator/ctranslator/BaseBuffer.java b/src/tmltranslator/ctranslator/BaseBuffer.java index 3f4345f4cb94b2ae78f247afe9955a72fc8704b3..ba0d6ac2f98021138b623d9af2c8de74fe2d0fea 100755 --- a/src/tmltranslator/ctranslator/BaseBuffer.java +++ b/src/tmltranslator/ctranslator/BaseBuffer.java @@ -74,4 +74,8 @@ public class BaseBuffer extends Buffer { } return s.toString(); } + + public String getContext() { + return Context; + } } //End of class diff --git a/src/tmltranslator/ctranslator/DataTransfer.java b/src/tmltranslator/ctranslator/DataTransfer.java index c4e19d02b5f48656db12085cc97b91abf51f3a1b..b6de85e33487da7cdc3d021ab4fe5a5c77345e94 100755 --- a/src/tmltranslator/ctranslator/DataTransfer.java +++ b/src/tmltranslator/ctranslator/DataTransfer.java @@ -158,6 +158,10 @@ public class DataTransfer { return s.toString().substring( 0, s.length() - 3 ); } + public String getContextName() { + return getTMLCPLib().getName() + "_ctx"; + } + public String toString() { StringBuffer s = new StringBuffer( "DATA TRANSFER " + name + "\n\t" ); diff --git a/src/tmltranslator/ctranslator/FepBuffer.java b/src/tmltranslator/ctranslator/FepBuffer.java index 8c42294e3b75b52770ea4ba9fa451e28b21b58ad..270d5963baa8671a33c3905e1ef809aaea035cd4 100755 --- a/src/tmltranslator/ctranslator/FepBuffer.java +++ b/src/tmltranslator/ctranslator/FepBuffer.java @@ -125,4 +125,8 @@ public class FepBuffer extends BaseBuffer { dataTypeValue = String.valueOf(( new Vector<String>( Arrays.asList( dataTypeList ))).indexOf( bufferParameters.get( dataTypeIndex ))); } } + + public String getContext() { + return Context; + } } //End of class diff --git a/src/tmltranslator/ctranslator/IntlOperationMEC.java b/src/tmltranslator/ctranslator/IntlOperationMEC.java index 75c4253f0f693f980e57e7a4fe9fdf3a9d19974a..59ad9e66f2e04b334ddf6c2dd35e4abd1b81ddc3 100644 --- a/src/tmltranslator/ctranslator/IntlOperationMEC.java +++ b/src/tmltranslator/ctranslator/IntlOperationMEC.java @@ -51,38 +51,38 @@ import java.util.*; public class IntlOperationMEC extends OperationMEC { - public IntlOperationMEC( String XOP, String ID0, String OD0, String BTC ) { + public IntlOperationMEC( String ctxName, String ID0, String OD0, String BTC ) { name = "InterleaverOperationMEC"; exec_code = TAB + "/*firm instruction*/" + CR + TAB + - "fep_set_qx(&" + XOP + ", ((FEP_BUFF_TYPE*)sig[" + ID0 + "].pBuff)->q);" + CR + TAB + + "fep_set_qx(&" + ctxName + ", ((FEP_BUFF_TYPE*)sig[" + ID0 + "].pBuff)->q);" + CR + TAB + "/*start execution*/" + CR + TAB + - "fep_start(&" + XOP + ");" + CR; + "fep_start(&" + ctxName + ");" + CR; - init_code ="/***** INIT " + XOP + "_ctx *******/" + CR + - "void init_" + XOP + "(void){" + CR + TAB + - "fep_ctx_init(&" + XOP + "_ctx, (uint64_t) /*USER TODO: value*/);" + CR + TAB + + init_code ="/***** INIT " + ctxName + " *******/" + CR + + "void init_" + ctxName + "(void){" + CR + TAB + + "fep_ctx_init(&" + ctxName + ", (uint64_t) /*USER TODO: value*/);" + CR + TAB + "// initialize context" + CR + TAB + - "fep_set_op(&" + XOP + "_ctx, FEP_OP_MOV);" + CR + TAB + + "fep_set_op(&" + ctxName + ", FEP_OP_MOV);" + CR + TAB + "// X vector configuration => Zk=Y[Xi]" + CR + TAB + - "fep_set_r(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_l(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_bx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_qx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_wx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_tx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_sx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_nx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_mx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_px(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_dx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_vrx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_vix(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_r(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_l(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_bx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_qx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_wx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_tx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_sx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_nx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_mx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_px(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_dx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_vrx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_vix(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + "// Operation configuration" + CR + TAB + - "fep_set_sma(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_qs(&" + XOP + "_ctx, ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->q);" + CR + TAB + - "fep_set_bs(&" + XOP + "_ctx, ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->b);" + CR + TAB + + "fep_set_sma(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_qs(&" + ctxName + ", ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->q);" + CR + TAB + + "fep_set_bs(&" + ctxName + ", ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->b);" + CR + TAB + "}" + CR; - cleanup_code = "fep_ctx_cleanup(&" + XOP + "_ctx);"; + cleanup_code = "fep_ctx_cleanup(&" + ctxName + ");"; } } //End of class diff --git a/src/tmltranslator/ctranslator/MMBuffer.java b/src/tmltranslator/ctranslator/MMBuffer.java index e36ab0a1384c11522643a33fee6f145148dc6521..2e0654d5d91b3ec52effa1ecf2b0d23f5ece8d37 100644 --- a/src/tmltranslator/ctranslator/MMBuffer.java +++ b/src/tmltranslator/ctranslator/MMBuffer.java @@ -102,4 +102,8 @@ public class MMBuffer extends BaseBuffer { baseAddressValue = bufferParameters.get( baseAddressIndex ); } } + + public String getContext() { + return Context; + } } //End of class diff --git a/src/tmltranslator/ctranslator/MappOperationMEC.java b/src/tmltranslator/ctranslator/MappOperationMEC.java index 365b1252a2d131882151b1ccf7d792507f9d4300..2169f141b803611a92096e797a84769e98d5a175 100644 --- a/src/tmltranslator/ctranslator/MappOperationMEC.java +++ b/src/tmltranslator/ctranslator/MappOperationMEC.java @@ -51,38 +51,38 @@ import java.util.*; public class MappOperationMEC extends OperationMEC { - public MappOperationMEC( String XOP, String ID0, String OD0, String BTC ) { + public MappOperationMEC( String ctxName, String ID0, String OD0, String BTC ) { name = "MapperOperationMEC"; exec_code = TAB + "/*firm instruction*/" + CR + TAB + - "fep_set_qx(&" + XOP + ", ((FEP_BUFF_TYPE*)sig[" + ID0 + "].pBuff)->q);" + CR + TAB + + "fep_set_qx(&" + ctxName + ", ((FEP_BUFF_TYPE*)sig[" + ID0 + "].pBuff)->q);" + CR + TAB + "/*start execution*/" + CR + TAB + - "fep_start(&" + XOP + ");" + CR; + "fep_start(&" + ctxName + ");" + CR; - init_code ="/***** INIT " + XOP + "_ctx *******/" + CR + - "void init_" + XOP + "(void){" + CR + TAB + - "fep_ctx_init(&" + XOP + "_ctx, (uint64_t) /*USER TODO: value*/);" + CR + TAB + + init_code ="/***** INIT " + ctxName + " *******/" + CR + + "void init_" + ctxName + "(void){" + CR + TAB + + "fep_ctx_init(&" + ctxName + ", (uint64_t) /*USER TODO: value*/);" + CR + TAB + "// initialize context" + CR + TAB + - "fep_set_op(&" + XOP + "_ctx, FEP_OP_MOV);" + CR + TAB + + "fep_set_op(&" + ctxName + ", FEP_OP_MOV);" + CR + TAB + "// X vector configuration => Zk=Y[Xi]" + CR + TAB + - "fep_set_r(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_l(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_bx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_qx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_wx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_tx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_sx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_nx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_mx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_px(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_dx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_vrx(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_vix(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_r(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_l(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_bx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_qx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_wx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_tx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_sx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_nx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_mx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_px(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_dx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_vrx(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_vix(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + "// Operation configuration" + CR + TAB + - "fep_set_sma(&" + XOP + "_ctx, (uint64_t) /* USER TODO: value */);" + CR + TAB + - "fep_set_qs(&" + XOP + "_ctx, ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->q);" + CR + TAB + - "fep_set_bs(&" + XOP + "_ctx, ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->b);" + CR + TAB + + "fep_set_sma(&" + ctxName + ", (uint64_t) /* USER TODO: value */);" + CR + TAB + + "fep_set_qs(&" + ctxName + ", ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->q);" + CR + TAB + + "fep_set_bs(&" + ctxName + ", ((FEP_BUFF_TYPE*)sig[" + OD0 + "].pBuff)->b);" + CR + TAB + "}" + CR; - cleanup_code = "fep_ctx_cleanup(&" + XOP + "_ctx);"; + cleanup_code = "fep_ctx_cleanup(&" + ctxName + ");"; } } //End of class diff --git a/src/tmltranslator/ctranslator/MapperBuffer.java b/src/tmltranslator/ctranslator/MapperBuffer.java index c449ba928394c0d5a6b863b1597e944ab4f77922..d7429d39cbe583ab726db9604b0d01e3262e6111 100644 --- a/src/tmltranslator/ctranslator/MapperBuffer.java +++ b/src/tmltranslator/ctranslator/MapperBuffer.java @@ -133,4 +133,8 @@ public class MapperBuffer extends BaseBuffer { symmetricalValue = String.valueOf( ( new Vector<String>( Arrays.asList( symmetricalValues ))).indexOf( bufferParameters.get( symmetricalIndex ))); } } + + public String getContext() { + return Context; + } } //End of class diff --git a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java index ed47407f9c19011cb2e683b0277eb02bc81713c3..754340e863fc941a2d6d86c2cca5606e351734ec 100755 --- a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java +++ b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java @@ -685,6 +685,7 @@ public class TMLCCodeGeneration { private String buffersAndInstructionsDeclaration( boolean declaration ) { TMLTask xTask, fTask; + String ctxName; ArchUnitMEC taskMEC; Buffer inBuff, outBuff; StringBuffer buffersString = new StringBuffer( "/**** Buffers *****/" + CR ); @@ -696,35 +697,36 @@ public class TMLCCodeGeneration { fTask = op.getSDRTasks().get( Operation.F_TASK ); inBuff = op.getInBuffer(); outBuff = op.getOutBuffer(); + ctxName = op.getContextName(); if( declaration ) { if( inBuff == null ) { //for source operation - buffersString.append( "extern" + SP + outBuff.getType() + SP + outBuff.getName() + ";" + CR ); - instructionsString.append( "extern" + SP + outBuff.getContext() + SP + fTask.getTaskName() + "_ctx;" + CR ); + buffersString.append( "extern" + SP + outBuff.getType() + SP + outBuff.getName() + SC + CR ); + instructionsString.append( "extern" + SP + outBuff.getContext() + SP + ctxName + SC + CR ); } else { if( outBuff == null ) { //for sink operation - buffersString.append( "extern" + SP + inBuff.getType() + SP + inBuff.getName() + ";" + CR ); - instructionsString.append( "extern" + SP + inBuff.getContext() + SP + fTask.getTaskName() + "_ctx;" + CR ); + buffersString.append( "extern" + SP + inBuff.getType() + SP + inBuff.getName() + SC + CR ); + instructionsString.append( "extern" + SP + inBuff.getContext() + SP + ctxName + SC + CR ); } else { //for all the remaining operations - buffersString.append( "extern" + SP + inBuff.getType() + SP + inBuff.getName() + ";" + CR ); - instructionsString.append( "extern" + SP + inBuff.getContext() + SP + fTask.getTaskName() + "_ctx;" + CR ); + buffersString.append( "extern" + SP + inBuff.getType() + SP + inBuff.getName() + SC + CR ); + instructionsString.append( "extern" + SP + inBuff.getContext() + SP + ctxName + SC + CR ); } } } else { if( inBuff == null ) { //for source operation - buffersString.append( outBuff.getType() + SP + outBuff.getName() + ";" + CR ); - instructionsString.append( outBuff.getContext() + SP + fTask.getTaskName() + "_ctx;" + CR ); + buffersString.append( outBuff.getType() + SP + outBuff.getName() + SC + CR ); + instructionsString.append( outBuff.getContext() + SP + ctxName + SC + CR ); } else { if( outBuff == null ) { //for sink operation - buffersString.append( inBuff.getType() + SP + inBuff.getName() + ";" + CR ); - instructionsString.append( inBuff.getContext() + SP + fTask.getTaskName() + "_ctx;" + CR ); + buffersString.append( inBuff.getType() + SP + inBuff.getName() + SC + CR ); + instructionsString.append( inBuff.getContext() + SP + ctxName + SC + CR ); } else { //for all the remaining operations - buffersString.append( inBuff.getType() + SP + inBuff.getName() + ";" + CR ); - instructionsString.append( inBuff.getContext() + SP + fTask.getTaskName() + "_ctx;" + CR ); + buffersString.append( inBuff.getType() + SP + inBuff.getName() + SC + CR ); + instructionsString.append( inBuff.getContext() + SP + ctxName + SC + CR ); } } } @@ -734,26 +736,27 @@ public class TMLCCodeGeneration { for( DataTransfer dt: dataTransfersList ) { TMLCPLib tmlcplib = dt.getTMLCPLib(); CPMEC mec = tmlcplib.getCPMEC(); + ctxName = dt.getContextName(); if( mec instanceof CpuMemoryCopyMEC ) { if( declaration ) { - instructionsString.append( "extern" + SP + CpuMemoryCopyMEC.Context + SP + tmlcplib.getName() + "_ctx;" + CR ); + instructionsString.append( "extern" + SP + CpuMemoryCopyMEC.Context + SP + ctxName + SC + CR ); } - else { instructionsString.append( CpuMemoryCopyMEC.Context + SP + tmlcplib.getName() + "_ctx;" + CR ); } + else { instructionsString.append( CpuMemoryCopyMEC.Context + SP + ctxName + SC + CR ); } } if( mec instanceof SingleDmaMEC ) { if( declaration ) { - instructionsString.append( "extern" + SP + SingleDmaMEC.Context + SP + tmlcplib.getName() + "_ctx;" + CR ); + instructionsString.append( "extern" + SP + SingleDmaMEC.Context + SP + ctxName + SC + CR ); } else { - instructionsString.append( SingleDmaMEC.Context + SP + tmlcplib.getName() + "_ctx;" + CR ); + instructionsString.append( SingleDmaMEC.Context + SP + ctxName + SC + CR ); } } if( mec instanceof DoubleDmaMEC ) { if( declaration ) { - instructionsString.append( "extern" + SP + DoubleDmaMEC.Context + SP + tmlcplib.getName() + "_ctx;" + CR ); + instructionsString.append( "extern" + SP + DoubleDmaMEC.Context + SP + ctxName + SC + CR ); } else { - instructionsString.append( DoubleDmaMEC.Context + SP + tmlcplib.getName() + "_ctx;" + CR ); + instructionsString.append( DoubleDmaMEC.Context + SP + ctxName + SC + CR ); } } } @@ -820,7 +823,7 @@ public class TMLCCodeGeneration { scheduler.getCode() + CR + TAB + "cleanup_operations_context();" + CR + TAB + "cleanup_CPs_context();" + CR + TAB + - "return status;" + "}" + CR2 ); + "return status;" + CR + "}" + CR2 ); generateCodeForOperations(); generateCodeForCommunicationPatterns(); generateCodeToRegisterOperations(); @@ -994,9 +997,11 @@ public class TMLCCodeGeneration { String s; TMLCPLib tmlcplib; + String ctxName; for( DataTransfer dt: dataTransfersList ) { tmlcplib = dt.getTMLCPLib(); + ctxName = dt.getContextName(); if( tmlcplib.getArtifacts().size() == 1 ) { } programString.append( "int op_" + tmlcplib.getName() + "()\t{" + CR ); @@ -1006,15 +1011,15 @@ public class TMLCCodeGeneration { } CPMEC cpMEC = tmlcplib.getCPMEC(); if( cpMEC instanceof CpuMemoryCopyMEC ) { - CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( tmlcplib.getName() + "_ctx" ); + CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( ctxName ); programString.append( mec.getExecCode() ); } if( cpMEC instanceof SingleDmaMEC ) { - SingleDmaMEC mec = new SingleDmaMEC( tmlcplib.getName() + "_ctx" ); + SingleDmaMEC mec = new SingleDmaMEC( ctxName ); programString.append( mec.getExecCode() ); } if( cpMEC instanceof DoubleDmaMEC ) { - DoubleDmaMEC mec = new DoubleDmaMEC( tmlcplib.getName() + "_ctx" ); + DoubleDmaMEC mec = new DoubleDmaMEC( ctxName ); programString.append( mec.getExecCode() ); } @@ -1090,7 +1095,7 @@ public class TMLCCodeGeneration { private void generateInitFile( ArrayList<TMLTask> mappedTasks ) { String init_code = ""; - String XOD = ""; + String ctxName; initFileString.append( "#include \"" + applicationName + ".h\"" + CR2 ); initFileString.append( "/**** variables ****/" + CR2 /*+ "int g_r_size = 10240;" + CR + @@ -1111,41 +1116,41 @@ public class TMLCCodeGeneration { TMLTask fTask = op.getSDRTasks().get( Operation.X_TASK ); OperationMEC xTaskOperation = xTask.getOperationMEC(); OperationMEC fTaskOperation = fTask.getOperationMEC(); - XOD = xTask.getName().split("__")[1]; + ctxName = op.getContextName(); if( xTaskOperation instanceof CwpMEC ) { - CwpMEC cwp = new CwpMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + CwpMEC cwp = new CwpMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); init_code = cwp.getInitCode(); } else if( xTaskOperation instanceof CwmMEC ) { - CwmMEC cwm = new CwmMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + CwmMEC cwm = new CwmMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); init_code = cwm.getInitCode(); } else if( xTaskOperation instanceof CwaMEC ) { - CwaMEC cwa = new CwaMEC( XOD, xTask.getID0(), "", xTask.getOD0(), "" ); + CwaMEC cwa = new CwaMEC( ctxName, xTask.getID0(), "", xTask.getOD0(), "" ); init_code = cwa.getInitCode(); } else if( xTaskOperation instanceof CwlMEC ) { - CwlMEC cwl = new CwlMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + CwlMEC cwl = new CwlMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); init_code = cwl.getInitCode(); } else if( xTaskOperation instanceof SumMEC ) { - SumMEC sum = new SumMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + SumMEC sum = new SumMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); init_code = sum.getInitCode(); } else if( xTaskOperation instanceof FftMEC ) { - FftMEC fft = new FftMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + FftMEC fft = new FftMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); init_code = fft.getInitCode(); } else if( xTaskOperation instanceof IntlOperationMEC ) { - IntlOperationMEC intl = new IntlOperationMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + IntlOperationMEC intl = new IntlOperationMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); initFileString.append( intl.getInitCode() + CR ); } else if( xTaskOperation instanceof MappOperationMEC ) { - MappOperationMEC mapp = new MappOperationMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + MappOperationMEC mapp = new MappOperationMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); initFileString.append( mapp.getInitCode() + CR ); } else if( xTaskOperation instanceof AdaifOperationMEC ) { - AdaifOperationMEC adaif = new AdaifOperationMEC( XOD, xTask.getID0(), xTask.getOD0(), "" ); + AdaifOperationMEC adaif = new AdaifOperationMEC( ctxName, xTask.getID0(), xTask.getOD0(), "" ); initFileString.append( adaif.getInitCode() + CR ); } initFileString.append( init_code + CR ); @@ -1192,20 +1197,19 @@ public class TMLCCodeGeneration { for( Operation op: operationsList ) { if( op.getType() == Operation.SDR ) { TMLTask xTask = op.getSDRTasks().get( Operation.X_TASK ); - //TMLTask fTask = op.getSDRTasks().get( Operation.X_TASK ); - //OperationMEC xTaskOperation = xTask.getOperationMEC(); + ctxName = op.getContextName(); ArchUnitMEC xTaskArchMEC = tmap.getHwNodeOf( xTask ).getArchUnitMEC(); if( xTaskArchMEC instanceof FepMEC ) { - initFileString.append( TAB + FepMEC.Ctx_cleanup + "( &" + xTask.getTaskName() + "_ctx );" + CR ); + initFileString.append( TAB + FepMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR ); } if( xTaskArchMEC instanceof MapperMEC ) { - initFileString.append( TAB + MapperMEC.Ctx_cleanup + "( &" + xTask.getTaskName() + "_ctx );" + CR ); + initFileString.append( TAB + MapperMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR ); } if( xTaskArchMEC instanceof InterleaverMEC ) { - initFileString.append( TAB + InterleaverMEC.Ctx_cleanup + "( &" + xTask.getTaskName() + "_ctx );" + CR ); + initFileString.append( TAB + InterleaverMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR ); } if( xTaskArchMEC instanceof AdaifMEC ) { - initFileString.append( TAB + AdaifMEC.Ctx_cleanup + "( &" + xTask.getTaskName() + "_ctx );" + CR ); + initFileString.append( TAB + AdaifMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR ); } } } @@ -1214,14 +1218,15 @@ public class TMLCCodeGeneration { for( DataTransfer dt: dataTransfersList ) { TMLCPLib tmlcplib = dt.getTMLCPLib(); CPMEC cpMEC = tmlcplib.getCPMEC(); + ctxName = dt.getContextName(); if( cpMEC instanceof CpuMemoryCopyMEC ) { - initFileString.append( TAB + CpuMemoryCopyMEC.Ctx_cleanup + "( &" + tmlcplib.getName() + "_ctx );" + CR ); + initFileString.append( TAB + CpuMemoryCopyMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR ); } if( cpMEC instanceof SingleDmaMEC ) { - initFileString.append( TAB + SingleDmaMEC.Ctx_cleanup + "( &" + tmlcplib.getName() + "_ctx );" + CR ); + initFileString.append( TAB + SingleDmaMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR ); } if( cpMEC instanceof DoubleDmaMEC ) { - initFileString.append( TAB + DoubleDmaMEC.Ctx_cleanup + "( &" + tmlcplib.getName() + "_ctx );" + CR ); + initFileString.append( TAB + DoubleDmaMEC.Ctx_cleanup + "( &" + ctxName + " );" + CR ); } } initFileString.append( "}" + CR ); @@ -1232,19 +1237,20 @@ public class TMLCCodeGeneration { for( DataTransfer dt: dataTransfersList ) { TMLCPLib tmlcplib = dt.getTMLCPLib(); CPMEC cpMEC = tmlcplib.getCPMEC(); + String ctxName = dt.getContextName(); if( cpMEC instanceof CpuMemoryCopyMEC ) { initFileString.append( "void init_" + tmlcplib.getName() + "()\t{" + CR ); - CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( tmlcplib.getName() + "_ctx" ); + CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( ctxName ); initFileString.append( TAB + mec.getInitCode() + "}" + CR2 ); } if( cpMEC instanceof SingleDmaMEC ) { initFileString.append( "void init_" + tmlcplib.getName() + "()\t{" + CR ); - SingleDmaMEC mec = new SingleDmaMEC( tmlcplib.getName() + "_ctx" ); + SingleDmaMEC mec = new SingleDmaMEC( ctxName ); initFileString.append( TAB + mec.getInitCode() + "}" + CR2 ); } if( cpMEC instanceof DoubleDmaMEC ) { initFileString.append( "void init_" + tmlcplib.getName() + "()\t{" + CR ); - DoubleDmaMEC mec = new DoubleDmaMEC( tmlcplib.getName() + "_ctx" ); + DoubleDmaMEC mec = new DoubleDmaMEC( ctxName ); initFileString.append( TAB + mec.getInitCode() + "}" + CR2 ); } }