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

Subversion Repositories marca

[/] [marca/] [tags/] [INITIAL/] [vhdl/] [multiplier.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jeunes2
--  This file is part of the marca processor.
2
--  Copyright (C) 2007 Wolfgang Puffitsch
3
 
4
--  This program is free software; you can redistribute it and/or modify it
5
--  under the terms of the GNU Library General Public License as published
6
--  by the Free Software Foundation; either version 2, or (at your option)
7
--  any later version.
8
 
9
--  This program is distributed in the hope that it will be useful,
10
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
--  Library General Public License for more details.
13
 
14
--  You should have received a copy of the GNU Library General Public
15
--  License along with this program; if not, write to the Free Software
16
--  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
17
 
18
-------------------------------------------------------------------------------
19
-- MARCA multiplier
20
-------------------------------------------------------------------------------
21
-- architecture for a bit-serial multiplier
22
-------------------------------------------------------------------------------
23
 
24
-------------------------------------------------------------------------------
25
-- Wolfgang Puffitsch
26
-- Computer Architecture Lab, Group 3
27
-------------------------------------------------------------------------------
28
 
29
library IEEE;
30
use IEEE.std_logic_1164.all;
31
use IEEE.numeric_std.all;
32
 
33
use work.marca_pkg.all;
34
 
35
architecture behaviour of multiplier is
36
 
37
signal reg_busy     : std_logic;
38
signal reg_operand1 : std_logic_vector(width-1 downto 0);
39
signal reg_operand2 : std_logic_vector(width-1 downto 0);
40
signal reg_product  : std_logic_vector(width downto 0);
41
signal reg_hotbit   : std_logic_vector(width-1 downto 0);
42
 
43
signal next_busy     : std_logic;
44
signal next_operand1 : std_logic_vector(width-1 downto 0);
45
signal next_operand2 : std_logic_vector(width-1 downto 0);
46
signal next_product  : std_logic_vector(width downto 0);
47
signal next_hotbit   : std_logic_vector(width-1 downto 0);
48
 
49
begin  -- behaviour
50
 
51
  busy     <= reg_busy;
52
  product  <= reg_product;
53
 
54
  syn_proc: process (clock, reset)
55
  begin  -- process sync
56
 
57
    if reset = RESET_ACTIVE then               -- asynchronous reset (active low)
58
 
59
      reg_busy      <= '0';
60
      reg_operand1  <= (others => '0');
61
      reg_operand2  <= (others => '0');
62
      reg_product   <= (others => '0');
63
      reg_hotbit    <= (others => '0');
64
      reg_hotbit(0) <= '1';
65
 
66
    elsif clock'event and clock = '1' then  -- rising clock edge
67
 
68
      if trigger = '1' then
69
        reg_operand1                 <= operand1;
70
        reg_operand2                 <= operand2;
71
        reg_product                  <= (others => '0');
72
        reg_hotbit(width-1)          <= '1';
73
        reg_hotbit(width-2 downto 0) <= (others => '0');
74
        reg_busy                     <= '1';
75
      else
76
        reg_operand1                  <= next_operand1;
77
        reg_operand2                  <= next_operand2;
78
        reg_product(width-1 downto 0) <= next_product(width-1 downto 0);
79
        -- sticky "carry"-bit
80
        reg_product(width)            <= reg_product(width) or next_product(width);
81
        reg_hotbit                    <= next_hotbit;
82
        reg_busy                      <= next_busy;
83
      end if;
84
 
85
    end if;
86
  end process syn_proc;
87
 
88
  compute: process (reg_operand1, reg_operand2, reg_product, reg_hotbit)
89
  begin  -- process compute
90
 
91
    next_operand1 <= reg_operand1(width-2 downto 0) & '0';
92
    next_operand2 <= '0' & reg_operand2(width-1 downto 1);
93
    next_hotbit   <= '0' & reg_hotbit(width-1 downto 1);
94
 
95
    if reg_hotbit(0) = '1' then
96
      next_hotbit <= reg_hotbit;
97
      next_busy <= '0';
98
    else
99
      next_busy <= '1';
100
    end if;
101
 
102
    if reg_operand2(0) = '1' then
103
      next_product <= std_logic_vector(unsigned(reg_product) + unsigned(reg_operand1(width-1 downto 0)));
104
    else
105
      next_product <= reg_product;
106
    end if;
107
 
108
  end process compute;
109
 
110
end behaviour;

powered by: WebSVN 2.1.0

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