diff options
| author | Julian Blake Kongslie | 2021-04-18 16:00:54 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2021-04-18 16:12:38 -0700 |
| commit | 5742e1f66c4e70151865de7092547223898bbf6b (patch) | |
| tree | 5c4208eb0a32c985e1aa22e230b20fc780234152 /pll.rb | |
| parent | Move the core logic out of the top module. (diff) | |
| download | noncpu-5742e1f66c4e70151865de7092547223898bbf6b.tar.xz | |
Support a proper PDP-8 assembler.
Diffstat (limited to 'pll.rb')
| -rwxr-xr-x | pll.rb | 23 |
1 files changed, 0 insertions, 23 deletions
| @@ -1,23 +0,0 @@ | |||
| 1 | #!/usr/bin/ruby -w | ||
| 2 | |||
| 3 | TARGET_FREQ = ARGV.shift.to_f | ||
| 4 | NATIVE_FREQ = 50.0 | ||
| 5 | |||
| 6 | CLOCK_WIDTH = 5 | ||
| 7 | |||
| 8 | best = nil | ||
| 9 | best_mult = nil | ||
| 10 | best_div = nil | ||
| 11 | 1.upto(2**CLOCK_WIDTH) do | mult | | ||
| 12 | 1.upto(2**CLOCK_WIDTH) do | div | | ||
| 13 | new = NATIVE_FREQ * mult / div | ||
| 14 | if not best or (new - TARGET_FREQ).abs < (best - TARGET_FREQ).abs or ((new - TARGET_FREQ).abs == (best - TARGET_FREQ).abs and (mult + div) < (best_mult + best_div)) | ||
| 15 | best = new | ||
| 16 | best_mult = mult | ||
| 17 | best_div = div | ||
| 18 | end | ||
| 19 | end | ||
| 20 | end | ||
| 21 | |||
| 22 | error = (best - TARGET_FREQ).abs / TARGET_FREQ | ||
| 23 | $stdout.write("Closest I can get is #{best}: *#{best_mult} /#{best_div} (#{(error * 100).round}% error)\n") | ||
