Look at this piece of code (flip image on X)
PROCESS(iCLK)
BEGIN
IF (rising_edge(iCLK)) THEN
-- Mise en mémoire du pixel
ram(640*IdxC + PixX) <= PIXIN;
-- Choix traitement
IF (SWITCH='1') THEN
PIXOUT <= ram(640*((IdxC + 1) mod 2) + PixX);
ELSE
PIXOUT <= ram(640*(2-IdxC) - PixX + 1);
END IF;
END IF;
END PROCESS;
When I compile it, the overall project takes about 15% of the logic elements and 13% of total memory bits (QuartusII on cyclone III). If I change the code to
PROCESS (iCLK)
BEGIN
IF(rising_edge(iCLK)) THEN
-- Mise en mémoire du pixel
ram(640*IdxC + PixX) <= PIXIN;
-- Choix traitement
IF (SWITCH='1') THEN
PIXOUT <= ram(640*((IdxC + 1) mod 2) + PixX);
ELSE
IF (PixX > 1 AND PixX < 640) THEN
PIXOUT <= ram(640*(2-IdxC) - PixX + 1);
ELSE
PIXOUT <= x"111";
END IF;
END IF;
END IF;
END PROCESS;
I get
Error (276003): Cannot convert all sets of registers into RAM megafunctions when creating nodes. The resulting number of registers remaining in design exceeds the number of registers in the device or the number specified by the assignment max_number_of_registers_from_uninferred_rams. This can cause longer compilation time or result in insufficient memory to complete Analysis and Synthesis
That seems that I cannot fit anymore the design. I don't believe this. Is there a bug on the compiler or I'm doing something wrong?
I have the Quartus II web edition
Just putting some --
comments on the lines like this and it compiles again:
PROCESS (iCLK)
BEGIN
IF (rising_edge(iCLK)) THEN
-- Mise en mémoire du pixel
ram(640*IdxC + PixX) <= PIXIN;
-- Choix traitement
IF (SWITCH='1') THEN
PIXOUT <= ram(640*((IdxC + 1) mod 2) + PixX);
ELSE
-- IF (PixX > 1 AND PixX < 640) THEN
PIXOUT <= ram(640*(2-IdxC) - PixX + 1);
-- ELSE
-- PIXOUT <= x"111";
-- END IF;
END IF;
END IF;
END PROCESS;
This code works with megafunction RAM 2 port:
PROCESS (iCLK)
BEGIN
IF rising_edge(iCLK) THEN
-- Ecrire linéairement dans la RAM le pixel de la cam
RAMWRITE <= TO_UNSIGNED(640*IdxC + PixX - 1, 11);
-- Choix traitement
IF (SWITCH='1') THEN
RAMREAD <= TO_UNSIGNED(640*((IdxC + 1) mod 2) + PixX - 1, 11);
PIXOUT <= PIXMEM;
ELSE
RAMREAD <= TO_UNSIGNED(640*(2-IdxC) - PixX, 11);
IF (PixX > 1 AND PixX < 640) THEN
PIXOUT <= PIXMEM;
ELSE
PIXOUT <= x"FFF";
END IF;
END IF;
END IF;
END PROCESS;
else PIXOUT <= ram(some addr) or x"111";
will do... \$\endgroup\$