<commit_before>{- sv2v
 - Author: <NAME> <<EMAIL>>
 -
 - Elaboration of `$bits`, where possible
 -}

module Convert.Bits (convert) where

import Convert.Traverse
import Language.SystemVerilog.AST

convert :: AST -> AST
convert =
    traverseDescriptions $
    traverseModuleItems $
    traverseExprs $
    traverseNestedExprs $
    convertExpr

convertExpr :: Expr -> Expr
convertExpr (Bits (Left (IntegerVector _ _ [r]))) = rangeSize r
convertExpr (Bits (Left (Implicit        _ [r]))) = rangeSize r
convertExpr other = other
<commit_msg>$bits conversion handles types with more than 1 dimension<commit_after>{- sv2v
 - Author: <NAME> <<EMAIL>>
 -
 - Elaboration of `$bits`, where possible
 -}

module Convert.Bits (convert) where

import Convert.Traverse
import Language.SystemVerilog.AST

convert :: AST -> AST
convert =
    traverseDescriptions $
    traverseModuleItems $
    traverseExprs $
    traverseNestedExprs $
    convertExpr

convertExpr :: Expr -> Expr
convertExpr (Bits (Left (IntegerVector _ _ rs))) = size rs
convertExpr (Bits (Left (Implicit        _ rs))) = size rs
convertExpr other = other

size :: [Range] -> Expr
size ranges =
    simplify $
    foldl (BinOp Mul) (Number "1") $
    map rangeSize $
    ranges

{'fraction_non_alphanumeric': 0.10615883306320907, 'fraction_numerical': 0.0032414910858995136, 'mean_word_length': 3.5571955719557193, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1505997', 'n_tokens_mistral': 388, 'n_tokens_neox': 382, 'n_words': 116}