Skip to content

Instantly share code, notes, and snippets.

@coldcue
Created October 27, 2014 11:44
Show Gist options
  • Save coldcue/037b1eb4c1ec99089b75 to your computer and use it in GitHub Desktop.
Save coldcue/037b1eb4c1ec99089b75 to your computer and use it in GitHub Desktop.
//Process started
reg started;
//////////////
// States
// 0: load
// 1: start bit
// 2..8: data
// 9: parity bit
// 10..11: stop bits
//////////////
reg [3:0] state;
always @ (posedge clk) begin
if(rst) begin
state <= 4'b0;
started <= 0;
end
else if(start)
started <= start;
if(ce & shr_load & started) begin
state <= 1;
started <= 0;
end
else if(ce & state == 11)
state <= 4'b0;
else if(shr_ce)
state <= state + 1;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment