[2] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Counter_genMealy.cpp 123 2009-06-08 20:43:30Z 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 | |
---|
[123] | 20 | if (PORT_READ(in_NRESET)) |
---|
[113] | 21 | for (uint32_t i=0; i<_param->_nb_port; i++) |
---|
[2] | 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 | { |
---|
[113] | 31 | if (data_out < _param->_data_max) |
---|
[3] | 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 |
---|