OrbitNTNU / electronics-verilator

Contains makefiles and examples for Verilator.
0 stars 0 forks source link

Automatic generation of version control registers #13

Open magnmaeh opened 7 months ago

magnmaeh commented 7 months ago

All of our projects should contain automatically generated version control registers. This is probably easy to do in Python.

There is room for changes, but a suggestion for how it can be implemented is to generate a module like so:

module VersionCtrl (
    output[63:0] git_commit_hash,
    output[63:0] unix_build_time,
    output[8:0] version_major,
    output[8:0] version_minor,
    output[8:0] version_patch
);

    assign git_commit_hash = CONST;
    assign unix_build_time = CONST;
    assign version_major = CONST;
    assign version_minor = CONST;
    assign version_patch = CONST;

endmodule

where the CONST have to be replaced by actual values. For implementing this, look up how to get the current git commit, how to get the current unix time from your computer (https://www.unixtimestamp.com/), and finally look up how to fetch the git tag from a commit. (This assumes we use Semantic Versioning (https://semver.org/) and add them to our git tags.) If there is no git tag on the current commit, all three should be zero.

Also, if the commit is "dirty", i.e. there are local changes that git does not know about, the Python script should exit with error and tell the user to use a clean commit.