Maxim Vorontsov Posted February 22, 2019 Report Posted February 22, 2019 Dear accellera community, I'm trying to assign randomization constraint to a bit range: tb.cpp: #include "systemc.h" #include "scv.h" // // struct addr_rnd : public scv_constraint_base { scv_smart_ptr<sc_uint<32>> addr; SCV_CONSTRAINT_CTOR(addr_rnd) { SCV_CONSTRAINT( addr().range(1,0) == 0 ); } }; // int sc_main(int argc, char * argv[]) { // // addr_rnd addr("addr"); addr.next(); // // return 0; } g++ -lsystemc -lscv -std=gnu++17 tb.cpp And I get the following error: In file included from /home/mvorontsov/include/scv.h:50:0, from tb.cpp:2: tb.cpp: In member function 'void addr_rnd::init_core()': tb.cpp:8:26: error: 'class scv_expression' has no member named 'range' SCV_CONSTRAINT( addr().range(1,0) == 0 ); ^ /home/mvorontsov/include/scv/scv_constraint.h:821:38: note: in definition of macro 'SCV_CONSTRAINT' #define SCV_CONSTRAINT(expr) eh() &= expr; Would you please advise me what i am doing wrong? Quote
Bas Arts Posted February 24, 2019 Report Posted February 24, 2019 Hi Maxim, "addr" is a pointer, so you need to access its fields and methods by using operator-> : SCV_CONSTRAINT(addr->range(1,0) == 0); -- greetz, Bas Maxim Vorontsov 1 Quote
Maxim Vorontsov Posted February 25, 2019 Author Report Posted February 25, 2019 On 2/24/2019 at 11:37 AM, basarts said: Hi Maxim, "addr" is a pointer, so you need to access its fields and methods by using operator-> : SCV_CONSTRAINT(addr->range(1,0) == 0); -- greetz, Bas Thanks basarts, I indeed got rid of compilation error, but there is simulation runtime error: tb.cpp: #include "systemc.h" #include "scv.h" // // struct aaa { sc_uint<32> addr; }; // struct addr_rnd : public scv_constraint_base { scv_smart_ptr<sc_uint<32>> addr; SCV_CONSTRAINT_CTOR(addr_rnd) { SCV_CONSTRAINT( addr->range(1,0) == 0 ); } }; // int sc_main(int argc, char * argv[]) { // // addr_rnd addr("addr"); addr.next(); // // return 0; } $ g++ -lsystemc -lscv -std=gnu++17 tb.cpp $ ./a.out SystemC 2.3.3-Accellera --- Dec 20 2018 16:31:31 Copyright (c) 1996-2018 by all Contributors, ALL RIGHTS RESERVED Error: CONSTRAINT_ERROR_OVER_CONSTRAINED: Constraints for over-constrained object 'addr' will be ignored. In file: unknown:0 Quote
Bas Arts Posted February 25, 2019 Report Posted February 25, 2019 Hi Maxim, After reading some SCV documentation, it looks like we're not allowed to use smart pointers in your preferred way. E.g. we need to use "addr()" (without specific member functions like "range(int, int)") as a basis for building the expression we are using in a later stage. In your case, a practical solution would be to have no constraint on the generated address but to mask the 2 LSB after generation. -- greetz, Bas Maxim Vorontsov 1 Quote
Maxim Vorontsov Posted February 25, 2019 Author Report Posted February 25, 2019 2 hours ago, basarts said: In your case, a practical solution would be to have no constraint on the generated address but to mask the 2 LSB after generation. Yes, that's exactly how I'm workarounding it now. Would you please narrow me, where this derived from SCV documentation, to I might look for the limitations in the future? Because I've been looking into scv headers and that was not really clear. Thanks Quote
Bas Arts Posted February 26, 2019 Report Posted February 26, 2019 The release contains a file docs/scv/scvref/vwg_1_0e.pdf which (sort of) clarifies this. Maxim Vorontsov 1 Quote
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.