 
     
    
        
         
     
    
        
        
                        
            
                
                
                
                
            
            
            
                        
                
                
                    URL
                    https://opencores.org/ocsvn/potato/potato/trunk
                
             
            
            
[/] [potato/] [trunk/] [src/] [pp_alu.vhd] - Blame information for rev 55
Go to most recent revision |
Details |
Compare with Previous |
View Log
   
      
      | Line No. | Rev | Author | Line | 
   
   
      
         | 1 | 2 | skordal | -- The Potato Processor - A simple processor for FPGAs
 | 
      
         | 2 |  |  | -- (c) Kristian Klomsten Skordal 2014 <kristian.skordal@wafflemail.net>
 | 
      
         | 3 | 3 | skordal | -- Report bugs and issues on <http://opencores.org/project,potato,bugtracker>
 | 
      
         | 4 | 2 | skordal |  
 | 
      
         | 5 |  |  | library ieee;
 | 
      
         | 6 |  |  | use ieee.std_logic_1164.all;
 | 
      
         | 7 |  |  | use ieee.numeric_std.all;
 | 
      
         | 8 |  |  |  
 | 
      
         | 9 |  |  | use work.pp_types.all;
 | 
      
         | 10 |  |  |  
 | 
      
         | 11 |  |  | entity pp_alu is
 | 
      
         | 12 |  |  |         port(
 | 
      
         | 13 |  |  |                 x, y      : in  std_logic_vector(31 downto 0);
 | 
      
         | 14 |  |  |                 result    : out std_logic_vector(31 downto 0);
 | 
      
         | 15 |  |  |                 operation : in alu_operation
 | 
      
         | 16 |  |  |         );
 | 
      
         | 17 |  |  | end entity pp_alu;
 | 
      
         | 18 |  |  |  
 | 
      
         | 19 |  |  | architecture behaviour of pp_alu is
 | 
      
         | 20 |  |  | begin
 | 
      
         | 21 |  |  |  
 | 
      
         | 22 |  |  |         calculate: process(operation, x, y)
 | 
      
         | 23 |  |  |         begin
 | 
      
         | 24 |  |  |                 case operation is
 | 
      
         | 25 |  |  |                         when ALU_AND =>
 | 
      
         | 26 |  |  |                                 result <= x and y;
 | 
      
         | 27 |  |  |                         when ALU_OR =>
 | 
      
         | 28 |  |  |                                 result <= x or y;
 | 
      
         | 29 |  |  |                         when ALU_XOR =>
 | 
      
         | 30 |  |  |                                 result <= x xor y;
 | 
      
         | 31 |  |  |                         when ALU_SLT =>
 | 
      
         | 32 |  |  |                                 if signed(x) < signed(y) then
 | 
      
         | 33 |  |  |                                         result <= (0 => '1', others => '0');
 | 
      
         | 34 |  |  |                                 else
 | 
      
         | 35 |  |  |                                         result <= (others => '0');
 | 
      
         | 36 |  |  |                                 end if;
 | 
      
         | 37 |  |  |                         when ALU_SLTU =>
 | 
      
         | 38 |  |  |                                 if unsigned(x) < unsigned(y) then
 | 
      
         | 39 |  |  |                                         result <= (0 => '1', others => '0');
 | 
      
         | 40 |  |  |                                 else
 | 
      
         | 41 |  |  |                                         result <= (others => '0');
 | 
      
         | 42 |  |  |                                 end if;
 | 
      
         | 43 |  |  |                         when ALU_ADD =>
 | 
      
         | 44 |  |  |                                 result <= std_logic_vector(unsigned(x) + unsigned(y));
 | 
      
         | 45 |  |  |                         when ALU_SUB =>
 | 
      
         | 46 |  |  |                                 result <= std_logic_vector(unsigned(x) - unsigned(y));
 | 
      
         | 47 |  |  |                         when ALU_SRL =>
 | 
      
         | 48 |  |  |                                 result <= std_logic_vector(shift_right(unsigned(x), to_integer(unsigned(y(4 downto 0)))));
 | 
      
         | 49 |  |  |                         when ALU_SLL =>
 | 
      
         | 50 |  |  |                                 result <= std_logic_vector(shift_left(unsigned(x), to_integer(unsigned(y(4 downto 0)))));
 | 
      
         | 51 |  |  |                         when ALU_SRA =>
 | 
      
         | 52 |  |  |                                 result <= std_logic_vector(shift_right(signed(x), to_integer(unsigned(y(4 downto 0)))));
 | 
      
         | 53 |  |  |                         when others =>
 | 
      
         | 54 |  |  |                                 result <= (others => '0');
 | 
      
         | 55 |  |  |                 end case;
 | 
      
         | 56 |  |  |         end process calculate;
 | 
      
         | 57 |  |  |  
 | 
      
         | 58 |  |  | end architecture behaviour;
 | 
   
 
 
         
                
        
            
            
        
        
             
    
        © copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.