Tutorial - Electrical and Computer Engineering

4 downloads 379 Views 634KB Size Report
Department of Electrical and Computer Engineering ... Tutorial on SystemC modeling using CoCentric Studio. 1. ... You will see Window as shown in Figure 1 .
Department of Electrical and Computer Engineering State University of New York, Stony Brook ESE501 System Specification and Modeling Tutorial on SystemC modeling using CoCentric Studio 1. Environment Setup : You have to modify the .cshrc file in your home directory. Add the following lines. setenv SYNOPSYS_CCSS /usr/local/cocentric/gccsparcOS5/ccss source $SYNOPSYS_CCSS/../gnupackages/source_me.csh setenv LD_LIBRARY_PATH “/usr/lib:/usr/local/lib:$SYNOPSYS_CCSS/libʺ set path=($path /usr/in /usr/dt/bin /usr/local/bin $SYNOPSYS_CCSS/bin /usr/ccs/bin .) (IMP!! :: PLEASE NOTE THE SPACES AND THE . in above lines) Create another file named .cshrc_systemc Type the following lines in it setenv LM_LICENSE_FILE [email protected] setenv SNPSLMD_LICENSE_FILE [email protected] 2. SystemC CoCentric Studio At the unix prompt type ccss& i.e unix promtpt > source .cshrc unix promtpt > source .cshrc_systemc unix promtpt > ccss& You will see Window as shown in Figure 1

Figure 1: CoCentric System Studio

Note : Have a basic knowledge of SystemC before you start using Cocentric System studio. WE will be discussing Architecture level modeling feature of Cocentric System Studio. You have to create driver and monitor modules used for testbench and output debugging respectively. You can also use VirSim to view outputs. But you have to create the driver module for giving input to your design. For SystemC in Cocentric Studio, you have to create your design in Primitive modules. Your have to use Hierarchal module to Group your smaller Primitive modules into one. This will be your top module.

A. Creating a Workspace Select File › New from the System Studio main menu bar. A dialog box appears. The Create Workspace dialog box, shown in Figure 1

Figure 2 : Workspace

B. Creating a Library In the Create Workspace dialog box, with a workspace selected, click the Library tab. The dialog box changes to the Create Library dialog box, as shown in Figure 3. Create a user library under the workspace that you just created. Enter a name in the Name field or use the default name. You can specify a different location for the library directory in the Location field. After you enter a library name (or accept the default name), click Apply.

Figure 3: Library

C. Creating an Architectural Model (PRIMITIVE) : Select the library you have created and then Click on tab Model in the main menu Give the name of your model and then Let the Domain be at Architectural (SystemC) Model for this course. Select Type as ( in the radio button) : Primitive The Mode should be Assisted In the Create field select a model, generate header and source (for new files). a model from header and source (for your already existing files which you can browse and add). Let Use SC_CTOR be checked Then Click Apply D. Writing SystemC code using the Assisted mode In the Design area there are 4 tabs in the bottom namely, Interface, Header, Source and Symbol Interface : Click on Interface tab In this window in the Ports tab type your inputs and outputs in the Name field. In the Port Type field give the type of port you are using. For e.g. sc_in

Figure 4: Interface Header: The header file here is like a normal header file with input output port declarations and constructor. Here you declare your function and use any of the processes like SC_METHOD etc. in the SC_CTOR. You can use Add Member button to add any member functions or data or else you can type it out.

Figure5: Header File

Source : Click on source tab write your SystemC code in that area. E. Compling your Design In the Design tool bar in the Main window as shown in Figure 6, Check your Design. Ignore any warnings like “clock skew error” etc.

Figure 6 : Compiling and checking your design F. Creating the Printer Model The next step is to create a second architectural (SystemC) primitive model in the same library as the first model. This is a simple printer that takes all the outputs of your design as its input. The steps to create this model are the same as for the first model, so some of the explicit detail will be left out. Create this model in the same way as the first model and in the same library, refer to Creating an Architectural primitive model for help with this step. Note: You can directly use Virsim to view output. But in the hierarchical module make sure to connect the ports to signals, i.e bring them out for view purpose. Any unconnected ports will give you warning of “Interface Ports”. G. Creating a Hierarchical Model Now you will create a third architectural model. In this case, the model is a hierarchical model. You will then instantiate the other two models in this model. 1. Create a new hierarchical architectural model in the same library as your primitive models. Note :SELECT Hierarchical type in the Type radio buttons when you are creating a new hierarchical module. 2. Instantiate your two new primitive models in the new schematic (see Figure 8). You can do this by simply dragging and dropping the model instances you want from the workspace window into the design area.

3. Click the Channel button on the schematic toolbar. On the drop-down menu, choose the type you want as the channel type and connect the inputs and outputs

Figure 8: Hierarchical module H. Building your code Select the library containing all three instances. Click the right mouse button, choose Build Object Code, and then choose Debug (see Figure 9).

Figure 9: Building the code

I. Simulating your Design If there are no error messages displayed in the message window, the object code generation has succeeded. You can now generate the code and run the simulation. 1. Click the Code Generation tab. 2. In the code generation window (see Figure 10), select the Compile, Start, and Control panel check boxes. 3. Click the Start button and select Paused to start the simulation in paused mode. 4. Enter a simulation time, for example 1000, and then click Create.

Figure 10: Simulation Step 1 In the messages window you should see a log window containing the code generation progress. The simulation will now be compiled and started in paused mode. After a short time, the simulation control panel will open, allowing you to interact with the simulation. See Figure 11.

Figure 11: Simulation Step 2

J.

Using VirSim From the System Studio main menu, choose Simulation › Open VirSim. The Select Simulation dialog box appears. 1. Select the running simulation and click OK. VirSim will automatically connect to the running simulation. The VirSim Interactive window and the VirSim main menu bar will appear, see Figure 12 2. From the VirSim main menu bar, choose Hierarchy. The Hierarchy window appears. 3. From the VirSim main menu bar, choose Waveform, The Waveform window appears, see Figure 13

Figure 12: VirSim

Figure 13: Waveform window 4. In the Hierarchy window, select the down arrow next to the model name, then select the module and its ports you want to see.