Advertisement
STANAANDREY

Edgedetect2 but within the same clock cycle

Aug 19th, 2024
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module top_module (
  2.     input clk,
  3.     input [7:0] in,
  4.     output reg [7:0] anyedge
  5. );
  6.     reg [7:0] aux;
  7.  
  8.     always @(posedge clk) begin
  9.         anyedge <= aux ^ in;  // Detect edge by XORing current and previous state
  10.         aux <= in;            // Update aux with the current state of 'in'
  11.     end
  12. endmodule
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement