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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [src/] [carryover.vhd] - Blame information for rev 16

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

Line No. Rev Author Line
1 16 earlz
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.NUMERIC_STD.ALL;
4
use work.tinycpu.all;
5
 
6
entity carryover is
7
  port(
8
    EnableCarry: in std_logic; --When disabled, SegmentIn goes to SegmentOut
9
    DataIn: in std_logic_vector(7 downto 0);
10
    SegmentIn: in std_logic_vector(7 downto 0);
11
    Addend: in std_logic_vector(7 downto 0); --How much to increase DataIn by (as a signed number). Believe it or not, that's the actual word for what we need.
12
    DataOut: out std_logic_vector(7 downto 0);
13
    SegmentOut: out std_logic_vector(7 downto 0)
14
--    Debug: out std_logic_vector(8 downto 0)
15
   );
16
end carryover;
17
 
18
architecture Behavioral of carryover is
19
  signal temp: std_logic_vector(8 downto 0);
20
begin
21
  --treat as unsigned because it doesn't actually matter for addition and just make carry and borrow correct
22
  process(DataIn, SegmentIn,Addend, EnableCarry)
23
  begin
24
    temp <= std_logic_vector(unsigned('0' & DataIn) + unsigned( Addend));
25
--    if ('1' and ((not Addend(7)) and DataIn(7) and temp(8)))='1' then 
26
    if (EnableCarry and ((not Addend(7)) and DataIn(7) and not temp(8)))='1' then
27
      SegmentOut <= std_logic_vector(unsigned(SegmentIn)+1);
28
    elsif (EnableCarry and (Addend(7) and not DataIn(7) and temp(8)))='1' then
29
      SegmentOut <= std_logic_vector(unsigned(SegmentIn)-1);
30
    else
31
      SegmentOut <= SegmentIn;
32
    end if;
33
  end process;
34
  --Debug <= Temp;
35
  DataOut <= temp(7 downto 0);
36
end Behavioral;

powered by: WebSVN 2.1.0

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