2015-11-14 22:41:19 -05:00
|
|
|
/* Detects the common aligned positive edge for a
|
2015-11-14 23:33:48 -05:00
|
|
|
* slow/fast clocks. The circuit uses the negedge of the fast clock
|
|
|
|
* to sample the slow clock. Output is positive edge sampled.
|
2015-11-14 22:41:19 -05:00
|
|
|
*
|
|
|
|
* NOTE: Assumes clocks are aligned and synchronous!
|
|
|
|
*
|
|
|
|
* ___________ ___________
|
2015-11-14 23:33:48 -05:00
|
|
|
* __/ \___________/ \ SLOWCLK
|
2015-11-14 22:41:19 -05:00
|
|
|
* __ __ __ __ __ __
|
2015-11-14 23:33:48 -05:00
|
|
|
* _/ \__/ \__/ \__/ \__/ \__/ \__/ FASTCLK
|
|
|
|
* ___________ _________
|
|
|
|
* ___/ 1 1 \_0_____0____/ CLK45
|
|
|
|
* ____________ ___
|
|
|
|
* ______/ 1 1 \___0____0___/ CLK90
|
2015-11-14 22:41:19 -05:00
|
|
|
*
|
2015-11-14 23:33:48 -05:00
|
|
|
* ____ ______
|
|
|
|
* \________________/ \________ FIRSTEDGE
|
|
|
|
*
|
|
|
|
*
|
2015-11-14 22:41:19 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-11-30 13:45:49 -05:00
|
|
|
module oh_edgealign (/*AUTOARG*/
|
2015-11-14 22:41:19 -05:00
|
|
|
// Outputs
|
|
|
|
firstedge,
|
|
|
|
// Inputs
|
|
|
|
fastclk, slowclk
|
|
|
|
);
|
|
|
|
|
|
|
|
input fastclk;
|
|
|
|
input slowclk;
|
|
|
|
output firstedge;
|
|
|
|
|
|
|
|
reg clk45;
|
2015-11-14 23:33:48 -05:00
|
|
|
reg clk90;
|
2015-11-14 22:41:19 -05:00
|
|
|
reg firstedge;
|
|
|
|
|
|
|
|
always @ (negedge fastclk)
|
2015-11-14 23:33:48 -05:00
|
|
|
clk45 <= slowclk;
|
|
|
|
|
|
|
|
always @ (posedge fastclk)
|
2015-11-14 22:41:19 -05:00
|
|
|
begin
|
2015-11-14 23:33:48 -05:00
|
|
|
clk90 <= clk45;
|
|
|
|
firstedge <= ~clk45 & clk90;
|
2015-11-14 22:41:19 -05:00
|
|
|
end
|
2015-11-14 23:33:48 -05:00
|
|
|
|
2015-11-30 13:45:49 -05:00
|
|
|
//TODO: parametrized based on 1/N ratios?
|
|
|
|
//TODO: can we do this without using clock as data input?
|
2015-11-14 22:41:19 -05:00
|
|
|
|
2015-11-30 13:45:49 -05:00
|
|
|
|
|
|
|
endmodule // oh_edgealign
|
|
|
|
|
2015-11-14 22:41:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
|