Jump to content
mohitnegi

string directly as input ??/

Recommended Posts

hello ,,

 

i wish to use string as input data type i have used ...

sc_in<unsigned char> data_in;

and i am using data_in as static sensitivity ....and am getting error :

ca_fifo.h: In constructor ‘fifo::fifo(sc_core::sc_module_name)’:
ca_fifo.h:27:6: error: invalid static_cast from type ‘void (fifo::*)(char)’ to type ‘sc_core::SC_ENTRY_FUNC {aka void (sc_core::sc_process_host::*)()}’

please explain me the above error as i wish to sent a string literal from stimulus ...

 

and on page 199 of 1666-2011 string literals topic ...it is written

"

A string literal representation may be used as the value of a SystemC numeric or vector type object."

 

does it mean that we cannot sent a string literal directly ...

 

thanks

Mohit Negi

Share this post


Link to post
Share on other sites

Please show more of your code, including the line where the error occurs,

 

regards

Alan

 

P.S. I don't think the quote from the LRM is relevant. What that quote says is that you may write

 

  sc_lv<8> = "10101010";

 

i.e. mix vector types and string literals.

Share this post


Link to post
Share on other sites
#include <systemc.h>

SC_MODULE (fifo)
{
  sc_in<bool> read_write_n;
  sc_in<unsigned char> data_in;
  sc_in<bool> clock;
  sc_in<bool> reset;
  
  sc_out<bool> output;

  void fifo_read();
  void fifo_write(unsigned char c);
  void fifo_reset();

  sc_event write_event,read_event;
  enum e{MAX=10};
  char data[MAX];
  int num_element,first;

 SC_CTOR (fifo)
  {
     SC_THREAD(fifo_read);
     sensitive<<read_write_n;
     sensitive_pos<<clock;
      
     SC_THREAD(fifo_write);
     sensitive<<read_write_n;//<<data_in;
     sensitive<<data_in;
     sensitive_pos<<clock;

     SC_THREAD(fifo_reset);
     sensitive<<reset;
   }   
};

error is

mohit@ubuntu:~/Desktop/Untitled Folder$ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux -Wl,-rpath=$SYSTEMC_HOME/lib-linux ca_fifo.h -lsystemc -lm
ca_fifo.h: In constructor ‘fifo::fifo(sc_core::sc_module_name)’:
ca_fifo.h:27:6: error: invalid static_cast from type ‘void (fifo::*)(unsigned char)’ to type ‘sc_core::SC_ENTRY_FUNC {aka void (sc_core::sc_process_host::*)()}’

Share this post


Link to post
Share on other sites

Thanks Mohit - I think the error is here:

 

 

void fifo_write(unsigned char c);

Static SystemC processes may not have arguments. You need to remove the argument from the function declaration, e.g.

 

 

void fifo_write();
 

regards

Alan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×