diff options
author | Eric Anholt <eric@anholt.net> | 2007-10-18 11:17:38 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2007-10-18 11:29:24 -0700 |
commit | 1f8bf110394cc1df66aae9acf5c818145ae19b52 (patch) | |
tree | 39f44dfec7bf05a91023089a939be4e5b73384c8 | |
parent | 79636b8c776ae024518103c9fa137c8498c21d48 (diff) |
Add some nickle scripts for looking at PLL issues.
While here, move similar nickle scripts under src/scripts/
-rw-r--r-- | src/scripts/clock-graph.5c | 148 | ||||
-rw-r--r-- | src/scripts/clock.5c | 40 | ||||
-rw-r--r-- | src/scripts/fix.5c (renamed from src/fix.5c) | 0 | ||||
-rw-r--r-- | src/scripts/tv.5c (renamed from src/tv.5c) | 0 |
4 files changed, 188 insertions, 0 deletions
diff --git a/src/scripts/clock-graph.5c b/src/scripts/clock-graph.5c new file mode 100644 index 00000000..98500e1e --- /dev/null +++ b/src/scripts/clock-graph.5c @@ -0,0 +1,148 @@ +autoload Cairo; +import Cairo; +library "examples/sort.5c"; +import Sort; + +int width = 1000, height = 200; + +int min = 0xffffffff; +int max = 0; + +int max_clocks = 1000; +int[4][max_clocks] clocks; +int[4] clock_count = {0...}; + +int[4] p2vals = {5,10,7,14}; + +cairo_t cr = Cairo::new(width, height); + +void calc_p2(int p2i) +{ + int p2 = p2vals[p2i]; + int min_p, max_p; + + clocks[p2i] = (int [max_clocks]){0...}; + + if (p2 == 7 || p2 == 14) { + /* LVDS */ + min_p = 7; + max_p = 98; + } else { + /* SDVO/DAC */ + min_p = 5; + max_p = 80; + } + + for (int m1 = 10; m1 <= 20; m1++) { + for (int m2 = 5; m2 <= 9; m2++) { + for (int n = 3; n <= 8; n++) { + for (int p1 = 1; p1 <= 8; p1++) { + int ref = 96000000; + int m = 5 * (m1 + 2) + (m2 + 2); + int p = p1 * p2; + int vco = floor(ref * m / (n + 2)); + int clock = floor(vco / p); + + if (p < min_p || p > max_p) + continue; + if (m < 70 || m > 120) + continue; + if (m2 > m1) + continue; /* won't happen */ + if (vco < 1400000000 || + vco > 2800000000) + continue; + +/* + printf("clock: %d (%d,%d), %d, " + "(%d,%d)\n", + floor(clock / 1000), + m1, m2, n, p1, p2); +*/ + + clocks[p2i][clock_count[p2i]] = clock; + clock_count[p2i]++; + } + } + } + } +} + +bool sort_p2(poly a, poly b) +{ + return a > b; +} + +int min_rate = 25000 * 1000; +int max_rate = 200000 * 1000; + +real scale_x(real clock) +{ + int min_x = 75, max_x = width - 50; + + real frac = (clock - min_rate) / (max_rate - min_rate); + + return min_x + frac * (max_x - min_x); +} + +for (p2i = 0; p2i < dim(p2vals); p2i++) { + int p2 = p2vals[p2i]; + calc_p2(p2i); + /*qsort(&p2vals[p2i], sort_p2);*/ + + switch (p2) { + case 5: + set_source_rgb(cr, 1,0,0); + break; + case 10: + set_source_rgb(cr, 0,1,0); + break; + case 7: + set_source_rgb(cr, 0,0,1); + break; + case 14: + set_source_rgb(cr, 0,0,0); + break; + } + for (int i = 0; i < clock_count[p2i]; i++) { + int clock = clocks[p2i][i]; + real xpos; + + if (clock < min_rate || clock > max_rate) + continue; + + xpos = scale_x(clock); + move_to(cr, xpos, p2i / (dim(p2vals) + 1) * height); + line_to(cr, xpos, (p2i + 1) / (dim(p2vals) + 1) * height); + stroke(cr); + } + + set_source_rgb(cr, 0, 0, 0); + string p2label = sprintf("p2 = %d", p2); + move_to(cr, 5, (p2i + .5) / (dim(p2vals) + 1) * height + 4); + show_text(cr, p2label); +} + +void label_clock(real clock) { + real center_x = scale_x(clock); + string label = sprintf("%d", floor((clock + 500) / 1000000)); + text_extents_t e = text_extents(cr, label); + real left_x = center_x - e.x_advance / 2; + save(cr); + move_to(cr, left_x, height - 20); + show_text(cr, label); + restore(cr); +} + +label_clock(min_rate); +label_clock(max_rate); +label_clock(140 * 1000 * 1000); +label_clock(115 * 1000 * 1000); +label_clock(100 * 1000 * 1000); +label_clock(82 * 1000 * 1000); + +string xlabel = "Clock in Mhz"; +text_extents_t e = text_extents(cr, xlabel); +move_to(cr, width / 2 - e.x_advance / 2, height - 5); +show_text(cr, xlabel); +sleep(10); diff --git a/src/scripts/clock.5c b/src/scripts/clock.5c new file mode 100644 index 00000000..8ee9d90e --- /dev/null +++ b/src/scripts/clock.5c @@ -0,0 +1,40 @@ +int p2 = 14; +int min_p, max_p; + +if (p2 == 7 || p2 == 14) { + /* LVDS */ + min_p = 7; + max_p = 98; +} else { + /* SDVO/DAC */ + min_p = 5; + max_p = 80; +} + +for (int m1 = 10; m1 <= 20; m1++) { + for (int m2 = 5; m2 <= 9; m2++) { + for (int n = 3; n <= 8; n++) { + for (int p1 = 1; p1 <= 8; p1++) { + int ref = 96000000; + int m = 5 * (m1 + 2) + (m2 + 2); + int p = p1 * p2; + int vco = floor(ref * m / (n + 2)); + int clock = floor(vco / p); + + if (p < min_p || p > max_p) + continue; + if (m < 70 || m > 120) + continue; + if (m2 > m1) + continue; /* won't happen */ + if (vco < 1400000000 || + vco > 2800000000) + continue; + + printf("clock: %d (%d,%d),%d,(%d,%d)\n", + floor(clock / 1000), + m1, m2, n, p1, p2); + } + } + } +} diff --git a/src/fix.5c b/src/scripts/fix.5c index b758a433..b758a433 100644 --- a/src/fix.5c +++ b/src/scripts/fix.5c diff --git a/src/tv.5c b/src/scripts/tv.5c index b4a2ba61..b4a2ba61 100644 --- a/src/tv.5c +++ b/src/scripts/tv.5c |