Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

APB slave DUT and test-bench written in system c.

  1. As an exercise, I decided to write a simple DUT and test it, using systemc.

  2. The test-bench uses SCV to randomize some signals and timing between transaction to the DUT. It also, optionally, generates some print messages to help debug. Waves are also created in VCD format.

  3. The following variables are being randomized:
    * The number of read and write transactions are controlled by the variable loop_r:
    scv_smart_ptr loop_r ("loop_r"); //random loop number
    loop_r->keep_only(100, 200);
    ...
    for (unsigned int i=0; i<(unsigned int)*loop_r; i++) {
    * The delay between transactions and the transaction address value to be driven on the bus.
    * The data, which is written to the DUT is the value of address + 1, to facilitate visual debug on wave.

  4. Clock is generated using systemc sc_clock command:
    sc_clock pclk("CLOCK", 50, SC_NS, 0.5, 0.0, SC_NS);

  5. The test-bench uses a seed to control randomization:
    scv_random::set_global_seed(17581);
    Later it shown how to set, from a bash script, the test-bench seed value.

  6. The DUT address width and data width are controlled, at compile time, by define statements:
    #define PADDR_W 8
    #define PDATA_W 16

  7. To farther assist in the debug, the DUT is able to print debug messages as well. This is controlled by a define statement:
    #define DEBUG_1

  8. The DUT implements a simple APB memory device.

  9. The DUT memory is a sparse model to maximize efficient CPU memory usage. Sparse memory models are also discussed at: memory HDL models

  10. The memory function uses a static map array statement.
    static map< sc_uint<PADDR_W> sc_uint<PDATA_W> > array;
    Write to the array is as simple as
    array[a]=d;
    The find function simplifies the read code, which accesses a memory location:
    if(array.find(a) != array.end()) {

  11. The compilation are done with make files. Two sets exist. If SCV is not used, than a simple set may be selected: Makefile.osci and Makefile.defs. Otherwise use: Makefile and Makefile.rules.

  12. If compilation ends okay, an executable is generated and named run.x. To run it, one must set the environment once by doing:
    source scv_env.unx

  13. In the following link, I describe how to compile and run the project. I used two ways: command and script:
    APB slave compilation scripts and commands

  14. The source code, make files, read me, GTK signals file are available at: APB slave files

  15. Waveform example, using GTK WAVE:


 



Home

An extension to the systemc example from cadance of producer consumer.

A small verification project using, specman, to verify a VHDL UART.




Also available on this site a VHDL project, made of two AHB masters, one arbiter, one AHB to APB bridge and one simple APB slave. If you are interested in this project as a graduate project, contact me via mail and put in the subject: non free AHB project.


Search This Site




new pages on this site