Skip to content

Commit

Permalink
mem_tg: read major and minor version
Browse files Browse the repository at this point in the history
Add a function version_code() to combine major and minor version into a
single code for comparison to, e.g., guard version-dependent features.

Signed-off-by: Peter Colberg <peter.colberg@altera.com>
  • Loading branch information
pcolberg committed Jan 22, 2025
1 parent 19859d1 commit d3189ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions samples/mem_tg/mem_tg.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ class mem_tg : public test_afu {
return res;
}

// Combines major and minor version into single code for comparison.
static uint32_t version_code(uint32_t major, uint32_t minor)
{
// Major and minor version are encoded with 4 bits each.
return major * 16 + minor;
}

public:
uint32_t count_;
std::vector<std::string> mem_ch_;
Expand All @@ -225,6 +232,7 @@ class mem_tg : public test_afu {
uint32_t mem_speed_;
uint32_t status_;
uint64_t tg_offset_;
uint32_t version_;

std::map<uint32_t, uint32_t> limits_;

Expand Down Expand Up @@ -265,6 +273,7 @@ class mem_tg : public test_afu {
duplicate_obj->timeout_msec_ = this->timeout_msec_;
duplicate_obj->handle_ = this->handle_;
duplicate_obj->logger_ = this->logger_;
duplicate_obj->version_ = this->version_;
}

};
Expand Down
5 changes: 5 additions & 0 deletions samples/mem_tg/tg_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ class tg_test : public test_command
token_ = d_afu->get_token();

// Read HW details
const uint64_t tg_version = tg_exe_->read64(TG_VERSION);
const uint32_t major_ver = (tg_version >> 12) & 0xf; // [51:48]
const uint32_t minor_ver = (tg_version >> 48) & 0xf; // [15:12]
tg_exe_->version_ = tg_exe_->version_code(major_ver, minor_ver);
tg_exe_->logger_->debug("version: {}.{}", major_ver, minor_ver);

if (0 == tg_exe_->mem_speed_) {
tg_exe_->mem_speed_ = 300;
Expand Down

0 comments on commit d3189ca

Please sign in to comment.