+class InterfaceQSPI(Interface):
+
+ def ifacepfmt(self, *args):
+ pins = filter(lambda x: not x.name_.startswith('io'), self.pins)
+ res = '\n'.join(map(self.ifacepfmtdecpin, pins)).format(*args)
+ res = res.format(*args)
+
+ return "\n" + res + """
+ interface Put#(Bit#(4)) io_out;
+ interface Put#(Bit#(4)) io_out_en;
+ interface Get#(Bit#(4)) io_in;
+""".format(len(self.pinspecs))
+
+ def ifacedef2(self, *args):
+ pins = filter(lambda x: not x.name_.startswith('io'), self.pins)
+ res = '\n'.join(map(self.ifacedef2pin, pins))
+ res = res.format(*args)
+
+ pins = filter(lambda x: x.name_.startswith('io'), self.pins)
+ return '\n' + res + self.vectorifacedef2(pins, 4,
+ ['io_out', 'io_out_en', 'io_in'],
+ "Bit#(4)", *args) + '\n'
+
+ def ifacedef3pin(self, idx, pin):
+ decfn = self.ifacefmtdecfn2
+ outfn = self.ifacefmtoutfn
+ # print pin, pin.outenmode
+ if pin.outenmode:
+ decfn = self.ifacefmtdecfn3
+ outfn = self.ifacefmtoutenfn
+ return pin.ifacedef3(idx, outfn, self.ifacefmtinfn,
+ decfn)
+
+