-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathinso_inst.py
43 lines (40 loc) · 1.53 KB
/
inso_inst.py
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
import argparse
import os
import sys
import copy
import pickle
import _thread
from inso_lib import *
from inso_utils import *
__author__ = 'insomnia.px'
class inst(object):
def __init__(self, name, att, power_lib):
self.name = name
self.att = att
self.inst_tpye = power_lib.cls
self.power = power_lib.get_power(att)
self.busy_cycles = 0
self.E = 0
def rst(self):
self.busy_cycles = 0
self.E = 0
def get_cycles_mem(self, num_dt, prec1, glb_freq, static_cycles=0):
assert (self.inst_tpye=='memory')
assert (isinstance(static_cycles, int))
pw = str_tran(self.att['pw']).val
freq = str_tran(self.att['freq']).val
cycles_each = int(glb_freq/freq)
return int(div_up(num_dt * prec1.bits, pw ) * cycles_each) + static_cycles
def get_cycles_dp(self, num_dt, prec1, glb_freq, static_cycles=0):
assert (isinstance(static_cycles, int))
pw = str_tran(self.att['pw']).val
freq = str_tran(self.att['freq']).val
burst_len = str_tran(self.att['burst_len']).val
cycles_each = int(glb_freq/freq)
return int(div_up(num_dt * prec1.bits, pw) * cycles_each + static_cycles * div_up(num_dt * prec1.bits, pw * burst_len) )
def get_cycles_comp(self, glb_freq, comp=1, static_cycles=0):
assert (isinstance(static_cycles,int))
assert (isinstance(comp, int))
freq = str_tran(self.att['freq']).val
cycles_each = int(glb_freq/freq)
return int(comp* cycles_each) + static_cycles