------------------------------------------------------------------------------- -- Title : Ecriture d'une image en format ppm -- Project : ------------------------------------------------------------------------------- -- File : moniteurppm.vhd -- Author : -- Company : -- Last update : 2002/10/25 -- Platform : ------------------------------------------------------------------------------- -- Description : -- -- ------------------------------------------------------------------------------- -- Modification history : -- 1999/10/25 : created ------------------------------------------------------------------------------- LIBRARY std; USE std.textio.ALL; LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL; ENTITY ecriture IS GENERIC (nom_fichier : string := "output.ppm"; en_tete : IN string := "P3"; largeur : IN natural := 256; hauteur : IN natural := 256; couleur_max : IN natural := 255); PORT ( rouge : IN unsigned( 7 DOWNTO 0 ) ; vert : IN unsigned( 7 DOWNTO 0 ) ; bleu : IN unsigned( 7 DOWNTO 0 ) ; h : IN std_logic); -- horloge pour entrer les donnees END ecriture; ARCHITECTURE ecriture OF ecriture IS FILE fichier : text IS OUT nom_fichier; BEGIN -- ecriture ecr : PROCESS VARIABLE ligne : line; VARIABLE bon : boolean; CONSTANT Format_ligne: natural := 17; -- nombre d'octets par ligne du fichier CONSTANT marque : string(1 TO 8) := "# enserb"; VARIABLE autre_entree : boolean; CONSTANT nbr_pixels : natural := largeur * hauteur * 3; -- 512 * 512 = 262144 VARIABLE index : natural := 0; BEGIN ASSERT false REPORT "debut d'ecriture du fichier image filtree" SEVERITY note; write(ligne,en_tete); writeline(fichier,ligne); -- P2 write(ligne,marque); writeline(fichier,ligne); -- # ENSERB write( ligne, largeur); write(ligne,' '); write( ligne,hauteur); writeline(fichier,ligne); -- 512 512 write(ligne, couleur_max); writeline(fichier,ligne); -- 255 l1: LOOP WAIT UNTIL h'event AND h = '1' AND h'last_value= '0'; write(ligne,to_integer('0' & rouge)); writeline(fichier,ligne); write(ligne,to_integer('0' & vert)); writeline(fichier,ligne); write(ligne,to_integer('0' & bleu)); writeline(fichier,ligne); index := index + 3; IF index = nbr_pixels /4 THEN ASSERT false REPORT "Patience ... plus que 75%" SEVERITY note; END IF; IF index = nbr_pixels /2 THEN ASSERT false REPORT "Patience ... plus que 50%" SEVERITY note; END IF; IF index = nbr_pixels *3 /4 THEN ASSERT false REPORT "Patience ... plus que 25%" SEVERITY note; END IF; EXIT l1 WHEN index = nbr_pixels; END LOOP; ASSERT false REPORT "L'image au format ppm est disponible" SEVERITY note; WAIT; END PROCESS; END ecriture;