音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費(fèi)注冊(cè) 首頁(yè) | 行業(yè)黑名單 | 幫助
維庫(kù)電子市場(chǎng)網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測(cè)控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

請(qǐng)教256個(gè)數(shù)求平均值的問(wèn)題

作者:madke 欄目:EDA技術(shù)
請(qǐng)教256個(gè)數(shù)求平均值的問(wèn)題
編了一個(gè)256個(gè)數(shù)求均值的程序,仿真不對(duì)!
幫忙看看,錯(cuò)在哪里?謝謝!

use ieee.std_logic_unsigned.all;
entity average is
    PORT( clr,clk:in std_logic;
           a:in std_logic_vector(7 downto 0);
           s:out std_logic_vector(7 downto 0));
end average;
architecture bhv of average is
      signal s256:std_logic_vector(15 downto 0);
      signal seg256:std_logic_vector(7 downto 0);
    begin
     PROCESS(clk,clr)
      begin
        if clr='1' then s256<=(others=>'0');seg256<=(others=>'0');
        elsif clk'EVENT and clk='1' then
            s256<=s256+a;
          if seg256<255 then
             seg256<=seg256+1;
           else seg256<=(others=>'0');
          end if;
        end if;
     end PROCESS;
    PROCESS(seg256)
      begin
        if seg256=255 then
        for i in 0 to 7 loop
            s(i)<=s256(i+8);
        end loop;
        end if;
    end PROCESS;
end bhv;


2樓: >>參與討論
picklas
re
感覺(jué)是
PROCESS(seg256)
      begin
        if seg256=255 then
        for i in 0 to 7 loop
            s(i)<=s256(i+8);
        end loop;
        end if;
    end PROCESS;
的問(wèn)題,建議你用仿真器把所有的信號(hào)都加上去看看。
如果可以換成下面的進(jìn)程是一下:
    PROCESS(clk)
     if rising_edge(clk) then
         if seg256=255 then
             s <= s256(15 downto 8);
         end if;
     end if;
    end PROCESS;
試試吧。

3樓: >>參與討論
madke
thanks
謝謝指教!修改后程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity average is
    PORT( clr,clk:in std_logic;
           a:in std_logic_vector(7 downto 0);
           so:out std_logic;
           s:out std_logic_vector(7 downto 0));
end average;
architecture bhv of average is
      signal s256:std_logic_vector(15 downto 0);
      signal seg256:std_logic_vector(8 downto 0);
      signal soseg:std_logic;

    begin

     PROCESS(clk,clr)
      begin
        if clr='1' then seg256<=(others=>'0');seg256<=(others=>'0');
          elsif clk'EVENT and clk='1' then
            if seg256<"11111111" then
               seg256<=seg256+1;
             else seg256<="100000000";
            end if;
        end if;
     end PROCESS;

     PROCESS(clk,clr)
      begin
        if clr='1' then s256<=(others=>'0');
          elsif clk'EVENT and clk='1' then
            if seg256<"100000000" then
              s256<=s256+a;
            end if;
        end if;
     end PROCESS;


     PROCESS(clr,seg256)
      begin
        if clr='1' then soseg<='0';
          elsif seg256="100000000" then
                  soseg<='1';
             else soseg<='0';
        end if;
     end PROCESS;

    PROCESS(clr,soseg)
      begin
        if clr='1' then s<=(others=>'0');
          elsif soseg='1' then
               for i in 0 to 7 loop
                 s(i)<=s256(i+8);
               end loop;
        end if;
    end PROCESS;

  so<=soseg;
end bhv;



參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
如何得到verilog-HDL的軟件
幫我看個(gè)電路好嗎?
現(xiàn)在Spartan3好買嗎
FPGA大量輸入及輸出的問(wèn)題
SOS !!!!!!!!!綜合仿真均通過(guò) 布線怎么不行
免費(fèi)注冊(cè)為維庫(kù)電子開(kāi)發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào)