Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all 595 articles
Browse latest View live

vector declaration

$
0
0

hi,

 

when i try to assign a particular bti in a vector by using the statement ff[i]=o..it is showing error. Could any one pls tell what the mistake is.

 

.....

 sc_signal<sc_bv<8> > ff;

 

void func(){

sc_int<size>  i;

if(rst){

for(i=0;i<10;i++)
   ff[i]=0;//error
  }     ......

vector declaration

$
0
0

hi,

 

when i try to assign a particular bti in a vector by using the statement ff[i]=o..it is showing error. Could any one pls tell what the mistake is.

 

.....

 sc_signal<sc_bv<8> > ff;

 

void func(){

sc_int<size>  i;

if(rst){

for(i=0;i<10;i++)
   ff[i]=0;//error
  }     ......

Segmentation fault: Method sensitive to an event which is notified(immediately)

$
0
0

Hello,

 

With the following example, I have a method which is sensitive to an event which is notified(immediately) from end_of_elaboration() function.

This gives Segmentation fault (core dumped).

However if I do func_event.notify(SC_ZERO_TIME); or func_event.notify(1,SC_NS), there is no Segmentation fault

 

#include "systemc.h"

 

class TOP : public sc_module

{

  public:

  sc_event func_event;

  SC_HAS_PROCESS(TOP);

  TOP(sc_module_name name) {

    SC_METHOD(method_function);

    sensitive<<func_event;

    dont_initialize();

  }

  void end_of_elaboration(){

      func_event.notify();

  }

  void method_function() {

      std::cout<<"inside f() before wait"<<std::endl;

  }

};

 

int sc_main(int argc, char* argv[])

{

  TOP top("top");

  sc_start();

  return 0;

}

 

Please have a look, thanks in advance.

VCD file not generated

$
0
0

Hello there,

I've been trying to create a vcd file which helps me study the waveform of a 2 by 4 decoder. But, when I try to open the file "decoder.vcd" , it tells me that there is no such file or directory [ on Ubuntu 14.0.4  ].

 

//File: decoder_top.cpp

#include "driver.h"                                 //module that drives DUT
#include "monitor.h"                              //module that monitors DUT
#include "2_by_4_decoder.h"               //module that contains the info of the ports of DUT

int sc_main(int argc, char* argv[])
{
sc_signal<bool> t_select, t_enable, t_z;

sc_trace_file *wf = sc_create_vcd_trace_file("decoder");
wf->set_time_unit(1, SC_NS);


decoder2by4 dcdr("2by4decoder");
dcdr<<t_enable <<t_select <<t_z;

driver d1("GenerateWaveforms");

d1.d_select(t_select);
d1.d_enable(t_enable);
//d1.d_cin(t_cin);

monitor mo1 ("MonitorWaveforms");
mo1<< t_select << t_enable << t_z;

sc_trace(wf, t_select, "t_select");
sc_trace(wf, t_enable, "t_enable");
sc_trace(wf, t_z, "t_z");


sc_start(100, SC_NS);

sc_stop();

sc_close_vcd_trace_file(wf);


return(0);
}


Please help me solve this issue.

Thanks in advance!

Systemic & verilog co-simulation using cadence irun simulator

$
0
0
I am doing systemic & verilog co-simulation using cadence irun tool. When I am using non parameterize constructor and then using NCSC_MODULE_EXPORT it is working fine. But if I use parameterized constructor, then same NCSC_MODULE_EXPORT syntax is not working. Is the NCSC_MODULE_EXPORT different for parameterized constructor?

Accessing channel via port

$
0
0

Hello,

 

the class sc_port offers the function get_interface().

Is there also an option to get the bound channel?

 

Cheers!

 

Tim

Implement the function

$
0
0

Hi all,

I have a example with systemC. This example is implement and function. I have tried print results out to the monitor, but it seems to be incorrect ( it seems like the "c" variable updates slower than "a" and "b"  variable). Help me, please!  :wub:

 

Untitled08769.png

#define SC_INCLUDE_DYNAMIC_PROCESSES

#include "systemc"
using namespace sc_core;
using namespace sc_dt;
using namespace std;

#include "tlm.h"
#include "tlm_utils/simple_initiator_socket.h"
#include "tlm_utils/simple_target_socket.h"
#include "Initiator.h"
#include "Memory.h"

/*struct Top : public sc_module
{
  Initiator *initiator;
  Memory    *memory;

  SC_CTOR(Top)
  {
    initiator = new Initiator("initiator");
    memory    = new Memory   ("memory");

    initiator->socket.bind( memory->socket );
  }
};*/


int sc_main(int argc, char* argv[])
{
  Initiator *initiator;
  Memory    *memory;

  initiator = new Initiator("initiator");
  memory    = new Memory   ("memory");

  initiator->socket( memory->socket );

  sc_time t(100, SC_PS);

  sc_signal<bool> a,b,c,d;

  initiator->a(a);
  initiator->b(b);
  initiator->c(c);

  memory->d(d);

  sc_trace_file *wf= sc_create_vcd_trace_file("and2");
  sc_trace(wf, initiator->a, "a");
  sc_trace(wf, initiator->b, "b");
  sc_trace(wf, initiator->c, "c");
  sc_trace(wf, memory->d, "d");

  a.write(0);
  b.write(0);

  sc_start(t);
  a.write(0);
  b.write(1);

  sc_start(t);
  a.write(1);
  b.write(0);

  sc_start(t);
  a.write(1);
  b.write(1);

  sc_start(t);
  a.write(0);
  b.write(0);

  sc_start(t);
  sc_stop();

  sc_close_vcd_trace_file(wf);
  return 0;
}
#define SC_INCLUDE_DYNAMIC_PROCESSES

#include "systemc"
using namespace sc_core;
using namespace sc_dt;
using namespace std;

#include "tlm.h"
#include "tlm_utils/simple_initiator_socket.h"
#include "tlm_utils/simple_target_socket.h"

struct Initiator: sc_module
{
  tlm_utils::simple_initiator_socket<Initiator> socket;

	sc_in<bool> a,b;
	sc_out<bool> c;

  SC_CTOR(Initiator) : socket("socket")
  {
    SC_THREAD(do_and);
	sensitive << a << b;
  }

  void do_and()
  {
	  while(true)
	  {
		c.write(a.read()&b.read());
		data = 0xFF000000 | (c | 0x00000030);

		tlm::tlm_generic_payload* trans = new tlm::tlm_generic_payload;
		sc_time delay = sc_time(10, SC_NS);

		tlm::tlm_command cmd = tlm::TLM_WRITE_COMMAND;

		trans->set_command( cmd );
		trans->set_address(0);
		trans->set_data_ptr( reinterpret_cast<unsigned char*>(&data) );
		trans->set_data_length( 4 );
		trans->set_streaming_width( 4 ); // = data_length to indicate no streaming
		trans->set_byte_enable_ptr( 0 ); // 0 indicates unused
		trans->set_dmi_allowed( false ); // Mandatory initial value
		trans->set_response_status( tlm::TLM_INCOMPLETE_RESPONSE ); // Mandatory initial value

		socket->b_transport( *trans, delay );  // Blocking transport call
      
		 //Initiator obliged to check response status and delay
		if ( trans->is_response_error() )
			SC_REPORT_ERROR("TLM-2", "Response error from b_transport");
		
		cout << " a = " << hex << a << " , b = " << hex << b << " , c = " <<  hex << c << " , data = " << hex << data << " , " << sc_time_stamp() << endl;

		wait();
	  }
  }

  int data;
};
#define SC_INCLUDE_DYNAMIC_PROCESSES

#include "systemc"
using namespace sc_core;
using namespace sc_dt;
using namespace std;

#include "tlm.h"
#include "tlm_utils/simple_initiator_socket.h"
#include "tlm_utils/simple_target_socket.h"

// Target module representing a simple memory

struct Memory: sc_module
{
	sc_out<bool> d;

	enum { SIZE = 256 };
	int mem[SIZE];

	tlm_utils::simple_target_socket<Memory> socket;

  SC_CTOR(Memory) : socket("socket")
  {
    socket.register_b_transport(this, &Memory::b_transport);
  }

  // TLM-2 blocking transport method
	virtual void b_transport( tlm::tlm_generic_payload& trans, sc_time& delay )
  {
     tlm::tlm_command	cmd = trans.get_command();
     sc_dt::uint64		adr = trans.get_address() / 4;
     unsigned char*		ptr = trans.get_data_ptr();
     unsigned int		len = trans.get_data_length();
     unsigned char*		byt = trans.get_byte_enable_ptr();
     unsigned int		wid = trans.get_streaming_width();

    // Obliged to check address range and check for unsupported features,
    //   i.e. byte enables, streaming, and bursts
    // Can ignore DMI hint and extensions
    // Using the SystemC report handler is an acceptable way of signalling an error

    if (adr >= sc_dt::uint64(SIZE) || byt != 0 || len > 4 || wid < len)
      SC_REPORT_ERROR("TLM-2", "Target does not support given generic payload transaction");

    // Obliged to implement read and write commands
    if ( cmd == tlm::TLM_READ_COMMAND )
      memcpy(ptr, &mem[adr], len);
    else if ( cmd == tlm::TLM_WRITE_COMMAND )
      memcpy(&mem[adr], ptr, len);

	trans.set_response_status( tlm::TLM_OK_RESPONSE );

	if (mem[adr] == 0xFF000030)
	{
		d = false;
	}
	else
	{
		d = true;
	}

	//d = mem[adr];

	cout << " ptr = " << hex << ptr << " , mem[" << adr << "] = "  << mem[adr] << " , d = " << d << " , " << sc_time_stamp() << endl;
	
	}
};

Simulation stopped by the user

$
0
0

Hello there, 

While trying to run the executable, I get the following message:

 
Info: (I703) tracing timescale unit set: 1 ns (decoder.vcd)
At time0 s:: (select, enable) 00output is 0
 
Info: /OSCI/SystemC: Simulation stopped by user.
 
Please suggest me on how to solve this issue. 
 
Thanks in advance. 

system c and TLM 2.0 basics and help

$
0
0

Hi All,

I am new to system c and TLM.

Currently i am learning systemc and coding basics,

I want helps from you all.

pls give me some suggestion so that i can start learning properly .

currently i have started coding in eclipse based IDE environment with systemc library.

 

http://euinovation.blogspot.in/2016/02/systemc-development-of-eclipse-on-linux.html

 

what tool will be good to start with for system c coding ?

what virtulasation tool should i use for SOC simulation or basic basic module simulation and testing.

 

 

Since i am new to this pls suggest any kind of guidelines or suggestion is always welcome.

 

switch case

$
0
0

hi,

 

 Since iam new to systemc and am trying out new things in order to learn , iam getting lot of doubts, hope someone can help me out!!

 like i verilog where we use case statement for implementing fsm,similarly in  systemc to implement some fsm i hope we use switch statement, so is it possible to switch from one case to another? if so how is it done? 

 

This is part of the code i wanted to realize:

#include "systemc.h"
enum htrans_type { IDLE, BUSY,NONSEQ,SEQ};
SC_MODULE(trans){
sc_in<htrans_type> HTRANS;
void p1(){
while(true)
{
wait();
switch(HTRANS){
case IDLE: {///* I have some conditions here
}
break;
case IDLE: {/// * some conditions}
break;
case BUSY:{//// *some condition)
break;
}
 
how do i switch case from one case to other?

Error with a large number of SC_THREAD

$
0
0

Hi all,

 

In the context of a SystemC simulation with many SC_THREAD processes (> 32000), I am facing the following error on an Intel X86 platform running Ubuntu 15.04:

 

sc_cor_qt.cpp:114: virtual void sc_core::sc_cor_qt::stack_protect(bool) Assertion `ret == 0' failed

 

I looked into the implementation of the kernel, and here is my current understanding.

 

The default implementation of the SystemC kernel uses user-level threads (also called coroutines) to implement the SystemC processes. The static processes (SC_THREAD and SC_CTHREAD) are initialized in the sc_simcontext.cpp line 759 thread_p->prepare_for_simulation() This function will create the user-level thread object and then enable stack protection.

 

The stack of the user-level thread is allocated in the heap of the SystemC simulation process by the following line

 

cor->m_stack = new char[cor->m_stack_size]

 

The issue I am facing happens in the stack protection function after the creation, that uses an mprotect system call to make the page just after the stack of the user-level thread (again, being in the heap of the Linux process) non accessible at all (PROT_NONE). The error (ENOMEM) I have from mprotect says that this page we want to protect has never been mapped into the process or that the kernel was not able allocate some internal structures while running the mprotect call. Unfortunately I am not able to know which of these two errors happens and how to fix it. Moreover, I can't see where this extra page is allocated in the heap of the Linux process before the mprotect call is made.

 

Does anyone know what is going and/or what can I do know to further debug this issue ?

 

Thank you very much for any help you cna provide on this issue ?

 

----

Manu

 

Why [ ] operator is not overloaded for sc_signal ?

$
0
0

A follow-up question for

http://forums.accellera.org/topic/5443-vector-declaration/

 

Why square brakets are not overloaded for sc_signal class?  In case underling datatype allows bit-level access, it seems it would be handy to allow it for signals?

 

Looks like there is no technical limitation to do this, here is an example:

#include <systemc.h>

template< class T, sc_writer_policy POL = SC_DEFAULT_WRITER_POLICY >
struct my_sc_signal : public sc_signal<T, POL> {
    typedef my_sc_signal<T,POL>          this_type;
    typedef sc_signal<T, POL>            base_type;

    explicit my_sc_signal( const char* name_)  : base_type( name_ ){}

    struct signal_writer_helper {
        signal_writer_helper (this_type &s, size_t i) : sig(s), id(i) {}

        template <typename AT>
        void operator = ( const AT& val_ )
        {
            bool value_changed = !( sig.m_cur_val[id] == val_ );

            sig.m_new_val[id] = val_;
            if( value_changed )
                sig.request_update();
        }

        this_type &sig;
        size_t id;

    };

    signal_writer_helper operator [](size_t i) {
        return signal_writer_helper(*this, i);
    }

};


SC_MODULE(test) {

    static const int BUS_WIDTH = 10;
    my_sc_signal<sc_uint<BUS_WIDTH> > test_sig{"test_sig"};

    SC_CTOR(test) {
        SC_THREAD(master_thread);
        SC_METHOD(slave_method);
        sensitive << test_sig;
    }

    void master_thread() {
        for (int i = 0; i < BUS_WIDTH; ++i) {
            test_sig[i] = 1;
            wait(1, SC_NS);
        }

        for (int i = 0; i < BUS_WIDTH; ++i) {
            test_sig[i] = 1;
            wait(1, SC_NS);
        }

        sc_stop();
    }

    void slave_method() {
        cout << "New signal value is: " << test_sig.read() << endl;
    }

};

int sc_main(int argc, char *argv[]) {

    test test_inst("test_inst");
    sc_start();
    return 0;

}

Help me about "error C2064: term does not evaluate to a function taking 1 arguments"

$
0
0

I don't know how to fix this error, help me please

#define SC_INCLUDE_DYNAMIC_PROCESSES

#include "systemc"
using namespace sc_core;
using namespace sc_dt;
using namespace std;

#include "tlm.h"
#include "tlm_utils/simple_initiator_socket.h"
#include "tlm_utils/simple_target_socket.h"
#include "Initiator.h"
#include "Router.h"
#include "Memory.h"

int sc_main(int argc, char* argv[])
{
  Initiator* initiator;
  Router<4>* router;
  Memory*    memory[4];

  initiator = new Initiator("initiator");
  router    = new Router<4>("router");
    for (int i = 0; i < 4; i++)
    {
      char txt[20];
      sprintf(txt, "memory_%d", i);
      memory[i]   = new Memory(txt);
    }

    // Bind sockets
    initiator->socket.bind( router->target_socket );
    for (int i = 0; i < 4; i++) 
		router->initiator_socket[i]->bind( memory[i]->socket );

	sc_time t(100, SC_PS);

  sc_signal<bool> a,b,c;
  sc_signal<int> d;

  initiator->a(a);
  initiator->b(b);
  initiator->c(c);

  memory[0]->d(d);

  sc_trace_file *wf= sc_create_vcd_trace_file("and2");
  sc_trace(wf, initiator->a, "a");
  sc_trace(wf, initiator->b, "b");
  sc_trace(wf, initiator->c, "c");
  sc_trace(wf, memory[0]->d, "d");

  a.write(0);
  b.write(0);

  sc_start(t);
  a.write(0);
  b.write(1);

  sc_start(t);
  a.write(1);
  b.write(0);

  sc_start(t);
  a.write(1);
  b.write(1);

  sc_start(t);
  a.write(0);
  b.write(0);

  sc_start(t);
  sc_stop();

  sc_close_vcd_trace_file(wf);
  return 0;
}

it's error in this lines

memory[0]->d(d);
sc_trace(wf, memory[0]->d, "d");

Issue with sc_inout_resolved

$
0
0

I am writing I2C model (as per my requirement) which include master.cpp and slave.cpp. There are 2 signals: SDA and SCL, both are type of sc_inout_resolved in both the files. Connection and Port binding is done perfectly in test bench as well.  I am controlling SDA & SCL in file called master.cpp. While transferring ack from slave to master,  SDA will be controlled by slave.cpp (writes SDA 0). After this again master.cpp should control the SDA line for further transactions. But once controlling on SDA switches to slave.cpp, unable to control SDA again from master.cpp. Writing values(0,1) on SDA is not making any difference. I confirmed this issue using gtkwave. Am I missing anything here? Can anyone tell how to handle sc_inout_resolved between 2 models?.

Problems with SystemC syntax, improvment request

$
0
0

Hello, 

Is any facelift planned for next SystemC release (2.4 or 3.0)?

 

I want to share some feedback , from synthesizable SystemC designer prospective. 

 

Recently I’ve done a lot of synthesizable SystemC coding for HLS (High level synthesis tools). I really enjoy the power of synthesizable stateful threads (SC_THREADS), it helps a lot in converting algorithmic C++ code into RTL.  TLM abstraction of synthesizable bus interfaces works well too.

However, If you look at low level syntax details, SystemC code looks really ugly comparing to Verilog.  Consider a simple example:

module adder (
  input [7:0] a, b,
  output [8:0] res
  );

  assign res = a + b;

endmodule

module adder_test;
  reg [7:0] a, b;
  wire [8:0] res;

  adder adder_isnt(
    .a(a),
    .b(b),
    .res(res)
  );

  initial begin
    a = 11; b = 31;
    #1;
    $display("%d",res);
  end

endmodule

If I rewrite in SystemC it would be:

 
#include <systemc.h>

SC_MODULE(adder) {

   sc_in<uint8_t>      a, b;
   sc_out<sc_uint<9> > sum;

   SC_CTOR(adder)
   : a{"a"}
   , b{"b"}
   , sum{"sum"}
   {
       SC_METHOD(add_method);
       sensitive << a << b;
   }

   void add_method() {
       sum = a + b;
   }
};

SC_MODULE(adder_test) {

   sc_signal<uint8_t>     a, b;
   sc_signal<sc_uint<9>>  sum;

   adder add_inst;

   SC_CTOR(adder_test)
   : a("a")
   , b("b")
   , sum("sum")
   , add_inst("add_inst")
   {
       add_inst.a(a);
       add_inst.b(b);
       add_inst.sum(sum);

       SC_THREAD(test_thread);
   }

   void test_thread() {
       a = 11; b = 31;
       wait(1, SC_PS);
       cout << sum.read() << endl;
       sc_stop();
   }

};

Main problem is not that SystemC code has more charaters/LOCs, but that semantically related statements are distributed across source file.

 

Take for example adder instantiation:

  • First we have to declare member variable:

  adder add_inst;
  • Next we need to initialize its name:

  : add_inst("add_inst")
  • And finally bind its ports:

add_inst.a(a);
add_inst.b(b);
add_inst.sum(sum);

Because of this syntactic problem it is very hard to read SystemC code when you have a lot of signals and modules instantiated.  

 

Same problem with SC_METHOD and SC_THREAD:

You have to define method in one part of code, and declare it as a SC_METHOD/SC_THREAD in another.  I often forgot to put this SC_THREAD macro and my simulations do not work.

Forgetting sc_module_name initialization is even more common (but does not do that much damage).

 

So there are two problems with SystemC syntax:

  • Code hard to read.
  • Easy to forget something.

 

I hope this will be fixed soon.  If I start to think about it , I see two possible options:

 

 

Option 1: Preprocessing

 

First solution would be creating some SystemC preprocessor. It's not that uncommon idea in C++ world.  For example widely used Qt Framework (http://www.qt.io/) uses it’s own preprocessor. Some EDA SystemC tools use it too: Forte Cynthesizer used preprocessor to extract uArch constraints from some vendor predefined Macros,  I think Cadence Stratus inherited this HLS Macro idea too (have not tried it yet).


The obvious argument against this would be breaking C++ tools compatibility (for example C++ IDE front-ends). But it’s not always the case: Qt and HLS preprocessors do not break C++ syntax,  syntactically valid SystemC code will stay a valid C++ code.

But some C++ static analysis tools may break: for example, if we generate body of sc_module constructors in preprocessor, than we will have some “unreachable” code, “unused” methods detected in human-written code.


Second argument against preprocessor is that user will need to integrate additional step into C++ build process. Sometimes it hurts, many users do not like to write custom build steps.


Main benefit in preprocessing is that it solves all the problems. It would be even possible to automatically generate sensitivity lists for SC_METHODS (in that case it it would be very smart Clang-based preprocessor), highly desired.

http://forums.accellera.org/topic/5430-what-is-always-verilig2001-equivalent-syntax-in-systemc/

 

Option 2:  Improve SystemC library

 

Many things can be done simply by improving SystemC library.  In that case we will be limited by C++ meta-programming capabilities.


Ultimate solution to sc_object naming will be C++ reflection:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4451.pdf

But my bet it would not be standardized in next five years or so. Probably some EDA or semiconductor company can devote some resources to make it happen sooner?


Many things are better out-of-the box in C++11,

For example in-class initializers:

sc_signal<uint8_t>     a{"a"}, b{"b"};
sc_signal<sc_uint<9>>  sum{"sum"};

I use it now in all of my SystemC verification code.  Unfortunately not yet supported by HLS tool I use.


David Black proposed solution for assign

http://nascug.org/events/17th/black_cpp11_2_27_2012.pdf

Same idea with lambda can be applied to every SC_METHODS/SC_THREAD processes.  



Binding instance ports can be implemented in the same place where instance defined.

Consider for example passing “bind” lambda using in-class initializer:

 
#define SC_CTOR(user_module_name)                                           \
  typedef std::function<void(user_module_name& self)> bind_func_t;          \
  typedef user_module_name SC_CURRENT_USER_MODULE;                          \
  user_module_name( ::sc_core::sc_module_name, bind_func_t bindf= 0)        \
  { if (bindf) { bindf(*this); }

#define BIND_INST(module_type) \
  [&](module_type& i)

Summing all together improved SystemC can probably look like:

 

SC_MODULE(adder) {
      sc_in<uint8_t>       a{"a"}, b{"b"};
      sc_out<sc_uint<9> >  sum{"sum"};

      SC_CTOR(adder) {
           ASSIGN( a|b, sum = a + b; );
      }
};

SC_MODULE(adder_test) {
      sc_signal<uint8_t>     a{"a"}, b{"b"};
      sc_signal<sc_uint<9>>  sum{"sum"};

      adder add_inst{"add_inst", BIND_INST(adder) {
              i.a(a);
              i.b(b);
              i.sum(sum);
          }};

      SC_CTOR(adder_test) {          
          SC_THREAD_LAMBDA(test_thread) {
              a = 11; b = 31;
              wait(1, SC_PS);
              cout << sum.read() << endl;
              sc_stop();
          }
      }
};
 

sc_port sc_export binding issue

$
0
0

Hi

 

I am facing an issue with sc_port sc_export binding.

 

My following example compiles fine

class initiator : public sc_module {
    public:
    sc_port<sc_signal_inout_if<bool> > out;
    initiator(sc_module_name name){}
};

class target : public sc_module {
    public:
    sc_port<sc_signal_in_if<bool> > in;
    target(sc_module_name name){}
};

int sc_main(int, char**){
    initiator init("init");
    target targ("targ");
    sc_signal<bool> sig;
    init.out(sig);
    targ.in(sig);
    sc_start();
    return 0;
}

 

But when I move the channel inside the target, and replace sc_port with sc_export, I have following error

 

 

class initiator : public sc_module {
    public:
    sc_port<sc_signal_inout_if<bool> > out;
    initiator(sc_module_name name){}
};

class target : public sc_module {
    public:
    sc_export<sc_signal_in_if<bool> > in;
    sc_signal<bool> sig;
    target(sc_module_name name){in(sig);}
};

int sc_main(int, char**){
    initiator init("init");
    target targ("targ");
    init.out(targ.in);
    sc_start();
    return 0;
}

 

the error is

error: no match for call to ‘(sc_core::sc_port<sc_core::sc_signal_inout_if<bool>, 1, (sc_core::sc_port_policy)0u>) (sc_core::sc_export<sc_core::sc_signal_in_if<bool> >&)’
 

Can you help me in inderstanding this issue ?

 

Thanks

Rahul

 

 

Issue in viewing waveform

$
0
0

Hello there, 

The simulation for my module stops at 55 ns. This might probably happen because of my driver. In GTKwave , am not able to view what is the input and output at 55(th) ns, since the simulation stops exactly stops at 55. 

How to keep the simulation time to be infinite or extend more so that I can also view the last set of inputs? 

I also tried deactivating the "sc_stop()" command, but no change was found. If so, what's the need of sc_stop() ?

 

Any help would be appreciated. :)

 

Thanks in advance.

Seg fault when port is bound to dummay signal in before_end_of_elaboration

$
0
0

Hello

 

In the following example I am tying to connect the unconnected port to dummy channel in before_end_of_elaboration callback. But it gives me seg fault

 

#include "systemc.h"

class test : public sc_module {
    public:
    sc_in<bool> in1;
    SC_HAS_PROCESS(test);
    test(sc_module_name name){
        SC_THREAD(fun);
    }

    void fun(){
    }

    void before_end_of_elaboration(){
        sc_signal<bool> sig;
        in1.bind(sig);
    }
};

int sc_main(int, char**){
    test t("t");
    sc_start();
    return 0;
}

 

Can you please help.

 

Also the standard says that @page 122 that the time at which deferred port binding is complete is implementation defined, so where I shoudl check my unconnected ports in the module"

 

Thanks

RahulJn

creating additional ports in before_end_of_elaboration callback

$
0
0

Hello

 

As per standard we can create new sc_port in before_end_of_elaboration callback

In the following example, I am creating a new port in before_end_of_elaboration callback but it is not connected in sc_main.

#include "systemc.h"

class test : public sc_module {
    public:
    SC_HAS_PROCESS(test);
    test(sc_module_name name){
        SC_THREAD(fun);
    }
    void fun(){}
    void before_end_of_elaboration(){
        sc_port<sc_signal_inout_if<bool> > in1;
    }
};

int sc_main(int, char**){
    test t("t");
    sc_start(100,SC_NS);
    sc_stop();
    return 0;
}

But I am not getting unconnected port error.

 

 

Thanks

RahulJn

Merging sc_int and sc_bigint

$
0
0

It seems like it makes sense to merge sc_*int and sc_big*int types.

 

Wide buses are all around in modern systems. For example 64 bytes is common size of cache line. 

I do not see a good reason to keep two types for representing types with user-defined size.

 

For example in Verilog I have single common type for all cases:

bit [31:0] address;
bit [511:0] data;

But in SystemC I will have to use different types:

sc_uint<32> address;
sc_biguint<512> data;

Specializing sc_uint depending on size will not break compatibility with existing Systemc 2.3 code .

constexpr bool is_biguint(unsigned x) { return x > 64; }

template<int n, bool isbig = is_biguint(n)>
struct sc_uint {};

template<int n>
struct sc_uint <n, true>: public sc_unsigned { };

template<int n>
struct sc_uint <n, false>: public sc_uint_base { };
 
Viewing all 595 articles
Browse latest View live