always @ (posedge sck)
case(state)
RDY:
if (get) begin
ss <= 0;
state <= RECEIVE;
busy <= 1;
ready <= 0;
data_temp <= 0;
index <= data_length - 1;
end
RECEIVE: begin
if(index == 0) state <= STOP;
data_temp [index] <= miso;
index <= index -1;
end
STOP: begin
busy <= 0;
ready <= 1;
ss <= 1;
data_temp <= 0;
data <= data_temp;
state <= RDY;
end
endcase
endmodule
always @ (posedge sck)
case(state)
TRACK:
if(delay == 0) begin
get <= 1;
state <= GETIN;
end else delay <= delay - 1'b1;
GETIN:
if(ready == 1) begin
get <= 0;
lightdata <= data;
delay <= 2000 * delaytime;
state <= TRACK;
end
endcase
assign led = {thos, huns, tens, ones};
SPI_leader_receiver #(16) spi(clk, sdo,
get, data, sck, ss, busy, ready);
binarytoBCD bcd({4'b0000,
lightdata[12:5]}, thos, huns, tens, ones);
sevenseg_driver segdriver(clk, thos,
huns, tens, ones, seg, an);
endmodule
This was pretty straight forward. I think the caps in my Basys 3 were
struggling to discharge fast enough resulting in the ghosting because
it looks fine in steady state but struggles when updating rapidly. I
tried to play around with the delays but it didn't help much.
Discussion: Easy
peasy. Just copied the text books example and had to change some
parameters in the constraints. I think it would've been better to
change the values in the code to what the constraints file uses so I
don't mess myself up later but I'm not sure.