में एक लचीला/जेनेरिक डिकोडर के लिए विचार मैं चयनकर्ता और बिटोडेड आउटपुट सिग्नल के बिट्स की संख्या को बदलने के दौरान मेरे लिए उपयोग करने के लिए पर्याप्त लचीला है जो एक डिकोडर बनाना चाहता हूं।वीएचडीएल
तो, बजाय एक स्थिर होने का (फिक्स्ड इनपुट/आउटपुट आकार) डिकोडर कुछ इस तरह दिखता है कि:
entity Address_Decoder is
Generic
(
C_INPUT_SIZE: integer := 2
);
Port
(
input : in STD_LOGIC_VECTOR (C_INPUT_SIZE-1 downto 0);
output : out STD_LOGIC_VECTOR ((2**C_INPUT_SIZE)-1 downto 0);
clk : in STD_LOGIC;
rst : in STD_LOGIC
);
end Address_Decoder;
architecture Behavioral of Address_Decoder is
begin
DECODE_PROC:
process (clk)
begin
if(rising_edge(clk)) then
if (rst = '1') then
output <= conv_std_logic_vector(0, output'length);
else
case (input) is
for i in 0 to (2**C_INPUT_SIZE)-1 generate
begin
when (i = conv_integer(input)) => output <= conv_std_logic_vector((i*2), output'length);
end generate;
when others => output <= conv_std_logic_vector(0, output'length);
end case;
end if;
end if;
end process;
end Behavioral;
:
entity Address_Decoder is
Generic
(
C_INPUT_SIZE: integer := 2
);
Port
(
input : in STD_LOGIC_VECTOR (C_INPUT_SIZE-1 downto 0);
output : out STD_LOGIC_VECTOR ((2**C_INPUT_SIZE)-1 downto 0);
clk : in STD_LOGIC;
rst : in STD_LOGIC
);
end Address_Decoder;
architecture Behavioral of Address_Decoder is
begin
process(clk)
begin
if rising_edge(clk) then
if (rst = '1') then
output <= "0000";
else
case <input> is
when "00" => <output> <= "0001";
when "01" => <output> <= "0010";
when "10" => <output> <= "0100";
when "11" => <output> <= "1000";
when others => <output> <= "0000";
end case;
end if;
end if;
end process;
end Behavioral;
कुछ है कि और अधिक लचीला/सामान्य है, कि इस तरह दिखता है है
मुझे पता है कि यह कोड मान्य नहीं है और "कब" परीक्षण के मामले स्थिरांक होना चाहिए और मैं इस तरह के केस स्टेटमेंट के बीच उत्पन्न करने के लिए उपयोग नहीं कर सकता, लेकिन यह दिखाता है कि मैं क्या कर रहा हूं : मेरी जरूरतों को बढ़ाने के लिए पर्याप्त एक इकाई पर्याप्त है।
मैं बिना किसी सफलता के इस समस्या के लिए एक सुरुचिपूर्ण समाधान खोजने की कोशिश कर रहा हूं, इसलिए, मैं किसी भी सुझाव के लिए खुला हूं।
अग्रिम धन्यवाद, एरिक
'numeric_std' एक प्रदान करता है फ़ंक्शन जो एक निर्दिष्ट संख्या से वेक्टर को स्थानांतरित करता है। तो आप संभावित रूप से वेक्टर '0 =>' 1 ', अन्य =>' 0 '' को छोड़कर (इनपुट नंबर -1) को स्थानांतरित कर सकते हैं। –