What is the meaning of the class variable

F

fl

Hi,
I am new to C++. I do not understand the function of the following
line.

..................................................
fir_top fir_top1 ( "process_body");
........................................

It calls a constructor, I guess. But I cannot find which constructor
it calls.
fir_top1 is a class, right? ( "process_body") is sent to where?



I have attached the relevant definition in the .h files below.

Thanks.
.......................................................


#define
SC_MODULE(user_module_name)
\
struct user_module_name : ::sc_core::sc_module



..................................................
SC_MODULE(fir_top) {

sc_in<bool> CLK;
sc_in<bool> RESET;
sc_in<bool> IN_VALID;
sc_in<int> SAMPLE;
sc_out<bool> OUTPUT_DATA_READY;
sc_out<int> RESULT;

sc_signal<unsigned> state_out;

fir_fsm *fir_fsm1;
fir_data *fir_data1;

SC_CTOR(fir_top) {

fir_fsm1 = new fir_fsm("FirFSM");
fir_fsm1->clock(CLK);
fir_fsm1->reset(RESET);
fir_fsm1->in_valid(IN_VALID);
fir_fsm1->state_out(state_out);

fir_data1 = new fir_data("FirData");
fir_data1 -> reset(RESET);
fir_data1 -> state_out(state_out);
fir_data1 -> sample(SAMPLE);
fir_data1 -> result(RESULT);
fir_data1 -> output_data_ready(OUTPUT_DATA_READY);

}
};
 
F

fl

Hi,
I am new to C++. I do not understand the function of the following
line.

.................................................
  fir_top   fir_top1    ( "process_body");
.......................................

It calls a constructor, I guess. But I cannot find which constructor
it calls.
fir_top1 is a class, right? ( "process_body") is sent to where?

I have attached the relevant definition in the .h files below.

Thanks.
......................................................

#define
SC_MODULE(user_module_name)
\
    struct user_module_name : ::sc_core::sc_module

.................................................
SC_MODULE(fir_top) {

  sc_in<bool>       CLK;
  sc_in<bool>       RESET;
  sc_in<bool>       IN_VALID;
  sc_in<int>     SAMPLE;
  sc_out<bool>      OUTPUT_DATA_READY;
  sc_out<int>       RESULT;

  sc_signal<unsigned> state_out;

  fir_fsm  *fir_fsm1;
  fir_data *fir_data1;

  SC_CTOR(fir_top) {

      fir_fsm1 = new fir_fsm("FirFSM");
      fir_fsm1->clock(CLK);
      fir_fsm1->reset(RESET);
      fir_fsm1->in_valid(IN_VALID);
      fir_fsm1->state_out(state_out);

      fir_data1 = new fir_data("FirData");
      fir_data1 -> reset(RESET);
      fir_data1 -> state_out(state_out);
      fir_data1 -> sample(SAMPLE);
      fir_data1 -> result(RESULT);
      fir_data1 -> output_data_ready(OUTPUT_DATA_READY);

    }



};- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -

Sorry, I forgot to add the following definition.

.................
#define
SC_CTOR(user_module_name)
\
typedef user_module_name
SC_CURRENT_USER_MODULE; \
user_module_name( ::sc_core::sc_module_name )
 
D

Default User

Sorry, I forgot to add the following definition.


You haven't included the declaration for the class. As your questions are
related to it, that's the only one that will be helpful.




Brian
 
F

fl

You haven't included the declaration for the class. As your questions are
related to it, that's the only one that will be helpful.

Brian

Thanks. Your mean the following?


//
----------------------------------------------------------------------------
// CLASS : sc_module
//
// Base class for all structural entities.
//
----------------------------------------------------------------------------

