DSP Hardware
Fiels related to Image Processing

Chandranath.M
Front end Design Engineer
ITPL,Bangalore
India
July 11,2001

Updated July 23, 2001

Copyright 2001Chandranath.M


Table of Contents

  1. 1. PERL SCRIPTS
    1. 1.1 Decimal(ASCI) to Hexadecimal Conversion
  2. 2. Verilog Files
    1. 2.1 Test bench for Video SYNC and Data genarator
    2. 2.2 Standared RGB Clorbar Generator
    3. 2.3 Standared YCbCr Color Bar Generator
  3. 2. C Programs
    1. 2.1 . PPM files to .DAT file conversion
  4. RGB to YCbCr and YCbCr to RGB .PPM image file conversion
  • Scripts
  • References
  • 1.PERL SCRIPTS

    These PERL scripts are helpfull for easy conversion which you may come across in Image Processing. Helpfull for UNIX users.

    1.1 Decimal(ASCI) to Hexadecimal Conversion
     

    #!/usr/sys/bin/sun4/perl 
    ########################################################
    # func file converter
    # ver  1.0
    # auth. Chandranath.M
    # date 2001/07/17
    ########################################################
    # ex.
    #  This program is for converting the type of number.
    #  The image formatted file use the decimal number.
    #  This program change the decimal number to hex number
    #  for the verilog simulation.
    # note
    #  This program is till 8bit data for each(RGB)
    #-------------------------------------------------------
    $/ = "";

    # variables
    # $place_1  temporary for 16**1
    # $place_0  temporary for 16**0
    # $j   counter for return code

    while(<>){
     split;
    }
    $j=0;

    foreach(@_){
     $place_1 = 0;
     $place_0 = $_;
     while($place_0>=16){
      $place_0 = $place_0-16;
      $place_1++;
     }

     if($place_1==15)  {$place_1 = "F";}
     elsif($place_1==14)  {$place_1 = "E";}
     elsif($place_1==13)  {$place_1 = "D";}
     elsif($place_1==12)  {$place_1 = "C";}
     elsif($place_1==11)  {$place_1 = "B";}
     elsif($place_1==10)  {$place_1 = "A";}

     if($place_0==15)   {$place_0 = "F";}
     elsif($place_0==14)  {$place_0 = "E";}
     elsif($place_0==13)  {$place_0 = "D";}
     elsif($place_0==12)  {$place_0 = "C";}
     elsif($place_0==11)  {$place_0 = "B";}
     elsif($place_0==10)  {$place_0 = "A";}

     print $place_1.$place_0." ";
     $j++;
     if($j==24){
      $j = 0;
      print "\n";
     }
    }
     


     

    2. Verilog Files

    TheseVerilog Files are helpfull for Simulation Testbenches which you may come across in Image Processing.

    2.1 Test bench for Video SYNC and Data genarator
     

    Will be uploaded soon

    2.2 Standared RGB Color Bar Genarator

    /*-------------------------------------------------------------/
    FILENAME:  rgb.v
    OBJECTIVE: To generate RGB standared Color Bar ppm file
    AUTHOR :Chandranath.M
    DATE: 11-07-2001
    --------------------------------------------------------------*/

    module t_rgb ;

    reg    CLKI ;
     

    reg [7:0]  G, B, R ;

    integer     i;
    integer     mcd1;
    reg         DENB;
    integer     BARWID,PERIOD_2;

    parameter   XSIZE = 'd80;
    parameter   YSIZE = 'd60;
    parameter   PERIOD='d14;
     

        initial
        begin
     PERIOD_2=PERIOD/2;
     CLKI = 1'b1;
            forever
                #PERIOD_2    CLKI = ~CLKI;
        end
     
     

        initial
        begin
     BARWID = XSIZE/8;
     R  =  8'b0000_0000;
     G  =  8'b0000_0000;
     B  =  8'b0000_0000;
     DENB=1'b0;
            #100;

            for ( i=0; i        begin
                 R  =  8'b0000_0000;
      G  =  8'b0000_0000;
      B  =  8'b0000_0000;
                #(PERIOD*BARWID)   R = 8'b1111_1111;G = 8'b1111_1111;B = 8'b1111_1111;DENB=1'b1;  // white

                #(PERIOD*BARWID)   R = 8'b1111_1111;G = 8'b1111_1111;B = 8'b0000_0000;   // yellow

                #(PERIOD*BARWID)   R = 8'b0000_0000;G = 8'b1111_1111;B = 8'b1111_1111;   // cyan

                #(PERIOD*BARWID)   R = 8'b0000_0000;G = 8'b1111_1111;B = 8'b0000_0000;   // green

                #(PERIOD*BARWID)   R = 8'b1111_1111;G = 8'b0000_0000;B = 8'b1111_1111;   // magenta

                #(PERIOD*BARWID)   R = 8'b1111_1111;G = 8'b0000_0000;B = 8'b0000_0000;   // red

                #(PERIOD*BARWID)   R = 8'b0000_0000;G = 8'b0000_0000;B = 8'b1111_1111;   // blue

                #(PERIOD*BARWID)   R = 8'b0000_0000;G = 8'b0000_0000;B = 8'b0000_0000;   // front porch

                #(PERIOD*BARWID); DENB=1'b0;
            end
     #100 $finish;
        end

    initial
     begin
         mcd1 = $fopen("rgb.ppm");
        $fwrite(mcd1,"P3\n");
        $fwrite(mcd1,"%d %d\n",XSIZE,YSIZE);
        $fwrite(mcd1,"255\n");
     end
    always @(negedge  CLKI)
    begin
       if(DENB)
     $fdisplay(mcd1,"%d %d %d",R,G,B);
    end
    endmodule

    2.3 Standared YCbCr color bar Genarator

    /*-------------------------------------------------------------/
    FILENAME:  ycbcr.v
    OBJECTIVE: To generate RGB standared Color Bar ppm file
    AUTHOR :Chandranath.M
    DATE: 11-07-2001
    --------------------------------------------------------------*/

    module t_ycbcr ;
     
    reg    CLKI ;
    reg [7:0]  Y, CB, CR ;
    integer     i;
    integer     mcd1;
    reg         DENB;
    integer     BARWID,PERIOD_2;

    parameter   XSIZE = 'd80;
    parameter   YSIZE = 'd60;
    parameter   PERIOD='d14;

    initial
        begin
     PERIOD_2=PERIOD/2;
     CLKI = 1'b1;
            forever
                #PERIOD_2    CLKI = ~CLKI;
        end
    initial
        begin
     BARWID = XSIZE/8;
     Y  =  8'b0000_0000;
     CB =  8'b0000_0000;
     CR =  8'b0000_0000;
     DENB=1'b0;
            #100;
     
            for ( i=0; i        begin
                 Y  =  8'b0000_0000;
      CB =  8'b0000_0000;
      CR =  8'b0000_0000;
                #(PERIOD*BARWID)   Y = 8'b1111_1111;CB= 8'b1000_0000;CR= 8'b1000_0000;DENB=1'b1;  // white
                #(PERIOD*BARWID)   Y = 8'b1110_0011;CB= 8'b0000_0011;CR= 8'b1001_0100;   // yellow
                #(PERIOD*BARWID)   Y = 8'b1011_0011;CB= 8'b1010_1010;CR= 8'b0000_0011;   // cyan
                #(PERIOD*BARWID)   Y = 8'b1001_0110;CB= 8'b0010_1101;CR= 8'b0001_0111;   // green
                #(PERIOD*BARWID)   Y = 8'b0110_1010;CB= 8'b1101_0011;CR= 8'b1110_1001;   // magenta
                #(PERIOD*BARWID)   Y = 8'b0100_1101;CB= 8'b0101_0110;CR= 8'b1111_1101;   // red
                #(PERIOD*BARWID)   Y = 8'b0001_1101;CB= 8'b1111_1101;CR= 8'b0110_1100;   // blue
                #(PERIOD*BARWID)   Y = 8'b0000_0000;CB= 8'b1000_0000;CR= 8'b1000_0000;   // front porch
                #(PERIOD*BARWID); DENB=1'b0;
            end
     #100 $finish;
        end

    initial
     begin
         mcd1 = $fopen("ycbcr.ppm");
        $fwrite(mcd1,"P3\n");
        $fwrite(mcd1,"%d %d\n",XSIZE,YSIZE);
        $fwrite(mcd1,"255\n");
     end
    always @(negedge  CLKI)
    begin
       if(DENB)
     $fdisplay(mcd1,"%d %d %d",Y,CB,CR);
    end
    endmodule
     
     


     

    3. C Program Files

    TheseVerilog Files are helpfull forConversion from one format to another format which you may come across in Image Processing.

    3.1 Conversion from .PPM format to .DAT format
     

    Will be uploaded soon

     

    4. Click the link bellow to get Conversion(RGB<->YCbCr) programs
     

    conversion.zip

     

    5. Scripts


    SHELL SCRIPTS

    set filec

    ##################################################

    #set prompt="chida@`hostname`>"
    source /usr/slti/sys/shell/Cshrc
    #set prompt = "$cwd:t %"

    ####### FOR GCC ##################################

    set path=($path /usr/local/bin)
    set path=($path /users/ravindra/editors/vim61_my/bin)
    set path=($path /home/matlab6p1/bin)

    ############ FOR CVS #############################
    alias less "/users/chida/less/less-358/less $1"
    alias setlib "/users/chida/setlib"
    #setenv LSI_DESIGN_LIB "TSMC18"#"HD06M"
    ####### FOR PROMPT PATH DESCRIPTION ##############

    #set prompt = "`hostname`:`pwd`>"
    set prompt = "chida@`hostname`>:`pwd`>"
    ####### FOR PROMPT PATH DESCRIPTION ##############

    alias cd 'cd \!*;set prompt = "chida@`hostname`:`pwd`>"'
    cd

    ####### FOR SIGNALSCAN #############################

    alias disp "setenv DISPLAY toki:0.0"
    alias ss "signalscan &"
    ###########VI editor##################
    setenv EXINIT "set nu"

    ####### GENERAL COMMANDS ############ GENERAL COMMANDS ############ GENERAL COMMANDS #####
    #alias vi "vim $1"
    alias cls "clear"
    alias lt "ls -alFt |more"
    alias edit "/users/chida/nedit-5.5/nedit $1"
    alias l "ls -lt|more"
    alias prc "ps -ef|grep "
    alias rbk " \rm *.bck "
    alias rsig " rm *.dsn *.trn "
    alias rlog " rm *.log "
    alias veriq "veri_lic_check"
    alias lchk "license.check"
    alias dcq "syn_lic_check "
    alias ftp159 "ftp 10.31.32.51"
    alias tel159 "telnet 10.31.32.51"
    #alias verilog "/users/chida/verilog $1"
    alias windows "/usr/lib/ICAClient/wfcmgr &"
    alias xv "/users/chida/xv-3.10a/xv"
    alias dcr "dc_shell -f $1 >dcr.log &"
    alias ncsius "source /home/cadence/IUS5.3/cshrc.verilog"
    alias ncsldv "source /home/cadence/ldv5.1/cshrc.verilog"
    alias ncv "ncverilog +access+rwc $1 +licq+ "
    alias matlab "/home/matlab/bin/matlab &"
    -----------------------------------------------
    SYNTHESIS SCRIPTS
    read -f verilog /projects/dsphw/lc749451/users/chand/zsubmod/FMCNTPGEN/FMCNTPGEN.v
    analyze -f verilog /projects/dsphw/lc749451/users/chand/zsubmod/FMCNTPGEN/FMCNTPGEN.v

    remove_license HDL-Compiler
    current_design FMCNTPGEN
    check_design
    uniquify
    link
    create_clock -period 20 -w {0 10} CLK
    set_clock_skew -uncertainty 0.25 CLK
    set_fix_hold CLK
    create_clock -period 20 -w {0 10} XTAL
    set_clock_skew -uncertainty 0.25 XTAL
    set_fix_hold XTAL
    set_max_transition 1.0 XRST
    set_max_fanout 1 XRST
    derive_clocks
    set_input_delay 1.0 all_inputs() -clock CLK
    set_output_delay 3 all_outputs() -clock CLK
    set_input_delay 1.0 all_inputs() -clock XTAL
    set_output_delay 3 all_outputs() -clock XTAL
    check_design
    if(dc_shell_status == 0)
    {
    exit
    }

    set_max_area 0
    set_operating_conditions -min best_case -max worst_case
    set_operating_conditions slow
    compile
    ungroup -all -flatten
    set_wire_load_model -name tsmc13_wl10
    target_library = {"slow.db"}
    link_library = {"slow.db"}
    set_max_transition 1.8 find(design,"*")
    create_clock -period 10 -w {0 5} CLK
    create_clock -period 24 -w {0 12} XTAL
    compile -incremental -map_effort high

    report -constraint -verbose -all_violators > FMCNTPGENviol.rep
    report -area > FMCNTPGENarea.rep
    report_reference > FMCNTPGENref.rep
    report_timing -nworst 10 > FMCNTPGENtime.rep
    report -cell > FMCNTPGENcell.rep
    get_license HDL-Compiler
    write -f verilog -o FMCNTPGEN.net
    exit



    HDL SCORE SIMULATIOn SCRIPT FILE
    ----------------------------------------------
    /* call instrumentation code generation and setting script */
    hdli ./script/hdli.cf
    /* change directory to output */
    cd output
    /* call script for simulation with testbench-1 and tclconfigfile */
    ../script/hdls.cf
    /* change directory to report */
    cd ../report
    /* call script for code/fsm coverage report generation */
    hdlr ../script/hdlr.cf


    ##############################################################################
    # File : hdli.cf
    # Purpose : This script generates instrumented code for RTL coverage analysis.
    ##############################################################################
    # set the design name as hdls
    set_design_name hdls
    # Compile the RTL
    compile /projects/dsphw/lc749451/kijutu/FMTCNV/FMCNTPGEN.v
    # Tool setting for details of each command refer manual
    set_toggle_scoring -off
    set_library_selection -off
    set_scoring_style -vector
    set_implicit_block_scoring -on *
    set_hit_count_limit 1
    set_gates_enabled -off *
    set_coverable_operators -bitwise -xor -reduction -logical -relational -event
    set_coverable_statements -assign -control -procedural -module -initial
    set_default_case_scoring -on
    deselect_coverage -module -block -path -expr -nlevel -gate -variable *
    select_coverage -module -block -path -expr -nlevel -gate -variable *
    extract_fsm -auto
    select_fsm_coverage *
    set_simulation_coverage_control -off
    query -A > ./hdls_work/hdls.sif
    # generate instrumented codes (.vin)
    generate_instrumented_code hdls

    ###############################################################################
    #simulation
    ###############################################################################
    ncverilog -f ../list_sim \
    /users/rahul/lib/xilinx_lib/glbl.v \
    -v /users/rahul/lib/xilinx_lib/simprims.v \
    -v /users/rahul/lib/xilinx_lib/unisims.v \
    -v /projects/dsphw/lc749451/kijutu/QIMP/QIMPYUV2TO4.v \
    -v /projects/dsphw/lc749451/kijutu/QIMP/QIMP.v \
    ../hdls_work/hdls.vin \
    +togl+logfile=vertoggle.log +togl+master=vertoggle.mst \
    +loadpli1=/home/cadence/IUS5.3/tools.sun4v/ict/Solaris/pli/ncv1_21/hdlspli.so:hdlscore_bootstrap \
    +togl+workdir=toggle_work +togl+limit=1 \
    +ncsimexe+/home/cadence/IUS5.3/tools.sun4v/inca/bin/ncsim \
    +access+rwc \
    +ncelabexe+/home/cadence/IUS5.3/tools.sun4v/inca/bin/ncelab \
    +hdls+config+../config/tclconfigfile_1 \
    +licq

    #############################################################################
    # File : tclconfigfile_1
    # Purpose : tcl configuration file for simulation with 1st set of test vector
    ############################################################################
    # load the design
    load_design ../hdls_work/hdls.dgn
    # load the coverage file
    load_coverage ../hdls_work/hdls.cov
    # Save the code coverage file
    save_coverage -code /projects/dsphw/lc749451/hdlscore/FMCNTPGEN/hdls_work/hdls.sim_1.cov
    # Save the fsm coverage file
    save_coverage -fsm /projects/dsphw/lc749451/hdlscore/FMCNTPGEN/hdls_work/hdls_1.fsm
    set_expr_eval_limit 0

    #####################################################################
    # File : hdlr.cf
    #####################################################################
    # load the design (.dgn)
    load_design /projects/dsphw/lc749451/hdlscore/FMCNTPGEN/hdls_work/hdls.dgn
    # load the code coverage file (.cov) for simulation - 1
    load_coverage /projects/dsphw/lc749451/hdlscore/FMCNTPGEN/hdls_work/hdls.sim_1.cov
    # load the code coverage file (.cov) for simulation - 2
    # union union.cov
    set_legend -off
    # generate code coverage report in summary
    report_summary -instance -showzero -bpev *... > sum_coverage.rep
    # report_summary -module -bpev * > INPSEL_sum_coverage.rep
    # load the fsm coverage file (.fsm) for simulation - 1
    load_coverage -fsm ../hdls_work/hdls_1.fsm
    # load the fsm coverage file (.fsm) for simulation - 2
    #load_coverage -fsm ../hdls_work/hdls_2.fsm
    # generate fsm coverage report in summary
    report_summary -module -saq * > sum_fsm.rep
    # generate detail code coverage report cor uncovered logic
    report_detail -module -bpesaq * > sum_fsm_detail_cov.rep




    LEC DO FILE
    --------------------------------------------------------------------

    set log file ./verplex_v.log -replace
    set system mode setup

    read library -Both -sensitive -Verilog \
    /usr/sanyo/verilog/lib/tsmc018/stdcell/macrocell.v \
    /usr/sanyo/verilog/lib/tsmc018/stdcell/iocell.v \
    /usr/sanyo/verilog/lib/tsmc018/stdcell/iocell_analog.v \

    set undefined cell black_box

    //set flatten model -latch_fold
    //add substitute model PH2PSD PH1P

    read design -Verilog -Golden -sensitive \
    ./qskin_imp.v

    read design -Verilog -Revised -sensitive \
    ./qskin_imp.net.v \
    ./qskin_imp.wrap.v

    set system mode lec
    add compared points -all
    compare

    report modules -up -Both
    report black box -class Full -Both -Module
    report cut point -Both
    report design data -summary -nokey_point -Both
    report environment
    report floating signals -Undriven -Both -Full
    report instance constraints -Both
    report instance equivalences -Both
    report message -Design -Both -Nosummary
    report notranslate modules
    report pin constraints -module -Both
    report pin equivalences -module -Both
    report primary inputs -class Full -Both
    report primary outputs -class Full -Both
    report renaming rule -Full -Both
    report search path
    report tied signals -Net -class Full -Both
    report unmapped points -extra -unreachable -notmapped

    write hier dofile dofile.hier -Black_box -Exact_pin_match -NOConstraint -Threshold 50 -Rep
    exit -f







    5. References
     

    Will be uploaded soon
    Hosted by www.Geocities.ws

    1