clock resolution
[pinmux.git] / src / bsv / peripheral_gen / rgbttl.py
1 from bsv.peripheral_gen.base import PBase
2
3
4 class rgbttl(PBase):
5
6 def slowimport(self):
7 return "import rgbttl_dummy :: *;"
8
9 def has_axi_master(self):
10 return True
11
12 def num_axi_regs32(self):
13 return 10
14
15 def mkfast_peripheral(self):
16 sz = len(self.peripheral.pinspecs) - 4 # subtract CK, DE, HS, VS
17 return "Ifc_rgbttl_dummy lcd{0} <- mkrgbttl_dummy();"
18
19 def _mk_connection(self, name=None, count=0):
20 return "lcd{0}.slave"
21
22 def pinname_out(self, pname):
23 if not pname.startswith('out'):
24 return pname
25 return ''
26
27 def get_clock_reset(self, name, count):
28 return "slow_clock, slow_reset"
29
30 def _mk_pincon(self, name, count, ptyp):
31 ret = [PBase._mk_pincon(self, name, count, ptyp)]
32 if ptyp == 'fast':
33 sname = self.get_iname(count)
34 ps = "slow_peripherals.%s" % sname
35 else:
36 sname = self.peripheral.iname().format(count)
37 ps = "pinmux.peripheral_side.%s" % sname
38 n = self.get_iname(count)
39 for ptype in ['data_out']:
40 ps_ = "{0}.{1}".format(ps, ptype)
41 ret += self._mk_actual_connection('out', name, count, 'out',
42 ptype, ps_, n, ptype)
43 return '\n'.join(ret)
44
45 def _mk_clk_con(self, name, count, ctype):
46 ret = [PBase._mk_clk_con(self, name, count, ctype)]
47 ck = self.get_clock_reset(name, count)
48 if ck == PBase.get_clock_reset(self, name, count):
49 return ret
50 if ctype == 'slow':
51 spc = "sp_clock, sp_reset"
52 else:
53 spc = ck
54 ck = "core_clock, core_reset"
55 template = """\
56 Ifc_sync#({0}) {1}_sync <-mksyncconnection(
57 {2}, {3});"""
58
59 # one pin, data_out, might as well hard-code it
60 typ = 'out'
61 pname = 'data_out'
62 n = name
63 n_ = "{0}{1}".format(n, count)
64 n_ = '{0}_{1}'.format(n_, pname)
65 sz = len(self.peripheral.pinspecs) - 4 # subtract CK, DE, HS, VS
66 ret.append(template.format("Bit#(%d)" % sz, n_, ck, spc))
67 return '\n'.join(ret)