16 #include "llvm/Support/raw_ostream.h"
20 Trace::Trace(std::unique_ptr<State>
const &state, llvm::raw_ostream &out,
22 : out(out), state(state), mode(mode) {
23 auto root =
state->root;
24 for (
auto &sig :
state->signals) {
26 !sig.isOwner(root)) ||
37 auto &sig =
state->signals[sigIndex];
38 std::string valueDump;
40 llvm::raw_string_ostream ss(path);
42 ss <<
state->instances[inst].path <<
'/' << sig.getName();
46 ss <<
'[' << elem <<
']';
48 valueDump = sig.toHexString(elem);
51 valueDump = sig.toHexString();
55 auto lastValKey = std::make_pair(path, elem);
57 changes.push_back(std::make_pair(path, valueDump));
63 auto &sig =
state->signals[sigIndex];
64 if (sig.hasElement()) {
66 for (
size_t i = 0, e = sig.getElementSize(); i < e; ++i) {
79 auto &sig =
state->signals[sigIndex];
81 for (
auto inst : sig.getTriggeredInstanceIndices()) {
95 auto &sig =
state->signals[sigIndex];
96 if (sig.hasElement()) {
98 for (
size_t i = 0, e = sig.getElementSize(); i < e; ++i) {
99 auto valueDump = sig.toHexString(i);
104 auto valueDump = sig.toHexString();
115 [](std::pair<std::string, std::string> &lhs,
116 std::pair<std::string, std::string> &rhs) ->
bool {
117 return lhs.first < rhs.first;
136 out << timeDump <<
" " << change.first <<
" " << change.second <<
"\n";
145 auto sigIndex = elem.first.first;
146 auto sigElem = elem.first.second;
147 auto &sig =
state->signals[sigIndex];
148 auto change = elem.second;
152 for (
auto inst : sig.getTriggeredInstanceIndices()) {
167 out <<
" " << change.first <<
" " << change.second <<
"\n";
std::string toString() const
Get the stored time in a printable format.
std::vector< bool > isTraced
void flush(bool force=false)
Flush the changes buffer to the output stream.
void addChangeMerged(unsigned)
Add a merged change to the change buffer.
std::map< std::pair< std::string, int >, std::string > lastValue
void pushChange(unsigned inst, unsigned sigIndex, int elem)
Push one change to the changes vector.
void addChange(unsigned)
Add a value change to the trace changes buffer.
void flushFull()
Flush the changes buffer to the output stream with full format.
std::vector< std::pair< std::string, std::string > > changes
std::unique_ptr< State > const & state
void pushAllChanges(unsigned inst, unsigned sigIndex)
Push one change for each element of a signal if it is of a structured type, or the full signal otherw...
Trace(std::unique_ptr< State > const &state, llvm::raw_ostream &out, TraceMode mode)
void sortChanges()
Sorts the changes buffer lexicographically wrt. the hierarchical paths.
std::map< std::pair< unsigned, int >, std::string > mergedChanges