From 44a7f1f93aa9f0e1bf3d8045661e5f631d577a3e Mon Sep 17 00:00:00 2001 From: Damiano Bortolato Date: Tue, 29 Aug 2023 15:02:36 +0200 Subject: [PATCH] Add N_SLV__ADDR_WIDTH constants. It may be helpful, for a slave, to know how many low address lines they have to decode to minimize their internal decoder complexity. --- uhal/tools/scripts/gen_ipbus_addr_decode | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/uhal/tools/scripts/gen_ipbus_addr_decode b/uhal/tools/scripts/gen_ipbus_addr_decode index b4aff444c..8aa09edfd 100755 --- a/uhal/tools/scripts/gen_ipbus_addr_decode +++ b/uhal/tools/scripts/gen_ipbus_addr_decode @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/libexec/platform-python """ This script automatically generates address select logic for IPbus-based firmware designs. @@ -296,7 +296,7 @@ def main(): error_count += 1 or_prod = or_prod | (addr_bits & ~mask_bits) and_prod = and_prod & (addr_bits | mask_bits) - slaves.append((n, i.name, addr_bits, mask_bits)) + slaves.append((n, i.name, addr_bits, mask_bits, i.width)) addr_mask = or_prod & ~and_prod log.info("Significant address bits 0b%s" % str(addr_mask)) @@ -322,9 +322,10 @@ def main(): snippet1 = "-- START automatically generated VHDL" + timestamp_suffix + "\n" if numSlaves > 0: slaveIds={} - for n,id,addr_bits,mask_bits in slaves: + for n,id,addr_bits,mask_bits,width in slaves: slaveIds[n]="N_SLV_"+id.upper().replace(".","_") snippet1 += " constant "+slaveIds[n]+": integer := %i;\n"%n + snippet1 += " constant "+slaveIds[n]+"_ADDR_WIDTH: integer := %i;\n"%width snippet1 += " constant N_SLAVES: integer := %i;\n"%(numSlaves) snippet1 += "-- END automatically generated VHDL" @@ -333,7 +334,7 @@ def main(): if numSlaves <= 1: snippet2 += " sel := ipbus_sel_t(to_unsigned(" + slaveIds[0] + ", IPBUS_SEL_WIDTH));\n" else: - for n,id,addr_bits,mask_bits in slaves: + for n,id,addr_bits,mask_bits,width in slaves: mask = addr_mask & ~mask_bits if n == 0: snippet2 += " if "