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

Subversion Repositories ratpack

[/] [ratpack/] [trunk/] [rtl/] [vhdl/] [ratalu.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 kavi
library IEEE;
2
use IEEE.std_logic_1164.all;
3
use IEEE.std_logic_unsigned.all;
4
use WORK.ratpack.all;
5
 
6
entity ratalu is
7
  port (
8
    a   : in  rational;
9
    b   : in  rational;
10
    sel : in  std_logic_vector(4 downto 0);
11
    y   : out rational
12
  );
13
end ratalu;
14
 
15
architecture rtl of ratalu is
16
  signal temp : rational;
17
  constant OP_ADD : std_logic_vector(4 downto 0) := "00000";
18
  constant OP_SUB : std_logic_vector(4 downto 0) := "00001";
19
  constant OP_MUL : std_logic_vector(4 downto 0) := "00010";
20
  constant OP_DIV : std_logic_vector(4 downto 0) := "00011";
21
  constant OP_ABS : std_logic_vector(4 downto 0) := "00100";
22
  constant OP_MAX : std_logic_vector(4 downto 0) := "00101";
23
  constant OP_MIN : std_logic_vector(4 downto 0) := "00110";
24
  constant OP_CGT : std_logic_vector(4 downto 0) := "00111";
25
  constant OP_CLT : std_logic_vector(4 downto 0) := "01000";
26
  constant OP_CGE : std_logic_vector(4 downto 0) := "01001";
27
  constant OP_CLE : std_logic_vector(4 downto 0) := "01010";
28
  constant OP_CEQ : std_logic_vector(4 downto 0) := "01011";
29
  constant OP_CNE : std_logic_vector(4 downto 0) := "01100";
30
  constant OP_MED : std_logic_vector(4 downto 0) := "01101";
31
begin
32
 process (a, b, sel)
33
  begin
34
    case sel is
35
      when OP_ADD => temp <= a + b;
36
      when OP_SUB => temp <= a - b;
37
      when OP_MUL => temp <= a * b;
38
      when OP_DIV => temp <= a / b;
39
      when OP_ABS => temp <= a abs b;
40
      when OP_MAX => temp <= a max b;
41
      when OP_MIN => temp <= a min b;
42
      when OP_CGT =>
43
        if (a > b) then
44
          temp <= RAT_ONE;
45
        else
46
          temp <= RAT_ZERO;
47
        end if;
48
      when OP_CLT =>
49
        if (a < b) then
50
          temp <= RAT_ONE;
51
        else
52
          temp <= RAT_ZERO;
53
        end if;
54
      when OP_CGE =>
55
        if (a >= b) then
56
          temp <= RAT_ONE;
57
        else
58
          temp <= RAT_ZERO;
59
        end if;
60
      when OP_CLE =>
61
        if (a <= b) then
62
          temp <= RAT_ONE;
63
        else
64
          temp <= RAT_ZERO;
65
        end if;
66
      when OP_CEQ =>
67
        if (a = b) then
68
          temp <= RAT_ONE;
69
        else
70
          temp <= RAT_ZERO;
71
        end if;
72
      when OP_CNE =>
73
        if (a /= b) then
74
          temp <= RAT_ONE;
75
        else
76
          temp <= RAT_ZERO;
77
        end if;
78
      when OP_MED => temp <= mediant(a, b);
79
      when others => temp <= RAT_ZERO;
80
    end case;
81
  end process;
82
  y <= temp;
83
end rtl;

powered by: WebSVN 2.1.0

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