-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan_input.py
More file actions
63 lines (59 loc) · 1.88 KB
/
scan_input.py
File metadata and controls
63 lines (59 loc) · 1.88 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
#version 2.0
import os
import sys
import time
import subprocess
import binascii
import math
# Check for the proper input format
if len(sys.argv) != 5 :
sys.stdout.write("Error : The correct format is python convert_tracefile_to_jtag_trace.py TRACEFILE.txt in.txt <no_of_inputs> <no_of_outputs> \n")
sys.exit(1)
else:
input_file = open(sys.argv[1],"r")
output_file = open(sys.argv[2],"w")
in_pins = int(sys.argv[3])
out_pins = int(sys.argv[4])
#output_file.write("Expected Output Received Output Remarks\n")
#output_file.write("============================================\n")
line = 1;
for comm in input_file.readlines():
# taking care of single-line comments
if comm[0] == '#': continue
comm = comm.replace('\n','')
comm = comm.replace('\r','')
#Display the command on screen
print ("line:",line,"-",comm,"")
line = line+1
command = comm.split(' ')
temp = int(command[0],2);
output_file.write("SDR ")
output_file.write(str(in_pins))
output_file.write(" TDI(")
output_file.write(hex(temp).upper()[2:].zfill(int(math.ceil((float(in_pins)/4)))));
output_file.write(") ")
output_file.write(str(out_pins))
temp = int(command[1],2);
output_file.write(" TDO(")
output_file.write(hex(temp).upper()[2:].zfill(int(math.ceil((float(out_pins)/4)))));
output_file.write(")")
temp = (command[2],2);
output_file.write(" MASK(")
temp1 = len(temp[0])
if temp1%4 == 0: temp1 = int(temp1/4)
else : temp1 = int(temp1/4) + 1
print (temp1)
if int(temp[0], 2) == 0 :
for i in range(temp1):
output_file.write(hex(0).upper()[2:]);
else :
#print int(temp)
#temp = temp/4 + 1
for i in range(temp1):
# print ""
output_file.write(hex(15).upper()[2:]);
output_file.write(")\n")
output_file.write("RUNTEST 1 MSEC\n")
print("----------------------------------------------------")
print("============Done============")
print("----------------------------------------------------")