21EC32 Mod5
21EC32 Mod5
21EC32 Mod5
OBJECTIVES
entity half_add is
port (I1, I2 : in bit; O1, O2 : out bit);
end half_add ;
architecture behave_ex of half_add is
Execution of SA statements
begin
Inside process is
process (I1, I2) Sequential calculation
begin And then assignment
O1 <= I1 xor I2 after 10 ns ; -- statement 1
O2 <= I1 and I2 after 10 ns; -- statement 2
end process;
end behave_ex;
I1 I1
I2 I2
10 ns 10 ns
O1 O1
O2 O2
Varb: process(t1)
Signl: process(t1) variable temp1, temp2: bit;
begin begin
st1: S1<= t1; st3: temp1 := t1;
st2: S2 <= not S1; st4: temp2 := not temp1;
end process; st5: S1 <= temp1;
st6: S2 <= temp2;
end process ;
t1
t1
S1
temp1
S2
temp2
S1
S2
Another example
If (clk = ‘1’ and cs =‘1’) then
b) Verilog
if ( clk ==1)
Begin
temp = s1;
end
Another example
If (clk == 1 & cs ==1)
begin
•To execute Signal we need two phases ( calculate and assign), Variable is
the same as in software languages such as C only one phase to execute.
Example 3.6
D Latch using
Signals. The
Wave form is
Wrong
0 1
x1
3-bit counter
clr
clk
♂
♀ A B O
A AA AB AO
B AB BB BO
O AO BO OO
♂
♀ A B O
A A AB A
B AB B B
O A B O
Listing 3.11
3.4.4.1 For-Loop
a) VHDL
for i in 0 to 2 loop
if temp(i) = '1' then
result := result + 2**i;
end if;
end loop;
statement1; statement2;....
b) Verilog
for (i=0; i<=2;i=i+1)
begin
if (temp[i] ==1)
begin
result = result + 2**i;
end
end
a) VHDL
while (i < x)loop
i := i + 1;
z := i*z;
end loop;
b) Verilog
while(i < x)
begin
i = i +1;
z = i*z;
end
Listing 3.13
VHDL Verilog
process always
variable ------
------- reg
MOD %
Signed signed
Srl 1 >> 1
integer integer