Use countbits to count number of bits having a specified set of values 0 1 x z

Use countbits to count number of bits having a

This preview shows page 16 - 20 out of 38 pages.

Use $countbits() to count number of bits having a specified set of values (0, 1, x , z ) assert (!$isunknown(data) else $error (“data has %0d bits with x or z”, $countbits (data, 'x, 'z)); ECE 571 Introduction to SystemVerilog SystemVerilog non-integer types void No storage Functions that don’t return values shortreal 32-bit single precision floating point (like float in C) Not synthesizable real Same as in “Classic” Verilog 64-bit double precision (like double in C) Not synthesizable time 64-bit unsigned Ex: time now; // declares now as a time variable ) realtime Same as real
Image of page 16
17 ECE 571 Introduction to SystemVerilog Relaxation of Variable Assignment Rules SystemVerilog relaxes rules on where var(iables) can be used A variable can receive a value from any one of these ways: Assigned value from any number of initial or always procedural blocks (Same as “Classic” Verilog) Assigned value from single always_comb, always_ff , or always_latch procedural block Assigned value from single continuous assignment statement Receive value from single module or gate primitive output or an inout port ECE 571 Introduction to SystemVerilog var(iables) cannot be driven by multiple sources but nets can Illegal Use of Variables
Image of page 17
18 ECE 571 Introduction to SystemVerilog Static and Automatic Variables At module level all variables are static SystemVerilog adds static keyword and allows any variable to be declared static or automatic in tasks , functions , begin…end blocks, fork…join blocks static variables initialized only once (not synthesizable) automatic variables initialized each call (synthesizable) Defaults are compatible with Verilog Functions/tasks are static as are their variables Automatic functions/tasks have automatic variables unless the ECE 571 Introduction to SystemVerilog Deterministic Initialization Verilog-1995 didn't support in-line initialization of variables when declared - had to initialize variables in initial blocks Verilog-2001 introduced C language syntax for initialization Semantics are as though i and j are initialized sequentially in same initial block. Otherwise, semantics of initial blocks unchanged (i.e. j could get uninitialized value of i) SystemVerilog changed the semantics: in-line initializations always evaluated prior to initial blocks
Image of page 18
19 ECE 571 Introduction to SystemVerilog An Example Consider behavior of following code using “Classic” Verilog semantics Two possibilities: The always block is activated first, looking for next positive clock edge or negative resetN edge which will occur (still at simulation time 0) when resetN is subsequently initialized The resetN initialization occurs first. The always block will be looking for the next positive edge of clock or negative edge of resetN (not the one that occurred at time 0 SystemVerilog removes this ambiguity: in-line initializations always evaluated prior to initial blocks ECE 571 Introduction to SystemVerilog
Image of page 19
Image of page 20

You've reached the end of your free preview.

Want to read all 38 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture