mirror of https://github.com/openXC7/prjxray.git
roi_harness: fix formatting
Signed-off-by: John McMaster <johndmcmaster@gmail.com>
This commit is contained in:
parent
12516c53fb
commit
8da9f4f572
|
|
@ -4,28 +4,39 @@ import subprocess
|
|||
import demo_sw_led_fasm
|
||||
import os
|
||||
|
||||
|
||||
def run(roi_dir, swn, ledn):
|
||||
design_txt_fn = roi_dir + '/design.txt'
|
||||
bit_ref_fn = roi_dir + '/design.bit'
|
||||
fasm_fn = 'demo_sw_led.fasm'
|
||||
bit_out_fn = 'demo_sw_led.bit'
|
||||
ocd_cfg = os.getenv('XRAY_DIR') + '/utils/openocd/board-digilent-basys3.cfg'
|
||||
ocd_cfg = os.getenv(
|
||||
'XRAY_DIR') + '/utils/openocd/board-digilent-basys3.cfg'
|
||||
|
||||
# Clean up old tmp files to be sure we are generating them fresh
|
||||
subprocess.call('rm -f %s %s' % (fasm_fn, bit_out_fn), shell=True)
|
||||
|
||||
# subprocess.shell("python3 demo_sw_led.py out_xc7a35tcpg236-1_BASYS3-SWBUT_roi_basev/design.txt 0 0 demo.fasm")
|
||||
demo_sw_led_fasm.run(open(design_txt_fn, 'r'), swn, ledn, open(fasm_fn, 'w'))
|
||||
subprocess.check_call("./fasm2bit.sh %s %s %s" % (fasm_fn, bit_ref_fn , bit_out_fn), shell=True)
|
||||
subprocess.check_call('openocd -f %s -c "init; pld load 0 %s; exit"' % (ocd_cfg, bit_out_fn), shell=True)
|
||||
demo_sw_led_fasm.run(
|
||||
open(design_txt_fn, 'r'), swn, ledn, open(fasm_fn, 'w'))
|
||||
subprocess.check_call(
|
||||
"./fasm2bit.sh %s %s %s" % (fasm_fn, bit_ref_fn, bit_out_fn),
|
||||
shell=True)
|
||||
subprocess.check_call(
|
||||
'openocd -f %s -c "init; pld load 0 %s; exit"' % (ocd_cfg, bit_out_fn),
|
||||
shell=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Basys3 switch to LED interconnect demo. Compiles and programs')
|
||||
parser.add_argument('roi_dir', help='ROI project dir for harness .bit and metadata.txt')
|
||||
parser = argparse.ArgumentParser(
|
||||
description=
|
||||
'Basys3 switch to LED interconnect demo. Compiles and programs')
|
||||
parser.add_argument(
|
||||
'roi_dir', help='ROI project dir for harness .bit and metadata.txt')
|
||||
parser.add_argument('sw', type=int, help='Switch to use')
|
||||
parser.add_argument('led', type=int, help='LED to use')
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
run(args.roi_dir, args.sw, args.led)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import simpleroute
|
|||
print()
|
||||
print('ready')
|
||||
|
||||
|
||||
def load_design(f):
|
||||
'''
|
||||
name node pin wire
|
||||
|
|
@ -18,10 +19,11 @@ def load_design(f):
|
|||
f.readline()
|
||||
for l in f:
|
||||
l = l.strip()
|
||||
name,node,pin,wire = l.split(' ')
|
||||
name, node, pin, wire = l.split(' ')
|
||||
ret[name] = wire
|
||||
return ret
|
||||
|
||||
|
||||
def route2fasm(route, out_f):
|
||||
pips = simpleroute.route(route)
|
||||
for pip in pips:
|
||||
|
|
@ -32,26 +34,32 @@ def route2fasm(route, out_f):
|
|||
pip = pip[0:doti] + ' ' + pip[doti + 1:]
|
||||
out_f.write(pip + '\n')
|
||||
|
||||
|
||||
def run(design_f, swn, ledn, out_f):
|
||||
name2wire = load_design(design_f)
|
||||
led_name = 'dout[%d]' % ledn
|
||||
sw_name = 'din[%d]' % swn
|
||||
led_wire = name2wire[led_name]
|
||||
sw_wire = name2wire[sw_name]
|
||||
print('Routing %s (%s) => %s (%s)' % (sw_wire, sw_name, led_wire, led_name))
|
||||
print(
|
||||
'Routing %s (%s) => %s (%s)' % (sw_wire, sw_name, led_wire, led_name))
|
||||
|
||||
route2fasm((sw_wire, led_wire), out_f)
|
||||
# XXX: terminate LEDs so they are off?
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Switch to LED interconnect demo: FASM generator')
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Switch to LED interconnect demo: FASM generator')
|
||||
parser.add_argument('design_txt', help='ROI metadata file')
|
||||
parser.add_argument('sw', type=int, help='Switch to use')
|
||||
parser.add_argument('led', type=int, help='LED to use')
|
||||
# For now can't use stdout since simpleroute is spewing out prints
|
||||
parser.add_argument('out_fasm', help='Output .fasm file')
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
run(open(args.design_txt, 'r'), args.sw, args.led, open(args.out_fasm, 'w'))
|
||||
run(
|
||||
open(args.design_txt, 'r'), args.sw, args.led, open(
|
||||
args.out_fasm, 'w'))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import unittest
|
||||
import demo_sw_led
|
||||
|
||||
|
||||
class TestStringMethods(unittest.TestCase):
|
||||
def test_all(self):
|
||||
for i in range(8):
|
||||
|
|
@ -12,5 +13,6 @@ class TestStringMethods(unittest.TestCase):
|
|||
print(i)
|
||||
demo_sw_led.run('out_xc7a35tcpg236-1_BASYS3-SWBUT_roi_basev', i, i)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -119,7 +119,8 @@ def route(args):
|
|||
try:
|
||||
write_scores(set([dst_node]), 1)
|
||||
except RecursionError as e:
|
||||
raise Exception("Could not find route for node %s" % (dst_node,)) from None
|
||||
raise Exception("Could not find route for node %s" %
|
||||
(dst_node, )) from None
|
||||
print(" route length: %d" % node_scores[src_node])
|
||||
|
||||
count = 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue