-
Notifications
You must be signed in to change notification settings - Fork 0
/
mem_class.sv
38 lines (37 loc) · 1.05 KB
/
mem_class.sv
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
// The mem_type should be converted into a class so that you can collect statistics of the instructions
package mem_package;
import instr_package::*;
typedef bit [15:0] uint16;
typedef uint16 mem_type;
typedef bit [3:0] nybble;
class mem_statistics;
int instr[nybble];
function new();
for(int i=0;i<15;i++) instr[i]=0;
endfunction
function void Incr(mem_type din);
nybble op;
op=din[15:12];
instr[op]++;
endfunction
function void Print();
$display("ADD %x iSUB %x iAND %x iOR %x iXOR %x iNOT %x MOV %x NOP %x LD %x ST %x LDI %x NU %x BRZ %x BRN %x BRO %x BRA",
instr[ADD],
instr[iSUB],
instr[iAND],
instr[iOR],
instr[iXOR],
instr[iNOT],
instr[MOV],
instr[NOP],
instr[LD],
instr[ST],
instr[LDI],
instr[NU],
instr[BRZ],
instr[BRN],
instr[BRO],
instr[BRA]);
endfunction
endclass
endpackage