You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.8 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. `include "../config.v"
  2. module genlock_input_module #(
  3. parameter REG_START_ADD = 0,
  4. parameter SYS_CLOCK_FREQ = 10000000
  5. ) (
  6. input clk, //! 时钟输入
  7. input rst_n, //! 复位输入
  8. input [31:0] addr, //! 寄存器地址
  9. input [31:0] wr_data, //! 写入数据
  10. input wr_en, //! 写使能
  11. output wire [31:0] rd_data, //! 读出数据
  12. input genlock_in_hsync, //! genlock hsync
  13. input genlock_in_vsync, //! genlock vsync
  14. input genlock_in_fsync, //! genlock fsync
  15. output genlock_freq_signal, //! genlock freq signal
  16. output genlock_in_state_led
  17. );
  18. reg [31:0] r1_genlock_freq_detect_bias;
  19. wire [31:0] r2_genlock_freq;
  20. wire [31:0] reg_wr_index;
  21. zutils_register_advanced #(
  22. .REG_START_ADD(REG_START_ADD)
  23. ) _register (
  24. .clk (clk),
  25. .rst_n (rst_n),
  26. .addr (addr),
  27. .wr_data (wr_data),
  28. .wr_en (wr_en),
  29. .rd_data (rd_data),
  30. .reg1 (r1_genlock_freq_detect_bias),
  31. .reg2 (r2_genlock_freq),
  32. .reg_wr_sig(reg_wr_sig),
  33. .reg_index (reg_wr_index)
  34. );
  35. always @(posedge clk or negedge rst_n) begin
  36. if (!rst_n) begin
  37. r1_genlock_freq_detect_bias <= `FREQ_DETECT_BIAS_DEFAULT;
  38. end else begin
  39. if (reg_wr_sig) begin
  40. case (reg_wr_index)
  41. 1: r1_genlock_freq_detect_bias <= wr_data;
  42. default: begin
  43. end
  44. endcase
  45. end
  46. end
  47. end
  48. zutils_freq_detector_v2 freq_detector1 (
  49. .clk (clk),
  50. .rst_n (rst_n),
  51. .freq_detect_bias(r1_genlock_freq_detect_bias),
  52. .pluse_input (genlock_in_vsync),
  53. .pluse_width_cnt (r2_genlock_freq)
  54. );
  55. assign genlock_freq_signal = genlock_in_vsync;
  56. assign genlock_in_state_led = 1;
  57. endmodule