cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dr_jjrussell
Participant
Participant
590 Views
Registered: ‎11-02-2015

Possible incorrect CoSim Code

Using Vitis HLS 2020.1, code that passes the CSIM and SYNTHESIS stage fails to compile in the CoSIm stage.  After digging a bit, I think I found the file that is actually being compiled.   It is heavily preprocessed and it looks like there are statements which splits the template declaration and the qualified method,  rendering the code illegal .

template <typename FRAME_STREAM, typename FRAME_WRITER, typename TRANSPOSER, typename MODULE_CONFIG>
#ifndef HLS_FASTSIM
#ifdef __cplusplus
extern “C”
#endif
void apatb_compress_sw(hls::stream<FrameAxiWordTemplate<FrameWordTemplate<96> >, 0> &, hls::stream<ap_axiu<64, 4, 1, 1>, 0> &, const ModuleConfigTemplate<8>);
# 270 “../../../.././shared/src/CompressTest.hpp”
int ProcesserFileTemplate<FRAME_STREAM, FRAME_WRITER, TRANSPOSER, MODULE_CONFIG>::
process (int nevents, int nsamples)

 

I've verified (or at least tried to) that HLS_FASTSIM is not defined, but even so the void apatb_compress_sw declaration is illegal.   This snippet is inserted in some, but not all, implementations of this template class.  It looks like this is depends on whether the method calls an external method, but perhaps I am speculating too much.

JJRussell 

0 Kudos
3 Replies
wenchen
Moderator
Moderator
483 Views
Registered: ‎05-27-2018

Hi @dr_jjrussell ,

It seems that you are using a rare template function. I'm not experienced with this kind of template statement. Could you please share the logs of cosim errors?

Wen

-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.


**~ Got a minute? Answer our Vitis HLS survey here! ~**


-------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
dr_jjrussell
Participant
Participant
439 Views
Registered: ‎11-02-2015

Wen,

I have twice posted detailed replies, but neither has appeared.  It is pretty time-consuming.  Any idea why these are disappearing or am I not looking in the proper place?  I will post again if necessary.

Jim Russell

 

0 Kudos
dr_jjrussell
Participant
Participant
430 Views
Registered: ‎11-02-2015

Wen,

Here is another attempt to reply.  But first, in response to your comment: you are using a rare template function

I am not the best with C++ templates, but the code is standard for declaring a method outside a template class. Correct me if I am wrong.

The code for the original error is gone.  I had to make progress.  I don't think the log file was particularly enlightening.  I posted other errors in reply in another post.  But I do still have other errors, which is not in a template class, although one of its members is (Histogram is a templated class; Histogram just a using alias.)

Here is the original code, the .cpp_pre.tb.cpp file from that code and the log file

Original Code

 

inline
HistogramVerify::HistogramVerify (Histogram const &hist,
                                  int             nbits,
                                  int          nentries,
                                  uint16_t        first) :
   m_hist     (    hist),
   m_nbits    (   nbits),
   m_nentries (nentries),
   m_first    (   first)
{
   return;
}

 

The equivalent code in the .cpp_pre.tb.cpp file

 

inline
HistogramVerify::HistogramVerify (Histogram const &hist,
                                  int nbits,
                                  int nentries,
                                  uint16_t first) :
   m_first ( rint),
   m_nbits ( nbits),
   m_nentries (nentries),
   m_first ( first)
{
   return;
}

 

Note the change in the first initializer m_hist (hist) -> m_first ( rint)

The relevant lines from the log file which are the C++ errors you would expect given the above source code.

 

In file included from ../../../.././shared/src/AP-Encoder.cpp:595:0,
                 from ../../../.././shared/src/Compress.cpp:355,
                 from /afs/slac.stanford.edu/u/ey/russell/Experiments/nexo/nexo-daq-compression/hls/NexoDaqCompressionCharge/src/ChargeCompress.cpp:9:
../../../.././shared/src/Histogram-Decoder.hpp: In constructor ‘HistogramVerify::HistogramVerify(const Histogram&, int, int, uint16_t)’:
../../../.././shared/src/Histogram-Decoder.hpp:93:1: error: multiple initializations given for ‘HistogramVerify::m_first’
../../../.././shared/src/Histogram-Decoder.hpp:93:1: error: uninitialized reference member in ‘const Histogram& {aka const class HistogramTemplate<ap_uint<5>, ap_int<14>, 32, 2048>&}’ [-fpermissive]
../../../.././shared/src/Histogram-Decoder.hpp:85:20: note: ‘const Histogram& HistogramVerify::m_hist’ should be initialized
In file included from ../../../.././shared/src/Compress.cpp:355:0,
                 from /afs/slac.stanford.edu/u/ey/russell/Experiments/nexo/nexo-daq-compression/hls/NexoDaqCompressionCharge/src/ChargeCompress.cpp:9:

 

 

0 Kudos