-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryTransaction.sv
More file actions
190 lines (161 loc) · 4.21 KB
/
MemoryTransaction.sv
File metadata and controls
190 lines (161 loc) · 4.21 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
class MemoryTransaction;
time timestamp; //Monitor will fill in this value
// ID members
int id;
//This Bit is an Empty Transaction Generated by the Scoreboard to
// tell the checker to compare the ScoreBoard State with
bit EndOfInstructionCycle;
bit [15:0] Address;
rand bit [15:0] DataOut;
bit [15:0] DataIn;
bit we;
bit en; //Distinguish between MIO Read and Memory Read
bit isInstr;
//Reset Signal
rand bit rst;
//Interrupt Signal
rand bit IRQ;
rand bit [7:0] INTV;
rand bit [2:0] INTP;
rand int reset_cycles;
//Memory Mapped I/O Signals
rand bit [15:0] MemoryMappedIO_in;
bit MemoryMappedIO_out;
bit MemoryMappedIO_load;
//Machine Control Register
rand bit [15:0] MCR;
//Change these later... if necessary
constraint c_mcr { MCR==16'h8000; }
constraint c_rst {
rst dist {0:/90, 1:/10 };
}
constraint r_cyc { reset_cycles inside {[1:9]}; }
constraint c_irq {
(rst == 1) -> (IRQ == 0);
(rst == 1) -> (INTV == 0);
(rst == 1) -> (INTP == 0);
IRQ dist {0:/70, 1:/30 };
}
function MemoryTransaction copy(int i);
copy = new();
copy.timestamp = timestamp;
copy.id = i;
copy.EndOfInstructionCycle = EndOfInstructionCycle;
copy.Address = Address;
copy.DataOut = DataOut;
copy.DataIn = DataIn;
copy.we = we;
copy.en = en;
copy.isInstr = isInstr;
copy.rst = rst;
copy.IRQ = IRQ;
copy.INTV = INTV;
copy.INTP = INTP;
copy.reset_cycles = reset_cycles;
copy.MemoryMappedIO_in = MemoryMappedIO_in;
copy.MemoryMappedIO_out = MemoryMappedIO_out;
copy.MemoryMappedIO_load = MemoryMappedIO_load;
copy.MCR = MCR;
endfunction
//Instruction Helper Functions
function int ID();
return id;
endfunction
//Instruction Helper Functions
function bit [3:0] Opcode();
if(Address>=16'hfe00)
return MemoryMappedIO_in[15:12];
else
return DataOut[15:12];
endfunction // Opcode
function bit [2:0] Imm();
if(Address>=16'hfe00)
return MemoryMappedIO_in[5];
else
return DataOut[5];
endfunction // DR
function bit [2:0] JSRR();
if(Address>=16'hfe00)
return MemoryMappedIO_in[11];
else
return DataOut[11];
endfunction // DR
function bit [2:0] DR();
if(Address>=16'hfe00)
return MemoryMappedIO_in[11:9];
else
return DataOut[11:9];
endfunction // DR
function bit [2:0] SR1();
if(Address>=16'hfe00)
return MemoryMappedIO_in[8:6];
else
return DataOut[8:6];
endfunction // SR1
function bit [2:0] SR2();
if(Address>=16'hfe00)
return MemoryMappedIO_in[2:0];
else
return DataOut[2:0];
endfunction // SR2
function bit [2:0] SR();
if(Address>=16'hfe00)
return MemoryMappedIO_in[11:9];
else
return DataOut[11:9];
endfunction // SR
function bit [2:0] BaseR();
if(Address>=16'hfe00)
return MemoryMappedIO_in[8:6];
else
return DataOut[8:6];
endfunction // BaseR
function bit [4:0] imm5();
if(Address>=16'hfe00)
return MemoryMappedIO_in[4:0];
else
return DataOut[4:0];
endfunction // imm5
function bit [5:0] offset6();
if(Address>=16'hfe00)
return MemoryMappedIO_in[5:0];
else
return DataOut[5:0];
endfunction // offset6
function bit [7:0] trapvect8();
if(Address>=16'hfe00)
return MemoryMappedIO_in[7:0];
else
return DataOut[7:0];
endfunction // trapvect8
function bit [8:0] PCoffset9();
if(Address>=16'hfe00)
return MemoryMappedIO_in[8:0];
else
return DataOut[8:0];
endfunction // PCoffset9
function bit [10:0] PCoffset11();
if(Address>=16'hfe00)
return MemoryMappedIO_in[10:0];
else
return DataOut[10:0];
endfunction // PCoffset11
function bit n();
if(Address>=16'hfe00)
return MemoryMappedIO_in[11];
else
return DataOut[11];
endfunction // n
function bit z();
if(Address>=16'hfe00)
return MemoryMappedIO_in[10];
else
return DataOut[10];
endfunction // z
function bit p();
if(Address>=16'hfe00)
return MemoryMappedIO_in[9];
else
return DataOut[9];
endfunction // p
endclass // MemoryTransaction