Skip to content
Snippets Groups Projects
Commit 0894173c authored by Magnus Rentsch Ersdal's avatar Magnus Rentsch Ersdal
Browse files

beginning of parallel execution

parent 13a19779
No related branches found
No related tags found
No related merge requests found
"""
@author : magnus.ersdal@uib.no
"""
import fire
import multiprocessing as mp
import run_jtag_svf_programming as jp
def program_all_RUs(*cfgs):
jobs = []
for cfg in cfgs:
#run individual python exec.
p = mp.Process(target=jp.configure_PA3, args=(cfg,))
jobs.append(p)
p.start()
if __name__ == "__main__":
print("The input to this script is one or several configuration files")
fire.Fire(program_all_RUs)
"""
author = magnus.ersdal@uib.no
"""
import fire
def get_configuration_variables(filename):
#filename = "defaults.cfg"
with open(filename,'r') as cfgfile:
import sys
if sys.version_info >= (3,0):
# we are in python 3xx
import configparser as cp
config = cp.ConfigParser()
config.read_file(cfgfile)
else:
# python2 :(
print("Python 2. Upgrade required by 2020")
import ConfigParser as cp
config = cp.ConfigParser()
config.readfp(cfgfile)
# hardcoded option names, because we need the options to run the tool.
# more specifically, to initialize the Sca object.
sect = ['CRU']*2 + ['RU'] + ['FILE']
opt = ['id_card','board','gbt_ch','svf_filename']
variables = {}
print("cfg file read")
try:
for section, option in zip(sect,opt):
print(section,option, config.get(section,option))
variables[option] = config.get(section,option)
except (NameError, cp.NoOptionError) as e:
print("Name/NoOptionError !, name \'{}\' is not defined.\
Please check the config file".format(option))
print e.message
raise
print("cfg dict:")
print(variables)
return variables
if __name__ == '__main__':
fire.Fire(get_configuration_variables)
...@@ -69,6 +69,8 @@ def listof32s_append_tuplelist(liol,tuples): ...@@ -69,6 +69,8 @@ def listof32s_append_tuplelist(liol,tuples):
def listof32s_append_tuplelist_old(liol,tuples): def listof32s_append_tuplelist_old(liol,tuples):
"""make a list (liol) of 32 bit integers (implicit), from the explicit tuples [(number,binlength)]""" """make a list (liol) of 32 bit integers (implicit), from the explicit tuples [(number,binlength)]"""
# bug: accepts (0,0) and actually makes it into something :(
# lacking feature: reverse the int.
remn = 0 remn = 0
remlen = 0 remlen = 0
print(tuples) print(tuples)
......
[CRU]
# id card must be pcie id OR serial no.
id_card = 33554941
board = CRU
[RU]
gbt_ch = 0
[FILE]
svf_filename = idcode.svf
[JTAG]
# jtag chain configuration, don't touch.
hdrlen = 1
hirlen = 6
\ No newline at end of file
...@@ -3,4 +3,11 @@ requires from pip ...@@ -3,4 +3,11 @@ requires from pip
* pyzmq * pyzmq
* numpy * numpy
\ No newline at end of file
The purpose of this code is to program the ITS RU Microsemi ProAsic3 FPGA.
It communicates from a FLP/(a server) with the CRU card and libReadoutCard driver from O²
The IO is using the SCA.py read and write methods. This file is slightly modified from the original ITS version.
The driver communicates with the CRU FW. In the CRU FW there is a hardware HDLC wrapper that sends the data down the GBT links EC field.
\ No newline at end of file
"""
author = magnus.ersdal@uib.no
"""
from __future__ import print_function
print("start!")
import svf_intepreter as interpreter
from stopwatch import Stopwatch
from svf_separate_commands import read_svf
from hwdriver.SCA import Sca
import sys
from components.get_cfg import get_configuration_variables
# opt = ['id_card','board','gbt_ch','svf_filename']
def configure_PA3(cfgfile_name)
cfg = get_configuration_variables(cfgfile_name)
instruction_list = read_svf(cfg[svf_filename])
sw1 = Stopwatch()
sca = Sca(cfg[id_card], 2, cfg[gbt_ch], cfg[board])
try:
svf = interpreter.svfinterpreter(sca)
print("")
for vect in instruction_list:
svf.caller(vect)
remli = svf.end()
except KeyboardInterrupt:
print("----- C-C detected! -----")
finally:
sw1.stop()
...@@ -16,11 +16,11 @@ import jtag_if.jtag_ctrl ...@@ -16,11 +16,11 @@ import jtag_if.jtag_ctrl
# tap.state_change(state) # tap.state_change(state)
from svf_dictionary import tap_graph, valid_svf_end_states from svf_dictionary import tap_graph, valid_svf_end_states
from zmqsender_config import Errlvl #from zmqsender_config import Errlvl
import settings import settings
from memoize import Memoize from memoize import Memoize
from settings import jtg_tp #jtg_seq from settings import jtg_tp #jtg_seq
import numpy as np
#from jtag_if.jtag_ #from jtag_if.jtag_
#z = settings.z #z = settings.z
...@@ -30,7 +30,6 @@ def get_int_and_b_len(binstring): ...@@ -30,7 +30,6 @@ def get_int_and_b_len(binstring):
@Memoize @Memoize
def reverse_int(number, length): def reverse_int(number, length):
# return number # return number
#return int(np.binary_repr(number, length)[::-1],2)
return int(bin(number)[2:].rjust(length, '0')[::-1],2) return int(bin(number)[2:].rjust(length, '0')[::-1],2)
class jsignal(str): class jsignal(str):
...@@ -127,11 +126,6 @@ class bussequencer(): ...@@ -127,11 +126,6 @@ class bussequencer():
# list of tuples with (data,length) # list of tuples with (data,length)
tms_tuples= [(tms_start,tms_start_l),(0,(tdi_d_len-1)),(tms_end,tms_end_l)] tms_tuples= [(tms_start,tms_start_l),(0,(tdi_d_len-1)),(tms_end,tms_end_l)]
tdi_tuples= [(0,tms_start_l), tdi_d_a, tdi_d_b, tdi_d_c, (0,(tms_end_l-1))] tdi_tuples= [(0,tms_start_l), tdi_d_a, tdi_d_b, tdi_d_c, (0,(tms_end_l-1))]
#print("SIR")
#print("tms:")
#print(tms_tuples)
#print("tdi:")
#print(tdi_tuples)
deltal =sum([item[1] for item in tms_tuples]) - sum([item[1] for item in tdi_tuples]) deltal =sum([item[1] for item in tms_tuples]) - sum([item[1] for item in tdi_tuples])
try: try:
assert deltal == 0 assert deltal == 0
...@@ -271,14 +265,7 @@ class svfinterpreter(): ...@@ -271,14 +265,7 @@ class svfinterpreter():
assert False assert False
elif isinstance(arg, list): elif isinstance(arg, list):
for item in arg: for item in arg:
#print("item,item[0],converter item, lenght, signal:") bsequence = int(item[1], 16) #
#print(item, item[0], hex(int(item[1],16)) , length, sig)
# format into int. svf format is hex
bsequence = int(item[1], 16)#int(bin(int(item[1],16))[2:][::-1] ,2)# #
#print("parse of", item[1])
#bsequence = int(bin(int(item[1],16))[2:][::-1] ,2) # interpret and reverse binary number.
# bsequence = int(item[1],16) #'{0:0{length}b}'.format(int(item[1], 16), length=length)
# bsequence = reverse_int(bsequence, length)
self._data_sub_parse(item[0], bsequence, mode, sig, length=length) self._data_sub_parse(item[0], bsequence, mode, sig, length=length)
def dummy(self, arg=None): def dummy(self, arg=None):
......
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 26 23:43:04 2018
@author: Magnus Rentsch Ersdal (magnus.ersdal@uib.no)
"""
from __future__ import print_function
print("start!")
import svf_intepreter as interpreter
from stopwatch import Stopwatch
from svf_separate_commands import read_svf
from hwdriver.SCA import Sca
import pstats
#settings.init()
def space():
print("====================================================================")
def littlespace():
print("------")
def test():
listone = read_svf("program_pa3.svf") #("idcode.svf")#("../p_400klines.svf")#("../p_reduced.svf")
totlen = len(listone)
print("length of data list:",totlen)
if totlen < 20:
print(listone)
totpc = totlen / 100
if totpc < 1:
totpc = 1
sw1 = Stopwatch()
id_card = "33554941"
gbt_ch = 0
board = "CRU"
sca = Sca(id_card, 2, gbt_ch, board)
#def __init__(self, pcie_id, bar_ch, gbt_ch, board, debug=None,logger = None):
try:
i = 0
svf = interpreter.svfinterpreter(sca)
space()
for test in listone:
svf.caller(test)
i +=1
svf.end()
except KeyboardInterrupt:
print("----- C-C detected! -----")
finally:
sw1.stop()
print("ran {} tests".format(i))
def profile_test():
import cProfile
cProfile.run('test()', "profiledata")
if __name__== '__main__':
profile_test()
p = pstats.Stats('profiledata')
p.strip_dirs()
p.sort_stats('cumulative').print_stats(10)
p.sort_stats('tottime').print_stats(10)
[CRU]
# id card must be pcie id OR serial no.
id_card = 33554941
board = CRU
[RU]
gbt_ch = 0
[FILE]
svf_filename = idcode.svf
"""
author = magnus.ersdal@uib.no
"""
filename = "defaults.cfg"
with open(filename,'r') as cfgfile:
import sys
if sys.version_info >= (3,0):
# we are in python 3xx
import configparser as cp
config = cp.ConfigParser()
config.read_file(cfgfile)
else:
# python2 :(
print("Python 2. Upgrade required by 2020")
import ConfigParser as cp
config = cp.ConfigParser()
config.readfp(cfgfile)
sect = ['CRU']*2 + ['RU'] + ['FILE']
opt = ['id_card','board','gbt_ch','svf_filename']
variables = {}
#variables = {
#"id_card":"-1",
#"board":"-1",
#"gbt_ch":-1,
#"svf_filename":"-1"
#}
print("cfg file read")
try:
for section, option in zip(sect,opt):
print(section,option, config.get(section,option))
variables[option] = config.get(section,option)
except (NameError, cp.NoOptionError) as e:
print("Name/NoOptionError !, name \'{}\' is not defined.\
Please check the config file".format(option))
print e.message
raise
print("cfg dict:")
print(variables)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment