ok , I tried to keep it simple so here is the code:
the code for for the pseudo random nums.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity random_gen is
generic ( width : integer := 32 );
port (
clk : in std_logic;
random_num : out std_logic_vector (width-1 downto 0) --output vector
);
end random_gen;
architecture Behavioral of random_gen is
begin
process(clk)
variable rand_temp : std_logic_vector(width-1 downto 0):=(width-1 => '1',others => '0');
variable temp : std_logic := '0';
begin
if(rising_edge(clk)) then
temp := rand_temp(width-1) xor rand_temp(width-2);
rand_temp(width-1 downto 1) := rand_temp(width-2 downto 0);
rand_temp(0) := temp;
end if;
random_num <= rand_temp;
end process;
end Behavioral;
the code for the ALU :
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity ALU_32 is
port( A: in STD_LOGIC_VECTOR (31 downto 0);
B: in STD_LOGIC_VECTOR (31 downto 0);
CHOICE: in STD_LOGIC_VECTOR (2 downto 0);
OUTPUT: out STD_LOGIC_VECTOR (31 downto 0));
end alu_32;
architecture Behavioral of ALU_32 is
begin
process (choice)
begin
case choice is
when "000" => output (31 downto 0) <= a+b ;
when "001" => output (31 downto 0) <= a-b ;
when "010" => output (31 downto 0) <= not a ;
when "011" => output (31 downto 0) <= a xor b ;
when "100" => output (31 downto 0) <= a and b ;
when "101" => output (31 downto 0) <= a or b ;
when "110" => output (31 downto 0) <= a nand b;
when "111" => output (31 downto 0) <= a nor b;
when others => null;
end case;
end process;
end Behavioral;
the other component is just a simple comparator that compares the output of 2 ALU's that get the same input , when they are not equal it raises a flag.
this flag is the output of the module.
if you have some other good idea how to implement such a thing i'll be happy to hear since I'm not experienced and beside this great forum I don't really have anything to consult with.
thanks, Yaniv