class sc_module
: public sc_object, public sc_process_host
{
friend class sc_module_name;
friend class sc_module_registry;
friend class sc_object;
friend class sc_port_registry;
friend class sc_process_b;
friend class sc_simcontext;

public:

sc_simcontext* sc_get_curr_simcontext()
{ return simcontext(); }

// to generate unique names for objects in an MT-Safe way
const char* gen_unique_name( const char* basename_, bool
preserve_first );

virtual const char* kind() const
{ return "sc_module"; }

protected:

// called by construction_done
virtual void before_end_of_elaboration();

void construction_done();

// called by elaboration_done (does nothing by default)
virtual void end_of_elaboration();

void elaboration_done( bool& );

// called by start_simulation (does nothing by default)
virtual void start_of_simulation();

void start_simulation();

// called by simulation_done (does nothing by default)
virtual void end_of_simulation();

void simulation_done();

void sc_module_init();

// constructor
sc_module( const char* nm );
sc_module( const std::string& nm );
sc_module( const sc_module_name& nm ); /* for those used to old
style */
sc_module();

public:

// destructor
virtual ~sc_module();

// positional binding methods

sc_module& operator << ( sc_interface& );
sc_module& operator << ( sc_port_base& );

sc_module& operator , ( sc_interface& interface_ )
{ return operator << ( interface_ ); }

sc_module& operator , ( sc_port_base& port_ )
{ return operator << ( port_ ); }

// operator() is declared at the end of the class.

const ::std::vector<sc_object*>& get_child_objects() const;

protected:

void add_child_object( sc_object* );
void remove_child_object( sc_object* );

// this must be called by user-defined modules
void end_module();


// to prevent initialization for SC_METHODs and SC_THREADs
void dont_initialize();

// positional binding code - used by operator ()

void positional_bind( sc_interface& );
void positional_bind( sc_port_base& );

// set reset sensitivity for SC_CTHREADs
void reset_signal_is( const sc_in<bool>& port, bool level );
void reset_signal_is( const sc_signal_in_if<bool>& iface, bool
level );

// static sensitivity for SC_THREADs and SC_CTHREADs

void wait()
{ ::sc_core::wait( simcontext() ); }

// dynamic sensitivity for SC_THREADs and SC_CTHREADs

void wait( const sc_event& e )
{ ::sc_core::wait( e, simcontext() ); }

void wait( sc_event_or_list& el )
{ ::sc_core::wait( el, simcontext() ); }

void wait( sc_event_and_list& el )
{ ::sc_core::wait( el, simcontext() ); }

void wait( const sc_time& t )
{ ::sc_core::wait( t, simcontext() ); }

void wait( double v, sc_time_unit tu )
{ ::sc_core::wait( sc_time( v, tu, simcontext() ),
simcontext() ); }

void wait( const sc_time& t, const sc_event& e )
{ ::sc_core::wait( t, e, simcontext() ); }

void wait( double v, sc_time_unit tu, const sc_event& e )
{ ::sc_core::wait(
sc_time( v, tu, simcontext() ), e, simcontext() ); }

void wait( const sc_time& t, sc_event_or_list& el )
{ ::sc_core::wait( t, el, simcontext() ); }

void wait( double v, sc_time_unit tu, sc_event_or_list& el )
{ ::sc_core::wait( sc_time( v, tu, simcontext() ), el,
simcontext() ); }

void wait( const sc_time& t, sc_event_and_list& el )
{ ::sc_core::wait( t, el, simcontext() ); }

void wait( double v, sc_time_unit tu, sc_event_and_list& el )
{ ::sc_core::wait( sc_time( v, tu, simcontext() ), el,
simcontext() ); }


// static sensitivity for SC_METHODs

void next_trigger()
{ ::sc_core::next_trigger( simcontext() ); }


// dynamic sensitivty for SC_METHODs

void next_trigger( const sc_event& e )
{ ::sc_core::next_trigger( e, simcontext() ); }

void next_trigger( sc_event_or_list& el )
{ ::sc_core::next_trigger( el, simcontext() ); }

void next_trigger( sc_event_and_list& el )
{ ::sc_core::next_trigger( el, simcontext() ); }

void next_trigger( const sc_time& t )
{ ::sc_core::next_trigger( t, simcontext() ); }

void next_trigger( double v, sc_time_unit tu )
{ ::sc_core::next_trigger(
sc_time( v, tu, simcontext() ), simcontext() ); }

void next_trigger( const sc_time& t, const sc_event& e )
{ ::sc_core::next_trigger( t, e, simcontext() ); }

void next_trigger( double v, sc_time_unit tu, const sc_event& e )
{ ::sc_core::next_trigger(
sc_time( v, tu, simcontext() ), e, simcontext() ); }

void next_trigger( const sc_time& t, sc_event_or_list& el )
{ ::sc_core::next_trigger( t, el, simcontext() ); }

void next_trigger( double v, sc_time_unit tu, sc_event_or_list&
el )
{ ::sc_core::next_trigger(
sc_time( v, tu, simcontext() ), el, simcontext() ); }

void next_trigger( const sc_time& t, sc_event_and_list& el )
{ ::sc_core::next_trigger( t, el, simcontext() ); }

void next_trigger( double v, sc_time_unit tu, sc_event_and_list&
el )
{ ::sc_core::next_trigger(
sc_time( v, tu, simcontext() ), el, simcontext() ); }


// for SC_METHODs and SC_THREADs and SC_CTHREADs

bool timed_out()
{ return ::sc_core::timed_out(); }


// for SC_CTHREADs

void halt()
{ ::sc_core::halt( simcontext() ); }

void wait( int n )
{ ::sc_core::wait( n, simcontext() ); }

void at_posedge( const sc_signal_in_if<bool>& s )
{ ::sc_core::at_posedge( s, simcontext() ); }

void at_posedge( const sc_signal_in_if<sc_dt::sc_logic>& s )
{ ::sc_core::at_posedge( s, simcontext() ); }

void at_negedge( const sc_signal_in_if<bool>& s )
{ ::sc_core::at_negedge( s, simcontext() ); }

void at_negedge( const sc_signal_in_if<sc_dt::sc_logic>& s )
{ ::sc_core::at_negedge( s, simcontext() ); }

// Catch uses of watching:
void watching( bool expr )
{ SC_REPORT_ERROR(SC_ID_WATCHING_NOT_ALLOWED_,""); }

// These are protected so that user derived classes can refer to
them.
sc_sensitive sensitive;
sc_sensitive_pos sensitive_pos;
sc_sensitive_neg sensitive_neg;

// Function to set the stack size of the current (c)thread
process.
void set_stack_size( std::size_t );

int append_port( sc_port_base* );

private:
sc_module( const sc_module& );

private:

bool m_end_module_called;
std::vector<sc_port_base*>* m_port_vec;
int m_port_index;
sc_name_gen* m_name_gen;
std::vector<sc_object*> m_child_objects;
sc_module_name* m_module_name_p;

public:

void defunct() { }

// positional binding methods (cont'd)

void operator () ( const sc_bind_proxy& p001,
const sc_bind_proxy& p002 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p003 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p004 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p005 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p006 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p007 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p008 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p009 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p010 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p011 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p012 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p013 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p014 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p015 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p016 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p017 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p018 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p019 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p020 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p021 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p022 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p023 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p024 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p025 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p026 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p027 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p028 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p029 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p030 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p031 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p032 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p033 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p034 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p035 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p036 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p037 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p038 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p039 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p040 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p041 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p042 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p043 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p044 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p045 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p046 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p047 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p048 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p049 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p050 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p051 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p052 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p053 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p054 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p055 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p056 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p057 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p058 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p059 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p060 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p061 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p062 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p063 = SC_BIND_PROXY_NIL,
const sc_bind_proxy& p064 = SC_BIND_PROXY_NIL );

};
 
