test_sc.cpp

来自「H.264完整的C语言代码和DCT的代码」· C++ 代码 · 共 40 行

CPP
40
字号
#include "idb_streamc.hpp"
#include "test_kc.hpp"
// this defines the function "testProgram"
// as a stream program
STREAMPROG(testProgram);
// this stream program is a simple example
// that calls the addAndSum kernel twice
// all stream programs must have only these arguments
streamprog testProgram( String args)
//Macroprogram testProgram(String args)
{
// print the arguments (otherwise unused)
cout << args << endl;
// declare two streams of 32 integers
// note that these are streams of "im_int"
// the Imagine integer type not "int"
im_stream<im_int> s1(32);
im_stream<im_int> s2(32);
// initialize the input stream from an array
int data[32];
for (int i = 0; i < 32; i++) {
data[i] = i;
}
//streamLoadBin(data, s1);
streamLoadBin(data, 32, s1);
// declare a microcontroller variable
im_uc<im_int> uc_sum = 0;
// declare a stream of 32 integers
im_stream<im_int> temp(32);
// call the addAndSum kernel twice
addAndSum(s1, s1, temp, uc_sum);
addAndSum(s1, temp, s2, uc_sum);
// save the output and display it
streamSaveBin(data, s2);
for (int i = 0; i < 32; i++) {
cout << data[i] << " ";
}
cout << endl;
cout << "sum = " << ucRead(uc_sum) << endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?