4
4
from pyxcp .daq_stim .optimize .binpacking import Bin , first_fit_decreasing
5
5
6
6
7
+ # McObject(name="", address=section.address, ext=section.ext, length=section.length, components=[section])
8
+ # McObject(name: str, address: int, ext: int, length: int, data_type: str = '', components: list[pyxcp.cpp_ext.cpp_ext.McObject] = [])
7
9
@pytest .fixture
8
10
def blocks ():
9
11
return [
10
- McObject (name = "" , address = 0x000E10BA , length = 2 ),
11
- McObject (name = "" , address = 0x000E10BE , length = 2 ),
12
- McObject (name = "" , address = 0x000E41F4 , length = 4 ),
13
- McObject (name = "" , address = 0x000E51FC , length = 4 ),
14
- McObject (name = "" , address = 0x00125288 , length = 4 ),
15
- McObject (name = "" , address = 0x00125294 , length = 4 ),
16
- McObject (name = "" , address = 0x001252A1 , length = 1 ),
17
- McObject (name = "" , address = 0x001252A4 , length = 4 ),
18
- McObject (name = "" , address = 0x00125438 , length = 3 ),
19
- McObject (name = "" , address = 0x0012543C , length = 1 ),
12
+ McObject (name = "" , address = 0x000E10BA , ext = 0 , length = 2 ),
13
+ McObject (name = "" , address = 0x000E10BE , ext = 0 , length = 2 ),
14
+ McObject (name = "" , address = 0x000E41F4 , ext = 0 , length = 4 ),
15
+ McObject (name = "" , address = 0x000E51FC , ext = 0 , length = 4 ),
16
+ McObject (name = "" , address = 0x00125288 , ext = 0 , length = 4 ),
17
+ McObject (name = "" , address = 0x00125294 , ext = 0 , length = 4 ),
18
+ McObject (name = "" , address = 0x001252A1 , ext = 0 , length = 1 ),
19
+ McObject (name = "" , address = 0x001252A4 , ext = 0 , length = 4 ),
20
+ McObject (name = "" , address = 0x00125438 , ext = 0 , length = 3 ),
21
+ McObject (name = "" , address = 0x0012543C , ext = 0 , length = 1 ),
20
22
]
21
23
22
24
@@ -28,16 +30,16 @@ def test_pack_to_single_bin(blocks):
28
30
bin0 = bins [0 ]
29
31
assert bin0 .residual_capacity == BIN_SIZE - 29
30
32
assert bin0 .entries == [
31
- McObject (name = "" , address = 0x000E41F4 , length = 4 ),
32
- McObject (name = "" , address = 0x000E51FC , length = 4 ),
33
- McObject (name = "" , address = 0x00125288 , length = 4 ),
34
- McObject (name = "" , address = 0x00125294 , length = 4 ),
35
- McObject (name = "" , address = 0x001252A4 , length = 4 ),
36
- McObject (name = "" , address = 0x00125438 , length = 3 ),
37
- McObject (name = "" , address = 0x000E10BA , length = 2 ),
38
- McObject (name = "" , address = 0x000E10BE , length = 2 ),
39
- McObject (name = "" , address = 0x001252A1 , length = 1 ),
40
- McObject (name = "" , address = 0x0012543C , length = 1 ),
33
+ McObject (name = "" , address = 0x000E41F4 , ext = 0 , length = 4 ),
34
+ McObject (name = "" , address = 0x000E51FC , ext = 0 , length = 4 ),
35
+ McObject (name = "" , address = 0x00125288 , ext = 0 , length = 4 ),
36
+ McObject (name = "" , address = 0x00125294 , ext = 0 , length = 4 ),
37
+ McObject (name = "" , address = 0x001252A4 , ext = 0 , length = 4 ),
38
+ McObject (name = "" , address = 0x00125438 , ext = 0 , length = 3 ),
39
+ McObject (name = "" , address = 0x000E10BA , ext = 0 , length = 2 ),
40
+ McObject (name = "" , address = 0x000E10BE , ext = 0 , length = 2 ),
41
+ McObject (name = "" , address = 0x001252A1 , ext = 0 , length = 1 ),
42
+ McObject (name = "" , address = 0x0012543C , ext = 0 , length = 1 ),
41
43
]
42
44
43
45
@@ -54,46 +56,46 @@ def test_pack_to_multiple_bins1(blocks):
54
56
bin0 , bin1 , bin2 , bin3 , bin4 , bin5 = bins
55
57
assert bin0 .residual_capacity == 0
56
58
assert bin0 .entries == [
57
- McObject (name = "" , address = 0x000E41F4 , length = 4 ),
58
- McObject (name = "" , address = 0x000E10BA , length = 2 ),
59
+ McObject (name = "" , address = 0x000E41F4 , ext = 0 , length = 4 ),
60
+ McObject (name = "" , address = 0x000E10BA , ext = 0 , length = 2 ),
59
61
]
60
62
assert bin1 .residual_capacity == 0
61
63
assert bin1 .entries == [
62
- McObject (name = "" , address = 0x000E51FC , length = 4 ),
63
- McObject (name = "" , address = 0x000E10BE , length = 2 ),
64
+ McObject (name = "" , address = 0x000E51FC , ext = 0 , length = 4 ),
65
+ McObject (name = "" , address = 0x000E10BE , ext = 0 , length = 2 ),
64
66
]
65
67
assert bin2 .residual_capacity == 0
66
68
assert bin2 .entries == [
67
- McObject (name = "" , address = 0x00125288 , length = 4 ),
68
- McObject (name = "" , address = 0x001252A1 , length = 1 ),
69
- McObject (name = "" , address = 0x0012543C , length = 1 ),
69
+ McObject (name = "" , address = 0x00125288 , ext = 0 , length = 4 ),
70
+ McObject (name = "" , address = 0x001252A1 , ext = 0 , length = 1 ),
71
+ McObject (name = "" , address = 0x0012543C , ext = 0 , length = 1 ),
70
72
]
71
73
assert bin3 .residual_capacity == 2
72
- assert bin3 .entries == [McObject (name = "" , address = 0x00125294 , length = 4 )]
74
+ assert bin3 .entries == [McObject (name = "" , address = 0x00125294 , ext = 0 , length = 4 )]
73
75
assert bin4 .residual_capacity == 2
74
- assert bin4 .entries == [McObject (name = "" , address = 0x001252A4 , length = 4 )]
76
+ assert bin4 .entries == [McObject (name = "" , address = 0x001252A4 , ext = 0 , length = 4 )]
75
77
assert bin5 .residual_capacity == 3
76
- assert bin5 .entries == [McObject (name = "" , address = 0x00125438 , length = 3 )]
78
+ assert bin5 .entries == [McObject (name = "" , address = 0x00125438 , ext = 0 , length = 3 )]
77
79
78
80
79
81
def test_binpacking_raises (blocks ):
80
82
BIN_SIZE = 7
81
83
with pytest .raises (ValueError ):
82
- first_fit_decreasing (items = [McObject (name = "" , address = 0x1000 , length = 32 )], bin_size = BIN_SIZE )
84
+ first_fit_decreasing (items = [McObject (name = "" , address = 0x1000 , ext = 0 , length = 32 )], bin_size = BIN_SIZE )
83
85
84
86
85
87
def test_binpacking_works (blocks ):
86
88
BIN_SIZE = 7
87
- first_fit_decreasing (items = [McObject (name = "" , address = 0x1000 , length = 7 )], bin_size = BIN_SIZE )
89
+ first_fit_decreasing (items = [McObject (name = "" , address = 0x1000 , ext = 0 , length = 7 )], bin_size = BIN_SIZE )
88
90
89
91
90
92
def test_make_continuous_blocks1 ():
91
93
BLOCKS = [
92
- McObject (name = "" , address = 0x000E0002 , length = 2 ),
94
+ McObject (name = "" , address = 0x000E0002 , ext = 0 , length = 2 ),
93
95
McObject (name = "" , address = 0x000E0008 , ext = 23 , length = 4 ),
94
- McObject (name = "" , address = 0x000E0004 , length = 4 ),
96
+ McObject (name = "" , address = 0x000E0004 , ext = 0 , length = 4 ),
95
97
McObject (name = "" , address = 0x000E000C , ext = 23 , length = 4 ),
96
- McObject (name = "" , address = 0x000E0000 , length = 2 ),
98
+ McObject (name = "" , address = 0x000E0000 , ext = 0 , length = 2 ),
97
99
]
98
100
bins = make_continuous_blocks (chunks = BLOCKS )
99
101
assert bins == [
@@ -123,11 +125,11 @@ def test_make_continuous_blocks1():
123
125
124
126
def test_make_continuous_blocks2 ():
125
127
BLOCKS = [
126
- McObject (name = "" , address = 0x000E0002 , length = 2 ),
127
- McObject (name = "" , address = 0x000E0008 , length = 4 ),
128
- McObject (name = "" , address = 0x000E0004 , length = 4 ),
129
- McObject (name = "" , address = 0x000E000C , length = 4 ),
130
- McObject (name = "" , address = 0x000E0000 , length = 2 ),
128
+ McObject (name = "" , address = 0x000E0002 , ext = 0 , length = 2 ),
129
+ McObject (name = "" , address = 0x000E0008 , ext = 0 , length = 4 ),
130
+ McObject (name = "" , address = 0x000E0004 , ext = 0 , length = 4 ),
131
+ McObject (name = "" , address = 0x000E000C , ext = 0 , length = 4 ),
132
+ McObject (name = "" , address = 0x000E0000 , ext = 0 , length = 2 ),
131
133
]
132
134
bins = make_continuous_blocks (chunks = BLOCKS )
133
135
assert bins == [
0 commit comments