-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhl_inputs.py
executable file
·140 lines (106 loc) · 4.86 KB
/
hl_inputs.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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#! /usr/bin/python3.5
################################################################################
# @Author: Corteggiani Nassim <Corteggiani> #
# @Email: [email protected] #
# @Filename: hl_inputs.py #
# @Last modified by: Corteggiani #
# @Last modified time: 23-Mar-2017 #
# @License: GPLv3 #
# #
# Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. #
# Copyright (C) 2017 Corteggiani Nassim <Corteggiani> #
# #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# #
################################################################################
import random
import binascii
import os
import subprocess
import time
from collections import OrderedDict
import collections
#TODO : the path should be passed as command-line argument !
PATH = "/home/enoname/Tools/altera/13.1/modelsim_ase/linux"
PATH2 = "/home/noname/Projects/usb3-low-latency-debug/jtag/superspeed-jtag/Debug"
def start_inception():
pipe = -1
print("[Inception]")
print(" starting...")
# with open(os.devnull, "w") as fnull:
pipe = subprocess.Popen([PATH2+"/inception", "--debug2"])
print(" Inception communication in progress...")
time.sleep(3)
print(" Inception communication successfully done...")
print(" closing inception...")
pipe.kill()
def start_simu():
err = None
out = None
pid = -1
print("[Simulator]")
print(" starting...")
pipe = subprocess.Popen([PATH+"/vsim", "-c", "-do", "cd "+PATH+"/../bin/inception/build/ms ; do ../../scripts/sim.do; quit"])
print(" simulation in progress...")
time.sleep(10)
print(" simulation successfully done...")
print(" closing simulator...")
pipe.kill()
def set_inputs(input):
f = open(PATH+"/../bin/inception/io/input.txt", "w")
if isinstance(input, list):
for line in input:
f.write(str(line)+'\n')
else:
f.write(input+'\n')
f.close()
# def move_outputs():
#
# source = PATH+"/../bin/inception/io/output.txt"
# dest = PATH2+"/input.txt"
#
# pipe = subprocess.Popen(["mv", source, dest])
# pipe.kill()
if __name__== "__main__":
HL_COMMANDS = ([('RESET', 0x30000000), ('READ', 0x24000001), ('WRITE', 0x14000001)])
# {
# "RESET" : 0x30000000,
# "READ" : 0x24000001,
# "WRITE" : 0x14000001,
# }
commands = []
HL_COMMANDS = collections.OrderedDict(HL_COMMANDS)
print(HL_COMMANDS)
for item in HL_COMMANDS:
print("[Test]\n\ttesting command "+item)
data_rw = None
commands.append("{0:0{1}x}".format(HL_COMMANDS[item], 8))
address = random.randint(0x10000000, 0x20000000)
print("\tCommand : "+format(HL_COMMANDS[item], 'x'))
print("\tAddress : "+"{0:0{1}x}".format(address, 8))
if item == "WRITE" :
#Data to be write if needed
data_rw = random.randint(1, 32)
commands.append("{0:0{1}x}".format(address, 8))
commands.append("{0:0{1}x}".format(data_rw, 8))
print("\tData : "+"{0:0{1}x}".format(data_rw, 8))
elif item == "READ" :
commands.append("{0:0{1}x}".format(address, 8))
elif item == "RESET" :
commands.append("{0:0{1}x}".format(address, 8))
set_inputs(commands)
start_simu()
print("[Waiting] ....")
time.sleep(3)
start_inception()