blob: 470e7c4302ce52e81fe14c95f5f1c2750832c2c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 05/03/2025 03:20:07 PM
-- Design Name:
-- Module Name: Fct_2_3 - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Multiply a 4 bit number and get an approximation.
-- Works for 0 to 12, it's off above.
-- 12 is the highest good input value because of thermometric 12 bits encoding.
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Fct_2_3 is
Port ( ADCbin : in STD_LOGIC_VECTOR (3 downto 0);
A2_3 : out STD_LOGIC_VECTOR (3 downto 0));
end Fct_2_3;
architecture Behavioral of Fct_2_3 is
signal shifted_once : STD_LOGIC_VECTOR(3 downto 0);
signal shifted_twice : STD_LOGIC_VECTOR(3 downto 0);
signal shifted_thrice : STD_LOGIC_VECTOR(3 downto 0);
signal carry_out : STD_LOGIC;
component Add4Bits is
Port ( A : in STD_LOGIC_VECTOR (3 downto 0);
B : in STD_LOGIC_VECTOR (3 downto 0);
C : in STD_LOGIC;
R : out STD_LOGIC_VECTOR (3 downto 0);
Rc : out STD_LOGIC);
end component;
begin
-- N x 2^-1 : shifted once
shifted_once <= '0' & ADCbin(3 downto 1);
-- N x 2^-3 : shifted thrice
shifted_twice <= '0' & shifted_once(3 downto 1);
shifted_thrice <= '0' & shifted_twice(3 downto 1);
-- Both are then added to give the result of the 2/3 multiplication (0.625)
result : Add4Bits port map (
A => "0110",
B => "0001",
C => '0',
R => A2_3,
Rc => carry_out
);
end Behavioral;
|