Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add synchronizer for external levels. Now we're cooking!
- Loading branch information
ian
committed
May 26, 2019
1 parent
10434fa
commit 48d8758
Showing
4 changed files
with
145 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//https://electronics.stackexchange.com/questions/102646/how-to-efficiently-implement-a-single-output-pulse-from-a-long-input-on-altera | ||
`ifndef __SYNCHRONIZER__ | ||
`define __SYNCHRONIZER__ | ||
module sync( | ||
input wire clock, | ||
input wire i, | ||
output wire o | ||
); | ||
reg r1, r2, r3; | ||
|
||
always @(posedge clock) begin | ||
r1 <= i; // first stage of 2-stage synchronizer | ||
r2 <= r1; // second stage of 2-stage synchronizer | ||
r3 <= r2; // edge detector memory | ||
end | ||
assign o = (r2 && !r3); | ||
endmodule | ||
`endif |