首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[求助]请高手帮忙!谢谢!在线等!--已解决

[求助]请高手帮忙!谢谢!在线等!--已解决

---我是初学者,请大家帮忙。我想实现把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编辑过]

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

[em01]
每一天都是新的开始,每一天都有新的收获

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

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

每一天都是新的开始,每一天都有新的收获

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

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

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

返回列表