OpenCores
URL https://opencores.org/ocsvn/turbo8051/turbo8051/trunk

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [lib/] [stat_counter.v] - Diff between revs 11 and 50

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 11 Rev 50
Line 59... Line 59...
  (
  (
   // Clock and Reset Signals
   // Clock and Reset Signals
   sys_clk,
   sys_clk,
   s_reset_n,
   s_reset_n,
 
 
   count_trigger,
   count_inc,
 
   count_dec,
 
 
   reg_sel,
   reg_sel,
   reg_wr_data,
   reg_wr_data,
   reg_wr,
   reg_wr,
 
 
Line 77... Line 78...
   //-------------------- Parameters -------------------------------------
   //-------------------- Parameters -------------------------------------
 
 
   // ------------------- Clock and Reset Signals ------------------------
   // ------------------- Clock and Reset Signals ------------------------
   input                     sys_clk;
   input                     sys_clk;
   input                     s_reset_n;
   input                     s_reset_n;
   input                     count_trigger;
   input                     count_inc; // Counter Increment
 
   input                     count_dec; // counter decrement, assuption does not under flow
   input                     reg_sel;
   input                     reg_sel;
   input                     reg_wr;
   input                     reg_wr;
   input  [CWD-1:0]          reg_wr_data;
   input  [CWD-1:0]          reg_wr_data;
   output                    cntr_intr;
   output                    cntr_intr;
   output [CWD-1:0]          cntrout;
   output [CWD-1:0]          cntrout;
Line 101... Line 103...
   else begin
   else begin
      if (reg_sel && reg_wr) begin
      if (reg_sel && reg_wr) begin
         reg_trig_cntr <= reg_wr_data;
         reg_trig_cntr <= reg_wr_data;
      end
      end
      else begin
      else begin
         if (count_trigger)
         if (count_inc && count_dec)
 
            reg_trig_cntr <= reg_trig_cntr;
 
         else if (count_inc)
              reg_trig_cntr <= reg_trig_cntr + 1'b1;
              reg_trig_cntr <= reg_trig_cntr + 1'b1;
 
         else if (count_dec)
 
              reg_trig_cntr <= reg_trig_cntr - 1'b1;
         else
         else
            reg_trig_cntr <= reg_trig_cntr;
            reg_trig_cntr <= reg_trig_cntr;
      end
      end
   end
   end
end
end
assign cntr_intr = ((reg_trig_cntr + 1) == 'h0 && count_trigger) ;
// only increment overflow is assumed  
 
// decrement underflow is not handled 
 
assign cntr_intr = ((reg_trig_cntr + 1) == 'h0 && count_inc) ;
 
 
assign cntrout = reg_trig_cntr;
assign cntrout = reg_trig_cntr;
 
 
endmodule // must_stat_counter
endmodule // must_stat_counter
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.