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

Subversion Repositories tinycpu

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

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 21 earlz
    SegmentOut: out std_logic_vector(7 downto 0);
14
    Clock: in std_logic
15 16 earlz
--    Debug: out std_logic_vector(8 downto 0)
16
   );
17
end carryover;
18
 
19
architecture Behavioral of carryover is
20 21 earlz
  signal temp: std_logic_vector(8 downto 0) := "000000000";
21
  signal temp2: std_logic_vector(7 downto 0);
22 16 earlz
begin
23
  --treat as unsigned because it doesn't actually matter for addition and just make carry and borrow correct
24
  process(DataIn, SegmentIn,Addend, EnableCarry)
25 21 earlz
 
26 16 earlz
  begin
27 21 earlz
    --if rising_edge(Clock) then
28
      temp <= std_logic_vector(unsigned('0' & DataIn) + unsigned( Addend));
29
  --    if ('1' and ((not Addend(7)) and DataIn(7) and temp(8)))='1' then 
30
      if (EnableCarry and ((not Addend(7)) and DataIn(7) and not temp(8)))='1' then
31
        SegmentOut <= std_logic_vector(unsigned(SegmentIn)+1);
32
      elsif (EnableCarry and (Addend(7) and not DataIn(7) and temp(8)))='1' then
33
        SegmentOut <= std_logic_vector(unsigned(SegmentIn)-1);
34
      else
35
        SegmentOut <= SegmentIn;
36
      end if;
37
    --end if;
38 16 earlz
  end process;
39
  --Debug <= Temp;
40
  DataOut <= temp(7 downto 0);
41
end Behavioral;

powered by: WebSVN 2.1.0

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