Skip to content

leonardoaraujosantos/Learn_SystemC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Learning SystemC

Learn basics of SystemC

SystemC Tutorials and References

Some other references

First things

  • It's not a language it's a C++ library
  • Attempt to make HW/SW/Algo engineers to use the same language (C++)
  • Not supported by much FPGA vendors

Hello World

// All systemc modules should include systemc.h header file
#include "systemc.h"
// Hello_world is module name
SC_MODULE (hello_world) {
  SC_CTOR (hello_world) {
    // Nothing in constructor 
  }
  void say_hello() {
    //Print "Hello World" to the console.
    cout << "Hello World.\n";
  }
};

// sc_main in top level function like in C++ main
int sc_main(int argc, char* argv[]) {
  hello_world hello("HELLO");
  // Print the hello world
  hello.say_hello();
  return(0);
}

Combinational Circuit

#include "systemc.h"
SC_MODULE (half_add) {
  // Input and Output ports
  sc_out<sc_logic> s,c;
  sc_in<sc_logic> a,b;
  
  // Pure C++ coder here (For synthesis depends on HLS power...)
  void compute(){
    s = a ^ b; // a XOR b
    c = a & b; // a AND b
  }
  
  SC_CTOR (half_add) {
    // Kind of always_comb block (Sensitive to a and b)
    SC_METHOD(compute);
    sensitive << a << b;
  }  
};

Compiling (by hand)

g++ adder.cpp -I/systemc-2.3.2/include -L/systemc-2.3.2/lib-linux64 -lsystemc -o adder
g++ test_adder.cpp -I/systemc-2.3.2/include -L/systemc-2.3.2/lib-linux64 -lsystemc -lgtest -lgtest_main -lpthread -o test_adder 

Compiling with CMake

mkdir build; cd build
cmake ..
make

About

Learn basics of SystemC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published