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

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