B

Bart van Ingen Schenau

Hi,
I am new to C++. I do not understand the function of the following
line.

.................................................
  fir_top   fir_top1    ( "process_body");
.......................................

It calls a constructor, I guess. But I cannot find which constructor
it calls.
fir_top1 is a class, right? ( "process_body") is sent to where?

The SC_MODULE and SC_CTOR macros make the code a lot harder to
understand for novice programmers.

The "SC_MODULE(fir_top) { ... }" portion of your header defines
'fir_top' as being a class (or actually a struct; the 'struct' keyword
is hidden in the SC_MODULE macro).
The (only) constructor for this class is defined by the
"SC_CTOR(fir_top) { ... }" lines. This constructor is defined to take
a '::sc_core::sc_module_name' argument, which is probably some kind of
string.
As a hint for future use: 'ctor' is a commonly used abbreviation for
'constructor'. Similarly for 'dtor' and 'destructor'.

The line
fir_top fir_top1 ( "process_body");
defines a variable named 'fir_topl' of the type 'fir_top' and passes
the string "process_body" to the one constructor that fir_top has.

<snip>

Bart v Ingen Schenau
 
F

fl

The SC_MODULE and SC_CTOR macros make the code a lot harder to
understand for novice programmers.

The "SC_MODULE(fir_top) { ... }" portion of your header defines
'fir_top' as being a class (or actually a struct; the 'struct' keyword
is hidden in the SC_MODULE macro).
The (only) constructor for this class is defined by the
"SC_CTOR(fir_top) { ... }" lines. This constructor is defined to take
a '::sc_core::sc_module_name' argument, which is probably some kind of
string.
As a hint for future use: 'ctor' is a commonly used abbreviation for
'constructor'. Similarly for 'dtor' and 'destructor'.

The line
   fir_top   fir_top1    ( "process_body");
defines a variable named 'fir_topl' of the type 'fir_top' and passes
the string "process_body" to the one constructor that fir_top has.

<snip>

Bart v Ingen Schenau

I have know the answer to the above question. It has a friend class to
process the class name. A new question here, for the below definition
in .h file, I do not understand the second line.

#define
SC_MODULE(user_module_name)
\
struct user_module_name : ::sc_core::sc_module

I think the second line is equivalent to the first line. What is the
meaning of the second line? Could you explain the gramma to me? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top