---------------------------------- -- first component for xor operation…
- User
-- first component for xor operation
library ieee; use ieee.std_logic_1164.all;
entity xor_get is port(input1,input2 : in std_logic_vector(15 downto 0); output : out std_logic_vector(15 downto 0)); end xor_get;
architecture Behavioral of xor_get is begin output <= input1 xor input2; end Behavioral;
-- second component for decoder 4x16
library ieee; use ieee.std_logic_1164.all;
entity decoder_4x16 is port(input : in std_logic_vector(3 downto 0); output : out std_logic_vector(15 downto 0)); end decoder_4x16;
architecture Behavioral of decoder_4x16 is begin process(input) begin case input is when "0000" => output <= "0000000000000001"; when "0001" => output <= "0000000000000010"; when "0010" => output <= "0000000000000100"; when "0011" => output <= "0000000000001000"; when "0100" => output <= "0000000000010000"; when "0101" => output <= "0000000000100000"; when "0110" => output <= "0000000001000000"; when "0111" => output <= "0000000010000000"; when "1000" => output <= "0000000100000000"; when "1001" => output <= "0000001000000000"; when "1010" => output <= "0000010000000000"; when "1011" => output <= "0000100000000000"; when "1100" => output <= "0001000000000000"; when "1101" => output <= "0010000000000000"; when "1110" => output <= "0100000000000000"; when "1111" => output <= "1000000000000000"; when others => output <= "0000000000000000"; end case; end process; end Behavioral;
-- main component
library ieee; use ieee.std_logic_1164.all;
entity main is port(input_1,input_2 : in std_logic_vector(3 downto 0); xorKey : in std_logic_vector(15 downto 0); output1,output2 : out std_logic_vector(15 downto 0)); end main;
architecture Behavioral of main is
codesignal decoder1,decoder2: std_logic_vector(15 downto 0); component xor_get is port(input1,input2 : in std_logic_vector(15 downto 0); output : out std_logic_vector(15 downto 0)); end component; component decoder_4x16 is port(input : in std_logic_vector(3 downto 0); output : out std_logic_vector(15 downto 0)); end component; begin L0 : decoder_4x16 port map(input_1,decoder1); L1 : decoder_4x16 port map(input_2,decoder2); L2 : xor_get port map(decoder1,xorKey,output1); L3 : xor_get port map(decoder2,xorKey,output2); end Behavioral; - Assistant
To find the inputs that led to the given output, we must first understand the VHDL description provided.
The main component takes two 4-bit inputs (input_1 and input_2) and a 16-bit input (xorKey), which together produce two 16-bit outputs (output1 and output2). The outputs are calculated as follows:
- User
write out the complete truth table
- Assistant
Here's the complete truth table for the 4x16 decoder, as described in the given VHDL:
pythondecoder_truth_table = { "0000": "0000000000000001", "0001": "0000000000000010", "0010": "0000000000000100", "0011": "0000000000001000", "0100": "0000000000010000", "0101": "0000000000100000", "0110": "0000000001000000", "0111": "0000000010000000", "1000": "0000000100000000", "1001": "0000001000000000", "1010": "0000010000000000", "1011": "0000100000000000", "1100": "0001000000000000", "1101": "0010000000000000", "1110": "0100000000000000", "1111": "1000000000000000" }This table maps 4-bit inputs to their corresponding 16-bit outputs. For example, an input of "0000" corresponds to an output of "0000000000000001".
- User
I dont think this works out because output in the find_decoder_input function can be something like 0111001110111100 which is not in the truthtable
- Assistant
You are correct; my initial approach overlooked the possibility of having outputs that didn't perfectly match the decoder outputs. Based on your observation, a different approach is needed.