WriteToPipeIn and ReadFromPipeOut using python doesnt seem to work?

So I wanted to use the SDRAM using python to see if I could write and read on it. I configured the XEM3010 with the ramtest.bit file that was given in the samples and used the python API to manipulate the RAM.

The first thing I did was set the wire ins to reset then enable write. Then i created a bytearray of 2048 elements of \x12, I used WriteToPipeIn to send this to the RAM and it returned -15 which was weird. Then I set the wire ins to enable read and used ReadFromPipeOut to another bytearray with the same size to see if I can get back what I wrote but the other buffer just has random elements in it instead. I’d be really grateful if anyone could help me with this

1 Like

Hi!

The -15 error code you are receiving indicates an UnsupportedFeature error (Error Codes - Opal Kelly Documentation Portal). Double check the parameters and the documentation to make sure you are providing the correct arguments. The DES sample also uses pipes and has a Python implementation that you can checkout as well.

Hi! thank you for your reply I think I have sorted that error out now when I send my bytearray with 2048 elements it returns 2048 in the shell. I’m still trying to write and read to the SDRAM but I don’t think it’s working. This is my code.

import ok

dev=ok.okCFrontPanel() #call okcfrontpanel
pll=ok.okCPLL22150() #call pll
dev.OpenBySerial(dev.GetDeviceListSerial(0)) #open device
buf=bytearray(b’\22’*2048) #create write array of elements x12(actually creates x12 not 22)
buf1=bytearray(b’\00’*2048) #creates read array of 2048 x00 elements
dev.SetWireInValue(0x00,0b0100) #send reset high
dev.UpdateWireIns()
dev.SetWireInValue(0x00,0b0010) # send write enable
dev.UpdateWireIns()
dev.WriteToPipeIn(0x80,buf) # write the buffer through pipe to sdram
dev.SetWireInValue(0x00,0b0001) #send read enable
dev.UpdateWireIns()
dev.ReadFromPipeOut(0xA0,buf1) #read into the read buffer
print(buf1)

I’m trying to just write elements from buf into sdram and read from sdram to buf1. I have ramtest.bit configured on the FPGA. So for both write and read using the pipes they return 2048 in the shell but in buf1 the values are still x00 when it’s supposed to be x12. I’m not sure what the issue is.

I figured what I did wrong, in ramtest.bit both the write and read shared the same address counter so if wrote five five memory elements and read without resetting I would read the next five memory elements. So now to make this code work I just reset in between writing and reading.

Ex:
import ok

dev=ok.okCFrontPanel() #call okcfrontpanel
pll=ok.okCPLL22150() #call pll
dev.OpenBySerial(dev.GetDeviceListSerial(0)) #open device
buf=bytearray(b"\x12"*2048) #create write array of elements x12
buf1=bytearray(b"\x00"*2048) #creates read array of 2048 x00 elements
dev.SetWireInValue(0x00,0b0100) #send reset high
dev.UpdateWireIns()
dev.SetWireInValue(0x00,0b0010) # send write enable
dev.UpdateWireIns()
dev.WriteToPipeIn(0x80,buf) # write the buffer through pipe to sdram
dev.SetWireInValue(0x00,0b0100) #send reset high
dev.UpdateWireIns()
dev.SetWireInValue(0x00,0b0001) #send read enable
dev.UpdateWireIns()
dev.ReadFromPipeOut(0xA0,buf1) #read into the read buffer
print(buf1)

so that’s about it.

1 Like