CS/COE 535M Acceleration of Algorithms in Reconfigurable Hardware Lockwood, Fall 2001

Machine Problem 3

Software Data Processing in Reprogrammable Hardware

Assigned Monday, October 8, 2001
Due Date Friday, October 19, 2001, 4pm
Purpose: Introduction of the FPX KCPSM Module
Points50

Introduction

The FPX provides simple and fast mechanisms to process cells or packets directly in hardware. By performing all computations in FPGA hardware, cells and packets can be processing at the full line speed of the card [currently 2.4 Gbits/sec].

Although hardware modules are well suited for processing data with high throughput, software modules are well suited for implementing some complex control functions. For this reason, the FPX KCPSM Module has been implemented for the FPX that executes software on a softcore processor embedded in reprogrammable hardware. By including this design, it is possible to implement active networking functions on the FPX using both hardware and software. The KCPSM, a 8-bit microcontroller from Xilinx Corp. has been embedded into the FPX KCPSM Module. The module includes circuits that allow the program memory of the KCPSM to be dynamically reprogrammed over the network through the use of UDP datagrams. Therefore, the function of the processing module can be changed dynamically, on a packet by packet basis. Currently, up to four packets with a maximum length of 256 bytes can be stored in the module for processing and up to two programs with a maximum length of 256 instructions can be stored in the module for execution.

Background: The FPX KCPSM Module

The FPX KCPSM Module is a small, active, and reconfigurable processing module for the FPX using the Layered Protocol Wrappers and the KCPSM. The Protocol Wrappers process the incoming ATM cells and provide the module with valid UDP packets. The module then loads the contents of the packets into the program or data memory of the processor according to the first word of the payload. If the module takes in a program packet, the KCPSM will reset and run the new program after it has finished processing the current packet. If the module takes in a data packet, the KCPSM will process the new packet after it has finished processing all of the previous packets. When the module is not accepting any incoming packets, it will send the completed program and data packets back to the Layered Protocol Wrappers. The Layered Protocol Wrappers pack the completed packets into valid ATM cells. The block diagram of the FPX KCPSM Module is shown in Figure 1.



Figure 1: Block Diagram of the FPX KCPSM Module

Background: The KCPSM

The KCPSM (Constant (K) Coded Programmable State Machine) is a 8-bit microcontroller and takes only 35 CLBs in a FPGA. It provides 49 different instructions, 16 registers, 256 directly and indirectly addressable ports, and a maskable interrupt at 35 millions instructions per second (MIPS). It can be used in conjunction with an UART to process serial input and output. Its functions and performance are adequate to process packets and control network traffic. The KCPSM was developed by Ken Chapman of Xilinx Corp. and is designed for use with its Virtex and Spartan-II devices. It is provided in the form of an EDIF macro and can be embedded into any FPGA design. It also includes an assembler and debugger for writing and testing programs for the KCPSM. Two modules of dual-port memory are required in order to use the KCPSM. One dual-port memory acts as the program memory while the other acts as the data memory. Both are generated using the COREGEN program provided from Xilinx Corp. The block diagram of the KCPSM is shown in Figure 2.



Figure 2: Block Diagram of the KCPSM

Description of the Assignment

The purpose of the first part of this assignment is to write an assembly program that encrypts / decrypts the string stored in the UDP Payload using the ROT13 algorithm. The purose of the second part of this assignment is to write an assembly program that compresses / decompresses the string stored in the UDP Payload using the RLE algorithm. The purpose of the third part of this assignment is to run both of the assembly programs in simulation using Modelsim.

The tar files for this package can be downloaded here. It consists of six folders, coregen, package, sim, syn, vhdl and wrappers. The coregen folder includes all the files generated from COREGEN. The package folder includes all the files from the KCPSM package from Xilinx Corp. The sim folder includes all the simulation files for use with Modelsim, and the setup is exactly the same as MP1. The syn folder includes the project files for use with Synplicity Pro. The wrappers folder includes all the files from the Layered Protocol Wrappers package. The vhdl folder includes the vhdl files of the FPX_KCPSM module. The contents of the tar file is listed below:

Part 1: A ROT13 KCPSM Program

In this part of the assignment, write a KCPSM program that encrypts / decrypts the string stored in the UDP Payload using the ROT13 algorithm. Follow the steps below in order to generate a ".TBP" file from the ROT13 KCPSM program that can be used for simulation in ModelSim. Refer to Figure 3 to understand the format of a UDP Datagram. The FPX data bus is 32-bit, but the KCPSM data bus is only 8-bit, so the lowest 8-bit (7 downto 0) of the FPX data bus corresponds to byte 0, 4, 8 etc. of the KCPSM Data memory and the highest 8-bit (31 downto 24) of the FPX data bus corresponds to byte 3, 7, 11 etc. of the KCPSM Data memory.





Figure 3: Format of a UDP Datagram

KCPSM Registers, Constants and Special Instructions

