Giter Club home page Giter Club logo

google-test-systemc-tdd's Introduction

google-test-systemc-tdd

SystemC integration with Google Test (gtest) to facilitate Test-Driven Development (TDD)

Quick start

Open terminal on cloned folder

cmake -S . -B build
cmake --build build
./build/test_counter3

The expected result is a test run which shows 1 failed case (because the test case is incorrect).

Rationale

SystemC is a very powerful tool in systems design, specially for microelectroncis, which allows developing and testing systems in a software environment (in contrast to HDL simulators). This means a huge chunk of modeling and experimentation can be done with easily downloadable tools and no need of paid software.

TDD in hardware models is difficult to achieve for two reasons

  1. The process of elaborating a software model takes too long, so the TDD cycle is slow (>30s per test run)
  2. Tests usually require step-by-step information passed through clock cycles, this is too low-level and requires boilerplate code

To simplify these steps, the following changes are proposed

  1. Module classes have functions (methods) with simple input-output relationships represented
  2. These functions don't have side effects
  3. The module's step-by-step behavior can be described by the chaining of simple functions

This way, each function can be tested for specific behavior and functional erros can be pinpointed to a function or a small subset of functions.

This approach may lead to fragile tests, so it is advised to think about the hardware architecture before writing unit tests. This methodology is supposed to facilitate testing interfaces quicker than with traditional tools and design flows.

Google Test was the testing framework of choice because of its ease of integration and richness of features and 3rd party tools.

The project is only supposed to support TDD and does not substitute other means of testing modules.

Dependencies and observations

  • Google Test's version present in CMakeLists comes from its tutorial. Other versions can be experimented
  • SystemC 2.3.3 used, (https://www.accellera.org/downloads/standards/systemc) compiled from source
    • It should be compiled with the std=c++11 flag to be compatible with gtest!
    • Modify CMakeLists' SYSTEMC_PATH to your own SystemC Home path
    • Change lines 25-26 from lib-linux64 to the equivalent of your system

To-do list

Contributions to the tasks or the contents of the list are welcome

  • Create module instance through fixture so it's available in all test cases
  • Test in Windows environment
  • Update gtest version if necessary
  • Add more examples
  • Think of how to minimize compilation time for larger examples

google-test-systemc-tdd's People

Contributors

danilo-bc avatar

Watchers

 avatar

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.