Showing posts with label Fixed Point. Show all posts
Showing posts with label Fixed Point. Show all posts

Friday, September 24, 2010

Model Based Design – VIP Appln -04


Model-Based Design to Develop and Deploy a
Video Processing Application

04 Implementing and Verifying the Application on TI Hardware

Using Real-Time Workshop® and Real-Time Workshop Embedded Coder, we automatically generate code and implement our embedded video application on a TI C6400™ processor using the Embedded Target for TI C6000™ DSP. To verify that the implementation meets the original system specifications, we can use Link for Code Composer Studio™ to perform real-time "Processor-in-the-Loop" validation and visualization of the embedded application.
Before implementing our design on a TI C6416DSK evaluation board, we must convert the fixed-point, target-independent model to a target-specific model. For this task we use TCP/IP Send and Receive a TI real-time communications protocol that enables the transfer of data to and from the host.
Creating the target-specific model involves three steps:

  1. Replace the source block of the target-independent model with the "TCP/IP Receive" block and set its parameters.

  2. Replace the Video Viewer block of the target-independent model with the "TCP/IP Send" block and set its parameters.

  3. Set up Real-Time Workshop target-specific preferences by dragging a block specific to our target board from the C6000 Target Preferences from Target Support Package library into the model.



Figure 7: Target-Specific Model.

To automate the process of building the application and verifying accurate real-time behaviour on the hardware, we can create a script, using Link for Code Composer Studio to perform the following tasks:

  1. Invoke the Link for Code Composer Studio IDE to automatically generate the Link for Code Composer Studio project.

  2. Compile and link the generated code from the model.

  3. Load the code onto the target.

  4. Run the code: Send the video signal to the target-specific model from the same input file used in simulation and retrieve the processed video output from the DSP.

  5. Plot and visualize the results in a MATLAB figure window.
Here is the Figure 8, shows the script used to automate embedded software verification for TI DSPs from MATLAB. Link for Code Composer Studio provides several functions that can be invoked from MATLAB to parameterize and automate the test scripts for embedded software verification.

Figure 8: Script used to Automate Embedded Software Verification for TI DSPs from MATLAB

Figure 9 shows the results of the automatically generated code executing on the target DSP. Means, you can observe that the application running on the target hardware properly, and verify that the application meets the requirements of the original model.

Figure 9: Result of the Automatically Generated Code Executing on the Target DSP

After running the application on the target, we may find that algorithm does not meet the real-time hardware requirements. In Model-Based Design, simulation and code generation are based on the same model, and so we can quickly conduct multiple iterations to optimize the design. For example, we can use the profiling capabilities in Link for Code Composer Studio to identify the most computation-intensive segments of our algorithm. Based on this analysis, we can change the model parameters, use a more efficient algorithm, or even replace the general-purpose blocks used in the model with target-optimized blocks supplied with the Embedded Target for TI C6000. Such design iterations help us optimize our application for the best deployment on the hardware target.

TCP/IP Setting Description
This demo is configured to run in an Ethernet network where there is a DHCP server. A DHCP server allows automatic assignment of the IP parameters of the target board. During this process, the status of the Ethernet link as well as the acquired IP address is displayed on the standard output window of the CCS IDE. If you don't have a DHCP server in your network, you must manually configure the IP parameters on the target side model. In order to do this, open the C6000™ IP Config block in the target side model, uncheck Use DHCP to allocate an IP address option and manually enter Use the following IP address, Subnet mask, Gateway IP, Domain name server IP address and Domain name parameters. You must always set Use the following IP address and Subnet mask parameters to meaningful values. As a rule of thumb, leave the Subnet mask parameter at its default value of "255.255.255.0" and set Use the following IP address parameter so that the first three numbers in the IP address assigned to the target board matches to those found in your computer's IP address. For example, if your computer's IP address is "100.101.102.3" you may choose "100.101.102.4" to be assigned to the target board provided that there is no other Ethernet device using IP address "100.101.102.4". Make sure that there are no IP address collisions when assigning an IP address to the target board. If you are unsure about what to enter for any other IP parameter, leave it at its default value.

Model Based Design – VIP Appln -02


Model-Based Design to Develop and Deploy a
Video Processing Application

02 Converting the Design from Floating Point to Fixed Point

To implement this system on a fixed-point processor, we need to convert the algorithm to use fixed-point data types. In a traditional design flow based on C programming, this conversion would require major code modification. Conversion of the Simulink model involves three basic steps:

  1. Change the source block output data types. During automatic data type propagation, Simulink displays messages indicating the need to change block parameters to ensure data type consistency in the model.

  2. Set the fixed-point attributes of the accumulators and product outputs using Simulink Fixed Point tools, such as Min-max and Overflow logging.

  3. Examine blocks whose parameters are sensitive to the pixel values to ensure that these parameters are consistent with the input signal data type. (The interpretation of pixel values depends on the data type. For example, the maximum intensity of a pixel is denoted by a value of 1 in floating point and by a value of 255 in an unsigned 8-bit integer representation.)
This can be done using Fixed-Point Tool or by Fixed-Point Advisor from Tools->Fixed-Point
If this is first time, then start with Fixed-Point Advisor.
This opens a window as shown below:


The Fixed-Point Advisor is broken into four main tasks. Each task addresses one aspect of the conversion process. The tasks are:

  • Prepare Model for Conversion
    • Evaluate model wide configuration options.
    • Create floating-point base line data set.

  • Prepare for Data Typing and Scaling
    • Evaluate block specific configurations.
    • Add design minimum and maximum information to the model.

  • Perform Data Typing and Scaling
    • Propose fixed-point data typing and initial scaling to the blocks.
    • Analyze the resulting fixed-point model behaviour.

  • Prepare for Code Generation
    • Examine issues resulting in inefficient code.

After pressing the button "Run to Failure", tool will run till failure and then opens model advisor window as well as report like as below:



After doing the modification and changes need to run again.
Sometimes, to go directly to the error location we need to use "Explore Result…" Button as shown below.

Which open a window named Model Advisor Result Explorer.

Here select main signals to Log Signal Data from check box and Use Signal name for Logging name from pull up.
This Floating-Point to Fixed-Point conversion is an iterative procedure; we need to run every time after doing small changes in the model. And finally here we go with Fixed-Point Model.

Figure 4: Summary- No Fail.


Figure 5: Resulting Fixed-Point Model.