jsmith125x Posted January 20, 2014 Report Share Posted January 20, 2014 Hi, How to implement a simple not gate with sc_logic type inputs? The ! operator is not defined for this type. Quote Link to comment Share on other sites More sharing options...
Hans64 Posted January 20, 2014 Report Share Posted January 20, 2014 Use the bitwise operator ~ Hans. Quote Link to comment Share on other sites More sharing options...
jsmith125x Posted January 20, 2014 Author Report Share Posted January 20, 2014 I have got error message for ~ operator too. Quote Link to comment Share on other sites More sharing options...
Hans64 Posted January 20, 2014 Report Share Posted January 20, 2014 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. Quote Link to comment Share on other sites More sharing options...
jsmith125x Posted January 20, 2014 Author Report Share Posted January 20, 2014 ...\\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 Quote Link to comment Share on other sites More sharing options...
Hans64 Posted January 20, 2014 Report Share Posted January 20, 2014 Try: void proc() { o.write(~a.read()); } Hans. Quote Link to comment Share on other sites More sharing options...
manikanta.mashetti Posted January 20, 2014 Report Share Posted January 20, 2014 Use internal variable of type logic in the proc copy the input value in to this variable then invert variable and assign to the output port. Quote Link to comment Share on other sites More sharing options...
agrawalyogesh04 Posted January 21, 2014 Report Share Posted January 21, 2014 Following piece of code should work. void proc() { bool tmp; tmp = a.read(); o.write(~tmp); } Quote Link to comment Share on other sites More sharing options...
dakupoto Posted January 21, 2014 Report Share Posted January 21, 2014 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. Quote Link to comment Share on other sites More sharing options...
Hans64 Posted January 21, 2014 Report Share Posted January 21, 2014 ~ 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. Quote Link to comment Share on other sites More sharing options...
dakupoto Posted January 22, 2014 Report Share Posted January 22, 2014 ~ 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. 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.