UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer ayhamzedan
Observer
4,582 Views
Registered: ‎08-04-2016

Flag does not hold high when implemeted on the device.

Jump to solution

I have written the code for a buffer. It is supposed to output data under a certain condition and along with the data, it is supposed to raise a flag to indicate that this data can be used because the condition is met. The code is as follows:

void foo(           double inputData,
                         bool     *valid,
                         double *output)

    #pragma HLS PIPELINE II=4

    #pragma HLS INTERFACE ap_ovld port=packet_IQ
    #pragma HLS INTERFACE ap_ovld port=valid
    #pragma HLS INTERFACE ap_vld port=output

    double BufferVector [100];

 

// here is the code to evaluate the condition 

// also a new sample is pushed into the buffer every function call

 

    if (condition==true)
        *valid =true;


    if (*valid){
        *output =  BufferVector[0];
        count     += *valid;
    }


    // if the complete data is recorded, reset the block variables
    if (count > data_len) {
       *valid= false;  // stop recording the data
        count     = 0;
    }

 

The C and RTL simulations are running as expected.  However, when the condition is met, instead of holding high until it is set low, the valid flag goes high for a clock cycle, then goes down again, and stays down. 

Also, I noticed that there is a valid_o, valid_o_vld and a valid_i. Could it be that leaving the valid_i dangling will make it reset to low? if so, how can I force HLS to ignore the valid_i input?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Scholar jprice
Scholar
8,624 Views
Registered: ‎01-28-2014

Re: Flag does not hold high when implemeted on the device.

Jump to solution

It would appear you have a couple misconceptions about how HLS interfaces work. First I would search this forum and the internet for the volatile keyword as that's important for you to understand. Then I would read about the various interfaces in the user guide (all of this is spelled out quite well).

 

Part of what's going on is that you both write to valid, and then try to read from it. As a result it has to be both an input and output. You can fix this in a couple of ways but I have to ask why have valid at all? If you don't want a value to be consumed then simply don't write the output in the first place. The ap_vld interface already has a valid for when you decide to write to the output. Your valid as such will also have its own valid signal in RTL which means each time you write it value of valid and its own valid will be asserted for one cycle (that's how the interface works). If you truly want that functionality you'll have to be more descriptive as to what you're looking for. I would recommend that your code would look as follows:

 

    #pragma HLS INTERFACE ap_vld port=output
    double BufferVector [100];
 
    if (condition) {
        *output =  BufferVector[0];
         count++;
    }

    // if the complete data is recorded, reset the block variables
    if (count > data_len) {
        count     = 0;
    }
3 Replies
Scholar jprice
Scholar
8,625 Views
Registered: ‎01-28-2014

Re: Flag does not hold high when implemeted on the device.

Jump to solution

It would appear you have a couple misconceptions about how HLS interfaces work. First I would search this forum and the internet for the volatile keyword as that's important for you to understand. Then I would read about the various interfaces in the user guide (all of this is spelled out quite well).

 

Part of what's going on is that you both write to valid, and then try to read from it. As a result it has to be both an input and output. You can fix this in a couple of ways but I have to ask why have valid at all? If you don't want a value to be consumed then simply don't write the output in the first place. The ap_vld interface already has a valid for when you decide to write to the output. Your valid as such will also have its own valid signal in RTL which means each time you write it value of valid and its own valid will be asserted for one cycle (that's how the interface works). If you truly want that functionality you'll have to be more descriptive as to what you're looking for. I would recommend that your code would look as follows:

 

    #pragma HLS INTERFACE ap_vld port=output
    double BufferVector [100];
 
    if (condition) {
        *output =  BufferVector[0];
         count++;
    }

    // if the complete data is recorded, reset the block variables
    if (count > data_len) {
        count     = 0;
    }
Observer ayhamzedan
Observer
4,538 Views
Registered: ‎08-04-2016

Re: Flag does not hold high when implemeted on the device.

Jump to solution

Thank you for your answer. Coming from a software background, these information were very important to read

0 Kudos
Scholar jprice
Scholar
4,530 Views
Registered: ‎01-28-2014

Re: Flag does not hold high when implemeted on the device.

Jump to solution

No problem, it's easy to think that HLS is like writing software but you have to approach it from the RTL mindset. For a software person with no FPGA experience there is a learning curve. I'd recommend learning how to do some simple VHDL/Verilog designs as that experience will help you immensely. I hope you're having fun learning this stuff :)

0 Kudos