"""
def __init__(self, name,
+ name_ = None,
ready=True,
enabled=True,
io=False,
bitspec=None,
outenmode=False):
self.name = name
+ self.name_ = name_
self.ready = ready
self.enabled = enabled
self.io = io
Action io0_inputval (Bit#(1) in);
"""
+ def ifacepfmt(self, fmtfn):
+ res = ' '
+ status = []
+ res += "interface "
+ name = fmtfn(self.name_)
+ if self.action:
+ res += "Put"
+ else:
+ res += "Get"
+ res += "#(%s) %s;" % (self.bitspec, name)
+ return res
+
def ifacefmt(self, fmtfn):
res = ' '
status = []
del _p['outen']
for psuffix in ['out', 'outen', 'in']:
# changing the name (like sda) to (twi_sda_out)
+ _p['name_'] = "%s_%s" % (p['name'], psuffix)
_p['name'] = "%s_%s" % (self.pname(p['name']), psuffix)
_p['action'] = psuffix != 'in'
self.pins.append(Pin(**_p))
#{'name': 'twi_sda_in', 'action': False}
# NOTice - outen key is removed
else:
+ _p['name_'] = p['name']
_p['name'] = self.pname(p['name'])
self.pins.append(Pin(**_p))
res += '\n'
return '\n' + res
+ def ifacepfmt(self, *args):
+ res = '\n'.join(map(self.ifacepfmtdecpin, self.pins)).format(*args)
+ return '\n' + res # pins is a list
+
def ifacefmt(self, *args):
res = '\n'.join(map(self.ifacefmtdecpin, self.pins)).format(*args)
return '\n' + res # pins is a list
+ def ifacepfmtdecfn(self, name):
+ return name
+
def ifacefmtdecfn(self, name):
return name # like: uart
return pin.wirefmt(self.ifacefmtoutfn, self.ifacefmtinfn,
self.ifacefmtdecfn2)
+ def ifacepfmtdecpin(self, pin):
+ return pin.ifacepfmt(self.ifacepfmtdecfn)
+
def ifacefmtdecpin(self, pin):
return pin.ifacefmt(self.ifacefmtdecfn)
bf = self.data[name].busfmt(i)
f.write(bf)
+ def ifacepfmt(self, f, *args):
+ comment = '''
+ // interface declaration between {0} and pinmux
+ (*always_ready,always_enabled*)
+ interface PeripheralSide{0};'''
+ for (name, count) in self.ifacecount:
+ f.write(comment.format(name.upper()))
+ f.write(self.data[name].ifacepfmt(0))
+ f.write("\n endinterface\n")
+
def ifacefmt(self, f, *args):
comment = '''
// interface declaration between %s-{0} and pinmux'''
header = copyright + '''
package pinmux;
+import GetPut::*;
+
'''
footer = '''
endmodule
cell_bit_width = 'Bit#(%d)' % p.cell_bitwidth
bsv_file.write('''\
- interface MuxSelectionLines;
+ (*always_ready,always_enabled*)
+ interface MuxSelectionLines;
// declare the method which will capture the user pin-mux
// selection values.The width of the input is dependent on the number
# ===== finish interface definition and start module definition=======
bsv_file.write("\n endinterface\n")
+ ifaces.ifacepfmt(bsv_file)
# ===== io cell definition =======
bsv_file.write('''
-
+ (*always_ready,always_enabled*)
interface PeripheralSide;
// declare the interface to the peripherals
// Each peripheral's function will be either an input, output
import GetPut::*;
(*always_ready,always_enabled*)
- interface MuxSelectionLines;
+ interface MuxSelectionLines;
// declare the method which will capture the user pin-mux
// selection values.The width of the input is dependent on the number
Action io2_cell_in (Bit#(1) in);
endinterface
-
+ // interface declaration between UART and pinmux
(*always_ready,always_enabled*)
interface PeripheralSideUART;
- // interface declaration between UART and pinmux
interface Put#(Bit#(1)) tx;
interface Get#(Bit#(1)) rx;
-// (*always_ready,always_enabled*) method Action tx (Bit#(1) in);
-// (*always_ready,always_enabled*) method Bit#(1) rx;
endinterface
+ // interface declaration between GPIOA and pinmux
(*always_ready,always_enabled*)
interface PeripheralSideGPIOA;
- // interface declaration between GPIOA-0 and pinmux
interface Put#(Bit#(1)) a0_out;
interface Put#(Bit#(1)) a0_outen;
interface Get#(Bit#(1)) a0_in;
interface Put#(Bit#(1)) a2_out;
interface Put#(Bit#(1)) a2_outen;
interface Get#(Bit#(1)) a2_in;
- endinterface
+ endinterface
+ // interface declaration between TWI and pinmux
(*always_ready,always_enabled*)
interface PeripheralSideTWI;
- // interface declaration between TWI and pinmux
interface Put#(Bit#(1)) sda_out;
interface Put#(Bit#(1)) sda_outen;
interface Get#(Bit#(1)) sda_in;
endinterface;
-// interface peripheral_side = interface PeripheralSide
-//
-// interface uart = peripherals.uart;
-// interface gpioa = peripherals.gpioa;
-// interface twi = peripherals.twi;
-//
-// endinterface;
endmodule
endpackage