<commit_before>#include "writer/verilog/insn_writer.h"

#include "iroha/logging.h"
#include "iroha/i_design.h"
#include "iroha/resource_class.h"
#include "iroha/resource_params.h"
#include "writer/names.h"
#include "writer/verilog/state.h"
#include "writer/verilog/table.h"

static const char I[] = "          ";

namespace iroha {
namespace writer {
namespace verilog {

InsnWriter::InsnWriter(const IInsn *insn, const State *st,
		       ostream &os)
  : insn_(insn), st_(st), os_(os) {
}

string InsnWriter::RegisterValue(const IRegister &reg, Names *names) {
  if (reg.IsConst()) {
    int w = reg.value_type_.GetWidth();
    if (w == 0) {
      w = 1;
    }
    return Util::Itoa(w) + "'d" + Util::ULLtoA(reg.GetInitialValue().GetValue0());
  } else {
    return names->GetRegName(reg);
  }
}

string InsnWriter::ConstValue(const IRegister &reg) {
  CHECK(reg.IsConst());
  return Util::Itoa(reg.GetInitialValue().GetValue0());
}

string InsnWriter::ResourceName(const IResource &res) {
  return res.GetClass()->GetName() + "_" + Util::Itoa(res.GetId());
}

void InsnWriter::Print() {
  for (int i = 0; i < insn_->inputs_.size(); ++i) {
    IRegister *reg = insn_->inputs_[i];
    os_ << I << "$display(\"%d\", " << RegisterValue(*reg, st_->GetNames()) << ");\n";<commit_msg>Add table id to resource name to avoid conflict.<commit_after>#include "writer/verilog/insn_writer.h"

#include "iroha/logging.h"
#include "iroha/i_design.h"
#include "iroha/resource_class.h"
#include "iroha/resource_params.h"
#include "writer/names.h"
#include "writer/verilog/state.h"
#include "writer/verilog/table.h"

static const char I[] = "          ";

namespace iroha {
namespace writer {
namespace verilog {

InsnWriter::InsnWriter(const IInsn *insn, const State *st,
		       ostream &os)
  : insn_(insn), st_(st), os_(os) {
}

string InsnWriter::RegisterValue(const IRegister &reg, Names *names) {
  if (reg.IsConst()) {
    int w = reg.value_type_.GetWidth();
    if (w == 0) {
      w = 1;
    }
    return Util::Itoa(w) + "'d" + Util::ULLtoA(reg.GetInitialValue().GetValue0());
  } else {
    return names->GetRegName(reg);
  }
}

string InsnWriter::ConstValue(const IRegister &reg) {
  CHECK(reg.IsConst());
  return Util::Itoa(reg.GetInitialValue().GetValue0());
}

string InsnWriter::ResourceName(const IResource &res) {
  return res.GetClass()->GetName() + "_" + Util::Itoa(res.GetTable()->GetId()) +
    "_" + Util::Itoa(res.GetId());
}

void InsnWriter::Print() {
  for (int i = 0; i < insn_->inputs_.size(); ++i) {
    IRegister *reg = insn_->inputs_[i];
    os_ << I << "$display(\"%d\", " << RegisterValue(*reg, st_->GetNames()) << ");\n";
{'fraction_non_alphanumeric': 0.18766553159288688, 'fraction_numerical': 0.0037835792659856224, 'mean_word_length': 4.2047244094488185, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 14, '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': '4493713', 'n_tokens_mistral': 983, 'n_tokens_neox': 980, 'n_words': 192}