Hardware Description Language1
Hardware Description Language1
• Relational operator
< less than
> greater than
<= less than or equal
>= greater than or equal
• Equality operator
a === b a equal to b
· a !== b a not equal to b
· a == b a equal to b
· a != b a not equal to b
• Logical operator
! -logical negation
&& - logical and
|| -logical or
• Bitwise operator
~ negation
& and
| inclusive or
^ exclusive or
^~ or ~^ exclusive nor (equivalence)
• Reduction operator
& and
~& nand
| or
~| nor
^ xor
^~ or ~^ xnor
– Shift opearator
– << left shift
– · >> right shift
Loop statement
• Forever Statement
Continuously executes a statement
Syntax
Forever
Procedural_ statement
Example
Initial
Begin
Clock=0;
#5 forever
# 10 clock=~ clock;
end
•Repeat loop
Similar to C for-statement
for (initial_assignment; condition; step_assignment)
Procedural statement
Example
begin :init_mem
reg [7:0] tempi;
for (tempi = 0; tempi < memsize; tempi = tempi + 1)
memory[tempi] = 0;
end
Procedural statement
Initial Statement
· Activated at the beginning of simulation
· Executed once
initial
begin
areg = 0; // initialize a register
for (index = 0; index < size; index = index + 1)
memory[index] = 0; // initialize a memory
end
initial
begin
inputs = 6'b000000;
#10 inputs = 6'b001011;
#10 inputs = 6'b110001;
end
Always Statement
· Activated at the beginning of simulation
· Repeats continuously throughout the whole simulation run
always
#100 clock = ~clock // creates a clock signal with #200 period
time
always
@(posedge clock) // the block below starts execution at
posedge of clock
begin
#10 a = 0; // #10 after the posedge of clock, a becomes 0
#20 b = 1; // #30 after the posedge of clock, b becomes 1
#40 b = 0; // #70 after the posedge of clock, b becomes 1
end