ATA 发表于 2010-6-27 23:30:35

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

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]
查看完整版本: 2位的串并转换但总是出现错误 说在进程里的q不能解释子程序调用