[2] | 1 | #ifdef SYSTEMC |
---|
| 2 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
| 3 | /* |
---|
| 4 | * $Id$ |
---|
| 5 | * |
---|
| 6 | * [ Description ] |
---|
| 7 | * |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #include "Behavioural/Generic/Counter/include/Counter.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace generic { |
---|
| 15 | namespace counter { |
---|
| 16 | |
---|
| 17 | void Counter::genMealy (void) |
---|
| 18 | { |
---|
| 19 | log_printf(FUNC,Counter,"genMealy","Begin"); |
---|
| 20 | |
---|
| 21 | for (uint32_t i=0; i<_param._nb_port; i++) |
---|
| 22 | { |
---|
[3] | 23 | Tcontrol_t addsub = PORT_READ(in_COUNTER_ADDSUB [i]); |
---|
| 24 | Tdata_t data_in = PORT_READ(in_COUNTER_DATA [i]); |
---|
| 25 | Tdata_t data_out= data_in; |
---|
| 26 | log_printf(TRACE,Counter,"genMealy","before : %d %s = %d",data_in,((addsub==1)?"++":"--"),data_out); |
---|
[2] | 27 | |
---|
| 28 | // Staturate counter |
---|
[3] | 29 | if (addsub == 1) |
---|
[2] | 30 | { |
---|
[3] | 31 | if (data_out < _param._data_max) |
---|
| 32 | data_out++; |
---|
[2] | 33 | } |
---|
| 34 | else |
---|
| 35 | { |
---|
[3] | 36 | if (data_out > 0) |
---|
| 37 | data_out--; |
---|
[2] | 38 | } |
---|
| 39 | |
---|
[3] | 40 | log_printf(TRACE,Counter,"genMealy","after : %d %s = %d",data_in,((addsub==1)?"++":"--"),data_out); |
---|
| 41 | |
---|
| 42 | PORT_WRITE(out_COUNTER_DATA[i], data_out); |
---|
[2] | 43 | } |
---|
| 44 | |
---|
| 45 | log_printf(FUNC,Counter,"genMealy","End"); |
---|
| 46 | }; |
---|
| 47 | |
---|
| 48 | }; // end namespace counter |
---|
| 49 | }; // end namespace generic |
---|
| 50 | }; // end namespace behavioural |
---|
| 51 | }; // end namespace morpheo |
---|
| 52 | #endif |
---|
| 53 | #endif |
---|