• Visual Studio 2008配置SystemC开发环境


    Visual Studio 2008配置SystemC开发环境

    一、编译System库

    1.下载SystemC library source code
           到http://www.systemc.org注册会员账号后,即可下载SystemC library soure code

    2. 以SystemC 2.2.0为例,下载后的文件名喂systemc-2.2.0.tgz,解压到C盘目录下:C:\systemc-2.2.0

    3. 打开C:\systemc-2.2.0\msvc71\SystemC目录下的SystemC.sln

    4.VS一般都是Debug模式,所以直接"生成(Build英文)"-->“生成解决方案(Build Solution)”,如果编译成功的话(忽略那些Warning)。在C:\systemc-2.2.0\msvc71\SystemC\debug目录下就生成了SystemC.lib

    二:更新SystemC include file 和 library

    1. Select Tools(工具) -> Options(选项) . . . and the Projects(项目和解决方案) -> VC++ Directories tab(Vc++目录)
       
    2. Select show directories for: Library files(库文件)

    3. Select the 'New' icon and browse to: C:\systemc-2.2.0\msvc71\SystemC\Debug

    4. Select show directories for: Include files(包含文件)

    5. Select the 'New' icon and browse to: C:\systemc-2.2.0\src

    步骤三:创建SystemC应用程序

    1. Start Visual Studio. From the Start Page select New Project and Win32 Console Project (Windows 控制台应用程序). Type the project name and select a suitable location then click OK.
    2. Select the Application Settings page of the Win32 Application Wizard and make sure the 'Empty project' box is ticked(把空项目勾起来). Click 'Finish' to complete the wizard.

    3. Add new/existing C++ files to the project and edit code.【一定要添加某个C++文件否则下一步就找不到C/c++的选项了】
    4. Display the project Property Pages by selecting 'Properties...' from the Project menu.

    5. C/C++ -> General properties Warning level= Level 1(/W1)
    6. C/C++ -> Code Generation Runtime Library =Multi-thread Debug (/MTd)
    7. C/C++ -> Command Line properties Additional Options = /vmg /D_CRT_SECURE_NO_DEPRECATE
    8. Linker -> Input properties Additional Dependiences = systemc.lib
    9. Click

    结束

    附上一个测试文件: 一个加法器:

    adder.h

    Cpp代码
    1. #ifndef _ADDER_H   
    2. #define _ADDER_H   
    3.   
    4. SC_MODULE(Adder){   
    5. public:   
    6.       sc_in<int> data_in_1;   
    7.       sc_in<int> data_in_2;   
    8.       sc_out<int> data_out;   
    9. SC_CTOR(Adder){   
    10.        SC_METHOD(adder_action);   
    11.        sensitive << data_in_1 <<data_in_2;   
    12.       }   
    13.   
    14.      void adder_action(){   
    15.           data_out = data_in_1 + data_in_2;   
    16.       }   
    17. };   
    18.   
    19. #endif  
    #ifndef _ADDER_H
    #define _ADDER_H
    
    SC_MODULE(Adder){
     public:
      sc_in<int> data_in_1;
         sc_in<int> data_in_2;
      sc_out<int> data_out;
    SC_CTOR(Adder){
          SC_METHOD(adder_action);
       sensitive << data_in_1 <<data_in_2;
      }
    
      void adder_action(){
             data_out = data_in_1 + data_in_2;
      }
    };
    
    #endif

    adder.cpp

    Cpp代码
    1. #include <systemc.h>   
    2. #include "adder.h"   
    3.   
    4. SC_MODULE(Stimulator) {   
    5. public:   
    6.      sc_out<int> data_out_1, data_out_2;   
    7.   
    8.      SC_CTOR(Stimulator){   
    9.          SC_THREAD(send_data);   
    10.          dont_initialize();   
    11.      };   
    12.   
    13. private:   
    14.     void send_data() {   
    15.         int i = 3;   
    16.         while(true){   
    17.              wait(i, SC_NS);   
    18.              cout << "Time: " << sc_time_stamp() << "::";   
    19.              cout << "Send data: " << 4*i << ", " << 5*i-2 << endl;   
    20.              data_out_1 = 4*i;   
    21.              data_out_2 = 5*i-2;   
    22.              i++;   
    23.             if(i >= 14) {   
    24.                  wait(1,SC_NS);   
    25.                  sc_stop();   
    26.              }   
    27.          }   
    28.      };   
    29. };   
    30.   
    31. SC_MODULE(Monitor) {   
    32. public:   
    33.      sc_in<int> data_in;   
    34.   
    35.      SC_CTOR(Monitor){   
    36.          SC_METHOD(display);   
    37.          dont_initialize();   
    38.          sensitive << data_in;   
    39.      };   
    40.   
    41. private:   
    42.     void display(){   
    43.          cout << "Time: " << sc_time_stamp() << "::";   
    44.          cout << "Receive data: " << data_in.read() << endl;   
    45.      };     
    46. };   
    47.   
    48. int sc_main(int argc, char* argv[]) {   
    49.      Stimulator *stim;   
    50.      Monitor *mon;   
    51.      Adder *adder;   
    52.   
    53.      stim = new Stimulator("Stimulator");   
    54.      mon = new Monitor("Monitor");   
    55.      adder = new Adder("Adder");   
    56.   
    57.      sc_signal<int> data_in_1, data_in_2, data_out;   
    58.   
    59.      stim->data_out_1(data_in_1);   
    60.      stim->data_out_2(data_in_2);   
    61.      mon->data_in(data_out);   
    62.      adder->data_in_1(data_in_1);   
    63.      adder->data_in_2(data_in_2);   
    64.      adder->data_out(data_out);   
    65.   
    66.      sc_start();   
    67.   
    68.     return 0;   
    69. }  
  • 相关阅读:
    建设工程造价数据服务云平台(计价BIM)
    工程造价数据服务云平台(造价BIM)
    工程造价数据服务云平台(造价BIM)
    ie9下对象for..in..的bug
    JavaScript闭包
    JavaScript如何比较两个对象字面量是否一样(key 和 value都对比)
    JavaScript转码和编码
    JavaScript中正则编码
    Sizzle 官方API翻译
    JSONP跨域
  • 原文地址:https://www.cnblogs.com/Neddy/p/2281830.html
Copyright © 2020-2023  润新知