2017-03-17 312 views
0

不,对我来说这是行不通的。它在合成过程中显示错误:顶部功能Adder没有输出。可能的原因是:VIVADO HLS综合错误

  1. 输出参数由值
  2. 旨在输出(参数或全局变量)通过从未写入

头文件

#ifndef ADDERS_H_ 
#define ADDERS_H_ 
#include <cmath> 
#include <fstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdlib> 
using namespace std; 

// Types and top-level function prototype // 
int adders(int in1, int in2, int in3); 
#include "ap_int.h" 
typedef ap_int<8> in1_t; 
typedef ap_int<8> in2_t; 
typedef ap_int<8> out_t; 
void Adder(in1_t inA, in2_t inB, out_t sumAB); 
#endif 

测试台代码

#include <stdio.h> 
#include "ap_int.h" 
#include "Adder.h" 

int main() 
{ 
    in1_t inA; 
    in2_t inB; 
    out_t sumAB; 

    inA = 15; 
    inB = 15; 

    sumAB = inA + inB; 

    Adder(inA, inB, sumAB); 
    cout << "A = "<< inA; 
    printf("\n"); 
    cout << "B = " << inB; 
    printf("\n"); 
    cout << "SUM = "<< sumAB; 
    printf("\n"); 
} 
+0

在粘贴内容时很难遵循Stackoverflow中的格式。 – Saras

+1

加法器的返回类型为'void'。你只是想把A添加到B? int Adder(int a,int b){return a + b;} –

+0

感谢您的回复。你在哪里指出我的错误。我无法理解。是的,我使用VIVADO HLS 2014 3.1 – Saras

回答

0

您的错误是您正在传递加法器函数的输出参数。在C中,对这些值的更新只在函数内部可见并且不会传播给调用者。你应该通过指针或引用来传递它,或者简单地通过@ jp-hellemons建议的函数返回一个值。例如:

void adder(in_t inA, in_t inB, out_t& sumAB); 

Here是一篇不错的文章,通过引用解释了传递函数参数。