source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Configuration/src/Parameter_definition_test.cpp @ 146

Last change on this file since 146 was 146, checked in by rosiere, 13 years ago

1) Integration of RegisterFile_Internal_Banked in RegisterFile?
2) Erase "read_write" interface in RegisterFile_Monolithic component
3) Add smith predictor parameters in Load_store_pointer_unit.
4) Fix not statistics flags

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1/*
2 * $Id: Parameter_definition_test.cpp 146 2011-02-01 20:57:54Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Configuration/include/Parameter_definition.h"
9#include "Behavioural/include/Stat_binary_tree.h"
10#include "Behavioural/include/Stat_type.h"
11#include "Common/include/FromString.h"
12
13namespace morpheo {
14namespace behavioural {
15namespace configuration {
16
17#undef  FUNCTION
18#define FUNCTION "Parameter_definition::test"
19  void Parameter_definition::test (std::string x)
20  {
21    log_begin(Configuration,FUNCTION);
22
23    std::map<std::string, counter_t*> * operand = new std::map<std::string, counter_t*>;
24
25    std::string expr = _step+" "+_name;
26    std::string expr_str = _name + "(n+1) = "+_step+" "+_name+"(n)";
27
28    counter_t value;
29    (*operand)[_name] = &value;
30
31    Stat_binary_tree * tree;
32    try
33      {
34        tree = new Stat_binary_tree(expr,operand);
35      }
36    catch (morpheo::ErrorMorpheo & error)
37      {
38        throw (ERRORMORPHEO (FUNCTION,toString(_("step make an invalid infix expression : \"%s\"\n"),expr_str.c_str())));
39      }
40   
41    counter_t min = fromString<counter_t>(_min);
42    counter_t max = fromString<counter_t>(_max);
43
44    value = min;
45    while ((value != fromString<counter_t>(x)) and (value <= max))
46      {
47        counter_t tmp = tree->eval();
48
49        // warning, can have infinite loop
50        value = (tmp == value)?(max+1):tmp; 
51      }
52
53    if (value > max)
54      {
55        throw (ERRORMORPHEO (FUNCTION,toString(_("With the expression \"%s\" and \"%s(0) = %s\" and value between [%s:%s], \"%s(n) = %s\" is not a valid value.\n"),expr_str.c_str(),_name.c_str(),_min.c_str(),_min.c_str(),_max.c_str(),_name.c_str(),x.c_str())));
56      }
57   
58    delete tree;
59    delete operand;
60
61    log_end(Configuration,FUNCTION);
62  };
63
64}; // end namespace configuration
65}; // end namespace behavioural
66}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.