Jump to content


Popular Content

Showing content with the highest reputation on 11/11/2013 in all areas

  1. 2 points

    array inside class

    Adding an option for you. You might want to use it like as follows: class hci_test { public: unsigned char* host_hci_pkt_arr = new unsigned char [2]; hci_test(){ host_hci_pkt_arr[0] = 0x01; host_hci_pkt_arr[1] = 0x02; } ~hci_test(){ delete [] host_hci_pkt_arr ; } }; Enable c++11 option in your compiler if you want to have it! Regards, Sumit
  2. 2 points

    array inside class

    Hello, Please note that SystemC is just a C++ library. So, there is no reason why an array cannot be declared, initialized and used inside a class. But there are some problems: 1. unsigned char* host_hci_pkt_arr == this is just a pointer to a single unsigned char NOT an array of pointers to unsigned chars. Why not : unsigned char* host_hci_pkt_arr[<SOME_SIZE>]; This is declaring array of pointers to an array of SOME_SIZE, explicitly. You could then fill the elements in as : host_hci_pkt_arr[0] = "0x01"; 2. The moment you use the "new" operator, you have to use the corresponding "delete" to clear memory in the destructor. On the other hand, by explicitly declaring the array as above, the compiler and runtime system takes care of memory allocation/deallocation. It appears that you are trying to model packets, and realistically a packet consists of a large number of bytes. If there are a large number of packets moving around, that are created dynamically, and then not deleted when the container object is deleted, one is looking at annoying memory leak issues. HTH.
  3. 1 point

    array inside class

    That's just C++ - you need to allocate the memory in the constructor, and de-allocate it in the destructor, regards Alan P.S. Another way I find is useful to help remember things like this is that sequential code in C/C++ really belongs in a function. So writing this: host_hci_pkt_arr = new(nothrow) unsigned char [2]; host_hci_pkt_arr[0] = 0x01; host_hci_pkt_arr[1] = 0x02; in a class doesn't make sense, it belongs in a function (in this particular case the class constructor).
  4. 1 point
    For the macros, which are part of the official IEEE Std 1666-2011, the index of this freely available LRM is your friend: Look for all upper-case identifiers starting with either SC_ or TLM_. If they are a macro and not a constant, it is indicated in the index. If you need all macros defined by an implementation of SystemC and TLM, probably a "grep #define" on the sources is your best option.
  5. 1 point
    Assertions in SystemC are not so powerful as they are in SystemVerilog. The assert condition is tested instantaneously and does not allow to express any time constraints. Still, they are very useful to test invariants inside your design. If you use the sc_assert macro of SystemC, you will get the context reported from which the assertion was triggered. Please note that this will terminate the simulation as it is considered to be of fatal severity. Use the SC_REPORT_* macros to generate messages with other severity levels. SCV mainly adds support for randomization and transaction tracing to SystemC. The verification working group is working towards the release of an updated version, which is compatible with the current version of the SystemC standard and modern C++ compilers. Work has started to bring the UVM to the SystemC world. First results were presented by the European FP7 project VERDI at FDL 2013 and the ESCUG meeting, which both took place this September in Paris: http://www.ecsi.org/fdl/program#verdi http://www.ti.uni-tuebingen.de/ESCUGM28-Paris-2013.1570.0.html