Changeset 165 for soft/giet_vm/apps/router/main.c
- Timestamp:
- Jul 4, 2012, 2:51:18 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/apps/router/main.c
r160 r165 1 1 #include "stdio.h" 2 #include " srl.h"2 #include "mwmr_channel.h" 3 3 4 4 #define NMAX 200 … … 10 10 unsigned int n; 11 11 unsigned int buf; 12 srl_mwmr_tmwmr;12 mwmr_channel_t* mwmr; 13 13 14 srl_log_printf( TRACE, "*** Starting task producer on processor %d",procid() );15 srl_log_printf( TRACE, " at cycle %d ***\n\n",proctime() );14 giet_tty_printf( "*** Starting task producer on processor %d", giet_procid() ); 15 giet_tty_printf( " at cycle %d ***\n\n", giet_proctime() ); 16 16 17 if( vobj_get_vbase( "router" , "mwmr_in", MWMR, (unsigned int*)&mwmr ) ) 17 if( giet_vobj_get_vbase( "router" , 18 "mwmr_in", 19 VOBJ_TYPE_MWMR, 20 (void*)&mwmr ) ) 18 21 { 19 srl_log_printf( NONE, "\n[ERROR] in producer task :\n"); 20 srl_log_printf( NONE, " undefined <mwmr_in> channel: %d\n", mwmr); 21 srl_log_printf( TRACE, "*** &mwmr_in = %x\n\n", (unsigned int)mwmr ); 22 exit(); 23 } 24 else 25 { 26 srl_log_printf( TRACE, "*** &mwmr_in = %x\n\n", (unsigned int)mwmr ); 22 giet_tty_printf( "\n[ERROR] in producer task :\n"); 23 giet_tty_printf( " undefined <mwmr_in> channel: %d\n", mwmr); 24 giet_tty_printf( "*** &mwmr_in = %x\n\n", (unsigned int)mwmr ); 25 giet_exit(); 27 26 } 28 27 … … 31 30 { 32 31 buf = n; 33 srl_mwmr_write( mwmr, &buf , 1 );34 srl_log_printf( TRACE,"transmitted value : %d\n", buf);32 mwmr_write( mwmr, &buf , 1 ); 33 giet_tty_printf( "transmitted value : %d\n", buf); 35 34 } 36 35 37 srl_log_printf( TRACE, "\n*** Completing producer task at cycle %d ***\n",proctime());38 exit();36 giet_tty_printf( "\n*** Completing producer task at cycle %d ***\n", giet_proctime()); 37 giet_exit(); 39 38 40 39 } // end producer() … … 45 44 unsigned int n; 46 45 unsigned int buf[5]; 47 srl_mwmr_tmwmr;46 mwmr_channel_t* mwmr; 48 47 49 srl_log_printf( TRACE, "*** Starting task consumer on processor %d",procid() );50 srl_log_printf( TRACE, " at cycle %d ***\n\n",proctime() );48 giet_tty_printf( "*** Starting task consumer on processor %d", giet_procid() ); 49 giet_tty_printf( " at cycle %d ***\n\n", giet_proctime() ); 51 50 52 if ( vobj_get_vbase( "router" , "mwmr_out", MWMR, (unsigned int*)&mwmr ) ) 51 if ( giet_vobj_get_vbase( "router" , 52 "mwmr_out", 53 VOBJ_TYPE_MWMR, 54 (void*)&mwmr ) ) 53 55 { 54 srl_log_printf( NONE, "\n[ERROR] in consumer task :\n"); 55 srl_log_printf( NONE, " undefined <mwmr_out> channel\n"); 56 exit(); 57 } 58 else 59 { 60 srl_log_printf( TRACE, "*** &mwmr_out = %x\n\n", (unsigned int)mwmr ); 56 giet_tty_printf( "\n[ERROR] in consumer task :\n"); 57 giet_tty_printf( " undefined <mwmr_out> channel\n"); 58 giet_exit(); 61 59 } 62 60 … … 64 62 for(n = 0 ; n < NMAX ; n = n+5 ) 65 63 { 66 srl_mwmr_read( mwmr, buf , 5 );67 srl_log_printf( TRACE,"received token %d / value = %d\n", n , buf[0]);68 srl_log_printf( TRACE,"received token %d / value = %d\n", n+1, buf[1]);69 srl_log_printf( TRACE,"received token %d / value = %d\n", n+2, buf[2]);70 srl_log_printf( TRACE,"received token %d / value = %d\n", n+3, buf[3]);71 srl_log_printf( TRACE,"received token %d / value = %d\n", n+4, buf[4]);64 mwmr_read( mwmr, buf , 5 ); 65 giet_tty_printf( "received token %d / value = %d\n", n , buf[0]); 66 giet_tty_printf( "received token %d / value = %d\n", n+1, buf[1]); 67 giet_tty_printf( "received token %d / value = %d\n", n+2, buf[2]); 68 giet_tty_printf( "received token %d / value = %d\n", n+3, buf[3]); 69 giet_tty_printf( "received token %d / value = %d\n", n+4, buf[4]); 72 70 } 73 71 74 srl_log_printf( TRACE, "\n*** Completing consumer task at cycle %d ***\n",proctime());75 exit();72 giet_tty_printf( "\n*** Completing consumer task at cycle %d ***\n", giet_proctime()); 73 giet_exit(); 76 74 77 75 } // end consumer() … … 83 81 unsigned int x; 84 82 unsigned int tempo; 85 srl_mwmr_tmwmr_in ;86 srl_mwmr_tmwmr_out ;83 mwmr_channel_t* mwmr_in ; 84 mwmr_channel_t* mwmr_out ; 87 85 88 86 89 srl_log_printf( TRACE, "*** Starting task router on processor %d at cycle %d ***\n\n",90 procid(),proctime() );87 giet_tty_printf( "*** Starting task router on processor %d", giet_procid() ); 88 giet_tty_printf( " at cycle %d ***\n\n", giet_proctime() ); 91 89 92 if ( vobj_get_vbase( "router" , "mwmr_out", MWMR, (unsigned int*)&mwmr_out ) ) 90 if ( giet_vobj_get_vbase( "router" , 91 "mwmr_out", 92 VOBJ_TYPE_MWMR, 93 (void*)&mwmr_out ) ) 93 94 { 94 srl_log( NONE, "\n[ERROR] in router task :\n"); 95 srl_log( NONE, " undefined <mwmr_in> channel\n"); 96 exit(); 97 } 98 else 99 { 100 srl_log_printf( TRACE, "*** &mwmr_out = %x\n\n", (unsigned int)mwmr_out ); 95 giet_tty_printf( "\n[ERROR] in router task :\n"); 96 giet_tty_printf( " undefined <mwmr_in> channel\n"); 97 giet_exit(); 101 98 } 102 99 103 if ( vobj_get_vbase( "router" , "mwmr_in", MWMR, (unsigned int*)&mwmr_in ) ) 100 if ( giet_vobj_get_vbase( "router" , 101 "mwmr_in", 102 VOBJ_TYPE_MWMR, 103 (void*)&mwmr_in ) ) 104 104 { 105 srl_log( NONE, "\n[ERROR] in router task :\n"); 106 srl_log( NONE, " undefined <mwmr_out> channel\n"); 107 exit(); 108 } 109 else 110 { 111 srl_log_printf( TRACE, "*** &mwmr_in = %x\n\n", (unsigned int)mwmr_out ); 105 giet_tty_printf( "\n[ERROR] in router task :\n"); 106 giet_tty_printf( " undefined <mwmr_out> channel\n"); 107 giet_exit(); 112 108 } 113 109 … … 115 111 while(1) 116 112 { 117 srl_mwmr_read( mwmr_in , buf , 2 );118 tempo = rand() >> 6;113 mwmr_read( mwmr_in , buf , 2 ); 114 tempo = giet_rand() >> 6; 119 115 for ( x = 0 ; x < tempo ; x++ ) asm volatile (""); 120 srl_log_printf( TRACE,"token value : %d / temporisation = %d\n", buf[0], tempo);121 srl_log_printf( TRACE,"token value : %d / temporisation = %d\n", buf[1], tempo);122 srl_mwmr_write( mwmr_out, buf , 2 );116 giet_tty_printf( "token value : %d / temporisation = %d\n", buf[0], tempo); 117 giet_tty_printf( "token value : %d / temporisation = %d\n", buf[1], tempo); 118 mwmr_write( mwmr_out, buf , 2 ); 123 119 } 124 120 }
Note: See TracChangeset
for help on using the changeset viewer.