4.3. Mapping Application to Platform

The application input model for ESE is C/C++ processes communicating through FIFO channels. Since most legacy application is written in C, this is an advantage over other forms of input styles or languages. For communication, the user does not need to write any SystemC channel code. ESE provides very simple APIs for inter-process communication as we will see in this section.

4.3.1. Add Application Process

The PE window on the top left corner organizes the processes mapped to the various PEs in the design. To add a new process executing on CPU1, change to the CPU1 tab. Then right-click and select Add Process. This will create a new process with a default name.

4.3.2. Assign Name to New Process

Change the name of the new process to "zigzag". This is the process for the zigzag scan in the JPEG encoder application. Please ensure that the process is named correctly since there exist references to it in the existing partial design. If the process is not named as suggested, the generated models will not compile. Create one more process for its name to be "huffencoder" in the same way.

4.3.3. Add C Source File

The process added in the last step is only symbolic. The user must associate the actual C/C++ code with it for the models to be functionally correct. In this case, we add C code by right-clicking on the process name in the PE window and selecting Add .C File for adding ".c" files. And we can also add ".h" files by selecting Add .H File. This will open the file browser.

4.3.4. Select C Source File

Go to the demo directory and follow the symbolic link to "jpeg_srcs". For the "zigzag" proecss, select two ".c" files, "zigzag.c" and "Zigzag_aux.c" ,and one ".h" file, "Zigzag_aux.h", and then click Open. In the same way, for the "huffencode" process, select three files, "HuffEncode_aux.c", "huffencode.c", and "HuffEncode_aux.h". The files will be added under the new process in the PE window.

4.3.5. Add Process Ports

After, the C code for the process is added, we need to add the application level communication to the design. First of all, we need to add the process port for each process, which will be connected to a channel for data transfer to another process. To add the process port for the new process, click on the new process and select the Add Process Port. This will open the window to add the process port. We can create any name for the process port and select the type of it. There are ten possible types. We can categorize them into three kinds. The "Send", "Receive", and "Send/Receive" are used for double handshake channels. The "Read", "Write", and "Read/Write" are used for shared memory. And the others are for the FIFO channels. Finally, we need to assign its function name to be what is actually used in C code. Please ensure that the function name is the same as that used in C code. If the name is not correct, the generated models will not compile.

The "zigzag" process has two process ports. One is for receiving data from "quantize" process and the other is for sending data to "huffencode" process. Assign the process port name to be "q2z_if" for the former and "z2h_if" for the latter. Since we are using FIFO channels, select the type to be "blocking_read" for the former and "blocking_write" for the latter, respectively. Also, assign the function name to be "recv_q2z" and "send_z2h", respectively. The "huffencode" process has only one process port which is for receiveing data from "zigzag". Its process port name is "z2h_if" and its function name is "recv_z2h". Please add all the process ports for all the new processes using the given names.

4.3.6. View Application Channels

After, the process port for the process is added, we need to create the channels for the communication between processes. To view the existing channels, click on the CPU0 tab in PE window. This will display the existing FIFO channels between processes in CPU0, including the source and destination names as well as the route used to implement the channel in the communication platform. In the partial platform, there exist only local FIFO channels for intra-process communication. All the channels in ESE can be uni-directional or bi-directional channels. If the user clicks on a PE in the platform canvas, all the channels originating or terminating at the PE will be selected. All other PEs that the clicked PE communicates with will be highlighted in light yellow. All physical connections, including buses and transducers used by the PE for communication will be highlighted in green.

4.3.7. Add New Application Channel

Please click on CPU1 and see the Channel window. We can know that they are currently not connected at the application level to any other PE. Since we need communication between the "quantize" process in CPU0 and the "zigzag" process in CPU1, we will add the application level channels, by right-clicking in the channel window and selecting Add Channel. This will pop up the channel wizard for adding application level channels.

4.3.8. Channel Wizard for Inter-Process Communication

In the channel wizard dialog, we first need to select the channel type. Choose "FIFO Channel" since we are using FIFOs. Then, assign the channel name to be "q2z" for consistency with existing channels and also assign the FIFO size to be "256" bytes since the processes send/receive an 64-array integer data each other. Next, since the process will send data in one way from "quantize" to "zigzag", select "Unidirectional" using the pull down menu. Then, use the pull down menu to select the first communicating process as "quantize" and also use the next pull down menu to select the process port as "q2z_if". In the same way, select the other communicating process as "zigzag" and select the process porst as "q2z_if". Next, select the mapping to be "TRANSDUCER" since we are using a transducer for the inter-process communication. Once the communicating processes and process ports are decided, ESE automatically filters all the possible physical routes on the platform that can implement the channels. For this example, it shows that there is only one route for each direction that goes over the OPB bus from the sender PE to the transducer Tx0 and back to the receiver PE on the OPB bus. The route goes through the transducer because all PEs in the platform are connected as masters, which does not allow direct communication. The slave interface of Tx0, thus makes the routing possible. Click Add to add the channel.

4.3.9. Channel Wizard for Intra-Process Communication

In order to add the channel for the communication between "zigzag" and "huffencode", right-click in the Channel window and select Add Channel. In the channel wizard dialog, assign the channel name to be "z2h". From the next step, everything is the same as the previous section except the channel mapping and route. Since it is for the intra-communcation, the mapping and route will be automatically set to "LOCAL ACCESS" as shown in the above screenshot. Select the default mapping and route. Finally, click Add to add the channel.

4.3.10. View New Channel Communication

The newly created channels will now be visible in the channel window under the Tx0 tab. Once the channels are selected, the communicating PEs will be highlighted. This shows that the new PE, CPU1 is now "connected" with the rest of the system on an application level.

4.3.11. Add RTOS

As mentioned before, since CPU1 has more than one process and the proecesses should be multi-threaded, we need a RTOS model to control the execution of the processes. To add the RTOS model, right-click on the PE box and select Properties. Then, enable RTOS by clicking the small sqare box. There are two scheduling policies, "Round-Robin" and "Priority". Select one from the two scheduling policies. If you select "Priority" scheduling, then the priority of the processes in the PE will be shown in order. Users can change the priority by using the arrow buttons located at the right side.