[88] | 1 | /* |
---|
| 2 | * $Id: Configuration.cpp 97 2008-12-19 15:34:00Z 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 | //-------------------------------------------------- |
---|
[97] | 42 | debug_init (fromString<debug_verbosity_t>(_simulator->getParam("debug_level"))); |
---|
[88] | 43 | |
---|
[97] | 44 | log_init(fromString<bool>(_simulator->getParam("debug_have_log_file")), |
---|
| 45 | MORPHEO_LOG); |
---|
| 46 | |
---|
[88] | 47 | //-------------------------------------------------- |
---|
| 48 | // Usage |
---|
| 49 | //-------------------------------------------------- |
---|
| 50 | _usage = USE_NONE; |
---|
| 51 | |
---|
| 52 | if (fromString<bool>(_simulator->getParam("use_systemc"))) |
---|
| 53 | _usage = usage_set(_usage, USE_SYSTEMC); |
---|
| 54 | if (fromString<bool>(_simulator->getParam("use_vhdl"))) |
---|
| 55 | _usage = usage_set(_usage, USE_VHDL); |
---|
| 56 | if (fromString<bool>(_simulator->getParam("use_vhdl_testbench"))) |
---|
| 57 | _usage = usage_set(_usage, USE_VHDL_TESTBENCH); |
---|
| 58 | if (fromString<bool>(_simulator->getParam("use_vhdl_testbench_assert"))) |
---|
| 59 | _usage = usage_set(_usage, USE_VHDL_TESTBENCH_ASSERT); |
---|
| 60 | if (fromString<bool>(_simulator->getParam("use_position"))) |
---|
| 61 | _usage = usage_set(_usage, USE_POSITION); |
---|
| 62 | if (fromString<bool>(_simulator->getParam("use_statistics"))) |
---|
| 63 | _usage = usage_set(_usage, USE_STATISTICS); |
---|
| 64 | if (fromString<bool>(_simulator->getParam("use_information"))) |
---|
| 65 | _usage = usage_set(_usage, USE_INFORMATION); |
---|
| 66 | if (fromString<bool>(_simulator->getParam("use_header"))) |
---|
| 67 | _usage = usage_set(_usage, USE_HEADER); |
---|
| 68 | |
---|
| 69 | usage_environment (_usage); |
---|
| 70 | |
---|
| 71 | //-------------------------------------------------- |
---|
[97] | 72 | // Header |
---|
| 73 | //-------------------------------------------------- |
---|
| 74 | |
---|
| 75 | if (usage_is_set(_usage,USE_HEADER)) |
---|
| 76 | std::cout << header(); |
---|
| 77 | |
---|
| 78 | //-------------------------------------------------- |
---|
[88] | 79 | // Parameters_Statistics |
---|
| 80 | //-------------------------------------------------- |
---|
| 81 | _param_statistics = new Parameters_Statistics (fromString<uint64_t>(_simulator->getParam("nb_cycle_before_begin")), |
---|
| 82 | fromString<uint64_t>(_simulator->getParam("period_save"))); |
---|
| 83 | |
---|
| 84 | //-------------------------------------------------- |
---|
| 85 | // Simulation condition stop |
---|
| 86 | //-------------------------------------------------- |
---|
| 87 | simulation_init (fromString<double>(_simulator->getParam("simulation_nb_cycle")), |
---|
| 88 | fromString<double>(_simulator->getParam("simulation_nb_instruction"))); |
---|
| 89 | |
---|
[97] | 90 | |
---|
| 91 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 92 | // Generator configuration + Instance |
---|
| 93 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 94 | |
---|
| 95 | _generator = new Generator (filename_generator); |
---|
| 96 | _instance = new Instance (filename_instance , |
---|
| 97 | _generator, |
---|
| 98 | get_custom_information); |
---|
| 99 | |
---|
[88] | 100 | //-------------------------------------------------- |
---|
[97] | 101 | // Name |
---|
[88] | 102 | //-------------------------------------------------- |
---|
[97] | 103 | _name = _instance->getName(); |
---|
[88] | 104 | |
---|
[97] | 105 | //-------------------------------------------------- |
---|
| 106 | // Parameters |
---|
| 107 | //-------------------------------------------------- |
---|
| 108 | _param = _instance->_param; |
---|
| 109 | |
---|
| 110 | |
---|
[88] | 111 | log_end(Configuration,FUNCTION); |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | #undef FUNCTION |
---|
| 115 | #define FUNCTION "Configuration::~Configuration" |
---|
| 116 | Configuration::~Configuration () |
---|
| 117 | { |
---|
| 118 | log_begin(Configuration,FUNCTION); |
---|
| 119 | |
---|
| 120 | delete _simulator; |
---|
| 121 | delete _generator; |
---|
| 122 | delete _instance; |
---|
| 123 | delete _param_statistics; |
---|
| 124 | |
---|
| 125 | log_end(Configuration,FUNCTION); |
---|
| 126 | }; |
---|
| 127 | |
---|
| 128 | }; // end namespace configuration |
---|
| 129 | }; // end namespace behavioural |
---|
| 130 | }; // end namespace morpheo |
---|