hub75_timing.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/usr/bin/env python3
  2. import argparse
  3. OVERHEAD = 5 # Guesstimated
  4. class PanelConfig(object):
  5. def __init__(self, **kwargs):
  6. params = [
  7. 'freq', # Clock frequency in Hz
  8. 'n_banks', # Number of banks
  9. 'n_rows', # Number of rows
  10. 'n_cols', # Number of columns
  11. 'n_planes', # Number of bitplanes in BCM modulation
  12. 'bcm_lsb_len', # Duration of the LSB of BCM modulation (in clk cycles)
  13. ]
  14. for x in params:
  15. setattr(self, x, kwargs.pop(x))
  16. self._sim()
  17. def _sim(self):
  18. # Init
  19. cyc_tot = 0
  20. cyc_on = 0
  21. # Scan all place
  22. for plane in range(self.n_planes):
  23. # Length of the plane in clock cycle
  24. len_show = self.bcm_lsb_len << plane
  25. # Length required to do data shift for the next plane
  26. len_shift = self.n_cols
  27. # Length of this cycle is the max
  28. len_plane = max(len_show, len_shift) + OVERHEAD
  29. # Accumulate
  30. cyc_tot += len_plane
  31. cyc_on += len_show
  32. # Compute results
  33. self._light_efficiency = 1.0 * cyc_on / cyc_tot
  34. self._refresh_rate = self.freq / (self.n_rows * cyc_tot)
  35. @property
  36. def light_efficiency(self):
  37. return self._light_efficiency
  38. @property
  39. def refresh_rate(self):
  40. return self._refresh_rate
  41. def main():
  42. # Parse options
  43. parser = argparse.ArgumentParser()
  44. parser.add_argument('--freq', type=float, help='Clock frequency in Hz', default=30e6)
  45. parser.add_argument('--n_banks', type=int, required=True, metavar='N', help='Number of banks')
  46. parser.add_argument('--n_rows', type=int, required=True, metavar='N', help='Number of rows')
  47. parser.add_argument('--n_cols', type=int, required=True, metavar='N', help='Number of columns')
  48. parser.add_argument('--n_planes', type=int, required=True, metavar='N', help='Number of bitplanes in BCM modulation')
  49. parser.add_argument('--bcm_min_len',type=int, metavar='CYCLES', help='Min duration of the LSB of BCM modulation (in clk cycles, default=1)', default=1)
  50. parser.add_argument('--bcm_max_len',type=int, metavar='CYCLES', help='Max duration of the LSB of BCM modulation (in clk cycles, default=20)', default=20)
  51. args = parser.parse_args()
  52. # Scan various bcm_lsb_len
  53. print("bcm_lsb_len\tlight_efficiency\trefresh_rate")
  54. for i in range(args.bcm_min_len, args.bcm_max_len+1):
  55. pc = PanelConfig(
  56. freq = args.freq,
  57. n_banks = args.n_banks,
  58. n_rows = args.n_rows,
  59. n_cols = args.n_cols,
  60. n_planes = args.n_planes,
  61. bcm_lsb_len = i,
  62. )
  63. print("%2d\t\t%4.1f\t\t\t%5.1f" % (
  64. i,
  65. pc.light_efficiency * 100.0,
  66. pc.refresh_rate
  67. ))
  68. if __name__ == '__main__':
  69. main()