Giter Club home page Giter Club logo

vcml's Introduction

Virtual Components Modeling Library (vcml)

The Virtual Components Modeling Library contains a set of SystemC/TLM modeling primitives and component models that can be used to swiftly assemble system level simulators for embedded systems, i.e. Virtual Platforms. Its main design goal is to accelerate VP construction by providing a set of commonly used features, such as TLM sockets, Interrupt ports, I/O peripherals and registers. Based on these design primitives, TLM models for frequently deployed components are also provided, such as memories, memory-mapped buses, UARTs, etc.

Build Status Sanitizer Status Lint Status Code Style Nightly Status Coverage Status Windows Status


Build & Installation

In order to build vcml, you need a working installation of SystemC. Currently, versions >= 2.3.0 are supported. Furthermore, you need cmake, libelf and, optionally, libvncserver if you also want graphics support. This is how to build and install them:

  1. Optional: download and build SystemC (here systemc-2.3.2). Make sure to set the environment variables SYSTEMC_HOME and TARGET_ARCH accordingly:

    wget http://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.2.tar.gz
    tar -xzf systemc-2.3.2.tar.gz && cd systemc-2.3.2
    export SYSTEMC_HOME=`pwd`
    export TARGET_ARCH=linux64
    mkdir BUILD && cd BUILD
    ../configure --prefix=$SYSTEMC_HOME --enable-optimize --enable-static
    make -j 4 && make install
    

    Note: if you choose to skip this step, vcml will automatically download SystemC from github.com/machineware-gmbh/systemc.git during configuration and set the environment variables accordingly for this build.

    Note: you can provide your own SystemC installation by specifing your own SYSTEMC_HOME and TARGET_ARCH variables. Versions starting from 2.3.0 are supported.

  2. Download and install cmake:

  3. Install optional dependencies:

    • Lua for scripting support
    • SDL2 for graphic output
    • libvnc for remote graphic output
    • libslirp for userspace ethernet emulation
    # Ubuntu
    sudo apt-get install liblua5.4-dev libsdl2-dev libvncserver-dev libslirp-dev
    # Fedora
    sudo dnf install lua-devel SDL2-devel libvncserver-devel libslirp-devel
    

    Optional dependencies are automatically enabled if found by cmake on the host build system. To disable their use, pass -DUSE_<LUA|SDL2|VNC|SLIRP>=FALSE to cmake during configuration (see step 6).

  4. Clone VCML repository and initialize submodules:

    git clone https://github.com/machineware-gmbh/vcml.git --recursive
    

    or, alternatively

    git clone https://github.com/machineware-gmbh/vcml.git
    git submodule init
    git submodule update
    
  5. Chose directories for building and deployment:

    <source-dir>  location of your repo copy,     e.g. /home/jan/vcml
    <build-dir>   location to store object files, e.g. /home/jan/vcml/BUILD
    <install-dir> output directory for binaries,  e.g. /opt/vcml
    
  6. Configure and build the project using cmake. During configuration you must state whether or not to build the utility programs and unit tests:

    • -DVCML_BUILD_UTILS=[ON|OFF]: build utility programs (default: ON)
    • -DVCML_BUILD_TESTS=[ON|OFF]: build unit tests (default: OFF)

    Release and debug build configurations are controlled via the regular parameters:

    mkdir -p <build-dir>
    cd <build-dir>
    cmake -DCMAKE_INSTALL_PREFIX=<install-dir> -DCMAKE_BUILD_TYPE=RELEASE <source-dir>
    make -j 4
    sudo make install
    sudo make -C mwr install
    sudo make -C systemc install # if you skipped step 1
    

    If building with -DVCML_BUILD_TESTS=ON you can run all unit tests using make test within <build-dir>.

  7. After installation, the following new files should be present:

    <install-dir>/lib/libvcml.a   # library
    <install-dir>/include/vcml.h  # library header
    <install-dir>/include/vcml/   # header files
    <install-dir>/bin/            # utility programs
    
  8. Update your environment so that other projects can reference your build:

    export VCML_HOME=<install-dir>
    

Maintaining Multiple Builds

Debug builds (i.e. -DCMAKE_BUILD_TYPE=DEBUG) are intended for developers that use vcml to construct a new VP and want to track down bugs. Note that these builds operate significantly slower than optimized release builds and should therefore not be used for VPs that are used productively, e.g. for target software development. To maintain both builds from a single source repository, try the following:

git clone https://github.com/machineware-gmbh/vcml.git --recursive && cd vcml
home=$PWD
for type in "DEBUG" "RELEASE"; do
    install="$home/BUILD/$type"
    build="$home/BUILD/$type/BUILD"
    mkdir -p $build && cd $build
    cmake -DCMAKE_BUILD_TYPE=$type -DCMAKE_INSTALL_PREFIX=$install $home
    make install
done

Afterwards, you can use the environment variable VCML_HOME to point to the build you want to use:

  • export VCML_HOME=(...)/vcml/BUILD/DEBUG for the debug build or
  • export VCML_HOME=(...)/vcml/BUILD/RELEASE for the release build

Windows Build & Installation

Windows builds are currently supported using Microsoft Visual Studio. There are two ways to build vcml on Windows:

  1. Using Visual Studio IDE:
  • Launch Visual Studio
  • In the Open Dialog click on Clone a Repository
  • Enter https://github.com/machineware-gmbh/vcml and click Clone
  • Once Visual Studio has cloned the project, double-click on the vcml folder
  • Run Build All from the build menu.
  1. Using the command line:
  • Install Git for Windows
  • Launch git-bash (installed by Git for Windows)
  • Run git clone --recursive https://github.com:machineware-gmbh/vcml
  • Run cmake -B BUILD -G "Visual Studio 17" -DCMAKE_BUILD_TYPE=[DEBUG|RELEASE]
  • Run cmake --build BUILD

Documentation

Some basic documentation about this library and its models can be found here. Another potential useful source for help can be the study of projects that employ VCML to construct a complete VP, for example or1kmvp.


Contributions

Please note that we currently cannot accept Pull Requests on Github. Instructions on how to contribute to VCML, along with a curated collection of existing contributions in the form of individual models or complete Virtual Platforms can be accessed on our community projects website at:

https://www.machineware.de/vcml-community


License

This project is licensed under the Apache-2.0 license - see the LICENSE file for details.

vcml's People

Contributors

ant2a avatar aut0 avatar janweinstock avatar nbosb avatar rpelke avatar rubbra avatar simonwin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vcml's Issues

value of m_stop_reson is always empty when handling some commands

Hey,

in the vspserver the m_stop_reason is returned when the server is handling a resume command. But the value of m_stop_reason is cleared by the function resume_simulation() which is called before. So the value of m_stop_reason is always an empty string. This behavior is also appearing in the functionhandle_step().

https://github.com/machineware-gmbh/vcml/blob/main/src/vcml/debugging/vspserver.cpp#L171-L172
https://github.com/machineware-gmbh/vcml/blob/main/src/vcml/debugging/vspserver.cpp#L188-L189

Shouldn't the value be saved before calling resume_simulation()?

Meik

Unused variable in sdcard.cpp

Hi Jan,
in your sd card model there is the variable m_maxblk of type size_t (long unsigned int). The variable is set to -1 in the constructor and never changes its value. It is used in two comparisons in sd_data_read() and sd_data_write() but the condition can never become true. In my view you can just delete the variable. It is not necessary that the sd card knows the number of blocks that will be written or read. Due to this little flaw lines 84 (case SDTX_OK_COMPLETE) and 108 (SDRX_OK_COMPLETE) in spi2sd are never executed after WRITE_MULTIPLE_BLOCK and READ_MULTIPLE_BLOCK. But that is no big problem either.
Lasse

too many main() routines?

Hi,

my avp64 based design did not start today.

After some debugging I found, that there is a second main() routine from

systemc-src/src/sysc/kernel/sc_main.cpp

int
main( int argc, char* argv[] )
{
        return sc_core::sc_elab_and_sim( argc, argv );
}

The one I want (because I can then specify vcml properties) is from here:

vcml/src/vcml/core/setup.cpp

extern "C" {

#ifndef MWR_MSVC
MWR_DECL_WEAK
#endif
int main(int argc, char** argv) {
    return vcml::main(argc, argv);
}
}

I was experimenting with another linker "mold" today and that probably exposed the problem.

find_program(MOLD mold)
if(MOLD)
    add_link_options("-fuse-ld=mold")
endif()

However I am not sure that the current setup in vcml is deterministic.

libsystemc.a is a public link dependency of vcml.

So the linker of the final executable has always two main routines:

  • a weak extern "C" main() from vcml
  • a global "CPLUSPLUS" main() from systemc

As the one from vcml is "weak", why was it used with the normal linker?

ui::vnc crashes when setup() is followed by render() early

ui::vnc::setup() creates the vnc server screen at m_screen which is used by ui::vnc::render() to mark the screen rectangle as modified. However, m_screen is created in a separate thread and there is no protection to ensure m_screen has been initialized before using it.

Protect rendering by using the currently unused m_mutex and a condition_variable to wait for the vnc server to be properly set up.

0001-ui-vnc-wait-for-server-setup-before-rendering.patch.txt

libmwr includes are missing in installation directory

Trying the example from "https://github.com/machineware-gmbh/vcml/blob/main/doc/session.md" and I stumbled that the constructor of vpserver would not match my usage. That's when I realized that there is an issue with the type "u16". Looking into types.h I then notice that <mwr.h> is giving me a file not found. A find . -name "mwr.h" in the installation dir of vcml gives me nothing, while that find in the build directory gives me ./build/mwr-src/include/mwr.h

hierarchical binding for vcml::tlm_target_socket: "(E126) sc_export instance already bound"

Hi,

I have a question wrt to hierarchical binding of vcml::tlm_target_socket.

The situation I have is:
I have a child module ("stream") with a vcml::tlm_target_socket ("stream_child_socket") and a parent module ("dma") with a vcml::tlm_target_socket.

If I bind now the parent-target-socket to the child-target-socket

parent_socket.bind(stream.stream_child_socket);

I get the following error during elaboraton:

C++ exception with description "Error: (E126) sc_export instance already bound: tb.dma.stream.stream_child_socket
In file: /build/3rdparty/systemc/install/include/sysc/communication/sc_export.h:188" thrown in the test body.

What is the best approach to deal with this?

The SystemC language reference seems to indicate this behaviour is intentional for simple_target_sockets in table "Table 60—Permitted socket bindings". If I read this correctly.

But then I am wondering what the purpose of this template specialisation is:

https://github.com/machineware-gmbh/vcml/blame/8b21479538a35c7549dfe278e6dc71465619e46e/include/vcml/protocols/tlm_sockets.h#L372

mwr is not installed during vcml installation

vcml downloads a copy of mwr while building vcml. However, when the user invokes make install under vcml, mwr is not installed. This results in an compile error later when the user tries to use vcml since mwr is not installed. I see two fixes:

  1. Modify the build script of vcml to install mwr with it when the user does make install in vcml
  2. Decouple the two libraries and list mwr as a prerequisite for vcml (just like libelf)

Missed IRQs at the end of each quantum (?)

I've had trouble with VCML as used in AVP. After bisecting the problem (thx to @lukas Juenger) I've found out that the following commit breaks the correct functionality:

e26c855?diff=unified

(If I add the two removed lines, everything works fine.)

The symptoms are difficult to describe. After Linux boot, sometimes I can't get into the console. Sometime I get in but when executing e.g. "ls -la" or so, the output comes discretely in a couple of seconds difference or only by pressing a key multiple times. Once a kernel panic happened arising from the IRQ handler.

Our wild guess: MMIO interrupts are frequently missed somehow at the end of the quantum.

Would you happen to know why this happens? Could you suggest a fix please?

VCML fails with newer gcc version

Here is the warning which triggers the error with -Werror -> Tried under Ubuntu 14.04 and gcc 7.2

/home/pedram/mpsoc_vp/vcml/src/vcml/debugging/gdbserver.cpp: In member function ‘std::__cxx11::string vcml::debugging::gdbserver::handle_reg_write(const char*)’:
/home/pedram/mpsoc_vp/vcml/src/vcml/debugging/gdbserver.cpp:188:45: error: ‘<<’ in boolean context, did you mean ‘<’ ? [-Werror=int-in-bool-context]
buffer[byte] = char2int(str[0]) << 4 || char2int(str[1]);
~~~~~~~~~~~~~~~~^~~

/home/pedram/mpsoc_vp/vcml/src/vcml/debugging/gdbserver.cpp: In member function ‘std::__cxx11::string vcml::debugging::gdbserver::handle_reg_write_all(const char*)’:
/home/pedram/mpsoc_vp/vcml/src/vcml/debugging/gdbserver.cpp:230:49: error: ‘<<’ in boolean context, did you mean ‘<’ ? [-Werror=int-in-bool-context]
buffer[byte] = char2int(str[0]) << 4 || char2int(str[1]);

How do I enable tracing of TLM transactions?

When I pass --trace-stdout, I don't see any TLM traces being printed to the stdout despite the simulation having many read transactions. Do I have to enable something explicitly to obtain these traces?

Windows - #error unsupported operating system

I wanted to check out the newly released Windows support with #63. I did not find dedicated instructions in the README.md how to proceed under Windwos. I did in build directory ...
cmake -DVCML_BUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=C:\Users\nxf94074\WORK\vcml -DCMAKE_BUILD_TYPE=RELEASE C:\Users\nxf94074\WORK\REPOS\vcml\
... which seems to have worted nicely. I get several MSVS projects:

-a----        28.08.2023     10:13          60955 ALL_BUILD.vcxproj
-a----        28.08.2023     10:13            288 ALL_BUILD.vcxproj.filters
-a----        28.08.2023     10:13          35764 CMakeCache.txt
-a----        28.08.2023     10:13           3202 cmake_install.cmake
-a----        28.08.2023     10:13            362 CTestTestfile.cmake
-a----        28.08.2023     10:13           9422 INSTALL.vcxproj
-a----        28.08.2023     10:13            530 INSTALL.vcxproj.filters
-a----        28.08.2023     10:13           9070 RUN_TESTS.vcxproj
-a----        28.08.2023     10:13            532 RUN_TESTS.vcxproj.filters
-a----        28.08.2023     10:13         106430 vcml.sln
-a----        28.08.2023     10:13          72494 vcml.vcxproj
-a----        28.08.2023     10:13          17747 vcml.vcxproj.filters
-a----        28.08.2023     10:13         102958 ZERO_CHECK.vcxproj
-a----        28.08.2023     10:13            531 ZERO_CHECK.vcxproj.filters

Starting example 'vcml.vcxproj' creates many errors of unsupported operating System so e.g.:

c1189 Projekt mwr compiler.h Line 29

#if defined(linux)
#define MWR_LINUX
#elif defined(_WIN64)
#define MWR_WINDOWS
#else
#error unsupported operating system <-------------- ERROR
#endif

Why are symbols of elf files ignored if there size is equals zero?

Is there a reason symbols of size 0 are ignored in elf_reader?
https://github.com/janweinstock/vcml/blob/103db7e51d5b7d57e6c86a7064d3d55d95d10043/src/vcml/debugging/elf_reader.cpp#L122-L123
I tried to get a symbol from an elf file that has been skipped in elf_reader due to unknown symbol size (syms[i].st_size == 0). I think, I my case the size of the symbol was 0 because it was a label in an assembly file (where the size of the "function" was not know).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.