Thursday, October 5, 2017

model for piecewise linear source

http://www.designers-guide.org/Forum/YaBB.pl?num=1270820173

Verilog-A pwl implementation using arrays for time/voltage input

`include "disciplines.vams"

module pwl(out);
output out;
electrical out;

parameter integer N = 1 from [2:inf);parameter real t[1:N] = {N{0}};
parameter real y[1:N] = {N{0}};

analog begin : blk
integer nxt_i;
real yp, tp, slope;
integer err;

        @(initial_step) begin
                nxt_i = 1;
                yp = y[1];
                tp = 0.0;
        end

        @(timer(t[nxt_i])) begin
                yp = y[nxt_i];
                tp = t[nxt_i];

                if(nxt_i < N) begin
                        nxt_i = nxt_i + 1;
                        if(t[nxt_i] - tp <= 0) begin
                                err = 1;
                                $debug("Non monotonic time sequence: t[%d] == %e, t[%d] == %e", nxt_i-1, tp, nxt_i, t[nxt_i]);
                                $finish;
                        end
                        if(!err)
                                slope = (y[nxt_i] - yp)/(t[nxt_i] - tp);
                end
        end

        if(!err)
                V(out) <+ yp + slope*($realtime - tp);

end

endmodule




System-Verilog pwl implementation


module strpwl(p, n);
   electrical p, n;
   inout p, n;

   parameter string pwl = "";
   parameter        dcval = 0.0;
  

   analog function real scanval;
      input s;
      inout pos;
      string s;
      integer pos;
      integer ipos;
      string  valstr;
            
      begin
         ipos = pos;
         while(pos < s.len() && s.substr(pos, pos) != ",")
           pos = pos+1;

         valstr = s.substr(ipos, pos-1);
         if(1 == $sscanf(valstr, "%g", scanval))
           pos = pos+1;
         else
           pos = -1;  // Error indicator
      end
   endfunction

   integer pos = 0;
   real    tnext, vnext;
   real    tprev = 0.0;
   real    vprev = dcval;
   real    slope;
  
   integer err;
  
   analog initial begin : blk
      real retVal;

      tprev = 0.0;
      vprev = dcval;
      
      tnext = scanval(pwl, pos);
      vnext = scanval(pwl, pos);
      if (tnext-tprev != 0.0)
          slope = (vnext - vprev)/(tnext - tprev);
      $strobe(tnext, vnext);
   end

   analog begin
      @(timer(tnext)) begin
         tprev = tnext;
         vprev = vnext;
        
         tnext = scanval(pwl, pos);
         vnext = scanval(pwl, pos);

         if(pos > 0)
           begin
              if(tnext - tprev <= 0) begin
                 err = 1;
                 $debug("Non monotonic time sequence.");
                 $finish;
              end
              if(!err)
                slope = (vnext - vprev)/(tnext - tprev);
           end
      end

      if(!err)
        V(p, n) <+ vprev + slope*($abstime - tprev);

   end

endmodule
 




Thursday, September 21, 2017

Friday, August 4, 2017

lecture link

Sam Palermo
ECEN 689: Optical Interconnects Circuits and Systems
ECEN 720: High-Speed Links Circuits and Systems
High-Speed Links Circuit Design Techniques Short Course


A 10Gb/s Compact Low-Power Serial I/O with DFE-IIR Equalization in 65nm CMOS
hslink_eq_overview_hanumolu_jhses05.pdf

Controlled Intersymbol Interference Design Techniques of Conventional Interconnect Systems for Data Rates Beyond 20 Gbps


Modeling, Simulation, and Design of a Multi-Mode 2-10 Gb/sec Fully Adaptive Serial Link System

Pattern Generator Model for Jitter-Tolerance Simulation
Modeling Jitter in PLL-based Frequency Synthesizers

Modeling and Verification of High-Speed Wired Links with Verilog-AMS

IEEE JOURNAL OF SOLID-STATE CIRCUITS, VOL. 43, NO. 9, SEPTEMBER 2008
Edge and Data Adaptive Equalization of Serial-Link Transceivers
Koon-Lun Jackie Wong, E-Hung Chen, and Chih-Kong Ken Yang, Senior Member, IEEE

Clock and Data Recovery Circuit and Clock Synthesizers for 40 Gb/s High-Density Serial I/O-Links in 90-nm CMOS
ABHANDLUNG
zur Erlangung des Titels


verilog piecewise linear behavioral modeling for mixed-signal

INTRODUCTION TO DIGITAL FILTERS

Art of approximation in science and engineering

Accurate and Efficient Modeling Approach for PhaseLocked Loops for Mixed-Signal

Phase Noise Simulation and Modeling of ADPLL by SystemVerilog

All digital phase-locked loop: concepts, design and applications

Metastability

Real Portable Models for System/Verilog/A/AMS 


Wednesday, June 14, 2017

spec link

Serial ATA Revision 3.0
 http://www.lttconn.com/res/lttconn/pdres/201005/20100521170123066.pdf

Clock and Data Recovery/Buffer Memory (Elastic Buffer)

https://en.wikibooks.org/wiki/Clock_and_Data_Recovery/Buffer_Memory_(Elastic_Buffer)

Clock and Data Recovery/Buffer Memory (Elastic Buffer)/Cascades of Buffers and CDRs, delays and tolerance

https://en.wikibooks.org/wiki/Clock_and_Data_Recovery/Buffer_Memory_(Elastic_Buffer)/Cascades_of_Buffers_and_CDRs,_delays_and_tolerance

1G/2.5G Ethernet PCS/PMA or SGMII v15.0
https://www.xilinx.com/support/documentation/ip_documentation/gig_ethernet_pcs_pma/v15_0/pg047-gig-eth-pcs-pma.pdf

1G/2.5G Ethernet PCS/PMA or SGMII v16.0
https://www.xilinx.com/support/documentation/ip_documentation/gig_ethernet_pcs_pma/v16_0/pg047-gig-eth-pcs-pma.pdf

10G Ethernet PCS/PMA v6.0
https://www.xilinx.com/support/documentation/ip_documentation/ten_gig_eth_pcs_pma/v6_0/pg068-ten-gig-eth-pcs-pma.pdf

IEEE 802.3by 25G Ethernet TF A BASELINE PROPOSAL FOR RS, PCS, AND FEC
http://www.ieee802.org/3/by/public/Jan15/baden_3by_01b_0115.pdf

IPG Considerations
http://www.ieee802.org/3/ba/public/may08/folkens_01_0508.pdf

Physical Coding Sublayer

https://en.wikipedia.org/wiki/Physical_Coding_Sublayer



Friday, June 9, 2017

vim tip

Changing case with regular expressions

For example, assume a line with the text "This is a test".
:s/\(test\)/\U\1 file/
produces: This is a TEST FILE
:s/\(test\)/\U\1\e file/
produces: This is a TEST file


http://vim.wikia.com/wiki/Changing_case_with_regular_expressions


Wednesday, May 31, 2017

Change filenames and replace string within files

Change filenames and replace string within files.

import os
import fnmatch
import shutil
import re

for file in os.listdir('.'):
    if fnmatch.fnmatch(file, 'pattern_*.v'):
        p = re.compile('pattern_')
        dest = 'new_dir/' + p.sub('new_pattern_',file)
        print 'new_dir/' + dest
        shutil.copyfile(file, dest)

        with open(dest, 'r') as file:
            filedata = file.read()
        filedata = filedata.replace('pattern_', 'new_pattern_')

        flag = True
        newfile = ""
        for line in filedata.splitlines():
            if re.search(r"^.ifdef", line):
                flag = True
                continue
            elif re.search(r"^.else", line):
                flag = False
            elif re.search(r"^.endif", line):
                flag = True
                continue
            if flag :
                newfile = newfile + line + '\n'

        with open(dest, 'w') as file:
            file.write(newfile)
            #file.write(filedata)

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 {} \;




      Tuesday, March 3, 2015

      지구에 존재하는 ‘최강 운동’ 버피

      The burpee is a full body exercise used in strength training and as an aerobic exercise. The basic movement is performed in four steps and known as a "four-count burpee":
      1. Begin in a standing position.
      2. Drop into a squat position with your hands on the ground. (count 1)
      3. Kick your feet back, while keeping your arms extended. (count 2)
      4. Immediately return your feet to the squat position. (count 3)
      5. Jump up from the squat position (count 4)

      Origin[edit]

      According to Oxford Dictionaries Online, the exercise was named in the 1930s for American physiologist Royal H. Burpee, who developed theburpee test. He earned a PhD in applied physiology from Columbia University in 1940 and created the "burpee" exercise as part of his PhD thesis as a quick and simple way to assess fitness.[8] The exercise was popularized when the United States Armed Services adopted it as a way to assess the fitness level of recruits when the US entered WWII. Consisting of a series of the exercises performed in rapid succession, the test was meant to be a quick measure of agility, coordination and strength.[9]

      http://en.wikipedia.org/wiki/Burpee_%28exercise%29

      <div align=right><font color=blue>ⓒ위즈덤하우스 제공</font></div>


      https://www.youtube.com/watch?v=JZQA08SlJnM


      http://www.sisainlive.com/news/articleView.html?idxno=22217

      Wednesday, February 11, 2015

      SystemVerilog Interface

      SystemVerilog Interfaces

      Interfaces are created to encapsulate the communication between blocks, allowing a smooth refinement from abstract system-level through successive steps down to lower RTL and structural levels of the design. Interfaces also facilitate design re-use. Interfaces are hierarchical structures that can contain other interfaces.

      advantages:
      • They encapsulate connectivity: an interface can be passed as a single item through a port, thus replacing a group of names by a single one. This reduces the amount of code needed to model port connections and improves its maintainability as well as readability.
      • They encapsulate functionality, isolated from the modules that are connected via the interface. So, the level of abstraction and the granularity of the communication protocol can be refined totally independent of the modules. 
      • They can contain parameters, constants, variables, functions and tasks, processes and continuous assignments, useful for both system-level modelling and testbench applications. 
      • They can help build applications such as functional coverage recording and reporting, protocol checking and assertions.
      • They can be used for port-less access: An interface can be instantiated directly as a static data object within a module. So, the methods used to access internal state information about the interface may be called from different points in the design to share information.
      • Flexibility: An interface may be parameterised in the same way as a module. Also, a module header can be created with an unspecified interface instantiation, called a Generic Interface. This interface can be specified later on, when the module is instantiated.
      At its simplest, an interface is a named bundle of wires, similar to a struct, except that an interface is allowed as a module port, while a struct is not.
      // Interface definition
      interface Bus;
        logic [7:0] Addr, Data;
        logic RWn;
      endinterface
      
      // Using the interface
      module TestRAM;
        Bus TheBus();                   // Instance the interface
        logic[7:0] mem[0:7];
        RAM TheRAM (.MemBus(TheBus));   // Connect it
      
        initial
        begin
          TheBus.RWn = 0;               // Drive and monitor the bus
          TheBus.Addr = 0;
          for (int I=0; I<7; I++)
            TheBus.Addr = TheBus.Addr + 1;
          TheBus.RWn = 1;
          TheBus.Data  = mem[0];
        end
      endmodule
      
      module RAM (Bus MemBus);
        logic [7:0] mem[0:255];
      
        always @*
          if (MemBus.RWn)
            MemBus.Data = mem[MemBus.Addr];
          else
            mem[MemBus.Addr] = MemBus.Data;
      endmodule

      Modports in Interfaces

      A new construct related to Interface is also added: Modport. This provides direction information for module interface ports and controls the use of tasks and functions within certain modules. The directions of ports are those seen from the module.
      This example includes modports, which are used to specify the direction of the signals in the interface. The directions are the ones seen from the module to which the modport is connected, in our case the RAM:
      interface MSBus (input Clk);
        logic [7:0] Addr, Data;
        logic RWn;
        modport Slave (input Addr, inout Data);
      endinterface
      
      module TestRAM;
        logic Clk;
        MSBus TheBus(.Clk(Clk));
        RAM TheRAM (.MemBus(TheBus.Slave));
        ...
      endmodule
      
      module RAM (MSBus.Slave MemBus);
        // MemBus.Addr is an input of RAM
      endmodule
      http://www.doulos.com/knowhow/sysverilog/tutorial/interfaces/

      Monday, December 22, 2014

      향이 좋은 수도원 맥주

      Alpirsbacher Ambrosius - 7,7%
      Steenbrugge Tripel - 8.7%
      Westmalle Extra - 4.8%
      Mont des Cats
      Floreffe Dubbel - 6.3%
      Trappist Ale
      La Trappe Quadrupel - 10%
      Maredsours 10 - 10%
      Westmalle Dubbel - 7.0%
      St. Bernardus Abt 12 - 10.5%
      Rochefort 8 - 9.2%
      Affligem Tripel - 9.5%
      Westmalle Tripel - 9.5%

      집에서 맥주 만들기.
      http://sapporoboom.com/51
      http://theopendoor.tistory.com/497
      http://blog.daum.net/kdc21c/43
      http://swleeca.tistory.com/entry/%EC%A7%91%EC%97%90%EC%84%9C-%EB%A7%A5%EC%A3%BC-%EB%A7%8C%EB%93%A4%EA%B8%B0


      Wednesday, December 3, 2014

      How to select Christmas tree.

      Natural trees[edit]

      The most commonly used species are fir (Abies), which have the benefit of not shedding their needles when they dry out, as well as retaining good foliage colour and scent; but species in other genera are also used.

      In North America, Central America and South America most commonly used are:
      • Douglas-fir Pseudotsuga menziesii -- reasonably priced tree and creates that great smell



      http://en.wikipedia.org/wiki/Christmas_tree





      Monday, October 27, 2014

      adb command list

      1. connect with wifi
          adb connect address
          - connect with usb
      2. enter adb shell
          adb shell
      3. find out apps package name
          pm list packages | grep "app name"
      4. adb uninstall or pm uninstall

      Rooting a Nook Simple Touch 1.2.1 and Power Optimization

      http://blog.shanock.com/rooting-a-nook/

      Guide/HowTo/Tips'nTricks - The perfect Nook Simple Touch Setup
      Nook Simple Touch (N2E) power management / battery optimization
      http://forum.xda-developers.com/showthread.php?t=1933615


       nice tutorial about getting information 
      http://www.androidsnippets.com/get-installed-applications-with-name-package-name-version-and-icon 

      Android Debug Bridge
      http://developer.android.com/tools/help/adb.html


      Following are the basic commands which we usually use :
      http://forum.xda-developers.com/showthread.php?t=1521097

      pull - to copy file/dir from Xoom to computer
      push - to copy file/dir from computer to Xoom , we will call it "X"
      delete - delete file/dir from X
      install – install apps on X [either on SD Card or internal storage]
      reboot - reboot your X

      The following command, (pull) takes the file avi.apk from the device and saves it as file.apk to the Android Tools directory of computer. 

      Pull 
      Code:
      Code:
       adb pull /system/app/avi.apk file.apk
      Push
      The following command will copy avi.apk file as happy.apk, from the computer Android tools folder to /system/app of the device
      Code:
      Code:
        adb push avi.apk /system/app/happy.apk
      Delete :
      The following command removes file avi.apk
      Code:
      Code:
        adb shell rm /system/app/avi.apk
      Install :
      adb can also be used to install apks. Place the downloaded apks in C:/ drive. for eg, I have placed angrybirds.apk in C:/ drive of my computer. To install it, just run the following command.


      Code:
      Code:
       adb install angrybirds.apk
      By above command it will install to internal storage. 
      *You can also install to SD card by -s switch. (example below)

      Code:
      Code:
      adb install -s angrybirds.apk
      Reboot :
      The following command will reboot your (device)
      Code:


      Code:
       adb shell su reboot