data/full_repos/permissive/187464337/stopwatch/stopwatch.v
1: b'%Warning-MULTITOP: data/full_repos/permissive/187464337/stopwatch/stopwatch.v:101: Multiple top level modules\n                                                                                 : ... Suggest see manual; fix the duplicates, or use --top-module to select top.\n                   ... Use "/* verilator lint_off MULTITOP */" and lint_on around source to disable this message.\n                                                                                 : ... Top module \'stopwatch_counter\'\nmodule stopwatch_counter(\n       ^~~~~~~~~~~~~~~~~\n                                                                                 : ... Top module \'ssd\'\nmodule ssd(digit, out);\n       ^~~\n%Warning-WIDTH: data/full_repos/permissive/187464337/stopwatch/stopwatch.v:55: Operator ADD expects 19 bits on the RHS, but RHS\'s VARREF \'counting_enable\' generates 1 bits.\n                                                                             : ... In instance stopwatch_counter\n         counter = counter + counting_enable;\n                           ^\n%Error: Exiting due to 2 warning(s)\n'
module stopwatch_counter(
   clock, min_higher_display, min_lower_display, s_higher_display,
   s_lower_display, ms_higher_display, ms_lower_display, key_start_pause,
   key_reset, key_freeze_resume
);
   parameter delay = 500000;
   parameter two_ms_delay = 100000;
   input clock, key_start_pause, key_reset, key_freeze_resume;


   output reg [3:0] min_higher_display, min_lower_display, s_higher_display,
      s_lower_display, ms_higher_display, ms_lower_display;

   reg [18:0] counter;
   reg counting_enable, display_frozen;


   reg [31:0] enable_count, freeze_count;

   reg [3:0] min_higher, min_lower, s_higher, s_lower, ms_higher, ms_lower;

   initial begin
      counter <= 0;
      min_higher <= 0;
      min_lower <= 0;
      s_higher <= 0;
      s_lower <= 0;
      ms_higher <= 0;
      ms_lower <= 0;
      counting_enable <= 0;
      display_frozen <= 0;
   end

   always @(posedge clock) begin
      enable_count = key_start_pause ? 0 : enable_count + 1;
      freeze_count = key_freeze_resume ? 0 : freeze_count + 1;


      if (enable_count == two_ms_delay)
         counting_enable = ~counting_enable;
      if (freeze_count == two_ms_delay)
         display_frozen = ~display_frozen;
         
      if (~key_reset) begin
         counter = 0;
         counting_enable = 0;
         display_frozen = 0;
         min_higher = 0;
         min_lower = 0;
         s_higher = 0;
         s_lower = 0;
         ms_higher = 0;
         ms_lower = 0;
      end else begin
         counter = counter + counting_enable;
         if (counter == delay) begin
            counter = 0;
            ms_lower = ms_lower + 1'b1;

            if (ms_lower == 10) begin
               ms_lower = 0;
               ms_higher = ms_higher + 1'b1;

               if (ms_higher == 10) begin
                  ms_higher = 0;
                  s_lower = s_lower + 1'b1;

                  if (s_lower == 10) begin
                     s_lower = 0;
                     s_higher = s_higher + 1'b1;

                     if (s_higher == 6) begin
                        s_higher = 0;
                        min_lower = min_lower + 1'b1;

                        if (min_lower == 10) begin
                           min_lower = 0;
                           min_higher = min_higher + 1'b1;

                           if (min_higher == 6)
                              min_higher = 0;
                        end
                     end
                  end
               end
            end
         end
      end

      if (~display_frozen) begin
         min_higher_display = min_higher;
         min_lower_display = min_lower;
         s_higher_display = s_higher;
         s_lower_display = s_lower;
         ms_higher_display = ms_higher;
         ms_lower_display = ms_lower;
      end
   end
endmodule
module stopwatch_counter(
   clock, min_higher_display, min_lower_display, s_higher_display,
   s_lower_display, ms_higher_display, ms_lower_display, key_start_pause,
   key_reset, key_freeze_resume
);

   parameter delay = 500000;
   parameter two_ms_delay = 100000;
   input clock, key_start_pause, key_reset, key_freeze_resume;


   output reg [3:0] min_higher_display, min_lower_display, s_higher_display,
      s_lower_display, ms_higher_display, ms_lower_display;

   reg [18:0] counter;
   reg counting_enable, display_frozen;


   reg [31:0] enable_count, freeze_count;

   reg [3:0] min_higher, min_lower, s_higher, s_lower, ms_higher, ms_lower;

   initial begin
      counter <= 0;
      min_higher <= 0;
      min_lower <= 0;
      s_higher <= 0;
      s_lower <= 0;
      ms_higher <= 0;
      ms_lower <= 0;
      counting_enable <= 0;
      display_frozen <= 0;
   end

   always @(posedge clock) begin
      enable_count = key_start_pause ? 0 : enable_count + 1;
      freeze_count = key_freeze_resume ? 0 : freeze_count + 1;


      if (enable_count == two_ms_delay)
         counting_enable = ~counting_enable;
      if (freeze_count == two_ms_delay)
         display_frozen = ~display_frozen;
         
      if (~key_reset) begin
         counter = 0;
         counting_enable = 0;
         display_frozen = 0;
         min_higher = 0;
         min_lower = 0;
         s_higher = 0;
         s_lower = 0;
         ms_higher = 0;
         ms_lower = 0;
      end else begin
         counter = counter + counting_enable;
         if (counter == delay) begin
            counter = 0;
            ms_lower = ms_lower + 1'b1;

            if (ms_lower == 10) begin
               ms_lower = 0;
               ms_higher = ms_higher + 1'b1;

               if (ms_higher == 10) begin
                  ms_higher = 0;
                  s_lower = s_lower + 1'b1;

                  if (s_lower == 10) begin
                     s_lower = 0;
                     s_higher = s_higher + 1'b1;

                     if (s_higher == 6) begin
                        s_higher = 0;
                        min_lower = min_lower + 1'b1;

                        if (min_lower == 10) begin
                           min_lower = 0;
                           min_higher = min_higher + 1'b1;

                           if (min_higher == 6)
                              min_higher = 0;
                        end
                     end
                  end
               end
            end
         end
      end

      if (~display_frozen) begin
         min_higher_display = min_higher;
         min_lower_display = min_lower;
         s_higher_display = s_higher;
         s_lower_display = s_lower;
         ms_higher_display = ms_higher;
         ms_lower_display = ms_lower;
      end
   end
endmodule