Section 8.3. Performing Software Simulation


8.3. Performing Software Simulation

Before going through the process of choosing an FPGA-based platform target and compiling/synthesizing the encryption algorithm to that target, we will first use a standard C development environment to verify that the application, including both the legacy C code and the modified Impulse C version of the code, is correct in terms of the computations being performed. Because the Impulse C libraries are compatible with most popular C development environments, we can perform this test using any number of such compiler/debugger environments.

The test bench that we will create for this encryption process will allow us to directly compare the results of both encrypting and decrypting a stream of characters that originate from a text file, as shown in Figure 8-3.

Figure 8-3. Block diagram of the complete encryption/decryption test bench.


As shown in the diagram, the software simulation consists of six distinct processes:

  • A producer test process. This process reads characters of data from an input text file (a sequence of ASCII text characters) and streams the characters one byte at a time into the encryptor. The producer also moves those same characters into an array that will be used by the legacy C version of the encryptor to allow direct comparison of the results.

  • An Impulse C process representing the encryption algorithm. This process (which was summarized in the preceding section) accepts configuration and text data from the consumer and writes the encrypted results one character at a time to its output stream.

  • An Impulse C process representing a decryption algorithm. This process is actually the same process used for the encryption, but with different compile-time parameters.

  • An Impulse C process representing the legacy C algorithm. This process does not accept data on a stream, but instead reads the input characters from the array populated by the producer process. The producer process communicates a "ready" status with this process using a signal to indicate that the array is filled and ready for processing.

  • An Impulse C process representing the legacy C algorithm, with parameters necessary for decryption rather than encryption.

  • A consumer test process. This process accepts the results of both the Impulse C (streaming) version of the encryption and decryption algorithms and the results of the legacy C version (which have been written to a results array) to verify that the new and old versions of the algorithm produce identical results.

This method of creating test benches in C, in which an Impulse C algorithm is tested in parallel with a legacy, known-good algorithm, is extremely useful, particularly when you will be making later C-language optimizations to the algorithm.

By using a standard IDE in conjunction with the Application Monitor provided with the Impulse tools, we can use standard C debugging techniques (including source-level debugging) while observing how data moves between the various processes in the system, which now includes two versions of both the encryption and decryption processes, plus the test consumer and producer processes. The result, using Visual Studio as the debugger, is shown in Figures 8-4 and 8-5.

Figure 8-4. Debugging the Impulse C encryption processing using Visual Studio.


Figure 8-5. Application monitoring.




    Practical FPGA Programming in C
    Practical FPGA Programming in C
    ISBN: 0131543180
    EAN: 2147483647
    Year: 2005
    Pages: 208

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net