-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransaction.sv
More file actions
107 lines (85 loc) · 2.51 KB
/
transaction.sv
File metadata and controls
107 lines (85 loc) · 2.51 KB
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
typedef enum
{
PRINTABLE_ASCII, UPPER_CASE, LOWER_CASE, PROBABILITY,ANY
}
control_t;
class transaction #(parameter DEPTH=32, parameter WIDTH=8);
// rand bit [ $clog2(DEPTH)-1:0 ] addr;
// rand bit [ WIDTH-1:0 ] data;
control_t ctrl;
//-----------mem_interface_signals-------------//
rand logic read;
rand logic write;
rand logic [$clog2(DEPTH)-1:0] addr;
rand logic [WIDTH-1:0] data_in; // data_in TO memory
logic [WIDTH-1:0] data_out; // data_in FROM memory
//--------------------------------------------//
function void display();
if(write) $display("\nWrite Trans | Data_in: %0c | Addr:%0d\n", data_in, addr);
else $display("Read Trans | Addr:%0d", addr);
endfunction
constraint read_write{
read&&write !=0;
}
constraint read_write_range{
read inside {1,0};
write inside {1,0};
}
covergroup cover_alpha;
// option.per_instance = 1;
a: coverpoint addr;
d: coverpoint data_in {
bins upper={[8'h41:8'h5a]};
bins lower={[8'h61:8'h7a]};
bins other= default;
}
endgroup : cover_alpha
// cover_alpha cg;
// constraint printable_ascii {
// data_in inside {
// [8'h20 : 8'h7F]
// };
// }
// constraint ascii_alphabet {
// data_in inside {
// [8'h41:8'h5a], [8'h61:8'h7a]
// };
// }
// constraint ascii_weightage {
// data_in dist {
// [8'h41:8'h5a]:/80, [8'h61:8'h7a]:/20
// };
// }
// constraint not_ascii_weightage {
// (
// data_in inside {
// [8'h41:8'h5a], [8'h61:8'h7a]
// }
// );
// }
constraint control_knob {
ctrl== PRINTABLE_ASCII -> data_in inside {
[8'h20 : 8'h7F]
};
ctrl== UPPER_CASE -> data_in inside {
[8'h41:8'h5a]
};
ctrl== LOWER_CASE -> data_in inside {
[8'h61:8'h7a]
};
ctrl== PROBABILITY -> data_in dist {
[8'h41:8'h5a]:/80, [8'h61:8'h7a]:/20
};
ctrl== ANY -> data_in inside{[0: (2**WIDTH)-1] };
}
// constraint read_after_write{
// write=>read
// }
function new(int data_in=0, int data_out=0, int addr=0, control_t ctrl=4);
this.data_in= data_in;
this.data_out= data_out;
this.addr=addr;
this.ctrl= ctrl;
cover_alpha=new();
endfunction
endclass