OpenCores
URL https://opencores.org/ocsvn/potato/potato/trunk

Subversion Repositories potato

[/] [potato/] [trunk/] [src/] [pp_comparator.vhd] - Diff between revs 2 and 3

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 3
-- The Potato Processor - A simple processor for FPGAs
-- The Potato Processor - A simple processor for FPGAs
-- (c) Kristian Klomsten Skordal 2014 <kristian.skordal@wafflemail.net>
-- (c) Kristian Klomsten Skordal 2014 <kristian.skordal@wafflemail.net>
-- Report bugs and issues on <https://github.com/skordal/potato/issues>
-- Report bugs and issues on <http://opencores.org/project,potato,bugtracker>
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.numeric_std.all;
 
 
use work.pp_utilities.all;
use work.pp_utilities.all;
 
 
--! @brief Component for comparing two registers in the ID stage whens branching.
--! @brief Component for comparing two registers in the ID stage whens branching.
entity pp_comparator is
entity pp_comparator is
        port(
        port(
                funct3   : in  std_logic_vector(14 downto 12);
                funct3   : in  std_logic_vector(14 downto 12);
                rs1, rs2 : in  std_logic_vector(31 downto 0);
                rs1, rs2 : in  std_logic_vector(31 downto 0);
                result   : out std_logic --! Result of the comparison.
                result   : out std_logic --! Result of the comparison.
        );
        );
end entity pp_comparator;
end entity pp_comparator;
 
 
architecture behaviour of pp_comparator is
architecture behaviour of pp_comparator is
begin
begin
 
 
        compare: process(funct3, rs1, rs2)
        compare: process(funct3, rs1, rs2)
        begin
        begin
                case funct3 is
                case funct3 is
                        when b"000" => -- EQ
                        when b"000" => -- EQ
                                result <= to_std_logic(rs1 = rs2);
                                result <= to_std_logic(rs1 = rs2);
                        when b"001" => -- NE
                        when b"001" => -- NE
                                result <= to_std_logic(rs1 /= rs2);
                                result <= to_std_logic(rs1 /= rs2);
                        when b"100" => -- LT
                        when b"100" => -- LT
                                result <= to_std_logic(signed(rs1) < signed(rs2));
                                result <= to_std_logic(signed(rs1) < signed(rs2));
                        when b"101" => -- GE
                        when b"101" => -- GE
                                result <= to_std_logic(signed(rs1) >= signed(rs2));
                                result <= to_std_logic(signed(rs1) >= signed(rs2));
                        when b"110" => -- LTU
                        when b"110" => -- LTU
                                result <= to_std_logic(unsigned(rs1) < unsigned(rs2));
                                result <= to_std_logic(unsigned(rs1) < unsigned(rs2));
                        when b"111" => -- GEU
                        when b"111" => -- GEU
                                result <= to_std_logic(unsigned(rs1) >= unsigned(rs2));
                                result <= to_std_logic(unsigned(rs1) >= unsigned(rs2));
                        when others =>
                        when others =>
                                result <= '0';
                                result <= '0';
                end case;
                end case;
        end process compare;
        end process compare;
 
 
end architecture behaviour;
end architecture behaviour;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.