Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomization of SystemC types > 64 bit not supported #4

Open
AnthonyVH opened this issue Jun 12, 2018 · 4 comments
Open

Randomization of SystemC types > 64 bit not supported #4

AnthonyVH opened this issue Jun 12, 2018 · 4 comments

Comments

@AnthonyVH
Copy link

AnthonyVH commented Jun 12, 2018

Creating an e.g. crave::randv<sc_dt::sc_bv<128>> object works fine. However, when next() is called on this object, only bits 0-63 will be set, the remaining ones will all be zero. This is hardcoded in SystemC.hpp's next function, where an std::int64 generator is used.

I'm not sure how difficult it would be to fix this. Extending the random number generation to generate enough random bits seems doable. Modifying generated constraints to be correct seems like a more difficult task.

Alternatively, construction of such objects could be prevented with some SFINAE, e.g.:

/* Boost is preferred/required over C++14 for compatibility with e.g. QuestaSim. */
template <int N, std::enable_if_t<N <= 64, int> = 0>
struct randv<sc_dt::sc_bv<N>> : public randv_base<sc_dt::sc_bv<N>> { /* etc */ };
@hoangmle
Copy link
Member

The main issue here is that ir/Constant uses uint64_t internally. Switching to boost::multiprecision::cpp_int should be enough and can be done with reasonable effort. The downside is that things get a bit slower when you do not use types > 64-bit. I will try this in my next free slot.

@AnthonyVH
Copy link
Author

That sounds very promising! This, the RAII, and the vector randomization issues are the only thing holding me back from proposing the use of CRAVE into all our future SysC testbench infrastructure, so I'm loving the quick responses to the issues I opened here 👍.

@hoangmle
Copy link
Member

I have added basic support for this in the branch experimental_bigint, you need to use the experimental API though. There is also a new example https://github.com/hoangmle/crave-examples/blob/experimental_bigint/experimental_api/ex12_bigint/main.cpp
Can you try it out to see whether it suits your need and what is still missing? Thanks!

@AnthonyVH
Copy link
Author

AnthonyVH commented Jun 27, 2018

Awesome! I've been a bit swamped by other things, but as soon as I find this for this again I'll take a look at it (and put together a PR for issue #5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants