Loesung des Praktikums Systementwurf - Bjarne Hoesch - Bernhard Schoeffel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

binding.c 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "binding.h"
  2. #include "signal_processing.h"
  3. #include <stdio.h>
  4. static const char * BINDING_HW_STRING = "HW";
  5. static const char * BINDING_SW_STRING = "SW";
  6. static const char * UNKOWN_STRING = "UNKOWN_STRING";
  7. void binding_from_value( uint32_t value, uint32_t * binding ) {
  8. for ( uint32_t i = 0; i < TASK_COUNT; ++i ) {
  9. binding[ i ] = value & 1;
  10. value >>= 1;
  11. }
  12. }
  13. int binding_get_channel_binding( const uint32_t * connections,
  14. const uint32_t * binding,
  15. uint32_t n,
  16. DataChannelBinding * channel_binding ) {
  17. if ( n >= CHANNEL_COUNT ) {
  18. printf( "ERROR in %s: %" PRIu32 " not a valid channel number\n",
  19. __func__, n );
  20. return 1;
  21. }
  22. channel_binding->sink = binding[ n ];
  23. channel_binding->source = binding[ connections[ n ] ];
  24. return 0;
  25. }
  26. const char * binding_to_string( uint32_t binding ) {
  27. switch ( binding ) {
  28. case BINDING_SW: return BINDING_SW_STRING;
  29. case BINDING_HW: return BINDING_HW_STRING;
  30. }
  31. return UNKOWN_STRING;
  32. }