SystemC-AMS中的跟踪信号问题

时间:2018-07-23 14:06:14

标签: c++ eclipse cygwin systemc

我在SystemC-AMS中实现了一个正弦波发生器,并希望在一定时间内可视化其输出。为此,我想创建一个VCD文件。生成器的代码和主要功能如下所示。我的问题是VCD文件为空。我在做什么错了?

main.cpp:

#include <iostream>
#include "systemc.h"
#include "systemc-ams.h"
#include "sin_source.h"

int sc_main (int argc, char* argv[])
{
    std::cout << "Hello World" << std::endl;

    sca_tdf::sca_signal <double> out1;
    sin_source mySine("sine1");
    mySine.out(out1);

    sca_util::sca_trace_file *tf1= sca_util::sca_create_vcd_trace_file("sine_wave");
    sca_util::sca_trace(tf1, out1, "i'm_sine_1");

    sc_core::sc_start(10, sc_core::SC_MS);
    sca_util::sca_close_vcd_trace_file(tf1);

    return 0;
}

sin_source.h:

#include <systemc-ams.h>

SCA_TDF_MODULE(sin_source)
{
    sca_tdf::sca_out<double> out;

    double ampl;
    double freq;

    void set_attributes()
    {
        out.set_timestep(5, SC_US);
    }

    void processing ()
    {
        double t=out.get_time().to_seconds();
        double x = ampl * std::sin(2.0 * M_PI * freq * t);
        out.write(x);
    }

    SCA_CTOR(sin_source):
        out("out"), ampl(1.0), freq(1e3){}
};

编辑:不幸的是,重命名信号并没有显示任何改善。现在,我如下所示更改了main.cpp。在输出中,我看到的最后一个“ Hello World”消息是编号为4的消息。因此,很可能在程序退出之前我的仿真从未开始。

更改了main.cpp:

int sc_main (int argc, char* argv[])
{
    std::cout << "Hello World" << std::endl;

    sca_tdf::sca_signal <double> out1;
    sin_source mySine("sine1");
    mySine.out(out1);

    std::cout << "Hello World 2" << std::endl;

    sca_util::sca_trace_file *tf1= sca_util::sca_create_vcd_trace_file("sine_wave");

    std::cout << "Hello World 3" << std::endl;

    sca_util::sca_trace(tf1, out1, "sine");

    std::cout << "Hello World 4" << std::endl;

    sc_core::sc_start(10, sc_core::SC_MS);

    std::cout << "Hello World 5" << std::endl;

    sca_util::sca_close_vcd_trace_file(tf1);

    std::cout << "Hello World 6" << std::endl;

    return 0;
}

控制台输出:

Hello World
Hello World 2
        SystemC 2.3.2-Accellera --- Jul 17 2018 16:06:04
        Copyright (c) 1996-2017 by all Contributors,
        ALL RIGHTS RESERVED


        SystemC AMS extensions 2.1.0-COSEDA Release date: 20160404
        Copyright (c) 2010-2014  by Fraunhofer-Gesellschaft IIS/EAS
        Copyright (c) 2015-2016  by COSEDA Technologies GmbH
        Licensed under the Apache License, Version 2.0


Hello World 3
Hello World 4

Info: SystemC-AMS: 
    1 SystemC-AMS modules instantiated
    1 SystemC-AMS views created
    1 SystemC-AMS synchronization objects/solvers instantiated


Info: SystemC-AMS: 
    1 dataflow clusters instantiated
      cluster 0:
        1 dataflow modules/solver, contains e.g. module: sine1
        1 elements in schedule list,  
        5 us cluster period, 
        ratio to lowest:  1              e.g. module: sine1
        ratio to highest: 1 sample time  e.g. module: sine1
        0 connections to SystemC de, 0 connections from SystemC de

1 个答案:

答案 0 :(得分:0)

我无法重现该问题。您是否在文本编辑器中打开了文件以检查它是否真的为空?

可能是有问题的问题,我看到的是信号名称中的'(sca_util :: sca_trace(tf1,out1,“ i'm_sine_1”);)-可能您的waveviewer不喜欢它。