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