# Automatic Configurable Hardware Code Generation for Software-Defined Radios+
## 3 Analysis of SDF-AP Model
The maximum throughput of the SDF-AP model is only bounded by an actor with the longest execution time (\(ET\)) and calculated as  
\[\tau_{max}=\frac{RV(a_{e})\times CR(c_{e})}{RV(a_{e})\times ET_{max}(a)}=\frac{ CR(c_{e})}{ET_{max}(a)}\]  
where \(a_{e}\) is a model sink actor (i.e., \(a_{e}\in\mathcal{A}_{snk}\)), \(c_{e}\) is a model sink channel (i.e., \(c_{e}\in\mathcal{C}_{snk}\)) and \(ET_{max}(a)\) denotes the maximum execution time of the model actor (i.e., actor \(a\in\mathcal{A}\) with the longest \(ET(a)\)). For example, the maximum throughput of SDF-AP model in Figure 1 is  
\[\frac{CR(c1)}{ET(y)}=\frac{3}{5}=0.6\]  
We address the problem of buffer size computation of a bounded SDF-AP model execution under a \(1\)-periodic schedule and a throughput constraint by implementing a buffer sizing algorithm shown in Algorithm 2. To explain this algorithm, we use the model example in Figure 1. Generally, the algorithm accepts the throughput constraint \(\tau_{\mathcal{G}}=\frac{6}{12}=0.5\) of the model and returns a set \(D=\{(c,2)\}\) of channel-buffer size pairs. First the iteration period \(T\) is determined in line 2 as  
\[T=\textsc{Ceil}\left(\frac{RV(a_{e})\times CR(c_{e})}{\tau_{\mathcal{G}}} \right)=\textsc{Ceil}\left(\frac{RV(y)\times CR(c1)}{\tau_{\mathcal{G}}} \right)=\textsc{Ceil}\left(\frac{2\times 3}{0.5}\right)=12\]  
with respect to model sink actor \(a_{e}\in\mathcal{A}_{snk}\) and model sink channel \(c_{e}\in\mathcal{C}_{snk}\) (where \(RV(y)=2\) and \(CR(y)=3\)). The algorithm continues iteratively (line 3) to find the channel buffer size of each channel of the SDF-AP model \(\mathcal{G}\) where there is only one channel (i.e., \(c1\)) in this example. To compute the buffer size for each channel, the initial source actor scheduling period \(\sigma(0,0,u)\) is initialized to \(0\) (line 4). The source actor scheduling period \(\mu(u)\) remains set (line 5) to the scheduling period \(\mu(v_{p})\) of a sink actor from the predecessor channel if the two conditions (lines 6 and 8) of Algorithm 2 do not hold. The first condition ensures that \(\mu(u)\) does not fall below the \(ET(u)\) while the second one applies when the source actor of the channel (i.e., \(u\)) is also a root actor in a model (i.e., \(a_{r}=u\in\mathcal{A}_{src}\)). Figure 2: The \(1\)-periodic scheduling of SDF-AP for example in Figure 1.  
Next, the algorithm determines the initial schedule of the first sink actor instance \(\sigma(0,0,v)\), calculated in line \(11\) as  
\[\sigma(0,0,y)=TC_{CR(c1),p}-CR(c1)+1=3-3+1=1,\]  
and this value remains unchanged as the conditions in lines \(12\) and \(14\) do not hold. The initial schedule of the second sink actor instance \(\sigma(0,1,v)\) is calculated in line \(17\) as  
\[\sigma(0,1,y)=TC_{(2\times CR(c1)),p}-CR(c1)+1=5-3+1=3,\]  
and a sink actor scheduling period \(\mu(v)\) is computed in line \(18\) as  
\[\mu(y)=\sigma(0,1,y)-\sigma(0,0,y)=3-1=2.\]  
To allocate the buffer size \(\theta_{t,c}\) in a channel \(c\) at clock cycle \(t\in\{0...IL\}\), the number of tokens consumed prior to \(t\) is subtracted from the sum of number of produced tokens up to \(t\) and initial delay \(dy\). Given \(TC\) that is computed from \(EP\) as explained in Section 3, the vector \(TC_{*,p}\) is extended to length \(IL+1\) by appending the last element in line \(17\) as  
\[TC_{*,p}\cup TC_{IL-1,p}=[ \begin{array}{cccccccccccccccccccccccccccccccc}0&1&2&2&2&3&4& 4&4&5&6&6&6&6\end{array} ]\]  
and the vector \(TC_{*,q}\) is extended to \(IL+1\) by prepending \(0\) in line \(17\) as  
\[0\cup TC_{*,q}=[ \begin{array}{cccccccccccccccccccccccccccccccc}0&0&0&0&1&1&2&2&3& 4&4&5&5&6\end{array} ].\]The element-wise difference (line 17) of the two vectors above becomes  
\[\theta_{t,c}=[ \begin{array}{cccccccccccccccc}0&1&2&2&1&2&2&2&1&1&2&1&1&0\end{array} ].\]  
This resulting vector \(\theta_{t,c}\) contains the buffer sizes at time \(t\) over one iteration period \(\forall t\in\{0...IL\}\).