data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v
1: b'%Warning-REDEFMACRO: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:10: Redefining existing define: \'VERILATOR\', with different value: \n                     ... Use "/* verilator lint_off REDEFMACRO */" and lint_on around source to disable this message.\n%Warning-REDEFMACRO: Previous definition is here, with value: 1\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:82: Unsupported: Ignoring delay on this delayed statement.\n      #1;\n      ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:84: Unsupported: Ignoring delay on this delayed statement.\n      #1;\n      ^\n%Error: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:90: Unsupported or unknown PLI call: $dumpfile\n      $dumpfile("external_io_usage_tb.vcd");\n      ^~~~~~~~~\n%Error: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:91: Unsupported or unknown PLI call: $dumpvars\n      $dumpvars;\n      ^~~~~~~~~\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:106: Unsupported: Ignoring delay on this delayed statement.\n      #10;\n      ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:124: Unsupported: Ignoring delay on this delayed statement.\n      #reset_hold_period;\n      ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:131: Unsupported: Ignoring delay on this delayed statement.\n          #spi_bit_half_period;\n          ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:135: Unsupported: Ignoring delay on this delayed statement.\n          #spi_bit_half_period;\n          ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:142: Unsupported: Ignoring delay on this delayed statement.\n      #10;\n      ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:167: Unsupported: Ignoring delay on this delayed statement.\n          #spi_bit_half_period;\n          ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:171: Unsupported: Ignoring delay on this delayed statement.\n          #spi_bit_half_period;\n          ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:206: Unsupported: Ignoring delay on this delayed statement.\n          #spi_bit_half_period;\n          ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:211: Unsupported: Ignoring delay on this delayed statement.\n          #spi_bit_half_period;\n          ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:218: Unsupported: Ignoring delay on this delayed statement.\n      #reset_hold_period;\n      ^\n%Warning-STMTDLY: data/full_repos/permissive/132173046/src/tests/external_io_usage_tb.v:231: Unsupported: Ignoring delay on this delayed statement.\n      #100;\n      ^\n%Error: Exiting due to 2 error(s), 15 warning(s)\n'
module external_io_usage_tb();



  `define VERILATOR
  `define DEBUG_VERBOSE

  localparam spi_bit_half_period = 6;
  localparam reset_hold_period = 2;

  localparam JOB_CONFIG_WIDTH = 8;
  localparam DEVICE_CONFIG_WIDTH = 8;

  reg clk;
  reg reset_n;

  reg sck0;
  reg sdi0;
  reg cs0_n;

  reg sck1;
  reg sdi1;
  wire sdo1;
  reg cs1_n;

  wire [DEVICE_CONFIG_WIDTH-1:0] device_config;
  wire [JOB_CONFIG_WIDTH-1:0] job_config;

  wire core_reset_n;

  reg [7:0] shapool_match_flags;
  reg [31:0] shapool_result;
  reg shapool_success;

  wire ready;

  external_io
  #(.JOB_CONFIG_WIDTH(DEVICE_CONFIG_WIDTH),
    .DEVICE_CONFIG_WIDTH(JOB_CONFIG_WIDTH))
  uut (
    clk,
    reset_n,

    sck0,
    sdi0,
    cs0_n,

    sck1,
    sdi1,
    sdo1,
    cs1_n,

    device_config,
    job_config,

    core_reset_n,

    shapool_success,
    { shapool_match_flags, shapool_result},

    ready
  );

  reg [31:0] i;

  localparam [39:0] expected_result = 40'hAA_EEDDCCBB;
  localparam [DEVICE_CONFIG_WIDTH-1:0] expected_device_config = 8'b10101010;
  localparam [JOB_CONFIG_WIDTH-1:0] expected_job_config = 8'b10101010;

  reg [JOB_CONFIG_WIDTH-1:0] test_job_config = expected_job_config;
  reg [DEVICE_CONFIG_WIDTH-1:0] test_device_config = expected_device_config;
  reg [39:0] test_result = 0;


  always
  begin
      clk <= 0;
      #1;
      clk <= 1;
      #1;
  end

  initial
    begin

      $dumpfile("external_io_usage_tb.vcd");
      $dumpvars;


      reset_n <= 0;
      sck0 <= 0;
      sdi0 <= 0;
      cs0_n <= 1;

      sck1 <= 0;
      sdi1 <= 0;
      cs1_n <= 1;
      shapool_result <= 32'hEEDDCCBB;
      shapool_match_flags <= 8'hAA;
      shapool_success <= 0;

      #10;





      if (core_reset_n == 0)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: core_reset_n");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: core_reset_n");
          $error("Test case failed: core_reset_n should be low after reset_n goes low and reset_hold_period elapsed.");
        end


      cs0_n <= 0;
      #reset_hold_period;

      for (i = 0; i < JOB_CONFIG_WIDTH; i = i + 1)
        begin

          sdi0 <= test_job_config[JOB_CONFIG_WIDTH-1];
          test_job_config <= { test_job_config[JOB_CONFIG_WIDTH-2:0], 1'b0 };
          #spi_bit_half_period;


          sck0 <= 1;
          #spi_bit_half_period;


          sck0 <= 0;
        end

      cs0_n <= 1;
      #10;

      if (uut.job_config == expected_job_config)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: shift in job configuration");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: shift in job configuration");
          $display("uut.job_config: %h", uut.job_config);
          $error("Test case failed: SPI0 did not properly load uut.job_config.");
        end






      cs1_n <= 0;

      for (i = 0; i < DEVICE_CONFIG_WIDTH; i = i + 1)
        begin

          sdi1 <= test_device_config[DEVICE_CONFIG_WIDTH-1];
          test_device_config <= { test_device_config[DEVICE_CONFIG_WIDTH-2:0], 1'b0 };
          #spi_bit_half_period;


          sck1 <= 1;
          #spi_bit_half_period;


          sck1 <= 0;
        end

      cs1_n <= 1;
      reset_n <= 1;

      if (uut.device_config == expected_device_config)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: shift in device configuration");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: shift in device configuration");
          $display("uut.device_config: %h", uut.device_config);
          $error("Test case failed: SPI1 did not properly load uut.device_config");
        end







      shapool_success <= 1;


      cs1_n <= 0;
      sdi1 <= 0;

      for (i = 0; i < 40; i = i + 1)
        begin

          #spi_bit_half_period;


          test_result <= { test_result[38:0], sdo1 };
          sck1 <= 1;
          #spi_bit_half_period;


          sck1 <= 0;
        end

      cs1_n <= 1;
      #reset_hold_period;

      if (test_result == expected_result)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: shift out result");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: shift out result");
          $display("test_result: %h", test_result);
          $error("Test case failed: SPI1 failed to shift out result properly.");
        end

      #100;
      $finish;
    end

endmodule
module external_io_usage_tb();




  `define VERILATOR
  `define DEBUG_VERBOSE

  localparam spi_bit_half_period = 6;
  localparam reset_hold_period = 2;

  localparam JOB_CONFIG_WIDTH = 8;
  localparam DEVICE_CONFIG_WIDTH = 8;

  reg clk;
  reg reset_n;

  reg sck0;
  reg sdi0;
  reg cs0_n;

  reg sck1;
  reg sdi1;
  wire sdo1;
  reg cs1_n;

  wire [DEVICE_CONFIG_WIDTH-1:0] device_config;
  wire [JOB_CONFIG_WIDTH-1:0] job_config;

  wire core_reset_n;

  reg [7:0] shapool_match_flags;
  reg [31:0] shapool_result;
  reg shapool_success;

  wire ready;

  external_io
  #(.JOB_CONFIG_WIDTH(DEVICE_CONFIG_WIDTH),
    .DEVICE_CONFIG_WIDTH(JOB_CONFIG_WIDTH))
  uut (
    clk,
    reset_n,

    sck0,
    sdi0,
    cs0_n,

    sck1,
    sdi1,
    sdo1,
    cs1_n,

    device_config,
    job_config,

    core_reset_n,

    shapool_success,
    { shapool_match_flags, shapool_result},

    ready
  );

  reg [31:0] i;

  localparam [39:0] expected_result = 40'hAA_EEDDCCBB;
  localparam [DEVICE_CONFIG_WIDTH-1:0] expected_device_config = 8'b10101010;
  localparam [JOB_CONFIG_WIDTH-1:0] expected_job_config = 8'b10101010;

  reg [JOB_CONFIG_WIDTH-1:0] test_job_config = expected_job_config;
  reg [DEVICE_CONFIG_WIDTH-1:0] test_device_config = expected_device_config;
  reg [39:0] test_result = 0;


  always
  begin
      clk <= 0;
      #1;
      clk <= 1;
      #1;
  end

  initial
    begin

      $dumpfile("external_io_usage_tb.vcd");
      $dumpvars;


      reset_n <= 0;
      sck0 <= 0;
      sdi0 <= 0;
      cs0_n <= 1;

      sck1 <= 0;
      sdi1 <= 0;
      cs1_n <= 1;
      shapool_result <= 32'hEEDDCCBB;
      shapool_match_flags <= 8'hAA;
      shapool_success <= 0;

      #10;





      if (core_reset_n == 0)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: core_reset_n");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: core_reset_n");
          $error("Test case failed: core_reset_n should be low after reset_n goes low and reset_hold_period elapsed.");
        end


      cs0_n <= 0;
      #reset_hold_period;

      for (i = 0; i < JOB_CONFIG_WIDTH; i = i + 1)
        begin

          sdi0 <= test_job_config[JOB_CONFIG_WIDTH-1];
          test_job_config <= { test_job_config[JOB_CONFIG_WIDTH-2:0], 1'b0 };
          #spi_bit_half_period;


          sck0 <= 1;
          #spi_bit_half_period;


          sck0 <= 0;
        end

      cs0_n <= 1;
      #10;

      if (uut.job_config == expected_job_config)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: shift in job configuration");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: shift in job configuration");
          $display("uut.job_config: %h", uut.job_config);
          $error("Test case failed: SPI0 did not properly load uut.job_config.");
        end






      cs1_n <= 0;

      for (i = 0; i < DEVICE_CONFIG_WIDTH; i = i + 1)
        begin

          sdi1 <= test_device_config[DEVICE_CONFIG_WIDTH-1];
          test_device_config <= { test_device_config[DEVICE_CONFIG_WIDTH-2:0], 1'b0 };
          #spi_bit_half_period;


          sck1 <= 1;
          #spi_bit_half_period;


          sck1 <= 0;
        end

      cs1_n <= 1;
      reset_n <= 1;

      if (uut.device_config == expected_device_config)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: shift in device configuration");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: shift in device configuration");
          $display("uut.device_config: %h", uut.device_config);
          $error("Test case failed: SPI1 did not properly load uut.device_config");
        end







      shapool_success <= 1;


      cs1_n <= 0;
      sdi1 <= 0;

      for (i = 0; i < 40; i = i + 1)
        begin

          #spi_bit_half_period;


          test_result <= { test_result[38:0], sdo1 };
          sck1 <= 1;
          #spi_bit_half_period;


          sck1 <= 0;
        end

      cs1_n <= 1;
      #reset_hold_period;

      if (test_result == expected_result)
        begin
          $display("\033\133\063\062\155[PASS]\033\133\060\155 `external_io`: shift out result");
        end
      else
        begin
          $display("\033\133\063\061\155[FAIL]\033\133\060\155 `external_io`: shift out result");
          $display("test_result: %h", test_result);
          $error("Test case failed: SPI1 failed to shift out result properly.");
        end

      #100;
      $finish;
    end

endmodule