Maxim Vorontsov 0 Report post Posted February 22 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 Share this post Link to post Share on other sites
basarts 3 Report post Posted February 24 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 1 Maxim Vorontsov reacted to this Quote Share this post Link to post Share on other sites
Maxim Vorontsov 0 Report post Posted February 25 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 Share this post Link to post Share on other sites
basarts 3 Report post Posted February 25 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 1 Maxim Vorontsov reacted to this Quote Share this post Link to post Share on other sites
Maxim Vorontsov 0 Report post Posted February 25 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 Share this post Link to post Share on other sites
basarts 3 Report post Posted February 26 The release contains a file docs/scv/scvref/vwg_1_0e.pdf which (sort of) clarifies this. 1 Maxim Vorontsov reacted to this Quote Share this post Link to post Share on other sites
Maxim Vorontsov 0 Report post Posted February 26 Thank you Bas. Quote Share this post Link to post Share on other sites