Newer
Older
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
##############################################################################
################ This file sets the tbench for the CIM up ####################
##############################################################################
import os, sys
import subprocess
import numpy as np
from create_C_header import create_header
from genRandomData import genRandomData
### Local variables ###
# // Hardware parameters
# CIM size
Nrows = 1152;
Ncols = 256;
# Image dimensions
Himg = 28;
Wimg = Himg;
# Target layer size
C_in = 1024;
C_out = 32;
# Target precision
r_in = 1;
r_w = 1;
r_out = 8;
# Timing config
T_DP = 2;
T_PRE = 2;
T_MBIT = 2;
T_ADC = 2;
# ABN vectors
r_beta = 5;
r_gamma = 8;
GAMMA_VEC = np.arange(1,r_gamma);
BETA_VEC = 2**np.arange(r_beta)-1;
# // Target data distributions & data
dist_in = 'normal';
dist_w = 'uniform';
Ndata = 50;
# // Path to output file
filename_h = "./outputs/cim_config.h";
filename_o = "./outputs/TF_DP_in.txt";
### Create data distributions ###
cim_info = (Nrows,Ncols,r_in,C_in,r_out,C_out);
dataVec = genRandomData(cim_info,dist_in,dist_w,Ndata);
### Generate test files ###
filename_vec = (filename_h,filename_o);
cim_dim = (Nrows,Ncols);
D_VEC = (Himg,Wimg,C_in,C_out);
P_VEC = (r_in,r_w,r_out,r_beta,r_gamma);
T_VEC = (T_DP,T_PRE,T_MBIT,T_ADC);
create_header(filename_vec,cim_dim,D_VEC,P_VEC,T_VEC,BETA_VEC,GAMMA_VEC,dataVec);
# // C header has been created, C file is ready for execution //
print("/// Done writing setup files, ready for flashing ///");