-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/topic/awelzel/bitfield-examples'
- Loading branch information
Showing
8 changed files
with
292 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.10.0-dev.129 | ||
1.10.0-dev.133 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
[warning] <...>/bit-bitorder.spicy:14:5-14:56: &bit-order on bitfield item 'x1015_msb0' has no effect and is deprecated | ||
[warning] <...>/bit-bitorder.spicy:15:5-15:56: &bit-order on bitfield item 'x1015_lsb0' has no effect and is deprecated |
6 changes: 6 additions & 0 deletions
6
tests/Baseline/spicy.types.bitfield.parse-bitorder-endianness/output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
be_lsb0, (1, 2, 0, 4, 32, 32, 32) | ||
le_lsb0, (0, 1, 0, 3, 1, 1, 1) | ||
le_msb0, (0, 0, 1, 6, 2, 2, 2) | ||
le32_lsb0, (0, 0, 7, 5, 32, 0, 7, 8, 8, 8, 1) | ||
be32_msb0, (1, 3, 6, 2, 2, 5, 0, 15, 15, 15, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# @TEST-EXEC: spicyc -p -o /dev/null %INPUT 2>output | ||
# @TEST-EXEC: btest-diff output | ||
# | ||
# @TEST-DOC: Test deprecated "&bit-order" attribute on bits emits deprecation warning. | ||
|
||
module Mini; | ||
|
||
import spicy; | ||
|
||
public type X = unit { | ||
be16_lsb0: bitfield(16) { | ||
x0: 0; | ||
x1015: 10..15; | ||
x1015_msb0: 10..15 &bit-order=spicy::BitOrder::MSB0; | ||
x1015_lsb0: 10..15 &bit-order=spicy::BitOrder::LSB0; | ||
}; | ||
}; |
143 changes: 143 additions & 0 deletions
143
tests/spicy/types/bitfield/parse-bitorder-endianness.spicy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# @TEST-EXEC: echo "" | spicy-driver %INPUT >output | ||
# @TEST-EXEC: btest-diff output | ||
|
||
module Mini; | ||
|
||
import spicy; | ||
|
||
public type X = unit { | ||
|
||
be16_lsb0: bitfield(16) { | ||
x0: 0; # 1 | ||
x12: 1..2; # 2 10 | ||
x35: 3..5; # 0 | ||
x79: 7..9; # 4 100 ) | ||
x1015: 10..15; # 32 100000 | ||
x1015_msb0: 10..15 &bit-order=spicy::BitOrder::MSB0; # still 32 | ||
x1015_lsb0: 10..15 &bit-order=spicy::BitOrder::LSB0; # still 32 | ||
} &parse-from=b"\x82\x05" { | ||
# input 10000010 00000101 \x82\x05 | ||
# 1 0 | ||
# big-lsb0-bits 54321098 76543210 | ||
assert $$.x0 == 1; | ||
assert $$.x12 == 2; | ||
assert $$.x35 == 0; | ||
assert $$.x79 == 4; | ||
assert $$.x1015 == 32; | ||
assert $$.x1015_msb0 == 32; | ||
assert $$.x1015_lsb0 == 32; | ||
} | ||
|
||
le16_lsb0: bitfield(16) { | ||
x0: 0; # 0 | ||
x12: 1..2; # 1 | ||
x35: 3..5; # 0 | ||
x79: 7..9; # 3 011 | ||
x1015: 10..15; # 1 | ||
x1015_msb0: 10..15 &bit-order=spicy::BitOrder::MSB0; # still 1 | ||
x1015_lsb0: 10..15 &bit-order=spicy::BitOrder::LSB0; # still 1 | ||
} &byte-order=spicy::ByteOrder::Little | ||
&parse-from=b"\x82\x05" { | ||
# input 10000010 00000101 \x82\x05 | ||
# 1 1 | ||
# little-lsb0-bits 76543210 54321098 | ||
assert $$.x0 == 0; | ||
assert $$.x12 == 1; | ||
assert $$.x35 == 0; | ||
assert $$.x79 == 3; | ||
assert $$.x1015 == 1; | ||
assert $$.x1015_msb0 == 1; | ||
assert $$.x1015_lsb0 == 1; | ||
} | ||
|
||
le16_msb0: bitfield(16) { | ||
x0: 0; # 0 | ||
x12: 1..2; # 0 | ||
x35: 3..5; # 1 001 | ||
x79: 7..9; # 6 110 | ||
x1015: 10..15; # 2 000010 | ||
x1015_msb0: 10..15 &bit-order=spicy::BitOrder::MSB0; # still 2 | ||
x1015_lsb0: 10..15 &bit-order=spicy::BitOrder::LSB0; # still 2 | ||
} &byte-order=spicy::ByteOrder::Little | ||
&bit-order=spicy::BitOrder::MSB0 | ||
&parse-from=b"\x82\x05" { | ||
# input: 10000010 00000101 \x82\x05 | ||
# 1 0 | ||
# little-msb0-bits 89012345 01234567 | ||
assert $$.x0 == 0; | ||
assert $$.x12 == 0; | ||
assert $$.x35 == 1; | ||
assert $$.x79 == 6; | ||
assert $$.x1015_msb0 == 2; | ||
assert $$.x1015_lsb0 == 2; | ||
} | ||
|
||
le32_lsb0: bitfield(32) { | ||
x0: 0; | ||
x12: 1..2; | ||
x35: 3..5; # 7 111 | ||
x79: 7..9; # 5 101 | ||
x1015: 10..15; # 32 10000 | ||
x1923: 19..23; | ||
x2527: 25..27; # 7 111 | ||
x2831: 28..31; # 8 1000 | ||
x2831_msb0: 28..31 &bit-order=spicy::BitOrder::MSB0; # still 8 | ||
x2831_lsb0: 28..31 &bit-order=spicy::BitOrder::LSB0; # still 8 | ||
x31: 31; # 1 | ||
} &byte-order=spicy::ByteOrder::Little | ||
&parse-from=b"\xf8\x82\x05\x8f" { | ||
# LE is just confusing. | ||
# input: 11111000 10000010 00000101 10001111 \xf8\x82\x05\x8f | ||
# 1 2 3 | ||
# little-lsb0-bits 76543210 54321098 32109876 10987654 | ||
assert $$.x0 == 0; | ||
assert $$.x12 == 0; | ||
assert $$.x35 == 7; | ||
assert $$.x79 == 5; | ||
assert $$.x1015 == 32; | ||
assert $$.x1923 == 0; | ||
assert $$.x2527 == 7; | ||
assert $$.x2831 == 8; | ||
assert $$.x2831_msb0 == 8; | ||
assert $$.x2831_lsb0 == 8; | ||
assert $$.x31 == 1; | ||
} | ||
|
||
be32_msb0: bitfield(32) { | ||
x0: 0; | ||
x12: 1..2; | ||
x35: 3..5; | ||
x79: 7..9; | ||
x1015: 10..15; | ||
x1923: 19..23; | ||
x2527: 25..27; | ||
x2831: 28..31; | ||
x2831_msb0: 28..31 &bit-order=spicy::BitOrder::MSB0; | ||
x2831_lsb0: 28..31 &bit-order=spicy::BitOrder::LSB0; | ||
x31: 31; # 1 | ||
} &bit-order=spicy::BitOrder::MSB0 | ||
&parse-from=b"\xf8\x82\x05\x8f" { | ||
# input: 11111000 10000010 00000101 10001111 \xf8\x82\x05\x8f | ||
# 1 2 3 | ||
# big-msb0-bits 01234567 89012345 67890123 45678901 | ||
assert $$.x0 == 1; | ||
assert $$.x12 == 3; | ||
assert $$.x35 == 6; | ||
assert $$.x79 == 2; | ||
assert $$.x1015 == 2; | ||
assert $$.x1923 == 5; | ||
assert $$.x2527 == 0; | ||
assert $$.x2831 == 15; | ||
assert $$.x2831_msb0 == 15; | ||
assert $$.x2831_lsb0 == 15; | ||
assert $$.x31 == 1; | ||
} | ||
|
||
on %done { | ||
print "be_lsb0", self.be16_lsb0; | ||
print "le_lsb0", self.le16_lsb0; | ||
print "le_msb0", self.le16_msb0; | ||
print "le32_lsb0", self.le32_lsb0; | ||
print "be32_msb0", self.be32_msb0; | ||
} | ||
}; |