|
8
Using the SPB-C Simulator
Introduction
The SPB-C simulator works by creating, compiling, and running a C program for each simulation run. Once compiled, a simulation program is executed more efficiently than by the SPB-I simulator. The speed advantage of SPB-C is particularly useful for long, complex simulations or for repeated simulations of the same system using different parameter settings.
Note: In versions of SPW prior to SPW 4.0, SPB-C was known as the Code Generation System or CGS.
SPB-C produces the same results as the SPB-I simulator. You can use probes and override or sweep parameters just as you can with the SPB-I simulator. However, SPB-C does not have the debugging capabilities of SPB-I.
Notch Filter Simulation
In this section, you simulate the notch filter test system that you built in Chapter 3, yourlib/notchtest.system. A test signal that you created in Chapter 4, yourlib/noisy.sig, is the input signal.
A prerequisite to this tutorial procedure is the corresponding SPB-I tutorial procedure, "Notch Filter Simulation" in Chapter 6, "Using the SPB-I Simulator"
The results of the SPB-C simulation should be the same as for the SPB-I simulation.
Display and Modify the System Design
- Display the notch60 test system, yourlib/notchtest.system, in a BDE design window.
- Change the Sink block's Library/File name parameter from 'yourlib/test_out' to an empty string (just two apostrophe characters).
This prevents the existing output signal from being overwritten by the SPB-C simulation. Instead, the Simulation Manager saves the output signal in the toolrun.
Note: It is not necessary to save the modified design in order to simulate it. The Simulation Manager uses the edited design in the design window, when available, rather than the design stored on disk.
Prepare for SPB-C Simulation
- If you have not already done so, invoke the Simulation Manager from the design window using the following command:
- Verify that the toolrun name in the title bar of the Simulation Manger window is yourlib/notchtest.toolrun. If necessary, change it to that name with the File-Open command.
- In the Simulation Manager window, change the Engine option button setting from SPB-I to SPB-C.
Invoking the SPB-C simulator changes the options in the Simulation page as shown in Figure 8-1. There is an additional Tool Launch button called Edit C.
Figure 8-1 Simulation Page and Buttons in SPB-C Mode
For normal use, you would leave the Create, Run and Debug options toggled on so that all operations are performed. However, for this tutorial, you perform these steps separately.
Create the Simulation Program
- In the Simulation Control area, click on the Start button.
- Watch the status line and the system message area for the program creation status.
SPB-C generates a hierarchical netlist from the BDE design, flattens the hierarchy and schedules the code for each block, and creates a simulation program in the C programming language.
SBP-C automatically performs a compile operation to prepare the code for execution on the local host.
- Allow the operation to run to completion.
- In the Tool Launch area, click on the Edit C button.
The Simulation Manager displays the generated C source code in a text editor window.
Note: SPW uses the "vi" text editor by default. To have SPW use a different text editor, set the EDITOR environment variable to the name of your editor. For example, in a C shell, execute the command "setenv EDITOR emacs" to use the "emacs" editor.
- Remove the text editor window by executing the editor's "quit" command. For the "vi" text editor, this is the "quit" command:
Escape : q Return
Run the Simulation Program
View the Simulation Results
- Click on the SigCalc button.
SigCalc displays the simulation Files Preview dialog box, which lists the simulation input and output signals.
- In the simulation Files Preview dialog box, click on the OK button.
The simulator displays the input signal and output signal.
- In SigCalc, set the value in the Win Size field to 2000 if it is not already set to that value.
Compare your results to Figure 8-2.
Figure 8-2 Notch Filter SPB-C Simulation Results
The results are the same as for the SPB-I simulator.
Using the Debugger
An SPB-C system can be simulated using a debugger on Linux, HP or Solaris platforms. A debugger lets you interactively start, stop, and progress one step at a time through the simulation. You can set breakpoints that stop the simulation each time the code associated with a block instance is executed.
This section contains instructions and concepts that will enable you to understand the role of a debugger and also how to use it. For an example, we will take a system that implements a 60Hz notch filter.
Preparing for Debug
Before using the debug feature, perform the following steps:
- Make sure that you have the appropriate debugger location in your PATH variable
- If you have not already done so, display the hds_demo/notch.system, in a BDE design window.
- Select Tools - Simulation Manager... to invoke the Simulation Manager from the design window.
- Verify that the toolrun name on the title bar of the Simulation Manger window is yourlib/notch.toolrun. If necessary, change it with the File - Save As option.
Simulation Manager uses the cgsDebug.csh script to invoke a debugger. By default, this file is stored in the $SPW_HOME/caesys/nui/data/config/cgsDebug directory. You may modify the script to suit your requirements. A sample of the default cgsDebug.csh script is shown in Figure 8-3 below:
Figure 8-3 Default cgsDebug.csh Script
Simulation Manager searches for the cgsDebug.csh script in the following locations, in the order they are listed:
Note: If you have a customized cgsDebug.csh script, ensure that it is available in either of the first two locations.
Invoke the Debugger
- In the Simulation page of the Simulation Manager window, toggle on the Debug option.
- Verify that the Simulation Manager fields and options are set as follows:
- Click Start.
After a brief delay, the debugger window will be launched. SPW also enables you to debug on a remote host in conjunction with the remote simulation feature. For example, if you are running a remote simulation on the Linux platform, you may invoke the Linux debugger for that simulation.
Following are some of the debuggers that can be used and their respective platform.
The procedure for using a debugger tool will be available with the product documentation of that tool.
Searching for Block-Specific Code
SPW forms a cohesive link to the debugger, which enables optimal usage of the feature. For example, if you have multiple instances of a leaf-level block, you can search for it by specifying lib/cell.symbol / instance_id as the search string. The instance_id parameter is optional and need not be provided.
If precise details about the block, such as instance_id, are not known, you can use BDE to determine them. To do this, perform the following:
This will give you precise details of the block in the lib/cell.symbo/instance_id format. This information can be used as the search string.
Note: Once the debugger is invoked, you will have to close the session to return control to the Simulation Manager.
Probes
You can use probes with SPB-C just as you can with SPB-I.
A prerequisite to this tutorial procedure is the corresponding SPB-I tutorial procedure, "Using Probes" in Chapter 6, "Using the SPB-I Simulator" You run the same simulation using SPB-C. The results should be the same as for the SPB-I simulation.
Display and Modify the System Design
Note: It is not necessary to save the modified design in order to simulate it.
Invoke the Toolrun Containing Probes
- If you have not already done so, invoke the Simulation Manager.
- In the Simulation Manager, execute the following command:
- In the dialog box, enter the following toolrun name:
yourlib/notchtest.toolrun_probe
- Click on the OK button.
This loads your previously saved toolrun containing a set of two probes.
- Click on the Probes tab to view the Probes page and verify that the two probes are there.
If the probes are not there, double-click on the notch60 block to display its context window. Then follow the steps in the sections "Add Probes" and "Save the Toolrun" in Chapter 6, "Using the SPB-I Simulator"
- In the design window, double-click on the notch60 block to display the context window for the notch60 detail.
The two probes are displayed in the context window.
Invoke the SPB-C Simulator
Run the Simulation
View the Results
- In the Tool Launch section, click on the SigCalc button.
- In the simulation Files Preview dialog box, click on the OK button.
SigCalc displays the same results as the corresponding SPB-I simulation, as shown in "Notch Filter Simulation Results" and "Probe Signals" in Chapter 6, "Using the SPB-I Simulator"
Overriding Parameters
You can override parameters with SPB-C just as you can with SPB-I.
A prerequisite to this tutorial procedure is the corresponding SPB-I tutorial procedure, "Overriding Parameters" in Chapter 6, "Using the SPB-I Simulator" You run the same simulation using SPB-C. The results should be the same as for the SPB-I simulation.
Display and Modify the System Design
Note: It is not necessary to save the modified design in order to simulate it.
Invoke the Toolrun Containing Parameter Overrides
- If you have not already done so, invoke the Simulation Manager.
- In the Simulation Manager, execute the following command:
- In the dialog box, enter the following toolrun name:
yourlib/notchtest.toolrun_over
- Click on the OK button.
This loads your previously saved toolrun containing two coefficient parameter overrides.
- Click on the Parameters tab to view the Parameters page and verify that the two parameter override values are 0.997.
Invoke the SPB-C Simulator
Run the Simulation
View the Results
- In the Tool Launch section, click on the SigCalc button.
- In the simulation Files Preview dialog box, click on the OK button.
SigCalc displays the same results as the corresponding SPB-I simulation, as shown in Figure 6-18 in Chapter 6, "Using the SPB-I Simulator"
Sweeping Parameters
You can sweep parameters with SPB-C just as you can with SPB-I.
A prerequisite to this tutorial procedure is the corresponding SPB-I tutorial procedure, "Sweeping Parameters" in Chapter 6, "Using the SPB-I Simulator" You run the same parameter sweep using SPB-C. The results should be the same as for the SPB-I parameter sweep.
Load the System Design
- In an empty design window, execute the following command:
- In the File Open dialog box, select the following logical grouping:
>Iterate Example>BPSK Bit Error Rate
- Click on the OK button to display the block diagram.
- Change the Sink block's Library/File name parameter from 'demo_out/iterate' to an empty string (just a pair of apostrophe characters).
Note: It is not necessary to save the modified design in order to simulate it.
Invoke the Toolrun Containing Parameter Sweeps
- If you have not already done so, invoke the Simulation Manager.
- In the Simulation Manager, execute the following command:
- In the dialog box, enter the following toolrun name:
yourlib/iterate.toolrun
- Click on the OK button.
This loads your previously saved toolrun containing two parameter sweep specifications.
- Click on the Parameters tab to view the Parameters page and verify that the two parameter sweeps are defined as follows:
Invoke the SPB-C Simulator
Run the Simulations
Plot the Results
To plot the results in an XvsY plot window, follow the procedure shown in "Plot the Results" in Chapter 6, "Using the SPB-I Simulator" You should obtain the same results as before.
|
CoWare CoWare's Web Site Phone: 1-888-269-2738 CoWare Customer Support |