-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestrandpackedstruct.d
68 lines (61 loc) · 1.09 KB
/
testrandpackedstruct.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import esdl.rand;
import esdl.data.packed;
import esdl.data.bvec;
struct Packed {
mixin packed!q{
@rand int x;
@rand ubvec!4 helo;
@rand ubvec!3 nohelo;
@rand bool yo;
};
// pragma(msg, (packed!q{
// @rand int x;
// @rand bvec!4 helo;
// @rand ubvec!3 nohelo;
// ubvec!1 yo;
// }));
}
struct Foo {
void pre_randomize() {
// import std.stdio;
// writeln("pre_randomize");
}
private @rand int frop;
public:
void display() {
import std.stdio;
writeln("frop is: ", frop);
}
}
class Bar {
mixin randomization;
@rand Foo foo;
@rand Packed pak;
void preRandomize() {
zoo++;
}
int zoo = 64;
constraint!q{
// pak.nohelo == 4;
pak.helo <= pak.nohelo;
foo.frop == zoo;
} frop_cst;
public:
void display() {
import std.stdio;
foo.display();
writeln("helo is: ", pak.helo);
writeln("nohelo is: ", pak.nohelo);
writeln("yo is: ", pak.yo);
writeln("helo is: ", pak);
}
}
void main()
{
Bar bar = new Bar();
for (size_t i=0; i!=20; ++i)
{
bar.randomize();
bar.display();
}
}