Advertisement
FSan

8 Cores

Jun 6th, 2024 (edited)
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.31 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL;
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5.  
  6. entity CPU is
  7.     Port ( CLK : in  STD_LOGIC;
  8.            RST : in  STD_LOGIC;
  9.            Instr : in  STD_LOGIC_VECTOR (7 downto 0);
  10.            Result : out  STD_LOGIC_VECTOR (7 downto 0));
  11. end CPU;
  12.  
  13. architecture Behavioral of CPU is
  14.     signal A, B : STD_LOGIC_VECTOR (7 downto 0);
  15.     signal ALU_Result : STD_LOGIC_VECTOR (7 downto 0);
  16.     signal ALU_Op : STD_LOGIC_VECTOR (2 downto 0);
  17. begin
  18.     process(CLK, RST)
  19.     begin
  20.         if RST = '1' then
  21.             A <= (others => '0');
  22.             B <= (others => '0');
  23.             ALU_Op <= "000";
  24.         elsif rising_edge(CLK) then
  25.             -- Simulando una operación simple
  26.             A <= Instr(7 downto 4);
  27.             B <= Instr(3 downto 0);
  28.             ALU_Op <= Instr(2 downto 0);
  29.         end if;
  30.     end process;
  31.  
  32.     -- ALU simple
  33.     process(ALU_Op, A, B)
  34.     begin
  35.         case ALU_Op is
  36.             when "000" => ALU_Result <= A + B;
  37.             when "001" => ALU_Result <= A - B;
  38.             when "010" => ALU_Result <= A and B;
  39.             when "011" => ALU_Result <= A or B;
  40.             when others => ALU_Result <= (others => '0');
  41.         end case;
  42.     end process;
  43.  
  44.     Result <= ALU_Result;
  45.  
  46. end Behavioral;
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement