OpenASIP  2.0
RemoteController.cc
Go to the documentation of this file.
1 /*
2  This file is part of TTA-Based Codesign Environment (TCE).
3 
4  Permission is hereby granted, free of charge, to any person obtaining a
5  copy of this software and associated documentation files (the "Software"),
6  to deal in the Software without restriction, including without limitation
7  the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  and/or sell copies of the Software, and to permit persons to whom the
9  Software is furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  DEALINGS IN THE SOFTWARE.
21 */
22 
23 /**
24  * @file RemoteController.cc
25  * @author Kalle Raiskila 2014
26  */
27 
28 #include "RemoteController.hh"
29 #include "SimValue.hh"
30 #include "ProgramImageGenerator.hh"
31 #include "BinaryEncoding.hh"
32 #include "BEMGenerator.hh"
33 #include "Binary.hh"
34 #include "ProgramWriter.hh"
35 
36 #define DEBUG_REMOTE_DEBUGGER_CONTROLLER
37 #ifdef DEBUG_REMOTE_DEBUGGER_CONTROLLER
38 #include <cstdio>
39 #define _DPRINT(...) printf(__VA_ARGS__)
40 #define _WHERE() printf("%s:%d - %s\n", __FILE__, __LINE__, __func__)
41 #else
42 #define _DPRINT(...)
43 #define _WHERE()
44 #endif
45 
46 #include <iostream>
47 
49  SimulatorFrontend& frontend,
51  const TTAProgram::Program& program) :
53  imemImage(std::ostringstream::binary) {
55 }
56 
57 void
59 
60  ProgramImageGenerator thePIG;
61  BinaryEncoding *theBE;
62  TPEF::Binary *binary;
63  // TODO. better name from somewhere?
64  std::string programName("the program");
65  // clear the old image
66  imemImage.str("");
67 
68  // Binary encoding of the instruction sream
69  // TODO: loading of instruction compressors would happen here?
70  BEMGenerator theBEMGen(sourceMachine_);
71  theBE = theBEMGen.generate();
72 
74  binary = writer.createBinary();
76  // TODO: have some actual name for this program?
77  tmap[programName] = binary;
78 
79  thePIG.loadBEM(*theBE);
80  thePIG.loadMachine(sourceMachine_);
81  thePIG.loadPrograms(tmap);
82  // clear the old image
83 
84  // put the instructions into imemImage
85  thePIG.generateProgramImage(
86  programName, imemImage,
88 
89  writeIMem(imemImage.str().c_str(), imemImage.str().size());
90 
91  delete binary;
92  delete theBE;
93 
94  return;
95 
96 }
97 /* vim: set ts=4 expandtab: */
ProgramImageGenerator::generateProgramImage
void generateProgramImage(const std::string &programName, std::ostream &stream, OutputFormat format, int mausPerLine=0)
Definition: ProgramImageGenerator.cc:185
TTAProgram::Program
Definition: Program.hh:63
BinaryEncoding
Definition: BinaryEncoding.hh:61
BEMGenerator.hh
RemoteController::writeIMem
virtual void writeIMem(const char *data, int size)=0
RemoteController::loadIMemImage
virtual void loadIMemImage()
Definition: RemoteController.cc:58
ProgramImageGenerator::loadBEM
void loadBEM(const BinaryEncoding &bem)
Definition: ProgramImageGenerator.cc:162
RemoteController::exitPoints
std::set< InstructionAddress > exitPoints
Definition: RemoteController.hh:120
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TPEF::Binary
Definition: Binary.hh:49
TTAProgram::ProgramWriter
Definition: ProgramWriter.hh:141
ProgramWriter.hh
ProgramImageGenerator::loadPrograms
void loadPrograms(TPEFMap programs)
Definition: ProgramImageGenerator.cc:140
RemoteController.hh
BEMGenerator
Definition: BEMGenerator.hh:61
ProgramImageGenerator::loadMachine
void loadMachine(const TTAMachine::Machine &machine)
Definition: ProgramImageGenerator.cc:151
TTASimulationController
Definition: TTASimulationController.hh:69
ProgramImageGenerator.hh
TTASimulationController::findProgramExitPoints
virtual std::set< InstructionAddress > findProgramExitPoints(const TTAProgram::Program &program, const TTAMachine::Machine &machine) const
Definition: TTASimulationController.cc:209
BinaryEncoding.hh
TTASimulationController::sourceMachine_
const TTAMachine::Machine & sourceMachine_
The simulated Machine Object Model.
Definition: TTASimulationController.hh:137
ProgramImageGenerator
Definition: ProgramImageGenerator.hh:67
ProgramImageGenerator::BINARY
@ BINARY
Real binary format.
Definition: ProgramImageGenerator.hh:72
SimValue.hh
RemoteController::imemImage
std::ostringstream imemImage
Definition: RemoteController.hh:121
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
TTAProgram::ProgramWriter::createBinary
TPEF::Binary * createBinary() const
Definition: ProgramWriter.cc:700
TTASimulationController::program_
const TTAProgram::Program & program_
Program object model of the simulated program.
Definition: TTASimulationController.hh:139
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
ProgramImageGenerator::TPEFMap
std::map< std::string, TPEF::Binary * > TPEFMap
Definition: ProgramImageGenerator.hh:81
BEMGenerator::generate
BinaryEncoding * generate()
Definition: BEMGenerator.cc:104
RemoteController::RemoteController
RemoteController(SimulatorFrontend &frontend, const TTAMachine::Machine &machine, const TTAProgram::Program &program)
Definition: RemoteController.cc:48
TTAMachine::Machine
Definition: Machine.hh:73
Binary.hh