item(rand_obj* parent = 0) : rand_obj(parent), src_addr(this), dest_addr(this), data(this), x(this), y(this), z(this) { constraint(dist(src_addr(), distribution<uint>::simple_range(0, 0xFE))); constraint(dest_addr() <= src_addr()); constraint("neg_data", -16 < data() && data() < 0); constraint("pos_data", 16 > data() && data() > 0); constraint(bitslice(10, 3, x()) == 0xFF); constraint(x() > 123456); constraint((y() ^ 0x7FFF) == 0); constraint((z() >> 4) == 0x000F); }
item(rand_obj* parent = 0) : rand_obj(parent), src_addr(this), dest_addr(this) { constraint(dist(src_addr(), distribution<unsigned>::create(range<unsigned>(0, 9))(range<unsigned>(90, 99)))); constraint(dist(dest_addr(), distribution<unsigned>::create(weighted_range<unsigned>(0, 9, 60))( weighted_range<unsigned>(10, 19, 30))(weighted_range<unsigned>(100, 109, 10)))); }
using crave::crv_object_name; using crave::reference; using crave::distribution; using crave::dist; using crave::bitslice; class item : public crv_sequence_item { public: crv_variable<unsigned> src_addr; crv_variable<unsigned> dest_addr; crv_variable<short> data; crv_variable<int> x; crv_variable<short> y, z; crv_constraint c_addr_constraints{ dist(src_addr(), distribution<unsigned>::simple_range(0, 0xFE)), dest_addr() <= src_addr() }; crv_constraint c_neg_data{ -16 < data(), data() < 0 }; crv_constraint c_pos_data{ 16 > data(), data() > 0 }; crv_constraint c_x_constraints{ bitslice(10, 3, x()) == 0xFF, x() > 123456 }; crv_constraint c_y_constraints{(y() ^ 0x7FFF) == 0 }; crv_constraint c_z_constraints{(z() >> 4) == 0x000F }; item(crv_object_name) {} friend ostream& operator<<(ostream& os, item& it) { os << it.src_addr << " " << it.dest_addr << " " << it.data << " " << it.x << " " << it.y << " " << it.z; return os; } };