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

Subversion Repositories kvcordic

[/] [kvcordic/] [trunk/] [sim/] [rtl_sim/] [vhdl/] [operpack.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kavi
--------------------------------------------------------------------------------
2
-- Filename: operpack.vhd
3
-- Purpose : Package for various arithmetic operators:
4
--           * Variable shifter (left shift unsigned, left shift signed, right 
5
--             shift unsigned, right shift signed)
6
--           * Multipliers (mul, smul, umul)
7
--           * Dividers and modulo extractors (divqr, divq, divr)
8
--           * Bit manipulation operators (bitinsert, bitextract)
9
--             
10
-- Author  : Nikolaos Kavvadias (C) 2009, 2010, 2011, 2012, 2013, 2014
11
-- Date    : 22-Feb-2014
12
-- Revision: 0.0.0 (03/10/09)
13
--           Initial version.
14
--           0.2.0 (12/10/09)
15
--           Added mul, umul, smul operators.
16
--           0.3.0 (22/01/10)
17
--           Added divqr, divq, divr operators.
18
--           0.3.1 (20/07/10)
19
--           All input procedure parameters are not necessarily of the signal 
20
--           type.
21
--           0.3.2 (14/10/10)
22
--           Spin-off of file "operpack.vhd". Supports the "real" IEEE standard
23
--           libraries (numeric_std).
24
--           0.3.3 (01/05/11)
25
--           Added bitinsert, bitextract operators.
26
--           0.4.9 (25/02/12)
27
--           Added support for shrv6, shlv6 (64-bit quantities).
28
--           1.0.0 (22/02/14)
29
--           Underhanded version: removed all functionality except shrv4 which 
30
--           needed for the CORDIC IP CORE.
31
--
32
--------------------------------------------------------------------------------
33
 
34
library IEEE;
35
use IEEE.std_logic_1164.all;
36
use IEEE.numeric_std.all;
37
 
38
 
39
package operpack is
40
 
41
  function shrv4 (a, b : std_logic_vector; mode : std_logic) return std_logic_vector;
42
  constant  ONE : std_logic_vector(0 downto 0) := "1";
43
 
44
end operpack;
45
 
46
 
47
package body operpack is
48
 
49
  function shrv4 (a, b : std_logic_vector; mode : std_logic) return std_logic_vector is
50
    variable shift1R, shift2R, shift4R, shift8R : std_logic_vector(a'RANGE);
51
    variable fills : std_logic_vector(a'LENGTH-1 downto a'LENGTH/2);
52
  begin
53
   if (mode = '1' and a(a'LENGTH-1) = '1') then
54
     fills := (others => '1');
55
   else
56
     fills := (others => '0');
57
   end if;
58
   if (b(0) = '1') then
59
     shift1R := fills(a'LENGTH-1 downto a'LENGTH-1) & a(a'LENGTH-1 downto 1);
60
   else
61
     shift1R := a;
62
   end if;
63
   if (b(1) = '1') then
64
     shift2R := fills(a'LENGTH-1 downto a'LENGTH-2) & shift1R(a'LENGTH-1 downto 2);
65
   else
66
     shift2R := shift1R;
67
   end if;
68
   if (b(2) = '1') then
69
     shift4R := fills(a'LENGTH-1 downto a'LENGTH-4) & shift2R(a'LENGTH-1 downto 4);
70
   else
71
     shift4R := shift2R;
72
   end if;
73
   if (b(3) = '1') then
74
     shift8R := fills(a'LENGTH-1 downto a'LENGTH-8) & shift4R(a'LENGTH-1 downto 8);
75
   else
76
     shift8R := shift4R;
77
   end if;
78
   return (shift8R);
79
  end shrv4;
80
 
81
end operpack;

powered by: WebSVN 2.1.0

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