集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2099|回复: 2

2位的串并转换但总是出现错误 说在进程里的q不能解释子程序调用

[复制链接]
ATA 发表于 2010-6-27 23:30:35 | 显示全部楼层 |阅读模式
2位的串并转换但总是出现错误 说在进程里的q不能解释子程序调用
ibrary ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cb is
port(clk:in std_logic;
input:in std_logic;
output

ut std_logic_vector(1 downto 0));
end cb;
architecture behave of cb is
begin
process(clk,input)
variable q:integer:=0;
begin
if clk'event and clk='1' then
if q='0' then
output(0)<=input;
q:=1;
elsif q='1' then
output(1)<=input;
q:=0;
end if;
end if;
end process;
end behave;
VVC 发表于 2010-6-28 00:31:59 | 显示全部楼层
在进程里出现了两次翻转,它的值不能保持。这样该下,看行不行。<br>
<br>
ibrary ieee;<br>
use ieee.std_logic_1164.all;<br>
use ieee.std_logic_unsigned.all;<br>
entity cb is<br>
port(clk:in std_logic;<br>
input:in std_logic;<br>
outputut std_logic_vector(1 downto 0));<br>
end cb;<br>
architecture behave of cb is<br>
signal q:std_logic;<br>
begin<br>
<br>
process(clk,)<br>
begin<br>
if clk'event and clk='1' then<br>
q&lt;=not q;<br>
end if;<br>
end process;<br>
<br>
process(clk,q)<br>
begin<br>
if clk'event and clk='1' then<br>
if q='0' then<br>
output(0)&lt;=input;<br>
elsif q='1' then<br>
output(1)&lt;=input;<br>
end if;<br>
end if;<br>
end process;<br>
end behave;
Sunlife 发表于 2015-7-4 10:10:15 | 显示全部楼层
ibrary ieee;<br>
use ieee.std_logic_1164.all;<br>
use ieee.std_logic_unsigned.all;<br>
entity cb is<br>
port(clk:in std_logic;<br>
input:in std_logic;<br>
outputut std_logic_vector(1 downto 0));<br>
end cb;<br>
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

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

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-6 20:25 , Processed in 0.058046 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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