Table of Contents
Previous Chapter
The following assumes that the user has completed Tutorial Example 1.
This example is an altered version of Example 1. There are now ten adder nodes instead of two and each adder prints it's number and the sum it has calculated when it completes. Replication is used to produce the ten adders.
Contents of the Tutorial
I. Preliminaries
I. Preliminaries
Get the X-Windows system running. Create a directory to hold the files associated with the program and move to that directory. Before running CODE, ensure that it is present on your UNIX path. Then enter
code2 rsum.grf
at the UNIX prompt. This will run CODE and open a program called "rsum". A single window will be opened and all activity will take place within it. Fig. 4.1 shows the CODE window.
II. Entering Example 2
Our goal is to draw the following graph:
Figure 5.2.1
You may enter and annotate the nodes and arcs of your program in any order, but we will adopt the following sequence of operations:
Step 1. Draw all the nodes and arcs in a graph.
STEP 1. Draw all the Nodes and Arcs in a Graph
A. Draw all the nodes.
1.Draw the UC node, INIT by
a. Position the create cursor in the CODE window, where the UC INIT is to be located.
2. Draw the UCs ADD[10] and PRINTSUM.
.
B. Draw all the arcs.
1. Draw the arc V_IN[10] by,
a. With the create cursor, click on the lower arrow of UC, INIT.
2. Draw the arc SUM_OUT[10].
At this point the graph looks like Fig. 5.2.2.
Fig. 5.2.2
A. Enter information about the nodes
1. Enter information about INIT
b. Click the open cursor on the UC INIT to open its attribute form. It looks like Fig.5.2.3
Fig. 5.2.3
d. The value in the UID field is automatically generated by CODE. It is a debugging aid
g. Click on the Node Specification field. A text box labelled 'Text of UC Specs' will
i. To exit the UC INIT attribute form, click on the white space outside the form in the
cursor.
Specification field of ADD[10] is as shown below,
3. Enter information about PRINTSUM as in 1.
code to be entered in the Node Specification field of PRINTSUM is as shown below,
The name 'INIT' will be displayed next to the node, but you can move it with the Move
2. Enter information about ADD[10] as in 1.
The one difference is that ADD[10] is not a Start node. The code to be entered in the Node
The one difference is that PRINTSUM must be designated as a termination node. The
B. Enter information about the arcs
1. Enter information about V_IN[10]
a. Click the open cursor on the arc V_IN[10] to open its attribute form. It looks like Fig.
b. Click on the name field and a text box will appear. Enter the name 'V_IN[10]' in this
c. The value in the UID field is automatically generated by CODE.
d. Click on the Arc Topology Rule field and another text box will appear. The code to be
e. Exit from both the text box and the form by clicking on the white space outside the
The name 'V_IN[10]' will be displayed next to the arc, but you can move it with the Move
cursor.
2. Enter information about SUM_OUT[10] as in 1.
The Arc Topology Rule field of SUM_OUT[10] is,
C. Enter information about the program
a. Click the open cursor on the Program button in the CODE window, to open its
Fig. 5.2.5
c. Click on the Global Types field and a text box will appear. The code to be entered in
d. Click on the Global Function Signatures field and another text box will appear. The
e. The Global Function Definitions and Documentation fields are to be left blank.
f. Click on the Translation Options field, to bring up it's attribute form. Now, click on the
g. Exit from the program form by clicking on the white space outside the form in the
III. Executing Example2 on the Sequent
We will now compile and run the program in the following order:
Step 1. Save and compile the program.
STEP 1. Save and Compile the Program
a. Click on the Save button.
example1.
At this stage, the following files and directories will be present under the directory
STEP 2. Create the Files which record the Node Function Definitions
$cd ./rsum.sequent The following files will be present in this directory.
$vi filename.c Record all node function definitions in this file. Give it the same
These directories will be present under the directory in which
CODE2 has been installed.
STEP 3. Create the executable and run it
Tutorial 1.
$rlogin qt
$make This will create the executable 'rsum'.
below,
These operations will depend on how your workstation is connected to the Sequent, as in
After having logged in on the Sequent, give the following commands,
$cc -c filename.c Compile the file specifying node function definitions.
$./rsum Run the executable. The output displayed should be that shown