<commit_before>// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

// Verify the countermeasure(s) CONFIG.REGWEN.

class csrng_regwen_vseq extends csrng_base_vseq;
  `uvm_object_utils(csrng_regwen_vseq)

  `uvm_object_new

  bit ctrl_bit        = 0;
  bit chk_bit         = 0;
  int ctrl_int        = 0;
  int chk_int         = 0;

  task body();

    csr_wr(.ptr(ral.regwen), .value(ctrl_bit), .blocking(1));
    csr_wr(.ptr(ral.regwen), .value(~ctrl_bit), .blocking(1));
    csr_rd(.ptr(ral.regwen), .value(chk_bit), .blocking(1));

    if (chk_bit != ctrl_bit) begin
      `uvm_fatal(`gfn, $sformatf(" Was able to overwrite REGWEN after being set to 0"))
    end

    csr_rd(.ptr(ral.ctrl), .value(ctrl_int), .blocking(1));
    csr_wr(.ptr(ral.ctrl),
           .value(ctrl_int ^ 1'b1),
           .blocking(1));
    csr_rd(.ptr(ral.ctrl), .value(chk_int), .blocking(1));

    if (ctrl_int != chk_int) begin
      `uvm_fatal(`gfn, $sformatf(" Was able to overwrite CTRL with REGWEN being set to 0"))
    end

    csr_rd(.ptr(ral.err_code_test), .value(ctrl_int), .blocking(1));
    csr_wr(.ptr(ral.err_code_test),
           .value(ctrl_int ^ 1'b1),
           .blocking(1));
    csr_rd(.ptr(ral.err_code_test), .value(chk_int), .blocking(1));

    if (ctrl_int != chk_int) begin
      `uvm_fatal(`gfn, $sformatf(" Was able to overwrite ERR_CODE_TEST with REGWEN being set to 0"))
    end

  endtask : body

endclass : csrng_regwen_vseq<commit_msg>[csrng,dv] Sample cfg_cg in regwen test<commit_after>// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

// Verify the countermeasure(s) CONFIG.REGWEN.

class csrng_regwen_vseq extends csrng_base_vseq;
  `uvm_object_utils(csrng_regwen_vseq)

  `uvm_object_new

  bit ctrl_bit        = 0;
  bit chk_bit         = 0;
  int ctrl_int        = 0;
  int chk_int         = 0;

  task body();

    csr_wr(.ptr(ral.regwen), .value(ctrl_bit), .blocking(1));
    csr_wr(.ptr(ral.regwen), .value(~ctrl_bit), .blocking(1));
    csr_rd(.ptr(ral.regwen), .value(chk_bit), .blocking(1));

    if (chk_bit != ctrl_bit) begin
      `uvm_fatal(`gfn, $sformatf(" Was able to overwrite REGWEN after being set to 0"))
    end

    csr_rd(.ptr(ral.ctrl), .value(ctrl_int), .blocking(1));
    csr_wr(.ptr(ral.ctrl),
           .value(ctrl_int ^ 1'b1),
           .blocking(1));
    csr_rd(.ptr(ral.ctrl), .value(chk_int), .blocking(1));

    if (ctrl_int != chk_int) begin
      `uvm_fatal(`gfn, $sformatf(" Was able to overwrite CTRL with REGWEN being set to 0"))
    end

    csr_rd(.ptr(ral.err_code_test), .value(ctrl_int), .blocking(1));
    csr_wr(.ptr(ral.err_code_test),
           .value(ctrl_int ^ 1'b1),
           .blocking(1));
    csr_rd(.ptr(ral.err_code_test), .value(chk_int), .blocking(1));

    if (ctrl_int != chk_int) begin
      `uvm_fatal(`gfn, $sformatf(" Was able to overwrite ERR_CODE_TEST with REGWEN being set to 0"))
    end

    super.body();

  endtask : body

endclass : csrng_regwen_vseq
{'fraction_non_alphanumeric': 0.14531001589825118, 'fraction_numerical': 0.015262321144674086, 'mean_word_length': 3.134034165571616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3010150', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1197, 'n_words': 259}