Jump to content

initialization problem with <sc_dt::sc_logic> port


Recommended Posts

Hello Geniuses, 

 

in my ADC design, I have a output signal "eoc" (end of conversion), I declared it in port declaration like below

 

sca_tdf::sca_de::sca_out<sc_dt::sc_logic> eoc;

 

In processing function, when I assign it a value '1' like below

 

eoc = '1';

 

I get following error message

 

A2D.cpp: In member function ‘virtual void a2d_nbit::processing()’:

A2D.cpp:50: error: invalid conversion from ‘char’ to ‘sc_dt::sc_logic_value_t’
A2D.cpp:50: error:   initializing argument 1 of ‘sc_dt::sc_logic::sc_logic(sc_dt::sc_logic_value_t)’
 
I also tried to initialize "eoc" in Initialize function like
 
eoc.initialize('1');
 
but then my compiler gives me another error as follows
 
A2D.cpp: In member function ‘virtual void a2d_nbit::initialize()’:
A2D.cpp:28: error: invalid conversion from ‘char’ to ‘sc_dt::sc_logic_value_t’
A2D.cpp:28: error:   initializing argument 1 of ‘sc_dt::sc_logic::sc_logic(sc_dt::sc_logic_value_t)’
 
could you please suggest me how can initialize and assign sc_dt::sc_logic port ?
 
thanks in advance, 
 
Milind.
 
 

 

Link to comment
Share on other sites

The sc_logic constructor taking a char is marked as explicit.  Therefore, you can't pass a char to functions expecting an sc_logic (e.g. initialize).

 

You can either explicitly create (pun intended) an sc_logic from a char, or use the predefined sc_logic constants for assignments and parameter passing:

sc_logic a;
a = sc_logic('1');

eoc.initialize( SC_LOGIC_0 ); // SC_LOGIC_1, SC_LOGIC_X, SC_LOGIC_Z

Greetings from Oldenburg,
  Philipp

Link to comment
Share on other sites

Hello experts, 

I have further problems with my ADC design. 

 

In a A2D TDF module, I have a following ports: 

 
  sca_tdf::sca_in<double> a_in; // analog input pin
 
  sca_tdf::sca_de::sca_in<sc_dt::sc_logic> start;                               //start signal
  sca_tdf::sca_de::sca_in<sc_dt::sc_logic> clk;                                 //clock signal
 
  sca_tdf::sca_de::sca_out<sc_dt::sc_logic> eoc;                             //end of conversion pin  
  sca_tdf::sca_de::sca_out< sc_dt::sc_lv<8> > d_out;                       // digital output signal
 
I want to trace all the input and output ports in the top_level design. In the top_level design, I have also instantiated a Voltage source, and a internal signal in with type double is declared. 
 
      ________     in              __________________
      | vtg_src |-------------->|  A2D TDF module   |--------> d_out 
      |_______ |      start---->|__________________|--------> eoc
 
I suppose in oder to trace d_out, eoc, and start, I need to connect them to the internal signals. I have tried following approach but the compiler returns with error.
     
//following part is the part of constructor
 
 a2d.a_in(in);
 a2d.d_out(out);
 a2d.start(start);
 a2d.clk(clk);
 a2d.eoc(eoc);
 
 SC_THREAD(start_logic);
 
}
 
private:
 
sca_tdf::sca_signal <double> in;
sc_core::sc_signal<sc_dt::sc_lv<8>> out;
sc_core::sc_signal<sc_dt::sc_logic> start, clk, eoc;
 
could you please suggest me what kind of internal signals I need to use in this case ?
 
thanks in Advance !!!
 
best regards, 
Milind
Link to comment
Share on other sites

Usually it is better to start a new topic in this forum, when there is a new question.

 

Secondly, you should always provide the detailed error message given by the compiler.

 

It is not entirely clear to me, what you are trying to achieve, because you do not show the all relevant parts of the code.  Irrespectively of any tracing, you always need to connect the ports through appropriate channels (TDF or SystemC signals in your case).

 

Last, but not least, a wild guess regarding the compiler error:

 

sc_core::sc_signal<sc_dt::sc_lv<8>> out;

 

In case you've copied the code directly to the browser and depending on your compiler version, you need to insert a space between the two closing template brackets:

sc_core::sc_signal<sc_dt::sc_lv<8> > out;
//              space needed here ^ 

 

Hope that helps,

  Philipp

 

Link to comment
Share on other sites

  • 4 years later...
On 7/11/2013 at 5:20 AM, Philipp A Hartmann said:

The sc_logic constructor taking a char is marked as explicit.  Therefore, you can't pass a char to functions expecting an sc_logic (e.g. initialize).

 

You can either explicitly create (pun intended) an sc_logic from a char, or use the predefined sc_logic constants for assignments and parameter passing:


sc_logic a;
a = sc_logic('1');

eoc.initialize( SC_LOGIC_0 ); // SC_LOGIC_1, SC_LOGIC_X, SC_LOGIC_Z

Greetings from Oldenburg,
  Philipp

Hi , can you explain the diffrence between " eoc.initialize(false) and  eoc .write ( false) "?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...