Docsity

VHDL Logic Design Lab: Syntax and Operators, Lab Reports of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE-238 Logic Design – Lab
Syntax (Data type and operation)
* Words written using lower-case letters and possibly one or many hyphens, are used to denote a syntactical category, for example: entity-declaration. Reserved words
are written with bold char acters, for example: entity, constant.
* Every replacement rule contains a left hand side expression and a right hand side expression separated by the sign –›, which means ”looks as” or ”may be replaced
with”.
* |, a vertical line (the pipe sign) is used to separate many mutually exclusive alternatives. [], square brackets surround optional things that may occur once or not at
all. {}, braces surround optional things that may occur once, many times or not at all. (), parenthesis are used to clarify how and in which order a rule is evaluated.
Reserved words and characters surrounded by apostrophes, ‘ ’, are included ”as is” in the source code.
Type Possible values Operation(by priority) Example
INTEGER At least
-2147483647~2147483647
ABS **
* / MOD REM
+ - (sign)
+ -
= /= < <= > >=
REAL At least:
-1.0E38 ~ 1.0E38
ABS **
* /
+ - (sign)
+ -
= /= < <= > >=
TIME At least:
-2147483647 ~2147483647
(fs, ps, ns, us, ms, sec, min, hr)
ABS **
* /
+ - (sign)
+ -
= /= < <= > >=
BIT ‘0’,’1’ NOT
= /= < <= > >=
AND NAND OR NOR XOR
XNOR
BIT_VECT
OR
Unconstrained
array of BIT
NOT &
SLL* SRL* SLA* SRA*
ROL* ROR*
= /= < <= > >=
AND NAND OR NOR XOR
XNOR*
BOOLEAN FALSE, TRUE NOT
= /= < <= > >=
AND NAND OR NOR XOR
XNOR*
CHARACT
ER
128 characters in VHDL’87 [ISO 646-1983]
256 characters in VHDL’93 [ISO 8859-1 : 1987(E)]
STRING Unconstrained array of CHARACTER
architecture sample1 of consts is
signal A, B, Z : integer range 0 to 3;
constant A1: real :=0.1231;
constant PERIOD : time := 50 ns;
signal A2 : bit := ’1’;
signal A3, B3, Z3: bit_vector (1 downto 0);
constant A4: Boolean
:=FALSE;
constant A5: charater :=’c’;
constant A6: string := "This is a string";
begin
A <= 2;
A2 <= not A2 after PERIOD*2;
A3 <= "10";
B3<=” 11”
process(Z3,A3,B3)
begin
if Z3 = '1' then
Z 3<= A3;
else
Z3 <= B3;
end if;
end process;
end smaple1;
pf3

Partial preview of the text

Download VHDL Logic Design Lab: Syntax and Operators and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

ECE-238 Logic Design – Lab

Syntax (Data type and operation)

  • Words written using lower-case letters and possibly one or many hyphens, are used to denote a syntactical category, for example: entity-declaration. Reserved words are written with bold characters, for example: entity, constant.
  • Every replacement rule contains a left hand side expression and a right hand side expression separated by the sign –›, which means ”looks as” or ”may be replaced with”.
  • |, a vertical line (the pipe sign) is used to separate many mutually exclusive alternatives. [], square brackets surround optional things that may occur once or not at all. {}, braces surround optional things that may occur once, many times or not at all. (), parenthesis are used to clarify how and in which order a rule is evaluated. Reserved words and characters surrounded by apostrophes, ‘ ’, are included ”as is” in the source code.

Type Possible values Operation(by priority) Example INTEGER At least -2147483647~

ABS **

* / MOD REM

    • (sign)

= /= < <= > >= REAL At least: -1.0E38 ~ 1.0E

ABS **

    • (sign)

= /= < <= > >= TIME At least: -2147483647 ~ (fs, ps, ns, us, ms, sec, min, hr)

ABS **

    • (sign)

= /= < <= > >= BIT ‘0’,’1’ NOT = /= < <= > >= AND NAND OR NOR XOR XNOR BIT_VECT OR

Unconstrained array of BIT

NOT &

SLL* SRL* SLA* SRA*

ROL* ROR*

AND NAND OR NOR XOR

XNOR*

BOOLEAN FALSE, TRUE NOT

AND NAND OR NOR XOR

XNOR*

CHARACT

ER

128 characters in VHDL’87 [ISO 646-1983] 256 characters in VHDL’93 [ISO 8859-1 : 1987(E)] STRING Unconstrained array of CHARACTER

architecture sample1 of consts is signal A, B, Z : integer range 0 to 3; constant A1: real :=0.1231; constant PERIOD : time := 50 ns; signal A2 : bit := ’1’; signal A3, B3, Z3: bit_vector (1 downto 0); constant A4: Boolean :=FALSE; constant A5: charater :=’c’; constant A6: string := "This is a string"; begin A <= 2; A2 <= not A2 after PERIOD*2; A3 <= "10"; B3<=” 11” process(Z3,A3,B3) begin if Z3 = '1' then Z 3<= A3; else Z3 <= B3; end if; end process;

end smaple1;

Logical operators The logical operators and, or, nand, nor, xor and xnor are used to describe Boolean logic operations, or perform bit-wise operations, on bits or arrays of bits.

Operator Description Operand Types Result Types

and And Any Bit or Boolean type Same Type

or Or Any Bit or Boolean type Same Type

nand Not And Any Bit or Boolean type Same Type

nor Not Or Any Bit or Boolean type Same Type

xor Exclusive OR Any Bit or Boolean type Same Type

xnor Exclusive NOR Any Bit or Boolean type Same Type

Relational operators Relational operators are used to test the relative values of two scalar types. The result of a relational operation is always a Boolean true or false value.

Operator Description Operand Types Result Type

= Equality Any type Boolean /= Inequality Any type Boolean

< Less than Any scalar type or discrete array Boolean <= Less than or equal Any scalar type or discrete array Boolean

Greater than Any scalar type or discrete array Boolean

= Greater than or equal^ Any scalar type or discrete array^ Boolean

Adding operators The adding operators can be used to describe arithmetic functions or, in the case of array types, concatenation operations.

Operator Description Operand Types Result Type

  • Addition Any numeric type Same type
  • Subtraction Any numeric type Same type

& Concatenation Any numeric type Same type

& Concatenation^ Any array or element type^ Same array type

Multiplying operators The multiplying operators can be used to describe mathematical functions on numeric types.

Note: Synthesis tools vary in their support for multiplying operators.

Operator Description Operand Types Result Type

  • Multiplication Left: any integer or floating point type. Right: same type

Same as left

  • Multiplication Left: any physical type. Right: integer or real type.

Same as left

  • Multiplication^ Left: integer or real type. Right: any physical type.

Same as right