Elvis Shera Posted January 30, 2018 Report Share Posted January 30, 2018 Hi, I came across the ConnectPorts between TDF and Discrete domain models..... In this case for the discrete domain is intended a System-C model, therefore, we go from classes to classes. The question I have is: How to connect in an efficient way a sc_signal<double> with a variable of type double? sc_signal<double> myscd; double myvar; having the above defined, what is a good way to do (a made up code): assign myscd = myvar; and assign myvar = myscd; I usually have to use the .read() and .write() methods but how can I achieve a permanent assignment? assuming that all that I want to do is manipulate simple variables. The same would apply to other data types (int, logic etc....) Quote Link to comment Share on other sites More sharing options...
maehne Posted January 31, 2018 Report Share Posted January 31, 2018 Signals constitute the communication channels between your models. However, in almost all cases, you should avoid to read/write them directly. Signals are meant to be bound to ports, which constitute the interface of your modules. The read() and write() member functions of the ports are the primary functions to reading a value from the port or writing a value into it, respectively. As you can see from the class definitions of the ports in the SystemC LRM and SystemC AMS LRM, the ports do provide depending on their input/output direction overloads, which allow them to be used in most cases like a regular variable for reading and writing: sc_core::sc_in<int> de_in; sc_core::sc_out<int> de_out; sca_tdf::sca_in<double> tdf_in; sca_tdf::sca_out<double> tdf_out; ... void my_proc() { int ivar; double dvar; ivar = de_in; de_out = ivar; dvar = tdf_in; tdf_out = dvar; } Though, using the read() and write() member functions of the ports is the recommended practice as this makes it explicit that you are accessing a port instead of a variable. As this questions touches very basic concepts of SystemC (AMS), I recommend you to read a good introductory text on SystemC and SystemC AMS. Quote Link to comment Share on other sites More sharing options...
Elvis Shera Posted February 1, 2018 Author Report Share Posted February 1, 2018 Thanks for the code template. "As this question touches very basic concepts of SystemC (AMS), I recommend you to read a good introductory text on SystemC and SystemC AMS.". Your point is well taken here. Sometimes, is hard to spot the solution to your problem by just going through the LRM. It comes down to having acquired a certain level of experience :). Thanks again, Elvis Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.