Matthew
Matthew

Reputation: 31

pcie memory access on linux

I'm trying to make my own pcie card. I'm using a xilinx spartan 6 sp605 board with the spartan 6 integrated block for pci express. My target system is a Ubuntu 16.04. My computer is seeing the pcie card when I do a lspci, but I'm having trouble reading memory from the pcie card.

I'm using this tool I found to read memory from the device without having to make a driver yet: https://github.com/billfarrow/pcimem/blob/master/README

I'm using the example code that comes with the spartan 6 integrated block to write to memory from the pcie card using the following code:

  wire [31:0] data_reg;
  wire [10:0] add_reg;
  assign add_reg = 11'b00000000000;
  assign data_reg  = 32'b00001111111111111111111111111111;

  PIO_EP_MEM_ACCESS EP_MEM (
  .
  .
  .
    // Memory Write Port
    .wr_addr_o(add_reg),                 // O [10:0]//wr_addr
    .wr_be_o(wr_be),                     // O [7:0]
    .wr_data_o(data_reg),                 // O [31:0]//wr_data
    .wr_en_o(wr_en),                     // O
    .wr_busy_i(wr_busy)                  // I
    );

Then I'm using ./pcimem pciesystemfile/resource0 0 w to verify 00001111111111111111111111111111 got written to memory, but it's not there, I'm reading 11111111111111111111111111111111 instead.

What might I be doing wrong?

Upvotes: 0

Views: 1239

Answers (1)

Matthew
Matthew

Reputation: 31

This is not the correct location to read and write data to pci memory:

// Memory Write Port
    .wr_addr_o(add_reg),                 // O [10:0]//wr_addr
    .wr_be_o(wr_be),                     // O [7:0]
    .wr_data_o(data_reg),                 // O [31:0]//wr_data
    .wr_en_o(wr_en),                     // O
    .wr_busy_i(wr_busy)                  // I
    );

Apparently at this stage in the code the data is split into bytes where each byte in the overall word is reversed, the data I was reading in the original question I posted must have been misread by me.

Upvotes: 0

Related Questions