Skip to content

make sure that the register size is always a power of 2 >= 8 #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 98 additions & 98 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ main() {
# test_svd MKV58F22
# test_svd MKV58F24

# BAD-SVD field names are equivalent when case is ignored
# test_svd MK61F15
# test_svd MK61F15WS
# test_svd MK70F12
# test_svd MK70F15
# test_svd MK70F15WS

# OK
# NOTE it would take too long to test all these so we only test half
test_svd MK02F12810
Expand Down Expand Up @@ -223,13 +230,6 @@ main() {
# test_svd MKW40Z4
# test_svd MKW41Z4

# FIXME(#105) "error[E0428]: a type named `NOT_USEDR` has already been defined in this module"
# test_svd MK61F15
# test_svd MK61F15WS
# test_svd MK70F12
# test_svd MK70F15
# test_svd MK70F15WS

# FIXME(#92) "duplicate definitions with name `bits`"
# test_svd MKE02Z2
# test_svd MKE02Z4
Expand Down Expand Up @@ -445,96 +445,96 @@ main() {

Spansion)
# OK
test_svd MB9AF12xK
test_svd MB9AF12xL
test_svd MB9AF42xK
test_svd MB9AF42xL
test_svd MB9BF12xJ
test_svd MB9BF12xS
test_svd MB9BF12xT
test_svd MB9BF16xx
test_svd MB9BF32xS
test_svd MB9BF32xT
test_svd MB9BF36xx
test_svd MB9BF42xS
test_svd MB9BF42xT
test_svd MB9BF46xx
test_svd MB9BF52xS
test_svd MB9BF52xT
test_svd MB9BF56xx

# FIXME(#102) "binary operation `>>` cannot be applied to type `bool`"
# test_svd MB9AF10xN
# test_svd MB9AF10xR
# test_svd MB9AF11xK
# test_svd MB9AF11xL
# test_svd MB9AF11xM
# test_svd MB9AF11xN
# test_svd MB9AF13xK
# test_svd MB9AF13xL
# test_svd MB9AF13xM
# test_svd MB9AF13xN
# test_svd MB9AF14xL
# test_svd MB9AF14xM
# test_svd MB9AF14xN
# test_svd MB9AF15xM
# test_svd MB9AF15xN
# test_svd MB9AF15xR
# test_svd MB9AF31xK
# test_svd MB9AF31xL
# test_svd MB9AF31xM
# test_svd MB9AF31xN
# test_svd MB9AF34xL
# test_svd MB9AF34xM
# test_svd MB9AF34xN
# test_svd MB9AFA3xL
# test_svd MB9AFA3xM
# test_svd MB9AFA3xN
# test_svd MB9AFA4xL
# test_svd MB9AFA4xM
# test_svd MB9AFA4xN
# test_svd MB9AFB4xL
# test_svd MB9AFB4xM
# test_svd MB9AFB4xN
# test_svd MB9BF10xN
# test_svd MB9BF10xR
# test_svd MB9BF11xN
# test_svd MB9BF11xR
# test_svd MB9BF11xS
# test_svd MB9BF11xT
# test_svd MB9BF12xK
# test_svd MB9BF12xL
# test_svd MB9BF12xM
# test_svd MB9BF21xS
# test_svd MB9BF21xT
# test_svd MB9BF30xN
# test_svd MB9BF30xR
# test_svd MB9BF31xN
# test_svd MB9BF31xR
# test_svd MB9BF31xS
# test_svd MB9BF31xT
# test_svd MB9BF32xK
# test_svd MB9BF32xL
# test_svd MB9BF32xM
# test_svd MB9BF40xN
# test_svd MB9BF40xR
# test_svd MB9BF41xN
# test_svd MB9BF41xR
# test_svd MB9BF41xS
# test_svd MB9BF41xT
# test_svd MB9BF50xN
# test_svd MB9BF50xR
# test_svd MB9BF51xN
# test_svd MB9BF51xR
# test_svd MB9BF51xS
# test_svd MB9BF51xT
# test_svd MB9BF52xK
# test_svd MB9BF52xL
# test_svd MB9BF52xM
# test_svd MB9BF61xS
# test_svd MB9BF61xT
# test_svd MB9BFD1xS
# test_svd MB9BFD1xT
# test_svd MB9AF12xK
# test_svd MB9AF12xL
# test_svd MB9AF42xK
# test_svd MB9AF42xL
# test_svd MB9BF12xJ
# test_svd MB9BF12xS
# test_svd MB9BF12xT
# test_svd MB9BF16xx
# test_svd MB9BF32xS
# test_svd MB9BF32xT
# test_svd MB9BF36xx
# test_svd MB9BF42xS
# test_svd MB9BF42xT
# test_svd MB9BF46xx
# test_svd MB9BF52xS
# test_svd MB9BF52xT
# test_svd MB9BF56xx

# #102 regression tests
test_svd MB9AF10xN
test_svd MB9AF10xR
test_svd MB9AF11xK
test_svd MB9AF11xL
test_svd MB9AF11xM
test_svd MB9AF11xN
test_svd MB9AF13xK
test_svd MB9AF13xL
test_svd MB9AF13xM
test_svd MB9AF13xN
test_svd MB9AF14xL
test_svd MB9AF14xM
test_svd MB9AF14xN
test_svd MB9AF15xM
test_svd MB9AF15xN
test_svd MB9AF15xR
test_svd MB9AF31xK
test_svd MB9AF31xL
test_svd MB9AF31xM
test_svd MB9AF31xN
test_svd MB9AF34xL
test_svd MB9AF34xM
test_svd MB9AF34xN
test_svd MB9AFA3xL
test_svd MB9AFA3xM
test_svd MB9AFA3xN
test_svd MB9AFA4xL
test_svd MB9AFA4xM
test_svd MB9AFA4xN
test_svd MB9AFB4xL
test_svd MB9AFB4xM
test_svd MB9AFB4xN
test_svd MB9BF10xN
test_svd MB9BF10xR
test_svd MB9BF11xN
test_svd MB9BF11xR
test_svd MB9BF11xS
test_svd MB9BF11xT
test_svd MB9BF12xK
test_svd MB9BF12xL
test_svd MB9BF12xM
test_svd MB9BF21xS
test_svd MB9BF21xT
test_svd MB9BF30xN
test_svd MB9BF30xR
test_svd MB9BF31xN
test_svd MB9BF31xR
test_svd MB9BF31xS
test_svd MB9BF31xT
test_svd MB9BF32xK
test_svd MB9BF32xL
test_svd MB9BF32xM
test_svd MB9BF40xN
test_svd MB9BF40xR
test_svd MB9BF41xN
test_svd MB9BF41xR
test_svd MB9BF41xS
test_svd MB9BF41xT
test_svd MB9BF50xN
test_svd MB9BF50xR
test_svd MB9BF51xN
test_svd MB9BF51xR
test_svd MB9BF51xS
test_svd MB9BF51xT
test_svd MB9BF52xK
test_svd MB9BF52xL
test_svd MB9BF52xM
test_svd MB9BF61xS
test_svd MB9BF61xT
test_svd MB9BFD1xS
test_svd MB9BFD1xT
;;

STMicro)
Expand Down Expand Up @@ -579,7 +579,7 @@ main() {
test_svd STM32L4x6
test_svd STM32W108

# FIXME(???) "field is never used: `register`"
# FIXME(#91) "field is never used: `register`"
# test_svd STM32L051x
# test_svd STM32L052x
# test_svd STM32L053x
Expand Down
7 changes: 7 additions & 0 deletions src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ pub fn register(
format!("Register {} has no `size` field",
register.name)
})?;
let rsize = if rsize < 8 {
8
} else if rsize.is_power_of_two() {
rsize
} else {
rsize.next_power_of_two()
};
let rty = rsize.to_ty()?;
let description = util::respace(&register.description);

Expand Down