x393  1.0
FPGAcodeforElphelNC393camera
clk_to_clk2x.v
Go to the documentation of this file.
1 
39 `timescale 1ns/1ps
40 
41 module clk_to_clk2x(
42  input clk, // single rate clock
43  input clk2x, // double rate clock, approximately posedge aligned to clk
44  output clk_sync // approximately repeating clk, clocked @posedge clk2x - use as CE to transfer data
45 );
46 
47  reg r_clk = 0;
48  reg r_nclk2x = 0;
49  reg r_clk2x;
50 
51  assign clk_sync=r_clk2x;
52 
53  always @(posedge r_nclk2x or posedge clk) begin
54  if (r_nclk2x) r_clk <= 0;
55  else r_clk <= 1;
56  end
57 
58  always @(negedge clk2x) r_nclk2x <= r_clk;
59  always @(posedge clk2x) r_clk2x <= !r_nclk2x;
60 
61 endmodule
62