2013年12月1日 星期日

raspberry pi projects case study

1.  airplay remote audio player
http://gsyan888.blogspot.tw/2013/04/raspberry-pi-shairport-airplay-receiver.html

1.1 implement
http://www.instructables.com/id/raspbAIRy-the-RaspberryPi-based-Airplay-speaker/step3/Installation/

2 wifi adaptor
http://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/overview

3. game player
http://pimame.org/

4. media center by xbmc + navi = free movie + airplay media
http://www.instructables.com/id/How-to-Make-a-Raspberry-Pi-Media-Panel-fka-Digita/step2/Order-an-LCD-Controller-Board/
http://www.instructables.com/id/XBMC-Media-Center-with-Raspberry-Pi/
https://www.youtube.com/watch?v=rjcu3eYvlMY

5. microcontroller i2c python
http://www.instructables.com/id/Raspberry-Pi-I2C-Python/
http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

6. microcontroller gpio
http://www.instructables.com/id/Web-Control-of-Raspberry-Pi-GPIO/

7. small web server
http://www.instructables.com/id/Raspberry-Pi-Web-Server/step5/SSH-Login/

8.Running Minecraft on a Raspberry Pi
http://learn.adafruit.com/running-minecraft-on-a-raspberry-pi

9. IDE debug
http://learn.adafruit.com/webide/installation

10 ATX power controller
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=40&t=59919

2013年11月18日 星期一

python microcontroller case study

arm raspberrypi
http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

pymcu
http://www.pymcu.com/index.html

python microcontroller
http://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers

real time warning message broadcast system
bluetooth microphone
android usb


brain wave monitor

brain wave product 

bike LED 風火輪

風阻訓練台

arduino (openhardware)

openhardware

beagleboard source code


benchmark arm vs x86

power profile

bike fit

bike fit calculate

2013年10月14日 星期一

llvmpy = JIT python via llvm keynotes

  • llvmpy
    • a jit python interpreter via llvm
    • a  wrapper interface between llvm c/c++ function calls and python interface
  • flow
    • wrapper c/c++ code to shared lib, such as pass, target, VM...
    • explore the shared lib to python import path
    • import it
  • example
  • original c/c++ code
    #include "dpi.h"
    
    /* c_add */
    int
    c_add(int a, int b) {
      return a+b;
    }
    
    wrapper it via c/c++ python extend
    #include <Python/Python.h>
    #include <numpy/arrayobject.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "dpi.h"
    
    /* wrapper add, ref count definition */
    static PyObject *
    dpi_add_wrapper(PyObject *self, PyObject *args)
    {
      int a, b, c;
    
      // parse arguments
      if (!PyArg_ParseTuple(args, "ii", &a, &b)) {
        return NULL;
      }
    
      // run the actual function
      c = c_add(a, b);
    
      // build the result to a Python object.
      return Py_BuildValue("i", c);
    }
    
    /* register methods */
    static PyMethodDef DPIMethods[] =
    {
          {"dpi_add", dpi_add_wrapper, METH_VARARGS, "Calculate the sum of two integers."},
          {NULL, NULL, 0, NULL}
    };
    
    
    register to python search path
    from distutils.core import setup, Extension
    
    
    # ref : http://docs.python.org/2/extending/building.html
    # the c++ extension module
    extension_mod = Extension("dpi", ["moduledpi.c", "dpi.c"], include_dirs=['/var/root/anaconda/lib/python2.7/site-packages/numpy/core/include'],
    library_dirs=['/var/root/anaconda/lib/python2.7/site-packages/numpy/core/lib', '/var/root/anaconda/lib/python2.7/site-packages/numpy/lib'])
    
    setup(name = "dpi", ext_modules=[extension_mod])
    
    run it
    >>> python
    >>> import dpi
    >>> dpi.dpi_add(1,2)
    

2013年10月6日 星期日

how many ways to import c/c++ to python


  • import your c/c++ to python
  • way
    • cython
    • pyobject python c api (python extension with C)
    • swing
    • ctypes
  • ref
    • http://realmike.org/blog/2012/07/05/supercharging-c-code-with-embedded-python/
    • https://intermediate-and-advanced-software-carpentry.readthedocs.org/en/latest/c++-wrapping.html
    • http://realmike.org/blog/2012/07/08/embedding-python-tutorial-part-1/
    • http://www.tutorialspoint.com/python/python_further_extensions.htm
    • https://mail.python.org/pipermail/capi-sig/2009-May/000256.html
    • http://docs.scipy.org/doc/numpy/user/c-info.how-to-extend.html
    • http://dan.iel.fm/posts/python-c-extensions/
    • http://web.mit.edu/course/6/6.863/OldFiles/python/old/numpy-1.0.1/numpy/core/src/arraymethods.c
    • http://scipy-lectures.github.io/advanced/interfacing_with_c/interfacing_with_c.html#introduction

2013年9月27日 星期五

fast debug key notes

these are my tips for fast debug.

  • set breakpoint when the assertion was happened
    • like GDB methodology 
      • forward, backward, force signal, release signal
    • tip
      • forcing the error signal value to your expect signal value when the simulation assertion was happened. if the signal was forced, then continuous go through it without rerun again. that can save the interrater running  times
  • dump the error time window waveform without whole simulation time dump
    • tip
      • using the interactive method to dump waveform. 
        • 1. find the error happened time
        • 2. set breakpoint 
        • 3. jumping the previous time window via backward breakpoint
        • 4. open interactive dump waveform command
        • 5. start dumping until the next breakpoint was happened
  • using assertion 
  • using verification IPs
    • sub IP test (selftest)
      • functional test, coverage test, Direct/Random pattern test
    • sub system test (sub system test)
      • protocol test, transaction path test, performance test
    • whole system test (H/S test)
      • OS boot, H/S correlation test

2013年9月25日 星期三

python2.7 + openCV + myHDL


  • main purpose
    • using openCV to estimate how may hardware cycles in our archicture
  • requirement
    • python2.7.3
    • opencv2.4.2
    • numpy
  • exercise
    • rotate 0, 90, 180, 270 degree
    • image mask
    • image fetch
    • watermaker
  • project:
    • https://github.com/funningboy/openCV_myHDL/tree/master/opencv
    • ref
    • http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html
    • https://github.com/FalkorSystems/DeFisheye/blob/master/README.md
    • http://cg2010studio.wordpress.com/2012/01/03/opencv-%E6%A8%A1%E6%93%AC%E9%AD%9A%E7%9C%BC%E9%8F%A1%E9%A0%AD-simulate-fisheye-lens/
    • http://stackoverflow.com/questions/2477774/correcting-fisheye-distortion-programmatically

2013年9月22日 星期日

2013年9月21日 星期六

MyHDL slides

coverage group based on different bins

bus interface coverage catagology

classification

  • functional coverage bins
    • address rage bins
    • burst len bins
    • read/write bins
    • burst type bins
    • byten enable bins
    • cross coverage 
      • read trx
        • address, burst, read, ....
      • write trx
        • address, burst, write, ....
  • performance coverage bins
    • standard/normal bins
    • out standard bins
    • below standard bins
    • cross coverage
      • read trx
        • standard
      • write trx
        • standard
  • toggle coverage bins
    • 0 -> 1 
    • 1 -> 0
    • cross coverage
      • read trx
        • 0 -> 1 -> 0
      • write trx
        • 0 -> 1 -> 0
  • FSM coverage bins
    • default pass
  • protocol coverage bins
    • atomic bins
    • out of order bins
    • divide/conquer bins
    • address mapping table bins span tree
    • hit rate bins (cache coherence)



2013年9月14日 星期六

python finance model Quant-economic

Python finance model example

  • http://quant-econ.net/_static/pdfs/quant-econ.pdf?utm_source=Python+Weekly+Newsletter&utm_campaign=8e17b3ce66-Python_Weekly_Issue_104_September_12_2013&utm_medium=email&utm_term=0_9e26887fc5-8e17b3ce66-312683741
  • https://github.com/funningboy/quant-econ


requirements
  • numpy
  • pandas
  • scipy
  • matplotlib
  • pylab


Cadence SimVision UVM/SystemVerilog debugger

