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