好吧,我的同學弄清楚如何使用MOD功能進行編碼的問題。下面的代碼:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec_to_bcd is
Port (Ina : in STD_LOGIC_VECTOR (9 downto 0);
clk : in STD_LOGIC;
Outa : out STD_LOGIC_VECTOR (15 downto 0);
err : out STD_LOGIC);
end dec_to_bcd;
architecture Behavioral of dec_to_bcd is
begin
process (clk)
begin
if clk='1' and clk'event then
if (conv_integer(Ina) >= 1024) then
err <= '1';
else
Outa(15 downto 12) <= conv_std_logic_vector((conv_integer(Ina)/1000),4);
Outa(11 downto 8) <= conv_std_logic_vector((conv_integer(Ina)/100)MOD 10,4);
Outa(7 downto 4) <= conv_std_logic_vector((conv_integer(Ina)/10)MOD 10,4);
Outa(3 downto 0) <= conv_std_logic_vector((conv_integer(Ina))MOD 10,4);
end if;
end if;
end process;
end Behavioral;
由於我們的介紹在課堂上VHDL只使用模擬,那麼我們不知道這是否是「合成的」。有關如何改進此代碼的任何建議受到熱烈歡迎。謝謝:)
那麼,我的同學想出了它會怎麼做。他在部門使用MODULO功能。我會在這裏上傳代碼,但是因爲我們在課堂上介紹VHDL只使用模擬,所以我們不知道它是否是「可合成的」。 – c2s1
一個簡單的搜索就會顯示你幾十個關於BCD轉換器的問題。 –
一般作業問題,沒有特定的VHDL語言問題,沒有研究完成 – EML