I have some error that cannot fix:
1. set on less than
2. cannot assign A,B for test purpose
Here is my code>>>>
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity ALU is
port (
A, B: in BIT_VECTOR(3 downto 0);
OP: in BIT_VECTOR(2 downto 0);
CLK: in BIT;
F: buffer BIT_VECTOR(3 downto 0));
end ALU;
architecture BEHAVIORAL of ALU is
begin
process(CLK,OP)
A := "0101"; -- Assign A = 5 for test purpose
B := "0111"; -- B = 7
begin
if (CLK'EVENT and CLK = '1') then
case OP is
when "000" => F <= (A + B); -- Add
when "001" => F <= A + (NOT B); -- Sub
when "010" => F <= A and B; -- And
when "011" => F <= A or B; -- Or
when "100" => F <= A sll 1; -- Shift left logical
when "101" => F <= A srl 1; -- Shift right logical
when "111" => F <= "0001" when (A < B) else "000"; -- set on less than
when others => F <= F;
end case;
end if;
end process;
end BEHAVIORAL;
1. set on less than
2. cannot assign A,B for test purpose
Here is my code>>>>
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity ALU is
port (
A, B: in BIT_VECTOR(3 downto 0);
OP: in BIT_VECTOR(2 downto 0);
CLK: in BIT;
F: buffer BIT_VECTOR(3 downto 0));
end ALU;
architecture BEHAVIORAL of ALU is
begin
process(CLK,OP)
A := "0101"; -- Assign A = 5 for test purpose
B := "0111"; -- B = 7
begin
if (CLK'EVENT and CLK = '1') then
case OP is
when "000" => F <= (A + B); -- Add
when "001" => F <= A + (NOT B); -- Sub
when "010" => F <= A and B; -- And
when "011" => F <= A or B; -- Or
when "100" => F <= A sll 1; -- Shift left logical
when "101" => F <= A srl 1; -- Shift right logical
when "111" => F <= "0001" when (A < B) else "000"; -- set on less than
when others => F <= F;
end case;
end if;
end process;
end BEHAVIORAL;