[88] | 1 | /* |
---|
| 2 | * $Id: Configuration.cpp 100 2009-01-08 13:06:27Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Configuration/include/Configuration.h" |
---|
| 9 | #include "Behavioural/include/Simulation.h" |
---|
| 10 | #include "Common/include/Environment.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace configuration { |
---|
| 15 | |
---|
| 16 | #undef FUNCTION |
---|
| 17 | #define FUNCTION "Configuration::Configuration" |
---|
| 18 | Configuration::Configuration (std::string filename_simulator, |
---|
| 19 | std::string filename_generator, |
---|
| 20 | std::string filename_instance , |
---|
| 21 | behavioural::custom::custom_information_t (*get_custom_information) (void)) |
---|
| 22 | { |
---|
| 23 | log_begin(Configuration,FUNCTION); |
---|
| 24 | |
---|
[97] | 25 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 26 | // Simulator configuration |
---|
| 27 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 28 | |
---|
[88] | 29 | _simulator = new Simulator (filename_simulator); |
---|
| 30 | |
---|
| 31 | //-------------------------------------------------- |
---|
[97] | 32 | // Directory |
---|
[88] | 33 | //-------------------------------------------------- |
---|
[97] | 34 | directory_init (_simulator->getParam("directory_statistics"), |
---|
| 35 | _simulator->getParam("directory_vhdl" ), |
---|
| 36 | _simulator->getParam("directory_position" ), |
---|
| 37 | _simulator->getParam("directory_log" )); |
---|
[88] | 38 | |
---|
| 39 | //-------------------------------------------------- |
---|
[97] | 40 | // Debug & Log File |
---|
[88] | 41 | //-------------------------------------------------- |
---|
[100] | 42 | debug_init (fromString<debug_verbosity_t>(_simulator->getParam("debug_level")), |
---|
| 43 | fromString<double> (_simulator->getParam("debug_cycle_start")), |
---|
| 44 | fromString<double> (_simulator->getParam("debug_cycle_stop"))); |
---|
[88] | 45 | |
---|
[97] | 46 | log_init(fromString<bool>(_simulator->getParam("debug_have_log_file")), |
---|
| 47 | MORPHEO_LOG); |
---|
| 48 | |
---|
[88] | 49 | //-------------------------------------------------- |
---|
| 50 | // Usage |
---|
| 51 | //-------------------------------------------------- |
---|
| 52 | _usage = USE_NONE; |
---|
| 53 | |
---|
| 54 | if (fromString<bool>(_simulator->getParam("use_systemc"))) |
---|
| 55 | _usage = usage_set(_usage, USE_SYSTEMC); |
---|
| 56 | if (fromString<bool>(_simulator->getParam("use_vhdl"))) |
---|
| 57 | _usage = usage_set(_usage, USE_VHDL); |
---|
| 58 | if (fromString<bool>(_simulator->getParam("use_vhdl_testbench"))) |
---|
| 59 | _usage = usage_set(_usage, USE_VHDL_TESTBENCH); |
---|
| 60 | if (fromString<bool>(_simulator->getParam("use_vhdl_testbench_assert"))) |
---|
| 61 | _usage = usage_set(_usage, USE_VHDL_TESTBENCH_ASSERT); |
---|
| 62 | if (fromString<bool>(_simulator->getParam("use_position"))) |
---|
| 63 | _usage = usage_set(_usage, USE_POSITION); |
---|
| 64 | if (fromString<bool>(_simulator->getParam("use_statistics"))) |
---|
| 65 | _usage = usage_set(_usage, USE_STATISTICS); |
---|
| 66 | if (fromString<bool>(_simulator->getParam("use_information"))) |
---|
| 67 | _usage = usage_set(_usage, USE_INFORMATION); |
---|
| 68 | if (fromString<bool>(_simulator->getParam("use_header"))) |
---|
| 69 | _usage = usage_set(_usage, USE_HEADER); |
---|
| 70 | |
---|
| 71 | usage_environment (_usage); |
---|
| 72 | |
---|
| 73 | //-------------------------------------------------- |
---|
[97] | 74 | // Header |
---|
| 75 | //-------------------------------------------------- |
---|
| 76 | |
---|
| 77 | if (usage_is_set(_usage,USE_HEADER)) |
---|
| 78 | std::cout << header(); |
---|
| 79 | |
---|
| 80 | //-------------------------------------------------- |
---|
[88] | 81 | // Parameters_Statistics |
---|
| 82 | //-------------------------------------------------- |
---|
[100] | 83 | _param_statistics = new Parameters_Statistics (fromString<uint64_t>(_simulator->getParam("statistics_cycle_start")), |
---|
| 84 | fromString<uint64_t>(_simulator->getParam("statistics_period"))); |
---|
[88] | 85 | |
---|
| 86 | //-------------------------------------------------- |
---|
| 87 | // Simulation condition stop |
---|
| 88 | //-------------------------------------------------- |
---|
| 89 | simulation_init (fromString<double>(_simulator->getParam("simulation_nb_cycle")), |
---|
| 90 | fromString<double>(_simulator->getParam("simulation_nb_instruction"))); |
---|
| 91 | |
---|
[97] | 92 | |
---|
| 93 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 94 | // Generator configuration + Instance |
---|
| 95 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 96 | |
---|
| 97 | _generator = new Generator (filename_generator); |
---|
| 98 | _instance = new Instance (filename_instance , |
---|
| 99 | _generator, |
---|
| 100 | get_custom_information); |
---|
| 101 | |
---|
[88] | 102 | //-------------------------------------------------- |
---|
[97] | 103 | // Name |
---|
[88] | 104 | //-------------------------------------------------- |
---|
[97] | 105 | _name = _instance->getName(); |
---|
[88] | 106 | |
---|
[97] | 107 | //-------------------------------------------------- |
---|
| 108 | // Parameters |
---|
| 109 | //-------------------------------------------------- |
---|
| 110 | _param = _instance->_param; |
---|
| 111 | |
---|
| 112 | |
---|
[88] | 113 | log_end(Configuration,FUNCTION); |
---|
| 114 | }; |
---|
| 115 | |
---|
| 116 | #undef FUNCTION |
---|
| 117 | #define FUNCTION "Configuration::~Configuration" |
---|
| 118 | Configuration::~Configuration () |
---|
| 119 | { |
---|
| 120 | log_begin(Configuration,FUNCTION); |
---|
| 121 | |
---|
| 122 | delete _simulator; |
---|
| 123 | delete _generator; |
---|
| 124 | delete _instance; |
---|
| 125 | delete _param_statistics; |
---|
| 126 | |
---|
| 127 | log_end(Configuration,FUNCTION); |
---|
| 128 | }; |
---|
| 129 | |
---|
| 130 | }; // end namespace configuration |
---|
| 131 | }; // end namespace behavioural |
---|
| 132 | }; // end namespace morpheo |
---|