| 21 | | #!python |
| 22 | | class HwIdct(MwmrCoproc): |
| 23 | | def __init__(self, name, **d): |
| 24 | | MwmrCoproc.__init__(self, name, ['input'], ['output'], **d) |
| | 20 | Module('caba:fifo_idct', |
| | 21 | classname = 'dsx::caba::FifoIdct', |
| | 22 | header_files = [ |
| | 23 | "../source/include/fifo_idct.h", |
| | 24 | "../../include/fifo_idct.h", |
| | 25 | ], |
| | 26 | implementation_files = [ |
| | 27 | "../source/src/fifo_idct.cpp", |
| | 28 | ], |
| | 29 | ports = [ |
| | 30 | Port('caba:fifo_output', 'p_to_ctrl'), |
| | 31 | Port('caba:fifo_input', 'p_from_ctrl'), |
| | 32 | Port('caba:bit_in', 'p_resetn', auto = 'resetn'), |
| | 33 | Port('caba:clock_in', 'p_clk', auto = 'clock'), |
| | 34 | ], |
| | 35 | uses = [ |
| | 36 | Uses('caba:base_module'), |
| | 37 | ], |
| | 38 | instance_parameters = [ |
| | 39 | parameter.Int('latency'), |
| | 40 | ], |
| | 41 | tmpl_parameters = [ |
| | 42 | parameter.Type('word_t'), |
| | 43 | ], |
| | 44 | ) |
| 26 | | |
| 27 | | And register a Caba driver for this component: |
| 28 | | |
| 29 | | {{{ |
| 30 | | #!python |
| 31 | | |
| 32 | | # Heritage from MwmrCoprocCabaDriver is important |
| 33 | | class idctgen(MwmrCoprocCabaDriver): |
| 34 | | # Here goal is to map between TaskModel fifo names and actual component's fifos |
| 35 | | namemap = {'output':'OUT', 'input':'IN'} |
| 36 | | # For all below, see [1] |
| 37 | | headers = 'hw_components/hw_idct.h', |
| 38 | | def __init__(self, node): |
| 39 | | MwmrCoprocCabaDriver.__init__(self, node) |
| 40 | | self.plugmap['output'] = "OUT" |
| 41 | | self.plugmap['input'] = "IN" |
| 42 | | def genType(self, driver): |
| 43 | | return 'HW_IDCT' |
| 44 | | def genDecl(self, driver): |
| 45 | | return '("%s")'%(self.node.name) |
| 46 | | Caba.register(HwIdct, idctgen) |
| 47 | | }}} |
| 48 | | |
| 49 | | Notes: |
| 50 | | 1. CabaDriver |
| 57 | | idct = TaskModel( |
| 58 | | 'idct', |
| 59 | | infifos = [ 'input' ], |
| 60 | | outfifos = [ 'output' ], |
| 61 | | impl = [ SwTask( 'idct', |
| 62 | | stack_size = 1024, |
| 63 | | sources = [ 'src/idct.c' ] ), |
| 64 | | HwTask( HwIdct ) |
| 65 | | ] ) |
| | 75 | == Creating the coprocessor in the netlist == |
| | 76 | |
| | 77 | In our netlist, we now have to create the coprocessor and its controller. There is a helper function to do this: |
| | 78 | |
| | 79 | {{{ |
| | 80 | # The helper function needs the task implementation: get the task model |
| | 81 | idct = dsx.TaskModel.getByName('hw_idct').getImpl(soclib.HwTask) |
| | 82 | |
| | 83 | # The we can call the helper function, it returns the controller |
| | 84 | # and the coprocessor components freshly instanciated |
| | 85 | |
| | 86 | # first argument is your current platform (the one from soclib.Architecture() |
| | 87 | # second argument is base name, coprocessor will use "NAME", and controller "NAME_ctrl" |
| | 88 | ctrl, coproc = idct.instanciate(arch, 'idct0') # here names are "idct0" and "idct0_ctrl" |
| | 89 | |
| | 90 | # Connections between the controller and the coprocessor has been completed (fifos, config, status) |
| | 91 | # Anything else is to be done by the designer. |
| | 92 | # For instance, connecting the controller to the interconnect, and assigning a segment to the controller. |
| | 93 | |
| | 94 | ctrl.addSegment('idct0_ctrl', 0x70400000, 0x100, False) |
| | 95 | ctrl.vci_initiator // vgmn.to_initiator.new() |
| | 96 | ctrl.vci_target // vgmn.to_target.new() |