SystemC和Skyeye的集成

一、systemC介绍

 

二、集成的步骤

 

1. 编译 systemc

下载systemc-2.2.0,解压缩,并配置编译

./configure --prefix=/home/ksh/systemc_install/ ;make              

 

2. TLM-2009-07-15

下载TLM,并解压缩

 

 

3. 下载SkyEye软件包编译并安装。

 

4. 编写Systemc的模块

 

4.1 Makefile.am 

 # Should be set in the environment:
DEFAULT_TARGET_ARCH  = linux
DEFAULT_SYSTEMC_HOME = /Users/charleswilson/Documents/OSCI/SystemC/2.2-gcc4.0
DEFAULT_TLM_HOME     = /Users/charleswilson/Documents/ESLX/projects/tlm_2
DEFAULT_BOOST_HOME   = /Users/charleswilson/Documents/boost_1_35_0

 TARGET_ARCH         = linux64
  SYSTEMC_HOME        = $(HOME)/systemc_install
  TLM_HOME            = $(HOME)/spsim/TLM-2009-07-15/
  BOOST_HOME          = $(HOME)/spsim/boost-1_33_1/

#ifndef BOOST_HOME
# BOOST_HOME          = $(DEFAULT_BOOST_HOME)
#endif

SYSTEMC_INC_DIR      = $(SYSTEMC_HOME)/include
SYSTEMC_LIB_DIR      = $(SYSTEMC_HOME)/lib-$(TARGET_ARCH)
TLM_INC_DIR          = $(TLM_HOME)/include/tlm

# use null version for SystemC-2.1v1 / boost / gcc-3.4.4
#FLAG_WERROR          = -Werror
#FLAG_WERROR         =

GXX                  = g++
GCC                  = gcc
LD                   = g++

FLAGS                = -g -Wall -pedantic -Wno-long-long $(FLAG_WERROR) /
                       -D SC_INCLUDE_DYNAMIC_PROCESSES /
                       -I$(SYSTEMC_INC_DIR) -I$(TLM_INC_DIR)
AM_LDFLAGS              = -L$(SYSTEMC_LIB_DIR) -lsystemc
#VALGRIND             = valgrind --log-file-exactly=valgrind.log

spsim = spsim_module.c simple_test.cpp simple_top.cpp

libspsim_la_SOURCES = $(spsim)
libspsim_la_LDFLAGS = -module -L$(SYSTEMC_LIB_DIR) -lsystemc

pkglib_LTLIBRARIES = libspsim.la

DEFS = -g -Wall -pedantic -Wno-long-long $(FLAG_WERROR) -D SC_INCLUDE_DYNAMIC_PROCESSES
INCLUDES =  -I. @COMMON_INCLUDES@ -I$(SYSTEMC_INC_DIR) -I$(TLM_INC_DIR)
  
4.2 编写模块注册文件spsim_module.c

#include <stdlib.h>
#include "skyeye_module.h"
#include "skyeye_mach.h"
#include "simple_top.h"
const char* skyeye_module = "spsim";

void module_init(){
        test_main();
}

void module_fini(){
}

 

4.3 simple_test.cpp

#include "simple_test.h"

SIMPLE_TEST::SIMPLE_TEST (
                                       sc_core::sc_module_name name
                                   ):
                                       sc_core::sc_module(name)
{
    // ===================================
    // TODO : init local variables
    // ===================================


    // ===================================
    // End TODO
    // ===================================

    SC_THREAD(Hello);

} // end of SIMPLE_INITIATOR


SIMPLE_TEST::~SIMPLE_TEST()
{

}

void
SIMPLE_TEST::Hello(void)
{
    while (1)
    {
        printf("Hello world/n");
        wait(15,sc_core::SC_NS);
    }
}

 

4.4 simple_top.cpp

#include "simple_test.h"

#ifdef __cplusplus
 extern "C" {
#endif

int test_main(){

    SIMPLE_TEST *test = new SIMPLE_TEST("SimpleTest");
#if 1
    int index = 0;
    while (index < 30)
    {
        sc_start(10,sc_core::SC_NS);
        index++;
    }
    return 0;
#endif
}

#ifdef __cplusplus
}
#endif

 

4.5 simple_test.h

#ifndef  __SIMPLE_TEST_H
#define  __SIMPLE_TEST_H
// base requirment of TLM 2.0
#include "type_def.h"
class SIMPLE_TEST : public sc_core::sc_module
{
  public:
    SC_HAS_PROCESS (SIMPLE_TEST);
    SIMPLE_TEST(
                       sc_core::sc_module_name name
                    );
    ~SIMPLE_TEST();
    void Hello (void);
  private:

}; // end definiation of class SIMPLET_TEST

#endif //__SIMPLE_TEST_H

 

4.6 simple_top.h

#ifndef __SIMPLE_TOP_H__
#define __SIMPLE_TOP_H__

#ifdef __cplusplus
 extern "C" {
#endif

int sc_main();

#ifdef __cplusplus
}
#endif

#endif

三、编译运行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值