Files
b210-k7-fpga/tools/utils/rfnoc-system-sim/sim_colosseum.py
T
+18 6b67702ad7 Merge FPGA repository back into UHD repository
The FPGA codebase was removed from the UHD repository in 2014 to reduce
the size of the repository. However, over the last half-decade, the
split between the repositories has proven more burdensome than it has
been helpful. By merging the FPGA code back, it will be possible to
create atomic commits that touch both FPGA and UHD codebases. Continuous
integration testing is also simplified by merging the repositories,
because it was previously difficult to automatically derive the correct
UHD branch when testing a feature branch on the FPGA repository.

This commit also updates the license files and paths therein.

We are therefore merging the repositories again. Future development for
FPGA code will happen in the same repository as the UHD host code and
MPM code.

== Original Codebase and Rebasing ==

The original FPGA repository will be hosted for the foreseeable future
at its original local location: https://github.com/EttusResearch/fpga/

It can be used for bisecting, reference, and a more detailed history.

The final commit from said repository to be merged here is
05003794e2da61cabf64dd278c45685a7abad7ec. This commit is tagged as
v4.0.0.0-pre-uhd-merge.

If you have changes in the FPGA repository that you want to rebase onto
the UHD repository, simply run the following commands:

- Create a directory to store patches (this should be an empty
  directory):

    mkdir ~/patches

- Now make sure that your FPGA codebase is based on the same state as
  the code that was merged:

    cd src/fpga # Or wherever your FPGA code is stored
    git rebase v4.0.0.0-pre-uhd-merge

  Note: The rebase command may look slightly different depending on what
  exactly you're trying to rebase.

- Create a patch set for your changes versus v4.0.0.0-pre-uhd-merge:

    git format-patch v4.0.0.0-pre-uhd-merge -o ~/patches

  Note: Make sure that only patches are stored in your output directory.
  It should otherwise be empty. Make sure that you picked the correct
  range of commits, and only commits you wanted to rebase were exported
  as patch files.

