Jump to content

scsc

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by scsc

  1. Thanks Eyck again for these pointers. Much clearer now on the structures.
  2. @Eyck, Looking at the GitHub you provided, what's the instructions to generate RTL and verification test cases? I am not familiar with what TGC cores are. Does the RTL and verification generation come with the libraries in these TGC core libraries? I think the Vibes are just for the interconnects like AXI, maybe for the cores.
  3. Thanks Guys for the links!
  4. Realized after digging into the old risc-cpu example coming with systemc's installation that the example wasn't complete. For example, the code seemed containing some cache coherence protocols like MESI. But there was no implementation for that except some printf() statements. Same as the branch prediction unit. So just wonder if there are more comprehensive example out there?
  5. Problem resolved. This line that caused syntax error input_mant.template set_slc(0, mant_i.template slc<Wfl - 2>(0)); should be: input_mant.set_slc(0, mant_i.template slc<Wfl - 2>(0));
  6. The error message is simply "syntax error: template in line 371" (the specific line in the post). Why is this an FPGA question? ac_math is from Mentor's HLS library. I agree this is not part of SystemC but I read someone here had posted AC HLS questions too.
  7. Someone seemed had used ac_math library. So here is my question. What's syntax error with the template keyword in the following line of rtest_ac_abs.cpp: ac_fixed<Wfl, Ifl, true> input_mant; // Set the sign bit to zero to ensure a positive value. input_mant[Wfl - 1] = 0; // Set the bit adjacent to the sign bit to 1 to ensure a normalized mantissa input_mant[Wfl - 2] = 1; // Set the remaining bits to the bit pattern stored in the last (Wfl - 2) bits in mant_i. input_mant.template set_slc(0, mant_i.template slc<Wfl - 2>(0)); //<<< this line has syntax error???
  8. Thanks. I realized my LRM is an "OSCI SystemC 2.1 LRM", which was published in 2005. The 1666-2011 one has sc_vector.
  9. The 2.3 LRM didn't even mention sc_vector. It is a hidden feature?
  10. The answer is here: https://stackoverflow.com/questions/48312460/c17-filesystem-is-not-a-namespace-name/48312534#48312534 This particular g++ version doesn't support full c++17 features.
  11. I think I had also already specified C++17 already: g++ -c -g -Wall -std=c++17 -DSC_INCLUDE_FX -DSC_INCLUDE_DYNAMIC_PROCESSES -I. -I/opt/systemc/include But still got that "inline" error. I am using g++ version g++ --version g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 looking at the g++ manual, there is no c++17 but c++1z. But even with "-std=c++1z", the errors still persist. What version of g++ are you using to support this feature?
  12. Tried to run an example using C++14/17 styles. But got these errors similar to this: error: ‘created’ declared as an ‘inline’ field inline static size_t created{ 0u }; Doesn't 14 or 17 support this "inline" feature? Both "-std=c++14" and "-std=c++17" generated the same errors.
  13. I don't have EDA Playground account. But I drop test code here: #include <systemc.h> SC_MODULE(nand2) { sc_in<bool> a; sc_in<bool> b; sc_out<bool> f; sc_out<bool> ff; sc_event e; SC_CTOR(nand2) { SC_METHOD(do_nand2); // the right way is use SC_METHOD + next_trigger. sensitive << a << b; SC_THREAD(nand2_thread); // but how to use use SC_THREAD instead? } void nand2_thread() { bool aa, bb, c; aa = a.read(); bb = b.read(); c = !(a & b); e.notify(4, SC_NS); for (;;) { wait(e); ff.write(c); } } void do_nand2() { bool aa, bb, ff; aa = a.read(); bb = b.read(); ff = !(a & b); next_trigger(4, SC_NS); // next_trigger in SC_METHOD had the expteced delay f.write(ff); } }; SC_MODULE(stim) { sc_out<bool> A, B; sc_in<bool> clk; void stimGen() { wait(); A.write(false); B.write(false); wait(); A.write(false); B.write(true); wait(); A.write(true); B.write(true); wait(); A.write(false); B.write(true); } SC_CTOR(stim) { SC_THREAD(stimGen); sensitive << clk.pos(); } }; int sc_main(int argc, char* argv[]) { sc_signal<bool> a; sc_signal<bool> b; sc_signal <bool> f, ff; sc_clock clk("clk", 100, SC_NS, 0.5); stim s("stim"); s.A(a); s.B(b); s.clk(clk); nand2 n2("n2"); n2.a(a); n2.b(b); n2.f(f); n2.ff(ff); sc_trace_file* wf = sc_create_vcd_trace_file("sim"); sc_trace(wf, s.clk, "clk"); sc_trace(wf, n2.a, "a"); sc_trace(wf, n2.b, "b"); sc_trace(wf, n2.f, "f"); sc_trace(wf, n2.ff, "ff"); sc_start(400, SC_NS); sc_close_vcd_trace_file(wf); return 0; }
  14. There are quite a few examples here and on the net that using SC_METHOD to implement delay is the right way. I just want to deepen my understanding on SC_THREAD. I look at the gas station example in SystemC from the Ground Up. The customer_thread2 actually has such delay implemented with a dynamic sensitivity setting: // header file declares SC_THREAD, no sensitivity SC_THREAD(customer2_thread); The implementation of customer2_thread is: void gas_station::customer2_thread(void) { for (;;) { // Simulate gas tank emptying time wait((m_full2+rand()%int(m_full2*0.10))*t_MIN); cout << "INFO: " << name() << " Customer2 needs gas (1) at " << hms() << endl; m_tank2 = 0; // Request fillup from attendant and then // wait for acknowledging event. do { e_request2.notify(); // I need fillup! (2) wait(e_filled); // use dynamic sensitivity <<<<<<<<< this is the delay between e_request2.notify() and e_filled event. } while (m_tank2 == 0); }//endforever }//end customer2_thread() Since e_filled in the customer2_thread comes from another method, I wonder if I can put a standalone event inside the same thread? In other words, the event just triggers the delay from the same thread? For example, a delay thread in a NAND2 function: void nand2_thread() { // nand2_thread has no sensitivity, just like customer2_thread bool aa, bb, c; aa = a.read(); bb = b.read(); c = !(a & b); e.notify(4, SC_NS); // e is an object in nand2. This event seems not notified and triggered correctly, for (;;) { wait(e); // e never comes ff.write(c); } } I think the above code didn't have the right event notified so wait(e) didn't work. What's the right way to setup this event? By the way, how to set enclosure in this forum for code? Pasting code as raw text is hard to read.
  15. Yeah, I did end up putting angles inside entry() and it worked. But I didn't know why the SC_CTOR way didn't work. Now you have pointed out the difference between the FIR example and my error. I complete got it now. Thanks for the advance on variable life times and visibility.
  16. But fir_data.h in SystemC's example folder used similar coefficient declaration: SC_CTOR(fir_data) { SC_METHOD(entry); dont_initialize(); sensitive << reset; sensitive << state_out; sensitive << sample; #include "fir_const.h" }
  17. It seemed different behavior when putting a constant array inside the SC_CTOR vs. in process function. For example, SC_CTOR(ex) { ... double angles[28]; SC_METHOD(entry); double angles[28] = {...} } vs. void ex::entry() { double angles[...] = {...}; } When putting constant array inside SC_CTOR, the readout values aren't correct. They are like huge numbers to power of 63. The second way had correct readout values.
  18. Thanks again Eyck. I confirmed that #define N was the culprit. I can run the example after changing N to something else (along with a typo in the typedef line). This is a tricky one. But the errors made sense looking back as there is "int N" in sc_fixed template
  19. Thanks Eyck, I tried to use double input for an sc_fixed data type (see the attached example). Somehow the direct assignment didn't work. Or because the errors I got were from sc_port.h, which has not been used at all. So I wasn't sure the direct assignment actually works. #define SC_INCLUDE_FX #define N 25 #include <systemc.h> using namespace sc_core; using namespace sc_dt; typedef sc_fix<32, 16, SC_RND> fixed_type; double fix_fir(double _in[]) { fixed_type in[N], c[N], t[N], y; int i; double ct = 0.9987966; for (i = 0; i < N; i++) { in[i] = _in[i]; c[i] = ct; ct = ct / 2; } for (i = 0; i < N; i++) { t[i] = c[i] * in[i]; y += t[i]; } return y; } int sc_main(int argc, char* argv[]) { double _in[25]; double y; for (int i = 0; i < 25; i++) { _in[i] = (double)i; } y = fix_fir(_in); cout << "y = " << y << endl; return 0; } Some errors are like these: Error (active) E0706 expected a ',' or '>' sc_fixed_fir \Documents\systemc-2.3.2\src\sysc\communication\sc_port.h 386 Error (active) E0306 default argument not at end of parameter list sc_fixed_fir \Documents\systemc-2.3.2\src\sysc\datatypes\fx\sc_fixed.h 61 Line 61 of sc_fixed.h has this definition in which the default argument to sc_fixed is "int N": // classes defined in this module template <int W, int I, sc_q_mode Q, sc_o_mode O, int N> class sc_fixed;
  20. I dug up this old thread on double(float) conversion to sc_bv: Apparently we can convert a double to sc_ieee_double (see the snippet below from that post) then manually convert to sc_fix(ed) from mantissa and exponent or convert to sc_fixed from the bitvector (with some truncation because the bitvector would have different bitwidth to sc_fixed. But just wonder if there are built in methods that perform the conversion to sc_fixed directly? double d = ...; sc_dt::scfx_ieee_double id(d); // convert to IEEE 754 bitfield // prepare parts bool sgn = id.negative(); sc_dt::sc_uint<11> exp = id.exponent(); sc_dt::sc_uint<53> mnt = ( sc_dt::uint64( id.mantissa1() ) << 20 ) | id.mantissa0(); // concatenate parts to bitvector sc_dt::sc_bv<64> bv = ( sgn, exp, mnt );
  21. Ah, thanks Eyck. It works! Apparently I didn't read the LRM ...
  22. This must be a very simple issue but ... So I had narrowed down to this simple function: #include <systemc.h> void test_overflow_modes() { sc_fixed<6, 4> a = -7; cout << " a in dec: " << a << endl; } int sc_main(int argc, char* argv[]) { test_overflow_modes(); sc_start(); return 0; } VS2017 had compilation error: Error (active) E0020 identifier "sc_fixed" is undefined. I checked my installation under /src/sysc/datatypes/fx and saw sc_fixed.h but not sc_fixed.cpp. And I recalled when I compiled this systemc 2.3.2 systemc.sln, I didn't see sc_fixed.cpp was compiled. Is this the problem? What is missing? Thanks
  23. Thanks for pointing the binding process out. I do see slave_port is being used.
  24. Yes, I figured this one out by inserting a process ...
  25. sc_port<simple_bus_slave_if, 0> slave_port; In the above snippet, how many slave_port copies of simple_bus_slave_if are initialized, given N=0? The default of sc_port is N=1.
×
×
  • Create New...