Jump to content

"Reading" a file and passing it as input


sumi29

Recommended Posts

I am writing some code that requires me to read a file and then use it as input to the SystemC module. What this means is that I should read a file, say, abc.xxx, and then send its content in the binary form to a port (another way to interpret this: I wanna read a file into the buffer and send this buffer through a SystemC port). Basically, I want to demonstrate that I can "read" any file and perform any operations on it. My questions are:

 

1) I could use a text file as my input. Read the text file, and store its text contents in a string (using C++, which would be enough for my purposes). But how would I send this string through a systemC port?

 

2) The above solution is only for text files, where I wanna use the text content of a text file. But like my original query, what would I do when I just want to transfer the file through the port?

 

I apologize if my query isn't completely clear. Thanks in advance!!

 

Link to comment
Share on other sites

I am writing some code that requires me to read a file and then use it as input to the SystemC module. What this means is that I should read a file, say, abc.xxx, and then send its content in the binary form to a port (another way to interpret this: I wanna read a file into the buffer and send this buffer through a SystemC port). Basically, I want to demonstrate that I can "read" any file and perform any operations on it. My questions are:

 

1) I could use a text file as my input. Read the text file, and store its text contents in a string (using C++, which would be enough for my purposes). But how would I send this string through a systemC port?

 

2) The above solution is only for text files, where I wanna use the text content of a text file. But like my original query, what would I do when I just want to transfer the file through the port?

 

I apologize if my query isn't completely clear. Thanks in advance!!

 

Hello,

I am afraid you have run into the limitations of C++ templates, and a

viable option is to use your own custom channel. To achieve that,

you have to :

 

1. create a custom interface - sub-class of sc_core::sc_interface

2. create a class that implements the interface - the channel

3. create a custom port to read in strings from your custom channel

 

Because of the limitations of C++ templates, there is no generic way to

tackle strings. You see for all the pre-defined port types in SystemC, the

size of the data type is fixed (int 'x' bytes, double 'y' bytes etc., ) But

there is no fixed size for a string -- how would the SystemC elaboration

step assign space for it ? So, one has to create one's own channel

and port. Hope that helps.

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...