alucore_rtl.vhd
上传用户:sztwq510
上传日期:2007-04-20
资源大小:209k
文件大小:7k
源码类别:

VHDL/FPGA/Verilog

开发平台:

Matlab

  1. -------------------------------------------------------------------------------
  2. --                                                                           --
  3. --          X       X   XXXXXX    XXXXXX    XXXXXX    XXXXXX      X          --
  4. --          XX     XX  X      X  X      X  X      X  X           XX          --
  5. --          X X   X X  X         X      X  X      X  X          X X          --
  6. --          X  X X  X  X         X      X  X      X  X         X  X          --
  7. --          X   X   X  X          XXXXXX   X      X   XXXXXX      X          --
  8. --          X       X  X         X      X  X      X         X     X          --
  9. --          X       X  X         X      X  X      X         X     X          --
  10. --          X       X  X      X  X      X  X      X         X     X          --
  11. --          X       X   XXXXXX    XXXXXX    XXXXXX    XXXXXX      X          --
  12. --                                                                           --
  13. --                                                                           --
  14. --                       O R E G A N O   S Y S T E M S                       --
  15. --                                                                           --
  16. --                            Design & Consulting                            --
  17. --                                                                           --
  18. -------------------------------------------------------------------------------
  19. --                                                                           --
  20. --         Web:           http://www.oregano.at/                             --
  21. --                                                                           --
  22. --         Contact:       mc8051@oregano.at                                  --
  23. --                                                                           --
  24. -------------------------------------------------------------------------------
  25. --                                                                           --
  26. --  MC8051 - VHDL 8051 Microcontroller IP Core                               --
  27. --  Copyright (C) 2001 OREGANO SYSTEMS                                       --
  28. --                                                                           --
  29. --  This library is free software; you can redistribute it and/or            --
  30. --  modify it under the terms of the GNU Lesser General Public               --
  31. --  License as published by the Free Software Foundation; either             --
  32. --  version 2.1 of the License, or (at your option) any later version.       --
  33. --                                                                           --
  34. --  This library is distributed in the hope that it will be useful,          --
  35. --  but WITHOUT ANY WARRANTY; without even the implied warranty of           --
  36. --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        --
  37. --  Lesser General Public License for more details.                          --
  38. --                                                                           --
  39. --  Full details of the license can be found in the file LGPL.TXT.           --
  40. --                                                                           --
  41. --  You should have received a copy of the GNU Lesser General Public         --
  42. --  License along with this library; if not, write to the Free Software      --
  43. --  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  --
  44. --                                                                           --
  45. -------------------------------------------------------------------------------
  46. --
  47. --
  48. --         Author:                 Roland H鰈ler
  49. --
  50. --         Filename:               alucore_rtl.vhd
  51. --
  52. --         Date of Creation:       Mon Aug  9 12:14:48 1999
  53. --
  54. --         Version:                $Revision: 1.5 $
  55. --
  56. --         Date of Latest Version: $Date: 2002/01/07 12:17:44 $
  57. --
  58. --
  59. --         Description: This unit performs simple logical operations.
  60. --
  61. --
  62. --
  63. --
  64. -------------------------------------------------------------------------------
  65. architecture rtl of alucore is
  66.   constant LAND : std_logic_vector(3 downto 0) := "0011";
  67.   constant LOR  : std_logic_vector(3 downto 0) := "0101";
  68.   constant LXOR : std_logic_vector(3 downto 0) := "0110";
  69.   constant RL   : std_logic_vector(3 downto 0) := "0111";
  70.   constant RLC  : std_logic_vector(3 downto 0) := "1000";
  71.   constant RR   : std_logic_vector(3 downto 0) := "1001";
  72.   constant RRC  : std_logic_vector(3 downto 0) := "1010";
  73.   constant COMP : std_logic_vector(3 downto 0) := "1011";
  74.   constant INV  : std_logic_vector(3 downto 0) := "1100";
  75. begin                 -- architecture structural
  76.   p_alu: process (alu_cmd_i, op_a_i, op_b_i, cy_i)
  77.   begin
  78.   
  79.   case alu_cmd_i is
  80. -------------------------------------------------------------------------------
  81.     when LAND =>  -- op_a_i and op_b_i
  82.       result_o <= op_a_i and op_b_i;
  83.       cy_o <= cy_i;      
  84. -------------------------------------------------------------------------------
  85.     when LOR =>  -- op_a_i or op_b_i
  86.       result_o <= op_a_i or op_b_i;
  87.       cy_o <= cy_i;      
  88. -------------------------------------------------------------------------------
  89.     when LXOR =>  -- op_a_i xor op_b_i
  90.       result_o <= op_a_i xor op_b_i;
  91.       cy_o <= cy_i;      
  92. -------------------------------------------------------------------------------
  93.     when RL =>  -- rotate left op_a_i
  94.       if DWIDTH > 1 then
  95.         result_o(DWIDTH-1 downto 1) <= op_a_i(DWIDTH-2 downto 0);
  96. result_o(0) <= op_a_i(DWIDTH-1);
  97.       else
  98.         result_o <= op_a_i;
  99.       end if;
  100.       cy_o <= cy_i;      
  101. -------------------------------------------------------------------------------
  102.     when RLC =>  -- rotate left op_a_i with CY
  103.       if DWIDTH > 1 then
  104.         result_o(DWIDTH-1 downto 1) <= op_a_i(DWIDTH-2 downto 0);
  105. result_o(0) <= cy_i((DWIDTH-1)/4);
  106.       else
  107.         result_o(0) <= cy_i((DWIDTH-1)/4);
  108.       end if;
  109.       cy_o <= cy_i;      
  110.       cy_o((DWIDTH-1)/4) <= op_a_i(DWIDTH-1);      
  111. -------------------------------------------------------------------------------
  112.     when RR =>  -- rotate right op_a_i
  113.       if DWIDTH > 1 then
  114.         result_o(DWIDTH-2 downto 0) <= op_a_i(DWIDTH-1 downto 1);
  115. result_o(DWIDTH-1) <= op_a_i(0);
  116.       else
  117.         result_o <= op_a_i;
  118.       end if;
  119.       cy_o <= cy_i;      
  120. -------------------------------------------------------------------------------
  121.     when RRC =>  -- rotate right op_a_i with CY
  122.       if DWIDTH > 1 then
  123.         result_o(DWIDTH-2 downto 0) <= op_a_i(DWIDTH-1 downto 1);
  124. result_o(DWIDTH-1) <= cy_i((DWIDTH-1)/4);
  125.       else
  126.         result_o(0) <= cy_i((DWIDTH-1)/4);
  127.       end if;
  128.       cy_o <= cy_i;      
  129.       cy_o((DWIDTH-1)/4) <= op_a_i(0);      
  130. -------------------------------------------------------------------------------
  131.     when COMP =>  -- Compare op_a_i with op_b_i
  132.       if op_a_i = op_b_i then
  133.         result_o <= (others => '0');
  134.       else
  135.         result_o <= (others => '1');
  136.       end if;
  137.       cy_o <= cy_i;         
  138.       if op_a_i < op_b_i then
  139.         cy_o((DWIDTH-1)/4) <= '1';
  140.       else
  141.         cy_o((DWIDTH-1)/4) <= '0';          
  142.       end if;
  143. -------------------------------------------------------------------------------
  144.     when INV =>  -- invert op_a_i
  145.       result_o <= not(op_a_i);
  146.       cy_o <= cy_i;      
  147. -------------------------------------------------------------------------------
  148.     when others =>  -- turn unit off
  149.       result_o <= (others => '0');      
  150.       cy_o <= (others => '0');
  151. -------------------------------------------------------------------------------
  152.   end case;
  153.   
  154.  end process p_alu;
  155. end rtl;