?? usbf_rf.v
字號:
`include "usbf_defines.v"// Endpoint register Filemodule usbf_rf( clk, wclk, rst, // Wishbone Interface adr, re, we, din, dout, inta, intb, dma_req, dma_ack, // Internal Interface idin, ep_sel, match, buf0_rl, buf0_set, buf1_set, uc_bsel_set, uc_dpd_set, int_buf1_set, int_buf0_set, int_upid_set, int_crc16_set, int_to_set, int_seqerr_set, out_to_small, csr, buf0, buf1, funct_adr, dma_in_buf_sz1, dma_out_buf_avail, // Misc frm_nat, utmi_vend_stat, utmi_vend_ctrl, utmi_vend_wr, line_stat, usb_attached, mode_hs, suspend, attached, usb_reset, pid_cs_err, nse_err, crc5_err, rx_err, rf_resume_req );input clk, wclk, rst;input [6:0] adr;input re;input we;input [31:0] din;output [31:0] dout;output inta, intb;output [15:0] dma_req;input [15:0] dma_ack;input [31:0] idin; // Data Inputinput [3:0] ep_sel; // Endpoint Number Inputoutput match; // Endpoint Matchedinput buf0_rl; // Reload Buf 0 with original valuesinput buf0_set; // Write to buf 0input buf1_set; // Write to buf 1input uc_bsel_set; // Write to the uc_bsel fieldinput uc_dpd_set; // Write to the uc_dpd fieldinput int_buf1_set; // Set buf1 full/empty interruptinput int_buf0_set; // Set buf0 full/empty interruptinput int_upid_set; // Set unsupported PID interruptinput int_crc16_set; // Set CRC16 error interruptinput int_to_set; // Set time out interruptinput int_seqerr_set; // Set PID Sequence Error Interruptinput out_to_small; // OUT packet was to small for DMA operationoutput [31:0] csr; // Internal CSR Outputoutput [31:0] buf0; // Internal Buf 0 Outputoutput [31:0] buf1; // Internal Buf 1 Outputoutput [6:0] funct_adr; // Function Addressoutput dma_in_buf_sz1, dma_out_buf_avail;input [31:0] frm_nat;input [7:0] utmi_vend_stat; // UTMI Vendor C/S busoutput [3:0] utmi_vend_ctrl;output utmi_vend_wr;input [1:0] line_stat; // Below are signals for interrupt generationinput usb_attached;input mode_hs;input suspend;input attached;input usb_reset;input nse_err;input pid_cs_err;input crc5_err;input rx_err;output rf_resume_req;/////////////////////////////////////////////////////////////////////// Local Wires and Registers//wire [31:0] ep0_dout, ep1_dout, ep2_dout, ep3_dout;wire [31:0] ep4_dout, ep5_dout, ep6_dout, ep7_dout;wire [31:0] ep8_dout, ep9_dout, ep10_dout, ep11_dout;wire [31:0] ep12_dout, ep13_dout, ep14_dout, ep15_dout;wire ep0_re, ep1_re, ep2_re, ep3_re;wire ep4_re, ep5_re, ep6_re, ep7_re;wire ep8_re, ep9_re, ep10_re, ep11_re;wire ep12_re, ep13_re, ep14_re, ep15_re;wire ep0_we, ep1_we, ep2_we, ep3_we;wire ep4_we, ep5_we, ep6_we, ep7_we;wire ep8_we, ep9_we, ep10_we, ep11_we;wire ep12_we, ep13_we, ep14_we, ep15_we;wire ep0_inta, ep1_inta, ep2_inta, ep3_inta;wire ep4_inta, ep5_inta, ep6_inta, ep7_inta;wire ep8_inta, ep9_inta, ep10_inta, ep11_inta;wire ep12_inta, ep13_inta, ep14_inta, ep15_inta;wire ep0_intb, ep1_intb, ep2_intb, ep3_intb;wire ep4_intb, ep5_intb, ep6_intb, ep7_intb;wire ep8_intb, ep9_intb, ep10_intb, ep11_intb;wire ep12_intb, ep13_intb, ep14_intb, ep15_intb;wire ep0_match, ep1_match, ep2_match, ep3_match;wire ep4_match, ep5_match, ep6_match, ep7_match;wire ep8_match, ep9_match, ep10_match, ep11_match;wire ep12_match, ep13_match, ep14_match, ep15_match;wire [31:0] ep0_csr, ep1_csr, ep2_csr, ep3_csr;wire [31:0] ep4_csr, ep5_csr, ep6_csr, ep7_csr;wire [31:0] ep8_csr, ep9_csr, ep10_csr, ep11_csr;wire [31:0] ep12_csr, ep13_csr, ep14_csr, ep15_csr;wire [31:0] ep0_buf0, ep1_buf0, ep2_buf0, ep3_buf0;wire [31:0] ep4_buf0, ep5_buf0, ep6_buf0, ep7_buf0;wire [31:0] ep8_buf0, ep9_buf0, ep10_buf0, ep11_buf0;wire [31:0] ep12_buf0, ep13_buf0, ep14_buf0, ep15_buf0;wire [31:0] ep0_buf1, ep1_buf1, ep2_buf1, ep3_buf1;wire [31:0] ep4_buf1, ep5_buf1, ep6_buf1, ep7_buf1;wire [31:0] ep8_buf1, ep9_buf1, ep10_buf1, ep11_buf1;wire [31:0] ep12_buf1, ep13_buf1, ep14_buf1, ep15_buf1;wire ep0_dma_in_buf_sz1, ep1_dma_in_buf_sz1;wire ep2_dma_in_buf_sz1, ep3_dma_in_buf_sz1;wire ep4_dma_in_buf_sz1, ep5_dma_in_buf_sz1;wire ep6_dma_in_buf_sz1, ep7_dma_in_buf_sz1;wire ep8_dma_in_buf_sz1, ep9_dma_in_buf_sz1;wire ep10_dma_in_buf_sz1, ep11_dma_in_buf_sz1;wire ep12_dma_in_buf_sz1, ep13_dma_in_buf_sz1;wire ep14_dma_in_buf_sz1, ep15_dma_in_buf_sz1;wire ep0_dma_out_buf_avail, ep1_dma_out_buf_avail;wire ep2_dma_out_buf_avail, ep3_dma_out_buf_avail;wire ep4_dma_out_buf_avail, ep5_dma_out_buf_avail;wire ep6_dma_out_buf_avail, ep7_dma_out_buf_avail;wire ep8_dma_out_buf_avail, ep9_dma_out_buf_avail;wire ep10_dma_out_buf_avail, ep11_dma_out_buf_avail;wire ep12_dma_out_buf_avail, ep13_dma_out_buf_avail;wire ep14_dma_out_buf_avail, ep15_dma_out_buf_avail;reg dma_in_buf_sz1;reg dma_out_buf_avail;reg [31:0] dtmp;reg [31:0] dout;wire [31:0] main_csr;reg [6:0] funct_adr;reg [8:0] intb_msk, inta_msk;reg match_r1;reg [31:0] csr;reg [31:0] buf0;reg [31:0] buf1;reg [3:0] utmi_vend_ctrl;reg utmi_vend_wr;reg [7:0] utmi_vend_stat_r;reg int_src_re;reg [8:0] int_srcb;reg [15:0] int_srca;reg attach_r, attach_r1;wire attach, deattach;reg suspend_r, suspend_r1;wire suspend_start, suspend_end;reg usb_reset_r;reg rx_err_r;reg nse_err_r;reg pid_cs_err_r;reg crc5_err_r;reg rf_resume_req_r, rf_resume_req;wire inta_ep, intb_ep;wire inta_rf, intb_rf;reg inta, intb;/////////////////////////////////////////////////////////////////////// WISHBONE Access//// Main CSR Aliasassign main_csr = {27'h0, line_stat, usb_attached, mode_hs, suspend};// Read Registers Logicalways @(adr or main_csr or funct_adr or inta_msk or intb_msk or int_srca or int_srcb or frm_nat or utmi_vend_stat_r) case(adr[2:0]) // synopsys full_case parallel_case 3'h0: dtmp = main_csr; 3'h1: dtmp = { 25'h0, funct_adr}; 3'h2: dtmp = { 7'h0, intb_msk, 7'h0, inta_msk}; 3'h3: dtmp = { 3'h0, int_srcb, 4'h0, int_srca}; 3'h4: dtmp = frm_nat; 3'h5: dtmp = { 24'h0, utmi_vend_stat_r}; endcase// Interrupt Source Read Registeralways @(posedge wclk) int_src_re <= adr[6:0] == 7'h3 & re;// UTMI Vendor Control Stuffalways @(posedge wclk) utmi_vend_stat_r <= utmi_vend_stat;reg utmi_vend_wr_r;`ifdef USBF_ASYNC_RESETalways @(posedge wclk or negedge rst)`elsealways @(posedge wclk)`endif if(!rst) utmi_vend_wr_r <= 1'b0; else if(adr[6:0] == 7'h5 && we) utmi_vend_wr_r <= 1'b1; else if(utmi_vend_wr) utmi_vend_wr_r <= 1'b0;always @(posedge clk) // Second Stage sync utmi_vend_wr <= utmi_vend_wr_r;reg [3:0] utmi_vend_ctrl_r;always @(posedge wclk) if(adr[6:0] == 7'h5 && we) utmi_vend_ctrl_r <= din[3:0];always @(posedge clk) // Second Stage sync utmi_vend_ctrl <= utmi_vend_ctrl_r;// Resume Request`ifdef USBF_ASYNC_RESETalways @(posedge wclk or negedge rst)`elsealways @(posedge wclk)`endif if(!rst) rf_resume_req_r <= 1'b0; else if(adr[6:0] == 7'h0 && we) rf_resume_req_r <= din[5]; else if(rf_resume_req) rf_resume_req_r <= 1'b0;always @(posedge clk) // Second Stage sync rf_resume_req <= rf_resume_req_r;// Function Address Register`ifdef USBF_ASYNC_RESETalways @(posedge wclk or negedge rst)`elsealways @(posedge wclk)`endif if(!rst) funct_adr <= 7'h0; else if(adr[6:0] == 7'h1 && we) funct_adr <= din[6:0];// Interrup Mask Register`ifdef USBF_ASYNC_RESETalways @(posedge wclk or negedge rst)`elsealways @(posedge wclk)`endif if(!rst) begin inta_msk <= 9'h0; intb_msk <= 9'h0; end else if(adr[6:0] == 7'h2 && we) begin intb_msk <= din[24:16]; inta_msk <= din[08:00]; endalways @(posedge wclk) case(adr[6:2]) // synopsys full_case parallel_case 5'h00: dout <= dtmp; // Addr: 0h 5'h01: dout <= dtmp; 5'h02: dout <= 32'h0; 5'h03: dout <= 32'h0; 5'h04: dout <= ep0_dout; 5'h05: dout <= ep1_dout; 5'h06: dout <= ep2_dout; 5'h07: dout <= ep3_dout; 5'h08: dout <= ep4_dout; 5'h09: dout <= ep5_dout; 5'h0a: dout <= ep6_dout; 5'h0b: dout <= ep7_dout; 5'h0c: dout <= ep8_dout; 5'h0d: dout <= ep9_dout; 5'h0e: dout <= ep10_dout; 5'h0f: dout <= ep11_dout; 5'h10: dout <= ep12_dout; 5'h11: dout <= ep13_dout; 5'h12: dout <= ep14_dout; 5'h13: dout <= ep15_dout; endcaseassign ep0_re = (adr[6:2] == 5'h04) & re;assign ep1_re = (adr[6:2] == 5'h05) & re;assign ep2_re = (adr[6:2] == 5'h06) & re;assign ep3_re = (adr[6:2] == 5'h07) & re;assign ep4_re = (adr[6:2] == 5'h08) & re;assign ep5_re = (adr[6:2] == 5'h09) & re;assign ep6_re = (adr[6:2] == 5'h0a) & re;assign ep7_re = (adr[6:2] == 5'h0b) & re;assign ep8_re = (adr[6:2] == 5'h0c) & re;assign ep9_re = (adr[6:2] == 5'h0d) & re;assign ep10_re = (adr[6:2] == 5'h0e) & re;assign ep11_re = (adr[6:2] == 5'h0f) & re;assign ep12_re = (adr[6:2] == 5'h10) & re;assign ep13_re = (adr[6:2] == 5'h11) & re;assign ep14_re = (adr[6:2] == 5'h12) & re;assign ep15_re = (adr[6:2] == 5'h13) & re;assign ep0_we = (adr[6:2] == 5'h04) & we;assign ep1_we = (adr[6:2] == 5'h05) & we;assign ep2_we = (adr[6:2] == 5'h06) & we;assign ep3_we = (adr[6:2] == 5'h07) & we;assign ep4_we = (adr[6:2] == 5'h08) & we;assign ep5_we = (adr[6:2] == 5'h09) & we;assign ep6_we = (adr[6:2] == 5'h0a) & we;assign ep7_we = (adr[6:2] == 5'h0b) & we;assign ep8_we = (adr[6:2] == 5'h0c) & we;assign ep9_we = (adr[6:2] == 5'h0d) & we;assign ep10_we = (adr[6:2] == 5'h0e) & we;assign ep11_we = (adr[6:2] == 5'h0f) & we;assign ep12_we = (adr[6:2] == 5'h10) & we;assign ep13_we = (adr[6:2] == 5'h11) & we;assign ep14_we = (adr[6:2] == 5'h12) & we;assign ep15_we = (adr[6:2] == 5'h13) & we;/////////////////////////////////////////////////////////////////////// Internal Access//assign match = match_r1;always @(posedge clk) match_r1 <= ep0_match | ep1_match | ep2_match | ep3_match | ep4_match | ep5_match | ep6_match | ep7_match | ep8_match | ep9_match | ep10_match | ep11_match | ep12_match | ep13_match | ep14_match | ep15_match;always @(posedge clk) if(ep0_match) csr <= ep0_csr; else if(ep1_match) csr <= ep1_csr; else if(ep2_match) csr <= ep2_csr; else if(ep3_match) csr <= ep3_csr; else if(ep4_match) csr <= ep4_csr; else if(ep5_match) csr <= ep5_csr; else if(ep6_match) csr <= ep6_csr; else if(ep7_match) csr <= ep7_csr; else if(ep8_match) csr <= ep8_csr; else if(ep9_match) csr <= ep9_csr; else if(ep10_match) csr <= ep10_csr; else if(ep11_match) csr <= ep11_csr; else if(ep12_match) csr <= ep12_csr; else if(ep13_match) csr <= ep13_csr; else if(ep14_match) csr <= ep14_csr; else if(ep15_match) csr <= ep15_csr;always @(posedge clk) if(ep0_match) buf0 <= ep0_buf0; else if(ep1_match) buf0 <= ep1_buf0; else if(ep2_match) buf0 <= ep2_buf0; else if(ep3_match) buf0 <= ep3_buf0; else if(ep4_match) buf0 <= ep4_buf0; else if(ep5_match) buf0 <= ep5_buf0; else if(ep6_match) buf0 <= ep6_buf0; else if(ep7_match) buf0 <= ep7_buf0; else if(ep8_match) buf0 <= ep8_buf0; else if(ep9_match) buf0 <= ep9_buf0; else if(ep10_match) buf0 <= ep10_buf0; else if(ep11_match) buf0 <= ep11_buf0; else if(ep12_match) buf0 <= ep12_buf0; else if(ep13_match) buf0 <= ep13_buf0; else if(ep14_match) buf0 <= ep14_buf0; else if(ep15_match) buf0 <= ep15_buf0;always @(posedge clk) if(ep0_match) buf1 <= ep0_buf1; else if(ep1_match) buf1 <= ep1_buf1; else if(ep2_match) buf1 <= ep2_buf1; else if(ep3_match) buf1 <= ep3_buf1; else if(ep4_match) buf1 <= ep4_buf1; else if(ep5_match) buf1 <= ep5_buf1; else if(ep6_match) buf1 <= ep6_buf1; else if(ep7_match) buf1 <= ep7_buf1; else if(ep8_match) buf1 <= ep8_buf1; else if(ep9_match) buf1 <= ep9_buf1; else if(ep10_match) buf1 <= ep10_buf1; else if(ep11_match) buf1 <= ep11_buf1; else if(ep12_match) buf1 <= ep12_buf1; else if(ep13_match) buf1 <= ep13_buf1; else if(ep14_match) buf1 <= ep14_buf1; else
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -