data/full_repos/permissive/181738725/wavetrace/verilog/lib/stream/sim/rate_ctrl.v
 line:35: before: "real"
1: b'%Error: data/full_repos/permissive/181738725/wavetrace/verilog/lib/stream/sim/rate_ctrl.v:91: Unsupported: Seeding $random doesn\'t map to C++, use $c("srand")\n        rnd     = $unsigned($random(seed_i)) % 100;\n                            ^~~~~~~\n%Error: Internal Error: data/full_repos/permissive/181738725/wavetrace/verilog/lib/stream/sim/rate_ctrl.v:91: ../V3Ast.cpp:358: Null item passed to setOp1p\n        rnd     = $unsigned($random(seed_i)) % 100;\n                  ^~~~~~~~~\n                        ... See the manual and https://verilator.org for more assistance.\n'
module rate_ctrl #(
  parameter real MinThroughput = 0,
  parameter real MaxThroughput = 100,
  parameter      Period        = 1000,
  parameter      Seed          = 1)
(
  input      clk,
  input      rst,
  output reg active,
  input      ack
);




  integer  seed_i;
  initial begin
    seed_i = Seed;
  end





  localparam real Slope = (MaxThroughput - MinThroughput) / ($itor(Period) / 4);

  localparam RampUp   = 0,
             HoldHigh = 1,
             RampDown = 2,
             HoldLow  = 3;

  reg [1:0] state;
  real      rate, delta;
  integer   rnd, count;
  always @(posedge clk) begin
    if (rst) begin
      count  <= 0;
      state  <= RampUp;
      rate   <= MinThroughput;
      active <= 0;
    end else begin


      if (count == Period/4 - 1) begin
        state <= (state == HoldLow) ? RampUp : state + 1;
        count <= 0;
      end else begin
        count <= count + 1;
      end


      delta = (state == RampUp)   ?  Slope:
              (state == RampDown) ? -Slope : 0;
      rate <= rate + delta;


      if (!active || ack) begin
        rnd     = $unsigned($random(seed_i)) % 100;
        active <= (rnd < rate) ? 1 : 0;
      end
    end
  end

endmodule
module rate_ctrl #(
  parameter real MinThroughput = 0,
  parameter real MaxThroughput = 100,
  parameter      Period        = 1000,
  parameter      Seed          = 1)
(
  input      clk,
  input      rst,
  output reg active,
  input      ack
);





  integer  seed_i;
  initial begin
    seed_i = Seed;
  end





  localparam real Slope = (MaxThroughput - MinThroughput) / ($itor(Period) / 4);

  localparam RampUp   = 0,
             HoldHigh = 1,
             RampDown = 2,
             HoldLow  = 3;

  reg [1:0] state;
  real      rate, delta;
  integer   rnd, count;
  always @(posedge clk) begin
    if (rst) begin
      count  <= 0;
      state  <= RampUp;
      rate   <= MinThroughput;
      active <= 0;
    end else begin


      if (count == Period/4 - 1) begin
        state <= (state == HoldLow) ? RampUp : state + 1;
        count <= 0;
      end else begin
        count <= count + 1;
      end


      delta = (state == RampUp)   ?  Slope:
              (state == RampDown) ? -Slope : 0;
      rate <= rate + delta;


      if (!active || ack) begin
        rnd     = $unsigned($random(seed_i)) % 100;
        active <= (rnd < rate) ? 1 : 0;
      end
    end
  end

endmodule