source: soft/giet_vm/router/main.c @ 306

Last change on this file since 306 was 295, checked in by alain, 10 years ago

Introducing a major release, to suppoort the tsar_generic_leti platform
and the various (external or internal) peripherals configurations.
The map.xml format has been modified, in order to support the new
vci_iopic componentand a new policy for peripherals initialisation.
The IRQs are nom described in the XICU and IOPIC components
(and not anymore in the processors).
To enforce this major change, the map.xml file signature changed:
The signature value must be: 0xDACE2014

This new release has been tested on the tsar_generic_leti platform
for the following mappings:

  • 4c_4p_sort_leti
  • 4c_4p_sort_leti_ext
  • 4c_4p_transpose_leti
  • 4c_4p_transpose_leti_ext
  • 4c_1p_four_leti_ext
File size: 3.2 KB
Line 
1#include "stdio.h"
2#include "mwmr_channel.h"
3#include "mapping_info.h"
4#include "hard_config.h"
5
6#define NMAX 50
7
8/////////////////////////////////////////////
9__attribute__ ((constructor)) void producer()
10{
11
12    unsigned int        n;
13    unsigned int        buf;
14    mwmr_channel_t*     mwmr;
15
16    unsigned int    procid     = giet_procid();
17    unsigned int    cluster_xy = procid/NB_PROCS_MAX;
18    unsigned int    lpid       = procid%NB_PROCS_MAX;
19    unsigned int    x          = cluster_xy >> Y_WIDTH;
20    unsigned int    y          = cluster_xy & ((1<<Y_WIDTH)-1);
21
22    giet_tty_printf( "*** Starting task producer on processor[%d,%d,%d] at cycle %d\n\n", 
23                      x, y, lpid, giet_proctime() );
24
25    giet_vobj_get_vbase( "router" , 
26                         "mwmr_in", 
27                         (void*)&mwmr );
28
29    // main loop : display token value = source index
30    for(n = 0 ; n < NMAX ; n++) 
31    { 
32        buf = n;
33        mwmr_write( mwmr, &buf , 1 );
34        giet_tty_printf( "transmitted value : %d\n", buf);
35    }
36
37    giet_exit( "Producer task completed");
38
39} // end producer()
40
41/////////////////////////////////////////////
42__attribute__ ((constructor)) void consumer()
43{
44    unsigned int        n;
45    unsigned int        buf;
46    mwmr_channel_t*     mwmr;
47
48    unsigned int    procid     = giet_procid();
49    unsigned int    cluster_xy = procid/NB_PROCS_MAX;
50    unsigned int    lpid       = procid%NB_PROCS_MAX;
51    unsigned int    x          = cluster_xy >> Y_WIDTH;
52    unsigned int    y          = cluster_xy & ((1<<Y_WIDTH)-1);
53
54    giet_tty_printf( "*** Starting task consumer on processor[%d,%d,%d] at cycle %d\n\n", 
55                      x, y, lpid, giet_proctime() );
56
57    giet_vobj_get_vbase( "router" , 
58                         "mwmr_out", 
59                         (void*)&mwmr );
60
61    // main loop : display token arrival index and value
62    for(n = 0 ; n < NMAX ; n++ ) 
63    { 
64        mwmr_read( mwmr, &buf , 1 );
65        giet_tty_printf( "received token %d / value = %d\n", n  , buf);
66    }
67
68    giet_exit( "Consumer task completed");
69
70} // end consumer()
71
72///////////////////////////////////////////
73__attribute__ ((constructor)) void router()
74{
75    unsigned int        buf;
76    unsigned int        n;
77    unsigned int        tempo;
78    mwmr_channel_t*     mwmr_in ;
79    mwmr_channel_t* mwmr_out ;
80
81    unsigned int    procid     = giet_procid();
82    unsigned int    cluster_xy = procid/NB_PROCS_MAX;
83    unsigned int    lpid       = procid%NB_PROCS_MAX;
84    unsigned int    x          = cluster_xy >> Y_WIDTH;
85    unsigned int    y          = cluster_xy & ((1<<Y_WIDTH)-1);
86
87    giet_tty_printf( "*** Starting task router on processor[%d,%d,%d] at cycle %d\n\n", 
88                      x, y, lpid, giet_proctime() );
89
90    giet_vobj_get_vbase( "router" , 
91                         "mwmr_out", 
92                         (void*)&mwmr_out );
93
94    giet_vobj_get_vbase( "router" , 
95                         "mwmr_in", 
96                         (void*)&mwmr_in );
97    // main loop
98    while(1)
99    {
100        mwmr_read( mwmr_in , &buf , 1 );
101        tempo = giet_rand() >> 6;
102        for ( n = 0 ; n < tempo ; n++ ) asm volatile ("");
103        giet_tty_printf( "token value : %d / temporisation = %d\n", buf, tempo);
104        mwmr_write( mwmr_out, &buf , 1 );
105    }
106}
Note: See TracBrowser for help on using the repository browser.