I'm very new to VHDL and I would like to get some help. You see, we were told by our instructor to code the division of binary (by converting the binary to integer first) and if the divisor is zero, then the output error waveform will be displayed in the simulation. Here is my code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity division_in is
Port ( A : in STD_LOGIC_VECTOR (7 downto 0);
B : in STD_LOGIC_VECTOR (7 downto 0);
clk : in STD_LOGIC;
Y : out STD_LOGIC_VECTOR (7 downto 0);
err : out STD_LOGIC);
end division_in;
architecture Behavioral of division_in is
begin
process(clk)
begin
if clk='1' and clk'event then -- error here
Y <= conv_std_logic_vector(conv_integer(A)/conv_integer(B),8);
err <= '0';
elsif B = 0 then
err <= '1';
end if;
end process;
end Behavioral;
When I try to use the "check syntax" in the Xilinx ISE 9.1i (which was used by the university), there are no syntax errors that displayed on the transcript. I could even use the testbench waveform to simulate it with no problems. However, when I import this code to Quartus II, I got 5 errors in the message especially in this one:
Error (10818): Can't infer register for "err" at division_in.vhd(45) because it does not hold its value outside the clock edge
I don't know what I've done wrong in copying the exact code from the Xilinx to Quartus but a little help is much appreciated on why I got this error on Quartus II but not on Xilinx ISE 9.1i. Since Xilinx ISE is already not compatible to my laptop anymore, I just use Quartus II instead since it also has a simulation feature which is a "Vector Waveform File" simulation.
clk
changes. Your logic then does this: if there was a rising edge, carry out the pretend division and seterr
to 0; otherwise (ie. if there was a falling edge) and ifB
was 0 on that falling edge, seterr
to 1. Not what you want. – EMLerr
signal, which cannot be mapped to real hardware structures. There are a lot of language constructs in VHDL which can only be used in simulation but not in synthesis. Back in those days when VHDL was invented, no one was even thinking about using it to do synthesis :-) – Juergen