Skip to content

Instantly share code, notes, and snippets.

@koyamalmsteen
Last active October 17, 2018 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koyamalmsteen/ece53dce411cb8aee48122031abf4cb5 to your computer and use it in GitHub Desktop.
Save koyamalmsteen/ece53dce411cb8aee48122031abf4cb5 to your computer and use it in GitHub Desktop.
module TimingGenerator(clk,cs,shift,ld);
input clk;
output cs,shift,ld;
reg rcs;
reg [3:0] cnt;
always @(posedge clk) begin
cnt=cnt+1;
end
//cs ff
always @(negedge clk) begin
if(cnt==4'h0) begin
rcs=1'b1;
end
else begin
if(cnt==4'd15) begin
rcs=1'b0;
end
end
end
assign cs=rcs;
assign ld=(cnt==4'd15) ? 1'b1 : 1'b0;
assign shift=((cnt>=4'd5) && (cnt<=4'd14)) ? 1'b1 : 1'b0;
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment