2014-12-17 3 views
0

SDK (소프트웨어 개발 키트)와 함께 Vivado 2014.3과 함께 XILINX ZC702 FPGA를 사용하고 있습니다.연속 FIFO 데이터 스트림을 만들려고합니다

FIFO 데이터 스트림을 생성하고 싶습니다.이 스트림은 20 미만, 즉 플로우 미만, 500 이하입니다. 즉 오버 플로우입니다. 나는이 목적을 위해 AXI4 Stream FIFO IP를 사용했다. 코드를 작동시키기 위해 아래에 붙여 넣은 axi 스트림 fifo에 대한 데이터 시트에서 찾을 수있는 레지스터를 사용해야한다.

FIFO 데이터가 500에 도달하면 새 데이터로드가 중지되어야합니다. FIFO 데이터가 20에 도달하면 500에 도달 할 때까지 새 데이터를 채워야합니다.이 프로세스는 항상 반복되어야합니다.

하드웨어를 통해 시뮬레이션 된 파형 결과를 보려면 fifo 용 소프트웨어 개발 키트에서 절차를 테스트했습니다. 내가 관찰 한 것은 FIFO 데이터가 연속적이지 않다는 것입니다. 나는 그것을 연속 모드로 가질 필요가있다. 결코 멈추지 않아야한다. 그것은 루프와 같아야한다.

다음은 AXI의 스트 렘 선입 선출법 IP의 데이터 시트에 대한 링크가, C 코드 아래

#include <stdio.h> 
#include <xil_types.h> 
#include <xil_cache.h> 
#include "platform.h" 
#include "xil_io.h" 
//#include "usb20_per.h" 

int main() 
{ 
#define SLCR_UNLOCK  0xF8000008 
#define SLCR_UNLOCK_VAL 0xDF0D 
#define SLCR_LOCK  0xF8000004 
#define SLCR_LOCK_VAL 0x767B 
#define XSLCR_FPGA_RST_CTRL 0xF8000240 


    uint32_t baseaddr_ber=0x43c00000; 
    uint32_t baseaddr_fifo=0x43c10000; 

    Xil_Out32(SLCR_UNLOCK, SLCR_UNLOCK_VAL); // 
    Xil_Out32(XSLCR_FPGA_RST_CTRL, 0x0000000F); //Reset FPGAx_OUT_RST 
    Xil_Out32(XSLCR_FPGA_RST_CTRL, 0x00000000); //Deassert the FPGAx_OUT_RST 
    Xil_Out32(SLCR_LOCK, SLCR_LOCK_VAL);  // 

    Xil_ICacheEnable(); 
    Xil_DCacheEnable(); 

    print("---Entering main---\n\r"); 
    init_platform(); 

    // Xil_Out32 & Xil_In32 
    Xil_Out32(baseaddr_fifo+0x4, 0x0C0001FC); //IER //interrupt enable register 
    Xil_Out32(baseaddr_fifo+0x2C,0x00000002); //TDR //transmit data register 

    uint32_t word_cnt; 
    uint32_t idx; 
    uint32_t state; 
    uint32_t i,val; 
    #define ARRAY_LENGTH 16 
    uint32_t array_fifo_data[ARRAY_LENGTH] = { 0x0100, 0x0302, 0x0504, 0x0706, 0x0908, 0x0B0A, 0x0D0C, 0x0F0E, 0x0100, 0x0302, 0x0504, 0x0706, 0x0908, 0x0B0A, 0x0D0C, 0x0F0E }; //random sequence 

    state=0; 
    word_cnt=0; 
    idx=0; 
    while(1) 
    { 
     switch (state) 
     { 
      case 0: 
       val = Xil_In32(baseaddr_fifo + 0x0c); 
       if(val > 0x1A0) //check TDFV register value //transmit data fifo vacancy 
       { 
        state++; 
       } 
       else 
       { 
        val=0; 
       } 
       break; 

      case 1: 

       word_cnt=0; 
         for(i=0;i<16;i++) 
         { 
          Xil_Out32(baseaddr_fifo + 0x10, array_fifo_data[idx]); //Fill TXFIFO_DATA if TDFV falls below 20 and above 500 
          word_cnt++; 
          idx++; 
          if (idx>(ARRAY_LENGTH-1)) 
           idx=0; 
         } 

         Xil_Out32(baseaddr_fifo+0x14,word_cnt*4); //TLR (transmit length register) 
         state=0; 
       break; 
     } 
    } 
} 

을 찾아주십시오. 페이지 # 7, 패킷을 전송하고 # 23 페이지의 레지스터 공간은 위의 코드에서 사용한 레지스터의 baseaddress와 오프셋 주소를 보여줍니다.

http://www.xilinx.com/support/documentation/ip_documentation/axi_fifo_mm_s/v4_0/pg080-axi-fifo-mm-s.pdf

은 정말 당신의 도움을 주셔서 감사합니다.

내가 작성한 코드에서 코드에 입력 한 순차적 인 임의의 데이터를 전송하고 전송하는 것을 볼 수 있지만 프로세스가 연속적이지 않고 데이터를 전송 한 후 중지되며 프로세스를 반복하고 계속 진행해야합니다 그것을 계속하면 결코 멈추지 않아야한다.

시뮬레이션 된 파형 결과를 보려면 아래 링크를 연다. 당신은 FIFO가 작동한다는 것을 알게 될 것입니다, 그것은 완전한 랜덤 requence를 전송하고 멈춘 후에 나는 랜덤 시퀀스를 반복적으로 전송할 것으로 예상됩니다. 어떤 라인에

https://www.dropbox.com/sh/nydws0v5yjyphj3/AAAg_l7aEvUG3gEzhYedwgWra?dl=0

+0

은/루프는 '시간을 보내고 코드입니다? – user3629249

답변

1
EDIT: some comments about read/write only may be incorrect 

// I commented out certain #include statements and added certain 
// prototype statements, just for the ability to compile. 


// The coding sequences in the OP posted software do not 
// match the coding sequences given in the referenced PDF file. 
// suggest OP correct those coding sequences. 



#include <stdio.h> 
//#include <xil_types.h> 
//#include <xil_cache.h> 
//#include "platform.h" 
//#include "xil_io.h" 
void Xil_ICacheEnable(void); 
void Xil_DCacheEnable(void); 
void Xil_Out32(unsigned int registerAddress, int register value); 
unsigned int Xil_In32 (unsigned int registerAddress); 
//#include "usb20_per.h" 
#include <stdint.h> // uint32_t defined 
unsigned int print(char *); 
void init_platform(void); 

// the set of struct definitions that follow 
// are for the purpose of clearly defining 
// the AIL4 programming interface. 

// For the structs that are a series of bit fields, 
// especially those that are write only, I strongly suggest 
// keeping an image of the register in memory 
// 1) update the image in memory 
// 2) write the whole register at once to the device. 

// interrupt control register 
struct ICR_REG 
{ 
    unsigned int RPURE:1; 
    unsigned int RPORE:1; 
    unsigned int RPUE :1; 
    unsigned int TOPE :1; 
    unsigned int TC :1; 
    unsigned int RC :1; 
    unsigned int TSE :1; 
    unsigned int TRC :1; 
    unsigned int RPC :1; 
    unsigned int TFPF :1; 
    unsigned int TFPE :1; 
    unsigned int RFPF :1; 
    unsigned int RFPE :1; 
    unsigned int ICR_Reserved:19; 
}; 

// interrupt status register, write 1 to clear bit 
struct ISR_REG 
{ 
    unsigned int RPURE:1; 
    unsigned int RPORE:1; 
    unsigned int RPUE :1; 
    unsigned int TOPE :1; 
    unsigned int TC :1; 
    unsigned int RC :1; 
    unsigned int TSE :1; 
    unsigned int TRC :1; 
    unsigned int RPC :1; 
    unsigned int TFPF :1; 
    unsigned int TFPE :1; 
    unsigned int RFPF :1; 
    unsigned int RFPE :1; 
    unsigned int ISR_Reserved:19; 
}; 

// interrupt enable register 
struct IER_REG 
{ 
    unsigned int RPUREE:1; 
    unsigned int RPOREE:1; 
    unsigned int RPUEE :1; 
    unsigned int TOPEE :1; 
    unsigned int TCE :1; 
    unsigned int RCE :1; 
    unsigned int TSEE :1; 
    unsigned int TRCE :1; 
    unsigned int RPCE :1; 
    unsigned int TFPFE :1; 
    unsigned int TFPEE :1; 
    unsigned int RFPFE :1; 
    unsigned int RFPEE :1; 
    unsigned int IER_Reserved:19; 
}; 

// Transmit Data FIFO Reset Register write only with key 0x000000A5 
struct TDFR_REG 
{ 
    uint32_t tdfr; 
}; 

// Transmit Dat FIFO Vacancy Register, read only, 0x1A5 means xmit fifo empty 
struct TDFV_REG 
{ 
    unsigned int TDFV_reserved :20; 
    unsigned int TDFV_count :12; 
}; 

// Receive Data FIFO Reset Register, write only with key 0x000000A5 
struct RDFR_REG 
{ 
    uint32_t rdfr; 
}; 

// Receive Data FIFO Occupancy Register, read only 
struct RDFO_REG 
{ 
    unsigned int RDFO_reserved :20; 
    unsigned int RDFO_count :12; 
}; 

// Receive Data FIFO Data Read Port, read only 
struct RDFD_REG 
{ 
    uint32_t rdfd; 
}; 

// Transmit Length Register -- starts the actual xmit operation 
struct TLR_REG 
{ 
    unsigned int TLR_reserved :24; 
    unsigned int TLR_byteCount:15; 
}; 

// Receive Length Register, read only 
// note diagram and text in AXI4 pdf conflict for field sizes 
//  for store and forward mode 
struct RLR_REG 
{ 
    unsigned int RLR_reserved :24; 
    unsigned int RLR_byteCount:15; 
}; 

// AXIR Stream Reset Register, write only key= 0x000000A5 
struct SSR_REG 
{ 
    uint32_t ssr; 
}; 

// Transmit Destination Register, write only 
struct TDR_REG 
{ 
    unsigned int TDR_reserved :28; 
    unsigned int TDR_destination :4; 
}; 

// Receive Destination Register write only 
struct RDR_REG 
{ 
    unsigned int RDR_reserved :28; 
    unsigned int RDR_destination:4; 
}; 

// TX ID Register, read only 
struct TX_ID_REG 
{ 
    uint32_t tx_id_reg; 
}; 

// TX USER Register, read only 
struct TX_USER_REG 
{ 
    uint32_t tx_user_reg; 
}; 

// RX_ID_Register, read only 
struct RX_ID_REG 
{ 
    uint32_t rx_id_reg; 
}; 

// RX_USER_Register, read only 
struct RX_USER_REG 
{ 
    uint32_t rx_user_reg; 
}; 

// Write Port Register, write only 
struct WR_PORT_REG 
{ 
    uint32_t wr_port_reg; 
}; 

struct AXI4 
{ 
    struct ISR_REG  isr; 
    struct IER_REG  ier; 
    struct TDFR_REG  tdfr; 
    struct TDFV_REG  tdfv; 
    struct WR_PORT_REG tx_buf; 
    struct TLR_REG  tlr; 
    struct RDFR_REG  rdfr; 
    struct RDFO_REG  rdfo; 
    struct RLR_REG  rlr; 
    struct SSR_REG  ssr; 
    struct TDR_REG  tdr; 
    struct RDR_REG  rdr; 
    struct TX_ID_REG tx_id; 
    struct TX_USER_REG tx_user; 
    struct RX_ID_REG rx_id; 
    struct RX_USER_REG rx_user; 
    uint32_t   reserved[0x38]; 
}; 



