Skip to content

Instantly share code, notes, and snippets.

@buttercutter
Created October 12, 2017 09:27
Show Gist options
  • Save buttercutter/2d5d42b0d36e25b63849579fd78f9b2e to your computer and use it in GitHub Desktop.
Save buttercutter/2d5d42b0d36e25b63849579fd78f9b2e to your computer and use it in GitHub Desktop.
module detect_start_bit(clk, serial_in, start_detected); // just a falling edge detector
input clk, serial_in;
output reg start_detected = 0;
reg previously_idle = 1;
always @(posedge clk)
begin
if((!serial_in) && (previously_idle) && (!start_detected))
start_detected <= 1;
else
start_detected <= 0;
end
always @(posedge clk)
begin
if(serial_in)
previously_idle <= 1;
else
previously_idle <= 0;
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment