Commit 27b5c7bb authored by Daniela Genius's avatar Daniela Genius
Browse files

debut arborescence SystemC AMS translation

parent 832fab24
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
* Daniela Genius, Lip6, UMR 7606
*
* ludovic.apvrille AT enst.fr
* daniela.genius@lip6.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.
*/
/* * @version 1.0 07/07/2015
* @author Julien Henon, Daniela Genius */
package ddtranslatorSoclib;
import java.util.LinkedList;
import java.util.List;
public class AvatarddSpecification{
private List<AvatarComponent> components;
private List<AvatarConnector> connectors;
private List<AvatarMappedObject> mappedObjects;
private int nb_init = 0;
/*there are seven targets which are fixed but invisible to the user of the TTool deployment diagram) :
Targets on RAM0 :
the text segment (target 0)
the reset segment (target 1)
the data segment (target 2)
Other targets :
the simhelper segment (target 3)
the icu segment (target 4)
the timer segment (target 5)
the fdt segment (target 6)
There always is a RAM0, a TTY and an interconnect (Bus or VGMN or crossbar) otherwise an error message is printed
*/
/* initialization of counters, there are at least 6 targets */
int nb_target = 6;
int nb_mwmr_segments = 0;
public AvatarddSpecification( List<AvatarComponent> _components, List<AvatarConnector> _connectors, List<AvatarMappedObject> _mappedObjects, int _nb_target, int _nb_init){
components = _components ;
connectors = _connectors ;
mappedObjects = _mappedObjects ;
nb_target = _nb_target;
nb_init = _nb_init;
}
public List<AvatarComponent> getComponents(){
return components;
}
public List<AvatarConnector> getConnectors(){
return connectors;
}
public List<AvatarMappedObject> getMappedObjects(){
return mappedObjects;
}
public List<AvatarTask> getAllMappedTask(){
List<AvatarTask> tasks = new LinkedList<AvatarTask>();
for (AvatarMappedObject task : mappedObjects ) {
if (task instanceof AvatarTask) {
tasks.add((AvatarTask)task);
}
}
return tasks;
}
public LinkedList<AvatarChannel> getAllMappedChannels(){
LinkedList<AvatarChannel> channels = new LinkedList<AvatarChannel>();
for (AvatarMappedObject channel : mappedObjects )
{
if (channel instanceof AvatarChannel)
channels.add((AvatarChannel)channel);
}
return channels;
}
public LinkedList<AvatarTTY> getAllTTY(){
//int i=0;
LinkedList<AvatarTTY> ttys = new LinkedList<AvatarTTY>();
for (AvatarComponent tty : components )
{
if (tty instanceof AvatarTTY){
ttys.add((AvatarTTY)tty);
}
}
return ttys;
}
public LinkedList<AvatarCPU> getAllCPU(){
LinkedList<AvatarCPU> cpus = new LinkedList<AvatarCPU>();
for (AvatarComponent cpu : components )
{
if (cpu instanceof AvatarCPU){
cpus.add((AvatarCPU)cpu);
}
}
return cpus;
}
public List<AvatarRAM> getAllRAM(){
//int i=0;
List<AvatarRAM> rams = new LinkedList<AvatarRAM>();
for (AvatarComponent ram : components ) {
if (ram instanceof AvatarRAM){
rams.add((AvatarRAM)ram);
}
}
return rams;
}
public List<AvatarBus> getAllBus(){
LinkedList<AvatarBus> buss = new LinkedList<AvatarBus>();
for (AvatarComponent bus : components )
{
if (bus instanceof AvatarBus)
buss.add((AvatarBus)bus);
}
return buss;
}
public LinkedList<AvatarVgmn> getAllVgmn(){
LinkedList<AvatarVgmn> vgmns = new LinkedList<AvatarVgmn>();
for (AvatarComponent vgmn : components )
{
if (vgmn instanceof AvatarVgmn){
vgmns.add((AvatarVgmn)vgmn);
}
}
return vgmns;
}
public LinkedList<AvatarCrossbar> getAllCrossbar(){
LinkedList<AvatarCrossbar> crossbars = new LinkedList<AvatarCrossbar>();
//int i=0;
for (AvatarComponent crossbar : components )
{
//Currently, at least one crossbar -> clustered
if (crossbar instanceof AvatarCrossbar){
System.out.println("Clustered Interconnect found");
crossbars.add((AvatarCrossbar)crossbar);
//crossbar.setClusterIndex(i);
//i++;
}
}
return crossbars;
}
/* public LinkedList<AvatarBridge> getAllBridge(){
LinkedList<AvatarBridge> bridges = new LinkedList<AvatarBridge>();
for (AvatarComponent bridge : components )
{
if (bridges instanceof AvatarBridge){
bridges.add((AvatarBridge)bridge);
}
}
return bridges;
}*/
//Currently, we define 1 crossbar = 1 cluster
public int getNbClusters(){
return getAllCrossbar().size();
}
public List<AvatarCoproMWMR> getAllCoproMWMR(){
List<AvatarCoproMWMR> copros = new LinkedList<AvatarCoproMWMR>();
for (AvatarComponent copro : components )
{
if (copro instanceof AvatarCoproMWMR)
copros.add((AvatarCoproMWMR)copro);
}
return copros;
}
public int getNbCPU(){
return (getAllCPU()).size();
}
public int getNbTTY(){
return (getAllTTY()).size();
}
public int getNbRAM(){
return (getAllRAM()).size();
}
public int getNbBus(){
return (getAllBus()).size();
}
public int getNbVgmn(){
return (getAllVgmn()).size();
}
public int getNbCrossbar(){
return (getAllCrossbar()).size();
}
public int getNbCoproMWMR(){
return (getAllCoproMWMR()).size();
}
// for construction of the central interconnect
public int getNb_init(){
return nb_init ;
}
public int getNb_target(){
return nb_target;
}
// etc .....
}
/* 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 systemcamstranslator.toComponent;
import systemcamstranslator.*;
import systemcamstranslator.GenericTLMComponent;
import systemcamstranslator.SystemCamsSpecification;
import ddtranslatorSoclib.toTopCell.TopCellGenerator;
import myutil.Conversion;
import myutil.FileException;
import myutil.FileUtils;
import myutil.TraceManager;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
/**
* Daniela GENIUS
*/
public class ToComponent {
private final static int USEC = 0;
private final static int MSEC = 1;
private final static int SEC = 2;
private final static String UNUSED_ATTR = "__attribute__((unused))";
private final static String GENERATED_PATH = "generated_component" + File.separator;
// private final static String UNKNOWN = "UNKNOWN";
private final static String CR = "\n";
private final static String CR2 = "\n\n";
public static SystemCamsSpecification spec ;
private Vector<?> warnings;
private MainFileSoclib mainFile;
private Vector<ComponentFiles> ComponentFiles;
private String makefile_src;
private String makefile_SocLib;
private int timeUnit;
private boolean debug;
private boolean tracing;
private boolean includeUserCode = true;
public ToComponent(SystemCamsSpecification spec) {
spec = _spec;
componentFiles = new Vector<ComponentFiles>();
}
public void setTimeUnit(int _timeUnit) {
timeUnit = _timeUnit;
}
public void includeUserCode(boolean _inc) {
includeUserCode = _inc;
}
public static String getGeneratedPath() {
return GENERATED_PATH;
}
public void saveInFiles(String path) throws FileException {
System.err.println("ok");
TraceManager.addDev("Generating files");
if (mainFile != null) {
TraceManager.addDev("Generating main files in " + path + mainFile.getName() + ".h");
FileUtils.saveFile(path + GENERATED_PATH + mainFile.getName() + ".h", Conversion.indentString(mainFile.getHeaderCode(), 2));
FileUtils.saveFile(path + GENERATED_PATH + mainFile.getName() + ".c", Conversion.indentString(mainFile.getMainCode(), 2));
}
for(ComponentFiles componentFile: componentFiles) {
FileUtils.saveFile(path + GENERATED_PATH + componentFile.getName() + ".h", Conversion.indentString(componentFile.getFullHeaderCode/*Soclib*/(), 2));
FileUtils.saveFile(path + GENERATED_PATH + componentFile.getName() + ".cpp", Conversion.indentString(taskFile.getMainCode(), 2));
}
// Standard Makefile
makeMakefileSrc(GENERATED_PATH);
FileUtils.saveFile(path + "Makefile.src", makefile_src);
// Makefile for SocLib
makeMakefileSocLib();
FileUtils.saveFile(path + "Makefile.soclib", makefile_SocLib);
}
public Vector<?> getWarnings() {
return warnings;
}
public void generateSystemCAms(boolean _debug, boolean _tracing) {
debug = _debug;
tracing = _tracing;
mainFile = new MainFileSoclib("main");
if (avspec.hasApplicationCode() && includeUserCode) {
//mainFile.appendToBeforeMainCode("/* User code */\n");
mainFile.appendToBeforeMainCode(avspec.getApplicationCode());
//mainFile.appendToBeforeMainCode("\n/* End of User code */\n\n");
}
makeComponents();
}
public int FindCPUidFromTask(SystemCamsBlock block){
List<SystemCamsTask> tasks = avddspec.getAllMappedTask();
for (SystemCamsTask task : tasks){
if (task.getTaskName().equals(block.getName())){
return task.getCPUNo();
}
}
return -1;
}
public void makeComponents() {
componentFiles.add(componentFile);
}
public void defineAllSignal(ComponentFile _componentFile) {
for () {
_componentFile.addToMainCode( "" + CR);
}
_componentFile.addToMainCode(CR);
}
public void defineAllMethods(SystemCamsBlock _block, TaskFileSoclib _taskFile) {
Vector<String> allNames = new Vector<String>();
for (SystemCamsMethod am: _block.getMethods()) {
makeMethod(_block, am, allNames, _taskFile);
}
// Make method of father
makeFatherMethod(_block, _block, allNames, _taskFile);
}
private void makeFatherMethod(SystemCamsBlock _originBlock, SystemCamsBlock _currentBlock, Vector<String> _allNames, componentFile _componentFile) {
if (_currentBlock.getFather() == null) {
return;
}
for (SystemCamsMethod am: _currentBlock.getFather().getMethods()) {
makeMethod(_originBlock, am, _allNames, _taskFile);
}
makeFatherMethod(_originBlock, _currentBlock.getFather(), _allNames, _taskFile);
}
private void makeMethod(SystemCamsBlock _block, SystemCamsMethod _am, Vector<String> _allNames, TaskFileSoclib _taskFile) {
}
private String makeChannelAction(SystemCamsBlock _block, SystemCamsStateMachineElement asme) {
}
public String makeCanalDec(SystemCamsBlock _block) {
}
//************************************************************************RG
public void makeMainFunction(SystemCamsBlock _block, TaskFileSoclib _taskFile) {
}
}
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
* Daniela Genius, Lip6, UMR 7606
*
* ludovic.apvrille AT enst.fr
* daniela.genius@lip6.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.
*/
/* this class produces the lines containing essentially the initial #includes; we include all potential components event if they are not used in the deployment diagram*/
/* authors: v1.0 Raja GATGOUT 2014
v2.0 Daniela GENIUS, Julien HENON 2015 */
package ddtranslatorSoclib.toTopCell;
public class Constants {
static private String constants;
private final static String CR = "\n";
private final static String CR2 = "\n\n";
Constants(){
}
public static String getConstants() {
constants = "
////////////////////////////////////////////////////////////////////////
// System components constants.
////////////////////////////////////////////////////////////////////////
constants +=
+ CR2
////////////////////////////////////////////////////////////////////////
// Initial conditions and stimuli.
////////////////////////////////////////////////////////////////////////
}
return constants;
}
......@@ -53,272 +53,20 @@ import avatartranslator.AvatarSignal;
import avatartranslator.AvatarSpecification;
public class Declaration {
public static AvatarSpecification avspec;
public static SCamsSpecification spec;
private static String CR = "\n";
private static String CR2 = "\n\n";
public static String generateName(AvatarRelation _ar, int _index) {
return _ar.block1.getName() + "_" + _ar.getSignal1(_index).getName() + "__" + _ar.block2.getName() + "_" + _ar.getSignal2(_index).getName();
}
public static String getDeclarations(AvatarSpecification _avspec) {
avspec =_avspec;
public static String getDeclarations(SCamsSpecification _spec) {
spec =_spec;
String declaration = "//----------------------------Instantiation-------------------------------" + CR2;
String declaration = " ////////////////////////////////////////////////////////////////////////
// Model instantiation.
////////////////////////////////////////////////////////////////////////
+ CR2;
int nb_clusters = TopCellGenerator.avatardd.getAllCrossbar().size();
boolean trace_caba=true;
if(nb_clusters==0){
declaration += CR