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

Subversion Repositories the_wizardry_project

[/] [the_wizardry_project/] [trunk/] [Wizardry/] [VHDL/] [Wizardry Top Level/] [Address Generation/] [JOP/] [mul.vhd] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 mcwaccent
--
2
--  This file is a part of JOP, the Java Optimized Processor
3
--
4
--  Copyright (C) 2001-2008, Martin Schoeberl (martin@jopdesign.com)
5
--  Copyright (C) 2008, Wolfgang Puffitsch
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
 
21
 
22
--
23
--      mul.vhd
24
--
25
--      bit-serial multiplier
26
--      
27
--              244 LCs only mul
28
--
29
--      2002-03-22      first version
30
--      2004-10-07      changed to Koljas version
31
--      2004-10-08      mul operands from a and b, single instruction
32
--      2008-02-15      changed from booth to bit-serial
33
--
34
 
35
 
36
library ieee ;
37
use ieee.std_logic_1164.all ;
38
use ieee.numeric_std.all ;
39
use ieee.std_logic_unsigned.all;
40
 
41
 
42
entity mul is
43
 
44
generic (
45
        width           : integer := 32         -- one data word
46
);
47
 
48
port (
49
        clk             : in std_logic;
50
 
51
        ain             : in std_logic_vector(width-1 downto 0);
52
        bin             : in std_logic_vector(width-1 downto 0);
53
        wr              : in std_logic;         -- write starts multiplier
54
        dout            : out std_logic_vector(width-1 downto 0)
55
);
56
end mul;
57
 
58
 
59
architecture rtl of mul is
60
--
61
--      Signals
62
--
63
        signal count : integer range 0 to width/2;
64
        signal p     : unsigned(width-1 downto 0);
65
        signal a, b  : unsigned(width-1 downto 0);
66
 
67
begin
68
 
69
process(clk)
70
 
71
variable prod : unsigned(width-1 downto 0);
72
 
73
begin
74
  if rising_edge(clk) then
75
    if wr='1' then
76
      p <= (others => '0');
77
      a <= unsigned(ain);
78
      b <= unsigned(bin);
79
    else
80
 
81
      prod := p;
82
      if b(0) = '1' then
83
        prod := prod + a;
84
      end if;
85
      if b(1) = '1' then
86
        prod := (prod(width-1 downto 1) + a(width-2 downto 0)) & prod(0);
87
      end if;
88
      p <= prod;
89
 
90
      a <= a(width-3 downto 0) & "00";
91
      b <= "00" & b(width-1 downto 2);
92
 
93
    end if;
94
  end if;
95
end process;
96
 
97
dout <= std_logic_vector(p);
98
 
99
end rtl;

powered by: WebSVN 2.1.0

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