SpiClkMux.v 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //////////////////////////////////////////////////////////////////////////////////
  2. // Company: TAIR
  3. // Engineer:
  4. //
  5. // Create Date: 10/30/2023 11:24:31 AM
  6. // Design Name:
  7. // Module Name: SpiClkMux
  8. // Project Name: S5443_V3_FPGA3
  9. // Target Devices: BOARD: BY5443v3. FPGA: xc7s25csga225-2
  10. // Tool Versions:
  11. // Description: This module muxes clock based on a clkCh signal - MMCM or
  12. // from a custom divider.
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 1.0 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21. module SpiClkMux (
  22. input Rst_i,
  23. input clkCh,
  24. input clkOutMMCM,
  25. input clkMan,
  26. output SpiClk_o
  27. );
  28. //================================================================================
  29. // REG/WIRE
  30. //================================================================================
  31. reg spiClkReg;
  32. wire spiClk;
  33. //================================================================================
  34. // ASSIGNMENTS
  35. //===============================================================================
  36. assign spiClk = spiClkReg;
  37. //================================================================================
  38. // CODING
  39. //================================================================================
  40. // always @(*) begin
  41. // if (Rst_i) begin
  42. // spiClkReg = 0;
  43. // end
  44. // else begin
  45. // if (clkCh) begin
  46. // spiClkReg = clkOutMMCM;
  47. // end
  48. // else begin
  49. // spiClkReg = clkMan;
  50. // end
  51. // end
  52. // end
  53. // BUFG BUFG_inst (
  54. // .O(SpiClk_o), // 1-bit output: Clock output
  55. // .I(spiClk) // 1-bit input: Clock input
  56. // );
  57. BUFGMUX #(
  58. )
  59. BUFGMUX_inst (
  60. .O(SpiClk_o), // 1-bit output: Clock output
  61. .I0(clkMan), // 1-bit input: Clock input (S=0)
  62. .I1(clkOutMMCM), // 1-bit input: Clock input (S=1)
  63. .S(clkCh) // 1-bit input: Clock select
  64. );
  65. endmodule