1 |
2 |
wzab |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : Multiinput comparator for finding of maximum element
|
3 |
|
|
-- Project :
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : max_finder_1st.vhd
|
6 |
|
|
-- Author : Wojciech M. Zabolotny ( wzab01<at>gmail.com )
|
7 |
|
|
-- Company :
|
8 |
|
|
-- License : BSD
|
9 |
|
|
-- Created : 2013-11-01
|
10 |
|
|
-- Last update: 2015-09-24
|
11 |
|
|
-- Platform :
|
12 |
|
|
-- Standard : VHDL'93/02
|
13 |
|
|
-------------------------------------------------------------------------------
|
14 |
|
|
-- Description:
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
|
|
-- Copyright (c) 2014
|
17 |
|
|
-------------------------------------------------------------------------------
|
18 |
|
|
-- Revisions :
|
19 |
|
|
-- Date Version Author Description
|
20 |
|
|
-- 2013-11-01 1.0 WZab Created
|
21 |
|
|
-------------------------------------------------------------------------------
|
22 |
|
|
|
23 |
|
|
library IEEE;
|
24 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
25 |
|
|
|
26 |
|
|
use IEEE.NUMERIC_STD.all;
|
27 |
|
|
library work;
|
28 |
|
|
use work.lateq_pkg.all;
|
29 |
|
|
use work.ex1_pkg.all;
|
30 |
|
|
use work.ex1_trees_pkg.all;
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
entity max_finder_1st is
|
34 |
|
|
port (
|
35 |
|
|
dins : in T_EX1_CMP_INS;
|
36 |
|
|
dout : out T_SINGLE_DATA_WITH_POS;
|
37 |
|
|
clk : in std_logic;
|
38 |
|
|
rst_p : in std_logic);
|
39 |
|
|
end max_finder_1st;
|
40 |
|
|
|
41 |
|
|
architecture beh of max_finder_1st is
|
42 |
|
|
|
43 |
|
|
begin
|
44 |
|
|
|
45 |
|
|
--assert false report "This is report from device:" & desc severity note;
|
46 |
|
|
process (clk, rst_p) is
|
47 |
|
|
variable res : T_SINGLE_DATA_WITH_POS;
|
48 |
|
|
variable first : boolean;
|
49 |
|
|
-- pragma translate_off
|
50 |
|
|
variable lateq_mrk : T_LATEQ_MRK;
|
51 |
|
|
-- pragma translate_on
|
52 |
|
|
begin -- process
|
53 |
|
|
if clk'event and clk = '1' then -- rising clock edge
|
54 |
|
|
if rst_p = '1' then -- asynchronous reset (active high)
|
55 |
|
|
dout <= C_SINGLE_DATA_WITH_POS_INIT;
|
56 |
|
|
else
|
57 |
|
|
first := true;
|
58 |
|
|
res := C_SINGLE_DATA_WITH_POS_INIT;
|
59 |
|
|
for i in 0 to EX1_NOF_INS_IN_CMP-1 loop
|
60 |
|
|
if dins(i).valid then
|
61 |
|
|
-- In simulation check delays the adjustment blocks should equalize
|
62 |
|
|
-- time marks. So any time marker difference is a sign of serious problem!
|
63 |
|
|
if first then
|
64 |
|
|
res := dins(i);
|
65 |
|
|
first := false;
|
66 |
|
|
else
|
67 |
|
|
-- pragma translate_off
|
68 |
|
|
-- Check only valid inputs
|
69 |
|
|
assert res.lateq_mrk = dins(i).lateq_mrk report "in entity:" & max_finder_1st'instance_name &
|
70 |
|
|
" different delays between input 0 and input " &
|
71 |
|
|
integer'image(i) & ": " & integer'image(res.lateq_mrk) & "<>" & integer'image(dins(i).lateq_mrk)
|
72 |
|
|
severity failure;
|
73 |
|
|
-- pragma translate_on
|
74 |
|
|
if dins(i).valid and (ex1_cmp_data(dins(i), res) > 0) then
|
75 |
|
|
--report "swapped:" & integer'image(dins(i).value) & "<>" & integer'image(res.value) severity note;
|
76 |
|
|
res := dins(i);
|
77 |
|
|
end if;
|
78 |
|
|
end if;
|
79 |
|
|
end if;
|
80 |
|
|
end loop; -- i
|
81 |
|
|
--report "dout:" & integer'image(res.value) severity note;
|
82 |
|
|
dout <= res;
|
83 |
|
|
end if;
|
84 |
|
|
end if;
|
85 |
|
|
end process;
|
86 |
|
|
|
87 |
|
|
end beh;
|