This is dependent on a JusTAG task: StanfordVLSI/JusTAG#4
Once the JusTAG feature is ready, we can add the JTAG ID when make.py
is run to build the chip. (The current git commit hash can be retrieved with git rev-parse HEAD
.)
We have 31 bits available in the JTAG ID, and I suggest that we use the 28 most significant bits for the git commit hash, since it is customary to reference git commits using 7 nibbles. I suggest we use the three remaining bits to represent additional information about the repository state. For now, the main thing that comes to mind is the clean/dirty status of the repository to indicate whether the user has uncommitted changes (that can be automatically determined by checking if git status --porcelain
is a non-empty string)
We can then encode this information in the version
, part
, and man_num
variables:
version[3:0] = (git_hash >> 24) & 0xf
part[15:0] = (git_hash >> 8) & 0xffff
man_num[10:0] = {(git_hash & 0xff), 1'b0, 1'b0, git_is_clean}
For example, suppose the output of git rev-parse HEAD
is
1abc49b8ec66bad372e5728d2a2f42ab1b1264fa
git_hash
would then be the most significant 7 nibbles (1abc49b
). Further assuming that the git repository is clean (git_is_clean = 1'b1
), we have:
version[3:0] = 4'h1 = 4'b0001
part[15:0] = 16'habc4 = 16'b1010101111000100
man_num[10:0] = {8'h9b, 1'b0, 1'b0, 1'b1} = 11'b10011011001
The full JTAG ID (including the LSB that is always set to "1" by the TAP) would then be
jtag_id = 32'b00011010101111000100100110110011 = 32'h1ABC49B3
The nice thing about this format is that we can immediately read off the git commit has using the most significant 7 nibbles, while the git status is encoded in the least significant nibble ("3" means clean, "1" means dirty). We even have two more bits left over for other purposes if we can think of something :-)