2fcd6fed5c6d3cf2735212d37c837c9dc8ca94ac
[pinmux.git] / src / bsv / peripheral_gen / twi.py
1 from bsv.peripheral_gen.base import PBase
2
3 class twi(PBase):
4
5 def slowimport(self):
6 return " import I2C_top :: *;"
7
8 def slowifdecl(self):
9 return " interface I2C_out twi{0}_out;\n" + \
10 " method Bit#(1) twi{0}_isint;"
11
12 def num_axi_regs32(self):
13 return 8
14
15 def mkslow_peripheral(self, size=0):
16 return " I2C_IFC twi{0} <- mkI2CController();"
17
18 def _mk_connection(self, name=None, count=0):
19 return "twi{0}.slave_i2c_axi"
20
21 def pinname_out(self, pname):
22 return {'sda': 'out.sda_out',
23 'scl': 'out.scl_out'}.get(pname, '')
24
25 def pinname_in(self, pname):
26 return {'sda': 'out.sda_in',
27 'scl': 'out.scl_in'}.get(pname, '')
28
29 def pinname_outen(self, pname):
30 return {'sda': 'out.sda_out_en',
31 'scl': 'out.scl_out_en'}.get(pname, '')
32
33 def num_irqs(self):
34 return 3
35
36 def plic_object(self, pname, idx):
37 return ["{0}.isint()",
38 "{0}.timerint()",
39 "{0}.isber()"
40 ][idx].format(pname)
41
42 def mk_ext_ifacedef(self, iname, inum):
43 name = self.get_iname(inum)
44 return " method {0}_isint = {0}.isint;".format(name)
45
46 def slowifdeclmux(self):
47 return " method Bit#(1) {1}{0}_isint;"
48
49