2 from copy
import deepcopy
6 def __init__(self
, name
):
9 def slowifdeclmux(self
):
12 def slowifinstance(self
):
18 def num_axi_regs32(self
):
24 def axibase(self
, name
, ifacenum
):
26 return "%(name)s%(ifacenum)dBase" % locals()
28 def axiend(self
, name
, ifacenum
):
30 return "%(name)s%(ifacenum)dEnd" % locals()
32 def axi_reg_def(self
, start
, name
, ifacenum
):
34 offs
= self
.num_axi_regs32() * 4 * 16
37 end
= start
+ offs
- 1
38 bname
= self
.axibase(name
, ifacenum
)
39 bend
= self
.axiend(name
, ifacenum
)
40 comment
= "%d 32-bit regs" % self
.num_axi_regs32()
41 return (" `define %(bname)s 'h%(start)08X\n"
42 " `define %(bend)s 'h%(end)08X // %(comment)s" % locals(),
45 def axi_slave_name(self
, name
, ifacenum
):
47 return "{0}{1}_slave_num".format(name
, ifacenum
)
49 def axi_slave_idx(self
, idx
, name
, ifacenum
):
50 name
= self
.axi_slave_name(name
, ifacenum
)
51 return ("typedef {0} {1};".format(idx
, name
), 1)
53 def axi_addr_map(self
, name
, ifacenum
):
54 bname
= self
.axibase(name
, ifacenum
)
55 bend
= self
.axiend(name
, ifacenum
)
56 name
= self
.axi_slave_name(name
, ifacenum
)
58 if(addr>=`{0} && addr<=`{1})
59 return tuple2(True,fromInteger(valueOf({2})));
60 else""".format(bname
, bend
, name
)
62 def mk_pincon(self
, name
, count
):
63 # TODO: really should be using bsv.interface_decl.Interfaces
64 # pin-naming rules.... logic here is hard-coded to duplicate
65 # it (see Interface.__init__ outen)
67 for p
in self
.peripheral
.pinspecs
:
70 #n = "{0}{1}".format(self.name, self.mksuffix(name, count))
71 n
= name
# "{0}{1}".format(self.name, self.mksuffix(name, count))
72 ret
.append(" //%s %s" % (n
, str(p
)))
73 sname
= self
.peripheral
.pname(pname
).format(count
)
74 ps
= "pinmux.peripheral_side.%s" % sname
75 if typ
== 'out' or typ
== 'inout':
76 ret
.append(" rule con_%s%d_%s_out;" % (name
, count
, pname
))
77 fname
= self
.pinname_out(pname
)
78 if not n
.startswith('gpio'): # XXX EURGH! horrible hack
79 n_
= "{0}{1}".format(n
, count
)
87 ret
.append(" {0}({1}.{2});".format(ps_
, n_
, fname
))
90 fname
= self
.pinname_outen(pname
)
92 if isinstance(fname
, str):
93 fname
= "{0}.{1}".format(n_
, fname
)
94 fname
= self
.pinname_tweak(pname
, 'outen', fname
)
95 ret
.append(" {0}_outen({1});".format(ps
, fname
))
96 ret
.append(" endrule")
97 if typ
== 'in' or typ
== 'inout':
98 fname
= self
.pinname_in(pname
)
105 " rule con_%s%d_%s_in;" %
106 (name
, count
, pname
))
107 n_
= "{0}{1}".format(n
, count
)
108 n_
= '{0}.{1}'.format(n_
, fname
)
109 n_
= self
.ifname_tweak(pname
, 'in', n_
)
110 ret
.append(" {1}({0});".format(ps_
, n_
))
111 ret
.append(" endrule")
112 return '\n'.join(ret
)
114 def mk_cellconn(self
, *args
):
117 def mkslow_peripheral(self
, size
=0):
120 def mksuffix(self
, name
, i
):
123 def __mk_connection(self
, con
, aname
):
124 txt
= " mkConnection (slow_fabric.v_to_slaves\n" + \
125 " [fromInteger(valueOf({1}))],\n" + \
128 print "PBase __mk_connection", self
.name
, aname
131 return txt
.format(con
, aname
)
133 def mk_connection(self
, count
, name
=None):
136 print "PBase mk_conn", self
.name
, count
137 aname
= self
.axi_slave_name(name
, count
)
138 #dname = self.mksuffix(name, count)
139 #dname = "{0}{1}".format(name, dname)
140 con
= self
._mk
_connection
(name
, count
).format(count
, aname
)
141 return self
.__mk
_connection
(con
, aname
)
143 def _mk_connection(self
, name
=None, count
=0):
146 def pinname_out(self
, pname
):
149 def pinname_in(self
, pname
):
152 def pinname_outen(self
, pname
):
155 def ifname_tweak(self
, pname
, typ
, txt
):
158 def pinname_tweak(self
, pname
, typ
, txt
):
164 def slowimport(self
):
165 return " import Uart_bs :: *;\n" + \
166 " import RS232_modified::*;"
168 def slowifdecl(self
):
169 return " interface RS232 uart{0}_coe;\n" + \
170 " method Bit#(1) uart{0}_intr;"
172 def num_axi_regs32(self
):
175 def mkslow_peripheral(self
, size
=0):
176 return " Ifc_Uart_bs uart{0} <- \n" + \
177 " mkUart_bs(clocked_by sp_clock,\n" + \
178 " reset_by uart_reset, sp_clock, sp_reset);"
180 def _mk_connection(self
, name
=None, count
=0):
181 return "uart{0}.slave_axi_uart"
183 def pinname_out(self
, pname
):
184 return {'tx': 'coe_rs232.sout'}.get(pname
, '')
186 def pinname_in(self
, pname
):
187 return {'rx': 'coe_rs232.sin'}.get(pname
, '')
192 def slowimport(self
):
193 return " import Uart16550 :: *;"
195 def slowifdecl(self
):
196 return " interface RS232_PHY_Ifc quart{0}_coe;\n" + \
197 " method Bit#(1) quart{0}_intr;"
199 def num_axi_regs32(self
):
202 def mkslow_peripheral(self
, size
=0):
203 return " Uart16550_AXI4_Lite_Ifc quart{0} <- \n" + \
204 " mkUart16550(clocked_by sp_clock,\n" + \
205 " reset_by uart_reset, sp_clock, sp_reset);"
207 def _mk_connection(self
, name
=None, count
=0):
208 return "quart{0}.slave_axi_uart"
210 def pinname_out(self
, pname
):
211 return {'tx' : 'coe_rs232.modem_output_stx',
212 'rts': 'coe_rs232.modem_output_rts',
215 def _pinname_in(self
, pname
):
216 return {'rx': 'coe_rs232.modem_input.srx',
217 'cts': 'coe_rs232.modem_input.cts'
220 def mk_pincon(self
, name
, count
):
221 ret
= [PBase
.mk_pincon(self
, name
, count
)]
222 size
= len(self
.peripheral
.pinspecs
)
223 ret
.append(eint_pincon_template
.format(size
))
224 ret
.append(" rule con_%s%d_io_in;" % (name
, count
))
225 ret
.append(" {0}{1}.coe_rs232.modem_input(".format(name
, count
))
226 for idx
, pname
in enumerate(['rx', 'cts']):
227 sname
= self
.peripheral
.pname(pname
).format(count
)
228 ps
= "pinmux.peripheral_side.%s" % sname
229 ret
.append(" {0},".format(ps
))
230 ret
.append(" 1'b1,1'b0,1'b1")
232 ret
.append(" endrule")
234 return '\n'.join(ret
)
239 def slowimport(self
):
240 return " import Uart_bs::*;\n" + \
241 " import RS232_modified::*;"
243 def slowifdecl(self
):
244 return " interface RS232 uart{0}_coe;"
246 def num_axi_regs32(self
):
249 def mkslow_peripheral(self
, size
=0):
250 return " //Ifc_Uart_bs uart{0} <-" + \
251 " // mkUart_bs(clocked_by uart_clock,\n" + \
252 " // reset_by uart_reset,sp_clock, sp_reset);" +\
253 " Ifc_Uart_bs uart{0} <-" + \
254 " mkUart_bs(clocked_by sp_clock,\n" + \
255 " reset_by sp_reset, sp_clock, sp_reset);"
257 def _mk_connection(self
, name
=None, count
=0):
258 return "uart{0}.slave_axi_uart"
260 def pinname_out(self
, pname
):
261 return {'tx': 'coe_rs232.sout'}.get(pname
, '')
263 def pinname_in(self
, pname
):
264 return {'rx': 'coe_rs232.sin'}.get(pname
, '')
269 def slowimport(self
):
270 return " import I2C_top :: *;"
272 def slowifdecl(self
):
273 return " interface I2C_out twi{0}_out;\n" + \
274 " method Bit#(1) twi{0}_isint;"
276 def num_axi_regs32(self
):
279 def mkslow_peripheral(self
, size
=0):
280 return " I2C_IFC twi{0} <- mkI2CController();"
282 def _mk_connection(self
, name
=None, count
=0):
283 return "twi{0}.slave_i2c_axi"
285 def pinname_out(self
, pname
):
286 return {'sda': 'out.sda_out',
287 'scl': 'out.scl_out'}.get(pname
, '')
289 def pinname_in(self
, pname
):
290 return {'sda': 'out.sda_in',
291 'scl': 'out.scl_in'}.get(pname
, '')
293 def pinname_outen(self
, pname
):
294 return {'sda': 'out.sda_out_en',
295 'scl': 'out.scl_out_en'}.get(pname
, '')
297 def pinname_tweak(self
, pname
, typ
, txt
):
299 return "pack({0})".format(txt
)
305 def slowimport(self
):
306 size
= len(self
.peripheral
.pinspecs
)
307 return " `define NUM_EINTS %d" % size
309 def mkslow_peripheral(self
, size
=0):
310 size
= len(self
.peripheral
.pinspecs
)
311 return " Wire#(Bit#(%d)) wr_interrupt <- mkWire();" % size
313 def axi_slave_name(self
, name
, ifacenum
):
316 def axi_slave_idx(self
, idx
, name
, ifacenum
):
319 def axi_addr_map(self
, name
, ifacenum
):
322 def ifname_tweak(self
, pname
, typ
, txt
):
325 print "ifnameweak", pname
, typ
, txt
326 return "wr_interrupt[{0}] <= ".format(pname
)
328 def mk_pincon(self
, name
, count
):
329 ret
= [PBase
.mk_pincon(self
, name
, count
)]
330 size
= len(self
.peripheral
.pinspecs
)
331 ret
.append(eint_pincon_template
.format(size
))
332 ret
.append(" rule con_%s%d_io_in;" % (name
, count
))
333 ret
.append(" wr_interrupt <= ({")
334 for idx
, p
in enumerate(self
.peripheral
.pinspecs
):
336 sname
= self
.peripheral
.pname(pname
).format(count
)
337 ps
= "pinmux.peripheral_side.%s" % sname
338 comma
= '' if idx
== size
- 1 else ','
339 ret
.append(" {0}{1}".format(ps
, comma
))
341 ret
.append(" endrule")
343 return '\n'.join(ret
)
346 eint_pincon_template
= '''\
347 // TODO: offset i by the number of eints already used
348 for(Integer i=0;i<{0};i=i+ 1)begin
349 rule connect_int_to_plic(wr_interrupt[i]==1);
350 ff_gateway_queue[i].enq(1);
351 plic.ifc_external_irq[i].irq_frm_gateway(True);
359 def axi_slave_name(self
, name
, ifacenum
):
362 def axi_slave_idx(self
, idx
, name
, ifacenum
):
365 def axi_addr_map(self
, name
, ifacenum
):
368 def slowifdeclmux(self
):
369 return " method Action jtag_ms (Bit#(1) in);\n" + \
370 " method Bit#(1) jtag_di;\n" + \
371 " method Action jtag_do (Bit#(1) in);\n" + \
372 " method Action jtag_ck (Bit#(1) in);"
374 def slowifinstance(self
):
375 return jtag_method_template
# bit of a lazy hack this...
377 jtag_method_template
= """\
378 method Action jtag_ms (Bit#(1) in);
379 pinmux.peripheral_side.jtag_ms(in);
381 method Bit#(1) jtag_di=pinmux.peripheral_side.jtag_di;
382 method Action jtag_do (Bit#(1) in);
383 pinmux.peripheral_side.jtag_do(in);
385 method Action jtag_ck (Bit#(1) in);
386 pinmux.peripheral_side.jtag_ck(in);
392 def slowimport(self
):
393 return " import sdcard_dummy :: *;"
395 def slowifdecl(self
):
396 return " interface QSPI_out sd{0}_out;\n" + \
397 " method Bit#(1) sd{0}_isint;"
399 def num_axi_regs32(self
):
402 def mkslow_peripheral(self
):
403 return " Ifc_sdcard_dummy sd{0} <- mksdcard_dummy();"
405 def _mk_connection(self
, name
=None, count
=0):
408 def pinname_in(self
, pname
):
409 return "%s_in" % pname
411 def pinname_out(self
, pname
):
412 if pname
.startswith('d'):
413 return "%s_out" % pname
416 def pinname_outen(self
, pname
):
417 if pname
.startswith('d'):
418 return "%s_outen" % pname
423 def slowimport(self
):
424 return " import qspi :: *;"
426 def slowifdecl(self
):
427 return " interface QSPI_out spi{0}_out;\n" + \
428 " method Bit#(1) spi{0}_isint;"
430 def num_axi_regs32(self
):
433 def mkslow_peripheral(self
):
434 return " Ifc_qspi spi{0} <- mkqspi();"
436 def _mk_connection(self
, name
=None, count
=0):
437 return "spi{0}.slave"
439 def pinname_out(self
, pname
):
440 return {'clk': 'out.clk_o',
442 'mosi': 'out.io_o[0]',
443 'miso': 'out.io_o[1]',
446 def pinname_outen(self
, pname
):
449 'mosi': 'out.io_enable[0]',
450 'miso': 'out.io_enable[1]',
453 def mk_pincon(self
, name
, count
):
454 ret
= [PBase
.mk_pincon(self
, name
, count
)]
455 # special-case for gpio in, store in a temporary vector
456 plen
= len(self
.peripheral
.pinspecs
)
457 ret
.append(" // XXX NSS and CLK are hard-coded master")
458 ret
.append(" // TODO: must add spi slave-mode")
459 ret
.append(" // all ins done in one rule from 4-bitfield")
460 ret
.append(" rule con_%s%d_io_in;" % (name
, count
))
461 ret
.append(" {0}{1}.out.io_i({{".format(name
, count
))
462 for idx
, pname
in enumerate(['mosi', 'miso']):
463 sname
= self
.peripheral
.pname(pname
).format(count
)
464 ps
= "pinmux.peripheral_side.%s_in" % sname
465 ret
.append(" {0},".format(ps
))
466 ret
.append(" 1'b0,1'b0")
468 ret
.append(" endrule")
469 return '\n'.join(ret
)
474 def slowimport(self
):
475 return " import qspi :: *;"
477 def slowifdecl(self
):
478 return " interface QSPI_out qspi{0}_out;\n" + \
479 " method Bit#(1) qspi{0}_isint;"
481 def num_axi_regs32(self
):
484 def mkslow_peripheral(self
, size
=0):
485 return " Ifc_qspi qspi{0} <- mkqspi();"
487 def _mk_connection(self
, name
=None, count
=0):
488 return "qspi{0}.slave"
490 def pinname_out(self
, pname
):
491 return {'ck': 'out.clk_o',
493 'io0': 'out.io_o[0]',
494 'io1': 'out.io_o[1]',
495 'io2': 'out.io_o[2]',
496 'io3': 'out.io_o[3]',
499 def pinname_outen(self
, pname
):
502 'io0': 'out.io_enable[0]',
503 'io1': 'out.io_enable[1]',
504 'io2': 'out.io_enable[2]',
505 'io3': 'out.io_enable[3]',
508 def mk_pincon(self
, name
, count
):
509 ret
= [PBase
.mk_pincon(self
, name
, count
)]
510 # special-case for gpio in, store in a temporary vector
511 plen
= len(self
.peripheral
.pinspecs
)
512 ret
.append(" // XXX NSS and CLK are hard-coded master")
513 ret
.append(" // TODO: must add qspi slave-mode")
514 ret
.append(" // all ins done in one rule from 4-bitfield")
515 ret
.append(" rule con_%s%d_io_in;" % (name
, count
))
516 ret
.append(" {0}{1}.out.io_i({{".format(name
, count
))
517 for i
, p
in enumerate(self
.peripheral
.pinspecs
):
520 if not pname
.startswith('io'):
524 sname
= self
.peripheral
.pname(pname
).format(count
)
525 ps
= "pinmux.peripheral_side.%s_in" % sname
526 comma
= '' if i
== 5 else ','
527 ret
.append(" {0}{1}".format(ps
, comma
))
529 ret
.append(" endrule")
530 return '\n'.join(ret
)
535 def slowimport(self
):
536 return " import pwm::*;"
538 def slowifdecl(self
):
539 return " interface PWMIO pwm{0}_io;"
541 def num_axi_regs32(self
):
544 def mkslow_peripheral(self
, size
=0):
545 return " Ifc_PWM_bus pwm{0} <- mkPWM_bus(sp_clock);"
547 def _mk_connection(self
, name
=None, count
=0):
548 return "pwm{0}.axi4_slave"
550 def pinname_out(self
, pname
):
551 return {'out': 'pwm_io.pwm_o'}.get(pname
, '')
556 def slowimport(self
):
557 return " import pinmux::*;\n" + \
558 " import mux::*;\n" + \
561 def slowifdeclmux(self
):
562 size
= len(self
.peripheral
.pinspecs
)
563 return " interface GPIO_config#(%d) pad_config{0};" % size
565 def num_axi_regs32(self
):
568 def axi_slave_idx(self
, idx
, name
, ifacenum
):
569 """ generates AXI slave number definition, except
570 GPIO also has a muxer per bank
573 mname
= 'mux' + name
[4:]
574 mname
= mname
.upper()
575 print "AXIslavenum", name
, mname
576 (ret
, x
) = PBase
.axi_slave_idx(self
, idx
, name
, ifacenum
)
577 (ret2
, x
) = PBase
.axi_slave_idx(self
, idx
+ 1, mname
, ifacenum
)
578 return ("%s\n%s" % (ret
, ret2
), 2)
580 def mkslow_peripheral(self
, size
=0):
581 print "gpioslow", self
.peripheral
, dir(self
.peripheral
)
582 size
= len(self
.peripheral
.pinspecs
)
583 return " MUX#(%d) mux{0} <- mkmux();\n" % size
+ \
584 " GPIO#(%d) gpio{0} <- mkgpio();" % size
586 def mk_connection(self
, count
):
587 print "GPIO mk_conn", self
.name
, count
589 dname
= self
.mksuffix(self
.name
, count
)
590 for i
, n
in enumerate(['gpio' + dname
, 'mux' + dname
]):
591 res
.append(PBase
.mk_connection(self
, count
, n
))
592 return '\n'.join(res
)
594 def _mk_connection(self
, name
=None, count
=0):
595 n
= self
.mksuffix(name
, count
)
596 if name
.startswith('gpio'):
597 return "gpio{0}.axi_slave".format(n
)
598 if name
.startswith('mux'):
599 return "mux{0}.axi_slave".format(n
)
601 def mksuffix(self
, name
, i
):
602 if name
.startswith('mux'):
606 def mk_cellconn(self
, cellnum
, name
, count
):
608 bank
= self
.mksuffix(name
, count
)
609 txt
= " pinmux.mux_lines.cell{0}_mux(mux{1}.mux_config.mux[{2}]);"
610 for p
in self
.peripheral
.pinspecs
:
611 ret
.append(txt
.format(cellnum
, bank
, p
['name'][1:]))
613 return ("\n".join(ret
), cellnum
)
615 def pinname_out(self
, pname
):
616 return "func.gpio_out[{0}]".format(pname
[1:])
618 def pinname_outen(self
, pname
):
619 return "func.gpio_out_en[{0}]".format(pname
[1:])
621 def mk_pincon(self
, name
, count
):
622 ret
= [PBase
.mk_pincon(self
, name
, count
)]
623 # special-case for gpio in, store in a temporary vector
624 plen
= len(self
.peripheral
.pinspecs
)
625 ret
.append(" rule con_%s%d_in;" % (name
, count
))
626 ret
.append(" Vector#({0},Bit#(1)) temp;".format(plen
))
627 for p
in self
.peripheral
.pinspecs
:
632 sname
= self
.peripheral
.pname(pname
).format(count
)
633 ps
= "pinmux.peripheral_side.%s_in" % sname
634 ret
.append(" temp[{0}]={1};".format(idx
, ps
))
635 ret
.append(" {0}.func.gpio_in(temp);".format(name
))
636 ret
.append(" endrule")
637 return '\n'.join(ret
)
640 axi_slave_declarations
= """\
641 typedef 0 SlowMaster;
643 typedef TAdd#(LastGen_slave_num,`ifdef CLINT 1 `else 0 `endif )
645 typedef TAdd#(CLINT_slave_num ,`ifdef PLIC 1 `else 0 `endif )
647 typedef TAdd#(Plic_slave_num ,`ifdef AXIEXP 1 `else 0 `endif )
649 typedef TAdd#(AxiExp1_slave_num,1) Num_Slow_Slaves;
652 pinmux_cellrule
= """\
653 rule connect_select_lines_pinmux;
659 class CallFn(object):
660 def __init__(self
, peripheral
, name
):
661 self
.peripheral
= peripheral
664 def __call__(self
, *args
):
665 #print "__call__", self.name, self.peripheral.slow, args
666 if not self
.peripheral
.slow
:
668 return getattr(self
.peripheral
.slow
, self
.name
)(*args
[1:])
671 class PeripheralIface(object):
672 def __init__(self
, ifacename
):
674 slow
= slowfactory
.getcls(ifacename
)
675 print "Iface", ifacename
, slow
677 self
.slow
= slow(ifacename
)
678 self
.slow
.peripheral
= self
679 for fname
in ['slowimport',
680 'slowifinstance', 'slowifdecl', 'slowifdeclmux',
682 'mk_connection', 'mk_cellconn', 'mk_pincon']:
683 fn
= CallFn(self
, fname
)
684 setattr(self
, fname
, types
.MethodType(fn
, self
))
686 #print "PeripheralIface"
689 def mksuffix(self
, name
, i
):
690 if self
.slow
is None:
692 return self
.slow
.mksuffix(name
, i
)
694 def axi_reg_def(self
, start
, count
):
697 return self
.slow
.axi_reg_def(start
, self
.ifacename
, count
)
699 def axi_slave_idx(self
, start
, count
):
702 return self
.slow
.axi_slave_idx(start
, self
.ifacename
, count
)
704 def axi_addr_map(self
, count
):
707 return self
.slow
.axi_addr_map(self
.ifacename
, count
)
710 class PeripheralInterfaces(object):
714 def slowimport(self
, *args
):
716 for (name
, count
) in self
.ifacecount
:
717 #print "slowimport", name, self.data[name].slowimport
718 ret
.append(self
.data
[name
].slowimport())
719 return '\n'.join(list(filter(None, ret
)))
721 def slowifinstance(self
, *args
):
723 for (name
, count
) in self
.ifacecount
:
724 #print "slowimport", name, self.data[name].slowimport
725 ret
.append(self
.data
[name
].slowifinstance())
726 return '\n'.join(list(filter(None, ret
)))
728 def slowifdeclmux(self
, *args
):
730 for (name
, count
) in self
.ifacecount
:
731 for i
in range(count
):
732 ret
.append(self
.data
[name
].slowifdeclmux().format(i
, name
))
733 return '\n'.join(list(filter(None, ret
)))
735 def slowifdecl(self
, *args
):
737 for (name
, count
) in self
.ifacecount
:
738 for i
in range(count
):
739 ret
.append(self
.data
[name
].slowifdecl().format(i
, name
))
740 return '\n'.join(list(filter(None, ret
)))
742 def axi_reg_def(self
, *args
):
744 start
= 0x00011100 # start of AXI peripherals address
745 for (name
, count
) in self
.ifacecount
:
746 for i
in range(count
):
747 x
= self
.data
[name
].axi_reg_def(start
, i
)
748 #print ("ifc", name, x)
752 return '\n'.join(list(filter(None, ret
)))
754 def axi_slave_idx(self
, *args
):
757 for (name
, count
) in self
.ifacecount
:
758 for i
in range(count
):
759 (rdef
, offs
) = self
.data
[name
].axi_slave_idx(start
, i
)
760 #print ("ifc", name, rdef, offs)
763 ret
.append("typedef %d LastGen_slave_num;" % (start
- 1))
764 decls
= '\n'.join(list(filter(None, ret
)))
765 return axi_slave_declarations
.format(decls
)
767 def axi_addr_map(self
, *args
):
769 for (name
, count
) in self
.ifacecount
:
770 for i
in range(count
):
771 ret
.append(self
.data
[name
].axi_addr_map(i
))
772 return '\n'.join(list(filter(None, ret
)))
774 def mkslow_peripheral(self
, *args
):
776 for (name
, count
) in self
.ifacecount
:
777 for i
in range(count
):
778 print "mkslow", name
, count
779 x
= self
.data
[name
].mkslow_peripheral()
781 suffix
= self
.data
[name
].mksuffix(name
, i
)
782 ret
.append(x
.format(suffix
))
783 return '\n'.join(list(filter(None, ret
)))
785 def mk_connection(self
, *args
):
787 for (name
, count
) in self
.ifacecount
:
788 for i
in range(count
):
789 print "mk_conn", name
, i
790 txt
= self
.data
[name
].mk_connection(i
)
793 print self
.data
[name
].mk_connection
795 return '\n'.join(list(filter(None, ret
)))
797 def mk_cellconn(self
):
800 for (name
, count
) in self
.ifacecount
:
801 for i
in range(count
):
802 res
= self
.data
[name
].mk_cellconn(cellcount
, name
, i
)
805 (txt
, cellcount
) = res
807 ret
= '\n'.join(list(filter(None, ret
)))
808 return pinmux_cellrule
.format(ret
)
812 for (name
, count
) in self
.ifacecount
:
813 for i
in range(count
):
814 txt
= self
.data
[name
].mk_pincon(name
, i
)
816 return '\n'.join(list(filter(None, ret
)))
819 class PFactory(object):
820 def getcls(self
, name
):
821 for k
, v
in {'uart': uart
,
833 if name
.startswith(k
):
838 slowfactory
= PFactory()
840 if __name__
== '__main__':
844 i
= PeripheralIface('uart')
846 i
= PeripheralIface('gpioa')