 Hello and welcome to the series of video lectures on the subject digital techniques for secondary IT students. I am Dr. Srisail Sharad Gajbar and in this video lecture we are going to study syntax and lexical conventions that are used in virilog-hdl language. At the end of this session, you will be able to write syntax of virilog-hdl language. You will also be able to describe lexical conventions of virilog-hdl language. Like any other programming language, virilog-hdl is made up of statements, group of statements, keywords, etc. For example, a sample module definition is given. One can see that it consists of five lines of statements all terminated with the semicolon, having keywords, identifiers, and one assignment expression. Let us see properties of virilog statements. Similar to c-programming language, they are composed of tokens. Statements within the group are terminated with semicolon. The basic lexical conventions used by virilog-hdl are similar to those in c-programming language. Virilog contains a stream of tokens. Tokens are nothing but the smallest individual element of a program. Steps of tokens used in virilog are namely white space, comments, operators, constants, identifiers, keywords, and there is one more category called system tasks and functions. White space is any sequence of space, tab, new line, or form field. White space separates tokens and may be arbitrarily long between tokens. White space is ignored by virilog except when it separates tokens. White space is not ignored in strings. Comments can be inserted in the code for readability and documentation. There are two ways to write comments. A one line comment starts with double slash, virilog skips from that point to the end of line. A multiple line comment starts with slash star and ends with star slash. Multiple line comments cannot be nested. Examples for single line and multi-line comments are given. And one can see that their syntax is similar to syntax of c-language comments. Examples are of three types, unary, binary, and ternary. Unary operators precede the operand. For example, last example in the shown table that is bitwise negation operator is a unary operator. Binary operators appear between two operands. For example, logical or logical and are binary operators. Most of the operands in this table are binary operators. In this table also, most of the operators are binary operators. Alongside unary and binary operators, there are ternary operators also. Ternary operators have two separate operators that separate three operands. For example, last row of the table shows a ternary operator, namely conditional operator. It has two separate operators, question mark and colon, which separates three operands. Binary operators find their use in behavioral modeling, informing arithmetic, assignment, and conditional expressions. Varylog uses three types of constants, namely integer constants, real constants, and string constants. Integer constants are specified with three components. The first is size, which is an unsigned decimal number. The next component is base or a radix specifier. It can be one of the four types, dash D for decimal, dash B for binary, dash H for hexadecimal, dash O for octal number. Value is an unsigned number, which consists of digits appropriate for the specified radix. In the value part, X and Z are also allowed. Here X is nothing but unspecified value and Z is nothing but high impedance value. Examples are given. First example indicates 1-bit binary number with value 1. Second example declares an 8-bit binary number with value part as binary equivalent of hexadecimal number 81. In the third example, 12-bit binary number is declared, where all the bits are X, that is, have unknown value. First example declares 16-bit number with value part as binary equivalent of decimal number 5. Last example declares 3-bit binary number with value part as 1xz, that is, the LSB bit is Z, the middle bit is X, and the most significant bit is 1. An integer constant can be classified as either sized or unsized, depending on number of bits used in the representation. While it can be classified as either signed or unsigned depending on their sign. If size-specifier is present, the constant is sized, otherwise it is unsized. For example, in case of 16-d5, the size-specifier is present, while in case of o7773, the size-specifier is not provided and hence it is unsized. Unsized numbers have a default size of 32-bits. If both size and radix are omitted, the constant is a signed number and is represented in two's complement form. For example, 1 to 3, if this is the specified number, now in this case both size as well as radix is absent, so this number will be treated as a signed number and it will be represented as a two's complement binary number. The constant is an unsigned positive number if either of size or radix or both are present. For example, 16-d5 and o7773 are both unsigned numbers. Now let us see padding and truncation that is used by the verilog for storing the integer constants. If number of bits are more in the value part than the given size, then the higher order bits are truncated. For example, 7-h8f is equivalent to 7-h0f. The reason here is that the given number is hexadecimal and its value part given is 8f, which requires total number of 8-bits in binary representation. However, the size specified here is 7, due to which higher order bit is truncated, thus its value becomes 0f. If number of bits are less in the value part than the given size, then number is padded onto the left with zeroes. For example, in case of 12-h3, it is equivalent to the number specified onto the right. Here, the value part is 3, which requires only 4-bits. However, the size specified is 12, due to which the remaining 8-bits are padded with zeroes to the left. If the leftmost digit in the value part is x or z, then the number is padded with x or z. For example, in case of 12-0z37, it is equivalent to the number specified. Here, the octal number with the value z37 is specified, which is in binary, requires 9-bits of representation. However, the size specified is 12. The remaining 3-bits have to be padded and according to the mentioned rule, since the leftmost number is z, the remaining bits are also padded with the value z. Now, pause the video for 2 minutes and write down the answer of the given question. I hope you have written the answer and it is shown onto your screen. In the first example, the number specified is 12-h3x. Here, the value part contains the value 3x, which requires 8-bits in binary, since radix specified here is hexadecimal. The remaining higher 4-bits will be padded with the zero value. In the second example, 12-bit binary number is specified with the value part as x. Thus, all 12-bits will be initialized with the value x. Real numbers are represented using standard double precision format. Constants can be written in decimal notation or scientific notation. If a decimal point is present in the number, there must be at least one digit on either side of it. When real numbers are converted to integers, they are rounded, not truncated. Numbers which end in 0.5 are rounded away from the zero. For example, 1.5 rounds to 2 and minus 1.5 rounds to minus 2. The examples of real constants are given here. The first three examples use decimal notation, while the rest examples use scientific notation. In decimal notation, integer and fractional part is separated by decimal point. In scientific notation, the representation uses mantissa followed by exponent notation followed by exponent value. For exponent notation, capital E or small e can be used. The mantissa can be a real number. However, the exponent part is always integer and may be positive or negative. These are the references. Thank you very much.