-
Notifications
You must be signed in to change notification settings - Fork 3
/
xilinx_context.py
48 lines (42 loc) · 1.42 KB
/
xilinx_context.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from bal.context import BALContext, BALContextFactory
from bal.data_object import DataObject
from example.xilinx_model import XilinxBitstream
class XilinxContext(BALContext):
"""
:param Dict[Type[ConverterInterface],Type[AbstractConverter]] converters_by_type:
:param Dict[Type[AnalyzerInterface],Type[AbstractAnalyzer]] analyzers_by_type:
:param Dict[Type[ModifierInterface],Type[AbstractModifier]] modifiers_by_type:
:param bytes bytes: The bytes making up the bitstream.
"""
def __init__(
self,
converters_by_type,
analyzers_by_type,
modifiers_by_type,
bytes
):
super(XilinxContext, self).__init__(
converters_by_type,
analyzers_by_type,
modifiers_by_type
)
self._bitstream = DataObject.create_packed(self, bytes, XilinxBitstream)
def get_data(self):
"""
:rtype: DataObject[XilinxBitstream]
"""
return self._bitstream
class XilinxContextFactory(BALContextFactory):
def __init__(self):
super(XilinxContextFactory, self).__init__()
def create(self, data):
"""
:param bytes bytes: The bytes for the Xilinx FPGA bitstream
:rtype: XilinxContext
"""
return XilinxContext(
self._converters_by_type,
self._analyzers_by_type,
self._modifiers_by_type,
data
)