| // Copyright lowRISC contributors. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| def make_blocked_sv_literal(hexstr, randwidth): |
| """This chops the random hexstring into manageable blocks of 64 chars such that the |
| lines do not get too long. |
| # Make all-caps and drop '0x' preamble |
| hexstr = str(hexstr[2:]).upper() |
| # Block width in hex chars |
| remainder = randwidth % (4*blockwidth) |
| numbits = remainder if remainder else 4*blockwidth |
| hexblocks.append(str(numbits) + "'h" + hexstr[0:idx]) |
| package top_${top["name"]}_rnd_cnst_pkg; |
| % for m in top["module"]: |
| % for p in filter(lambda p: p.get("randtype") in ["data", "perm"], m["param_list"]): |
| //////////////////////////////////////////// |
| //////////////////////////////////////////// |
| parameter ${p["type"]} ${p["name_top"]} = { |
| % for block in make_blocked_sv_literal(p["default"], p["randwidth"]): |
| ${block}${"" if loop.last else ","} |
| endpackage : top_${top["name"]}_rnd_cnst_pkg |