source: firmware/FTM/trigger/drivers/detection_logic/unary_to_binary.vhd@ 18341

Last change on this file since 18341 was 10366, checked in by weitzel, 14 years ago
FTM trigger manager from MCSE added; DCM arrangement changed; changes in FTM ethernet module
File size: 3.1 KB
Line 
1--=======================================================================================
2-- TITLE : Binary to decimal converter
3-- DESCRIPTION : Convert 5bits to the sum on 3bits of the bits to '1' in input vector
4-- FILE : binary_to_decimal.vhd
5-- COMPANY : Micro-Cameras & Space Exploration SA
6--=======================================================================================
7-- CREATION
8-- DATE AUTHOR PROJECT REVISION
9-- 07/03/2011 JGi 110307a
10--=======================================================================================
11-- MODIFICATION HISTORY
12-- DATE AUTHOR PROJECT REVISION COMMENTS
13-- 07/03/2011 JGi 110307a Description
14--=======================================================================================
15-- Library Definition
16library ieee;
17 use ieee.std_logic_1164.all;
18 use ieee.numeric_std.all;
19
20-- Entity Definition
21entity unary_to_binary is
22 port( --clock
23 clk_250MHz : in std_logic;
24 --input
25 vector_in : in std_logic_vector(4 downto 0);
26 --output
27 result : out std_logic_vector(2 downto 0));
28end unary_to_binary;
29
30-- Architecture Definition
31architecture RTL of unary_to_binary is
32
33 type t_reg is record
34 -- Internal register declaration
35 -- Ouput register declaration
36 result : std_logic_vector(2 downto 0);
37 end record;
38
39 signal i_next_reg : t_reg := (result => (others => '0'));
40 signal i_reg : t_reg := (result => (others => '0'));
41
42begin
43
44 -- Combinatorial logic
45 process(vector_in, i_reg)
46 variable v_reg : t_reg := (result => (others => '0'));
47 variable temp_vect_0, temp_vect_1, temp_vect_2, temp_vect_3, temp_vect_4 :
48 unsigned(2 downto 0) := (others => '0');
49 begin
50 v_reg := i_reg;
51 --===================================================================================
52
53 --===================================================================================
54 -- Bit count processing
55 --===================================================================================
56 -- Simulate 5 vectors of 3 bits for the sum
57 temp_vect_0 := "00" & vector_in(0);
58 temp_vect_1 := "00" & vector_in(1);
59 temp_vect_2 := "00" & vector_in(2);
60 temp_vect_3 := "00" & vector_in(3);
61 temp_vect_4 := "00" & vector_in(4);
62
63 -- Sum all the simulated vectors
64 v_reg.result := std_logic_vector(temp_vect_0 + temp_vect_1 + temp_vect_2 +
65 temp_vect_3 + temp_vect_4);
66 --===================================================================================
67
68 --===================================================================================
69 -- Drive register input
70 i_next_reg <= v_reg;
71
72 --===================================================================================
73 -- Output assignation
74 result <= i_reg.result;
75 --===================================================================================
76 end process;
77
78 -- Sequential logic
79 process(clk_250MHz)
80 begin
81 if rising_edge(clk_250MHz) then
82 i_reg <= i_next_reg;
83 end if;
84 end process;
85
86end RTL;
Note: See TracBrowser for help on using the repository browser.