Showing posts with label SystemC. Show all posts
Showing posts with label SystemC. Show all posts

Thursday, March 29, 2012

Use vcs to sim systemc file

My ubuntu is 10.04, the default g++ is 4.4. But for simulating systemc file, you need to specify the lower version of g++.

The problem can be solved as follows:
1.  Go to the archive link to download the following five files:
    gcc-3.4-base_3.4.6-6Ubuntu3_i386.deb、
    gcc-3.4_3.4.6-6Ubuntu3_i386.deb、
    cpp-3.4_3.4.6-6Ubuntu3_i386.deb、
    g++-3.4_3.4.6-6Ubuntu3_i386.deb、
    libstdc++6-dev_3.4.6-6Ubuntu3_i386.deb
Put them into the same folder, like g++-3.4, and then run command "dpkg -i *.deb";

2. redirect the g++ link to use the lower version
   You can find the g++-3.4 with find / -name g++-3.4* command, however, it is already inside the /usr/bin if you are familiar. All you need to do right now is to redirect the g++ to your newly installed file.
   The command is "ln -sf /usr/bin/g++-3.4 /usr/bin/g++";
   There is also another way, check the reference link(in Chinese)

With the user guide, the easiest way is to run simulations of your systemc file is :
   syscan adder.cpp
   syscan adder_tb.cpp adder_main.cpp
   vcs -sysc sc_main
   ./simv

Saturday, July 30, 2011

llvm patched with systemc library

By Rui Chen

In this article, I will get into the IR generated by the llvm-g++ along with the systemc library.

Understand the installation flow of PinaVM
The project is to mimic the idea of PinaVM, but I have to repeat the first few steps to understand the relationship between llvm-g++ and systemc library. Check out the /doc/install document for details.

One limit is that you have to use LLVM 2.6, which may suffer incompatible features with the latest version.

Start from autoconf part, which is Step 3 in the manual
1. autoconf
What the autoconf do is to seek a file named configure.ac (or configure.in for backward compatibility), and then runs the M4 macro processor to create the configure script.

2. configrue
command ./configure --with-tools-dir=$DOWNLOAD
Part of the output:
configure: Summary of variables:

DOWNLOAD_AND_COMPILE_DIR: /home/chenrui/Desktop/pinavm/download
INSTALL_PATH_LLVM: /home/chenrui/Desktop/pinavm/lib/llvm-2.7
INSTALL_PATH_LLVMGCC: /home/chenrui/Desktop/pinavm/lib/llvm-gcc
INSTALL_PATH_SYSTEMC_LLVM: /home/chenrui/Desktop/pinavm/lib/systemc-2.2.0-llvm
INSTALL_PATH_SYSTEMC_GCC: /home/chenrui/Desktop/pinavm/lib/systemc-2.2.0-gcc

configure: creating ./config.status
config.status: creating config.mk
config.status: creating config.sh
The code in the configure.ac file:
DOWNLOAD_AND_COMPILE_DIR="${TOOLS_DIR}/download"
INSTALL_PATH_LLVM=${TOOLS_DIR}/lib/llvm-2.7
INSTALL_PATH_LLVMGCC=${TOOLS_DIR}/lib/llvm-gcc
INSTALL_PATH_SYSTEMC_LLVM=${TOOLS_DIR}/lib/systemc-2.2.0-llvm
INSTALL_PATH_SYSTEMC_GCC=${TOOLS_DIR}/lib/systemc-2.2.0-gcc
So the "--with-tools-dir" means specifying the $DOWNLOAD directory for ${TOOLS_DIR}.

Another part of configure.ac:
# Defining files to be generated
AC_CONFIG_FILES([config.mk
                 config.sh])
Then config.mk and config.sh will be generated.
NOTE: normally, AC_CONFIG_FILES([Makefile]) is used(ref link).

Motivation to use SystemC and LLVM
I have done a simple literal translator with SystemC-to-VHDL translator with ANTLR, and I think it needs tremendous effort to crack the whole C++ grammar.
Besides, sc2v and gsc and many tools are based on their self-made compilers, which suffers a severe issue that only a small set of systemc grammar can be compiled.

Based on this understanding, it is very important to immigrate the translation method from ANTLR literal way to llvm-g++ based.


Generate simple backend first.
Another idea about working with C++ & Systemc with LLVM is that I can generate a VHDL experiment backend for test first and then connect it to the systemc frontend.

Sunday, July 24, 2011

enum的翻译

By Rui Chen

VHDL 与systemc在enum的定义上有很大的不同。

VHDL-ref
Important Notes

  • It is illegal to define an enumeration type with a range.
  • It is assumed that the values are defined in ascending order. For this reason it is recommended to order the literals in such a way that the default value is the first one (it is referred to through the attribute 'left').
  • Objects of enumeration types are typically synthesizeable.
所以,VHDL的