-
Notifications
You must be signed in to change notification settings - Fork 7
/
processing.cpp
48 lines (45 loc) · 1.21 KB
/
processing.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @file processing.cpp
*/
#include "processing.hpp"
#include "fpsqrt.hpp"
#ifndef __SYNTHESIS__
#include "report.hpp"
#endif
using namespace sc_core;
namespace {
char const * const MSGID{ "/Doulos/Example/Modern/Processing_module" };
}
//..............................................................................
Processing_module::Processing_module( sc_module_name instance ) //< Constructor
: sc_module( instance )
{
SC_HAS_PROCESS( Processing_module );
SC_CTHREAD( processing_thread, clk_port.pos() );
}
//..............................................................................
Processing_module::~Processing_module( void ) = default;
//..............................................................................
void Processing_module::processing_thread( void )
{
RawData_t v;
FixedPt_t x, y, z, sum2, magnitude;
wait(1);
for(;;) {
wait(1);
if( input_port->nb_read( v ) ) {
x = v.x();
y = v.y();
z = v.z();
x *= x;
y *= y;
z *= z;
sum2 = x + y +z;
magnitude = FP::fpsqrt( sum2 );
#ifndef __SYNTHESIS__
INFO( DEBUG, "Processed " << v << " => " << magnitude.to_string() );
#endif
output_port->write( magnitude );
}
}
}