[78] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Sort_genMealy.cpp 123 2009-06-08 20:43:30Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Generic/Sort/include/Sort.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace generic { |
---|
| 14 | namespace sort { |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #undef FUNCTION |
---|
| 18 | #define FUNCTION "Sort::genMealy" |
---|
| 19 | void Sort::genMealy (void) |
---|
| 20 | { |
---|
| 21 | log_printf(FUNC,Sort,FUNCTION,"Begin"); |
---|
| 22 | |
---|
[123] | 23 | if (PORT_READ(in_NRESET)) |
---|
| 24 | { |
---|
[78] | 25 | sort_t array [_param->_nb_input]; |
---|
| 26 | |
---|
| 27 | // Push input in a array |
---|
| 28 | for (uint32_t i=0; i<_param->_nb_input; i++) |
---|
| 29 | { |
---|
| 30 | array[i].index = i; |
---|
| 31 | array[i].val = PORT_READ ( in_INPUT_VAL [i]); |
---|
| 32 | array[i].data = PORT_READ ( in_INPUT_DATA [i]); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | // Sort array |
---|
| 36 | //if (_param->_ascending == true) |
---|
| 37 | std::stable_sort(array, array+_param->_nb_input); |
---|
| 38 | |
---|
| 39 | // Write output |
---|
| 40 | for (uint32_t i=0; i<_param->_nb_output; i++) |
---|
| 41 | { |
---|
| 42 | PORT_WRITE (out_OUTPUT_VAL [i],array[i].val ); |
---|
| 43 | if (_param->_have_port_index_out) |
---|
| 44 | PORT_WRITE (out_OUTPUT_INDEX [i],array[i].index); |
---|
| 45 | if (_param->_have_port_data_out) |
---|
| 46 | PORT_WRITE (out_OUTPUT_DATA [i],array[i].data ); |
---|
| 47 | } |
---|
[123] | 48 | } |
---|
[78] | 49 | |
---|
| 50 | log_printf(FUNC,Sort,FUNCTION,"End"); |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | }; // end namespace sort |
---|
| 54 | }; // end namespace generic |
---|
| 55 | |
---|
| 56 | }; // end namespace behavioural |
---|
| 57 | }; // end namespace morpheo |
---|
| 58 | #endif |
---|