File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change 47
47
48
48
def make_ins_struct_def (layout ):
49
49
lines = layout .strip ().splitlines ()
50
- pos = 0
50
+ pos = 0 # bitfield definitions start from lsb
51
51
struct_def = {}
52
52
for line in lines :
53
53
bitfield = line .split ('#' , 1 )[0 ] # get rid of comment
Original file line number Diff line number Diff line change 3
3
4
4
OPCODE_DELAY = 4
5
5
LAYOUT_DELAY = """
6
- cycles : 16 # Number of cycles to sleep
7
- unused : 12 # Unused
8
- opcode : 4 # Opcode (OPCODE_DELAY)
6
+ cycles : 16 # Number of cycles to sleep
7
+ unused : 12 # Unused
8
+ opcode : 4 # Opcode (OPCODE_DELAY)
9
9
"""
10
10
11
11
12
12
def test_make_ins_struct_def ():
13
13
sd = make_ins_struct_def (LAYOUT_DELAY )
14
14
assert set (sd ) == {'cycles' , 'unused' , 'opcode' , 'all' }
15
- # TODO check if the expected values are correct (bitfield order)
16
15
assert sd ['cycles' ] == BFUINT32 | 0 << BF_POS | 16 << BF_LEN
17
16
assert sd ['unused' ] == BFUINT32 | 16 << BF_POS | 12 << BF_LEN
18
17
assert sd ['opcode' ] == BFUINT32 | 28 << BF_POS | 4 << BF_LEN
@@ -27,9 +26,7 @@ def test_make_ins():
27
26
assert _delay .cycles == 0x23
28
27
assert _delay .unused == 0
29
28
assert _delay .opcode == OPCODE_DELAY
30
- # TODO: check if the expected value is correct (byte order, bitfield order)
31
- expected = 0x40000023
32
- assert _delay .all == expected , '%x != %x' % (_delay .all , expected )
29
+ assert _delay .all == 0x40000023
33
30
34
31
35
32
test_make_ins_struct_def ()
You can’t perform that action at this time.
0 commit comments