Jump to content

not gate with sc_logic


Recommended Posts

...\\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_in<sc_logic> a; // input pins
sc_out<sc_logic> o; // output pin o

void proc() { o = ~a; }

sensitive << a;


Link to post
Share on other sites



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.

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.



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.

Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...