sysmgr.v 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * sysmgr.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * Copyright (C) 2019-2020 Sylvain Munaut <tnt@246tNt.com>
  7. * SPDX-License-Identifier: CERN-OHL-P-2.0
  8. */
  9. `default_nettype none
  10. module sysmgr (
  11. input wire clk_in,
  12. input wire rst_in,
  13. output wire clk_24m,
  14. output wire clk_48m,
  15. output wire rst_out
  16. );
  17. // Signals
  18. wire pll_lock;
  19. wire pll_reset_n;
  20. wire clk_24m_i;
  21. wire clk_48m_i;
  22. wire rst_i;
  23. reg [3:0] rst_cnt;
  24. // PLL instance
  25. SB_PLL40_2F_PAD #(
  26. .DIVR(4'b0000),
  27. .DIVF(7'b0111111),
  28. .DIVQ(3'b100),
  29. .FILTER_RANGE(3'b001),
  30. .FEEDBACK_PATH("SIMPLE"),
  31. .DELAY_ADJUSTMENT_MODE_FEEDBACK("FIXED"),
  32. .FDA_FEEDBACK(4'b0000),
  33. .SHIFTREG_DIV_MODE(2'b00),
  34. .PLLOUT_SELECT_PORTA("GENCLK"),
  35. .PLLOUT_SELECT_PORTB("GENCLK_HALF"),
  36. .ENABLE_ICEGATE_PORTA(1'b0),
  37. .ENABLE_ICEGATE_PORTB(1'b0)
  38. ) pll_I (
  39. .PACKAGEPIN(clk_in),
  40. .PLLOUTCOREA(),
  41. .PLLOUTGLOBALA(clk_48m_i),
  42. .PLLOUTCOREB(),
  43. .PLLOUTGLOBALB(clk_24m_i),
  44. .EXTFEEDBACK(1'b0),
  45. .DYNAMICDELAY(8'h00),
  46. .RESETB(pll_reset_n),
  47. .BYPASS(1'b0),
  48. .LATCHINPUTVALUE(1'b0),
  49. .LOCK(pll_lock),
  50. .SDI(1'b0),
  51. .SDO(),
  52. .SCLK(1'b0)
  53. );
  54. assign clk_24m = clk_24m_i;
  55. assign clk_48m = clk_48m_i;
  56. // PLL reset generation
  57. assign pll_reset_n = ~rst_in;
  58. // Logic reset generation
  59. always @(posedge clk_24m_i or negedge pll_lock)
  60. if (!pll_lock)
  61. rst_cnt <= 4'h0;
  62. else if (~rst_cnt[3])
  63. rst_cnt <= rst_cnt + 1;
  64. assign rst_i = ~rst_cnt[3];
  65. SB_GB rst_gbuf_I (
  66. .USER_SIGNAL_TO_GLOBAL_BUFFER(rst_i),
  67. .GLOBAL_BUFFER_OUTPUT(rst_out)
  68. );
  69. endmodule // sysmgr