05-29-2021 04:50 AM
I try to implement a low cost shift function, which include 2's complement operation. When I do complement operation, C simulation result is just what I want and on-board result is 2's complement represent of C simulation, for example if C simulation is "0xf200, 0x480, 0xf900, ...", then on-board result is "0x0e00, 0xfb80, 0x700". Code is shown below. Fig 1 is C++ code and Fig 2 is verilog code generated by HLS. Variable `in_sign` in Fig 1 represent sign. `in_sign == 1` is negative and 2's complement is need. `in_sign == 0` represent positive. I think there is something wrong about if condition but I cannot find it. Thanks for your time and looking forward to any suggestion.
05-31-2021 05:59 AM
05-29-2021 06:05 PM - edited 05-29-2021 06:10 PM
Thanks for your reply.
The problem is result of C simulation is what I want, but when I place my code on board, what I get is the 2's complement represent of C simulation. For example, if C simulation output is "0xf200, 0x480, 0xf900, ...", wtih same input, on-board result is "0x0e00, 0xfb80, 0x700", which is not what I want. C simulation should be same as on-board result. I think there is something wrong about if condition. Because if I remove if/else in Fig 1 and test each branch of if/else, C simulation result and on-board result is both correct. So, I guess that when if condition in C simulation return 1, correspond verilog if condition return 0 and that is why I get different result from C simulation and on-board test. However, I cannot find any problem in my C code or verilog code generate by HLS.
I don't know if I have expressed myself clearly. Anyway, thanks for your time and looking forward to your reply.
05-29-2021 11:31 PM
Data is same. I have caught the signal of input port with ILA. RTL is not simulated. I develop with HLS and just check verilog to help me locate bug. It is strange if verilog code is correct. Is it possible a bug of HLS or vivado? May be I should implement my function in another way. Anyway, really thanks for your help ^_^.
05-31-2021 05:59 AM
05-31-2021 11:27 PM
Really thanks for your help! Finally, I found that my shift function is correct. Wrong output is caused by other part of my project, which I haven't found yet. I apply shift function in another project and finally get what I want. Sorry to bother you with such stupid question and thanks again for your time.