Skip to content

Instantly share code, notes, and snippets.

@koyamalmsteen
Last active October 17, 2018 02:39
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/b27f55f258e2a67c09d9861ac41cbfa2 to your computer and use it in GitHub Desktop.
Save koyamalmsteen/b27f55f258e2a67c09d9861ac41cbfa2 to your computer and use it in GitHub Desktop.
module SpiIf(clk,cs,shift,ncs,sck,sdi,sdo,q);
input clk,cs,shift,sdo;
output ncs,sck,sdi;
output [9:0] q;
reg [9:0] sreg;
assign ncs=~cs;
assign sdi=1'b1;
assign sck=cs & clk;
always@(posedge clk) begin
if((cs==1'b1) && (shift==1'b1))
sreg={sreg[8:0],sdo};
end
assign q=sreg;
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment