Maverick_ 15 3 марта, 2007 Опубликовано 3 марта, 2007 · Жалоба Здравствуйте! Программирую на VHDL. И возникли некоторые трудности Я моделирую схему, которая описана ниже, в Post-Rout моделировании получаются при разных частотах разные результаты. Не могу понять почему. library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity decline is Port ( clk : in std_logic; rst : in std_logic; count : out std_logic_vector (15 downto 0); outdec1 : out std_logic_vector (9 downto 0); Q : out std_logic_vector (4 downto 0); outdec0 : out std_logic_vector (7 downto 0) ); end decline; architecture Behavioral of decline is signal cnt : std_logic_vector (15 downto 0) := (others => '0'); signal dec1 : std_logic_vector (9 downto 0); signal dec0 : std_logic_vector (7 downto 0); begin process (clk,rst,cnt) begin if rst = '1' then cnt <= "0000000000000000" ; elsif (clk'event and clk = '1') then cnt <= cnt + "0000000000000001"; end if; count <= cnt; end process; process (clk,cnt,rst,dec0) variable Qint: std_logic_vector (4 downto 0); begin if rst = '1' then dec0 <= "00000000"; Qint := "00000"; elsif ( clk'event and clk ='1') then case cnt is when "0000000000000000" => dec0 <= "00000001"; when "0000000000000001" => dec0 <= "00000010"; when "0000000000000011" => dec0 <= "00000100"; when "0000000000000101" => dec0 <= "00001000"; when "0000000000000111" => dec0 <= "00010000"; when "0000000000001010" => dec0 <= "00100000"; when "0000000000001011" => dec0 <= "01000000"; when "0000000000001101" => dec0 <= "10000000"; when others => dec0 <= "00000000"; end case; if (dec0(2) = '1' and dec0(4) = '1') then Qint(0) := not(Qint(0)); elsif (dec0(2)= '1' and dec0(4) = '0') then Qint(0) := '1'; elsif (dec0(2)= '0' and dec0(4) = '1') then Qint(0) := '0'; else Qint(0) := Qint(0); end if; if (dec0(3) = '1' and dec0(6) = '1') then Qint(1) := not(Qint(0)); elsif (dec0(3)= '1' and dec0(6) = '0') then Qint(1) := '1'; elsif (dec0(3)= '0' and dec0(6) = '1') then Qint(1) := '0'; else Qint := Qint; end if; if (dec0(4) = '1' and dec0(7) = '1') then Qint(2) := not(Qint(2)); elsif (dec0(4)= '1' and dec0(7) = '0') then Qint(2) := '1'; elsif (dec0(4)= '0' and dec0(7) = '1') then Qint(2) := '0'; else Qint := Qint; end if; if (dec0(1) = '1' and dec0(3) = '1') then Qint(3) := not(Qint(3)); elsif (dec0(1)= '1' and dec0(3) = '0') then Qint(3) := '1'; elsif (dec0(1)= '0' and dec0(3) = '1') then Qint(3) := '0'; else Qint := Qint; end if; if (dec0(0) = '1' and dec0(2) = '1') then Qint(4) := not(Qint(4)); elsif (dec0(0)= '1' and dec0(2) = '0') then Qint(4) := '1'; elsif (dec0(0)= '0' and dec0(2) = '1') then Qint(4) := '0'; else Qint := Qint; end if; end if; Q <= Qint; outdec0 <= dec0; end process; process (clk,cnt,rst,dec1) begin if rst = '1' then dec1 <= "0000000000"; elsif ( clk'event and clk ='1') then case cnt is when "1011110110000000" => dec1 <= "0000000001"; when "1011111001111000" => dec1 <= "0000000010"; when "1011111110000000" => dec1 <= "0000000100"; when "1100000000000000" => dec1 <= "0000001000"; when "1111111011000000" => dec1 <= "0000010000"; when "1111111011100000" => dec1 <= "0000100000"; when "1111111100000000" => dec1 <= "0001000000"; when "1111111100100000" => dec1 <= "0010000000"; when "1111111101000000" => dec1 <= "0100000000"; when "1111111101100000" => dec1 <= "1000000000"; when others => dec1 <= "0000000000"; end case; end if; outdec1 <= dec1; end process; end behavioral; Ниже даю описание модели для моделирования LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.std_logic_unsigned.all; USE ieee.numeric_std.ALL; ENTITY test_vhd IS END test_vhd; ARCHITECTURE behavior OF test_vhd IS -- Component Declaration for the Unit Under Test (UUT) COMPONENT decline PORT( clk : IN std_logic; rst : IN std_logic; count : OUT std_logic_vector(15 downto 0); outdec1 : OUT std_logic_vector(9 downto 0); Q : OUT std_logic_vector (4 downto 0); outdec0 : OUT std_logic_vector(7 downto 0) ); END COMPONENT; --Inputs SIGNAL clk : std_logic := '0'; SIGNAL rst : std_logic := '0'; --Outputs SIGNAL count : std_logic_vector(15 downto 0); SIGNAL outdec1 : std_logic_vector(9 downto 0); SIGNAL Q : std_logic_vector (4 downto 0); SIGNAL outdec0 : std_logic_vector(7 downto 0); BEGIN -- Instantiate the Unit Under Test (UUT) uut: decline PORT MAP( clk => clk, rst => rst, count => count, outdec1 => outdec1, Q => Q, outdec0 => outdec0 ); clock_gen: process begin clk <= '0'; wait for 10 ns; clk <= '1'; wait for 10 ns; end process; reset_gen: process begin rst <= '1'; wait for 40 ns; rst <= '0'; wait; end process; END; При функциональном моделировании все работает правильно. Расскажите в чем разница между приведенной выше программой и ниже приведенной программой при синтезе library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity decline is Port ( clk : in std_logic; rst : in std_logic; count : out std_logic_vector (15 downto 0); outdec1 : out std_logic_vector (9 downto 0); Q : out std_logic_vector (4 downto 0); outdec0 : out std_logic_vector (7 downto 0) ); end decline; architecture Behavioral of decline is signal cnt : std_logic_vector (15 downto 0) := (others => '0'); signal dec1 : std_logic_vector (9 downto 0); begin process (clk,rst,cnt) begin if rst = '1' then cnt <= "0000000000000000" ; elsif (clk'event and clk = '1') then cnt <= cnt + "0000000000000001"; end if; count <= cnt; end process; process (clk,cnt,rst) variable dec0 : std_logic_vector (7 downto 0); variable Qint: std_logic_vector (4 downto 0); begin if rst = '1' then dec0 := "00000000"; Qint := "00000"; elsif ( clk'event and clk ='1') then case cnt is when "0000000000000000" => dec0 := "00000001"; when "0000000000000001" => dec0 := "00000010"; when "0000000000000011" => dec0 := "00000100"; when "0000000000000101" => dec0 := "00001000"; when "0000000000000111" => dec0 := "00010000"; when "0000000000001010" => dec0 := "00100000"; when "0000000000001011" => dec0 := "01000000"; when "0000000000001101" => dec0 := "10000000"; when others => dec0 := "00000000"; end case; if (dec0(2) = '1' and dec0(4) = '1') then Qint(0) := not(Qint(0)); elsif (dec0(2)= '1' and dec0(4) = '0') then Qint(0) := '1'; elsif (dec0(2)= '0' and dec0(4) = '1') then Qint(0) := '0'; else Qint(0) := Qint(0); end if; if (dec0(3) = '1' and dec0(6) = '1') then Qint(1) := not(Qint(0)); elsif (dec0(3)= '1' and dec0(6) = '0') then Qint(1) := '1'; elsif (dec0(3)= '0' and dec0(6) = '1') then Qint(1) := '0'; else Qint := Qint; end if; if (dec0(4) = '1' and dec0(7) = '1') then Qint(2) := not(Qint(2)); elsif (dec0(4)= '1' and dec0(7) = '0') then Qint(2) := '1'; elsif (dec0(4)= '0' and dec0(7) = '1') then Qint(2) := '0'; else Qint := Qint; end if; if (dec0(1) = '1' and dec0(3) = '1') then Qint(3) := not(Qint(3)); elsif (dec0(1)= '1' and dec0(3) = '0') then Qint(3) := '1'; elsif (dec0(1)= '0' and dec0(3) = '1') then Qint(3) := '0'; else Qint := Qint; end if; if (dec0(0) = '1' and dec0(2) = '1') then Qint(4) := not(Qint(4)); elsif (dec0(0)= '1' and dec0(2) = '0') then Qint(4) := '1'; elsif (dec0(0)= '0' and dec0(2) = '1') then Qint(4) := '0'; else Qint := Qint; end if; end if; Q <= Qint; outdec0 <= dec0; end process; process (clk,cnt,rst,dec1) begin if rst = '1' then dec1 <= "0000000000"; elsif ( clk'event and clk ='1') then case cnt is when "1011110110000000" => dec1 <= "0000000001"; when "1011111001111000" => dec1 <= "0000000010"; when "1011111110000000" => dec1 <= "0000000100"; when "1100000000000000" => dec1 <= "0000001000"; when "1111111011000000" => dec1 <= "0000010000"; when "1111111011100000" => dec1 <= "0000100000"; when "1111111100000000" => dec1 <= "0001000000"; when "1111111100100000" => dec1 <= "0010000000"; when "1111111101000000" => dec1 <= "0100000000"; when "1111111101100000" => dec1 <= "1000000000"; when others => dec1 <= "0000000000"; end case; end if; outdec1 <= dec1; end process; end behavioral; От себя замечу разница состоит в построении дешифратора. :( Ну какая именно не скажу Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
sazh 3 3 марта, 2007 Опубликовано 3 марта, 2007 · Жалоба Наверно имеет смысл сказать, чем они похожи: if (dec0(3) = '1' and dec0(6) = '1') then Qint(1) := not(Qint(0)); Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться