-
Notifications
You must be signed in to change notification settings - Fork 7
/
stimulus.cpp
51 lines (48 loc) · 1.66 KB
/
stimulus.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
49
50
51
/**
* @file stimulus.cpp
*/
#include "stimulus.hpp"
#include "objection.hpp"
#include "report.hpp"
#include <random>
using namespace sc_core;
namespace {
char const * const MSGID{ "/Doulos/Example/Modern/Stimulus_module" };
}
//..............................................................................
Stimulus_module::Stimulus_module( sc_module_name instance ) //< Constructor
: sc_module( instance )
{
SC_HAS_PROCESS( Stimulus_module );
SC_THREAD( stimulus_thread );
}
//..............................................................................
Stimulus_module::~Stimulus_module( void ) = default;
//..............................................................................
void Stimulus_module::stimulus_thread( void )
{
Objection generating_data( name() );
unsigned int seed = 1;
std::default_random_engine generator(seed);
std::uniform_real_distribution<double> distribution (-128.0,128.0);
std::vector<double> directed = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
size_t samples = directed.size()*directed.size()*directed.size();
REPORT( INFO, "Sending " << samples << " directed samples" );
for( auto const& x : directed ) {
for( auto const& y : directed ) {
for( auto const& z : directed ) {
Coordinate xyz{ x, y, z };
rawout_port->write( xyz );
INFO( DEBUG, "Sent " << xyz );
}
}
}
samples = 1000;
REPORT( INFO, "Sending " << samples << " random samples" );
for( size_t n=0; n<samples; ++n ) {
Coordinate xyz = { distribution(generator), distribution(generator), distribution(generator) };
rawout_port->write( xyz );
INFO( DEBUG, "Sent " << xyz );
}
REPORT( INFO, "Stimulus complete" );
}