I'm new to VHDL and I'm having a problem with my code that I can't seem to fix. We're supposed to do this using either selected signal assignment or table lookup. Mine is kind of a combination of the two since we are supposed to use don't cares for inputs that will not happen.
The code is basically supposed to give the same output for either 2's complement input or offset binary. So, for instance, decimal number 7 is "1111" in offset binary and "0111" in 2's complement. Both forms should generate an output of "1111100000" depending on the value of the switch oe ('1' for offset binary, '0' for 2's complement).
I've debugged my code as much as I can at this level and I do not understand what I'm doing wrong.
Active-HDL is currently giving me errors at lines 48 and 55. I'm getting two "simple expression expected" errors.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity pitch_decoder_2 is
port(d, c, b, a : in std_logic;
ob : in std_logic;
led : out std_logic_vector(9 downto 0));
end pitch_decoder_2;
architecture myarch of pitch_decoder_2 is
type tbl is array (15 downto 0) of std_logic_vector(9 downto 0);
constant table : tbl := (
"1111100000", -- 7
"1111100000", -- 6
"1111100000", -- 5
"1111100000", -- 4
"0111100000", -- 3
"0011100000", -- 2
"0001100000", -- 1
"0000100000", -- 0
"0000110000", -- -1
"0000111000", -- -2
"0000111100", -- -3
"0000111110", -- -4
"0000111111", -- -5
"0000111111", -- -6
"0000111111", -- -7
"0000111111"); -- -8
signal input : std_logic_vector(3 downto 0);
signal tmp : std_logic_vector(2 downto 0);
begin
input <= std_logic_vector' (d, c, b, a);
tmp <= std_logic_vector' (c, b, a);
with input select
led <= table(to_integer(unsigned(d & tmp)))
when "0000" | "0001" | "0010" | "0011" |
"0100" | "0101" | "0110" | "0111" |
"1000" | "1001" | "1010" | "1011" |
"1100" | "1101" | "1110" | "1111"
and ob = '1',
table(to_integer(unsigned(not d & tmp)))
when "0000" | "0001" | "0010" | "0011" |
"0100" | "0101" | "0110" | "0111" |
"1000" | "1001" | "1010" | "1011" |
"1100" | "1101" | "1110" | "1111"
and ob = '0',
"----------" when others;
end myarch;
Also, if you have any tips on how I can improve the code while maintaining the assignment instructions, please feel free to suggest anything.