mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-25 23:24:15 +01:00
SD clock stop when RX FIFO is more than half full
This commit is contained in:
parent
c475b62197
commit
2ce73c03bf
@ -13,8 +13,10 @@ module sd_clk (
|
|||||||
logic [7:0] clock_divider;
|
logic [7:0] clock_divider;
|
||||||
|
|
||||||
always_ff @(posedge clk) begin
|
always_ff @(posedge clk) begin
|
||||||
|
if (!sd_scb.clock_stop) begin
|
||||||
clock_divider <= clock_divider + 1'd1;
|
clock_divider <= clock_divider + 1'd1;
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
logic selected_clock;
|
logic selected_clock;
|
||||||
|
|
||||||
|
@ -248,6 +248,7 @@ module sd_dat (
|
|||||||
crc_shift <= 1'b0;
|
crc_shift <= 1'b0;
|
||||||
|
|
||||||
if (reset || sd_scb.dat_stop) begin
|
if (reset || sd_scb.dat_stop) begin
|
||||||
|
sd_scb.clock_stop <= 1'b0;
|
||||||
sd_dat_oe_data <= 1'b0;
|
sd_dat_oe_data <= 1'b0;
|
||||||
sd_dat_data <= 4'hF;
|
sd_dat_data <= 4'hF;
|
||||||
end else begin
|
end else begin
|
||||||
@ -260,6 +261,9 @@ module sd_dat (
|
|||||||
end
|
end
|
||||||
|
|
||||||
STATE_RX_WAIT: begin
|
STATE_RX_WAIT: begin
|
||||||
|
if (sd_scb.rx_count <= 11'd512) begin
|
||||||
|
sd_scb.clock_stop <= 1'b0;
|
||||||
|
end
|
||||||
if (sd_clk_rising) begin
|
if (sd_clk_rising) begin
|
||||||
if (!sd_dat_in[0]) begin
|
if (!sd_dat_in[0]) begin
|
||||||
counter <= 11'd1;
|
counter <= 11'd1;
|
||||||
@ -288,6 +292,9 @@ module sd_dat (
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (counter == 11'd1041) begin
|
if (counter == 11'd1041) begin
|
||||||
|
if ((blocks_remaining > 8'd0) && (sd_scb.rx_count > 11'd512)) begin
|
||||||
|
sd_scb.clock_stop <= 1'b1;
|
||||||
|
end
|
||||||
blocks_remaining <= blocks_remaining - 1'd1;
|
blocks_remaining <= blocks_remaining - 1'd1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
interface sd_scb ();
|
interface sd_scb ();
|
||||||
|
|
||||||
logic [1:0] clock_mode;
|
logic [1:0] clock_mode;
|
||||||
|
logic clock_stop;
|
||||||
|
|
||||||
logic card_busy;
|
logic card_busy;
|
||||||
|
|
||||||
@ -55,7 +56,8 @@ interface sd_scb ();
|
|||||||
);
|
);
|
||||||
|
|
||||||
modport clk (
|
modport clk (
|
||||||
input clock_mode
|
input clock_mode,
|
||||||
|
input clock_stop
|
||||||
);
|
);
|
||||||
|
|
||||||
modport cmd (
|
modport cmd (
|
||||||
@ -72,6 +74,8 @@ interface sd_scb ();
|
|||||||
);
|
);
|
||||||
|
|
||||||
modport dat (
|
modport dat (
|
||||||
|
output clock_stop,
|
||||||
|
|
||||||
output card_busy,
|
output card_busy,
|
||||||
|
|
||||||
output rx_count,
|
output rx_count,
|
||||||
|
Loading…
Reference in New Issue
Block a user