-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestrandparen.d
139 lines (107 loc) · 2.45 KB
/
testrandparen.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// 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;
class Foo
{
mixin randomization;
@rand int roo;
@rand ubyte pop;
constraint! q{
(roo > 0);
! (roo < 0 || ! (roo > 32));
} rooc;
}
class Bar: Foo
{
// mixin(_esdl__randomizable());
// private @rand!(16) ushort bob[];
mixin randomization;
private @rand ubyte bro;
@rand ubyte pun3 = 0;
@rand ubyte mom;
@rand ubyte sis;
@rand ULogic!18 pun1 = 0;
// @rand int pun1 = 0;
@rand ubyte pun2 = 0;
@rand ubyte bar;
byte foo = -10;
int* test;
void display() {
import std.stdio;
writeln("bro: ", bro, " sis: ", sis, " pop: ", pop, " mom: ", mom,
" foo: ", foo, " pun3: ", pun3, " pun1: ", pun1, " pun2: ", pun2,
" bar: ", bar);
}
void preRandomize() {
if(foo == 20) foo = 0;
else foo++;
}
// void post_randomize() {
// writeln("Post Randomize Called");
// }
int nobar = 4;
constraint! q{
// bar dist [1 := 4, 2 := 2, 6:8 :/ 3];
bar != nobar + 4;
foo /* + boo*/ + pop + mom == 64;
// pop % 3 == 0;
// foo + pop + mom == 64 ? pop > 40 : mom > 24;
(foo + pop + mom == 64 && pop > 40) || (foo + pop + mom != 64 && mom > 24);
mom > 8 || mom < 25;
pun1[11] == 0;
pun1[10] == 0;
pun1[9] == 0;
pun1[8] == 0;
@soft pun1[0..4] == 0;
// pun1[0:3] == 0;
pun1 >= 32;
} cst02;
constraint! q{
// this is a comment
foo + bro + sis + bar == 64;
pop > 40;
bro > 24;
bar != bro;
@soft bro < 80;
sis < 24;
if (pop >= 48) {
// bro == pop;
// if (sis <= 1) pun2 == mom + 5;
pun2 == 2;
}
else {
pun2 == 4;
}
// pop + kid3 == 24;
} cst01;
// constraint! q{
// foo > bar;
// foo == 0 || foo == 231243432;
// solve foo before bar;
// }
// constraint! q{
// pop1 + mom2 + kid3 > 64;
// pop + kid3 == 24;
// } cst1;
// constraint! q{
// pop < 64;
// mom == 1;
// kid == 4;
// } cst10;
}
void main() {
for (size_t j=0; j!=1; ++j) {
auto foo = new Bar;
foo.seedRandom(100);
for (size_t i=0; i!=100; ++i) {
foo.randomize();
foo.display();
}
}
import std.stdio;
writeln("DONE MAIN");
}