2013年10月10日木曜日

PATCH for SystemC-2.3 to keep the module hierarchy in VCD

As I have posted to SystemC Forum I wrote a small patch to keep the module hierarchy in VCD.
The patch modifies a PoC simulator to treat signal name as a dot-separated path.
VCD Hierarchy Manipulator is no more necessary.

How to get the patch

Please see my github page or simply wget it.

How to apply

% tar zxvf systemc-2.3.0.tgz
% cd systemc-2.3.0
% patch -p0 <  ../sc_vcd_trace.patch
% ./configure --any-options
% make
% make install 
 

How to Use

No need to modify the SystemC model. All you need to do is just rebuild your design with the patched systemc library. You will get the VCD as a following screen shot.

If you want to disable this feature, set an environmental variable SC_VCD_NO_HIERARCHY.


Feedbacks

I only tested with a small example. Any feedback is welcome.

2013年7月29日月曜日

OpenRISC toolchain

Toolchain for OpenRISC cannot be built with the mainline source code. It was difficult for me to find the right way from openrisc web site.

After a couple of days of crawling, I found a repository maintained by Kevin Mehall.
It works perfectly, and its good point is gdb is also maintained.

If all libraries(GMP, MPFR and MPC) to build GCC have already been installed, simply do as following.
 
% git clone https://github.com/kevinmehall/openrisc-tools-build
% cd openrisc-tools-build
% git submodule update --init
% make -j3 PREFIX=

I wanted to build them on CentOS5.x machine and these libraries are not installed by default.
I wrote a preparation script to download and build these libraries.
These libraries are built as a static library, so setting LD_LIBRARY_PATH is not required.
If you faced the same problem, please try the following procedure.

% git clone https://github.com/kevinmehall/openrisc-tools-build
% cd openrisc-tools-build 
% git submodule update --init
% wget https://raw.github.com/yTakatsukasa/misc/master/openrisc_toolchain/toolchain.patch -O - | patch -p1
% bash ./prepare.sh
% make -j3 PREFIX=

Note that this patch disables openOCD. If you need openOCD, add openOCD to all: in Makefile.

2013年6月25日火曜日

SystemC-AMS 1.0 with clang

On some system, linking with libsystemc-ams.a compiled with clang may cause multiple definitions. In that case, systemc-ams must be compiled with
-fgnu89-inline option.
 

Howto

 tar zxvf systemcams-1.0.tar.gz 

 cd systemcams-1.0
 ./configure --with-systemc=/your/systemc/path
 make CC="clang -fgnu89-inline"
 make install

configure script ignores environmental variable CFLAGS, so -fgnu89-inline option must be specified during make.

Background

Clang assumes .c file as a C99 source code. Some C program assumes its language is C89 with gnu extension (aka gnu89).
gnu89 and C99 have several differences. The biggest one is a function with 'extern inline'.
In gnu89, functions with 'extern inline' are not necessarily compiled to normal non-inlined function.
In C99, such functions must be also compiled to a normal non-inlined function.
Source code which is expected to be compiled with gnu89 may cause link error of multiple definitions for this case.
If you use inline function in C, use 'static inline'. Its meaning is same for both C99 and gnu89.

2013年6月12日水曜日

SystemC-2.3 with Clang

Clang is a compiler which features fast compile, friendly error messages and high-compatibility with the latest C++ standard.
SystemC-2.2 can not be compiled with clang due to syntax violation of SystemC library.
Such violations are fixed in SystemC-2.3 but not perfect.
Clang emits warnings with -Wall and -Wextra option.
It is important to set the warning level higher to keep code clean.
If warnings are emitted at the library, warnings of user code may be concealed by them.
This is why libraries must be warning-free.

I wrote small patch to suppress such warnings.
https://github.com/yTakatsukasa/misc/tree/master/systemc-2.3_clang

Apply systemc-2.3_clang.patch before configure., then build it as usual.
 
  1. tar zxvf systemc-2.3.0.tgz
  2. patch -p0 < systemc-2.3_clang.patch
  3. cd systemc-2.3.0
  4. env CC=clang CXX=clang++ CPP="clang -E" ./configure
  5. make
  6. make install

2013年6月10日月曜日

JCPU shows pretty good performance

I changed the name or QCPU (in previous post) to JCPU, because noun QCPU is already used in a FA industry. 'J' derives from JIT (Just In Time compilation).
Only limited instructions are implemented, but now it can execute simple program.
I tested with a bubble sort with printf and get the result of more than 100 million instructions / sec without any optimization techniques.
Exceptions, MMU and supervisor mode is still unimplemented. These feature will decrease the performance. I hope I can cancel these negative effect with optimization.

(2013/06/12 update)
very primitive version can be seen at https://github.com/yTakatsukasa/JCPU

2013年6月3日月曜日

Started a new project : QCPU

I started a new project QCPU, which is a fast processor model using LLVM.
There are several related projects like QEMU, libcpu, and ArchC.
QEMU is mature project and supporting many architectures.
So I had been struggling for 2-3 weeks to cut out the processor model from QEMU., but QEMU is written in C and uses a lot of C macro tricks, so many files that are not necessary for processor models. Finally I gave up to cut out from QEMU. But the project name QCPU still derives from QEMU even though no source code of QEMU is used any more.

libcpu uses LLVM, but it does not looks to be actively developed.

ArchC is ongoing ambitions project. But it does not look focusing a performance.

So I started by myself.

I want to achieve the following points in QCPU.
  • Performance
  • Clean C++ code, no static/global object
  • Multi-instance friendly

According to the result of LLVM-QEMU of GSoC2007, it will be very difficult to get the similar performance as QEMU, but it's OK because this is just a hobby.

Currently only several instructions of openrisc is implemented.
  • Implement all instruction of OpenRISC
  • Support more archtectures (arm, mips, ppc, xtensa)
  • Implement MMU emulation framework
  • GDB stub
  • Performance optimization

I hope I can make the initial version in public in this month. The license will be GPL.

2013年4月28日日曜日

Manipulate the Hierarchy of VCDs generated by ASI (OSCI) PoC SystemC Simulator

All signals are recorded in one hierarchy named 'SystemC' in VCD generated by SystemC simulator even though VCD can describe hierarchy.

Just modifying the header of VCD is sufficient to set hierarchy structure. The easiest way is to write such script in Ruby or Python. I once wrote such script but it was slow for a large VCD file.
It had to read and write the main part of VCD even the header is need to be modified.

I wrote a small program to manipulate VCD very quickly. Mapping a file to memory is key point to get a good performance. If the file size does not change, head of file can be modified and only the modified portion is written.

It is available at github.

It might have been easy if I used std::string, but I used string_view class to avoid copying strings for future program.