easter egg . plot a cadence waveform to the tektronix 4014 emulatorof xterm

Discussion in 'Cadence' started by fogh, Mar 29, 2005.

  1. fogh

    fogh Guest

    Hi All,

    grey weather here for easter, so I made a SKILL toy. It will plot a
    waveform to the xterm Tek window. I had always wondered what this xterm
    "tek" mode was. I tried to plot families too, but that doesn t work. It
    should work OK if you plot a real valued waveform (probably fails on AC
    or PSS freq domain 's complex waves).


    ;; fun with xterm's tektronix 4014 emulator
    ;; for a phosphor alike color, "xterm -fg green -bg black"
    ;; run icfb from the xterm , load this file
    ;; open some simulation result, browse, put the a real wave expression
    in the clipboard
    ;; enter in CIW:
    ;; TKplotwave( <paste wave expression> )
    ;;voila.

    /*
    #get info on terminal capabilities and control codes
    man ascii
    man console_codes
    man reset
    man termcap
    man terminfo
    man tic
    man xterm
    gv /usr/share/doc/x*doc*.?/xterm/ctlseqs.PS.gz
    less $(locate tek.trm) #or use google/gnuplot source
    wget http://www.tug.org/cgi-bin/dirarchive/tex-archive/dviware/dvgt.tgz
    ; tar xzvf dvgt.tgz; less dvgt/dvgt/src/tek4010*
    mozilla http://www.gnu.org/software/plotutils/plotutils.html
    mozilla http://www.update.uu.se/~fstx/1/tekscope/
    wget http://vt100.net/tektronix/4014-um/4014-um.pdf
    #read from page 92 , appendix G
    ######## try it out
    #ECMA-48 Set Graphics Rendition
    echo -en "\033[32m"
    echo -en "\033[40m"

    #SGR code ; inverse video
    echo -e "\033[7m oediv esrever \033[0m"

    #Digital Equipment Corp. private mode set
    ##enter tektronix
    echo -en "\033[?38h"

    ###### what to do
    #-send "enter tek mode ; clear & init " control codes
    #-send graph commands from a dfII waveform

    */
    ;;;;;;;;;;;;;;;;;;;;;;;;;tek4010 definitions
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ESC="\033"
    TK='(nil)

    TK->entertek="\033[?38h" ; esc [ ? 38 h
    TK->reset="\033[?38l" ; esc [ ? 38 l
    TK->page="\033\014" ;esc ff

    TK->alpha="\037" ; ascii US , text mode
    TK->graph="\035" ; ascii GS , graphic mode
    TK->point="\034" ; ascii FS , point plot mode
    TK->incplot="\036" ; ascii RS , incremental plot mode

    TK->xmax=1024
    TK->ymax=780
    TK->xlast=TK->xmax-1
    TK->ylast=TK->ymax-1
    TK->vchar=25
    TK->hchar=14
    TK->vtic=TK->htic=11
    TK->hx=TK->hy=0x20
    TK->lx=0x40
    TK->ly=0x60
    ;TK->lower5= 2**5 - 1
    TK->lower5=0b11111
    TK->upper5=TK->lower5<<5

    TK->port=outfile("/dev/stdin")

    TK->linetypes = "`abcdhijkl"
    TK->last_vt_linetype = nil ;;this is a global. keeps state info: nil is
    uninitialised, 0 to 9 is build-in line type

    procedure(TKsnd(x)
    ;fprintf(TK->port "%s\n" x )
    fprintf(TK->port "%s" x )
    drain(TK->port)
    )
    procedure(TKascTostr(asc)
    ;;sending a beep
    ;;fprintf(outfile("/dev/stdout") "%s\n"
    symbolToString(intToChar(charToInt(stringToSymbol("\007") ))))
    symbolToString(intToChar(asc))
    )

    procedure( TKvector(x y)
    ;; (0 0) is lowerleft ; x is horizontal
    TKsnd( strcat(
    TKascTostr(TK->hy | (y & TK->upper5) >> 5)
    TKascTostr(TK->ly | (y & TK->lower5))
    TKascTostr(TK->hx | (x & TK->upper5) >> 5)
    TKascTostr(TK->lx | (x & TK->lower5))
    ))
    )

    procedure( TKmove(x y)
    let(()
    TKsnd(TK->graph)
    TKvector(x y)
    ))

    /* linetypes for VT-type terminals in tektronix emulator mode
    0 `=solid, 1 a=fine dots, 2 b=short dashes, 3 c=dash dot,
    4 d=long dash dot, 5 h=bold solid, 6 i=bold fine dots, 7 j=bold short
    dashes,
    8 k=bold dash dot, 9 l=bold long dash dot */
    procedure( TKlinetype(linetype)
    linetype = mod(linetype 10)
    TKsnd(strcat(ESC getchar(TK->linetypes linetype+1)))
    TK->last_vt_linetype = linetype
    )

    procedure( TKput_text(x, y, str)
    let( (lt)
    lt=TK->last_vt_linetype
    TKlinetype(0)
    TKmove(x, y - TK->vtic)
    TKsnd(strcat(TK->alpha str))
    TKlinetype(lt)
    ))

    procedure(TK_xterm_tekinit()
    ;;green foreground black background, ansi codes.
    TKsnd(strcat(ESC "[32m")) TKsnd(strcat(ESC "[40m"))
    TKsnd(TK->reset)
    TKsnd(TK->entertek)
    ;sh("sleep 1")
    ;hiRegTimer(
    TKsnd(TK->page)
    TKmove(0 0) ;;this also sets graph mode
    TKlinetype(5) ;;this also sets the "initialised" flag
    );proc


    ;;;;;;;;;;;;;;;;;;;;;;;;;waveform definitions
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    procedure( TKplotwave(w)
    let( (xmin xmax ymin ymax yspan xspan Tx Ty)

    unless(TK->last_vt_linetype TK_xterm_tekinit() ) ;initialise if necessary

    xmin=drGetElem(x=drGetWaveformXVec(w) 0)
    xmax=drGetElem(x drVectorLength(x)-1 )
    ymin=ymin(w) ymax=ymax(w)
    xspan=1.0/(xmax-xmin) yspan=1.0/(ymax-ymin)

    ;;get first point
    x=xmin
    y=drGetElem(drGetWaveformYVec(w) 0)
    Tx=round( TK->xlast*(x-xmin)*xspan )
    Ty=round( TK->ylast*(y-ymin)*yspan )
    ;;TxPrev=Tx TyPrev=Ty
    TKmove(Tx Ty)

    ;;loop through points
    foreach( mapcar lXY artWaveformToList(w)
    x=car(lXY) y=cadr(lXY)
    Tx=round( TK->xlast*(x-xmin)*xspan )
    Ty=round( TK->ylast*(y-ymin)*yspan )
    ;TKmove(Tx Ty)
    TKvector(Tx Ty)
    ;TxPrev=Tx TyPrev=Ty
    );foreach point
    t
    );let
    );proc

    procedure(TKplot(x)
    cond(
    (numberp(x) TKplotwave(artListToWaveform(list( list(x x) list(x x)))
    ) ) ;;
    (drIsWaveform(x) TKplotwave(x) ) ;;
    (famIsFamily(x) famMap('TKplot x ) ) ;;
    );cond
    );proc


    /************************************************
    procedure(TKX() ;;run examples
    let(
    nil
    ; (w l xl xv xrange urange F )
    defmacro( l () load("TektronixPlot.il") )
    ; l
    awvSetWaveformToolName( "awd" )

    w=artListToWaveform('((0 0) (1 1) (2 4) (3 9)))
    xl=linRg(-1 15 0.01)
    xv=drCreateVec( 'double xl )
    w=expr(x exp(x/3)*sin(5*x) xl)
    ;TKplotwave(w)

    procedure(myfunc(u x) exp(x/(3*u))*sin(x*5*u) ) ;myfunc
    xrange=linRg(-1 12 0.05)
    urange=logRg(0.9 1.5 10)
    VRL=;gives nil as second name
    list(
    list("U" urange )
    list("X" xrange )
    )
    F=famFuncApply('myfunc VRL)
    plot( F )
    TKplot( F )

    );let
    );proc examples
    ************************************************/
     
    fogh, Mar 29, 2005
    #1
  2. Don't you have anything better to do? ;-)

    I get people amazed at some of the things I've implemented over
    the years, but this is definitely even more far out than anything I've ever
    done (it beats my sandwich ordering GUI and billing system that I
    wrote years ago in NeWS (something similar to Display PostScript), before the
    days of the web; at least that was useful...).

    Andrew.
     
    Andrew Beckett, Mar 29, 2005
    #2
  3. fogh

    fogh Guest

    Like visit a museum ? If you know a museum where they expose tektronix
    4010 terminals, I may be interested :)

    I don t know why, I have an urge to write useless code these days. Here
    is more:

    let(
    (pi S C cv p)
    pi=4*atan(1)
    S=sin(pi/3)
    C=cos(pi/3)
    cv=geGetEditCellView()
    p=1.0/cv->DBUPerUU

    procedure(Kdraw(cv l_twopoints @optional (depth -1) )
    let( (xs ys xe ye x1 y1 x2 y2 x3 y3 x4 y4 cond)
    xs=caar(l_twopoints) ys=cadar(l_twopoints)
    xe=caadr(l_twopoints) ye=cadadr(l_twopoints)
    x1=xs+(xe-xs)/3.0
    x3=xs+2*(xe-xs)/3.0
    y1=ys+(ye-ys)/3.0
    y3=ys+2*(ye-ys)/3.0
    x2=(xs+xe)/2.0-C*(ye-ys)/3
    y2=(ys+ye)/2.0+S*(xe-xs)/3

    if(depth > -1
    { cond=(depth >0 ) }
    {
    d=sqrt((xe-xs)**2+(ye-ys)**2)
    cond=d>p
    }
    )
    if( cond
    {
    Kdraw(cv list(xs:ys x1:y1) depth-1)
    Kdraw(cv list(x1:y1 x2:y2) depth-1)
    Kdraw(cv list(x2:y2 x3:y3) depth-1)
    Kdraw(cv list(x3:y3 xe:ye) depth-1)
    }
    {
    ;dbCreateLine(cv "device" list(xs:ys x1:y1 x2:y2 x3:y3 xe:ye))
    dbCreateLine(cv "INDdummy" list(xs:ys x1:y1 x2:y2 x3:y3 xe:ye))
    }
    );fi
    );let
    );proc

    ;; Kdraw cv list(-1000:0 1000:0) 6
    ;; Kdraw cv list(-1.000:0 1.000:0)
    ;; Kdraw cv list(-0.3000:0 0.3000:0)
    ;; Kdraw cv list(-0.1000:0 0.1000:0)
    ;; { (mapcar 'dbDeleteObject cv->shapes) }
    );toplet
     
    fogh, Mar 31, 2005
    #3
  4. If you're going to post code, can you please learn to
    indent it properly? It makes reading the code much, much, much,
    easier.

    It's not basic - it's a proper programming language...

    Sorry for the criticism - I just want to encourage good practice!

    Cheers,

    Andrew.
     
    Andrew Beckett, Mar 31, 2005
    #4
  5. Hi,

    I thought I posted this sometime before, could be a starting point.

    http://www.nedit.org/ftp/contrib/highlighting/skill.pats

    in combination with
    editor = "nedit"
    and
    BFprettyPrint( 'Kdraw edit t )


    By my suggestion would be a kind of SKILL coding standards
    and recommendations for end users.

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    ;; File Name : prettyPrint.il
    ;;
    ;; Function(s) : BFprettyPrint
    ;;
    ;; Author : Bernd Fischer
    ;;
    ;; Date : Fri, 28 November 2003
    ;;
    ;; Version : 1.0
    ;;
    ;; Application : Cadence Design Framework II
    ;;
    ;; SW Release : 4.4.3 and higher
    ;;
    ;; SKILL Lint : PASSed
    ;;
    ;; Global Variable(s) : None
    ;;
    ;; Synopsis : BFprettyPrint( s_functionName ?edit b_edit )
    ;;
    ;; Description : Displays the code of a loaded SKILL function in a
    ;; viewfile window or in the default editor.
    ;;
    ;; Arguments : s_functionName Function name to pretty print,
    ;; name must start with a tic '.
    ;; b_edit A boolean value t/nil to define
    ;; if the function should be printed in
    ;; a viewfile window for nil or in an
    ;; editor for t, the default is nil.
    ;;
    ;; Return Value : w_windowId/ipc
    ;;
    ;; Example : BFprettyPrint( 'BFprettyPrint ?edit t )
    ;;
    ;; Modification : -
    ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    procedure( BFprettyPrint( s_functionName @key ( edit nil ) )
    let( (
    t_tmpFile p_outPort
    )

    t_tmpFile = strcat( "/tmp/" symbolToString( s_functionName ) ".il" )
    p_outPort = outfile( t_tmpFile )
    funcall( 'pp s_functionName p_outPort )

    close( p_outPort )

    cond(
    ( !edit
    view( t_tmpFile )
    )
    ( t
    edit(
    strcat( "/tmp/" symbolToString( s_functionName ) ".il" )
    )
    )
    ) ;; close cond

    ) ;; close let

    ) ;; close BFprettyPrint
     
    Bernd Fischer, Mar 31, 2005
    #5
  6. fogh

    fogh Guest

    Hi Bernd,
    I found the skill.pats to be awfully limited. It hilights within
    quotes and does not undertand the prefix syntax. And it does not take
    care of indentation either. I could not do much in trying to improve it
    tho. It seems pretty hard to find quotes '

    Do you have an improved version ?
     
    fogh, Apr 2, 2005
    #6
  7. fogh

    S.Badel Guest

    I also did not like this file.
    I did my own, which i like more and works fine. It also includes all the
    keywords of SKILL (or, at least, the ones which are in the reference
    manual). the suffixed numbers are recognized, and the strings seem to
    highlight correctly. Even though i do not code lisp-style, rather
    c-style, i tried to make it work for both.

    i also redid the script to generate calltips files, which somebody
    posted here a while ago and i found not working well.
    my version uses more advanced text parsing which allows to avoid many
    mistakes that the other was doing. if anyone's interested, i can post it
    here as well (its perl).

    stéphane

    --------------------------------------------------------------------------

    nedit.languageModes: SKILL:.il .ils .ocn
    ..tf::::::".,/\\`'!|#%^&*()-=+{}[]"":<>?~":"SKILL.tips"\n\

    SKILL:1:0{\n\
    Comment:"/\\*":"\\*/"::Comment::\n\
    SKILL Comment:";":"\\n"::Comment::\n\
    String:"""":"(?<=[^\\\\])"""::String::\n\
    Numeric
    Constant:"<((([0-9]+\\.?[0-9]*)|(\\.[0-9]+))(((e|E)(\\+|-)?[0-9]+)|([afpnumkMGTP])))?>":::Numeric
    Const::\n\
    SpecialWords:"<(nil|t|then|else)>":::Keyword::\n\

    Keywords:"\\y(abs|acos|add1|addDefstructClass|alias|alphalessp|alphaNumCmp|and|append|append1|apply|argc|argv|arrayp|arrayref|asin|assoc|assq|assv|atan|atof|atoi|atom|band|bcdp|begin|begin|bitfield1|bitfield|blankstrp|bnand|bnor|bnot|booleanp|bor|boundp|buildString|bxnor|bxor|car|caaaar|caaadr|caadar|caaddr|caar|caddar|cadddr|cadr|cdaaar|cdaadr|cdaar|cdadar|cdaddr|cdadr|cdar|cddaar|cddadr|cddar|cdddar|cddddr|cdddr|cddr|caaar|caadr|cadar|caddr|cdadr|cadaar|cadadr|caddar|cadddr|cdaaar|cdaadr|cdadar|cdaddr|cddaar|cddadr|cdddar|cddddr|case|caseq|cdr|cdsGetInstPath|ceiling|changeWorkingDir|charToInt|clearExitProcs|close|compareTime|compress|concat|cond|cons|constar|copy|copy_\\w*|copyDefstructDeep|cos|cputime|createDir|csh|declare|declareLambda|declareNLambda|declareSQNLambda|define|defmacro|defMathConstants|defprop|defstruct|defstructp|defun|defUserInitProc|defvar|deleteDir|deleteFile|difference|display|do|drain|dtpr|ed|edi|edit|edl|envobj|eq|equal|eqv|err|error|errset|errsetstri
    ng|eval|evalstring|evenp|exists|exit|exp|expandMacro|expt|fboundp|fileLength|fileSeek|fileTell|fileTimeModified|fix|fixp|float|floatp|floor|for|forall|foreach|fprintf|fscanf|scanf|sscanf|funcall|funobj|gc|gensym|geqp|get|get_filename|get_pname|get_string|getc|getchar|getCurrentTime|getd|getDirFiles|getFnWriteProtect|getFunType|getInstallPath|getLogin|getPrompts|getq|getqq|getTempDir|gets|getShellEnvVar|getSkillPath|getSkillVersion|getVarWriteProtect|getVersion|getWarn|getWorkingDir|go|greaterp|help|if|importSkillVar|index|infile|inportp|inScheme|inSkill|instring|integerp|intToChar|isCallable|isDir|isExecutable|isFile|isFileEncrypted|isFileName|isInfinity|isLargeFile|isLink|isMacro|isNaN|isReadable|isWritable|lambda|last|lconc|leftshift|length|leqp|lessp|let|let|letrec|letseq|lineread|linereadstring|list|listp|listToVector|load|loadi|loadstring|log|log10|lowerCase|make_\\w*|makeTable|makeTempFileName|makeVector|map|mapc|mapcan|mapcar|maplist|max|measureTime|member|memq|memv|mi
    n|minus|minusp|mod|modulo|mprocedure|nconc|ncons|needNCells|negativep|neq|nequal|newline|nindex|nlambda|not|nprocedure|nth|nthcdr|nthelem|null|numberp|numOpenFiles|oddp|onep|openportp|or|otherp|outfile|outportp|pairp|parseString|plist|plus|plusp|portp|postdecrement|postincrement|pprint|predecrement|preincrement|prependInstallPath|print|printf|printlev|println|procedure|procedurep|prog|prog1|prog2|progn|putd|putprop|putpropq|putpropqq|quote|quotient|random|range|read|readstring|readTable|realp|regExitAfter|regExitBefore|remainder|remd|remdq|remExitProc|remove|remprop|remq|renameFile|return|reverse|rexCompile|rexExecute|rexMagic|rexMatchAssocList|rexMatchList|rexMatchp|rexReplace|rexSubstitute|rightshift|rindex|round|rplaca|rplacd|schemeTopLevelEnv|set|setarray|setcar|setcdr|setFnWriteProtect|setof|setplist|setPrompts|setq|setqbitfield1|setqbitfield|setShellEnvVar|setSkillPath|setVarWriteProtect|sh|shell|simplifyFilename|sin|sort|sortcar|sprintf|sqrt|srandom|sstatus|status|strc
    at|strcmp|stringp|stringToFunction|stringToSymbol|stringToTime|strlen|strncat|strncmp|sub1|subst|substring|sxtd|symbolp|symbolToString|symeval|symstrp|system|tablep|tableToList|tailp|tan|tconc|theEnvironment|times|timeToString|timeToTm|tmToTime|truncate|type|typep|unalias|unless|upperCase|vector|vectorp|vectorToList|vi|vii|vil|warn|when|which|while|write|writeTable|xcons|xdifference|xplus|xquotient|xtimes|zerop|zxtd|defclass|defmethod)>":::plain::\n\
    Keyword Color:"\\1":""::Keyword:Keywords:C\n\
    Procedure Call:"\\((\\l\\w*)|<(\\l\\w*)\\(":::plain::\n\
    Procedure Name Color:"\\1\\2":""::Subroutine:procedure Call:C\n\
    KeyArg:"(?<=\\y\\?)\\l\\w*":::Text Arg::\n\
    QuotedWord:"(?<=\\y')\\l\\w*":::Identifier2::\n\
    Identifier:"(<[a-zA-Z]\\w*>)":::plain::\n\
    }
     
    S.Badel, Apr 3, 2005
    #7
  8. fogh

    fogh Guest

    Hi Stephane,

    I posted the calltips shell script... it s true it was a quick and
    blunt one, probably overlooking all peculiarities of the finder files.
    You could share with us the improved version. Or better, submit it
    along with your improved SKILL patterns to the nedit wiki.

    it would really be great if we had a patterns file that can recognise
    quotes by ticks ' , macros , etc ... some kind of merge between your
    pattern file and the lisp/scheme patterns. The must be gurus at cadence
    who can produce that in a blink.

     
    fogh, Apr 4, 2005
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.