Tuesday, December 30, 2008

systemverilog wordfile

copied from http://avm-users.googlegroups.com/web/systemverilog.txt?hl=en&gsc=Lb4u6AsAAADWzOiV2TvclJOPyNlia6Gs
/L20"Verilog 1364-2001" Line Comment = // Block Comment On = /* Block Comment Off = */ String Chars = " File Extensions = SV SVL/Delimiters = ~!@%^&*()-+=|\/{}[]:;"<> , .?#/Function String = "%[a-z0-9]+[ ^t]+[a-z_0-9]+[ ^t]+("
/Indent Strings = "begin" "fork" "specify" "config"
/Unindent Strings = "end" "join" "join_any" "join_none" "endspecify" "endconfig"
/C1"Keywords"
alias always always_comb always_ff always_latch and assert assign assume automatic 
before begin bind bins binsof bit break buf bufif0 bufif1 byte
case casex casez cell chandle class clocking cmos config const constraint context continue cover covergroup coverpoint cross
deassign default defparam design disable dist do
edge else end endcase endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event expect export extends extern
final first_match for force foreach forever fork forkjoin function
generate genvar
highz0 highz1
if iff ifnone ignore_bins illegal_bins import incdir include initial inout input inside instance int integer interface intersect join
join_any join_none
large liblist library local localparam logic longint
macromodule matches medium modport module
nand negedge new nmos nor noshowcancelled not notif0 notif1 null
or output
package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect pure
rand randc randcase randsequence rcmos real realtime ref reg release repeat return rnmos rpmos rtran rtranif0 rtranif1
scalared sequence shortint shortreal showcancelled signed small solve specify specparam static string strong0 strong1 struct super supply0 supply1
table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef
union unique unsigned use
var vectored virtual void
wait wait_order wand weak0 weak1 while wildcard wire with within wor
xnor xor
/C2"System"
** 'b 'B 'o 'O 'd 'D 'h 'H 'sb 'sB 'so 'sO 'sd 'sD 'sh 'sH 'Sb 'SB 'So 'SO 'Sd 'SD 'Sh 'SH
** _
$assertkill $assertoff $asserton $async$and$array $async$nand$array $async$or$array $async$nor$array $async$and$plane $async$nand$plane $async$or$plane $async$nor$plane
$bits $bitstoreal $bitstoshortreal 
$cast $comment $countdrivers $countones
$date $dimensions $display $displayb $displayh $displayo $dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t $dist_uniform $dumpall $dumpflush $dumpfile $dumplimit $dumpoff $dumpon $dumpports $dumpportsall $dumpportsflush $dumpportslimit $dumpportsoff $dumpportson $dumpvars
$enddefinitions $error $exit
$fatal $fdisplay $fdisplayf $fdisplayb $fdisplayh $fdisplayo $fell $feof $ferror $fflush $fgetc $fgets $finish $fopen $fmonitor $fmonitorb $fmonitorf $fmonitorh $fmonitoro $fclose $fread $fscanf $fseek $fsscanf $fstrobe $fstrobeb $fstrobef $fstrobeh $fstrobeo $ftell $fullskew $fwrite $fwriteb $fwritef $fwriteh $fwriteo 
$get_coverage $getpattern
$high $hold $history
$increment $incsave $info $input $isunbounded $isunknown $itor
$key 
$left $list $load_coverage_db $log $low 
$monitor $monitorb $monitorh $monitoro $monitoron $monitoroff 
$nochange $nokey $nolog $onehot $onehot0
$past $period $printtimescale
$q_add $q_exam $q_full $q_initialize $q_remove $q_random
$random $readmemb $readmemh $realtime $realtobits $recovery $recrem $removal $reset $reset_count $reset_value $restart $rewind $right $root $rose $rtoi
$sampled $save $scale $scope $sdf_annotate $set_coverage_db_name $setup $setuphold $sformat $shortrealtobits $showvariables $showscopes $showvars $signed $size $skew $sreadmemb $sreadmemh $sscanf $stable $stime $stop $strobe $strobeb $strobeh $strobeo $swrite $swriteb $swriteh $swriteo $sync$and$array $sync$nand$array $sync$or$array $sync$nor$array $sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane
$test$plusargs $time $timeformat $timescale $timeskew $typename $typeof
$ungetc $unit $unpacked_dimensions $unsigned $upscope $urandom $urandom_range
$value$plusargs $var $vcdclose $version
$warning $width $write $writeb $writeh $writeo $writememb $writememh

/C3"Operators"
->
+:
-:
@
@*
*>
,
;
.*
{
}
+
-
// /
*
**
%
>
>=
>>
>>>
<
<=
<<
<<<
!
!=
!==
&
&&
|
||
=
==
===
^
^~
~
~^
~&
~|
?
:
|->
|=>
/C4"Directives"
** `
`begin_keywords
`accelerate `autoexepand_vectornets
`celldefine
`default_nettype `define `default_decay_time `default_trieg_distributed `default_trireg_strength `delay_mode_distributed `delay_mode_path `delay_mode_unit `delay_mode_zero
`else `elsif `endcelldefine `endif `end_keywords `endprotect `endprotected `expand_vectornets
`file
`ifdef `ifndef `include
`line
`noaccelerate `noexpand_vectornets `noremove_gatenames `noremove_netnames `nounconnected_drive
`pragma `protect `protected
`remove_gatenames `remove_netnames `resetall
`timescale
`unconnected_drive `undef `uselib


/C5"DelaysAndParameters"
#
##

Make script

The oritinal page is http://www.hsrl.rutgers.edu/ug/make_help.html
How to write a Makefile

How to write a Makefile



Introduction


Make is one of the original Unix tools for Software Engineering. By
S.I. Feldman of AT&T Bell Labs circa 1975. But there are public
domain versions (eg. GNU) and versions for other systems
(eg. Vax/VMS).


Related tools are the language compilers (cc, f77, lex, yacc, etc.)
and shell programming tools (eg. awk, sed, cp, rm, etc.). You need to
know how to use these.


Important adjuncts are lint (source code checking for obvious errors)
ctags (locate functions, etc. in source code) and mkdepend. These are
nice, and good programmers use them.


Important, and related tools, are the software revision systems SCCS (Source Code Control System) and RCS (Revision Control System -- the recommended choice)

The idea is to automate and optimize the construction of
programs/files -- ie. to leave enough foot prints so that others can
follow.

Makefile Naming



make is going to look for a file called Makefile, if not found then a
file called makefile. Use the first (so the name stands out in
listings).


You can get away without any Makefile (but shouldn't)! Make has
default rules it knows about.

Makefile Components




  • Comments


    Comments are any text beginning with the pound (#) sign. A
    comment can start anywhere on a line and continue until the end of the
    line. For example:


    # $Id: slides,v 1.2 1992/02/14 21:00:58 reggers Exp $


  • Macros

    Make has a simple macro definition and substitution mechanism. Macros are defined in a Makefile as = pairs. For example:


    MACROS= -me
    PSROFF= groff -Tps
    DITROFF= groff -Tdvi
    CFLAGS= -O -systype bsd43

    There are lots of default macros -- you should honor the existing naming conventions. To find out what rules/macros make is using type:

    % make -p

    NOTE: That your environment variables are exported into the make as macros. They will override the defaults.


    You can set macros on the make command line:


    % make "CFLAGS= -O" "LDFLAGS=-s" printenv
    cc -O printenv.c -s -o printenv


  • Targets

    You make a particular target (eg. make all), in none specified then the first target found:


    paper.dvi: $(SRCS)
    $(DITROFF) $(MACROS) $(SRCS) >paper.dvi

    NOTE: The the line beginning with $(DITROFF) begins with TAB not spaces.

    The target is made if any of the dependent files have changed. The dependent files in this case are represented by the $(SRCS) statement.



  • Continuation of Lines

    Use a back slash (\). This is important for long macros and/or rules.




  • Conventional Macros


    There are lots of default macros (type "make -p" to print out the defaults). Most are pretty obvious from the rules in which they are used:


    AR = ar
    GFLAGS =
    GET = get
    ASFLAGS =
    MAS = mas
    AS = as
    FC = f77
    CFLAGS =
    CC = cc
    LDFLAGS =
    LD = ld
    LFLAGS =
    LEX = lex
    YFLAGS =
    YACC = yacc
    LOADLIBS =
    MAKE = make
    MAKEARGS = 'SHELL=/bin/sh'
    SHELL = /bin/sh
    MAKEFLAGS = b


  • Special Macros


    Before issuing any command in a target rule set there are certain special macros predefined.



    1. $@ is the name of the file to be made.
    2. $? is the names of the changed dependents.


    So, for example, we could use a rule


    printenv: printenv.c
    $(CC) $(CFLAGS) $? $(LDFLAGS) -o $@

    alternatively:

    printenv: printenv.c
    $(CC) $(CFLAGS) $@.c $(LDFLAGS) -o $@

    There are two more special macros used in implicit rules. They are:


    1. $< the name of the related file that caused the action.
    2. $* the prefix shared by target and dependent files.



  • Makefile Target Rules


    The general syntax of a Makefile Target Rule is


    target [target...] : [dependent ....]
    [ command ...]

    Items in brackets are optional, ellipsis means one or more.
    Note the tab to preface each command is required.


    The semantics is pretty simple. When you say "make target"
    make finds the target rule that applies and, if any of the
    dependents are newer than the target, make executes the com-
    mands one at a time (after macro substitution). If any
    dependents have to be made, that happens first (so you have
    a recursion).


    A make will terminate if any command returns a failure sta-
    tus. That's why you see rules like:


    clean:
    -rm *.o *~ core paper

    Make ignores the returned status on command lines that begin
    with a dash. eg. who cares if there is no core file?


    Make will echo the commands, after macro substition to show
    you what's happening as it happens. Sometimes you might want
    to turn that off. For example:


    install:
    @echo You must be root to install



  • Example Target Rules


    For example, to manage sources stored within RCS (sometimes
    you'll need to "check out" a source file):


    SRCS=x.c y.c z.c

    $(SRCS):
    co $@

    To manage sources stored within SCCS (sometimes you'll need
    to "get" a source file):

    $(SRCS):
    sccs get $@

    Alternativley, to manage sources stored within SCCS or RCS
    let's generalize with a macro that we can set as required.

    SRCS=x.c y.c z.c
    # GET= sccs get
    GET= co

    $(SRCS):
    $(GET) $@

    For example, to construct a library of object files

    lib.a: x.o y.o z.o
    ar rvu lib.a x.o y.o z.o
    ranlib lib.a

    Alternatively, to be a bit more fancy you could use:

    OBJ=x.o y.o z.o
    AR=ar

    lib.a: $(OBJ)
    $(AR) rvu $@ $(OBJ)
    ranlib $@

    Since AR is a default macro already assigned to "ar" you can
    get away without defining it (but shouldn't).


    If you get used to using macros you'll be able to make a few
    rules that you can use over and over again.

    For example, to construct a library in some other directory


    INC=../misc
    OTHERS=../misc/lib.a

    $(OTHERS):
    cd $(INC); make lib.a

    Beware:, the following will not work (but you'd think it
    should)

    INC=../misc
    OTHERS=../misc/lib.a

    $(OTHERS):
    cd $(INC)
    make lib.a

    Each command in the target rule is executed in a separate
    shell. This makes for some interesting constructs and long
    continuation lines.


    To generate a tags file


    SRCS=x.c y.c z.c
    CTAGS=ctags -x >tags

    tags: $(SRCS)
    ${CTAGS} $(SRCS)

    On large projects a tags file, that lists all functions and
    their invocations is a handy tool.


    To generate a listing of likely bugs in your problems

    lint:
    lint $(CFLAGS) $(SRCS)

    Lint is a really good tool for finding those obvious
    bugs that slip into programs -- eg. type classes, bad argu-
    ment list, etc.


  • Some Basic Make Rule


    People have come to expect certain targets in Makefiles. You
    should always browse first, but it's reasonable to expect
    that the targets all (or just make), install, and clean will
    be found.



    1. make all -- should compile everything so that you can do local testing before installing things.
    2. make install -- should install things in the right places. But watch out that things are installed in the right place for your system.
    3. make clean -- should clean things up. Get rid of the executables, any temporary files, object files, etc.


    You may encounter other common targets, some have been
    already mentioned (tags and lint).



  • An Example Makefile for printenv



    # make the printenv command
    #
    OWNER=bin
    GROUP=bin
    CTAGS= ctags -x >tags
    CFLAGS= -O
    LDFLAGS= -s
    CC=cc
    GET=co
    SRCS=printenv.c
    OBJS=printenv.o
    SHAR=shar
    MANDIR=/usr/man/manl/printenv.l
    BINDIR=/usr/local/bin
    DEPEND= makedepend $(CFLAGS)
    all: printenv

    # To get things out of the revision control system
    $(SRCS):
    $(GET) $@
    # To make an object from source
    $(CC) $(CFLAGS) -c $*.c

    # To make an executable

    printenv: $(OBJS)
    $(CC) $(LDFLAGS) -o $@ $(OBJS)

    # To install things in the right place
    install: printenv printenv.man
    $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 printenv $(BINDIR)
    $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 644 printenv.man $(MANDIR)

    # where are functions/procedures?
    tags: $(SRCS)
    $(CTAGS) $(SRCS)

    # what have I done wrong?
    lint: $(SRCS)
    lint $(CFLAGS) $(SRCS)

    # what are the source dependencies
    depend: $(SRCS)
    $(DEPEND) $(SRCS)

    # to make a shar distribution
    shar: clean
    $(SHAR) README Makefile printenv.man $(SRCS) >shar

    # clean out the dross
    clean:
    -rm printenv *~ *.o *.bak core tags shar

    # DO NOT DELETE THIS LINE -- make depend depends on it.
    printenv.o: /usr/include/stdio.h




  • Makefile Implicit Rules


    Consider the rule we used for printenv


    printenv: printenv.c
    $(CC) $(CFLAGS) printenv.c $(LDFLAGS) -o printenv

    We generalized a bit to get

    printenv: printenv.c
    $(CC) $(CFLAGS) $@.c $(LDFLAGS) -o $@

    The command is one that ought to work in all cases where we
    build an executable x out of the source code x.c This can be
    stated as an implicit rule:

    .c:
    $(CC) $(CFLAGS) $@.c $(LDFLAGS) -o $@

    This Implicit rule says how to make x out of x.c -- run cc
    on x.c and call the output x. The rule is implicit because
    no particular target is mentioned. It can be used in all
    cases.


    Another common implicit rule is for the construction of .o
    (object) files out of .c (source files).


    .o.c:
    $(CC) $(CFLAGS) -c $<

    alternatively

    .o.c:
    $(CC) $(CFLAGS) -c $*.c


  • Make Dependencies


    It's pretty common to have source code that uses include
    files. For example:


    % cat program.c

    #include
    #include "defs.h"
    #include "glob.h"
    etc....
    main(argc,argv)
    etc...

    The implicit rule only covers part of the source code depen-
    dency (it only knows that program.o depends on program.c).
    The usual method for handling this is to list the dependen-
    cies separately;

    etc...
    $(CC) $(CFLAGS) -c $*.c
    etc...
    program.o: program.c defs.h glob.h

    Usually an implicit rule and a separate list of dependencies
    is all you need. And it ought to be easy enough to figure
    out what the dependencies are.


    However, there are a number of nice tools around that will
    automatically generate dependency lists for you. For example
    (trivial):


    DEPEND= makedepend $(CFLAGS)
    etc...
    # what are the source dependencies

    depend: $(SRCS)
    $(DEPEND) $(SRCS)

    etc....
    # DO NOT DELETE THIS LINE -- ....

    printenv.o: /usr/include/stdio.h

    These tools (mkdepend, mkmkf, etc.) are very common these
    days and aren't too difficult to use or understand. They're
    just shell scripts that run cpp (or cc -M, or etc.) to find
    out what all the include dependencies are. They then just
    tack the dependency list onto the end of the Makefile.



Based on Make and Makefiles by
Reg Quinton

Computing and Communications Services

The University of Western Ontario

London, Ontario N6A 5B7

Canada




Press here to return to the General Unix Software Menu.

System Verilog by example by example

System Verilog by example(constraint, random, covergroup)
module top;
typedef enum bit { BAD_PARITY, GOOD_PARITY } parity_e;
class packet_c;
rand bit [5:0] pkt_length;
bit[63:0][7:0] pkt_payload;
bit[7:0] parity;
rand parity_e parity_type;
function bit [7:0] calc_parity();
 calc_parity = { pkt_length, pkt_addr };
 for (int i = 0; i calc_parity ^= pkt_payload[i];
endfunction :calc_parity

function void randomize_payload();
 pkt_addr = $urandom ;
 pkt_length = $urandom ;
 for (int i=0; i < pkt_length; i ++)
  pkt_payload[i]= $urandom;
endfunction:randomize_payload

function void post_randomize();
  randomize_payload();  
  if (parity_type == GOOD_PARITY)
  parity = calc_parity();
  else
  do
  parity = $urandom;
  while (parity == calc_parity());
endfunction:post_randomize

endmodule

class packet_c;
typedef enum bit { BAD_PARITY , GOOD_PARITY } parity_e;
typedef enum bit[1:0] { SMALL,MEDIUM, LARGE } payload_e;
  constraint c { parity_type == GOOD_PARITY ;}
  constraint c1 { payload_type == LARGE ;}
  constraint c3 { pkt_addr == 2; }
  constraint length_range {
  (payload_type == SMALL) -> pkt_length inside { [1 : 20] };
  (payload_type == MEDIUM) -> pkt_length inside { [21 : 44]};
  (payload_type == LARGE) -> pkt_length inside { [45 : 63]};
  }
// Define the Coverage module for the packet defined
  covergroup cg @ (pkt_event);
  coverpoint pkt_length {
  bins usb_range = {[0 : 20]};
  bins pci_range = {[21 : 44]};
  bins ahb_range = {[45 : 63 ]};
  }
  coverpoint pkt_addr;
  coverpoint parity;
  endgroup


Monday, December 1, 2008

水仙养殖

宝贝名称:水仙种球(别名:凌波仙子、玉玲珑、金盏银台等)

宝贝特点:为石蒜科多年生草本。地下部分的鳞茎肥大似洋葱,卵形至广卵状球形,外被棕褐色皮膜。叶狭长带状,二列状着生。花葶中空,扁筒状,通常每球有花葶数支,多者可达10余支,每葶数支,至10余朵,组成伞房花序。

栽培方法:栽培水仙有水培法和土培法两种方法。

一:水培法:即用浅盆水浸法培养。将水仙直立放入水仙浅盆中,加水淹没鳞茎三分之一的为宜。盆中可用石英砂 、鹅卵石等将鳞茎固定。

阳光:白天要放置在阳光充足的地方,夜晚可放在灯光下;

温度:以10-15度为宜,过低(4度以下)容易发生冻害,过高(20度以上)容易发生徒长;

换水:刚上盆时,水仙可每日换一次水,以后每2-3天换一次,花苞形成后,每周换一次水。为防止叶片徒长,最好是傍晚把盆水倒尽,次日清晨再加清水;

花期调控:一般水仙从上盆到开花约45天,但通过适当调控,可以在28天内至60天左右开花,比如节前10天还未看到饱满花苞,可改用接近体温的温水浸泡,并适当添加营养液催花;若想延长开花时间,则可将水仙放至温度较低处4-5度,适当控水等; 

按照以上方法,可使水仙叶短宽厚、茁壮,叶色浓绿,花开香浓。水养水仙,一般不需要施肥,如有条件,在开花期间稍施一些速效磷肥,花可开得更好。

二:土培法:准备肥沃的沙质土壤,将水仙种球栽入一半露出一半,鳞下面应事先垫一些细沙,以利排水。把花盆置于阳光充足、温度适宜的室内。以4至12℃为好,温度过低容易发生冻害,温度过高再加之光照不足,容易陡长,植株细弱,开花时间短暂,降低观赏价值。管理中如果满足光照和温度的要求,则叶片肥大,花莛粗壮,因而能使花朵开得大,芳香持久。土培水仙,可在开花前追施二至三次液肥。