Git Product home page Git Product logo

Comments (3)

ymherklotz avatar ymherklotz commented on August 15, 2024

Hi, the first issue you mention is actually a parsing issue with CompCert, it just doesn't allow empty initialiser lists. Instead the following will actually parse and compile with CompCert:

#define NUM_TAPS 4
void fir ( int input, int *output, int taps [NUM_TAPS] ) {

    static int delay_line [NUM_TAPS] = {0};

    int result = 0;

    for ( int i = NUM_TAPS -1 ; i > 0 ; i--) {
        delay_line[i] = delay_line[i - 1];
    }

    delay_line[0] = input;

    for ( int i = 0 ; i < NUM_TAPS ; i ++ ) {
        result += delay_line[i] * taps[i];
    }

    *output = result;
}

Finally though, unfortunavely Vericert doesn't support a large subset of C yet, so the designs that you can compile at the moment don't really look like typical HLS designs as you have written here. The below function will at least compile and kind of do what you want:

#define NUM_TAPS 4
int main ( int input ) {

    int taps [NUM_TAPS] = {1, 2, 3, 4};

    int delay_line [NUM_TAPS] = {0};

    int result = 0;

    for ( int i = NUM_TAPS -1 ; i > 0 ; i--) {
        delay_line[i] = delay_line[i - 1];
    }

    delay_line[0] = input;

    for ( int i = 0 ; i < NUM_TAPS ; i ++ ) {
        result += delay_line[i] * taps[i];
    }

    return result;
}

In general though, the things that you are using which are not supported in Vericert but used all the time in HLS are (which actually incidentally all have to do with the simplistic memory handling in Vericert:

  • Static variables, very useful for persistent state. This is related to the simplistic memory layout that Vericert supports.
  • Passing arrays into functions as arguments.
  • Returning a value by modifying a pointer.
  • Supporting not having a main function. This one is also quite difficult to tackle, but would be necessary for the HLS tool to be usable in practice.

Thanks for trying out Vericert though! I'm happy you managed to compile it in the first place. I hope this helps, and let me know if you have any thoughts.

from vericert.

ymherklotz avatar ymherklotz commented on August 15, 2024

But I will admit, without static the second design I posted does not implement an FIR filter.

from vericert.

nanoeng avatar nanoeng commented on August 15, 2024

Thanks a lot for the detailed reply!

from vericert.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.