Hola

Recién terminé este PWM súper sencillo y pues ya está sintetizado y funcionando como esperaba. Me gustaría preguntarles si ustedes le ven áreas de mejora al código... si está ocupando mucho de la FPGA, o si se puede hacer más rápido, optimizarlo, no sé, los típicos comentarios que luego los gurús nos hacen a los noobs jejeje
El PWM solito ocupa los siguientes porcentajes de la Cyclone IV...
Flow Status Successful - Wed Apr 18 18:28:34 2012
Quartus II 32-bit Version 11.1 Build 259 01/25/2012 SP 2 SJ Web Edition
Revision Name pwm_test
Top-level Entity Name PWM
Family Cyclone IV E
Device EP4CE22F17C6
Timing Models Final
Total logic elements 128 / 22,320 ( < 1 % )
Total combinational functions 128 / 22,320 ( < 1 % )
Dedicated logic registers 33 / 22,320 ( < 1 % )
Total registers 33
Total pins 66 / 154 ( 43 % )
Total virtual pins 0
Total memory bits 0 / 608,256 ( 0 % )
Embedded Multiplier 9-bit elements 0 / 132 ( 0 % )
Total PLLs 0 / 4 ( 0 % )
Y el código es...
--PWM
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity PWM is
port (
clk : in std_logic;
period : IN STD_LOGIC_VECTOR (31 downto 0);
duty_cycle : IN STD_LOGIC_VECTOR (31 downto 0);
--count_out : OUT STD_LOGIC_VECTOR (31 DOWNTO 0); --Debug
pwm_out : out STD_LOGIC
);
end PWM;
architecture behavior of PWM is
begin
process(clk, period, duty_cycle)
variable count : std_logic_vector(31 downto 0) := "00000000000000000000000000000000";
begin
if rising_edge(clk) then
count := count + 1;
if(count >= period) then
count := "00000000000000000000000000000000";
end if;
if(count >= duty_cycle) then
pwm_out <= '0';
else
pwm_out <= '1';
end if;
end if;
--Debug
--count_out <= count;
end process;
end behavior;Gracias =)