Alu Arithmetic
Alu Arithmetic
ALU-LOGIC
ALU VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity alu is
port(a,b: in std_logic_vector(7 downto 0);
sel : in std_logic_vector(3 downto 0);
cin: in std_logic;
y : out std_logic_vector(7 downto 0));
end alu;
library ieee;
use ieee.std_logic_1164.all;
entity moore_fsm is
port(a, clk : in bit;
z : out std_logic);
end moore_fsm;
begin
process(clk)
begin
library ieee;
use ieee.std_logic_1164.all;
entity mealy_fsm is
port(a, clk: in bit; z: out bit);
end mealy_fsm;
begin
seq_part:process(clk)
begin
if clk ='0' then
p_state <= n_state;
end if;
end process seq_part;
comb_part:process(p_state,a)
begin
case p_state is
when s0=>
if a='1' then
z<='1';n_state<=s3;
else
z<='0';
end if;
when s1=>
if a='1' then
z<='0';n_state<=s0;
else
z<='1';
end if;
when s2=>
if a='0' then
z<='0';
else
z<='1';n_state<=s1;
end if;
when s3=>
if a='0' then
z<='0';n_state<=s2;
else
z<='0';n_state<=s1;
end if;
end case;
end process comb_part;
end mealy_arch;