move interface and pinmux definition to test directory
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 23 Mar 2018 14:20:15 +0000 (14:20 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 23 Mar 2018 14:20:15 +0000 (14:20 +0000)
18 files changed:
interfaces.txt [deleted file]
jtag.txt [deleted file]
pinmap.txt [deleted file]
pwm.txt [deleted file]
sd.txt [deleted file]
spi.txt [deleted file]
src/interface_decl.py
src/pinmux_generator.py
test/interfaces.txt [new file with mode: 0644]
test/jtag.txt [new file with mode: 0644]
test/pinmap.txt [new file with mode: 0644]
test/pwm.txt [new file with mode: 0644]
test/sd.txt [new file with mode: 0644]
test/spi.txt [new file with mode: 0644]
test/twi.txt [new file with mode: 0644]
test/uart.txt [new file with mode: 0644]
twi.txt [deleted file]
uart.txt [deleted file]

diff --git a/interfaces.txt b/interfaces.txt
deleted file mode 100644 (file)
index 5a1a4e2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-uart   4
-spi    1
-twi    2
-sd     2
-jtag   2
-pwm    1
diff --git a/jtag.txt b/jtag.txt
deleted file mode 100644 (file)
index 494fbd2..0000000
--- a/jtag.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-tdi    in
-tms    in
-tclk   in
-trst   in
-tdo    out
diff --git a/pinmap.txt b/pinmap.txt
deleted file mode 100644 (file)
index f2fbccb..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-muxed
-0              uart0_tx        spi0_sclk               uart2_tx        uart3_tx
-1              uart0_rx        spi0_mosi               uart2_rx        uart3_rx
-2              twi0_sda        spi0_ss   
-3              twi0_scl        spi0_miso
-8   sd0_clk   sd1_clk
-9   sd0_cmd   sd1_cmd
-10  sd0_d0    sd1_d0
-11  sd0_d1    sd1_d1
-12  sd0_d2    sd1_d2
-13  sd0_d3    sd1_d3    pwm0_pwm
-dedicated
-4              uart1_tx
-5              uart1_rx
-6              twi1_sda
-7              twi1_scl
-14   jtag0_tclk
-15   jtag0_tdo
-16  jtag0_tdi
-17  jtag0_tms
-18  jtag0_tdo
diff --git a/pwm.txt b/pwm.txt
deleted file mode 100644 (file)
index 76b0c8b..0000000
--- a/pwm.txt
+++ /dev/null
@@ -1 +0,0 @@
-pwm    out
diff --git a/sd.txt b/sd.txt
deleted file mode 100644 (file)
index 4096e06..0000000
--- a/sd.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-clk    out
-cmd    out
-d0     inout
-d1     inout
-d2     inout
-d3     inout
diff --git a/spi.txt b/spi.txt
deleted file mode 100644 (file)
index 2528c8d..0000000
--- a/spi.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-sclk   out
-mosi   out
-ss     out
-miso   in
index 81fcb56f0b9625eba28768693c80a9de65ac9f89..51e56b2eb2d735895ed1e9cb297b746a88f0ba2c 100644 (file)
@@ -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")
index cefc77d3151846c8f3908924cec0f4b430355878..e8d629d0982363112ce26c916336e7a91ff35abe 100644 (file)
@@ -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/test/interfaces.txt b/test/interfaces.txt
new file mode 100644 (file)
index 0000000..5a1a4e2
--- /dev/null
@@ -0,0 +1,6 @@
+uart   4
+spi    1
+twi    2
+sd     2
+jtag   2
+pwm    1
diff --git a/test/jtag.txt b/test/jtag.txt
new file mode 100644 (file)
index 0000000..494fbd2
--- /dev/null
@@ -0,0 +1,5 @@
+tdi    in
+tms    in
+tclk   in
+trst   in
+tdo    out
diff --git a/test/pinmap.txt b/test/pinmap.txt
new file mode 100644 (file)
index 0000000..f2fbccb
--- /dev/null
@@ -0,0 +1,21 @@
+muxed
+0              uart0_tx        spi0_sclk               uart2_tx        uart3_tx
+1              uart0_rx        spi0_mosi               uart2_rx        uart3_rx
+2              twi0_sda        spi0_ss   
+3              twi0_scl        spi0_miso
+8   sd0_clk   sd1_clk
+9   sd0_cmd   sd1_cmd
+10  sd0_d0    sd1_d0
+11  sd0_d1    sd1_d1
+12  sd0_d2    sd1_d2
+13  sd0_d3    sd1_d3    pwm0_pwm
+dedicated
+4              uart1_tx
+5              uart1_rx
+6              twi1_sda
+7              twi1_scl
+14   jtag0_tclk
+15   jtag0_tdo
+16  jtag0_tdi
+17  jtag0_tms
+18  jtag0_tdo
diff --git a/test/pwm.txt b/test/pwm.txt
new file mode 100644 (file)
index 0000000..76b0c8b
--- /dev/null
@@ -0,0 +1 @@
+pwm    out
diff --git a/test/sd.txt b/test/sd.txt
new file mode 100644 (file)
index 0000000..4096e06
--- /dev/null
@@ -0,0 +1,6 @@
+clk    out
+cmd    out
+d0     inout
+d1     inout
+d2     inout
+d3     inout
diff --git a/test/spi.txt b/test/spi.txt
new file mode 100644 (file)
index 0000000..2528c8d
--- /dev/null
@@ -0,0 +1,4 @@
+sclk   out
+mosi   out
+ss     out
+miso   in
diff --git a/test/twi.txt b/test/twi.txt
new file mode 100644 (file)
index 0000000..31fbc5a
--- /dev/null
@@ -0,0 +1,2 @@
+sda    inout
+scl    inout
diff --git a/test/uart.txt b/test/uart.txt
new file mode 100644 (file)
index 0000000..9af527f
--- /dev/null
@@ -0,0 +1,2 @@
+rx     in
+tx     out
diff --git a/twi.txt b/twi.txt
deleted file mode 100644 (file)
index 31fbc5a..0000000
--- a/twi.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-sda    inout
-scl    inout
diff --git a/uart.txt b/uart.txt
deleted file mode 100644 (file)
index 9af527f..0000000
--- a/uart.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-rx     in
-tx     out