transaction level debug via SimVision....

  • transaction waveform info/pin level waveform info 
  • transaction database info
  • UVM phase sequence info
  • assertion info
  • coverage rate
    • functional
    • fsm
    • code
    • assertion
    • performance 
  • debug step by step, like gdb forward, backward, stop point, value dump....
  • unknown signal trace back
  • vif (virtual interface), Driver 




2013年8月21日 星期三

verification IP support lists


  • http://syswip.com/
    • support env : systemverilog
      • IP lists
        • AMBA
        • CAN
        • IO(I2C)
        • ...
  • http://www.smart-dv.com/products.html
    • support env :
      • IP lists
        • AMBA
        • IO(I2C)
  • http://www.truechip.net/
    • support env : UVM/OVM/SystemC
    • IP lists
      • USB3.0
      • AMBA
      • M-PHY
      • IO(I2C)
  • http://testandverification.com/
    • support env UVM/OVM
    • IP lists
      • USB3.0
      • AMBA
      • IO(I2S, I2C)
  • http://www.avery-design.com/
    • support env UVM/OVM
    • IP lists
      • PCI
      • DDR
      • SATA

python + systemverilog/verilog + uvm IDE (vim)



  • %vim command line to source the uvm syntax
    • : source ~/.vim/syntax/verilog_systemverilog.vim
  • project:
    • https://github.com/funningboy/vim
  • ref:
    • http://blog.eddie.com.tw/
    • https://github.com/kaochenlong/eddie-vim

2013年8月19日 星期一

machine learning note1


  • supervised learning
    • requirement
      • it must have the target/answer in it's training phase
      • using training phase to build up the 
      • using test phase to predict the next value 
    • regression
      • find the next value based on it's regression times, such as the temperature value in tomorrow, stock price in next open time....
      • example

    • classification
      • find the next classification value based on it's regression times, such as the it will rain or not tomorrow?, stock price will go up or down?... 
      • example
        •  
  • non-supervised learning
    • cluster
  • definition
    • http://en.wikipedia.org/wiki/Machine_learninghttp://www.gnu.org/software/octave/

https://class.coursera.org/ml-003/lecture/5
https://sites.google.com/site/octavetech/home

2013年8月14日 星期三

