I have my simple code in VDHL that seperates digit from 2-digit number, but when testing, my seperated digits remain unsigned (u). I have a hunch that the problem may be in the types of variables, when I use operations on them that they do not support. I use ghdl with gtkwave Variables in gtkwave
--FULL LOGIC--
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity DigitSeparator is
port(
value: in unsigned(6 downto 0);
leastSingnificantDigit: out unsigned(3 downto 0);
mostSignificantDigit: out unsigned(3 downto 0)
);
end entity DigitSeparator;
architecture DigitSeparator of DigitSeparator is
begin
-- Set the outputs to 1111 1111 if the input is greater than 99
process(value)
begin
if value > 99 then
leastSingnificantDigit <= "1111";
mostSignificantDigit <= "1111";
else
leastSingnificantDigit <= value mod 10;
mostSignificantDigit <= value / 10;
end if;
end process;
end architecture DigitSeparator;
--TEST BENCH--
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity DigitSeparatorTB is
end entity DigitSeparatorTB;
architecture DigitSeparatorTB of DigitSeparatorTB is
component DigitSeparator
port(
value: in unsigned(6 downto 0);
leastSingnificantDigit: out unsigned(3 downto 0);
mostSignificantDigit: out unsigned(3 downto 0)
);
end component DigitSeparator;
signal value: unsigned(6 downto 0) := "0110000";
signal leastSingnificantDigit: unsigned(3 downto 0);
signal mostSignificantDigit: unsigned(3 downto 0);
begin
kaka: DigitSeparator port map (value, leastSingnificantDigit, mostSignificantDigit);
value <= "0110000", "1111111" after 100 ns, "1000010" after 200 ns;
end architecture DigitSeparatorTB;
DigitSeparator
component in the testbench to the entity. TheDigitSeparator
entity has syntax errors.leastSingnificantDigit <= value mod 10;
results in a 7 bit result, not 4. So I suspect you have not even compiled theDigitSeparator
code.