mirror of
https://github.com/mist-devel/mist-board.git
synced 2026-01-27 20:27:12 +00:00
[PLUS TOO] SCSI write fix
This commit is contained in:
@@ -30,5 +30,6 @@ Functional changes:
|
||||
- various timing simplifications
|
||||
- fix mouse counter wrapping
|
||||
- Basic sound support
|
||||
- SCSI interface + SCSI hdd support
|
||||
|
||||
Binaries are available at the [binaries repository](https://github.com/mist-devel/mist-binaries/tree/master/cores/plus_too).
|
||||
|
||||
@@ -109,6 +109,7 @@ module scsi(input sysclk,
|
||||
cmd_read?buffer_dout:
|
||||
cmd_inquiry?inquiry_dout:
|
||||
cmd_read_capacity?read_capacity_dout:
|
||||
cmd_mode_sense?mode_sense_dout:
|
||||
8'h00;
|
||||
|
||||
// output of inquiry command, identify as "SEAGATE ST225N"
|
||||
@@ -131,15 +132,24 @@ module scsi(input sysclk,
|
||||
8'h00;
|
||||
|
||||
// output of read capacity command
|
||||
wire [31:0] capacity = 32'd41055; // 40960 + 96 blocks = 20MB
|
||||
wire [31:0] capacity = 32'd41056; // 40960 + 96 blocks = 20MB
|
||||
wire [31:0] capacity_m1 = capacity - 32'd1;
|
||||
wire [7:0] read_capacity_dout =
|
||||
(data_cnt == 32'd0 )?capacity[31:24]:
|
||||
(data_cnt == 32'd1 )?capacity[23:16]:
|
||||
(data_cnt == 32'd2 )?capacity[15:8]:
|
||||
(data_cnt == 32'd3 )?capacity[7:0]:
|
||||
(data_cnt == 32'd0 )?capacity_m1[31:24]:
|
||||
(data_cnt == 32'd1 )?capacity_m1[23:16]:
|
||||
(data_cnt == 32'd2 )?capacity_m1[15:8]:
|
||||
(data_cnt == 32'd3 )?capacity_m1[7:0]:
|
||||
(data_cnt == 32'd6 )?8'd2: // 512 bytes per sector
|
||||
8'h00;
|
||||
|
||||
wire [7:0] mode_sense_dout =
|
||||
(data_cnt == 32'd3 )?8'd8:
|
||||
(data_cnt == 32'd5 )?capacity[23:16]:
|
||||
(data_cnt == 32'd6 )?capacity[15:8]:
|
||||
(data_cnt == 32'd7 )?capacity[7:0]:
|
||||
(data_cnt == 32'd10 )?8'd2:
|
||||
8'h00;
|
||||
|
||||
// clock data out of buffer to allow for embedded ram
|
||||
reg [7:0] buffer_dout;
|
||||
wire buffer_out_clk = req && !io_rd;
|
||||
@@ -278,12 +288,13 @@ module scsi(input sysclk,
|
||||
wire cmd_inquiry = (op_code == 8'h12);
|
||||
wire cmd_format = (op_code == 8'h04);
|
||||
wire cmd_mode_select = (op_code == 8'h15);
|
||||
wire cmd_mode_sense = (op_code == 8'h1a);
|
||||
wire cmd_test_unit_ready = (op_code == 8'h00);
|
||||
wire cmd_read_capacity = (op_code == 8'h25);
|
||||
|
||||
// valid command in buffer? TODO: check for valid command parameters
|
||||
wire cmd_ok = cmd_read || cmd_write || cmd_inquiry || cmd_test_unit_ready ||
|
||||
cmd_read_capacity || cmd_mode_select || cmd_format;
|
||||
cmd_read_capacity || cmd_mode_select || cmd_format || cmd_mode_sense;
|
||||
|
||||
// latch parameters once command is complete
|
||||
reg [31:0] lba;
|
||||
@@ -332,7 +343,7 @@ module scsi(input sysclk,
|
||||
// continue according to command
|
||||
|
||||
// these commands return data
|
||||
if(cmd_read || cmd_inquiry || cmd_read_capacity)
|
||||
if(cmd_read || cmd_inquiry || cmd_read_capacity || cmd_mode_sense)
|
||||
phase <= `PHASE_DATA_OUT;
|
||||
// these commands receive dataa
|
||||
else if(cmd_write || cmd_mode_select)
|
||||
|
||||
@@ -67,7 +67,7 @@ module user_io #(parameter STRLEN=0) (
|
||||
reg [6:0] sbuf;
|
||||
reg [7:0] cmd;
|
||||
reg [2:0] bit_cnt; // counts bits 0-7 0-7 ...
|
||||
reg [7:0] byte_cnt; // counts bytes
|
||||
reg [9:0] byte_cnt; // counts bytes
|
||||
reg [5:0] joystick0;
|
||||
reg [5:0] joystick1;
|
||||
reg [3:0] but_sw;
|
||||
@@ -310,7 +310,7 @@ always@(posedge spi_sck or posedge SPI_SS_IO) begin
|
||||
|
||||
if(SPI_SS_IO == 1) begin
|
||||
bit_cnt <= 3'd0;
|
||||
byte_cnt <= 8'd0;
|
||||
byte_cnt <= 10'd0;
|
||||
sd_ack <= 1'b0;
|
||||
sd_dout_strobe <= 1'b0;
|
||||
sd_din_strobe <= 1'b0;
|
||||
@@ -322,8 +322,8 @@ always@(posedge spi_sck or posedge SPI_SS_IO) begin
|
||||
sbuf[6:0] <= { sbuf[5:0], SPI_MOSI };
|
||||
|
||||
bit_cnt <= bit_cnt + 3'd1;
|
||||
if((bit_cnt == 7)&&(byte_cnt != 8'd255))
|
||||
byte_cnt <= byte_cnt + 8'd1;
|
||||
if((bit_cnt == 7)&&(byte_cnt != 10'd1023))
|
||||
byte_cnt <= byte_cnt + 10'd1;
|
||||
|
||||
// finished reading command byte
|
||||
if(bit_cnt == 7) begin
|
||||
@@ -367,18 +367,16 @@ always@(posedge spi_sck or posedge SPI_SS_IO) begin
|
||||
// send sector IO -> FPGA
|
||||
if(cmd == 8'h17) begin
|
||||
// flag that download begins
|
||||
// sd_dout <= { sbuf, SPI_MOSI};
|
||||
sd_dout_strobe <= 1'b1;
|
||||
end
|
||||
|
||||
// send sector FPGA -> IO
|
||||
if(cmd == 8'h18)
|
||||
if((cmd == 8'h18) && (byte_cnt < 512))
|
||||
sd_din_strobe <= 1'b1;
|
||||
|
||||
// send SD config IO -> FPGA
|
||||
if(cmd == 8'h19) begin
|
||||
// flag that download begins
|
||||
// sd_dout <= { sbuf, SPI_MOSI};
|
||||
// sd card knows data is config if sd_dout_strobe is asserted
|
||||
// with sd_ack still being inactive (low)
|
||||
sd_dout_strobe <= 1'b1;
|
||||
|
||||
Reference in New Issue
Block a user