WT_RANGES = { # platform: (min, max, default) 520: (0, 8, 0.92), 530: (0, 16, 3.6), 540: (0, 16, 8.0), 630: (0, 16, 2.0), 720: (0, 16, 7.8), 730: (0, 16, 8.0), } DMA_RANGES = { # platform: (min, max, default) 520: (0, 8, 0.8), 530: (0, 16, 3.6), 540: (0, 16, 8.0), 630: (0, 16, 2.0), 720: (0, 16, 7.8), 730: (0, 16, 8.0), } def verify_bandwidth_range(bandwidth, ranges): r_min, r_max, r_default = ranges if bandwidth is None: return r_default # TODO. check range return min(r_max, max(r_min, bandwidth)) def gen_ip_config(platform, weight_bw, dma_bw): assert platform in WT_RANGES.keys() and platform in DMA_RANGES, "platform ({}) is not set up yet. ".format(platform) weight_bw = verify_bandwidth_range(weight_bw, WT_RANGES[platform]) dma_bw = verify_bandwidth_range(dma_bw, DMA_RANGES[platform]) templates = { 520: { "version": "520", "data_compression": 1, "weight_compression": 1, "bits_per_weight": 8, "cpu_freq_MHz": 800, "ip_freq_MHz": 300, "weight_bandwidth_GBps": dma_bw, "cycles_per_move": 20, "DMA_Bandwith_GBps": dma_bw, "select_DMA": True, "col_stride": False, "detailed_info": True, }, 720: { "Freq_Mhz": 700, "RDMA_bandwidth_GB/s": dma_bw, "WDMA_bandwidth_GB/s": dma_bw, "GETW_bandwidth_GB/s": weight_bw, "compression_rate": 1, "detailed_info": True, }, 630: { "Freq_Mhz": 700, "RDMA_bandwidth_GB/s": dma_bw, "WDMA_bandwidth_GB/s": dma_bw, "GETW_bandwidth_GB/s": weight_bw, "detailed_info": True, "compression_rate": 1 }, 730: { "Freq_Mhz": 700, "RDMA_bandwidth_GB/s": dma_bw, "WDMA_bandwidth_GB/s": dma_bw, "GETW_bandwidth_GB/s": weight_bw, "detailed_info": True, "compression_rate": 1 }, 540: { "Freq_Mhz": 700, "RDMA_bandwidth_GB/s": dma_bw, "WDMA_bandwidth_GB/s": dma_bw, "GETW_bandwidth_GB/s": weight_bw, "detailed_info": True, "compression_rate": 1 }, 530: { "Freq_Mhz": 500, "RDMA_bandwidth_GB/s": dma_bw, "WDMA_bandwidth_GB/s": dma_bw, "GETW_bandwidth_GB/s": weight_bw, "detailed_info": True, "compression_rate": 1 }, } return templates[platform]