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

Subversion Repositories potato

[/] [potato/] [trunk/] [src/] [pp_csr_alu.vhd] - Blame information for rev 3

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_csr.all;
10
 
11
--! @brief ALU used for calculating new values of control and status registers.
12
entity pp_csr_alu is
13
        port(
14
                x, y          : in  std_logic_vector(31 downto 0);
15
                result        : out std_logic_vector(31 downto 0);
16
                immediate     : in  std_logic_vector(4 downto 0);
17
                use_immediate : in  std_logic;
18
                write_mode    : in  csr_write_mode
19
        );
20
end entity pp_csr_alu;
21
 
22
architecture behaviour of pp_csr_alu is
23
        signal a, b : std_logic_vector(31 downto 0);
24
begin
25
 
26
        a <= x;
27
        b <= y when use_immediate = '0' else std_logic_vector(resize(unsigned(immediate), b'length));
28
 
29
        calculate: process(a, b, write_mode)
30
        begin
31
                case write_mode is
32
                        when CSR_WRITE_NONE =>
33
                                result <= a;
34
                        when CSR_WRITE_SET =>
35
                                result <= a or b;
36
                        when CSR_WRITE_CLEAR =>
37
                                result <= a and (not b);
38
                        when CSR_WRITE_REPLACE =>
39
                                result <= b;
40
                end case;
41
        end process calculate;
42
 
43
end architecture behaviour;

powered by: WebSVN 2.1.0

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