| | 1 | Here we will explain how to create an hardware version of a task, writing its SocLib equivalent model. |
| | 2 | |
| | 3 | For instance in the explaination of the process, we'll write a IDCT (inverse discrete cosine transform) coprocessor. |
| | 4 | * It handles packets of 64 values, representing a block of 8*8 coefficients |
| | 5 | * It has one input and one output fifo |
| | 6 | * It handles 16-bit values |
| | 7 | |
| | 8 | == Coprocessor == |
| | 9 | |
| | 10 | First we'll write the coprocessor in Caba [wiki:SystemC]. |
| | 11 | |
| | 12 | {{{ |
| | 13 | |
| | 14 | }}} |
| | 15 | |
| | 16 | == Declaration for SocLib code generation == |
| | 17 | |
| | 18 | We have to declare this component to DSX: |
| | 19 | |
| | 20 | {{{ |
| | 21 | #!python |
| | 22 | class HwIdct(MwmrCoproc): |
| | 23 | def __init__(self, name, **d): |
| | 24 | MwmrCoproc.__init__(self, name, ['input'], ['output'], **d) |
| | 25 | }}} |
| | 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 |
| | 51 | |
| | 52 | == Task declaration == |
| | 53 | |
| | 54 | {{{ |
| | 55 | #!python |
| | 56 | |
| | 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 | ] ) |
| | 66 | }}} |
| | 67 | |
| | 68 | == That's all == |
| | 69 | |
| | 70 | Now we can map this coprocessor as an hardware task |