OSDN Git Service

adc renamed.
[motonesfpga/motonesfpga.git] / simulation / cpu / alu / alu.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_unsigned.all;
4
5 entity alu is 
6     port (  a, b, m     : in std_logic_vector (7 downto 0);
7             o           : out std_logic_vector (7 downto 0);
8             cin         : in std_logic;
9             cout        : out std_logic;
10             n, v, z     :   out std_logic;
11             reset       :   out std_logic
12         );
13 end alu;
14
15 architecture rtl of alu is
16     component alu_adc
17         port (  a, b    : in std_logic_vector (7 downto 0);
18                 sum       : out std_logic_vector (7 downto 0);
19                 cin         : in std_logic;
20                 cout        : out std_logic;
21                 n, v, z : out std_logic
22                 );
23     end component;
24     component alu_and
25         port (  a, b    : in std_logic_vector (7 downto 0);
26                 and_o     : out std_logic_vector (7 downto 0);
27                 n, z    : out std_logic
28                 );
29     end component;
30     signal adc_o : std_logic_vector (7 downto 0);
31     signal adc_cout, adc_n, adc_v, adc_z : std_logic;
32     signal and_o : std_logic_vector (7 downto 0);
33     signal and_n, and_z : std_logic;
34 begin
35     adc_port : alu_adc port map (a, b, adc_o, cin, adc_cout, adc_n, adc_v, adc_z);
36     and_port : alu_and port map (a, b, and_o, and_n, and_z);
37
38     p : process (a, b, m, cin, adc_o, and_o)
39     begin
40     -- m is form of  "aaabbbcc"
41     if m(1 downto 0) = "01" then
42     -- case cc == 01
43         case m(7 downto 5) is
44             when "011" =>
45               ---case adc.
46                 o <= adc_o;
47                 n <= adc_n;
48                 v <= adc_v;
49                 z <= adc_z;
50                 cout <= adc_cout;
51             when "001" =>
52               ---case and.
53                 o <= and_o;
54                 n <= and_n;
55                 z <= and_z;
56             when others =>
57                 reset <= '1';
58         end case;
59     elsif m(1 downto 0) = "10" then
60     -- case cc == 10
61     elsif m(1 downto 0) = "00" then
62     -- case cc == 00
63     else
64         reset <= '1';
65     end if;
66
67     end process;
68
69 end rtl;
70