Hello, currently I am VHDL code for Control Unit (CU) for GCD Calculator. Here is my code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity CU is
port(clk, reset, start, Eq, Lt : in std_logic;
y : buffer std_logic;
CtrlVec : out std_logic_vector (6 downto 0);
done : out std_logic);
end CU;
architecture CU_arch of CU is
type state is (S0,S1);
signal PS, NS : std_logic;
begin
y <= PS; --- ERROR!!!
STATE_REG:
process(clk, reset) begin
if (reset = '1') then PS <= S0;
elsif (clk'event and clk = '0') then PS <= NS;
end if;
end process STATE_REG;
NS_LOGIC:
process (PS, start, Eq) begin
case PS is
when S0 => if start = '1' then NS <= S1; else NS <= S0; end if;
when S1 => if Eq = '1' then NS <= S0; else NS <= S1; end if;
end case;
end process NS_LOGIC;
OUTPUT_LOGIC:
process (PS, start, Eq, Lt) begin
CtrlVec <= (others => '0'); done <= 0;
case PS is
when S0 => if start = '1' then CtrlVec <= "0111100"; end if;
when S1 => if Eq = '1' then done <= '1'; CtrlVec <= "1000000";
elsif Lt = '1' then CtrlVec <= "0000100";
else CtrlVec <= "0010011";
end if;
end case;
end process OUTPUT_LOGIC;
end CU_arch;
My problem is: How to make the PS as output? I have to display the output y and y should be PS. Thanks!
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity CU is
port(clk, reset, start, Eq, Lt : in std_logic;
y : buffer std_logic;
CtrlVec : out std_logic_vector (6 downto 0);
done : out std_logic);
end CU;
architecture CU_arch of CU is
type state is (S0,S1);
signal PS, NS : std_logic;
begin
y <= PS; --- ERROR!!!
STATE_REG:
process(clk, reset) begin
if (reset = '1') then PS <= S0;
elsif (clk'event and clk = '0') then PS <= NS;
end if;
end process STATE_REG;
NS_LOGIC:
process (PS, start, Eq) begin
case PS is
when S0 => if start = '1' then NS <= S1; else NS <= S0; end if;
when S1 => if Eq = '1' then NS <= S0; else NS <= S1; end if;
end case;
end process NS_LOGIC;
OUTPUT_LOGIC:
process (PS, start, Eq, Lt) begin
CtrlVec <= (others => '0'); done <= 0;
case PS is
when S0 => if start = '1' then CtrlVec <= "0111100"; end if;
when S1 => if Eq = '1' then done <= '1'; CtrlVec <= "1000000";
elsif Lt = '1' then CtrlVec <= "0000100";
else CtrlVec <= "0010011";
end if;
end case;
end process OUTPUT_LOGIC;
end CU_arch;
My problem is: How to make the PS as output? I have to display the output y and y should be PS. Thanks!