Module 3 (Mixed Language Description)
Module 3 (Mixed Language Description)
MIXED-LANGUAGE DESCRIPTION
Facts
• To write HDL code in mixed language, the simulator used with the HDL
package should be able to handle a mixed-language environment.
• If you are writing Verilog code, you can invoke (import) a VHDL entity.
• By instantiating a VHDL package in a Verilog module, the contents of this
package are made visible to the module.
• If it could not find one, the simulator looks in the VHDL entities.
When the simulator finds an entity with the name VHD_enty, it
binds this entity to the Verilog module.
• The VHDL entity calculates the outputs O1 and O2; these two
outputs are passed to the Verilog outputs c and d, respectively.
• The inputs y and cin are passed to the input ports of HA, a and
b.
• A full adder is constructed from two half adders, as was done in previous
module. The logic diagram is shown below.
• The code of the half adder is written in verilog.
• A VHDL module is written to describe a full adder using the verilog code
of the half adder.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Full_Adder is
port (x, y, cin: in std_logic; sum, carry: out std_logic);
end Full_Adder;
architecture Full_MXD of Full_Adder is
component HA_verilog
port (I1, I2: in std_logic; O1, O2 : std_logic);
end component;
component and2
port (I1, I2 : in std_logic; O1 : out std_logic);
end component;
signal s0, c0, c1: std_logic;
begin
HA1 : HA_verilog port map (y, cin, s0, c0);
HA2 : HA_verilog port map (x, s0, sum, c1);
A1 : and2 port map (co, c1, carry);
end Full_MXD;
• The ports of the component should also be the same as those of the
Verilog module.
• Below shows the mixed language description of the flip-flop. The JK flip-
flop is declared as a component with the statement:
• A Verilog module can only invoke a VHDL entity. It cannot invoke any
other construct in the VHDL module such as a procedure or function.