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

Subversion Repositories plasma_fpu

[/] [plasma_fpu/] [trunk/] [src/] [fpu/] [plasma_fpu_comparator.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 __alexs__
-- --------------------------------------------------------------------------
2
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<
3
-- --------------------------------------------------------------------------
4
-- TITLE:       Plasma FPU comparator
5
-- AUTHORS:     Maximilian Reuter (maximilian.reuter@fs-etit.de)
6
--              Alex Schoenberger (Alex.Schoenberger@ies.tu-darmstadt.de)
7
-- COMMENT:     This project is based on Plasma CPU core by Steve Rhoads
8
--
9
-- www.ies.tu-darmstadt.de
10
-- TU Darmstadt
11
-- Institute for Integrated Systems
12
-- Merckstr. 25
13
-- 
14
-- 64283 Darmstadt - GERMANY
15
-- --------------------------------------------------------------------------
16
-- PROJECT:       Plasma CPU core with FPU
17
-- FILENAME:      plasma_fpu_comparator.vhd
18
-- --------------------------------------------------------------------------
19
-- COPYRIGHT: 
20
--  This project is distributed by GPLv2.0
21
--  Software placed into the public domain by the author.
22
--  Software 'as is' without warranty.  Author liable for nothing.
23
-- --------------------------------------------------------------------------
24
-- DESCRIPTION
25
--    
26
--
27
--    NOT SYNTHESIZABLE
28
--
29
----------------------------------------------------------------------------
30
-- Revision History
31
-- --------------------------------------------------------------------------
32
-- Revision   Date    Author     CHANGES
33
-- 1.0       4/2015    MR         initial
34
-- 2.0       5/2015    AS         changed to plasma coding style 
35
-- --------------------------------------------------------------------------
36
library IEEE;
37
  use IEEE.std_logic_1164.ALL;
38
  use IEEE.numeric_std.ALL;
39
 
40
library FLOATFIXLIB;
41
  use FLOATFIXLIB.fixed_float_types.all;
42
  use FLOATFIXLIB.float_pkg.all;
43
 
44
library PLASMA;
45
  use PLASMA.mips_instruction_set.ALL;
46
  use PLASMA.plasma_pack.ALL;
47
 
48
entity plasma_fpu_comparator is
49
  port (
50
    comp_a_in                 : in  t_plasma_dword;
51
    comp_b_in                 : in  t_plasma_dword;
52
    fpu_ctrl                  : in  t_fpu_ctrl;
53
    comp_out                  : out std_logic
54
  );
55
end entity plasma_fpu_comparator;
56
 
57
 
58
architecture behav_plasma_fpu_comparator of plasma_fpu_comparator is
59
 
60
begin
61
 
62
  process( comp_a_in, comp_b_in, fpu_ctrl )
63
    variable a_in     : float64;
64
    variable b_in     : float64;
65
 
66
    variable bool_cc  : Boolean;
67
  begin
68
    --
69
    -- convert input
70
    --
71
    if fpu_ctrl.double = '1' then
72
      a_in := Float64( comp_a_in );
73
      b_in := Float64( comp_b_in );
74
    else
75
      a_in := to_Float64( Float32( comp_a_in(31 downto 0)));
76
      b_in := to_Float64( Float32( comp_b_in(31 downto 0)));
77
    end if;
78
 
79
    --
80
    -- default values
81
    --
82
    bool_cc   := False;
83
    comp_out  <= '0';
84
 
85
    --
86
    -- partially implemented comparator functions
87
    --
88
    if fpu_ctrl.operation(5 downto 4) = "11" then
89
    case fpu_ctrl.operation is
90
 
91
      when MIPS_FUNC_FMT_C_F    =>
92
      when MIPS_FUNC_FMT_C_UN   =>
93
      when MIPS_FUNC_FMT_C_EQ   => bool_cc := a_in = b_in;
94
      when MIPS_FUNC_FMT_C_UEQ  =>
95
      when MIPS_FUNC_FMT_C_OLT  => bool_cc := a_in < b_in;
96
      when MIPS_FUNC_FMT_C_ULT  =>
97
      when MIPS_FUNC_FMT_C_OLE  =>
98
      when MIPS_FUNC_FMT_C_ULE  => bool_cc := not (a_in > b_in);
99
      when MIPS_FUNC_FMT_C_SF   => bool_cc := (a_in < b_in) or (a_in = b_in);
100
      when MIPS_FUNC_FMT_C_NGLE =>
101
      when MIPS_FUNC_FMT_C_SEQ  => bool_cc := a_in = b_in;
102
      when MIPS_FUNC_FMT_C_NGL  =>
103
      when MIPS_FUNC_FMT_C_LT   => bool_cc := a_in < b_in;
104
      when MIPS_FUNC_FMT_C_NGE  => bool_cc := (a_in > b_in) or (a_in = b_in);
105
      when MIPS_FUNC_FMT_C_LE   => bool_cc := (a_in < b_in) or (a_in = b_in);
106
      when MIPS_FUNC_FMT_C_NGT  => bool_cc := not (a_in > b_in);
107
 
108
      when others               => report "WARNING: Unknown FPU comparator command" & sv2string( fpu_ctrl.operation);
109
 
110
    end case;
111
    end if;
112
 
113
    --
114
    -- comparator output
115
    --
116
    if bool_cc then comp_out <= '1'; end if;
117
 
118
  end process;
119
 
120
end architecture behav_plasma_fpu_comparator;

powered by: WebSVN 2.1.0

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