res += ";"
return res
- # sample bsv method definition :
- """
- method Action cell0_mux(Bit#(2) in);
- wrcell0_mux<=in;
- endmethod
- """
-
def ifacedef(self, fmtoutfn, fmtinfn, fmtdecfn):
res = ' method '
if self.action:
fmtname = fmtoutfn(self.name)
res += "%s=%s;" % (self.name, fmtname)
return res
+ # sample bsv method definition :
+ """
+ method Action cell0_mux(Bit#(2) in);
+ wrcell0_mux<=in;
+ endmethod
+ """
+
# sample bsv wire (wire definiton):
"""
Wire#(Bit#(2)) wrcell0_mux<-mkDWire(0);
res += "<-mkDWire(0);"
return res
+ def ifacedef2(self, fmtoutfn, fmtinfn, fmtdecfn):
+ if self.action:
+ fmtname = fmtinfn(self.name)
+ res = " interface %s = interface Put\n" % self.name_
+ res += ' method '
+ res += "Action put"
+ #res += fmtdecfn(self.name)
+ res += '(%s in);\n' % self.bitspec
+ res += ' %s<=in;\n' % fmtname
+ res += ' endmethod\n'
+ res += ' endinterface;'
+ else:
+ fmtname = fmtoutfn(self.name)
+ res = " interface %s = interface Get\n" % self.name_
+ res += ' method ActionValue#'
+ res += '(%s) get;\n' % self.bitspec
+ res += " return %s;\n" % (fmtname)
+ res += ' endmethod\n'
+ res += ' endinterface;'
+ return res
class Interface(PeripheralIface):
""" create an interface from a list of pinspecs.
return pin.ifacedef(outfn, self.ifacefmtinfn,
decfn)
+ def ifacedef2pin(self, pin):
+ decfn = self.ifacefmtdecfn2
+ outfn = self.ifacefmtoutfn
+ # print pin, pin.outenmode
+ if pin.outenmode:
+ decfn = self.ifacefmtdecfn3
+ outfn = self.ifacefmtoutenfn
+ return pin.ifacedef2(outfn, self.ifacefmtinfn,
+ decfn)
+
def ifacedef(self, *args):
res = '\n'.join(map(self.ifacefmtpin, self.pins))
res = res.format(*args)
return '\n' + res + '\n'
+ def ifacedef2(self, *args):
+ res = '\n'.join(map(self.ifacedef2pin, self.pins))
+ res = res.format(*args)
+ return '\n' + res + '\n'
+
class MuxInterface(Interface):
for i in range(count):
f.write(self.data[name].ifacedef(i))
+ def ifacedef2(self, f, *args):
+ c = " interface {0} = interface PeripheralSide{1}"
+ for (name, count) in self.ifacecount:
+ for i in range(count):
+ iname = self.data[name].iname().format(i)
+ f.write(c.format(iname, name.upper()))
+ f.write(self.data[name].ifacedef2(i))
+ f.write(" endinterface;\n\n")
+
def busfmt(self, f, *args):
f.write("import BUtils::*;\n\n")
for (name, count) in self.ifacecount:
interface peripheral_side = interface PeripheralSide
''')
- ifaces.ifacedef(bsv_file)
+ ifaces.ifacedef2(bsv_file)
bsv_file.write("\n endinterface;")
bsv_file.write(footer)
interface peripheral_side = interface PeripheralSide
interface uart = interface PeripheralSideUART
- // interface declaration between UART and pinmux
interface tx = interface Put
method Action put(Bit#(1) in);
wruart_tx<=in;
endmethod
endinterface;
- interface rx = interface Get
+ interface rx = interface Get
method ActionValue#(Bit#(1)) get;
return wruart_rx;
endmethod
endinterface;
endinterface;
- interface twi = interface PeripheralSideTWI
- // interface declaration between TWI and pinmux
- interface sda_out = interface Put
+ interface gpioa = interface PeripheralSideGPIOA
+ interface a0_out = interface Put
method Action put(Bit#(1) in);
- wrtwi_sda_out<=in;
+ wrgpioa_a0_out<=in;
endmethod
endinterface;
- interface sda_outen = interface Put
+ interface a0_outen = interface Put
method Action put(Bit#(1) in);
- wrtwi_sda_outen<=in;
+ wrgpioa_a0_outen<=in;
endmethod
endinterface;
- interface sda_in = interface Get
+ interface a0_in = interface Get
method ActionValue#(Bit#(1)) get;
- return wrtwi_sda_in;
+ return wrgpioa_a0_in;
endmethod
endinterface;
- interface scl_out = interface Put
+ interface a1_out = interface Put
method Action put(Bit#(1) in);
- wrtwi_scl_out<=in;
+ wrgpioa_a1_out<=in;
endmethod
endinterface;
- interface scl_outen = interface Put
+ interface a1_outen = interface Put
method Action put(Bit#(1) in);
- wrtwi_scl_outen<=in;
+ wrgpioa_a1_outen<=in;
endmethod
endinterface;
- interface scl_in = interface Get
+ interface a1_in = interface Get
method ActionValue#(Bit#(1)) get;
- return wrtwi_scl_in;
+ return wrgpioa_a1_in;
endmethod
endinterface;
- endinterface;
-
- interface gpioa = interface PeripheralSideGPIOA
-
- interface a0_out = interface Put
+ interface a2_out = interface Put
method Action put(Bit#(1) in);
- wrgpioa_a0_out<=in;
+ wrgpioa_a2_out<=in;
endmethod
endinterface;
- interface a0_outen = interface Put
+ interface a2_outen = interface Put
method Action put(Bit#(1) in);
- wrgpioa_a0_outen<=in;
+ wrgpioa_a2_outen<=in;
endmethod
endinterface;
- interface a0_in = interface Get
+ interface a2_in = interface Get
method ActionValue#(Bit#(1)) get;
- return wrgpioa_a0_in;
+ return wrgpioa_a2_in;
endmethod
endinterface;
- interface a1_out = interface Put
+ endinterface;
+
+ interface twi = interface PeripheralSideTWI
+ interface sda_out = interface Put
method Action put(Bit#(1) in);
- wrgpioa_a1_out<=in;
+ wrtwi_sda_out<=in;
endmethod
endinterface;
- interface a1_outen = interface Put
+ interface sda_outen = interface Put
method Action put(Bit#(1) in);
- wrgpioa_a1_outen<=in;
+ wrtwi_sda_outen<=in;
endmethod
endinterface;
- interface a1_in = interface Get
+ interface sda_in = interface Get
method ActionValue#(Bit#(1)) get;
- return wrgpioa_a1_in;
+ return wrtwi_sda_in;
endmethod
endinterface;
- interface a2_out = interface Put
+ interface scl_out = interface Put
method Action put(Bit#(1) in);
- wrgpioa_a2_out<=in;
+ wrtwi_scl_out<=in;
endmethod
endinterface;
- interface a2_outen = interface Put
+ interface scl_outen = interface Put
method Action put(Bit#(1) in);
- wrgpioa_a2_outen<=in;
+ wrtwi_scl_outen<=in;
endmethod
endinterface;
- interface a2_in = interface Get
+ interface scl_in = interface Get
method ActionValue#(Bit#(1)) get;
- return wrgpioa_a2_in;
+ return wrtwi_scl_in;
endmethod
endinterface;
endinterface;