From 5767eae83f9825bba59adb98b198c8d70a015572 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 23 Mar 2018 14:20:15 +0000 Subject: [PATCH] move interface and pinmux definition to test directory --- src/interface_decl.py | 19 ++++++++++++++----- src/pinmux_generator.py | 2 +- interfaces.txt => test/interfaces.txt | 0 jtag.txt => test/jtag.txt | 0 pinmap.txt => test/pinmap.txt | 0 pwm.txt => test/pwm.txt | 0 sd.txt => test/sd.txt | 0 spi.txt => test/spi.txt | 0 twi.txt => test/twi.txt | 0 uart.txt => test/uart.txt | 0 10 files changed, 15 insertions(+), 6 deletions(-) rename interfaces.txt => test/interfaces.txt (100%) rename jtag.txt => test/jtag.txt (100%) rename pinmap.txt => test/pinmap.txt (100%) rename pwm.txt => test/pwm.txt (100%) rename sd.txt => test/sd.txt (100%) rename spi.txt => test/spi.txt (100%) rename twi.txt => test/twi.txt (100%) rename uart.txt => test/uart.txt (100%) diff --git a/src/interface_decl.py b/src/interface_decl.py index 81fcb56..51e56b2 100644 --- a/src/interface_decl.py +++ b/src/interface_decl.py @@ -1,3 +1,5 @@ +import os.path + from UserDict import UserDict from wire_def import generic_io # special case @@ -185,16 +187,20 @@ class Interfaces(UserDict): """ contains a list of interface definitions """ - def __init__(self): + def __init__(self, pth): + self.pth = pth self.ifacecount = [] UserDict.__init__(self, {}) - with open('interfaces.txt', 'r') as ifile: + ift = 'interfaces.txt' + if pth: + ift = os.path.join(pth, ift) + with open(ift, 'r') as ifile: for ln in ifile.readlines(): ln = ln.strip() ln = ln.split("\t") name = ln[0] count = int(ln[1]) - spec = self.read_spec(name) + spec = self.read_spec(pth, name) self.ifaceadd(name, count, Interface(name, spec)) def ifaceadd(self, name, count, iface, at=None): @@ -203,9 +209,12 @@ class Interfaces(UserDict): self.ifacecount.insert(at, (name, count)) self[name] = iface - def read_spec(self, name): + def read_spec(self, pth, name): spec = [] - with open('%s.txt' % name, 'r') as sfile: + fname = '%s.txt' % name + if pth: + ift = os.path.join(pth, fname) + with open(ift, 'r') as sfile: for ln in sfile.readlines(): ln = ln.strip() ln = ln.split("\t") diff --git a/src/pinmux_generator.py b/src/pinmux_generator.py index cefc77d..e8d629d 100644 --- a/src/pinmux_generator.py +++ b/src/pinmux_generator.py @@ -65,7 +65,7 @@ def pinmuxgen(pth=None, verify=True): p = Parse(pth, verify) init(p) - ifaces = Interfaces() + ifaces = Interfaces(pth) ifaces.ifaceadd('io', p.N_IO, io_interface, 0) bp = 'bsv_src' diff --git a/interfaces.txt b/test/interfaces.txt similarity index 100% rename from interfaces.txt rename to test/interfaces.txt diff --git a/jtag.txt b/test/jtag.txt similarity index 100% rename from jtag.txt rename to test/jtag.txt diff --git a/pinmap.txt b/test/pinmap.txt similarity index 100% rename from pinmap.txt rename to test/pinmap.txt diff --git a/pwm.txt b/test/pwm.txt similarity index 100% rename from pwm.txt rename to test/pwm.txt diff --git a/sd.txt b/test/sd.txt similarity index 100% rename from sd.txt rename to test/sd.txt diff --git a/spi.txt b/test/spi.txt similarity index 100% rename from spi.txt rename to test/spi.txt diff --git a/twi.txt b/test/twi.txt similarity index 100% rename from twi.txt rename to test/twi.txt diff --git a/uart.txt b/test/uart.txt similarity index 100% rename from uart.txt rename to test/uart.txt -- 2.30.2