-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sv_fpga_start_buffer_to_cl and sv_fpga_start_cl_to_buffer for unprintable chars #406
Comments
Hi da-steve101, Can you please tell us which simulator are you using? Thanks, |
Hi da-steve101, We use the null character to indicate end of string. I have tried some examples with raw data which has a '0' value in the string passed to sv_fpga_start_buffer_to_cl and did not see the issue you are talking about. If you can give us more information about how you are using this function and the Simulator you are using, we will be able to assist you better. Thanks, |
Hi, I am just using vivado as the simulator from the fpga dev image at commit 7dc2bee. diff --git a/hdk/cl/examples/cl_dram_dma/software/runtime/common_dma.c b/hdk/cl/examples/cl_dram_dma/software/runtime/common_dma.c
index 909e8d9..76d6850 100644
--- a/hdk/cl/examples/cl_dram_dma/software/runtime/common_dma.c
+++ b/hdk/cl/examples/cl_dram_dma/software/runtime/common_dma.c
@@ -43,8 +43,8 @@ rand_string(char *str, size_t size)
}
for(i = 0; i < size; ++i) {
- unsigned int key = rand() % (sizeof charset - 1);
- str[i] = charset[key];
+ // unsigned int key = rand() % (sizeof charset - 1);
+ str[i] = i % 256;
}
str[size-1] = '\0'; This causes the cl_dram_dma/test_dram_dma_hwsw_cosim to fail with the bytes read just being '0' |
Hi da-steve101, The System Verilog DPI functions string take string as input which is why you are seeing this issue when you change the code to pass integers. The two consecutive zeros most likely is interpreted as a NULL character and subsequent numbers are ignored. If the numbers are passed in the string format as well, you will not see the same issue. If you want to pass the integer instead of string these functions would have to be edited to pass strings as well. You can find these functions in hdk/common/verif/include/sh_dpi_tasks.svh. Please let us know if there is anything else we can do to help you. Thanks, |
Hey Sajja,
I am just changing the generated data. This is in the function rand_string that initialises the write_buffer. I haven't changed any interfacing code between C and verilog.
I do not think I am sending two consecutive zeros, but i see no reason why this should not be valid input either.
Are you suggesting that I pass in as characters '0', '1' etc to represent numbers? That would be horribly inefficient.
I am aware that I can change my code ( and have already done so ) but I raised this issue as I think these functions should be be defined as accepting an array of bytes of 'buffer_size' as nothing about them suggests that they only work with printable chars and was time consuming to debug. |
Hello Steve, str[i] = i % 256 + '0' ; or str[i] = i % 256 + 48; This will help you to print the characters. Please let us know if you have issues. Regards |
I am passing in raw data values eg) floating point etc. I have modified my code to do this already. |
Hello Steve, and to make integers printable, you need to convert them to "char". Regards |
I encounter this problem too. It took me days to identify the bug. It's really annoying. Still don't know how to remedy the bug... |
I have been using sv_fpga_start_buffer_to_cl and sv_fpga_start_cl_to_buffer in simulation.
These functions only work under the assumption that there is no "\0" char in the string.
When using raw data values as input with a '0' value in the string all subsequent characters are set to 0 and hence have incorrect input passed into the design in simulation.
The text was updated successfully, but these errors were encountered: