03.08.2013 Views

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Component implementation <strong>for</strong> COUNTER.<br />

char init(){<br />

_counter = 0;<br />

return 1;<br />

}<br />

void fire(){<br />

_counter++;<br />

CALL_COMMAND(fireOut)(_counter);<br />

}<br />

Figure 3: Fragment <strong>of</strong> code <strong>for</strong> implementation <strong>of</strong> the COUNTER component<br />

shown in Figure 1. This provides the method bodes <strong>for</strong> the interface defined<br />

in Figure 2. The internal variable counter is <strong>of</strong> type short.<br />

<strong>and</strong> USESC refer to method calls <strong>and</strong> may be connected to ports in INPORT SM <strong>and</strong><br />

OUT PORT SM, INPORT SM <strong>and</strong> OUT PORT SM are not executable. Additionally, ports<br />

in INPORT SM that are connected to ports in OUT PORT SM contain an implicit queue (see<br />

Section 2.3.4).<br />

Initialization methods in INITM are slightly different from input ports in INPORT SM;<br />

they do not contain implicit queues since buffering <strong>of</strong> data is not needed during initializa-<br />

tion.<br />

Figure 4 gives the module definition code <strong>for</strong> the module count in the application<br />

shown in Figure 1. The definition states that module count contains two components,<br />

COUNTER <strong>and</strong> CLOCK. Note that component CLOCK accepts init() <strong>and</strong> uses fireOut();<br />

component COUNTER accepts init() <strong>and</strong> fire(), <strong>and</strong> uses fireOut() (see Figure<br />

2. The init section states that the init() method <strong>of</strong> component COUNTER belongs<br />

to the initialization list <strong>of</strong> the module. The connection section at the bottom <strong>of</strong> Figure 4<br />

declares that the fireOut() method <strong>of</strong> component CLOCK is mapped to the fire()<br />

method <strong>of</strong> component COUNTER; the fireOut() method <strong>of</strong> component COUNTER is<br />

mapped to the count_out outport <strong>of</strong> module count; <strong>and</strong> that the count_start in-<br />

port <strong>of</strong> module count is mapped to the init() method <strong>of</strong> component CLOCK.<br />

10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!