UVM model notes 3


  • using callback func to handle the trx that's much more beautiful than using the trx handler in the same block  

    • this.trans_executed(tr); `uvm_do_callbacks(apb_master,apb_master_cbs,trans_executed(this,tr))   

  • using get_parent() to fetch the parent's pp and populate it to sub blocks

    • apb_agent agent;
      if ($cast(agent, get_parent()) && agent != null) begin
      sigs = agent.vif;
      end

  • using sequencer handler to sort/resort the sequence items by it's priority set, such as sorted([seq(0)->p(1), seq(1)->p(0)]) => [seq(1)->p(0), seq(0)->p(1)]  
    • register sub sequence to sequencer manager  

    • class dut_reset_seq extends uvm_sequence;

      function new(string name = "dut_reset_seq");
          super.new(name);
      endfunction

      `uvm_object_utils(dut_reset_seq)

      virtual task body();
          dut_top.rst = 1;
          repeat (5) @(negedge dut_top.clk);
          dut_top.rst = 0;
          endtask
      endclass

                ....
         dut_reset_seq rst_seq;                                                                                                  rst_seq = dut_reset_seq::type_id::create("rst_seq", this);
         rst_seq.start(null);

         ....
         my_tx tx;
         start_item(tx);
          ...// do something here
         finish_item(tx);

    • TLM interface (socket/package) it use like in "fifo" struct
      • pull_port (slave side)
        • querying the valuable trx from trx queue when the trx queue is not empty.

          uvm_seq_item_pull_port #(reg_rw) seqr_port;
          seqr_port.peek(rw); // aka 'get_next_rw
          ... // do trx handle
          seqr_port.get(rw); // aka 'item_done''
      • put_port(master side)
        • push the valuable trx to trx queue when the trx queue is not full
    • port/export TLM1
      • A component can send out a transaction out through a port, or receive an incoming transaction through an export.

      • function void connect;
            sqr2.seq_item_port.connect(sqr1.seq_item_export );
            ...
        endfunction

    • blocking/non-blocking trx in TLM2
      • non-blocking (return immediately) or blocking (suspend and wait for some event before returning)

      • non-blocking // no delay
        uvm_tlm_nb_target_socket#(device, usb_xfer, usb_tlm_phase) sock; // slave
        function uvm_tlm_sync_e nb_transport_fw(usb_xfer xfer, ref usb_tlm_phase ph...)

        uvm_tlm_nb_initiator_socket#(host, usb_xfer, usb_tlm_phase) sock; // master
        function uvm_tlm_sync_e nb_transport_bw(usb_xfer xfer,                        ref usb_tlm_phase ph, ...)
      • // connect sub sockets in uvm_env connect phase
        // master.sock.connect(slave.sock); 

      • blocking // support delay
      • uvm_tlm_b_target_socket #(target, apb_rw) sock; //slaveuvm_tlm_b_initiator_socket#(apb_rw) sock; // master
      • // connect sub sockets in uvm_env connect phase
        // master.sock.connect(slave.sock);
    • uvm_reg_field call back and sample
    class input_value_c extends uvm_reg;

      rand uvm_reg_field data;                                                                                                                                                        
      virtual function void build();
        data = uvm_reg_field::type_id::create("data");
        data.configure(this, 32, 0, "RO", 0, `UVM_REG_DATA_WIDTH'h0>>0, 1, 1, 1);
      endfunction

      covergroup value_cg;
        option.per_instance=1;
        coverpoint data.value[31:0];
      endgroup
     
      virtual function void sample_values();
        super.sample_values();
        value_cg.sample();
      endfunction

      `uvm_register_cb(input_value_c, uvm_reg_cbs)
      `uvm_set_super_type(input_value_c, uvm_reg)
      `uvm_object_utils(input_value_c)
      function new(input string name="unnamed-input_value_c");
        super.new(name, 32, build_coverage(UVM_CVR_FIELD_VALS));
        if(has_coverage(UVM_CVR_FIELD_VALS)) value_cg=new;
      endfunction : new
    endclass : input_value_c
    • uvm_reg_block
      • add sub classes "uvm_reg" to block set
    class gpio_regfile extends uvm_reg_block;                                                                       rand bypass_mode_c bypass_mode;
     
        virtual function void build();

         // Now create all registers

         bypass_mode = bypass_mode_c::type_id::create("bypass_mode", , get_full_name());
       
        // Now build the registers. Set parent and hdl_paths
         bypass_mode.configure(this, null, "bypass_mode_reg");
         bypass_mode.build();
         // Now define address mappings
        default_map = create_map("default_map", 0, 4, UVM_LITTLE_ENDIAN);
        default_map.add_reg(bypass_mode, `UVM_REG_ADDR_WIDTH'h0, "RW");

    endclass
    • uvm_report_server
      •    uvm_report_server svr;
           svr = _global_reporter.get_report_server();
           svr.set_max_quit_count(10);   

                                                          2013年7月23日 星期二

                                                          python 大補帖 = Anaconda



                                                          最近小弟因為要做些圖形應用的 project, 裡面要用到 opencv 跟 big data 相關的 modules, 去幫我做些圖形運算. 但小弟不才, 軟體灌了很久就是裝不起來, 不是東缺一塊就是西塊, 於是就拿出 python 大補帖, 直接install下去, 完全就是快速阿...
                                                          • what's Anaconda
                                                            • a tool set for big data analysis which is contains (numpy, scipy, panda, pytable)


                                                        • package list

                                                          • http://docs.continuum.io/anaconda/pkgs.html


                                                        • set up your python path

                                                          • ~/.bashrc
                                                          • export PATH=~/anaconda/bin:$PATH, export PYTHONPATH=~anaconda/lib/python2.7:$PYTHONPATH


                                                        • open source

                                                          • http://continuum.io/developer-resources

                                                          2013年7月14日 星期日

                                                          Demo for interview

                                                          最近為了 interview 寫了幾個小 project. 有興趣的就參考看看吧!!

                                                          jenkins + python = regression env

                                                          Hi all,
                                                          this is a python unittest regression flow by jenkins that can help designer daily run testsuites and support the GUI output reports(coverage pass rate)

                                                          github:

                                                          • https://github.com/funningboy/ijenkins/blob/master/README
                                                          ref:
                                                          • http://jenkins-ci.org/content/python-love-story-virtualenv-and-hudson

                                                          2013年7月3日 星期三

                                                          xilinx axi bus traffic gen


                                                          • AXI4/AXI-stream
                                                          • dependent/independent transaction
                                                          • initial ram
                                                          • error interrupt/ status
                                                            • command
                                                            • data
                                                            • debug
                                                          • address gen
                                                            • align
                                                              • byte 64bit, 32bit...
                                                            • un-align
                                                              • offset
                                                            • type
                                                              • inc, wrap, fixed
                                                          • data gen
                                                            • mem data width
                                                          • initial system set
                                                            • NOP instruction for dummy loops
                                                          • Test DUT performance
                                                          • replay Bus transactions when the debugging mode is opened

                                                          • ref:
                                                          • http://www.xilinx.com/support/documentation/ip_documentation/axi_traffic_gen/v1_0/pg125-axi-traffic-gen.pdf

                                                          Xilinx Hierarchical_Design_Methodology


                                                          • bottom up
                                                            • in any conditions should been re-runed partition again
                                                              • VHDL/ngc/ngd source changed
                                                              • constrains changed
                                                              • partition changed
                                                              • fpga package changed
                                                            • partition(split to small partitions)
                                                              • cost, benefit trade off, such as timing area ...
                                                            • black box(often used in Memory or fixed devices)
                                                              • ngc, ngd
                                                              • synthesis token 
                                                                • black box syntax in your VHDL like transfer_on, transfer_off
                                                            • minimal logic
                                                              • small cells. DSP/RAM normal cells
                                                            • advantage
                                                              • incremental place routing to reduce synthesis time
                                                              • no rerun again when it's non-touchable design  
                                                            • disadvantage
                                                              • the constrains need to be reseted in whole chip view, because in each sub constrains only has it's constrains setting, if some paths from source pad to internal block and this path can cross through two different constrain blocks, it means the sub constrains it seems does't work for this set.
                                                            • partition file
                                                              • PXML
                                                                • synplify smxl2pxml or xilinx xst
                                                            • pblock
                                                              • reversed place & route block 
                                                            • ngc 
                                                              • partition cell lib
                                                            • BoundaryOpt
                                                              • two partition interfaces bridge
                                                          • top down
                                                          ref:
                                                          • http://www.xilinx.com/support/documentation/sw_manuals/xilinx12_3/Hierarchical_Design_Methodology_Guide.pdf
                                                          • http://www.xilinx.com/support/documentation/white_papers/wp386_Hierarchical_Design_Synopsys_Xilinx.pdf

                                                          2013年6月27日 星期四

                                                          UVM AXI BFM 1.0 release

                                                          supported list

                                                          • AXI3/AXI4 bus protocol
                                                          • out of order/ inorder transactions
                                                          • each write/read phase is independent
                                                            • addr/write/resp is independent
                                                          • interlevel
                                                          • split
                                                          • performance watch dog 
                                                          • protocol watch dog
                                                          • performance report
                                                            • MAX, AVG, MIN bus bandwidth
                                                            • through put
                                                            • transaction list(disassemble bus info)
                                                          •  virtual master
                                                            • define each phase delay(req to grant or each valid/ready) or drive trx out time stamp
                                                          • virtual slave
                                                            • define each phase delay(req to grant or each valid/ready) or drive trx out time stamp
                                                          • scoreboard
                                                            • check connection
                                                            • check the memory read write is pass when the read/write trx in the same address, the read trx must be finished first than write trx to avoid the overwrite the address issue.
                                                          • STL 
                                                            • user define TRX language
                                                          • SystemC analysis port 
                                                            • user can use analysis port to link third part debug model by using DPI interface like Verilog to SystemC  or Verilog to C/C++

                                                          • https://github.com/funningboy/uvm_axi


                                                          2013年6月25日 星期二

                                                          UVM notes 2



                                                          • UVM reference flow
                                                          • UVM tutorial
                                                            • http://cluelogic.com/tag/vmm/UVM_AGENT
                                                          • virtual sequencer
                                                            • handle each sub sequencers when the platform contains multi sequences to drive the same DUT. 
                                                            • avoid race conditions,  transaction sequence, like multi threads system
                                                            •  ex:
                                                              •       jb_seq1 = same_flavored_jelly_beans_sequence::type_id::create( .name( "jb_seq1" ), .contxt( get_full_name() ) );
                                                              •       jb_seq2 = same_flavored_jelly_beans_sequence::type_id::create( .name( "jb_seq2" ), .contxt( get_full_name() ) );
                                                              •       case ( recipe )
                                                              •         LEMON_MERINGUE_PIE: begin
                                                              •            jb_seq1.flavor          = jelly_bean_transaction::LEMON;
                                                              •            jb_seq2.flavor          = jelly_bean_transaction::COCONUT;
                                                              •            jb_seq1.num_jelly_beans = 2;
                                                              •            jb_seq2.num_jelly_beans = 2;
                                                          • configure
                                                            • set  register , interface from top to down
                                                              • test_lib -> test_env -> test_cfg -> test_agent ... 
                                                            • ex:
                                                            •    initial begin
                                                            •       uvm_config_db#( virtual jelly_bean_if )::set
                                                            •          ( .cntxt( null ), .inst_name( "uvm_test_top" ), .field_name( "jb_if1" ), .value( jb_if1 ) );
                                                            •       uvm_config_db#( virtual jelly_bean_if )::set
                                                            •          ( .cntxt( null ), .inst_name( "uvm_test_top" ), .field_name( "jb_if2" ), .value( jb_if2 ) );
                                                            •       run_test();
                                                            •    end
                                                          • register abstract
                                                            • check register r/w limitation(only r/w), fields check, width check, coverage, assertion
                                                            • ex:
                                                            •       flavor = uvm_reg_field::type_id::create( "flavor" );
                                                            •       flavor.configure( .parent                 ( this ),
                                                            •                         .size                   ( 3    ),
                                                            •                         .lsb_pos                ( 0    ),
                                                            •                         .access                 ( "WO" ),
                                                            •                         .volatile               ( 0    ),
                                                            •                         .reset                  ( 0    ),
                                                            •                         .has_reset              ( 1    ),
                                                            •                         .is_rand                ( 1    ),
                                                            •                         .individually_accessible( 0    ) );

                                                          • assertion

                                                          • functional coverage

                                                          2013年6月20日 星期四

                                                          xilinx AXI interconnect

                                                          key notes


                                                          • cascade AXI bus if the input port > 4 (crossbar) multi to one
                                                          • traffic gen for DDR protocol (align burst length to 8), from AXI 2 DDR 
                                                          • example:
                                                            • 16 streams of 1920x1080 60/75p video information with up to 32 bits/pixel can be handled by a single 64-bit DDR3 interface
                                                            • VDMA
                                                            • Test Pattern Generators (TPGs) 
                                                            • Video Timing Control (VTC) 
                                                            •  On-Screen Display (OSD) 
                                                          • performance
                                                            • 622MB/s 
                                                            • 16 streams through memory, or nearly 9.95 GB/s (80 Gb/s)! This 18-port shared memory controller is used to support the 16 VDMA channels
                                                            • a memory clock speed of 800 MHz (1,600 MHz data rate).The primary internal AXI4 slave interface of the memory controller is operated at 200 MHz, using an AXI4 data width of 512 bits, supporting a theoretical maximum data bandwidth of 12.8 GB/s

                                                          refs: http://www.xilinx.com/support/documentation/white_papers/wp417-Xilinx-AXI4-Interconnects.pdfhttp://www.xilinx.com/support/documentation/application_notes/xapp521_XSVI_AXI4.pdf
                                                          http://www.xilinx.com/support/documentation/ip_documentation/ug761_axi_reference_guide.pdf

                                                          2013年6月19日 星期三

                                                          high level synthesis with Xilinx

                                                          key notes:

                                                          • write your struct ASIC c code, no class...., only for struct supported
                                                            • familiar hardware c (no hierarchal ptr, dynamic/static cast/ptr)
                                                          • implemented module select(architecture set)
                                                            • sub standard cell assign
                                                              •  like a+b  for operator "add", it can be "32bitAdd", or "64bitAdd" ...
                                                            • memory assign
                                                              • internal buffer, (asyn_fifo) for different clock interface
                                                            • for loop extend(unroll)
                                                              • like for (i=0; i < 2; i++), it will be extend to l0, l1, sequences for reschedule, if the data doesn't have any dependence in this loop, that can merge these two sequences in one parallel sequence. 
                                                            • resource constrain
                                                              • area constrain
                                                              • sub cell constrain
                                                              • timing constrain
                                                            • scheduling and binding
                                                              • pipeline
                                                          • implemented protocol interface
                                                            • AXI3/4 AXI stream
                                                            • transfer task assign
                                                              • req/grant
                                                              • burst ... ex: axi_bus_write(addr, [data,..]) => for axi burst write transfer 

                                                          • RTL code gen
                                                            • verilog/systemc
                                                          • report
                                                            • trade off
                                                              • performance/area
                                                            • simulation time estimation
                                                              • delay 
                                                            • area estimation
                                                              • size
                                                          • refs:
                                                            • http://www.xilinx.com/support/documentation/sw_manuals/xilinx2012_2/ug902-vivado-high-level-synthesis.pdf
                                                            • http://www.xilinx.com/support/documentation/sw_manuals/xilinx2012_2/ug871-vivado-high-level-synthesis-tutorial.pdf
                                                            • http://www.xilinx.com/support/answers/50929.html

                                                          2013年6月7日 星期五

                                                          uvm sequence item

                                                          speed up your simulation !!


                                                          • keynotes
                                                            • no waveform dump
                                                            • no timing check
                                                            • using unit delay
                                                            • using virtual model without real physical model
                                                            • atomic test like selftest/unittest
                                                            • atomic integration test / merge only input/output modules in DUT
                                                            • using two stage 0/1 info without 4 stage info 0/1/X/Z
                                                            • using error count num to finish simulation (avoid a lots useless info)
                                                            • using assertion to check functional value

                                                          ref:
                                                          https://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CDIQFjAA&url=http%3A%2F%2Fwww.bawankule.com%2Fverilogcenter%2Ffiles%2FDVCon_Sim_Increase_paper.pdf&ei=bkGnUcOnKMWTiAeZroD4Bg&usg=AFQjCNEyEYLFxQb5Qo8XnYa3gLKppuIobw&sig2=GPKPKLOpKTZ3K4rmwZ571A
                                                          http://www.cadence.com/Community/forums/t/24886.aspx
                                                          http://www.synopsys.com/Tools/Verification/FunctionalVerification/Pages/VCS.aspx
                                                          http://www.deepchip.com/items/0385-03.html
                                                          http://www.cadence.com/community/forums/T/23927.aspx

                                                          2013年5月27日 星期一

                                                          Xilinx ucf constrain notes

                                                          ucf constrain

                                                          • timing constrain
                                                            • input pad to first flip-flop groups
                                                              • input offset
                                                            • internal flip-flop to flip flop groups
                                                              • period
                                                            • out flip-flop to output pad groups 
                                                              • output offset
                                                            • clock
                                                              • offset
                                                              • duty
                                                              • jitter
                                                              • rotate
                                                                • 90 
                                                                • 180
                                                                • 270
                                                          • multi cycle path
                                                            • from one clock dom to another clock dom
                                                            • using async fifo to avoid the data missing issue
                                                              • data valid
                                                              • req fifo.empty/fifo.full
                                                              • status
                                                          • false path
                                                            • not normal paths
                                                            • -to
                                                            • -from -to
                                                            • -through
                                                            • -from -through -to 
                                                          • data path
                                                            • normal paths
                                                          • fanout
                                                            • set maxfanout
                                                          • DCM / DLL/ PLL
                                                            • ECO div/mux
                                                          • TNM (timing group)

                                                          • pin assignment constrain
                                                            • pad assignment 

                                                          • slack
                                                            • Slack (setup path): =  (requirement - (data path - clock path 
                                                            • skew + uncertainty))
                                                            • Slack (hold path): = requirement - (clock path skew + uncertainty - data path) 

                                                          2013年5月25日 星期六

                                                          sytemverilog virtual interface setup time hold time check

                                                          we use systemveirlog virtual interface and simulator keys $setup, $hold to check the setup/hold time.




                                                          interface my_if #(c_clk_high_time = 5,
                                                                            c_clk_low_time  = 5) (input clk, en);
                                                            specify
                                                              specparam clk_high_time = c_clk_high_time;
                                                              specparam clk_low_time = c_clk_row_time;
                                                              $setup(en, negedge clk, clk_high_time * 4 / 5);
                                                              $hold(negedge clk, en, clk_low_time * 4 / 5);
                                                            endspecify
                                                          
                                                          endinterface;
                                                          
                                                          or
                                                          module timing_checks_in_sv (input clk, data, ...); 
                                                            ...
                                                            event ev_data_delayed_toggled;
                                                            
                                                            always @(data)
                                                            begin
                                                              fork
                                                              begin
                                                                # tSetup;
                                                                -> ev_data_delayed_toggled;
                                                              end
                                                              join_none
                                                            end
                                                          
                                                            property setup_hold_time_checker;
                                                              time curr_time;
                                                              @(posedge clk) (1, curr_time = $time) |->
                                                              @(ev_data_delayed_toggled) (($time - curr_time) > (tSetup + tHold)); // check data arrival time is meet $time - cur_time > (SetUp + Hold)
                                                            endproperty : setup_hold_time_checker
                                                          
                                                            ASSERT_SETUP_HOLD: assert property setup_hold_time_checker;
                                                          endmodule 
                                                          

                                                          ref :
                                                          http://learn-systemverilog.blogspot.tw/2010/07/writing-systemverilog-assertion-for.html
                                                          http://www.ee.ed.ac.uk/~gerard/Teach/Verilog/me5cds/me95rh.html

                                                          2013年5月24日 星期五

                                                          UVM TLM2.0 notes

                                                          if your are a ESL designer, you may heard about the SystemC TLM2.0 model that can help designer to design system level evaluation models very quick without any detail info such as Pin assignment, protocol selected, timing(real).... as you known, if you can use these abstract level api(blocking_trans, non_blocking_trans), you can replay or remodel design very quick without reconstruct your design again when the project is in evaluation phase. right now you can migrate your design from SystemC to UVM1.1d, because UVM1.1d is based on SystemVerilog that can be more suitable for EDA vendor supported and more friendly for verification designer... that's my guess ...


                                                          socket channel connection
                                                          initiator_socket : as same as master socket
                                                          target_socket    : as same as slave socket

                                                          ex:
                                                          1. create sockets in master/slave sides
                                                          initiator_socket ini_socket; // master socket
                                                          target_socket tgt_socket; // slave socket

                                                          connect(ini_socket, [tat_socket,...]) // connect one master to multi slaves

                                                          2. create trx payload to socket channel in master side
                                                          Trx trx = new();
                                                          trx.addr = 0x100;
                                                          trx.data = [0x1, 0x2, 0x3]; // generation payload
                                                          init_socket.write(trx);

                                                          3. collected trx in slave side
                                                          trx = tgt_socket.get_trx();     // fetch trx from socket channel fifo, and double check the trx is valid
                                                          if (trx != NULL) { // do something .... }


                                                          4. blocking trx
                                                          blocking interface conveys transactions in blocking fashion; its methods do not return until the transaction has been successfully sent or retrieved.  Because delivery may consume time to complete, the methods in such an interface are declared as tasks

                                                          5. non blocking trx
                                                          A non-blocking interface attempts to convey a transaction without consuming simulation time.  Its methods are declared as functions.  Because delivery may fail (e.g. the target component is busy and can not accept the request), the methods may return with failed status.

                                                          6. port, export, imps
                                                          port: instantiated in components that require, or use, the associate interface to initiate transaction requests. export : instantiated by components that forward an implementation of the methods defined in the associated interface. The implementation is typically provided by an imp port in a child component.

                                                          2013年5月21日 星期二

                                                          deep copy or shadow copy in your systemverilog object

                                                          as the same methodology as c/c++ or any languages. we usually used copy function to copy trx to avoid the overwrite trx when the trx had new ptr triggered. this is an sample example about what's the difference between deep copy and shadow copy, in short word. deep copy is top down copy, copy from this(current) level info to it's parents info. shadow copy is template current level copy, only for this level info.
                                                          class Based #(type T=int unsigned);
                                                            T val;
                                                          
                                                            function new (T v=0);
                                                              val = v; // assign new val
                                                            endfunction : new
                                                          
                                                            virtual function void deep_copy(Based b);
                                                              assert(b!=null);
                                                              b.val = val; // b.val = this.val
                                                            endfunction : deep_copy
                                                          
                                                            virtual function void shadow_copy(Based b);
                                                              assert(b!=null);
                                                              b.val = val; // b.val = this.val
                                                            endfunction : shadow_copy
                                                          
                                                            virtual function bool eq(Based b);
                                                              return b.val == val;
                                                            endfunction : eq
                                                          
                                                          endclass : Based
                                                          
                                                          class A #(type T=int unsigned) extens Based;
                                                            T val_a
                                                          
                                                            function new (T v=0);
                                                              super.new();
                                                              val_a = v; // assign val_a
                                                            endfunction : new 
                                                          
                                                            virtual function void deep_copy(A a); 
                                                              assert(a!=null);
                                                              Based b;
                                                              a.val_a = val_a;
                                                              $cast(b,a);
                                                              super.deep_copy(b);
                                                              // or
                                                              // a.val_a = val_a
                                                              // a.val  = super.val
                                                            endfunction : deep_copy
                                                          
                                                            // operator overwrite ... eq, lt, lt, ...
                                                            virtual function bool eq(A a0);
                                                              assert(a0!=null);
                                                              Based b0;
                                                              $cast(b0,a0);
                                                              return val_a == a0.val_a & super.eq(b0);
                                                            endfunction : eq
                                                          
                                                          
                                                          endclass : A
                                                          
                                                          
                                                          A a0 = new(1);
                                                          A a1 = new(2);
                                                          
                                                          a0.val_a = 3;
                                                          a0.val = 2;
                                                          
                                                          a0.deep_copy(a1);
                                                          
                                                          // check a0, a1 contains are eq  a0 = a1
                                                          assert(a0.eq(a1));  
                                                          

                                                          waveform modeling

                                                          as well as your are a ATE engineer, you may very familiar with the ATE test pattern formats that can transfer the waveform info into sample digital codes.
                                                          this is  a very example code for req/grant test case.
                                                          // timing modeling
                                                          task req_grant_00();                                                                                                                                                                 
                                                            m_vif.REQ   <= 0;
                                                            m_vif.GRANT <= 0;
                                                            @(posedge m_vif.CLK);
                                                          endtask : req_grant_00
                                                          
                                                          task req_grant_01();
                                                            m_vif.REQ   <= 0;
                                                            m_vif.GRANT <= 1;
                                                            @(posedge m_vif.CLK);
                                                          endtask : req_grant_01
                                                          
                                                          task req_grant_10();
                                                            m_vif.REQ   <= 1;
                                                            m_vif.GRANT <= 0;
                                                            @(posedge m_vif.CLK);
                                                          endtask : req_grant_10
                                                          
                                                          task req_grant_11();
                                                            m_vif.REQ   <= 1;
                                                            m_vif.GRANT <= 1;
                                                            @(posedge m_vif.CLK);
                                                          endtask : req_grant_1
                                                          
                                                          task
                                                          
                                                          task wave_gen();
                                                            list = {`ON_OFF, `ON_ON, `OFF_ON, `OFF_OFF};
                                                          
                                                            foreach(list[i]) begin
                                                              case(list[i])
                                                                `ON_OFF : req_grant_10();
                                                                `ON_ON  : req_grant_11();
                                                                `OFF_OFF: req_grant_00();
                                                                `OFF_ON : req_grant_01();
                                                              endcase
                                                            end 
                                                          endtask
                                                          
                                                          

                                                          2013年5月17日 星期五

                                                          UVM scoreboard to check with c/c++ golden model via uvm analysis port

                                                          1.systemverilog DPI interface to interconnect the c/c++ part and systemverilog part

                                                          2.uvm analysis port to valid event channel
                                                          // golden cehck via uvm analysis port
                                                          // ps : the port should be connected to it's callback module. that uvm can collected.
                                                          // ex: item_port.connect( analysis_export );
                                                          
                                                          uvm_analysis_port item_port
                                                          
                                                          // DPI import ... for our golen model
                                                          import "DPI" void *yuv2rgb(int unsigned y, int unsigned u, int unsigned v);  
                                                          // yub2rgb(void* trx); using ptr is a more friendly interface....
                                                          import "DPI" void *rgb2yuv(int unsigned r, int unsigned g, int unsigned b); 
                                                          
                                                          // callback func called from callable func/module
                                                          task callback(sample_trx trx);
                                                          
                                                            assert(trx!=null);
                                                            if (trx.type == YUV2RGB)
                                                              dpi_c_yuv2rgb(trx);
                                                            else
                                                              dpi_c_rgb2yuv(trx);
                                                          
                                                          endtask
                                                          
                                                          void dpi_c_yuv2rgb(sample_trx trx);
                                                                                                                                                                                                                                              
                                                            assert(trx!=null);
                                                            c_rst = yuv2rgb(trx.y, trx.u, trx.v)
                                                            assert( c_rst.r == trx.r &
                                                                    c_rst.g == trx.g &
                                                                    c_rst.b == trx.b);
                                                          endtask
                                                          
                                                          

                                                          2013年5月16日 星期四

                                                          adding performance monitor to your design

                                                          the UVM monitor can play not only a functional checker but also a performance checker which means, user can use it more quickly to find out where is their design bottleneck without waveform tracing. in this topic, we focused on how to use UVM monitor to point out the collected transactions had timing violation immediately when the simulation was running.

                                                          we write a UVM SystemVerilog "req happened until grant received" to our demo case.

                                                           
                                                          // spawn sub procs(threads)                                                                                                       
                                                          task run_phase(uvm_phase);
                                                            fork
                                                              sent_req();
                                                              sent_grant();
                                                          
                                                              collected_req();
                                                              collected_grant();
                                                          
                                                              check_performance();
                                                              check_protocol();
                                                            join
                                                          endtask : run_phase
                                                          
                                                          
                                                          // sent req 
                                                          task sent_req();
                                                          
                                                            forever begin
                                                              // random  wait ....
                                                              repeat($urandom_range(8,16)) @(posedge m_vif.CLK);
                                                          
                                                              // sent req 
                                                              `delay(conf.half_cycle);
                                                              m_vif.REQ <= `TRUE;
                                                              @(posedge m_vif.CLK);
                                                          
                                                              // wait until grant received
                                                              while(!m_vif.GRANT) @(posedge m_vif.CLK);
                                                          
                                                              // free req 
                                                              `delay(conf.half_cycle);
                                                              m_vif.REQ <= `FALSE;
                                                              @(posedge m_vif.CLK);
                                                          
                                                            end
                                                          
                                                          endtask : sent_req
                                                          
                                                          
                                                          // snet grant
                                                          task sent grant();
                                                          
                                                            forever begin
                                                          
                                                              // sent unvalid grant
                                                              `delay(conf.half_cycle);
                                                              m_vif.GRANT <= `FALSE;
                                                              @(posedge m_vif.CLK);
                                                          
                                                              // wait until req received
                                                              while(!m_vif.REQ) @(posedge m_vif.CLK);
                                                          
                                                              // random wait ...
                                                              repeat($urandom_range(8,16)) @(posedge m_vif.CLK);
                                                          
                                                              // sent valid grant to free req
                                                              `delay(conf.half_cycle);
                                                              m_vif.GRANT <= `TRUE;
                                                              @(posedge m_vif.CLK);
                                                          
                                                            end
                                                          
                                                          endtask : sent grant                                                                                                              
                                                          
                                                          
                                                          task collected_req();
                                                          
                                                            forever begin
                                                               // @ neg edge check
                                                                @(negedge m_vif.CLK iff m_vif.REQ);
                                                          
                                                                // assert only one fifo deep when req/grant case
                                                                assert(m_trx_q.size() < 1);
                                                          
                                                                // collect trx
                                                                TRX m_trx = new();
                                                                m_trx.REQ = m_vif.REQ;
                                                                m_trx.TIME = $time;
                                                                m_trx_q.push_back(m_trx);
                                                          
                                                            end
                                                          endtask : collected_req
                                                          
                                                          
                                                          task collected_grant();
                                                          
                                                            forever begin
                                                              // @ neg edge cehck
                                                              @(negedge m_vif.CLK iff m_vif.GRANT);
                                                          
                                                              //assert the queue size must be 1, means the req has been stored in the queue
                                                              assert(m_trx.q.size() == 1);
                                                          
                                                              // free queue
                                                              m_trx_q.pop_front();
                                                          
                                                            end
                                                                                                                                                                                            
                                                          endtask : collected_grant
                                                          
                                                          
                                                          task check_performance();
                                                            forever begin
                                                              // at each pos edge check
                                                              @(posedge m_vif.CLK);
                                                          
                                                              //assert queue
                                                              if (m_trx_q.size() == 1) begin
                                                                  if ($time - m_trx_q[0].TIME > conf.min_offset) begin
                                                                    `uvm_error(get_full_name(), {$psprintf("out of time %d"), conf.min_offset}, UVM_LOW)
                                                                  end else begin
                                                                    `uvm_error(get_full_name(), {$psprintf("req/grant seuence is not valid")}, UVM_LOW)
                                                                  end
                                                              end
                                                            end
                                                          
                                                          endtask             
                                                          

                                                          2013年5月15日 星期三

                                                          python unittest + UVM testsuites + Jenkins = DUT regression

                                                          in recently, i got a order from my boss. he asked me to build up a automatically unittest env that can very quick to know where is the problem such as protocol error, functional error, timing error ... when the design is changed. the below list is my auto regression flow and requirements


                                                          • i used python unittest to our based unittest framework
                                                            • python unittest
                                                              • check testsuite is pass/fail
                                                            • python nose 
                                                              • call python unittest folder and testsuites
                                                            • python subprocess/multiprocess
                                                              • call system call (irun, vcs....)
                                                            • python re(regular expression)
                                                              • check simulation result is pass/faill if the error tokens are not found

                                                          • UVM testsuites
                                                            • define UVM test sequence for your simulator
                                                              • irun -uvm +UVM_TESTNAME=""...
                                                            • prepare your test sequence
                                                              • like xxSequences.sv
                                                                • test_1read_after_1write
                                                                • test_mread_after_mwrite
                                                                • test_read_write_at_same_time
                                                          • jenkins
                                                            • job manager
                                                              • daily regression run 

                                                          2013年5月8日 星期三

                                                          Microsemi BFM script language


                                                          • a very useful script language for bus performance estimation and bus functional check
                                                            • example:
                                                              • # read B uart 0;
                                                                Reading offset 0 of uart – data = 0x1c
                                                                # write B uart 4 bb;
                                                                Writing 0xbb to offset 4 of uart
                                                                # read B uart 8;
                                                                Reading offset 8 of uart – data = 0x28
                                                                # write B mac 30 11;
                                                                Writing 0x11 to offset 30 of mac
                                                                # readcheck B mac 11;
                                                                Reading offset 0 of mac
                                                                Error: Expected data = 0x11, Actual data = 0x22
                                                                Test Failed, with 1 error
                                                                  
                                                                  

                                                              • 
                                                                
                                                              • advantage
                                                                • simple 
                                                                • error check 
                                                              • disadvantage
                                                                • no time stamp
                                                                  • maybe it use ASAP(as soon as possible) methodology to transfer transactions, it means masters or slaves are not in busy status, or fetch/push buffers not full
                                                                • no atomic transfer
                                                                  • if valid/ready is not continuous in the burst transaction, the interlevel transactions will happened, 
                                                                  • like A1(4), A2(4), A1 has burst 4 trxs, A2 has burst 4 trxs.
                                                                    • A1(2), A2(2), A1(2), A2(2) => atomic transactions when the A1 or A2 has busy or error in the internal transaction.

                                                            synplify + ise TCL xflow

                                                            http://outputlogic.com/xcell_using_xilinx_tools/74_xperts_04.pdf https://github.com/dlitz/openmsp430/blob/master/core/synthesis/actel/synplify.tcl https://github.com/martinjthompson/VHDL-compare/blob/master/Synplify/rev_1/run_ise.tcl https://github.com/martinjthompson/VHDL-compare/tree/master/Synplify https://github.com/zakiali/pocket_corr/blob/master/pfb_core/SgIseProject.tcl

                                                            2013年5月6日 星期一

                                                            SystemVerilog Unit test = SVUnit = TDD(test drivent Development of Verification IP)

                                                            SystemVerilog UVM Unit test framework


                                                            • Methodology
                                                              • get UVM domain class and register it to unit test list
                                                              • fetch runnable  test suite from test list, the sorted priority is based on schedule manager definition
                                                              • collect test suite UVM report 
                                                              • report pass/fail coverages

                                                            ex:
                                                             
                                                              //************************************************************
                                                              // Test:
                                                              //   xformation_test
                                                              //  
                                                              // Desc:
                                                              //   ensure that objects going through the simple model have                                                                                                                       
                                                              //   their field property updated appropriately (multiply by
                                                              //   2)
                                                              //************************************************************
                                                              `SVTEST(xformation_test)
                                                                begin
                                                                  simple_xaction in_tr = new();
                                                                  simple_xaction out_tr;
                                                             
                                                                  void'(in_tr.randomize() with { field == 2; }); 
                                                             
                                                                  put_port.put(in_tr);
                                                                  get_port.get(out_tr);
                                                             
                                                                  `FAIL_IF(in_tr.field != 2); 
                                                                  `FAIL_IF(out_tr.field != 4); 
                                                                end 
                                                              `SVTEST_END(xformation_test)
                                                            

                                                            ref : http://www.agilesoc.com/svunit/

                                                            2013年5月4日 星期六

                                                            SystemVerilog parallel tasks by event trigger

                                                            SystemVeilog event trigger is implemented by event manager, that can define the dependences of parent and child tasks. and each tasks will be registered in event list when the building phase is done, after it, the task manager will sort event list by it's dependence or timing (such as E(timing(0)(0)), E(timing(1)(1)) E0 > E1, E0 will be run first than E1.

                                                            AXI write phase example. using delay constrain to define which one is first, which one is second


                                                            // @ write phase before write addr phase
                                                            // cfg.write_addr_delay = 10;
                                                            // cdg.write_data_phase = 0;
                                                            
                                                            
                                                            // @ write phase after write addr phase
                                                            // cfg.write_addr_phase = 0;
                                                            // cfg.write_data_phase = 10;
                                                            
                                                            task run_phase();
                                                              fork
                                                                write_addr_phase();
                                                                write_data_phase();
                                                                get_next_trx();
                                                              join
                                                            endtask
                                                            
                                                            
                                                            task get_next_trx();
                                                              forever begin
                                                                @(posedge vif.clk);
                                                                if (sequencer.item.has_next_trx()) begin
                                                                  trx = sequencer.item.get_next_trx();
                                                                  if (trx.rw == `WRITE)
                                                                    -> start_write;
                                                                  else
                                                                    -> start_read;
                                                                end 
                                                              end 
                                                            endtask
                                                            
                                                            task write_addr_phase();
                                                              forever begin
                                                                if (start_write.triggered) begin
                                                                  repeat(cfg.write_addr_delay) @(posedge vif.clk);
                                                                  // do write phase
                                                                end 
                                                              end 
                                                            endtask
                                                            
                                                            task write_data_phase();
                                                              forever begin
                                                                if (start_write.triggered) begin
                                                                  repeat(cfg.write_data_delay) @(posedge vif.clk);
                                                                  // do data phase
                                                              end 
                                                            endtask
                                                            
                                                            

                                                            2013年5月1日 星期三

                                                            PyHVL = verilog PLI is going died....


                                                            • open source tool supported 
                                                              • iverilog VPI 2.0 
                                                                • http://iverilog.wikia.com/wiki/Using_VPI
                                                            • what's VPI/PLI(Verilog Procedural Interface)
                                                              • http://en.wikipedia.org/wiki/Verilog_Procedural_Interface
                                                            • what's DPI(SystemVerilog Direct Programming Interface)
                                                              • http://en.wikipedia.org/wiki/SystemVerilog_DPI
                                                            • third party language support 
                                                              • perl
                                                                • http://www.veripool.org/wiki/verilog-pli/Manual-verilog-pli
                                                              • ruby
                                                                • http://snk.tuxfamily.org/lib/ruby-vpi/
                                                              • python
                                                                • http://sourceforge.net/projects/pyhvl/?source=dlp
                                                            • disadvantage
                                                              • hard to read
                                                                • more rules need to follow
                                                                  • init pli
                                                                  • register pli 
                                                                  • free pli
                                                                • using third part language to mix simulation run that's very difficult for designer view. they need to know how to driver system call and catch the simulation error when the segment fault happened 
                                                                • only for behavior model verification / profile
                                                                • why not using SystemVerilog + DPI to replace it?
                                                                  • more closer with Verilog language
                                                                  • more easily to understand 
                                                                  • OO suport
                                                                  • more flexible to designer(customer DPI)
                                                                  • UVM 

                                                            AXI BFM(bus function model)


                                                            • standard protocol
                                                              • write phase (fork events)
                                                                • write address phase
                                                                  • collect transactions when AXI_AWVALID and AXI_AWREADY
                                                                • write data phase
                                                                  • collect transactions when AXI_WVALID and AXI_WREADY
                                                                • write response phase
                                                                  • collect transactions when AXI_BVALID and AXI_BREADY
                                                                • the valid transaction should have the same ID at address, data, response 

                                                              • read phase(fork events)
                                                                • read address phase
                                                                  • collect transactions when AXI_ARVALID and AXI_ARREADY
                                                                • read data phase
                                                                  • collect transactions when AXI_RVALID and AXI_RREADY
                                                                • the valid transaction should have the same ID at address, data
                                                            • extend protocol
                                                              • qos
                                                              • user
                                                              • region
                                                              • lock
                                                              • cache
                                                              • strb
                                                            • https://github.com/funningboy/axi-bfm

                                                            2013年4月24日 星期三

                                                            UVM notes

                                                            UVM
                                                            • virtual interface
                                                              • interface define
                                                                • modports(define the port type for master/slave)
                                                                  • master (input,output), slave(input, output)...
                                                              • task trigger
                                                                • task req;
                                                                  `uvm_info(get_full_name(),"start req",UVM_LOW);
                                                                  vif.req <= 1b'1;
                                                                  @(posedge vif.clk);
                                                                  while(!vif.ack) @(posedge vif.clk)
                                                                  vif.req <= 1'b0;
                                                                  `uvm_info(get_full_name(),"end req",UVM_LOW);
                                                                  end_task
                                                              • protocol assertion
                                                                • assert
                                                              • timing constrain
                                                                • setup time, hold time, sample rate, clock rate
                                                                  • http://learn-systemverilog.blogspot.tw/2010/07/writing-systemverilog-assertion-for.html
                                                            • UVM_Transfer
                                                              • transfer type, contain definition
                                                                • common
                                                                  • transaction id, transaction type, begin time, end time
                                                                • base extends common
                                                                  • such as : address, RW type, Data byte array, burst size
                                                            • UVM_Agent
                                                              • support monitor, (driver, sequencer) if the active option is on
                                                            • UVM_monitor
                                                              • collect pin level info to transaction level info
                                                              • export transaction analysis port to TLM2.0 SystemC or scoreboard 
                                                              • protocol coverage like burst len need to support 1,2,4,8,16....
                                                            • UVM_driver
                                                              • driver the test sequence lib to virtual interface
                                                            • UVM_sequencer
                                                              • task item manager 
                                                                • sort the sequences by it's own priority or set it's dependence condition or it's spawn event
                                                            • UVM_scoreboard
                                                              • check transaction is completed from master to slave or slave to master
                                                            • UVM_test
                                                              • define testsuites like "read_after_write", "normal test", "critical test"...
                                                            • UVM_env
                                                              • test env build up.
                                                                • modules
                                                            • config
                                                              • module
                                                                • config address range, RGM
                                                              • transaction
                                                                • config type, info, address, data, len...
                                                              • system
                                                                • whole design config
                                                            • UVM_package
                                                              • pack lib 

                                                            Assertions

                                                            • coverage assertion
                                                              • coverage group
                                                              • FSM group
                                                              • pattern group
                                                            • functional assertion
                                                              • c/c++ co-sim 
                                                                • phase to phase check
                                                                  • DPI wrapper interface
                                                              • SystemC TL0/TL1 co-sim
                                                                • use TLM2.0 analysis port export 
                                                            • protocol assertion
                                                              • req/grant
                                                                • @(posedge clk) req |-> [1:3]gt;


                                                            2013年4月14日 星期日

                                                            UVM systemverilog assertion(SVA)


                                                            • assertion
                                                              • assert in C/C++, pointer check 
                                                                • A *a = new A();
                                                                • assert(a!=NULL);
                                                                • a->do_some_thing()...
                                                              • main purpose
                                                                • performance hazards
                                                                  • performance requirement throughput for real time issue
                                                                • wrong functionality
                                                                  • functional error when the transaction is miss-match for each condition description
                                                                  • Assertion active at both clock edges
                                                                    • a2: assert property(@(posedge clk)a|->b[*8]); 
                                                                  • Sequence used as clocking event 
                                                                    • sequence s;
                                                                      @(posedge clk) a[*5];

                                                                      endsequence
                                                                      a3: assert property (@(s) b |-> ##3 c); 
                                                                  • Complex Boolean expression used for clock 
                                                                    • a5: assert property (@(clk iff en) p1);    
                                                                  • Wrong argument type or size
                                                                    • `ASSERTS_ONE_HOT(a7, {sig1, sig2, sig3} ...);    
                                                                  • short circuit 
                                                                    • function bit legal_state(
                                                                    • bit [0:3] current, bit valid);
                                                                    • a12: assert #0 (valid |-> current != '0);
                                                                    • legal_state = valid && $onehot(current);
                                                                    • endfunction
                                                                    • if (status || legal_state(valid, state)) 
                                                                    •   
                                                                  • Action block without functional call
                                                                    • `define MY_MUTEX(sig) \
                                                                    • assert #0($onehot0(sig))
                                                                    • always @(posedge clk) begin
                                                                    • ...
                                                                    • `MY_MUTEX(fsm_1_state)
                                                                    • `MY_MUTEX(fsm_2_state); 
                                                                    • end
                                                                  • req/grant protocol check
                                                                    • a14: assert property
                                                                    • (@clk req |-> strong(##[1:$] gnt));
                                                                  • assertion for coverage
                                                                    • c16: cover property (@clk 
                                                                    • (state==REQ)##1 (state==SEND));
                                                                  •  possibly ignored assertions
                                                                  • low coverage(pattern valid/invalid, critical case, how to inc the coverage value)



                                                            2013年4月8日 星期一

                                                            llvm analysis notes

                                                            refs:
                                                            http://163.25.101.87/~yen3/wiki/doku.php?id=llvm:llvm_notes



                                                            • llvm commands



                                                            • Convert C/C++ code to llvm IR
                                                              llvm-g++ -emit-llvm -S test.cpp -o test.ll
                                                            • Convert llvm IR to llvm bitcode
                                                              llvm-as test.ll -o test.bc
                                                            • Print Control Flow Graph
                                                              opt -dot-cfg test.bc
                                                            • Print Dominator Tree Graph
                                                              opt -dot-dom test.bc
                                                            • Conver C++ code to C code
                                                              llvm-g++ -emit-llvm test.cpp -o program.bc -c
                                                              llc -march=c program.bc -o program.c

                                                            • analysis(ADT analysis, rule check, redundant check, frame remap)
                                                              • Alias analysis
                                                                • alias memory/register (immutable/mutable) label 
                                                                • check different two frames when the input arg is depended from another? 
                                                              • CFG analysis
                                                                • domain tree, basic block(entry, exist, loop, if/else), operator, reg/mem location
                                                                • loop (vector)
                                                                  • for(i=0;i<10 a1="" a2="" b1="" b2="" c1="" c2="" i="" li="" nbsp="">
                                                                  • vector(c1,c2) <= {a1,b1} {a2,b2}
                                                              • register analysis
                                                                • virtual register to physical register(arm r0~r10) , rega, regb, regc
                                                              • memory analysis
                                                                • load/store analysis(store is depended on load?)
                                                                • parallel load/store with different address block in the same BB 
                                                              • dependent analysis
                                                                • (depend memory? load/store check)
                                                                  • a[0] = 1; # load from constant input
                                                                  • b = a[0]; # b is depend from previous assignment, store to output
                                                                • split iterator
                                                                  • for(i=0; i<10 ...="" a="" i="" li="" nbsp="" org="">
                                                                  • fcheck each unit memory block dependence

                                                            2013年4月2日 星期二

                                                            LLVM + ZeroMQ = Remote Compiler flow plan

                                                            flow plan

                                                            • portable for different platform (client arm, server x86) balance tasks
                                                              • arm for low power mobile device
                                                              • x86 for high performance server device
                                                            • using zeroMQ to our communication handshaking
                                                              • balance the loading
                                                              • multi protocols(TCP/UDP)
                                                              • distribution communication
                                                              • internal broadcast
                                                            • client part
                                                              • method
                                                                • application to llvm byte code or llvm-IR
                                                                • pull llvm byte code or llvm-IR to server by zeroMQ request
                                                                • get server response when the pull-task is done by zeroMQ response
                                                              • require
                                                                • llvm compiler
                                                            • server part
                                                              • method
                                                                • get llvm byte code or llvm-IR from client request
                                                                • do task reassign based on it's server utility, like 2cores CPU(client) to 64 cores CPU(server)
                                                                • put result to client
                                                              • require
                                                                • listen port to link client request
                                                                • byte / IR ADT remap to physical hardware
                                                                • multi requests/ multi tasks balance timeout issue
                                                                • llvm compiler

                                                            Ta-lib + bigdata = stock analysis tool

                                                            • 如何用30分鐘, 打造出自己獨特程式交易系統. 話不多說,我們就直接開始吧!!!!
                                                            • requirements
                                                              • Ta-lib(support finance indicators)
                                                              • bigdata(pandas, numpy, scipy, matplotlib...)
                                                              • Ta-lib Cython wrapper (wrapper Ta-lib to python)
                                                            • how to install in Mac 
                                                              • install Ta-lib (port install ta-lib)
                                                              • install bigdata 
                                                                • port install py27-pandas
                                                                • port install py27-numpy
                                                                • port install py27-matplotlib
                                                                • ...
                                                              • setup python search path for mac port
                                                                • add the below info to "~/.bashrc"
                                                                  • "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
                                                                • source ~/.bashrc
                                                              • install Ta-lib(wrapper)
                                                                • https://github.com/funningboy/ta-lib
                                                            • example case
                                                              • 買點
                                                                • 利用5日平均線大於10日平均線
                                                              • 賣點
                                                                • 持有天數最多只能有三天
                                                              •  結論
                                                                • 還是實在賺錢比較重要
                                                              • ref:
                                                                • https://github.com/funningboy/ta-lib/blob/master/tools/tdr_jump.py
                                                              • results:
                                                            total profit is : -20.26
                                                            ----------------------------------------------------------------------------------------------------
                                                                           ma10      ma5   close    high     low    open   volume  entry  leave  profit
                                                            2013-01-02      NaN      NaN  723.25  727.00  716.55  719.42  2541300      0      0    0.00
                                                            2013-01-03      NaN      NaN  723.67  731.93  720.72  724.93  2318200      0      0    0.00

                                                            import sys                                                                                                                                                                           
                                                            from datetime import datetime
                                                            
                                                            import numpy as np
                                                            import talib
                                                            import matplotlib.finance as fin 
                                                            from pylab import show
                                                            
                                                            from pandas import Index, DataFrame, Series
                                                            from pandas.core.datetools import BMonthEnd
                                                            from pandas import ols 
                                                            
                                                            
                                                            def getQuotes(symbol, start, end):
                                                                """ get stock Quotes from Yahoo """
                                                            
                                                                quotes = fin.quotes_historical_yahoo(symbol, start, end)
                                                                dates, open, close, high, low, volume = zip(*quotes)
                                                            
                                                                data = { 
                                                                    'open': open,
                                                                    'close': close,
                                                                    'high': high,
                                                                    'low': low,
                                                                    'volume': volume
                                                                }   
                                                            
                                                                dates = Index([datetime.fromordinal(int(d)) for d in dates])
                                                                return DataFrame(data, index=dates)
                                                            
                                                            
                                                            def getMA(quotes):
                                                                """ get mv_avg indicator and update org quotes by joining two DataFrame """
                                                            
                                                                ma5 = talib.MA(quotes['close'],5)
                                                                ma10 = talib.MA(quotes['close'],10)
                                                            
                                                                data = { 
                                                                        'ma5' : ma5,
                                                                        'ma10': ma10,
                                                                        }   
                                                            
                                                                update = DataFrame(data, index=quotes.index)
                                                                return update.join(quotes)
                                                            
                                                            def setEntryRule1(quotes):
                                                                """ set entry rule when ma5 is cross-over ma10 """
                                                            
                                                                def rule1(quotes, index):
                                                                    rst = 1 if quotes['ma5'][index] > quotes['ma10'][index] else 0
                                                                    return rst
                                                            
                                                                quotes['entry'] = [rule1(quotes, index) for index in quotes.index]
                                                                return quotes
                                                            
                                                            
                                                            def setLeaveRule1(quotes):
                                                                """ set leave rule when the holding day is large than 3 days"""
                                                            
                                                                def rule1(quotes, position):
                                                                    if position - 3 >= 0:
                                                                        if quotes['entry'][position-3] == 1:
                                                                            return [1, quotes['close'][position] - quotes['close'][position-3]]
                                                                    return [0, 0]
                                                            
                                                                quotes['leave'], quotes['profit'] = zip(*[rule1(quotes, position) for position, index in enumerate(quotes.index)])
                                                                return quotes
                                                            
                                                            
                                                            def getProfit(quotes):
                                                                """ get profit report """
                                                            
                                                                print "total profit is : %s" %(sum(quotes['profit']))
                                                                print "-" * 100
                                                                print quotes
                                                            
                                                            
                                                            def main():
                                                                # get stock info from start to end
                                                                startDate = datetime(2013, 1, 1)
                                                                endDate = datetime(2013, 1, 30)
                                                            
                                                                # get stock id
                                                                goog = getQuotes('GOOG', startDate, endDate)
                                                                goog = getMA(goog)
                                                            
                                                                goog = setEntryRule1(goog)
                                                                goog = setLeaveRule1(goog)
                                                                getProfit(goog)
                                                            
                                                            if __name__ == '__main__':                                                                                                                                                           
                                                                main()
                                                            
                                                            

                                                            2013年3月28日 星期四

                                                            UVM guide line


                                                            • Naming rule
                                                              • axi_package, axi_monitor.svh
                                                            • how to debug
                                                              • if (debug) `uvm_info("DEBUG", msg, UVM_MEDIUM)
                                                              • uvm_factory  factory = uvm_factory.get(); factory.print();
                                                              • uvm_top.print_topology()
                                                            • how to trace connection 
                                                              • use "get_connect_to()", "get_provide_to()", children[$]

                                                              • // If there is something connected,
                                                                // print the port name and the connections. 
                                                                if ((connected_to_list.size() > 0) || (provided_to_list.size() > 0) ) begin 
                                                                // Print the name of the port. $display("%s Port: %s", {depth+2{" "}},
                                                                children[i].get_full_name()); end 
                                                            • how to trace transactions
                                                              • use backdoor to log the analysis point
                                                              • fifo.put_export.debug_connected_to(); fifo.put_export.debug_provided_to();
                                                              • $display("%s", tx_queue[tx_id].convert2string());
                                                            • atomic transaction items(active sequence)
                                                              • use "pre_body()" phase to add new sequence
                                                              • use "post_body()" phase to remove sequence
                                                              • active_sequenves::show();
                                                            • internal BB(break) point(assertion pp)
                                                              • `define BB if (BB::check_pp1( tx, get_full_name()) $stop;
                                                            • use "grep" command to filter out the useful info
                                                              • grep "type_id::create" xx.log
                                                            • use report catcher without default UVM_report, collect the report pool meg to our report format
                                                              • function action_e catch();
                                                              • id = get_id(); 
                                                              • filename = get_fname(); 
                                                              • line = get_line(); 
                                                              • severity = get_severity();
                                                              • $dispay("%s...,", id);
                                                            • use report server to overwrite the report
                                                            ref: Better Living Through Better Class-BasedSystemVerilog Debug