Skip to content

Instantly share code, notes, and snippets.

@thegcat
Created December 1, 2011 15:09
Show Gist options
  • Save thegcat/1417451 to your computer and use it in GitHub Desktop.
Save thegcat/1417451 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
msb, memsize = 31, nil
puts File.open('mpsoc_top.xdl', 'r').each_line.collect {|line| line.scan(/inst "([^\s\"]+)".*RAMB16_([\w\d]+)/)[0]}.compact.tap {|mems| memsize = mems.count}.collect {|mem0,mem1| " #{mem0} [#{msb}:#{(msb = msb - 32 / memsize) + 1}] PLACED = #{mem1}"}.unshift("ADDRESS_SPACE lmb_bram_#{memsize} RAMB16 [0x00000000:0x0000#{(2048*memsize-1).to_s(16)}]", " BUS_BLOCK").push(" END_BUS_BLOCK;", "END_ADDRESS_SPACE;").join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment