![]() Beware!Ħ Verilog - Representation of Number Literals (cont.) Literal numbers can also carry a sign: -4 sd15 This is equivalent to -(4 sd15) or -(-1) or 1. If a signed number such as 9shA6, (8 bits in 9 bit vector) is assigned to a bigger vector the sign bit is lost and is not sign extended. reg p1 = 4 sha initial $displayb ("p1 signed =\t", p1) //p1 = 1111_1111_1010, bit 3 is the sign bit reg p2 = 5 sha initial $displayb ("p2 signed =\t", p2) //p2 = 0000_0000_1010, bit 3 was the sign bit, but was lost in extension When the value is assgined to a bigger vector, the sign indication, will force sign extension when the MSB of value is one. 8 ha //unsigned value extends to: sha //signed value extends to: If the MSB of the size is one and is signed, sign extension will occur. Signed values are not necessarily sign extended because the sign bit is the MSB of the size, not the MSB of the value. If is smaller than value MSB s of value are truncated with warning (tool dependent) If is larger than value MSB s of value are filled Regardless of MSB being 0 or 1, 0 filling is done Left-most Bit Expansion 0 0 extend 1 0 extend x X x or X extend z Z z or Z extendĤ Verilog - Representation of Number Literals(cont.) Some Examples: reg v = 8 b1011 initial $displayb ("v signed =\t", v) //v =, MSBs filled with zeros reg w = 3 b1011 initial $displayb ("w signed =\t", w) //w =, bit 3 truncated then 0 filled //generates Modelsim compile warning (Redundant digits in numeric literal) //Runs without warning or errorĥ Verilog - Representation of Number Literals (cont.) Literal numbers may be declared as signed: 4shf 4 bit number (1111) interpreted as a signed 2s complement value Decimal value is -1. radix Radix of the number b or B : binary o or O : octal h or H : hex d or D : decimal default is decimalĢ Verilog - Representation of Number Literals(cont.) Possible values for value are dependent on the radix Format Prefix Legal characters binary b 01xXzZ? octal o 0-7xXzZ? decimal d 0-9 hexadecimal h 0-9a-fA-FxXzZ? The underscore is a separator used to improve readability e.g.: is easily read as 0x2AE5 The character x or X represents unknown The character z or Z represents high impedance The character? or? same as Z (high impedance) The character? is also don t care to synthesisģ Verilog - Representation of Number Literals(cont.) If prefix is preceded by a number, number defines the bit width If no prefix given, number is assumed to be 32 bits Verilog expands to fill given working from LSB to MSB. A separator, single quote, not a backtick signed Indicates if the value is signed. Barbossa) Numbers are represented as: value ( indicates optional part) size The number of binary bits the number is comprised of. In the O/P why is $realtime scaled to precision value of 100ns i.e 0.1us ? I expected that the real numbers be rounded to 1 decimal place so parameter d should have been scaled to 15.5us ,ĭelay of #1.1499 be scaled to 11.5us, delay of #1.1551 be scaled to 11.1 Verilog - Representation of Number Literals. I then tried a similar code from LRM Section 22.7 with the timescale and timeunit changed :: EDA_LINK (b) For `timescale 10 us / 100 ns, as 100ns is 0.1 us would the real numbers be rounded to 1 decimal place ?ĭoes the value specified in the timeunit and timeprecision i.e 10 and 100 in (b) contribute to how many decimal place the real number gets rounded to ? As 1ps is 0.001ns delays are rounded to 3 decimal places. (a) For `timescale 1 ns / 1 ps, Delays are rounded to real numbers with three decimal places-or precise to within one thousandth of a nanosecond-because the time_precision argument is “1 ps,” or one thousandth of a nanosecond. I have doubt related to " Delays are rounded to real numbers with n decimal places " LRM Section 22.7 :: " The time_precision argument specifies how delay values are rounded before being used in simulation " ![]() My recent threads have made me realize that I need to brush-up concepts of timeunit and timeprecision.
0 Comments
Leave a Reply. |