不,对我来说不管用。在合成过程中出现了错误:顶部函数Adder没有输出。可能的原因是:
头文件
#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");
}发布于 2017-10-09 10:50:20
您的错误是将加法器函数的输出参数按值传递.在C中,对这些值的更新仅在函数中可见,不会传播到调用方。您应该通过指针或引用传递它,或者像@jp-hellemons建议的那样从函数中返回一个值。例如:
void adder(in_t inA, in_t inB, out_t& sumAB);这里是一篇很好的文章,它解释了通过引用传递函数参数。
https://stackoverflow.com/questions/42850519
复制相似问题