Add comments.
This commit is contained in:
19
spi_slave.sv
19
spi_slave.sv
@@ -1,3 +1,14 @@
|
||||
/**
|
||||
* Specialized SPI slave.
|
||||
* Reads width bits at a time, and sets the ready flag
|
||||
* whenever a full 32 bits has been read. Also, recognizes
|
||||
* 0x00 as a pattern, and when full 0s are read, sets the done flag.
|
||||
* 0x00 is a special value in the CPU programming process that indicates
|
||||
* end-of-program.
|
||||
*
|
||||
* master_clk, ss, and mosi are all SPI-specific inputs.
|
||||
* data should only be read when ready is high.
|
||||
*/
|
||||
module spi_slave #(width=32)
|
||||
(input logic clk, reset,
|
||||
input logic master_clk, ss, mosi,
|
||||
@@ -7,7 +18,7 @@ module spi_slave #(width=32)
|
||||
logic [width-1:0] storage;
|
||||
logic unsigned [$clog2(width)-1:0] counter;
|
||||
logic old_clk;
|
||||
|
||||
|
||||
always_ff@(posedge clk)
|
||||
if(reset) begin
|
||||
counter <= 0;
|
||||
@@ -30,7 +41,7 @@ module spi_slave #(width=32)
|
||||
end
|
||||
old_clk <= master_clk;
|
||||
end
|
||||
|
||||
|
||||
assign data = storage;
|
||||
|
||||
endmodule
|
||||
|
||||
endmodule
|
||||
|
||||
Reference in New Issue
Block a user