The Sparta Modeling Framework
Loading...
Searching...
No Matches
ExpressionNode.hpp
1// <ExpressionNode> -*- C++ -*-
2
3#pragma once
4
7
8namespace sparta {
9
10 class StatisticInstance;
11
12 namespace statistics {
13 namespace expression {
14
19 OP_NULL = 0,
20 OP_ADD = '+',
21 OP_SUB = '-',
22 OP_MUL = '*',
23 OP_DIV = '/',
24 OP_NEGATE = 'n',
25 OP_PROMOTE = 'p',
26 OP_FORWARD = 'f'
27
28};
29
38{
39public:
40
45
47 //std::cout << "EI Con " << this << std::endl;
48 }
49
50 virtual ~ExpressionNode() {
51 //std::cout << "EI Des ~" << this << std::endl;
52 }
53
54 ExpressionNode* clone() const {
55 ExpressionNode* item = clone_();
56 //std::cout << "cloned " << item << " <- " << this << std::endl;
57 return item;
58 }
59
68 uint32_t getStats(std::vector<const StatisticInstance*>& results) const {
69 return getStats_(results);
70 }
71
76 double evaluate(){
77 double val = evaluate_();
78
79 // trace
80 //dump(std::cout);
81 //std::cout << " => " << val << std::endl;
82
83 return val;
84 }
85
86 virtual void start() = 0;
87 virtual void end() = 0;
88
89 virtual bool supportsCompression() const = 0;
90
101 virtual void dump(std::ostream& o,
102 bool show_range=true,
103 bool resolve_subexprs=true) const = 0;
104
111 virtual void getClocks(std::vector<const Clock*>& clocks) const = 0;
112
113private:
114
118 virtual double evaluate_() const = 0;
119
123 virtual uint32_t getStats_(std::vector<const StatisticInstance*>& results) const = 0;
124
130 virtual ExpressionNode* clone_() const = 0;
131
132};
133
134 } // namespace expression
135 } // namespace statistics
136} // namespace sparta
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Abstract interface class for an item in an expression. Subclasses can contain other ExpressionNodes.
virtual void getClocks(std::vector< const Clock * > &clocks) const =0
Populates a vector with the clocks found in this subexpression node.
ExpressionNode(const ExpressionNode &)=delete
No copy-constructable.
virtual void dump(std::ostream &o, bool show_range=true, bool resolve_subexprs=true) const =0
Dump the content of this expression item.
double evaluate()
Compute value of this item in simulation. Must be implemented by subclass.
uint32_t getStats(std::vector< const StatisticInstance * > &results) const
Gets the statistics present in this expression.
operation_t
Types of operations supported.
Macros for handling exponential backoff.