Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7897927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:17:43+00:00 2026-06-03T08:17:43+00:00

I’m new to systemC programming i’m writing a D flip-flop but i couldn’t find

  • 0

I’m new to systemC programming i’m writing a D flip-flop but i couldn’t find a way to write the main program and to enter signals (din , clock and dout in my case) :

this is my code :

#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;
         }};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:17:44+00:00Added an answer on June 3, 2026 at 8:17 am

    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:

    I made this one:

    // 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;
    }
    

    I hope it will help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.