-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCalDecoder.cpp
executable file
·69 lines (63 loc) · 2.26 KB
/
CalDecoder.cpp
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
#include"CalDecoder.h"
Cal_Decoder::Cal_Decoder(Technology tech,int functiontype,int xbarnum):INV_1IN(INV,NMOS,1,3*tech.featureSize,3*tech.featureSize,3*tech.featureSize,tech.featureSize*50,40+273.15,tech),NAND_2IN(NAND,NMOS,2,3*tech.featureSize,3*tech.featureSize,3*tech.featureSize,tech.featureSize*50,40+273,tech),NAND_3IN(NAND,NMOS,3,3*tech.featureSize,3*tech.featureSize,3*tech.featureSize,tech.featureSize*50,40+273.15,tech),NAND_4IN(NAND,NMOS,4,3*tech.featureSize,3*tech.featureSize,3*tech.featureSize,tech.featureSize*50,40+273.15,tech){
num_in = ceil(log((double)xbarnum)/log(2.0));
num_out = xbarnum;
temp1=num_in;
temp2=num_out;
function_type= functiontype;
}
Cal_Decoder::~Cal_Decoder(){}
double Cal_Decoder::Decoder_Area(int temp){
if(temp==2)
return 2*3*INV_1IN.Area()+4*NAND_2IN.Area();
else if(temp==3)
return 3*3*INV_1IN.Area()+8*NAND_3IN.Area();
else if(temp>3){
temp1=temp/2;
temp2=temp-temp1;
int num_temp1=1,num_temp2=1;//temp1,temp2所对应的的2^temp1,2^temp2的端口个数
for(int i=0;i<temp1;i++)
num_temp1=num_temp1*2;
for(int i=0;i<temp2;i++)
num_temp2=num_temp2*2;
return Decoder_Area(temp1)+Decoder_Area(temp2)+2*(num_temp1+num_temp2)*3*INV_1IN.Area()+num_out*NAND_2IN.Area();
}
else{ ///temp = 1
return 0;
}
}
double Cal_Decoder::Decoder_Latency(int temp){
if(temp==2)
return 3*INV_1IN.Latency()+NAND_2IN.Latency();
else if(temp==3)
return 3*INV_1IN.Latency()+NAND_3IN.Latency();
else if(temp>3){
temp1=temp/2;
temp2=temp-temp1;
return MAX(Decoder_Latency(temp1),Decoder_Latency(temp2));
}
else{ //temp = 1
return 0;
}
}
//double Cal_Decoder::Decoder_Power_Leakage(){
//};
double Cal_Decoder::Decoder_Power_Dynamic(int temp){
if(temp==2)
return 2*3*INV_1IN.Power_Dynamic()+4*NAND_2IN.Power_Dynamic();
else if(temp==3)
return 3*3*INV_1IN.Power_Dynamic()+8*NAND_3IN.Power_Dynamic();
else if(temp>3){
temp1=temp/2;
temp2=temp-temp1;
int num_temp1=1,num_temp2=1;//temp1,temp2所对应的的2^temp1,2^temp2的端口个数
for(int i=0;i<temp1;i++)
num_temp1=num_temp1*2;
for(int i=0;i<temp2;i++)
num_temp2=num_temp2*2;
return Decoder_Power_Dynamic(temp1)+Decoder_Power_Dynamic(temp2)+2*(num_temp1+num_temp2)*3*INV_1IN.Power_Dynamic()+num_out*NAND_2IN.Power_Dynamic();
}
else{
return 0;
}
};