The KCPSM has 16 8-bit registers and can be used in the program using the "sX" format, where "X" is one of the following: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. Constants can also be used in the program and is specified in the form of a two-digit hexadecimal value ranging from 0x00 to 0xFF.

The KCPSM provides several instructions used to handle Interrupt and I/O operations:

For detailed explanation of every instruction available to the KCPSM, refer to the KCPSM Application Notes.

KCPSM Program Template

All KCPSM programs should follow a template in order for them to work with the Interface module. A program should first enables the interrupt of the KCPSM so that the Interface unit is able to reset the KCPSM. Next, it should check if a data packet is stored in the memory. If there is no data packet stored in the memory, it should signal to the Interface that it has done processing and there is no write by writing 0x00 to address 0xFF. If there is a data packet stored in the memory, it can start processing. After the processing is done, it should signals to the Interface that it has done processing by writing 0xFF to address 0xFF. Finally, it should suspends the KCPSM. A KCPSM program template can be downloaded here.

Assembling a KCPSM Program

An assembler called KCPSMBLE is included in the KCPSM package from Xilinx Corp and needs to be executed in a PC platform. KCPSM programs are best written using plain text editors such as Notepad. The program file needs to be saved in a 8.3 file format with a .PSM extension.

The command line used to assemble a KCPSM program is: kcpsmble prog_name.psm.

After KCPSMBLE finishes assembling the program, several files are generated:

Debugging a KCPSM Program

A simple debugger called PSMDEBUG is included in the KCPSM package from Xilinx Corp and needs to be executed in a PC platform. It allows the user to test the operation of the program and provides internal program details such as program flow, I/O operations, and values of internal registers and flags. Notice that the ".coe" file used must be the one generated by KCPSMBLE and be unmodified.

The command line used to debug a KCPSM program is: psmdebug prog_name.coe.

Detail instructions on how to debug the program will appear on the screen after PSMDEBUG is executed.

Converting a KCPSM Program

Because the ".coe" file generated by KCPSMBLE is targeted to use with Single-Port block RAMs generated by COREGEN, some modifications to that file must be made before it can be used with the Dual-Port block RAMS. Also, the raw content of the KCPSM program stored in the ".coe" file must be converted before it can be used for simulation or laboratory testing. A C program called CONVERT is written to accomplish these tasks.

The command line used is: convert prog_name.coe.

Two files are generated after the CONVERT program is executed:

Part 2: A RLE KCPSM Program

In this part of the assignment, write a KCPSM program that compresses and another KCPSM program that decompresses the string stored in the UDP Payload using the RLE algorithm. Follow the above steps in order to generate a ".TBP" file from the RLE Encode KCPSM program and another ".TBP" file from the RLE decode KCPSM program that can be used for simulation in ModelSim.

A RLE Encode KCPSM Program

The RLE Encode KCPSM Program compresses the string by replacing the repeating characters by a "count". In order to simplify the problem, the valid input characters are between 'A' to 'Z' and 'a' to 'z', and the maximum repetition is limited to 9. Take a look at the following examples to understand the specifications of the RLE Encode KCPSM Program. Notice that the count is represented as an ASCII number character, not a decimal number, in the encoded string. It is done this way to allow easy testing and verification.

A RLE Decode KCPSM Program

The RLE Decode KCPSM Program decompresses the string by replacing the count with the repeating characters as specified by the value of the count. The valid input of the RLE Decode program includes all the valid output of the RLE Encode program. Take a look at the following examples to understand the specifications of the RLE Decode KCPSM Program.

Part 3: Simulation of the ROT13 and RLE Programs

In this part of the assignment, simulate the ROT13 and RLE KCPSM program in Modelsim.

Using the IPTestbench to Generate Fake ATM Cells for Simulation

A simulation simulation testbench has been setup to test the functionality of this module, which is the same setup as the previous machine problems. In order to generate a fake program packets/cells for simulation, use the ".TBP" file generated by the CONVERT program as the input to the IP2FAKE program. In order to generate a fake data packets/cells for simulation, use a plain text editor to modify the following sample ".TBP" file, and use it as the input to the IP2FAKE program. Please note that the first word of the payload must be 0x00000001 to indicate that it is a data packet/cell. The sample "HELLO.TBP" program can be download here.

The command line option to build the IPTestbench package is: make.

Copy the "INST.TBP" and "HELLO.TBP" file into the iptestbench folder.
The command line option to use the ip2fake program is: ip2fake FILENAME.TBP FILENAME.DAT.

Copy the "INST.DAT" and "HELLO.DAT" into the sim folder. Create a new input file to the testbench by using the "cat" command.
The command line option to use the cat program is: cat WAIT.DAT INST.DAT WAIT.DAT HELLO.DAT > INPUT_CELLS.DAT.

Implementation Hints for the ROT13 and RLE KCPSM Programs

There are some suggestions to approach this assignment:

Things to Turn In

Here is a check list of the things you need to turn in: Please print the grade sheet and staple it on top of your machine problem.