Installing SystemC for VS2013

可紊 提交于 2019-12-04 09:08:30

Update: if you use CMake with Visual Studio, check Setting up a SystemC project with CMake: undefined reference to `sc_core

Currently I have no MSVC2013 installed, so here are steps for MSVC2017 that worked for me.

  1. Download latest SystemC from http://accellera.org/downloads/standards/systemc
  2. Open systemc-2.3.1a\msvc80\SystemC\SystemC.sln in Visual Studio
  3. Visual Studio will offer to update solution, click ok. You can ignore report with warnings.
  4. In VS menu bar set configuration to “Debug“ “Win32”. (In my case was already selected by default)
  5. Build solution (F7)

    In console, you may find messages like:

    Unknown compiler version - please run the configure tests and report the results

    You can ignore them. Solution should build without errors:

    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

  6. As a result you will have SystemC.lib in systemc-2.3.1a\msvc80\SystemC\Debug

Now you can create some test SystemC project.

  1. File->New -> Project -> Win32 Console application
  2. Right click on project in solution explorer -> Properties
  3. In Configuration Properties -> C/C++ -> General-> Additional include directories

    Add path to: \systemc-2.3.1a\src

  4. In Configuration Properties -> C/C++ -> Code generation -> Runtime Library

    Select: Multi-threaded Debug (/MTd)

  5. In Configuration Properties -> C/C++ -> Language -> Enable Run-Time Type Information

    Select: Yes (/GR)

  6. In Configuration Properties -> C/C++ -> Command Line -> Additional options

    Type: /vmg

  7. In Configuration Properties -> Linker -> General -> Additional Library Directories

    Add path to: systemc-2.3.1a\msvc80\SystemC\Debug

  8. In Configuration Properties -> Linker -> Input -> Additional dependencies

    Add: SystemC.lib

Now it's time to type some code. For example this "Hello world":

#include "stdafx.h"

struct test_module : sc_module {
    SC_HAS_PROCESS(test_module);

    test_module(::sc_core::sc_module_name) {
        SC_THREAD(test_thread);
    }

    sc_signal<std::string>  message{ "message" };

    void test_thread() {
        message.write("Hello world!");
        wait(1, SC_NS);
        cout << message.read() << endl;
        sc_stop();
    }
};

int sc_main(int argc, char** argv)
{
    test_module tmod{ "tmod" };
    sc_start();
    return 0;
}

In stdafx.h add:

 #include <systemc.h>
  1. Build project, it will fail with:

    \systemc-2.3.1a\src\systemc.h(120): error C2039: 'gets': is not a member of 'std'

gets was removed from std namespace in latest MSVCs, but it is not really required. So just open systemc.h and comment out Line 120:

//    using std::gets;
  1. In case you got error about sprintf

Add _CRT_SECURE_NO_WARNINGS to list of preprocessor definitions

  1. Build again. Run without debugging (Ctrl+F5). You should see the following introduction test on your console:
    SystemC 2.3.1-Accellera --- Feb  1 2017 14:43:06
    Copyright (c) 1996-2014 by all Contributors,
    ALL RIGHTS RESERVED

    Hello world!

    Info: /OSCI/SystemC: Simulation stopped by user.
    Press any key to continue . . .

Hope that helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!