Professional Documents
Culture Documents
Dataflow Modelling
1. Write VHDL code for BCD to 7 Segment Converter using WITH SELECTStatement in
dataflow modeling.
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity seg7_driver is
port(
bcd : in STD_LOGIC_VECTOR(3 downto 0);
seg7 : out STD_LOGIC_VECTOR(6 downto 0)
);
end seg7_driver;
end seg7_driver_arc;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity SUBTRACTOR_SOURCE is
Port ( A, B, C : in STD_LOGIC;
H_DIFFERENCE, F_DIFFERENCE, H_BORROW, F_BORROW : out STD_LOGIC);
end SUBTRACTOR_SOURCE;
Begin
---full subtractor
F_DIFFERENCE <= A xor B xor C;
F_BORROW <= ((not A) and (B or C)) or (B and C);
end dataflow;
Behavioural modelling
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity encoder1 is
port(
a : in STD_LOGIC_VECTOR(3 downto 0);
b : out STD_LOGIC_VECTOR(1 downto 0)
);
end encoder1;
process(a)
begin
if (a="1000") then
b <= "00";
elsif (a="0100") then
b <= "01";
elsif (a="0010") then
b <= "10";
elsif (a="0001") then
b <= "11";
else
b <= "ZZ";
end if;
end process;
end bhv;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity JK_FF is
port( J, K, clk, rst : in std_logic;
Q, Qbar : out std_logic);
end JK_FF;
end process;
end behavioral;