]> rtime.felk.cvut.cz Git - fpga/pwm.git/blobdiff - pwm.vhd
Resets changed from asynchronous to synchronous.
[fpga/pwm.git] / pwm.vhd
diff --git a/pwm.vhd b/pwm.vhd
index 3590d5423041628c317a966c69c3bf6069edae3d..4ac8765f48e1ece55a00f0b2bb3c7d2262d29b9d 100644 (file)
--- a/pwm.vhd
+++ b/pwm.vhd
@@ -53,12 +53,13 @@ begin
   -- Peripheral register
   PWM_REGISTER : process (clk, reset)
   begin
-    if reset = '1' then
-      reg <= (others => '0');
-
-    elsif rising_edge(clk) then
-      if we = '1' then
-        reg <= din;
+    if rising_edge(clk) then
+      if reset = '1' then
+        reg <= (others => '0');
+      else
+        if we = '1' then
+          reg <= din;
+        end if;
       end if;
     end if;
   end process;
@@ -69,18 +70,20 @@ begin
   -- with next clk edge. Pwm output is delayed by one clock.
   PWM_GEN : process (clk, reset)
   begin
-    if reset = '1' then
-      pwm <= '0';
-      
-    elsif rising_edge(clk) then
-      if pwm_cyc = '1' then
-        cmp <= reg;
-      end if;
-      
-      if pwm_cnt < cmp then
-        pwm <= '1';
-      else
+    if rising_edge(clk) then
+      if reset = '1' then
         pwm <= '0';
+
+      else  
+        if pwm_cyc = '1' then
+          cmp <= reg;
+        end if;
+        
+        if pwm_cnt < cmp then
+          pwm <= '1';
+        else
+          pwm <= '0';
+        end if;
       end if;
     end if;
   end process;