Skip to content

Probable issue fix when sending more than 512 bytes #10

@lk-davidegironi

Description

@lk-davidegironi

Hello @WangXuan95 and thanks for this IP, it saves me a lot of time.

I've ported your code to Verilog.
I'm working on a ECP5 Lattice, running at synchronous mode a FT2232H.
I've built a simple project to loopback and test data. My sample program is in C and C#. I'm using the FTDI driver.

I've found a issue when sending/receiving more than 512 bytes.

It keeps me a couple of days but finally I've been able to solve the issue.
It happens only when TXE and WR goes up at the same cycle, find image as reference, this cause the txfifoo_wtrans_i to get full.

My solution was to disable the input buffer of this module and wait for the buffer to became empty when TXT get high.

Hope this helps!

Find below the changed code, in Verilog, but you can easily port to SystemVerilog

From this:

    stream_wtrans #
        (
            .I_DEXP(TXFIFO_DEXP),
            .O_DEXP(C_DEXP)
        ) txfifoo_wtrans_i (
            .rstn(rstn_usb_clk),
            .clk(usb_clk),
            .itvalid(txfifoo_valid),
            .itready(txfifoo_ready),
            .itdata(txfifoo_data),
            .otvalid(c_tx_valid),
            .otready(c_tx_ready),
            .otdata(c_tx_data)
        );

To this:

        wire txfifoo_readyt;
	assign txfifoo_ready = txfifoo_readyt & ~usb_txe & usb_txe_en;
	reg usb_txe_wait = 1'b0;
	reg usb_txe_en = 1'b1;
	always @(posedge usb_clk or negedge rstn_usb_clk)
	begin
		if(stat == TXD & usb_txe)
		begin
			usb_txe_wait <= 1'b1;
			usb_txe_en <= 1'b0;
		end
		else if(usb_txe_wait && ~c_tx_valid)
		begin
			usb_txe_wait <= 1'b0;
			usb_txe_en <= 1'b1;
		end
	end
	
    stream_wtrans #
        (
            .I_DEXP(TXFIFO_DEXP),
            .O_DEXP(C_DEXP)
        ) txfifoo_wtrans_i (
            .rstn(rstn_usb_clk),
            .clk(usb_clk),
            .itvalid(txfifoo_valid & ~usb_txe & usb_txe_en),
            .itready(txfifoo_readyt),
            .itdata(txfifoo_data),
            .otvalid(c_tx_valid),
            .otready(c_tx_ready),
            .otdata(c_tx_data)
        );

sample_img

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions