Jump to content
jsmith125x

not gate with sc_logic

Recommended Posts

Something must be wrong in your setup, do any other SystemC programs work? What is the error message?

All bitwise operators (& ! ^ ~) should work for sc_logic. You can also use the logical ! after converting it to boolean (.to_bool()).

 

Hans.

Share this post


Link to post
Share on other sites
...\\notg.h(11): error C2678: binary '~' : no operator found which takes a left-hand operand of type 'sc_core::sc_in<sc_dt::sc_logic>' (or there is no acceptable conversion) [...\\systemc_model.vcxproj]

 



#ifndef notgH
#define notgH

#include "systemc.h"

SC_MODULE(notg)
{
sc_in<sc_logic> a; // input pins
sc_out<sc_logic> o; // output pin o

void proc() { o = ~a; }

SC_CTOR(notg)
{
SC_METHOD(proc);
sensitive << a;
}
};

#endif


Share this post


Link to post
Share on other sites

Hi,

 

How to implement a simple not gate with sc_logic type inputs? The ! operator is not defined for this type.

Hello Sir,

Because of the strongly typed nature of C++ (SystemC is after all a C++ library),

direct conversions that the C language pemits (loosely typed mother langauge

of C++) would not work. There is not much option but to manually convert from

sc_core::sc_logic to the pure and simple bool, do the inversion, and then re-convert

back to sc_logic. It is one of the not so exciting properties of the C++ language

that one has to live with.

Share this post


Link to post
Share on other sites

~ is a perfectly legal operator for sc_logic, see the LRM.

 

The problem was the OP was using an implicit method call which confused the compiler. Changing to an explicit .read() method call should fix the problem.

Regards,
Hans.

Share this post


Link to post
Share on other sites

~ is a perfectly legal operator for sc_logic, see the LRM.

 

The problem was the OP was using an implicit method call which confused the compiler. Changing to an explicit .read() method call should fix the problem.

Regards,

Hans.

Dear Sir,

The LRM mentions some things that often do not work with the proof of concept 

SystemC implementation. I have had a number of issues with sc_dt::sc_lv object

in the past, that were solved by using a brute force approach.

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

×