📄 udevreadmux.v
字号:
/*
This file includes the read and write strobes as well as the
read multiplexor which is specific to the endpoint configuration.
*/
// create endpoint write signals here
assign corecommand = ( (setuprequest == GETDESCRIPTOR)&&(setuptype == 2'b00) ) ||
( (setuprequest == SETADDRESS)&&(setuptype == 2'b00) ) ||
( (setuprequest == SETINTERFACE)&&(setuptype == 2'b00) ) ||
( (setuprequest == SETCONFIGURATION)&&(setuptype == 2'b00) ) ||
( (setuprequest == GETINTERFACE)&&(setuptype == 2'b00) ) ||
( (setuprequest == GETCONFIGURATION)&&(setuptype == 2'b00) ) ||
( (setuprequest == GETSTATUS)&&(setuptype == 2'b00) );
// wire endp0noncorecmd = (~((setuptype == 2'b00) && corecommand) && // not a standard corecommand
// setupcycle && setupinfovalid && (currentendp == 4'h0));
wire endp0noncorecmd = ((setuptype == 2'b01) && // not a standard corecommand
setupcycle && setupinfovalid && (currentendp == 4'h0));
// only generate the write if the endpoint is ready, don't overflow
// wire endp0wr = (currentendp == 4'h0) ? (grabdata && secondbytevalid && endp0wrready && endp0noncorecmd) : 1'b0;
wire endp0wr = (currentendp == 4'h0) ? ( (grabdata || grabsetup) && secondbytevalid && endp0wrready && ~corecommand) : 1'b0;
// wire endp0rd = (currentendp == 4'h0) ? (nextdata && endp0noncorecmd) : 1'b0;
wire endp0rd = (currentendp == 4'h0) ? (nextdata && ~corecommand) : 1'b0; //JAKE
wire endp1rd = (currentendp == 4'h1) ? nextdata : 1'b0;
// create the read back data, ready signals JAKE
always @(romdevsetupdata or setupcycle or
currentendp or bytecount or totalbytecount or
endp0noncorecmd or
endp0wrready or endp0wrstall or
endp0rdready or endp0rddata or endp0rdstall or
endp1rdready or endp1rddata or endp1rdstall or
setupwindex or setuprecipient or setuprequest or setuplength or
setupwindexin or ourconfiguration or sendzerolengthpkt)
begin
case (currentendp) // synopsys parallel_case full_case
4'h0:
begin
if (setuprequest == GETSTATUS)
begin
case (bytecount) // synopsys parallel_case full_case
16'h0:
if (setuprecipient == REQENDPOINT)
begin
xmitdatabyte[7:1] = 7'h00;
case ({setupwindexin,setupwindex[3:0]}) // 1 for rd, endpoint index
5'h00: xmitdatabyte[0] = 1'b0; // endpoint 0 never stalls
5'h10: xmitdatabyte[0] = 1'b0; // endpoint 0 never stalls
5'h01: xmitdatabyte[0] = 1'b0;
5'h11: xmitdatabyte[0] = endp1rdstall;
5'h02: xmitdatabyte[0] = 1'b0;
5'h12: xmitdatabyte[0] = 1'b0; //endp2rdstall; // non-existent, never stalls
5'h03: xmitdatabyte[0] = 1'b0; // non-existent, never stalls
5'h13: xmitdatabyte[0] = 1'b0; //endp3rdstall;
default: xmitdatabyte[0] = 1'b0; // no stall
endcase
end
else
if (setuprecipient == REQDEVICE)
xmitdatabyte = 8'h00;
else
xmitdatabyte = {6'h00,REMOTEWAKEUP,SELFPOWERED};
5'h01:
xmitdatabyte = 8'h00; // always all zeros
endcase
end
else if (setuprequest == GETCONFIGURATION)
xmitdatabyte = {7'h0,ourconfiguration};
else if (setuprequest == GETINTERFACE)
xmitdatabyte = currentalternatesetting; // send alternate interface setting
//else if (endp0noncorecmd)
else if(~corecommand)
xmitdatabyte = endp0rddata;
else
xmitdatabyte = romdevsetupdata;
// last byte if we sent maxpacket or we are sending the last of the length it asked for
// xmitlastbyte = bytecount[7:0] == MAXPACKET0 ||
// totalbytecount == setuplength ||
// sendzerolengthpkt;
endpointrdready = (~corecommand) ? endp0rdready : 1'b1;
endpointwrready = (~corecommand) ? endp0wrready : 1'b1;
endpointrdstall = (~corecommand) ? endp0rdstall : 1'b0;
endpointwrstall = (~corecommand) ? endp0wrstall : 1'b0;
end
4'h1: // this is a read-only endpoint, use 0 for default
begin
xmitdatabyte = endp1rddata;
// xmitlastbyte = ((bytecount[7:0] == MAXPACKET1) || ~endp1rdready);
endpointrdready = endp1rdready;
endpointwrready = 1'b0;
endpointrdstall = endp1rdstall;
endpointwrstall = 1'b1; //JAKE 1'b1;
end
/* 4'h2: // this is a read-only endpoint, use 0 for default
begin
xmitdatabyte = endp2rddata;
// xmitlastbyte = ((bytecount[7:0] == MAXPACKET2) || ~endp2rdready);
endpointrdready = endp2rdready;
endpointwrready = 1'b0;
endpointrdstall = endp2rdstall;
endpointwrstall = 1'b1;
end
4'h3: // this is a read-only endpoint, use 0 for default
begin
xmitdatabyte = endp3rddata;
// xmitlastbyte = ((bytecount[7:0] == MAXPACKET3) || ~endp3rdready);
endpointrdready = endp3rdready;
endpointwrready = 1'b0;
endpointrdstall = endp3rdstall;
endpointwrstall = 1'b1;
end */
default:
begin
xmitdatabyte = 8'h00;
// xmitlastbyte = 1'b1;
endpointrdready = 1'b0;
endpointwrready = 1'b0;
endpointrdstall = 1'b1;
endpointwrstall = 1'b1;
end
endcase
end // always @ (romdevsetupdata or setupcycle or...
always @(currentendp or setuplength or setupcycle or
cfgdesclength or sendzerolengthpkt or bytecountd or
totalbytecountd or endp1rdready or
xmitlastbyte or ctlst or getcfgdesccycleflag)
begin
if (ctlst == CTLDIN)
xmitlastbyted = 1'b0;
// else if (xmitlastbyte && ctlst != CTLIDLE)
// xmitlastbyted = 1'b1;
else
case (currentendp) // synopsys parallel_case
4'h0 : xmitlastbyted = sendzerolengthpkt ||
(bytecountd == MAXPACKET0) ||
(totalbytecountd == cfgdesclength && getcfgdesccycleflag) ||
(totalbytecountd == setuplength);
4'h1 : xmitlastbyted = (bytecountd == MAXPACKET1) || ~endp1rdready;
/*
4'h2 : xmitlastbyted = (bytecountd == MAXPACKET2) || ~endp2rdready;
4'h3 : xmitlastbyted = (bytecountd == MAXPACKET3) || ~endp3rdready;
*/
default : xmitlastbyted = 1'b1;
endcase // case (currentendp)
end // always @ (currentendp or setuplength or setupcycle or...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -