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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [rtl/] [lxp32_compl.vhd] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 ring0_mipt
---------------------------------------------------------------------
2
-- Complementor
3
--
4
-- Part of the LXP32 CPU
5
--
6
-- Copyright (c) 2016 by Alex I. Kuznetsov
7
--
8
-- Computes a 2's complement of its input. Used as an auxiliary
9
-- unit in the divider.
10
---------------------------------------------------------------------
11
 
12
library ieee;
13
use ieee.std_logic_1164.all;
14
use ieee.numeric_std.all;
15
 
16
entity lxp32_compl is
17
        port(
18
                clk_i: in std_logic;
19
                compl_i: in std_logic;
20
                d_i: in std_logic_vector(31 downto 0);
21
                d_o: out std_logic_vector(31 downto 0)
22
        );
23
end entity;
24
 
25
architecture rtl of lxp32_compl is
26
 
27
signal d_prepared: unsigned(d_i'range);
28
signal sum_low: unsigned(16 downto 0);
29
signal d_high: unsigned(15 downto 0);
30
signal sum_high: unsigned(15 downto 0);
31
 
32
begin
33
 
34
d_prepared_gen: for i in d_prepared'range generate
35
        d_prepared(i)<=d_i(i) xor compl_i;
36
end generate;
37
 
38
process (clk_i) is
39
begin
40
        if rising_edge(clk_i) then
41
                sum_low<=("0"&d_prepared(15 downto 0))+(to_unsigned(0,16)&compl_i);
42
                d_high<=d_prepared(31 downto 16);
43
        end if;
44
end process;
45
 
46
sum_high<=d_high+(to_unsigned(0,15)&sum_low(sum_low'high));
47
 
48
d_o<=std_logic_vector(sum_high&sum_low(15 downto 0));
49
 
50
end architecture;

powered by: WebSVN 2.1.0

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