Your SlideShare is downloading. ×
EE3207+-+Computer+Architecture
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

EE3207+-+Computer+Architecture

136
views

Published on


0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
136
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. EE4218 Lab 4 SYSTEMC SIMULATION ENVIROMENT USING MICROSOFT VISUAL C++ 6.0GUI based Tools Used:Microsoft Visual C++ 6.0
  • 2. SEMESTER II 2008/2009DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERINGEE4218 EMBEDDED HARDWARE SYSTEM DESIGN ASSISTANT PROF. HA YAJUNNATIONAL UNIVERSITY OF SINGAPORE ii
  • 3. Table of Contents1. Introduction...............................................................................................................................52. Background ...............................................................................................................................53 Generating SystemC library......................................................................................................6 3.1 Getting Started ..................................................................................................................6 3.2 Define Directory Structure ................................................................................................6 3.3 Generating and Setting Up the SystemC Library..............................................................7 3.4 Summary ...........................................................................................................................74 Worked Example.......................................................................................................................7 4.1 Full Adder Circuit .............................................................................................................7 4.2 Procedure ..........................................................................................................................8 List of FiguresFigure 2-1: SystemC Design Methodology.......................................................................................5Figure 2-2: SystemC Environment....................................................................................................6Figure 4-1: Fuller Adder Schematic..................................................................................................8Figure 4-2 : Create a new Win32 console application ......................................................................8Figure 4-3: Create an empty project..................................................................................................8Figure 4-4: New project information ................................................................................................9Figure 4-5: Specify ‘C++ Language’ ................................................................................................9Figure 4-6: Specify SystemC ‘src’ path ............................................................................................9Figure 4-7: Execution window..........................................................................................................9Figure 4-8: Execution window........................................................................................................10Figure 4-9: Create a new console application .................................................................................10Figure 4-10: Select the properties of the console application .........................................................11Figure 4-11: Save the project ..........................................................................................................11Figure 4-12: Include the design files into the project......................................................................11Figure 4-13: Include the SystemC library into the project..............................................................11Figure 4-14: Include the SystemC header and library binary .........................................................11Figure 4-15: Make project...............................................................................................................12Figure 4-16: Build project...............................................................................................................12Figure 4-17: Windows Command Prompt Output ..........................................................................12Figure 4-18: Windows Command Prompt Output ..........................................................................13Figure 4-19: Windows Command Prompt Output ..........................................................................13 List of TablesTable 4-1: Full Adder Truth Table.....................................................................................................8 iii
  • 4. iv
  • 5. SystemC Design Methodology1. Introduction The current system design methodology has aThis laboratory demonstration exercise is number of problems such as:designed to provide students with some • Manual conversion from C++ toreference and experience in simulating system functional models written inSystemC models in a C++ environment. HDL creates errors • Disconnect between system model inThis manual first gives students a brief C/C++ and HDL modelintroduction on SystemC programming • Multiple system testslanguage and explains the steps to generate acompatible SystemC library binary in the On the other hand, SystemC design approachVisual C++ 6.0. The SystemC environment offers many advantages over the traditionalhas been set up in the laboratory computers approach for system level design. Theand students will not be required to perform SystemC design methodology for hardware isthe steps described in Section 3. However, shown in the Figure 2-1.students can use the information provided inthis lab manual to set up similar environmentin their own computers.Next, a simple worked example will beprovided to allow students to familiarize withrunning a SystemC design using the abovesetup Visual C++ environment.2. BackgroundSystemC is a C++ class library and amethodology that you can use to effectivelycreate a cycle-accurate model of softwarealgorithms, hardware architecture, andinterfaces of your SoC (System On a Chip)and system-level designs. You can useSystemC and standard C++ development tools Figure 2-1: SystemC Design Methodologyto create a system-level model, quicklysimulate to validate and optimize the design,explore various algorithms, and also to Using the SystemC design approach, there is aprovide the hardware and software number of advantages over the current designdevelopment team with an executable methodology, including the following:specification of the system. An executable • Gradual refinement methodologyspecification is essentially a C++ program that • Functional and synthesis models areexhibits the same behavior as the system when written in a single languageexecuted. More information on SystemC can be found in 5
  • 6. the User Guide uploaded in the course website. The original SystemC library source files <systemc-2.0.1.zip> downloadable in theSimulation SystemC website (www.systemc.org) containsSystemC can be used to simulate a system. It the necessary (*.cpp) files, (*.h) files andprovides header files and libraries which example files.describe the classes and contain the simulationkernel respectively. Any ANSI C++ compiler However, for Borland C++ Builder users,can compile SystemC code. The SystemC another file <SystemC2.0.1borland.zip> is tolibrary is used during linking. The resulting be downloaded from the SystemC website.executable serves as a simulator. An overview This is the SystemC2.0.1 port from theof using SystemC environment is shown in original library source files to the BorlandFigure 2-2. compiler. Note that you need to create a new account in order to download these files. Registering for a new account is free. <systemc-2.0.1.zip> and <SystemC2.0.1borland.zip> files can be downloaded respectively from: https://www.systemc.org/frs/viewRelease.php ?release_id=13&group_id=5 and https://www.systemc.org/frs/viewRelease.php ?release_id=21&group_id=6. Or can also Figure 2-2: SystemC Environment downloaded from the course complementary web site at3 Generating SystemC library http://courses.nus.edu.sg/course/elehy/EE4218 /projects.htm3.1 Getting Started1) Install Visual C++ 6.0 / Borland C++ 3.2 Define Directory Structure Builder 6 The directory structure is defined below toVisual C++ 6.0 is a commercial software and ease the explanation of interfacing SystemCis available in the market. An alternative is the with Visual C++ 6.0. The Visual C++ isBorland C++ Builder version 6 which can be assumed to be installed under <C:Programdownload from the NUS web shopping page Files>. The original SystemC library source(http://helpdesk.nus.edu.sg/webshop/user/web files from <systemc-2.0.1.zip> are extractedshop.htm). In the web shopping page, you will into <C:SystemCsystemc2.0.1>. In addition,find the Borland C++ Builder version 6 from three new folders, namely Include, Lib andthe category of Language and Compilers. An Tutorial are to be created in the SystemCinstallation request from the Computer Centre folder.will be required.2) Download Library Source Files 6
  • 7. 3.3 Generating and Setting Up the SystemC Library This will take a while to compile. When it completes, you will seeVisual C++ 6.0: additional files in1) To generate the SystemC library: <C:SystemCsystemc2.0.1-src- borlandsrc>: a) Go to <C:SystemCsystemc- 77 OBJ files 2.0.1msvc60systemc>. This systemc2.0.1.lib directory contains the project and make.log (with 12 warnings) workspace files to compile the 2) To set up the SystemC library: `systemc.lib’ library. b) Double-click on the ‘systemc.dsw’ a) Copy the SystemC-Borland library file to launch Visual C++ with the binary <systemc2.0.1.lib> to workspace file. The workspace file <C:SystemCLib> will have the proper switches set to b) Copy all the header files (*.h) to compile for Visual C++ 6.0. Select <C:SystemCInclude> ‘Build systemc.lib’ under the Build menu or press F7 to build ‘systemc.lib’. 3.4 Summary This will take a while to compile. After completing the steps above, the When it completes, you will see SystemC library binary will be generated. In additional files in the Debug folder: addition, the header files and library, 77 OBJ files necessary during compilation of the SystemC systemc.pch design, are set up. vc60.pdb vc60.idb systemc2.0.1.lib 4 Worked Example2) To set up the SystemC library: In this section, a simple example will be used to illustrate the process of setting up a console a) Copy the generated SystemC library application. Console applications are 32-bit inary <systemc2.0.1.lib> to programs that run without a graphical <C:SystemCLib> interface, usually in a console window. These applications typically do not require muchBorland C++ Builder user input and perform a limited set of1) To generate the SystemC library functions. a) Open a Windows Command Prompt 4.1 Full Adder Circuit b) Change the directory to <C:SystemCsystemc2.0.1-src- borlandsrc> Consider a full adder circuit, which can add c) Type the following command: three bits and gives a bit sum and carry. The make > make.log truth table and schematic for full adder circuit 7
  • 8. is as shown in Table 4-1 and Figure 4-1 d) Specify the ‘Location’ asrespectively. <C:SYSTEMCTUTORIALfull_ad der>. e) Click [OK]. A B Cin Sum Carry 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 Table 4-1: Full Adder Truth Table Figure 4-2 : Create a new Win32 console application f) In the next dialog box, select an empty project as shown in Figure 4-3. Figure 4-1: Fuller Adder Schematic4.2 ProcedureThe source files for this example are createdin the following directory:<C:SystemCTutorialfull_adder> Figure 4-3: Create an empty projectVisual C++ 6.0: g) Click [Finish]. A dialog box will pop1) Invoke Visual C++ 6.0. out showing the new project information as shown in Figure 4-4.2) Create new project. a) Click on [File | New ] b) Select the Projects tab on the dialog box that appears and select a Win32 Console Application as shown in Figure 4-2. c) Specify the ‘Project name’ as ‘full_adder’. 8
  • 9. Figure 4-6: Specify SystemC ‘src’ path 4) Add design files into the project. Figure 4-4: New project information3) SystemC settings. a) Click [Project | Add To Project | Files]. b) Include all the *.cpp and *.h files a) Click on [Project | Settings]. design files. b) First, select the C/C++ tab, and select 5) Include the SystemC library binary. the ‘C++ Language’ category. Make sure that the `Enable Run Time Type a) Click [Project | Add To Project | Files]. Information (RTTI) checkbox is b) Include the <systemc2.0.1.lib> from checked as shown in Figure 4-5. <C:SystemCLib>. c) Next, select the ‘Preprocessor’ category, and type the path 6) Start the compilation process. <C:SystemCsystemc-2.0.1src> in the text entry field labeled a) Select ‘Build full_adder.exe’ under ‘Additional include directories’ as the Build menu or press F7 to build shown in Figure 4-6. ‘full_adder.exe’. d) Click [OK]. 7) Select ‘Execute full_adder.exe’ under the Build menu or press Ctrl+F5 to execute the project. You will see a Windows Command Prompt as shown in Figure 4-7. Figure 4-5: Specify ‘C++ Language’ Figure 4-7: Execution window 8) Test the output. 9
  • 10. shown in Figure 4-9. a) Key in either a ‘0’ or ‘1’ for the C, A c) Click [OK]. and B inputs and press Enter. The sum and carry of the inputs will be displayed, as given by the truth table shown in Table 4.1. b) There are 5 test operations. Enter inputs for the other 4 test operations. An example of the output is as shown in Figure 4-8. After the 5th test operation (at the end of the project execution), the Windows Command Prompt will Figure 4-9: Create a new console prompt you to ‘press any key to application continue’ to exit the program. 3) In the “Console Wizard” window, specify the settings as shown in Figure 4-10 and click [OK]. 4) Save the project. a) Click on [File | Save Project As…]. b) Type <full_adder.bpr> as the filename as shown in Figure 4-11. 5) Add the rest of the design files into the project. a) Click on [Project | Add to Project…]. b) Include all the design files <C:SystemCTutorialfull_adder*.c pp> except <stimulus.cpp> into the Figure 4-8: Execution window project as shown in Figure 4-12. In this case, double-click on9) Click on [File | Exit] to exit Visual C++ <fulladder.cpp>. 6.0.Borland C++ Builder:1) Invoke Borland C++ Builder.2) Create a new console application. a) Click on [File | New | Other…]. b) Select Console Wizard in the [New] tab in the [New Item] window as 10
  • 11. Figure 4-10: Select the properties of the console application Figure 4-13: Include the SystemC library into the project Figure 4-11: Save the project 7) Change the project settings to include the SystemC header files and library binary. a) Click on [Project | Options…]. b) Click on the [Directories/Conditionals] tab as shown in Figure 4-14. c) Modify [Include path:] to include “C:SystemCInclude;”. d) Modify [Library path:] to include “C:SystemCLib;”. e) Click [OK]. Figure 4-12: Include the design files into the project6) Include the SystemC library binary. a) Click on [Project | Add to Project…]. b) Select <C:SystemCLibsystemc2.0.1.lib> into the project as shown in Figure 4-13. c) Double-click on <systemc2.0.1.lib> Figure 4-14: Include the SystemC header and library binary 8) Start the compilation process. a) Click on [Project | Make full_adder] 11
  • 12. A window is displayed as shown in Figure 4-15. b) Click [OK]. Figure 4-17: Windows Command Prompt Output Figure 4-15: Make project 11) Test the output.9) Build the executable. a) Key in either a ‘0’ or ‘1’ for the C, A and B inputs and press Enter. The a) Click on [Project | Build full_adder]. sum and carry of the inputs will be A window is displayed as shown in displayed, as given by the truth table Figure 4-16. shown in Table 4-1. b) Click [OK]. b) There are 5 test operations. Enter inputs for the other 4 test operations. An example of the output is as shown in Figure 4-18. After the 5th test operation (at the end of the project execution), the Windows Command Prompt will disappear. 12) Alternatively, you may view the result by opening a Windows Command Prompt Figure 4-16: Build project manually.10) Click on [Run | Run] to execute the a) Click on [Start | All Programs | project. You will see a Windows Accessories | Command Prompt] to Command Prompt as shown in Figure open the Windows Command Prompt 4-17. b) Change the directory to: <C:SystemCTutorialfull_adder> c) Type “full_adder” to execute the project. The result is the same as the above step by executing the project in the Borland C++ IDE. However, the Windows Command Prompt will not disappear from the project has been executed. An example of the output 12
  • 13. after the project has been successfully executed is as shown in Figure 4-19. Figure 4-19: Windows Command Prompt Output Figure 4-18: Windows Command Prompt Output13) Click on [File | Save All] to save the project.14) Click on [File | Close All] to close the project.15) Click on [File | Exit] to exit Borland. 13