ab68dcbbe7cbae52da50d213aea0e99d4bb3d2cd
[pinmux.git] / src / bsv / peripheral_gen.py
1 class PBase(object):
2 pass
3
4
5 class uart(PBase):
6 def importfn(self):
7 return " import Uart16550 :: *;"
8
9 def ifacedecl(self):
10 return " interface RS232_PHY_Ifc uart{0}_coe;\n" \
11 " method Bit#(1) uart{0}_intr;"
12
13 def num_axi_regs32(self):
14 return 8
15
16
17 class rs232(PBase):
18 def importfn(self):
19 return " import Uart_bs::*;\n" \
20 " import RS232_modified::*;"
21
22 def ifacedecl(self):
23 return " interface RS232 uart{0}_coe;"
24
25 def num_axi_regs32(self):
26 return 2
27
28
29 class twi(PBase):
30 def importfn(self):
31 return " import I2C_top :: *;"
32
33 def ifacedecl(self):
34 return " interface I2C_out i2c{0}_out;\n" \
35 " method Bit#(1) i2c{0}_isint;"
36
37 def num_axi_regs32(self):
38 return 8
39
40
41 class qspi(PBase):
42 def importfn(self):
43 return " import qspi :: *;"
44
45 def ifacedecl(self):
46 return " interface QSPI_out qspi{0}_out;\n" \
47 " method Bit#(1) qspi{0}_isint;"
48
49 def num_axi_regs32(self):
50 return 13
51
52
53 class pwm(PBase):
54 def importfn(self):
55 return " import pwm::*;"
56
57 def ifacedecl(self):
58 return " interface PWMIO pwm_o;"
59
60 def num_axi_regs32(self):
61 return 4
62
63
64 class gpio(PBase):
65 def importfn(self):
66 return " import pinmux::*;\n" \
67 " import mux::*;\n" \
68 " import gpio::*;\n"
69
70 def ifacedecl(self):
71 return " interface GPIO_config#({1}) pad_config{0};"
72
73 def num_axi_regs32(self):
74 return 2
75
76
77 class PFactory(object):
78 def getcls(self, name):
79 return {'uart': uart,
80 'rs232': rs232,
81 'twi': twi,
82 'qspi': qspi,
83 'pwm': pwm,
84 'gpio': gpio
85 }.get(name, None)