- Go to the UHD repository and apply the patches:

    cd src/uhd # Or wherever your UHD repository is stored
    git am --directory fpga ~/patches/*
    rm -rf ~/patches # This is for cleanup

== Contributors ==

The following people have contributed mainly to these files (this list
is not complete):

Co-authored-by: Alex Williams <alex.williams@ni.com>
Co-authored-by: Andrej Rode <andrej.rode@ettus.com>
Co-authored-by: Ashish Chaudhari <ashish@ettus.com>
Co-authored-by: Ben Hilburn <ben.hilburn@ettus.com>
Co-authored-by: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
Co-authored-by: Daniel Jepson <daniel.jepson@ni.com>
Co-authored-by: Derek Kozel <derek.kozel@ettus.com>
Co-authored-by: EJ Kreinar <ej@he360.com>
Co-authored-by: Humberto Jimenez <humberto.jimenez@ni.com>
Co-authored-by: Ian Buckley <ian.buckley@gmail.com>
Co-authored-by: Jörg Hofrichter <joerg.hofrichter@ni.com>
Co-authored-by: Jon Kiser <jon.kiser@ni.com>
Co-authored-by: Josh Blum <josh@joshknows.com>
Co-authored-by: Jonathon Pendlum <jonathan.pendlum@ettus.com>
Co-authored-by: Martin Braun <martin.braun@ettus.com>
Co-authored-by: Matt Ettus <matt@ettus.com>
Co-authored-by: Michael West <michael.west@ettus.com>
Co-authored-by: Moritz Fischer <moritz.fischer@ettus.com>
Co-authored-by: Nick Foster <nick@ettus.com>
Co-authored-by: Nicolas Cuervo <nicolas.cuervo@ettus.com>
Co-authored-by: Paul Butler <paul.butler@ni.com>
Co-authored-by: Paul David <paul.david@ettus.com>
Co-authored-by: Ryan Marlow <ryan.marlow@ettus.com>
Co-authored-by: Sugandha Gupta <sugandha.gupta@ettus.com>
Co-authored-by: Sylvain Munaut <tnt@246tNt.com>
Co-authored-by: Trung Tran <trung.tran@ettus.com>
Co-authored-by: Vidush Vishwanath <vidush.vishwanath@ettus.com>
Co-authored-by: Wade Fife <wade.fife@ettus.com>


Original-commit: bafa9d95453387814ef25e6b6256ba8db2df612f
2020-01-28 09:35:36 -08:00

143 lines
6.3 KiB
Python
Executable File

#!/usr/bin/env python
#
# Copyright 2016 Ettus Research
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import rfnocsim
import ni_hw_models as hw
import colosseum_models
import argparse
import re
def main():
# Arguments
parser = argparse.ArgumentParser(description='Simulate the Colosseum network')
parser.add_argument('--topology', type=str, default='flb', choices=['torus','flb'], help='Topology')
parser.add_argument('--domain', type=str, default='time', choices=['time','frequency'], help='Domain')
parser.add_argument('--fir_taps', type=int, default=4, help='FIR Filter Taps (Time domain only)')
parser.add_argument('--fir_dly_line', type=int, default=512, help='FIR Delay Line (Time domain only)')
parser.add_argument('--fft_size', type=int, default=512, help='FFT Size (Frequency domain only)')
parser.add_argument('--fft_overlap', type=int, default=256, help='FFT Overlap (Frequency domain only)')
parser.add_argument('--samp_rate', type=float, default=100e6, help='Radio Channel Sample Rate')
parser.add_argument('--coherence_rate', type=float, default=1000, help='Channel coefficient update rate')
args = parser.parse_args()
sim_core = rfnocsim.SimulatorCore(tick_rate=100e6)
NUM_USRPS = 128
NUM_HOSTS = 4
NUM_BLADES = 16
NUM_CHANS = NUM_USRPS * 2
# Build an application settings structure
app_settings = dict()
app_settings['domain'] = args.domain
app_settings['samp_rate'] = args.samp_rate
app_settings['coherence_rate'] = args.coherence_rate
if args.domain == 'frequency':
app_settings['fft_size'] = args.fft_size
app_settings['fft_overlap'] = args.fft_overlap
else:
app_settings['fir_taps'] = args.fir_taps
app_settings['fir_dly_line'] = args.fir_dly_line
print('[INFO] Instantiating hardware resources...')
# Create USRPs
usrps = []
for i in range(NUM_USRPS):
usrps.append(hw.UsrpX310(sim_core, index=i, app_settings=app_settings))
# Create BEE7s
bee7blades = []
for i in range(NUM_BLADES):
bee7blades.append(hw.Bee7Blade(sim_core, index=i))
# Create Management Hosts
hosts = []
for i in range(NUM_HOSTS):
hosts.append(hw.ManagementHostandSwitch(sim_core, index=i,
num_coeffs=pow(NUM_CHANS,2)/NUM_HOSTS, switch_ports=16, app_settings=app_settings))
# Build topology
print('[INFO] Building topology...')
if args.topology == 'torus':
colosseum_models.Topology_2D_4x4_Torus.connect(sim_core, usrps, bee7blades, hosts, app_settings)
elif args.topology == 'flb':
colosseum_models.Topology_3D_4x4_FLB.connect(sim_core, usrps, bee7blades, hosts, app_settings)
else:
raise RuntimeError('Invalid topology: ' + args.topology)
print('[INFO] Running simulation...')
sim_core.run(16e-9)
# Sanity checks
print('[INFO] Validating correctness...')
for u in sim_core.list_components(rfnocsim.comptype.hardware, 'USRP.*'):
sim_core.lookup(u).validate(0)
print('[INFO] Validating feasibility...')
for u in sim_core.list_components('', '.*'):
c = sim_core.lookup(u)
for a in c.get_util_attrs():
if c.get_utilization(a) > 1.0:
print('[WARN] %s: %s overutilized by %.1f%%' % (u,a,(c.get_utilization(a)-1)*100))
print('[INFO] Validating BEE7 FPGA image IO consistency...')
master_fpga = 'BEE7_000/FPGA_NE'
master_stats = dict()
for u in sim_core.list_components('', master_fpga + '/.*SER_.*'):
c = sim_core.lookup(u)
m = re.match('(.+)/(SER_.*)', u)
master_stats[m.group(2)] = c.get_utilization('bandwidth')
for ln in master_stats:
for u in sim_core.list_components('', '.*/' + ln):
c = sim_core.lookup(u)
m = re.match('(.+)/(SER_.*)', u)
if (c.get_utilization('bandwidth') != master_stats[ln]):
print('[WARN] Data flowing over ' + ln + ' is probably different between ' + master_fpga + ' and ' + m.group(1))
# Visualize various metrics
vis = rfnocsim.Visualizer(sim_core)
vis.show_network()
vis.new_figure([1,2])
vis.plot_utilization(rfnocsim.comptype.hardware, 'BEE7.*', 1)
vis.plot_utilization(rfnocsim.comptype.producer, 'USRP.*', 2)
vis.show_figure()
vis.new_figure([1,2])
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_000.*FPGA_NW.*EXT.*', 1)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_006.*FPGA_SE.*EXT.*', 2)
vis.show_figure()
vis.new_figure([1,3])
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_010.*FPGA_NW.*SER_EW_.*', 1)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_010.*FPGA_NW.*SER_NS_.*', 2)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_010.*FPGA_NW.*SER_XX_.*', 3)
vis.show_figure()
vis.new_figure([1,4])
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_000.*FPGA_NW.*EXT.*', 1)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_001.*FPGA_NW.*EXT.*', 2)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_002.*FPGA_NW.*EXT.*', 3)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_003.*FPGA_NW.*EXT.*', 4)
vis.show_figure()
vis.new_figure([1,4])
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_010.*FPGA_NW.*EXT.*', 1)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_010.*FPGA_NE.*EXT.*', 2)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_010.*FPGA_SW.*EXT.*', 3)
vis.plot_utilization(rfnocsim.comptype.channel, 'BEE7_010.*FPGA_SE.*EXT.*', 4)
vis.show_figure()
vis.new_figure([1,2])
vis.plot_consumption_latency('.*','.*USRP_.*', 1)
vis.plot_path_latency('tx[(0)]', '.*', 2)
vis.show_figure()
vis.plot_utilization(rfnocsim.comptype.producer, '.*MGMT_HOST.*')
if __name__ == '__main__':
main()