Skip to content

Commit

Permalink
Fix std_lsh FIRRTL primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
ayakayorihiro committed Jan 31, 2024
1 parent a2df85a commit 5c8fa19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tools/firrtl/generate-firrtl-with-primitives.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import math
import os
import sys

Expand All @@ -13,6 +14,9 @@ def generate_replacement_map(inst):
replacement_map["DIFF"] = replacement_map["OUT_WIDTH"] - replacement_map["IN_WIDTH"]
elif inst["name"] == "std_slice":
replacement_map["DIFF"] = replacement_map["IN_WIDTH"] - replacement_map["OUT_WIDTH"]
elif inst["name"] == "std_lsh":
width = replacement_map["WIDTH"]
replacement_map["BITS"] = math.ceil(math.log(width, 2)) + 1

return replacement_map

Expand Down Expand Up @@ -62,4 +66,4 @@ def main():
generate(sys.argv[1], sys.argv[2])

if __name__ == '__main__':
main()
main()
2 changes: 1 addition & 1 deletion tools/firrtl/templates/std_lsh.fir
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
input right : UInt<WIDTH>
output out : UInt<WIDTH>

out <= dshl(left, right)
out <= dshl(left, bits(right, BITS, 0))

0 comments on commit 5c8fa19

Please sign in to comment.