Jump to content

Recommended Posts

Posted

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?

Posted
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

 

Posted

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

Posted
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

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.

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