x393  1.0
FPGAcodeforElphelNC393camera
pulse_cross_clock.v
Go to the documentation of this file.
1 
41 `timescale 1ns/1ps
42 
44  parameter EXTRA_DLY=0 // for
45 )(
46  input rst,
47  input src_clk,
48  input dst_clk,
49  input in_pulse, // single-cycle positive pulse
50  output out_pulse,
51  output busy
52 );
53  localparam EXTRA_DLY_SAFE=EXTRA_DLY ? 1 : 0;
54 `ifndef IGNORE_ATTR
55  (* KEEP = "TRUE" *)
56 `endif
57  reg in_reg = 0; // can not be ASYNC_REG as it can not be put together with out_reg
58 //WARNING: [Constraints 18-1079] Register sensors393_i/sensor_channel_block[0].sensor_channel_i/sens_sync_i/pulse_cross_clock_trig_in_pclk_i/in_reg_reg
59 // and sensors393_i/sensor_channel_block[0].sensor_channel_i/sens_sync_i/pulse_cross_clock_trig_in_pclk_i/out_reg_reg[0] are
60 //from the same synchronizer and have the ASYNC_REG property set, but could not be placed into the same slice due to constraints
61 // or mismatched control signals on the registers.
62 
63 `ifndef IGNORE_ATTR
64  (* ASYNC_REG = "TRUE" *)
65 `endif
66  reg [2:0] out_reg = 0;
67 `ifndef IGNORE_ATTR
68  (* ASYNC_REG = "TRUE" *)
69 `endif
70  reg busy_r = 0;
71  assign out_pulse=out_reg[2];
72  assign busy=busy_r; // in_reg;
73  always @(posedge src_clk or posedge rst) begin
74  if (rst) in_reg <= 0;
75  else in_reg <= in_pulse || (in_reg && !out_reg[EXTRA_DLY_SAFE]);
76  if (rst) busy_r <= 0;
77  else busy_r <= in_pulse || in_reg || (busy_r && (|out_reg[EXTRA_DLY_SAFE:0]));
78  end
79 // always @(posedge dst_clk or posedge rst) begin
80  always @(posedge dst_clk) begin
81  out_reg <= {out_reg[0] & ~out_reg[1],out_reg[0],in_reg};
82  end
83 endmodule
84