13 #ifndef TEST2_MODULE_ALGORITHMS_FILE_H
14 #define TEST2_MODULE_ALGORITHMS_FILE_H
24 template<
int Ni,
int No>
27 srand ((
unsigned int)sc_time_stamp().to_double());
28 user_algo_interface.
get_logfile() << sc_time_stamp() <<
"init srand" << endl;
36 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" Beginning of loop" << endl;
38 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" Execution requested" << endl;
45 #ifdef GENERATE_LOG_FILE
46 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" New period started" << endl;
61 double random = rand()%101;
62 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" rand : " << rand() << endl;
63 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" rand : " << rand() << endl;
64 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" random : " << random << endl;
67 double random_result =(random/100.0)*(user_algo_interface.
get_WCET().to_seconds()-user_algo_interface.
get_BCET().to_seconds());
68 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" wcet : " << user_algo_interface.
get_WCET().to_seconds()*1000 << endl;
69 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" bcet : " << user_algo_interface.
get_BCET().to_seconds()*1000 << endl;
70 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" wcet-bcet : " << random_result*1000 << endl;
72 sc_time random_execution_time = user_algo_interface.
get_BCET();
75 if (tasks_execution_time == RANDOM)
76 random_execution_time = user_algo_interface.
get_BCET() + sc_time(random_result, SC_SEC);
78 if (tasks_execution_time == BCET)
79 random_execution_time = user_algo_interface.
get_BCET();
81 if (tasks_execution_time == WCET)
82 random_execution_time = user_algo_interface.
get_WCET();
86 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" Execution times : " << random_execution_time.to_seconds()*1000 <<
" ms : " << endl;
100 #ifdef GENERATE_LOG_FILE
101 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" User algorithm ended" << endl;
124 int data_in_length = 0;
125 int data_out_length = 0;
126 for(
int i = 0; i < No; i++) {
130 if(data_out_length <= data_in_length) {
134 for(
int j = data_in_length; j < data_out_length; j+=4) user_algo_interface.
get_data_out_ptr(i)[j/4] = 0;
151 user_algo_interface.wait_for_update_user_algorithm();
153 user_algo_interface.
get_logfile() << sc_time_stamp() <<
": " << user_algo_interface.
get_name() <<
" Update user algorithm event received" << endl;
156 #ifdef GENERATE_LOG_FILE
157 user_algo_interface.
get_logfile() << user_algo_interface.
get_name() <<
" User algorithm thread has to be killed!" << endl;
virtual ofstream & get_logfile(void)=0
Get logfile.
virtual bool & kill_user_algorithm(void)=0
Get a reference to a boolean indicating whether the user algorithm should be killed or not (for insta...
virtual void start_new_transaction_sequence(int id)=0
Indicate that a new transaction sequence is beginning (i.e. sending new data) for a particular socket...
virtual int * get_data_in_ptr(int socket)=0
Get pointer to incoming data from socket 'socket'.
virtual void set_address_out(int socket, sc_dt::uint64 value)=0
Set address for outgoing transaction on socket 'socket'.
virtual bool nb_data_received(string name)=0
Check if the data from channel 'name' have been received yet. Non-blocking function.
virtual int get_nb_preemption_points(void)=0
Get the number of preemption points that should be inserted in the algorithm.
virtual void b_all_data_received(void)=0
Check if the data from all channels have been received yet. Blocking function: if the data is not ava...
virtual void preemption_point(void)=0
Function to call to emulate preemption.
virtual sc_time get_WCET(void) const =0
Get task worst case execution time (WCET), depending on current implementation.
virtual int get_data_out_length(int socket) const =0
Get output socket data length.
virtual void compute(sc_time duration)=0
Emulate an execution time of the algorithm.
virtual void release_all_input_sockets(void)=0
Release all input socket so that preceding modules might send some more data.
virtual void set_algorithm_waiting(void)=0
Function to call when the algorithm is waiting for data in order to have an accurate trace...
virtual int get_data_in_length(int socket) const =0
Get input socket data length.
virtual const char * get_name(void) const =0
Get task name.
virtual void b_execution_requested(void)=0
Wait until an algorithm execution has been requested/granted by the manager.
Definition: user_algorithm_interface.h:35
virtual bool is_channel_transient(string name)=0
Check if channel 'name' is transient or not.
virtual void end_of_algorithm(void)=0
Function to call at the end of algorithm.
virtual int * get_data_out_ptr(int socket)=0
Get pointer to outgoing data from socket 'socket'.
virtual void set_algorithm_running(void)=0
Function to call when the algorithm is running in order to have an accurate trace.
virtual void set_algorithm_idle(void)=0
Function to call when the algorithm is idle in order to have an accurate trace.
virtual void wait_until_next_period(void)=0
Wait until the next period is started. For non-periodic tasks, return immediately.
virtual sc_dt::uint64 get_address_in(int socket) const =0
Retrieve address from the incoming transaction on socket 'socket'.
virtual void b_all_data_sent(void)=0
Check if data has been sent on every socket. Blocking function: if data send is not finished yet...
virtual void nb_send_all_data(void)=0
Send data towards all channels. Non-blocking function.
virtual sc_time get_BCET(void) const =0
Get task best case execution time (BCET), depending on current implementation.