Page 1 of 1
how do I use 64-bit memory interface
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
by Guest
Hi Eli,
Thanks for your efforts on Xillybus! I have attached my accelerator with Xillybus (revision XL) on VC707.
Now I would like to make use of the memory interface so that I could send some instructions to my accelerator before triggering the streaming input data.
However, when I requested a 64-bit wide, 5-bit depth memory (specifically xillybus_mem_64) and connected with my design, I found that it is impossible to send contents to the memory using memwrite command. And the command only can be executed for the address as multiples of 4. Do I need to make any change to the host program memwrite.c?
In addition, the instructions are 40-bit wide and I am only using the lower 40-bit of the memory interface. I have verified the results on simulation.
Regards,
Louis
Re: how do I use 64-bit memory interface
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
by support
Hello,
Please refer to section 6.1 ("Seekable Streams") in the Xillybus host application programming guide for Linux:
http://xillybus.com/downloads/doc/xilly ... _linux.pdf(or for Windows, if that's what you're using).
That section discusses the relation between 16 and 32 bit wide seekable streams, and the outcome of the address seen by logic. It also says that for a 32-bit wide stream, the seek address must be a multiple of 4 (as it wouldn't make any sense otherwise).
For a 64-bit wide seekable stream, it's the same, only with multiples of 8. Note that for an 64-bit wide stream, the address seen by hardware is the seek position divided by 8.
Unlike the narrower bit widths, the driver allows meaningless seeks of multiples of 4 (that aren't multiples of 8).
In short, data and address go in multiples of 8 bytes, or 64 bits. memwrite.c should be adapted accordingly.
Regards,
Eli
Re: how do I use 64-bit memory interface
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
by Guest
Hi Eli,
Thanks for your explanation. I have changed the data type from unsigned char to long for the 4th argument (argv[3]) in memwrite.c. And the write function is modified as allwrite(fd, &data, 8). The whole code is as follows.
However, I can only send data to the least 32-bit address (4 bytes). It is still not effective for the higher 4 bytes address. Can you give me some advice?
void allwrite(int fd, long *buf, int len);
int main(int argc, char *argv[]) {
int fd;
// int address;
long address;
// unsigned char data;
long data;
if (argc!=4) {
fprintf(stderr, "Usage: %s devfile address data\n", argv[0]);
exit(1);
}
address = (long) atoi(argv[2]);
// data = (unsigned char) atoi(argv[3]);
data = (long) atoi(argv[3]);
fd = open(argv[1], O_WRONLY);
if (fd < 0) {
if (errno == ENODEV)
fprintf(stderr, "(Maybe %s a read-only file?)\n", argv[1]);
perror("Failed to open devfile");
exit(1);
}
if (lseek(fd, address, SEEK_SET) < 0) {
perror("Failed to seek");
exit(1);
}
allwrite(fd, &data, 8);//1
return 0;
}
void allwrite(int fd, long *buf, int len) {
int sent = 0;
int rc;
while (sent < len) {
rc = write(fd, buf + sent, len - sent);
if ((rc < 0) && (errno == EINTR))
continue;
if (rc < 0) {
perror("allwrite() failed to write");
exit(1);
}
if (rc == 0) {
fprintf(stderr, "Reached write EOF (?!)\n");
exit(1);
}
sent += rc;
}
}
Re: how do I use 64-bit memory interface
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
by support
Hello,
Have you verified that "data" contains the desired value in the C program? A plain printf of its value will do.
I don't know how many bits "long" stand for on your system, and even less how atoi() treats large integers.
And the fact that you needed (?) to cast to long isn't very encouraging. Casting from a shorter word to a longer doesn't give it more valid bits.
Regards,
Eli
Re: how do I use 64-bit memory interface
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
by EdwinGi
Hi Eli, can this actually vary from system to system? I'm just curious.
Re: how do I use 64-bit memory interface
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
by support
Hello,
The rule of thumb is that one can't rely on that C types have the same sizes on different platforms and compilers. Same goes for library functions that depends on these types.
Whether there could be a difference in this specific case, I haven't taken the time to investigate. It's much easier to add a printf() and see. Or if you're curious, something like printf("size of long is %d bytes\n", sizeof(long)) etc.
Regards,
Eli