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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.accelerator/] [dctqidct/] [1.0/] [hdl/] [common_da/] [Serial_subtractor.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
------------------------------------------------------------------------------
2
-- Author               : Timo Alho
3
-- e-mail               : timo.a.alho@tut.fi
4
-- Date                 : 14.06.2004 14:11:03
5
-- File                 : Serial_subtractor.vhd
6
-- Design               : 
7
------------------------------------------------------------------------------
8
-- Description  : Serial subtractor (in0 - in1). 
9
------------------------------------------------------------------------------
10
LIBRARY ieee;
11
USE ieee.std_logic_1164.all;
12
USE ieee.std_logic_arith.all;
13
 
14
ENTITY Serial_subtractor IS
15
   PORT(
16
      clk     : IN     std_logic;
17
      in0     : IN     std_logic;   --serial data in 0
18
      in1     : IN     std_logic;   --serial data in 1
19
      rst_n   : IN     std_logic;
20
      start   : IN     std_logic;   --start (ignores borrowbit)
21
      sub_out : OUT    std_logic    --serial data out
22
   );
23
 
24
-- Declarations
25
 
26
END Serial_subtractor ;
27
 
28
--
29
ARCHITECTURE rtl OF Serial_subtractor IS
30
  SIGNAL borrow_bit_r : std_logic;      -- register for borrow bit
31
  SIGNAL borrow_bit   : std_logic;      -- internal signal for borrow bit
32
  SIGNAL sub : std_logic;               -- internal signal for result
33
 
34
BEGIN
35
 
36
  clocked : PROCESS (clk, rst_n)
37
  BEGIN  -- PROCESS clocked
38
    IF rst_n = '0' THEN                 -- asynchronous reset (active low)
39
      borrow_bit_r <= '0';
40
 
41
    ELSIF clk'event AND clk = '1' THEN  -- rising clock edge
42
      borrow_bit_r <= borrow_bit;
43
    END IF;
44
  END PROCESS clocked;
45
 
46
  calc             : PROCESS (borrow_bit_r, start, in0, in1)
47
    VARIABLE temp1 : std_logic_vector(1 DOWNTO 0);
48
    VARIABLE temp2 : std_logic_vector(2 DOWNTO 0);
49
  BEGIN  -- PROCESS calc
50
 
51
    IF (start = '1') THEN
52
      temp1 := in0 & in1;
53
      CASE temp1 IS
54
        WHEN "00"   =>
55
          sub      <= '0';
56
          borrow_bit <= '0';
57
        WHEN "01"   =>
58
          sub      <= '1';
59
          borrow_bit <= '1';
60
        WHEN "10"   =>
61
          sub      <= '1';
62
          borrow_bit <= '0';
63
        WHEN OTHERS =>
64
          sub      <= '0';
65
          borrow_bit <= '0';
66
      END CASE;
67
 
68
    ELSE
69
      temp2 := borrow_bit_r & in0 & in1;
70
      CASE temp2 IS
71
        WHEN "000"  =>
72
          sub      <= '0';
73
          borrow_bit <= '0';
74
        WHEN "001"  =>
75
          sub      <= '1';
76
          borrow_bit <= '1';
77
        WHEN "010"  =>
78
          sub      <= '1';
79
          borrow_bit <= '0';
80
        WHEN "011"  =>
81
          sub      <= '0';
82
          borrow_bit <= '0';
83
        WHEN "100"  =>
84
          sub      <= '1';
85
          borrow_bit <= '1';
86
        WHEN "101"  =>
87
          sub      <= '0';
88
          borrow_bit <= '1';
89
        WHEN "110"  =>
90
          sub      <= '0';
91
          borrow_bit <= '0';
92
        WHEN OTHERS =>
93
          sub      <= '1';
94
          borrow_bit <= '1';
95
      END CASE;
96
    END IF;
97
  END PROCESS calc;
98
 
99
  sub_out <= sub;
100
END rtl;
101
 

powered by: WebSVN 2.1.0

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