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; 在进程里出现了两次翻转,它的值不能保持。这样该下,看行不行。<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<=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)<=input;<br>
elsif q='1' then<br>
output(1)<=input;<br>
end if;<br>
end if;<br>
end process;<br>
end behave; 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]