📄 usbslavecontrolbi.v.bak
字号:
////////////////////////////////////////////////////////////////////////// //////// USBSlaveControlBI.v ////`include "timescale.v"`include "usbSlaveControl_h.v" module USBSlaveControlBI (address, dataIn, dataOut, writeEn, strobe_i, busClk, rstSyncToBusClk, usbClk, rstSyncToUsbClk, SOFRxedIntOut, resetEventIntOut, resumeIntOut, transDoneIntOut, NAKSentIntOut, vBusDetIntOut, endP0TransTypeReg, endP0NAKTransTypeReg, endP1TransTypeReg, endP1NAKTransTypeReg, endP2TransTypeReg, endP2NAKTransTypeReg, endP3TransTypeReg, endP3NAKTransTypeReg, endP0ControlReg, endP1ControlReg, endP2ControlReg, endP3ControlReg, EP0StatusReg, EP1StatusReg, EP2StatusReg, EP3StatusReg, SCAddrReg, frameNum, connectStateIn, vBusDetectIn, SOFRxedIn, resetEventIn, resumeIntIn, transDoneIn, NAKSentIn, slaveControlSelect, clrEP0Ready, clrEP1Ready, clrEP2Ready, clrEP3Ready, TxLineState, LineDirectControlEn, fullSpeedPol, fullSpeedRate, connectSlaveToHost, SCGlobalEn );input [4:0] address;input [7:0] dataIn;input writeEn; input strobe_i;input busClk; input rstSyncToBusClk;input usbClk; input rstSyncToUsbClk;output [7:0] dataOut;output SOFRxedIntOut;output resetEventIntOut;output resumeIntOut;output transDoneIntOut;output NAKSentIntOut;output vBusDetIntOut;input [1:0] endP0TransTypeReg;input [1:0] endP0NAKTransTypeReg;input [1:0] endP1TransTypeReg; input [1:0] endP1NAKTransTypeReg;input [1:0] endP2TransTypeReg; input [1:0] endP2NAKTransTypeReg;input [1:0] endP3TransTypeReg; input [1:0] endP3NAKTransTypeReg;output [4:0] endP0ControlReg;output [4:0] endP1ControlReg;output [4:0] endP2ControlReg;output [4:0] endP3ControlReg;input [7:0] EP0StatusReg;input [7:0] EP1StatusReg;input [7:0] EP2StatusReg;input [7:0] EP3StatusReg;output [6:0] SCAddrReg;input [10:0] frameNum;input [1:0] connectStateIn;input vBusDetectIn;input SOFRxedIn;input resetEventIn;input resumeIntIn;input transDoneIn;input NAKSentIn;input slaveControlSelect;input clrEP0Ready;input clrEP1Ready;input clrEP2Ready;input clrEP3Ready;output [1:0] TxLineState;output LineDirectControlEn;output fullSpeedPol; output fullSpeedRate;output connectSlaveToHost;output SCGlobalEn;wire [4:0] address;wire [7:0] dataIn;wire writeEn;wire strobe_i;wire busClk; wire rstSyncToBusClk;wire usbClk; wire rstSyncToUsbClk;reg [7:0] dataOut;reg SOFRxedIntOut;reg resetEventIntOut;reg resumeIntOut;reg transDoneIntOut;reg NAKSentIntOut;reg vBusDetIntOut;wire [1:0] endP0TransTypeReg;wire [1:0] endP0NAKTransTypeReg;wire [1:0] endP1TransTypeReg; wire [1:0] endP1NAKTransTypeReg;wire [1:0] endP2TransTypeReg; wire [1:0] endP2NAKTransTypeReg;wire [1:0] endP3TransTypeReg; wire [1:0] endP3NAKTransTypeReg;reg [4:0] endP0ControlReg;reg [4:0] endP0ControlReg1;reg [4:0] endP1ControlReg;reg [4:0] endP1ControlReg1;reg [4:0] endP2ControlReg;reg [4:0] endP2ControlReg1;reg [4:0] endP3ControlReg;reg [4:0] endP3ControlReg1;wire [7:0] EP0StatusReg;wire [7:0] EP1StatusReg;wire [7:0] EP2StatusReg;wire [7:0] EP3StatusReg;reg [6:0] SCAddrReg;reg [3:0] TxEndPReg;wire [10:0] frameNum;wire [1:0] connectStateIn;wire SOFRxedIn;wire resetEventIn;wire resumeIntIn;wire transDoneIn;wire NAKSentIn;wire slaveControlSelect;wire clrEP0Ready;wire clrEP1Ready;wire clrEP2Ready;wire clrEP3Ready;reg [1:0] TxLineState;reg [1:0] TxLineState_reg1;reg LineDirectControlEn;reg LineDirectControlEn_reg1;reg fullSpeedPol; reg fullSpeedPol_reg1; reg fullSpeedRate;reg fullSpeedRate_reg1;reg connectSlaveToHost;reg connectSlaveToHost_reg1;reg SCGlobalEn;reg SCGlobalEn_reg1;//internal wire and regsreg [6:0] SCControlReg;reg clrVBusDetReq;reg clrNAKReq;reg clrSOFReq;reg clrResetReq;reg clrResInReq;reg clrTransDoneReq;reg SOFRxedInt;reg resetEventInt;reg resumeInt;reg transDoneInt;reg vBusDetInt;reg NAKSentInt;reg [5:0] interruptMaskReg;reg EP0SetReady;reg EP1SetReady;reg EP2SetReady;reg EP3SetReady;reg EP0SendStall;reg EP1SendStall;reg EP2SendStall;reg EP3SendStall;reg EP0IsoEn;reg EP1IsoEn;reg EP2IsoEn;reg EP3IsoEn;reg EP0DataSequence;reg EP1DataSequence;reg EP2DataSequence;reg EP3DataSequence;reg EP0Enable;reg EP1Enable;reg EP2Enable;reg EP3Enable;reg EP0Ready;reg EP1Ready;reg EP2Ready;reg EP3Ready;reg [2:0] SOFRxedInExtend;reg [2:0] resetEventInExtend;reg [2:0] resumeIntInExtend;reg [2:0] transDoneInExtend;reg [2:0] NAKSentInExtend;reg [2:0] clrEP0ReadyExtend;reg [2:0] clrEP1ReadyExtend;reg [2:0] clrEP2ReadyExtend;reg [2:0] clrEP3ReadyExtend;//clock domain crossing sync registers//STB = Sync To Busclkreg [4:0] endP0ControlRegSTB;reg [4:0] endP1ControlRegSTB;reg [4:0] endP2ControlRegSTB;reg [4:0] endP3ControlRegSTB;reg [2:0] NAKSentInSTB;reg [2:0] SOFRxedInSTB;reg [2:0] resetEventInSTB;reg [2:0] resumeIntInSTB;reg [2:0] transDoneInSTB;reg [2:0] clrEP0ReadySTB;reg [2:0] clrEP1ReadySTB;reg [2:0] clrEP2ReadySTB;reg [2:0] clrEP3ReadySTB;reg SCGlobalEnSTB;reg [1:0] TxLineStateSTB;reg LineDirectControlEnSTB;reg fullSpeedPolSTB; reg fullSpeedRateSTB;reg connectSlaveToHostSTB;reg [7:0] EP0StatusRegSTB;reg [7:0] EP0StatusRegSTB_reg1;reg [7:0] EP1StatusRegSTB;reg [7:0] EP1StatusRegSTB_reg1;reg [7:0] EP2StatusRegSTB;reg [7:0] EP2StatusRegSTB_reg1;reg [7:0] EP3StatusRegSTB;reg [7:0] EP3StatusRegSTB_reg1;reg [1:0] endP0TransTypeRegSTB;reg [1:0] endP0TransTypeRegSTB_reg1;reg [1:0] endP0NAKTransTypeRegSTB;reg [1:0] endP0NAKTransTypeRegSTB_reg1;reg [1:0] endP1TransTypeRegSTB; reg [1:0] endP1TransTypeRegSTB_reg1; reg [1:0] endP1NAKTransTypeRegSTB;reg [1:0] endP1NAKTransTypeRegSTB_reg1;reg [1:0] endP2TransTypeRegSTB; reg [1:0] endP2TransTypeRegSTB_reg1; reg [1:0] endP2NAKTransTypeRegSTB;reg [1:0] endP2NAKTransTypeRegSTB_reg1;reg [1:0] endP3TransTypeRegSTB; reg [1:0] endP3TransTypeRegSTB_reg1; reg [1:0] endP3NAKTransTypeRegSTB;reg [1:0] endP3NAKTransTypeRegSTB_reg1;reg [10:0] frameNumSTB;reg [10:0] frameNumSTB_reg1;reg [2:0] vBusDetectInSTB;reg [1:0] connectStateInSTB;reg [1:0] connectStateInSTB_reg1; //sync write demuxalways @(posedge busClk)begin if (rstSyncToBusClk == 1'b1) begin EP0IsoEn <= 1'b0; EP0SendStall <= 1'b0; EP0DataSequence <= 1'b0; EP0Enable <= 1'b0; EP1IsoEn <= 1'b0; EP1SendStall <= 1'b0; EP1DataSequence <= 1'b0; EP1Enable <= 1'b0; EP2IsoEn <= 1'b0; EP2SendStall <= 1'b0; EP2DataSequence <= 1'b0; EP2Enable <= 1'b0; EP3IsoEn <= 1'b0; EP3SendStall <= 1'b0; EP3DataSequence <= 1'b0; EP3Enable <= 1'b0; SCControlReg <= 7'h00; SCAddrReg <= 7'h00; interruptMaskReg <= 6'h00; end else begin clrVBusDetReq <= 1'b0; clrNAKReq <= 1'b0; clrSOFReq <= 1'b0; clrResetReq <= 1'b0; clrResInReq <= 1'b0; clrTransDoneReq <= 1'b0; EP0SetReady <= 1'b0; EP1SetReady <= 1'b0; EP2SetReady <= 1'b0; EP3SetReady <= 1'b0; if (writeEn == 1'b1 && strobe_i == 1'b1 && slaveControlSelect == 1'b1) begin case (address) `EP0_CTRL_REG : begin EP0IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT]; EP0SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT]; EP0DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT]; EP0SetReady <= dataIn[`ENDPOINT_READY_BIT]; EP0Enable <= dataIn[`ENDPOINT_ENABLE_BIT]; end `EP1_CTRL_REG : begin EP1IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT]; EP1SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT]; EP1DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT]; EP1SetReady <= dataIn[`ENDPOINT_READY_BIT]; EP1Enable <= dataIn[`ENDPOINT_ENABLE_BIT]; end `EP2_CTRL_REG : begin EP2IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT]; EP2SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT]; EP2DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT]; EP2SetReady <= dataIn[`ENDPOINT_READY_BIT]; EP2Enable <= dataIn[`ENDPOINT_ENABLE_BIT]; end `EP3_CTRL_REG : begin EP3IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT]; EP3SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT]; EP3DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT]; EP3SetReady <= dataIn[`ENDPOINT_READY_BIT]; EP3Enable <= dataIn[`ENDPOINT_ENABLE_BIT]; end `SC_CONTROL_REG : SCControlReg <= dataIn[6:0]; `SC_ADDRESS : SCAddrReg <= dataIn[6:0]; `SC_INTERRUPT_STATUS_REG : begin clrVBusDetReq <= dataIn[`VBUS_DET_INT_BIT]; clrNAKReq <= dataIn[`NAK_SENT_INT_BIT]; clrSOFReq <= dataIn[`SOF_RECEIVED_BIT]; clrResetReq <= dataIn[`RESET_EVENT_BIT]; clrResInReq <= dataIn[`RESUME_INT_BIT]; clrTransDoneReq <= dataIn[`TRANS_DONE_BIT]; end `SC_INTERRUPT_MASK_REG : interruptMaskReg <= dataIn[5:0]; endcase end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -