vhdl新手求助
时间:10-02
整理:3721RD
点击:
怎么把x1,x2,x3的值导出来,到输出端啊?赋值给x11,x22,x33?
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY wash IS
PORT
(
clk: in std_logic;
on_off,choice : IN STD_LOGIC;
hold : in std_logic;
x11,x22,x33,signout: out std_logic;
time_t ut std_logic_vector(4 downto 0);
count : OUT STD_LOGIC_vector(2 downto 0)
);
END wash;
ARCHITECTURE a OF wash IS
SIGNAL count_c : STD_LOGIC_vector(2 downto 0);
signal x1,x2,x3: std_logic;
signal sign :std_logic;
signal time :std_logic_vector(4 downto 0);
BEGIN
PROCESS (choice)
variable xa:std_logic:=x1;
variable xb:std_logic:=x2;
variable xc:std_logic:=x3;
BEGIN
IF (choice'event and choice='1') THEN
IF on_off='0' THEN
count_c<="000";
ELSIF
count_c="101" THEN
count_c<="001";
ELSE
count_c<=count_c+1;
END IF;
END IF;
case count_c is
when "000" => xa:='0';xb:='0';xc:='0';
when "001" => xa:='1';xb:='1';xc:='1';
when "010" => xa:='1';xb:='0';xc:='0';
when "011" => xa:='0';xb:='1';xc:='0';
when "100" => xa:='0';xb:='0';xc:='1';
when others => xa:='0';xb:='1';xc:='1';
end case;
x1<=xa;
x2<=xb;
x3<=xc;
end process;
count<=count_c;
process(clk)
variable sign_s :std_logic;
begin
IF (hold'event and hold='1') THEN
sign_s := not sign_s;
end if;
sign<=sign_s;
end process;
signout<=sign;
mROCESS (clk)
BEGIN
if( sign='1' )then
if( x1='1')then
if(clk'event and clk='1') then
if(time="11110")then
x1<='0';
if(time="11110")then
time<="00000";
end if;
else
time<=time+1;
end if;
end if;
elsif( x1='0' and x2='1')then
if(clk'event and clk='1') then
if(time="01111")then
x2<='0';
if(time="01111")then
time<="00000";
end if;
else
time<=time+1;
end if;
end if;
elsif( x1='0' and x2='0' and x3='1' )then
if(clk'event and clk='1') then
if(time="10100")then
x3<='0';
if(time="10100")then
time<="00000";
end if;
else
time<=time+1;
end if;
end if;
end if;
end if;
END PROCESS ;
END a;
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY wash IS
PORT
(
clk: in std_logic;
on_off,choice : IN STD_LOGIC;
hold : in std_logic;
x11,x22,x33,signout: out std_logic;
time_t ut std_logic_vector(4 downto 0);
count : OUT STD_LOGIC_vector(2 downto 0)
);
END wash;
ARCHITECTURE a OF wash IS
SIGNAL count_c : STD_LOGIC_vector(2 downto 0);
signal x1,x2,x3: std_logic;
signal sign :std_logic;
signal time :std_logic_vector(4 downto 0);
BEGIN
PROCESS (choice)
variable xa:std_logic:=x1;
variable xb:std_logic:=x2;
variable xc:std_logic:=x3;
BEGIN
IF (choice'event and choice='1') THEN
IF on_off='0' THEN
count_c<="000";
ELSIF
count_c="101" THEN
count_c<="001";
ELSE
count_c<=count_c+1;
END IF;
END IF;
case count_c is
when "000" => xa:='0';xb:='0';xc:='0';
when "001" => xa:='1';xb:='1';xc:='1';
when "010" => xa:='1';xb:='0';xc:='0';
when "011" => xa:='0';xb:='1';xc:='0';
when "100" => xa:='0';xb:='0';xc:='1';
when others => xa:='0';xb:='1';xc:='1';
end case;
x1<=xa;
x2<=xb;
x3<=xc;
end process;
count<=count_c;
process(clk)
variable sign_s :std_logic;
begin
IF (hold'event and hold='1') THEN
sign_s := not sign_s;
end if;
sign<=sign_s;
end process;
signout<=sign;
mROCESS (clk)
BEGIN
if( sign='1' )then
if( x1='1')then
if(clk'event and clk='1') then
if(time="11110")then
x1<='0';
if(time="11110")then
time<="00000";
end if;
else
time<=time+1;
end if;
end if;
elsif( x1='0' and x2='1')then
if(clk'event and clk='1') then
if(time="01111")then
x2<='0';
if(time="01111")then
time<="00000";
end if;
else
time<=time+1;
end if;
end if;
elsif( x1='0' and x2='0' and x3='1' )then
if(clk'event and clk='1') then
if(time="10100")then
x3<='0';
if(time="10100")then
time<="00000";
end if;
else
time<=time+1;
end if;
end if;
end if;
end if;
END PROCESS ;
END a;
不明白小编到底想做什么?
如果仅仅是要把x1,x2,x3 的值赋给x11,x22,x33,那很简单啊
x11<=x1;
x22<=x2;
x33<=x3;
就行了
但是你这段代码实在令人费解。
第二个process中,用clk做敏感列表,却用hold做时钟。这种写法是错误的
第三个process也有问题,既然用clk做时钟,process里一开头就应该写
if(clk='1' and clk'event)
小编再好好看看vhdl的书吧,把一些基本概念弄清楚
感觉这代码很难看明白 不知是笔误还是显示有问题
问的到底是什么,意思没搞懂
不明白 lz多看点书
