English 中文(简体)
撰写D flip-flop的主要节目
原标题:Writing the main program of a D flip-flop
  • 时间:2012-04-24 15:57:55
  •  标签:
  • systemc

I m new to systemC program i mpaper a D flip-flop but i cann t found a way to written the main programme and to enter threats (din , clock and dout in my case)

这是我的法典:

#include "systemc.h" 

 SC_MODULE(d_ff) { // on déclare le module à l aide de la macro SC_MODULE.

  sc_in<bool> din;   // signal d entrée
  sc_in<bool> clock;// définition de l horlogue
  sc_out<bool> dout;// signal de sortie

   void doit() {  // La fonction qui assure le traitement de la bascule D
     dout = din; // Affectation de la valeur du port d entrée dans le port de sortie

     cout << dout;
     }; 

    SC_CTOR(d_ff) { //le constructeur du module d_ff
    SC_METHOD(doit); //On enregistre la fonction doit comme un processus
    sensitive_pos << clock;  } 


   int sc_main (int argc , char *argv[]) {
     d_ff obj();
       din<=true;
     clock<=false;
     obj.doit();
     return 0;
         }};
最佳回答

You have to install VCD Viewers to see simulation results in the form of waveforms. I suppose that s what you want I use this one http://www.iss-us.com/wavevcd/index.htm, but there are others.

Next you have to make some changes in you code. The changes will produce the vcd files:

我这样说:

// File dff.h
#include <iostream>
#include <systemc.h>

SC_MODULE (dff) {
    sc_in <bool> clk;
    sc_in <bool> din;
    sc_out <bool> dout;

    void dff_method();

    SC_CTOR (dff) {
        SC_METHOD (dff_method);
            sensitive_pos << clk;
    }
};

// File dff.cpp
#include "dff.h"

void dff:: dff_method (){
    dout=din;
}


// File: main.cpp
#include <systemc.h>
#include "dff.h"

int sc_main(int argc, char* argv[])
{
    sc_signal<bool> din, dout;
    sc_clock clk("clk",10,SC_NS,0.5);

    dff dff1("dff");

    dff1.din(din);
    dff1.dout(dout);
    dff1.clk(clk);

    // WAVE
    sc_trace_file *fp;                    // VCD file
    fp=sc_create_vcd_trace_file("wave");
    fp->set_time_unit(100, SC_PS);        // resolution (trace) ps
    sc_trace(fp,clk,"clk");               // signals
    sc_trace(fp,din,"din");
    sc_trace(fp,dout,"dout");

    //Inicialization
    din=0;

    //START
    sc_start(31, SC_NS);               
    din=1;
    cout << "Din=1" << endl;
    cout << "Tempo: " << sc_time_stamp() << endl;

    sc_start(31, SC_NS);
    din=0;
    cout << "Din=0" << endl;
    cout << "Tempo: " << sc_time_stamp() << endl;

    sc_start(31, SC_NS);

    sc_close_vcd_trace_file(fp);        // fecho(fp)

    char myLine[100];
    cin.getline(myLine, 100);

    return 0;
}

我希望,它将帮助它。

问题回答

这一页是否有助于?

rel=“nofollow” http://www.asic-world.com/systemc/first1.html

它的标题是“My first program in System C”,这样就看你在哪里。

对新开办者的其他一些有用的联系:

rel=“nofollow” http://www.ht-lab.com/howto/vh2sc_tut/vh2sc_tut1.html





相关问题
Understanding types in SystemC

I am a beginner in SystemC programming and there is one thing I noticed (looking in the SystemC official documentation): all types that I used to deal with in VHDL simulations have not been "ported" ...

selective access to bits on datatypes with C++

I m using C++ for hardware-based model design with SystemC. SystemC as a C++ extension introduces specific datatypes useful for signal and byte descriptions. How can I access the first bits of a ...

SystemC Seg Fault on sc_core::sc_in<bool>::read()

I am having a repeating seg fault while using SystemC. During initialization I set a value to 0. During operation of a testbench I am setting this value to 1 in a module (proc). This is a sc_signal ...

Does system C support tri-state logic?

Does System C support tri-state logic? That is, bits that can get 0, 1 or X, where X means "unknown"? If it does, does it also support vectors that can contain Xes, including logic and arithmetic ...

Installing systemc SCV library on x86-64 machine

When I tried to install the SCV library, I came accross with the following problem: "checking build system type... Invalid configuration x86_64-unknown-linux-gnu : machine x86_64-unknown not ...

VHDL/Verilog related programming forums? [closed]

Hardware design with VHDL or Verilog is more like programming nowadays. However, I see SO members are not so actively talking about VHDL/Verilog programming. Is there any forum dealing with hardware ...

热门标签