Results 1 to 5 of 5

Thread: Integer vs Arbitrary Precise Integer Intel HLS

  1. #1
    Join Date
    Jan 2018
    Posts
    22
    Rep Power
    1

    Default Integer vs Arbitrary Precise Integer Intel HLS

    Hello all great people and Anand,


    Below is the code snippet. I am using Intel HLS tool. The data type used in below given code is integer. I want to compare the result of integer data type with arbitrary precise integer represented as ac_int <W> in Intel HLS tool through AC data type library of Intel HLS tool. My question is what should be the exact representation of ac_int <W> in terms of 'W' for input arrays, dout, acc, a_reg, sub and sub2 for less latency and less resource utilization.
    I want to use the exact code for precise integer type instead of native integer and later compare the results of integer and arbitrary precise data type.


    void diff_sq_acc(int a[N], int b[N], int *dout)
    {

    unsigned char i;
    int acc= 0;
    int a_reg, b_reg, sub, sub2;

    for(i=0; i<N; i++)
    {


    a_reg = a[i];
    b_reg = b[i];
    sub = a_reg - b_reg;
    sub2 = sub*sub;
    acc += sub2;
    }

    *dout = acc;
    }

  2. #2
    Join Date
    Nov 2017
    Posts
    258
    Rep Power
    1

    Default Re: Integer vs Arbitrary Precise Integer Intel HLS

    Hi,

    You can try to optimize as per you design requriments.
    Code:
    #include "HLS/hls.h"
    #include <stdio.h>
    #include "HLS/ac_int.h"
    #include "HLS/ac_fixed.h"
    #include "HLS/extendedmath.h"
    #include "HLS/math.h"
    typedef ac_int<8, false> fixed_8_t;
    typedef ac_int<16, false> fixed_16_t;
    
    #define N 2
    
    component void dut(fixed_8_t a[N], fixed_8_t b[N], fixed_8_t *dout)
    {
    unsigned int i;
    fixed_16_t acc= 0;
    fixed_8_t a_reg, b_reg, sub;
    fixed_16_t sub2;
    for(i=0; i<N; i++)
    {
    a_reg = a[i];
    b_reg = b[i];
    sub = a_reg - b_reg;
    sub2 = sub*sub;
    acc += sub2;
    }
    *dout = acc;
      
     }
    
    int main() {
    	fixed_8_t z;
    	 fixed_16_t ip = &z;
    	fixed_8_t x[N]={128,128};
    	fixed_8_t y[N]={128,128};
      dut(x,y,&z);
      return 0;
    
    }
    let me know if this has helped resolve the issue you are facing or if you need any further assistance.

    PS:Same as thread https://alteraforum.com/forum/showth...t=57668&page=2

    Best Regards,
    Anand Raj Shankar
    (This message was posted on behalf of Intel Corporation)

  3. #3
    Join Date
    Jan 2018
    Posts
    22
    Rep Power
    1

    Default Re: Integer vs Arbitrary Precise Integer Intel HLS

    Dear Anand,

    thanks ! it works...i think there was a type error in your code... *dout should be fixed_16_t..... right ?

  4. #4
    Join Date
    Nov 2017
    Posts
    258
    Rep Power
    1

    Default Re: Integer vs Arbitrary Precise Integer Intel HLS

    Hi,

    There was no error in code.
    Yes logically it should be fixed_16_t .

    let me know if you need any further assistance.

    Best Regards,
    Anand Raj Shankar
    (This message was posted on behalf of Intel Corporation)
    Last edited by Anand Raj Shankar; February 12th, 2018 at 05:08 AM.

  5. #5
    Join Date
    Jan 2018
    Posts
    22
    Rep Power
    1

    Default Re: Integer vs Arbitrary Precise Integer Intel HLS

    ok got your point...thanks !

Similar Threads

  1. Replies: 1
    Last Post: March 28th, 2013, 03:36 PM
  2. using integer
    By sim in forum VHDL
    Replies: 10
    Last Post: January 22nd, 2013, 09:44 AM
  3. integer arithmetic
    By danielg1 in forum VHDL
    Replies: 3
    Last Post: November 6th, 2012, 01:11 AM
  4. Integer used as parameter
    By jasonkee111 in forum Quartus II and EDA Tools Discussion
    Replies: 6
    Last Post: September 10th, 2009, 05:15 PM
  5. Is it possible to represent a 48 bit integer?
    By xbos5505 in forum General Software Forum
    Replies: 1
    Last Post: October 20th, 2005, 09:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •