Thursday, February 2, 2017

SystemVerilog DPI in irun

module real_test ();

// map the C function name to the Verilog function name
import "DPI-C" context get_real_c = function real get_real_v ();
import "DPI-C" context put_real_c = function void put_real_v (real x);     

real pi;

initial
begin
$display("real_test");

pi = get_real_v();        // get a real number from the C code
$display("pi = %f", pi);  // display it

put_real_v(pi);           // send the real number back to C code  
  
end

endmodule
#include "svdpi.h"
// since we are using math functions, include the math library
#include <math.h>

// can use io_printf() instead of printf() to put into ncsim.log file
double get_real_c() {  // imported SV function
  // exercise DPI function - get calling scope
  printf("Function Calling HDL scope is %s \n", svGetNameFromScope(svGetScope() ) );
  return 3.14159;
}

void put_real_c(double n) {  // imported SV function
  // exercise DPI function - get calling scope
  printf("Function Calling HDL scope is %s \n", svGetNameFromScope(svGetScope() ) );
  printf("pi + 5.0 = %f\n", n+5.0);      
}
gcc -fPIC -g -shared -o libdpi.so  real_dpi.c  -I/`ncroot`/tools/include
irun -64 real_test.sv
or
ncvlog real_test.v -sv
ncelab -dpiheader dpi.h worklib.real_test:module
ncsim worklib.real_test:module -sv_lib libdpi.so  -sv_root .

Configuring ctags for Python and Vim

http://www.held.org.il/blog/2011/02/configuring-ctags-for-python-and-vim/

  1. Install ctags
  2. Configure ctags.
    Add to ~/.ctags the following, one option per line:
    1. --python-kinds=-i
    2. optional: --exclude=<partial names of bad files/directories>. e.g. --exclude=*/build/* to exclude all files inside 'build/' directories
  3. Add a cron to rebuild tags, for instance:
    1 * * * * ctags -R -o ~/mytags ~/src
  4. Configure vim:
    add to ~/.vimrc: :set tags=~/mytags
  5. Use Vim:
    1. vim -t <tag name> to open vim straight on the tag
    2. Ctrl+] to jump to tag when over a word
    3. Ctrl+T to pop back
    4. :tselect or :stselect to open
    5. :tnext, :tprev to go to next/prev tag finding
    6. :help tags for more ðŸ™‚

Setting up a MinGW-w64 build environment

http://ascend4.org/Setting_up_a_MinGW-w64_build_environment



    First steps


    MSYS


    Switchable 32- and 64-bit modes


    MinGW-w64


    SWIG

    • Download a pre-compiled 'swigwin' copy of SWIG We used swingwin-x.x.xx.zip.
    • Create a folder c:\mingw\msys\opt using Windows Explorer, then copy the 'swigwin-2.0.10' folder out of the Zip archive and into the new location c:\mingw\msys\opt\swigwin-2.0.10
    • In MSYS, type gedit ~/.profile, then add the SWIG directory to your PATH in your profile, by adding the following line at the bottom of that file:
    export PATH=$PATH:/opt/swigwin-2.0.10
    
    • Close your MSYS window and reopen it, so that the ~/.profile will be re-read.
    • Test that SWIG is accessible by typing swig -version. You should see the version number and some other information output.
    As SWIG is a code pre-processor, it doesn't matter whether it's 32-bit or 64-bit, they will be perfectly equivalent. That is the reason that we install SWIG under msys rather than in mingw\32 or mingw\64. Note that SWIG version 2.0.5 was known to cause problems with MinGW-w64.


      Monday, September 26, 2016

      verilog singed & unsigned

      If the size does not match the number of bits in the value:

      • If the left-most bit of value is 0 or 1, the value is left-extended with 0
      • If the left-most bit of value is Z, the value is left-extended with Z
      • If the left-most bit of value is X, the value is left-extended with X
      • But…a signed value is not sign-extended!

      8’hA   unsigned value extends to 00001010
      8’shA  signed value extends to     00001010

      There are two types of operators in Verilog and SystemVerilog

      • Self-determined operators do not modify their operand(s)
      • Context-determined operators modify all operands to have the same size, using zero-extension or sign-extension

      http://www.uccs.edu/~gtumbush/published_papers/Tumbush%20DVCon%2005.pdf

      module add_signed_1995 (
            input [2:0] A,
            input [2:0] B,
            output [3:0] Sum );
       assign Sum = {A[2],A} + {B[2],B};
      endmodule // add_signed_1995
      Code Example 1: Addition - Verilog 1995

       module add_signed_2001 (
            input signed [2:0] A,
            input signed [2:0] B,
            output signed [3:0] Sum );
       assign Sum = A + B;
      endmodule // add_signed_2001
      Code Example 2: Addition - Verilog 2001

      module add_carry_signed_1995 (
            input [2:0] A,
            input [2:0] B,
            input carry_in,
            output [3:0] Sum );
       assign Sum = {A[2],A} + {B[2],B} + carry_in;
      endmodule // add_carry_signed_1995
      Code Example 3: Add with Carry - Verilog 1995

      module add_carry_signed_2001 (
            input signed [2:0] A,
            input signed [2:0] B,
            input carry_in,
            output signed [3:0] Sum );
       assign Sum = A + B + carry_in;
      endmodule // add_carry_signed_2001
      Code Example 4: Addition with Carry – Incorrect

      module add_carry_signed_final (
            input signed [2:0] A,
            input signed [2:0] B,
            input carry_in,
            output signed [3:0] Sum );
       assign Sum = A + B + $signed({1'b0,carry_in}); ;
      endmodule // add_carry_signed_final
      Code Example 5: Add with Carry - Correct


      http://web.mit.edu/6.111/www/f2012/handouts/L08.pdf



      MoviePy

      User Guide

      MoviePy

      MoviePy is a Python module for video editing, which can be used for basic operations (like cuts, concatenations, title insertions), video compositing (a.k.a. non-linear editing), video processing, or to create advanced effects. It can read and write the most common video formats, including GIF.

      # Video and Audio mixing python script
      
      from moviepy.editor import *
      
      # VIDEO CLIPS
      vclip = VideoFileClip("video.mp4") # or .avi, .webm, .gif ...
      # AUDIO CLIPS
      aclip = AudioFileClip("audio.wav") # or .ogg, .wav... or a video !
      final = concatenate_videoclips([vclip]).set_audio(aclip)
      final.write_videofile("movie.mp4")
      
      

      Thursday, June 23, 2016

      USTA tennis links

      Nocal Tournament search

      FIND A RANKING
      o   Search by First name and Last name – You must enter at the least the first two characters of both the first and last name.
      o   Search by Last Name only – You must enter at least the first 3 characters of the player’s last name.

      https://www.usta.com/Youth-Tennis/Junior-Competition/junior_tournament_news/


      Player Search
      http://www.tennisrecruiting.net/player.asp


      Monday, June 8, 2015

      Use find command but exclude files in two directories & svn set-depth

      http://www.gnu.org/software/findutils/manual/html_mono/find.html

      find [file...] [expression]

      1.3 find Expressions

      The expression that find uses to select files consists of one or more primaries, each of which is a separate command line argument to find. find evaluates the expression each time it processes a file. An expression can contain any of the following types of primaries:
      options
      affect overall operation rather than the processing of a specific file; 
      tests
      return a true or false value, depending on the file's attributes; 
      actions
      have side effects and return a true or false value; and 
      operators
      connect the other arguments and affect when and whether they are evaluated.



      find . -type f -name "*_peaks.bed" ! -path "./tmp/*" ! -path "./scripts/*" -exec svn update -set-depth empty {} \;