#define SLCR_UNLOCK  (0xF8000008) 
#define SLCR_UNLOCK_VAL (0xDF0D) 
#define SLCR_LOCK  (0xF8000004) 
#define SLCR_LOCK_VAL (0x767B) 
#define XSLCR_FPGA_RST_CTRL (0xF8000240) 

#define ARRAY_LENGTH (16) 
static uint32_t array_fifo_data[ARRAY_LENGTH] = 
{ 
    0x0100, 
    0x0302, 
    0x0504, 
    0x0706, 
    0x0908, 
    0x0B0A, 
    0x0D0C, 
    0x0F0E, 
    0x0100, 
    0x0302, 
    0x0504, 
    0x0706, 
    0x0908, 
    0x0B0A, 
    0x0D0C, 
    0x0F0E 
}; //random sequence 

struct AXI4_REG * pAXI4 = (struct AXI4_REG*)(0x43C00000); 

int main() 
{ 



    //uint32_t baseaddr_ber=0x43c00000; 
    uint32_t baseaddr_fifo=0x43c10000; 

    Xil_Out32(SLCR_UNLOCK, SLCR_UNLOCK_VAL); // 
    Xil_Out32(XSLCR_FPGA_RST_CTRL, 0x0000000F); //Reset FPGAx_OUT_RST 
    Xil_Out32(XSLCR_FPGA_RST_CTRL, 0x00000000); //Deassert the FPGAx_OUT_RST 
    Xil_Out32(SLCR_LOCK, SLCR_LOCK_VAL);  // 

    Xil_ICacheEnable(); 
    Xil_DCacheEnable(); 

    print("---Entering main---\n\r"); 
    init_platform(); 

    // what is the '1FC' ? there are no interrupt enable bits that low 
    // why enable the receive interrupt? this code is not receiving anything 
    // Xil_Out32 & Xil_In32 (TOPEE, TCE) 
    Xil_Out32(baseaddr_fifo+0x4, 0x0C0001FC); //IER //interrupt enable register 

    Xil_Out32(baseaddr_fifo+0x2C,0x00000002); //TDR //transmit destination register 



    uint32_t state; 
    uint32_t i,val; 


    state=0; 

    while(1) 
    { // note write FIFO contains room for 512 4byte entries 
     switch (state) 
     { 
      case 0: // waiting for AXI4 to have < 20 entries in write FIFO 
       val = Xil_In32(baseaddr_fifo + 0x0c); 

       if(val > 482) //check TDFV register value //transmit data fifo vacancy 
       { // then less than 20 entries in write FIFO 
        state = 1; 
       } 
       break; 

      case 1: 
       // fill write FIFO buffer 
       do 
       { 
        for(i=0;i<16;i++) 
        { 
         Xil_Out32(baseaddr_fifo + 0x10, array_fifo_data[i]); 
        } 
        Xil_Out32(baseaddr_fifo+0x14, i*4); //TLR (transmit length register) 

        val = Xil_In32(baseaddr_fifo + 0x0c); 
       } while (val > 16); // assure room for another 16 entries to write FIFO 

       state=0; // indicate now waiting for transmit buffer to contain < 20 bytes 
       break; 
     } // end switch 
    } // end while 
} // end function: main 
+0

도와 주셔서 감사합니다. 귀하의 코드를 시뮬레이션하고, 내 보관 용 계정에 대한 링크를 공유했습니다. 내 질문이 끝날 때 링크를 볼 수 있습니다. 친절하게 링크를 열어 시뮬레이션 사진을보십시오. 시뮬레이션으로 얻은 파형 결과에서 배열 FIFO 데이터의 무작위 순서를 전송 한 후에 프로세스가 중지된다는 것을 알 수 있습니다. 그것은 0x0F0E를 전송하고 마지막으로 t를 사용 가능하게하고 t 유효 정지합니다. 그 후 0x0100을 trasnmits 한 후, 동일한 무작위 시퀀스가 ​​다시 전송되므로 연속적인 FIFO 데이터 스트림을보고 싶습니다. FIFO가 비어 있고로드되지 않은 것처럼 보입니다. 다시. – Sultan