Commit 78f67200 by Marcus Winter

Merge branch 'embb455_dataflow_source_semantics' into development

parents 4692cef0 63419b09
......@@ -53,7 +53,9 @@ class SourceExecutor< Outputs<Slices, O1> > {
Outputs<Slices, O1> & outputs) {
O1 o1;
bool result = function_(o1);
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
if (result) {
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
}
return result;
}
......@@ -78,8 +80,10 @@ class SourceExecutor< Outputs<Slices, O1, O2> > {
O1 o1;
O2 o2;
bool result = function_(o1, o2);
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
if (result) {
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
}
return result;
}
......@@ -106,9 +110,11 @@ class SourceExecutor< Outputs<Slices, O1, O2, O3> > {
O2 o2;
O3 o3;
bool result = function_(o1, o2, o3);
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
outputs.template Get<2>().Send(Signal<O3>(clock, o3));
if (result) {
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
outputs.template Get<2>().Send(Signal<O3>(clock, o3));
}
return result;
}
......@@ -137,10 +143,12 @@ class SourceExecutor< Outputs<Slices, O1, O2, O3, O4> > {
O3 o3;
O4 o4;
bool result = function_(o1, o2, o3, o4);
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
outputs.template Get<2>().Send(Signal<O3>(clock, o3));
outputs.template Get<3>().Send(Signal<O4>(clock, o4));
if (result) {
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
outputs.template Get<2>().Send(Signal<O3>(clock, o3));
outputs.template Get<3>().Send(Signal<O4>(clock, o4));
}
return result;
}
......@@ -172,11 +180,13 @@ class SourceExecutor< Outputs<Slices, O1, O2, O3, O4, O5> > {
O4 o4;
O5 o5;
bool result = function_(o1, o2, o3, o4, o5);
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
outputs.template Get<2>().Send(Signal<O3>(clock, o3));
outputs.template Get<3>().Send(Signal<O4>(clock, o4));
outputs.template Get<4>().Send(Signal<O5>(clock, o5));
if (result) {
outputs.template Get<0>().Send(Signal<O1>(clock, o1));
outputs.template Get<1>().Send(Signal<O2>(clock, o2));
outputs.template Get<2>().Send(Signal<O3>(clock, o3));
outputs.template Get<3>().Send(Signal<O4>(clock, o4));
outputs.template Get<4>().Send(Signal<O5>(clock, o5));
}
return result;
}
......
......@@ -56,12 +56,19 @@ embb::base::Atomic<int> source_counter;
int source_array[TEST_COUNT];
bool sourceFunc(int & out) {
out = source_counter;
if (source_counter < TEST_COUNT)
{
out = source_counter;
source_array[source_counter] = out;
source_counter++;
source_array[source_counter] = out;
source_counter++;
return source_counter < TEST_COUNT;
return true;
}
else
{
return false;
}
}
embb::base::Atomic<int> pred_counter;
......
......@@ -3,10 +3,14 @@ class Producer {
public:
explicit Producer(int seed) : seed_(seed), count_(4) {}
bool Run(T& x) {
// produce a new value x
x = SimpleRand(seed_);
count_--;
return count_ >= 0;
if (count_ >= 0) {
// produce a new value x
x = SimpleRand(seed_);
count_--;
return true;
} else {
return false;
}
}
private:
......
bool SourceFunction(std::string & str) {
std::getline(file, str);
return !file.eof();
if (!file.eof()) {
std::getline(file, str);
return true;
} else {
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment