#include void cross::dispatch() { for(;;) { sc_bit dest0, dest1; sc_bv r0, r1; r0 = in_0.read(); dest0 = r0[0]; r0 = r0 >> 1; r1 = in_1.read(); dest1 = r1[0]; r1 = r1 >> 1; if ( in_0.event() && ! in_1.event() ) // Event sur 0 { if ( dest0 == 0 ) out_0.write(r0); else out_1.write(r0); cout << "in0: " << r0 << " to " << dest0 << endl; } else if ( in_1.event() && ! in_0.event() ) // Event sur 1 { if ( dest1 == 0 ) out_0.write(r1); else out_1.write(r1); cout << "in1: " << r1 << " to " << dest1 << endl; } else if ( in_0.event() && in_1.event() ) // Event sur 1 et 2 { if ( dest0 == 0 ) out_0.write(r0); else out_1.write(r0); cout << "in0: " << r0 << " to " << dest0 << endl; if ( dest0 != dest1 ) { if ( dest1 == 0 ) out_0.write(r1); else out_1.write(r1); cout << "in1: " << r1 << " to " << dest1 << endl; } else cout << "in1: dropped" << endl; } wait(); } }