-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestrandarr.d
77 lines (62 loc) · 1.2 KB
/
testrandarr.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
69
70
71
72
73
74
75
76
77
// Copyright: Coverify Systems Technology 2013 - 2014
// License: Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Authors: Puneet Goel <[email protected]>
import std.stdio;
import esdl;
int FFFF = 20;
class Foo
{
mixin randomization;
@rand(32) byte[] foo;
@rand ubyte baz = 12;
void display() {}
}
class Bar : Foo
{
mixin randomization;
@rand ubyte[8] bar;
override void display() {
writeln("foo: ", foo);
writeln("bar: ", bar);
writeln("baz: ", baz);
}
constraint! q{
foo.length > 12;
baz < 32;
// FFFF + baz == 50;
} cstFooLength;
constraint! q{
foreach(i, f; bar) f <= i;
// this is a comment
foreach(i, f; foo) {
if (i < 2) {
f < 24;
f >= 20;
}
else {
f < 8;
}
}
foreach(i, f; foo) {
f < 64;
f > 0;
}
} cstFoo;
void preRandomize() {
FFFF += 2;
}
void postRandomize() {
FFFF++;
}
}
void main() {
Bar foo = new Bar;
for (size_t i=0; i!=40; ++i) {
foo.randomize();
foo.display();
}
import std.stdio;
writeln("End of program");
}