Board logo

标题: [求助]请高手帮忙!谢谢!在线等!--已解决 [打印本页]

作者: wlj3304    时间: 2007-6-21 22:04     标题: [求助]请高手帮忙!谢谢!在线等!--已解决

---我是初学者,请大家帮忙。我想实现把16位计数器计数并入移位寄存器,程序如下:

entity jsqyw is
generic(width:integer:=16);
Port ( clk : in STD_LOGIC;
resetn : in STD_LOGIC;
count_out : out STD_LOGIC_VECTOR(width-1 DOWNTO 0);
shift_en : in STD_LOGIC;
load : in STD_LOGIC;
shift_out : out STD_LOGIC;
d_in : in STD_LOGIC_VECTOR(width-1 DOWNTO 0));
end jsqyw;

architecture Behavioral of jsqyw is
begin
signal count_outQ:std_logic_vector(width-1 downto 0);
signal shift_red:std_logic_vector(width-1 downto 0);

P0:process(clk,resetn)
begin
if (resetn='0') then
count_outQ<=(others=>'0');
elsif(clk'event and clk='1') then
count_outQ<=count_outQ+1;
end if;
count_out<=count_outQ;
end process P0;

p1:process(clk,resetn,count_out)
begin
d_in<=count_out;
if resetn='0' then
shift_red<=(others=>'0');
elsif clk'event and clk='1' then
if load='1' then
shift_red<=d_in;
elsif shift_en='1' then
shift_red<=shl(shift_red,"1");
shift_red(0)<='0';
end if;
end if;
end process P1;
shift_out<=shift_red(width-1);
end jsyw;
end Behavioral;

可是这两个进程是并行的,无法把计数器的结果传入移位寄存器的输入,怎么样才能实现呢?谢谢!急!

[此贴子已经被作者于2007-7-7 22:10:42编辑过]


作者: 一切从零开始    时间: 2007-6-22 00:42

可以用信号量嘛(signal),你可以把它看作c语言中的全局变量,它能够在进程与进程中传递信息,但是其量只能在一个进程中变化,否则会有问题哦!试试吧

[em01]
作者: 一切从零开始    时间: 2007-6-22 01:02

又看看你的程序,有点乱哦.(没编译过吧)

要不这样,你描述一下第二个进程是什么意思,你的输出到底是什么?count_out作为输出可不能再做敏感信号了


作者: Kelvin.Z    时间: 2007-6-22 13:11

第一个:d_in<=count_out;这句话最好放在第二个进程的外面。

第二个:好象是shift_red<=d_in<=count_out,那不知道中间的这个din有什么意义。

第三个:如果移位的话,直接用shift_red〈=shift_red(width-1,1)&'0' 或许会好些。






欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0