Download PDF1 - Greg Gibeling

Transcript
Chapter 7
RDL Examples
One of the easiest ways to learn any new com- Figure 22 Crossbar
puter language, particularly those which are disCrossbarExample
similar to those within the reader’s experience, is
by example. In this section we describe, in detail
In[0]
several examples of RDL ranging from what are esChannel[0][0]
Out[0]
In[1]
sentially compiler test cases (sections 7.1 and 7.2) to
complete RDL systems (sections 7.4 and 7.6). Most
Out[1]
Channel[0][1]
Channel[1][0]
Element[0]
Element[0]
of these examples are available in a more complete,
In[N-1]
source code form along with RDLC itself from [9].
Out[N-1]
The examples in this section are small and easily
Channel[0][N-1]
understandable, and are not commensurate with
genuine applications (see Sections 13, 14 and 15)
In[0]
of RDL which are expected to be at least an order
Out[0]
In[1]
of magnitude more complex.
Channel[1][1]
Out[1]
Element[1]
Element[1]
In[N-1]
7.1
Crossbar
Out[N-1]
Channel[1][N-1]
Program 29 and Figure 22 show the most powerful
use of parameters and inference combined to build
a crossbar of channels. The goal of this example,
originally created as an RDLC2 test case (see Section 9.6), is to declare an array of Elements, and
connect them with an all-to-all crossbar or channels. This is accomplished in 2-4 lines of RDL,
using instance and channel arrays in conjunction
with indexed connections (see Section 6). Furthermore, by using parameter inference, we have reduced the specification of the bitwidth and number
of elements to a single point, line 7, allowing the
remaining values to be inferred.
Walking through the code, lines 1-4 of Program 29 declare simple unit Element which has two
port structures, both of them arrays, one for input
(In) and one for output (Out). Element also has two
parameters, one for the number of ports (NPorts
) and one for the bitwidth of these ports (Width).
Note however, that the parameters are each used
once, meaning that the bitwidth of the messages
sent through the In ports is not specified in this
code and must be inferred. Similarly, the bound
on the Out port array is unspecified and must be
inferred.
Channel[N-1][1]
Channel[N-1][0]
In[0]
Out[0]
In[1]
Out[1]
Element[N-1]
Element[N-1]
In[N-1]
Channel[N-1][N-1]
Out[N-1]
Lines 7-9 of Program 29 are the most interesting. Line 7 instantiates a two dimensional array of
Elements, and uses indexed, positional connections
to connect them to the Channels array instantiated
on line 10. Line 9 in essence is a straight-through
connection from each Element and each Out port to
a channel with the same indices.
The crossbar is created by virtue of the change
between index#0 major array selection and index
#1 major array selection on In port array on line
8. Thus while line 9, creates the connections
∀x, y Out[x][y] → Channel[x][y] line 8 creates the
49