Skip to content

Instantly share code, notes, and snippets.

@wolfmanjm
Last active May 15, 2025 14:05
Show Gist options
  • Save wolfmanjm/1a789cbd6d5b5fc32f952ca3188ae01b to your computer and use it in GitHub Desktop.
Save wolfmanjm/1a789cbd6d5b5fc32f952ca3188ae01b to your computer and use it in GitHub Desktop.
File.foreach('RP2350.svd') do |line|
if line.include?('<bitRange>')
# Extract range from <bitRange>[31:0]</bitRange>
range_match = line.match(/\[(\d+):(\d+)\]/)
if range_match
hr = range_match[1].to_i
lr = range_match[2].to_i
puts "<bitOffset>#{lr}</bitOffset>"
puts "<bitWidth>#{(hr - lr) + 1}</bitWidth>"
end
end
puts line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment