16#include "trg/trg/Utilities.h"
17#include "trg/trg/Debug.h"
18#include "trg/trg/Clock.h"
19#include "trg/trg/Signal.h"
20#include "trg/trg/SignalVector.h"
21#include "trg/trg/SignalBundle.h"
22#include "trg/trg/State.h"
47 const unsigned outputBitSize,
54 const vector<int> states = input.stateChanges();
55 const unsigned nStates = states.size();
58 vector<TRGState*> outputStates;
59 for (
unsigned i = 0; i < nStates; i++) {
66 outputStates.push_back(
new TRGState((* packer)(s)));
82 for (
unsigned i = 0; i < nStates; i++) {
84 sb->
set((*s), states[i]);
94 const unsigned outputBitSize,
95 const unsigned registerBitSize,
98 bool& logicStillActive))
103 const string sn =
"TRGSignalBundle constructor(4)";
107 const vector<int> states = input.stateChanges();
108 const unsigned nStates = states.size();
112 for (
unsigned i = 0; i < nStates; i++)
125 vector<TRGState*> outputStates;
126 vector<int> newStates;
127 int lastClock = states[0] - 1;
129 for (
unsigned i = 0; i < nStates; i++) {
132 cout <<
TRGDebug::tab() <<
"Last clock=" << lastClock << endl;
135 if (states[i] <= lastClock)
146 int clk = states[i] + nLoops;
151 newStates.push_back(clk);
155 cout <<
TRGDebug::tab() <<
"state=" << i <<
",clock=" << clk <<
156 ",LogicActive=" <<
active << endl;
176 const unsigned n = outputStates.size();
177 for (
unsigned i = 0; i < n; i++) {
178 const TRGState* s = outputStates[i];
179 sb->
set((* s), newStates[i]);
194 const string& pre)
const
196 cout << pre <<
_name <<
":" << size() <<
" signal vector(s)" << endl;
197 for (
unsigned i = 0; i < size(); i++)
198 (*
this)[i]->dump(msg,
" " + pre);
204 for (
unsigned i = 0; i < size(); i++)
205 if ((*
this)[i]->active())
215 std::vector<int> list;
218 const unsigned n = size();
219 for (
unsigned i = 0; i < n; i++) {
220 vector<int> a = (* this)[i]->stateChanges();
221 for (
unsigned j = 0; j < a.size(); j++)
222 list.push_back(a[j]);
230 std::sort(list.begin(), list.end());
233 std::vector<int> list2;
234 int last = numeric_limits<int>::min();
235 for (
unsigned i = 0; i < list.size(); i++) {
236 const int j = list[i];
249 const unsigned n = size();
250 for (
unsigned i = 0; i < n; i++) {
251 TRGState t = (* this)[i]->state(clockPosition);
262 for (
unsigned i = 0; i < size(); i++) {
276 const unsigned nStates = states.size();
283 for (
unsigned i = 0; i < nStates; i++) {
293 cout <<
"TRGSginalBundle::ored !!! not completed yet" << endl;
305 if (fnIn.size() == 0)
309 ofstream file(fn +
".coe", ios::out);
310 if (! file.is_open()) {
311 cout <<
"!!! " <<
name() <<
" can not open file : " << fn << endl;
360 file <<
"; " <<
name() << endl;
361 file <<
"; generated at " << TRGUtil::dateString() << endl;
362 file <<
"; start clock = " << clk0 << endl;
363 file <<
"; end clock = " << clk1 << endl;
364 file <<
"; bit size = " << tmp.
size() <<
" + clock counter(" << cc.size()
367 file <<
"memory_initialization_radix=2;" << endl;
368 file <<
"memory_initialization_vector=" << endl;
370 for (
int i = clk0; i <= clk1; i++) {
A class to represent a digitized signal. Unit is nano second.
A class to represent a bundle of SignalVectors.
const TRGClock * _clock
Clock.
A class to represent a bundle of digitized signals.
A class to represent a digitized signal. Unit is nano second.
A class to represent a state of multi bits.
unsigned size(void) const
returns bit size.
static std::string tab(void)
returns tab spaces.
const TRGSignalVector & set(const TRGState &, int clockPosition)
sets state at given clock.
virtual ~TRGSignalBundle()
Destructor.
TRGState state(int clockPosition) const
returns state at given clock position.
const TRGClock & clock(void) const
returns clock.
const std::string & name(void) const
returns name.
std::vector< int > stateChanges(void) const
returns a list of clock position of state change.
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
int min(void) const
returns min. clock point.
TRGSignalBundle(const TRGClock &)
Default constructor.
TRGSignal ored(void) const
returns signal of all ORed.
static int level(void)
returns the debug level.
bool active(void) const
returns true if there is a signal.
const TRGSignalVector & clockCounter(void) const
returns the clock counter.
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
void dumpCOE(const std::string &fileName="", int start=0, int stop=0) const
makes coe output.
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Abstract base class for different kinds of events.