搜索
bottom↓
回复: 1

VHDL 赋值语句位置差异

[复制链接]

出0入0汤圆

发表于 2011-8-30 08:46:58 | 显示全部楼层 |阅读模式
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity add_product is
port(
                clk                 : in std_logic;       
                clock                 : in std_logic;               
                reset                 : in std_logic;                          -----enable '1'
                outter                 : out std_logic_vector(9 downto 0);
                initial_f   : in std_logic_vector(9 downto 0);
                en                        : in std_logic;
                direction   : in std_logic;
                flag_out         : out std_logic
        );
end entity;       
architecture behav of add_product is
        signal flag                          : std_logic:='1';
        signal flag1                         : std_logic:='1';
        signal flag1_reg                 : std_logic:='0';
        signal direction_reg         : std_logic:='0';
        signal clear_flag1_reg         : std_logic:='0';
        signal clear_flag1                 : std_logic:='0';
--        signal yx   : std_logic:='1';
        signal cnt                          : std_logic_vector(9 downto 0):="0000000000";
        signal cnt_reg                  : std_logic_vector(9 downto 0):="0000000000";
--        signal num                                 : std_logic_vector (3 downto 0):="0000";       
begin


outter<=cnt;
flag_out<=flag;
flag1_reg<=flag1;
clear_flag1_reg<=clear_flag1;
--direction_reg<=direction;                                                                ----------1
process(clk)
       begin
       if clk'EVENT AND clk='1'then
                        if reset='1'  then
                                flag1<='1';
                        elsif clear_flag1_reg='0' then
                                if en='1' and  flag1='1' then
                                        flag1<='0';
                                        cnt_reg<=initial_f;
                                end if;
                        elsif clear_flag1_reg='1' then
                          flag1<='1';

                end if;
           end if;
end process;

counting:process(clock)
       begin
       if clock'EVENT AND clock='1'then
                direction_reg<=direction;                                              ------------2

                                        if flag1_reg='0' then
                                                cnt<=cnt_reg;
                                                clear_flag1<='1';

                                               
                                        elsif(flag=not direction_reg)then
                                                if(cnt="1111111111") then
                                                         --flag<='0';
                                                flag<=direction_reg;
                                                else cnt<=cnt+1;                                                        
                                                end if;                               
                                       
                                        elsif(flag=direction_reg)then
                                                if(cnt="0000000000") then
                                                         --flag<='1';
                                                        flag<=not direction_reg;
                                                else cnt<=cnt-1;
                                                end if;
                                        end if;       
                end if;
end process counting;

end behav;

上面程序的1 跟 2 赋值语句有区别吗?  怎么在实际应用中会有较大的差别呢?

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

发表于 2011-8-30 10:34:42 | 显示全部楼层
--direction_reg<=direction;             ----------1
这个是并行 可以说direction变化direction_reg同时也变化

direction_reg<=direction;   ------------2
因为这个在进程里,只有clock上升沿到来之后才赋值给direction_reg,因此赋值次数clock频率有关。和clock不跳变的话就不会赋值。
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-27 17:18

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表