在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 3367|回复: 9

10个19位数据比较,找出最大值,怎么做比较好?

[复制链接]
发表于 2007-11-10 20:39:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
需要在一个时钟周期内(125MHz)完成,我想进行并行比较,没找到例子,自己写了一个,思路就是1和2比,较大的一个和3比,再得到一个和4比,依次类推。时序仿真结果不太稳定,最大值的位置应该在0-9内,但是结果经常出现10-15,不知道错在哪儿。另外有没有更好的办法能推荐一下,谢谢。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity max19_10_comb is
port(
    clock:in std_logic;
    data0,data1,data2,data3,data4,data5,data6,data7:in std_logic_vector(18 downto 0);
    data8,data9:in std_logic_vector(18 downto 0);
    result_valueut std_logic_vector(18 downto 0);
    result_indexut std_logic_vector(3 downto 0)
    );
end max19_10_comb;

architecture beha of max19_10_comb is
    signal index0:std_logic_vector(3 downto 0):="0000";
    signal index1:std_logic_vector(3 downto 0):="0001";
    signal index2:std_logic_vector(3 downto 0):="0010";
    signal index3:std_logic_vector(3 downto 0):="0011";
    signal index4:std_logic_vector(3 downto 0):="0100";
    signal index5:std_logic_vector(3 downto 0):="0101";
    signal index6:std_logic_vector(3 downto 0):="0110";
    signal index7:std_logic_vector(3 downto 0):="0111";
    signal index8:std_logic_vector(3 downto 0):="1000";
    signal index9:std_logic_vector(3 downto 0):="1001";
    signal result01,result02,result03,result04,result05,result06,result07:std_logic_vector(18 downto 0);
    signal result08,result09:std_logic_vector(18 downto 0);
    signal index01,index02,index03,index04,index05,index06,index07:std_logic_vector(3 downto 0);
    signal index08,index09:std_logic_vector(3 downto 0);

begin
   process(data0,data1,data2,data3,data4,data5,data6,data7,data8,data9,result01,result02,result03,result04,result05,result06,result07,result08,result09,index01,index02,index03,index04,index05,index06,index07,index08,index09)
    begin
        if data0 > data1 then
            result01 <= data0;
            index01 <= index0;
        else
            result01 <= data1;
            index01 <= index1;
        end if;
        
        if result01 > data2 then
            result02 <= result01;
            index02 <= index01;
        else
            result02 <= data2;
            index02 <= index2;
        end if;
        
        if result02 > data3 then
            result03 <= result02;
            index03 <= index02;
        else
            result03 <= data3;
            index03 <= index3;
        end if;
        
        if result03 > data4 then
            result04 <= result03;
            index04 <= index03;
        else
            result04 <= data4;
            index04 <= index4;
        end if;
        
        if result04 > data5 then
            result05 <= result04;
            index05 <= index04;
        else
            result05 <= data5;
            index05 <= index5;
        end if;
        
        if result05 > data6 then
            result06 <= result05;
            index06 <= index05;
        else
            result06 <= data6;
            index06 <= index6;
        end if;
        
        if result06 > data7 then
            result07 <= result06;
            index07 <= index06;
        else
            result07 <= data7;
            index07 <= index7;
        end if;
        
        if result07 > data8 then
            result08 <= result07;
            index08 <= index07;
        else
            result08 <= data8;
            index08 <= index8;
        end if;
        
        if result08 > data9 then
            result09 <= result08;
            index09 <= index08;
        else
            result09 <= data9;
            index09 <= index9;
        end if;

    end process;
   
    process(clock)
    begin
        if clock'EVENT and clock = '1' then
            result_value <= result09;
            result_index <= index09;
        end if;
    end process;
end beha;
发表于 2007-11-11 15:09:46 | 显示全部楼层
一个时钟周期内要做这么多事情,完的成不哦?
发表于 2007-11-11 15:11:28 | 显示全部楼层
我觉得可以做个流水线来比较好一点
发表于 2007-11-18 01:34:25 | 显示全部楼层
确实在一个周期中没法做
发表于 2007-11-18 20:29:32 | 显示全部楼层

学习学习

!~!!!!!
发表于 2007-11-18 20:51:29 | 显示全部楼层
采用并行流水线结构吧,思路就是1和2比,3和4比,5和6比。。。
较大的再依次比较
发表于 2007-11-19 11:56:32 | 显示全部楼层
可以并行起来, 以空间换时间。

降低频率如果结果稳定,更说明需要改进比较算法。
发表于 2007-11-22 09:49:26 | 显示全部楼层
我觉得从MSB开始比较,若MSB全为“0”都保持不变;存在MSB中为“1”,对应值保持不变,其它MSB为“0”的就整个值屏蔽为全“0”;然后再按上述机制比较剩下的位。
不知可行不?
发表于 2007-11-22 10:51:12 | 显示全部楼层
支持,从MSB比较出发,同时每个bit比较可以并行进行。



原帖由 ddxx 于 2007-11-22 09:49 发表
我觉得从MSB开始比较,若MSB全为“0”都保持不变;存在MSB中为“1”,对应值保持不变,其它MSB为“0”的就整个值屏蔽为全“0”;然后再按上述机制比较剩下的位。
不知可行不?

 楼主| 发表于 2007-11-22 19:41:10 | 显示全部楼层
谢谢关注,我最后实现的时候用的并行比较+流水线结构,效果还不错。不过像ddxx说的那种方法肯定效果会更好一些。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-14 12:42 , Processed in 0.038573 second(s), 10 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表