x393  1.0
FPGAcodeforElphelNC393camera
elastic_cross_clock.v
Go to the documentation of this file.
1 
45 `timescale 1ns/1ps
46 
48  parameter WIDTH=2, // width of the pulse counter
49  parameter EXTRA_DLY=0)( // 0 or 1 - output duty cycle control
50  input rst,
51  input src_clk,
52  input dst_clk,
53  input in_pulses,
54  output out_pulse,
55  output busy
56 );
57  reg [WIDTH-1:0] pend_cntr=0;
60 
61 // assign busy = busy_single && (|pend_cntr);
62  assign busy = busy_single || (|pend_cntr);
63  assign single_rq_w = !busy_single && ((|pend_cntr) || in_pulses);
64 
65  always @(posedge src_clk) begin
66  if (rst) pend_cntr <= 0;
67  else if ( in_pulses && !single_rq_w) pend_cntr <= pend_cntr + 1;
68  else if (!in_pulses && single_rq_w) pend_cntr <= pend_cntr - 1;
69  end
70 
73  ) pulse_cross_clock_i (
74  .rst (rst), // input
75  .src_clk (src_clk), // input
76  .dst_clk (dst_clk), // input
77  .in_pulse (single_rq_w), // input
78  .out_pulse (out_pulse), // output
79  .busy (busy_single) // output
80  );
81 
82 endmodule
83 
pulse_cross_clock_i pulse_cross_clock
10362pend_cntrreg[WIDTH-1:0]