aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/usrp3
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usrp3')
-rwxr-xr-xfirmware/usrp3/x300/x300_aurora_bist.py40
1 files changed, 16 insertions, 24 deletions
diff --git a/firmware/usrp3/x300/x300_aurora_bist.py b/firmware/usrp3/x300/x300_aurora_bist.py
index f5e119b66..5f7a22a3b 100755
--- a/firmware/usrp3/x300/x300_aurora_bist.py
+++ b/firmware/usrp3/x300/x300_aurora_bist.py
@@ -43,8 +43,9 @@ SFP_TYPE_AURORA = 2
MAC_REG_CTRL = 0
MAC_REG_STATUS = 0
MAC_REG_OVERRUNS = 4
-MAC_REG_BIST_SAMPS = 8
-MAC_REG_BIST_ERRORS = 12
+MAC_REG_CHECKSUM_ERRS = 8
+MAC_REG_BIST_SAMPS = 12
+MAC_REG_BIST_ERRORS = 16
MAC_STATUS_LINK_UP_MSK = 0x00000001
MAC_STATUS_HARD_ERR_MSK = 0x00000002
@@ -52,19 +53,16 @@ MAC_STATUS_SOFT_ERR_MSK = 0x00000004
MAC_STATUS_BIST_LOCKED_MSK = 0x00000008
MAC_STATUS_BIST_LATENCY_MSK = 0x000FFFF0
MAC_STATUS_BIST_LATENCY_OFFSET = 4
-MAC_STATUS_CHECKSUM_ERRS_MSK = 0xFFF00000
-MAC_STATUS_CHECKSUM_ERRS_OFFSET = 20
MAC_CTRL_BIST_CHECKER_EN = 0x00000001
MAC_CTRL_BIST_GEN_EN = 0x00000002
MAC_CTRL_BIST_LOOPBACK_EN = 0x00000004
-MAC_CTRL_PHY_RESET = 0x00000100
-MAC_CTRL_BIST_RATE_MSK = 0x000000F8
+MAC_CTRL_PHY_RESET = 0x00000200
+MAC_CTRL_BIST_RATE_MSK = 0x000001F8
MAC_CTRL_BIST_RATE_OFFSET = 3
-AURORA_CLK_RATE = 156.25e6
BUS_CLK_RATE = 166.66e6
-BIST_MAX_TIME_LIMIT = math.floor(pow(2,48)/AURORA_CLK_RATE)-1
+BIST_MAX_TIME_LIMIT = math.floor(pow(2,48)/BUS_CLK_RATE)-1
########################################################################
# utils
@@ -83,10 +81,11 @@ def get_aurora_info(ctrl):
return (aur_port, link_up)
def get_rate_setting(rate):
- for div in range(2,32):
- if (rate < 8e-6 * BUS_CLK_RATE * (1.0 - 1.0/div)):
- return (div-1, 8e-6 * BUS_CLK_RATE * (1.0 - 1.0/(div-1)))
- return (0, 8e-6 * BUS_CLK_RATE)
+ RATE_RES_BITS = 6
+ rate_sett = int((1.0*rate/(8e-6*BUS_CLK_RATE))*pow(2, RATE_RES_BITS))-1 # Round rate down
+ rate_sett = numpy.clip(rate_sett, 0, pow(2, RATE_RES_BITS)-1)
+ coerced_rate = ((1.0+rate_sett)/pow(2, RATE_RES_BITS))*(8e-6*BUS_CLK_RATE)
+ return (rate_sett, coerced_rate)
def run_ber_loopback_bist(ctrls, duration, rate_tuple):
(rate_sett, rate) = rate_tuple
@@ -107,10 +106,7 @@ def run_ber_loopback_bist(ctrls, duration, rate_tuple):
# Put the slave in loopback mode and the master in BIST mode
if 'slave' in ctrls:
ctrls['slave'].poke(SLA_MAC_REG_BASE + MAC_REG_CTRL, MAC_CTRL_BIST_LOOPBACK_EN)
- if rate_sett == 0:
- master_ctrl = MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
- else:
- master_ctrl = ((rate_sett - 1) << MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
+ master_ctrl = (rate_sett<<MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
ctrls['master'].poke(MST_MAC_REG_BASE + MAC_REG_CTRL, master_ctrl)
start_time = datetime.datetime.now()
# Wait and check if BIST locked
@@ -153,7 +149,7 @@ def run_ber_loopback_bist(ctrls, duration, rate_tuple):
print('[INFO] BIST Complete!')
print('- Elapsed Time = ' + str(time_diff))
print('- Max BER (Bit Error Ratio) = %.4g (%d errors out of %d)'%((mst_errors+1)/mst_samps,mst_errors,mst_samps))
- print('- Max Roundtrip Latency = %.1fus'%(1e6*mst_latency_cyc/AURORA_CLK_RATE))
+ print('- Max Roundtrip Latency = %.1fus'%(1e6*mst_latency_cyc/BUS_CLK_RATE))
print('- Approx Throughput = %.0fMB/s'%((8e-6*mst_samps)/time_diff.total_seconds()))
else:
print('[ERROR] BIST Failed!')
@@ -187,10 +183,7 @@ def run_latency_loopback_bist(ctrls, duration, rate_tuple):
# Put the slave in loopback mode and the master in BIST mode
if 'slave' in ctrls:
ctrls['slave'].poke(SLA_MAC_REG_BASE + MAC_REG_CTRL, MAC_CTRL_BIST_LOOPBACK_EN)
- if rate_sett == 0:
- master_ctrl = MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
- else:
- master_ctrl = ((rate_sett - 1) << MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
+ master_ctrl = (rate_sett<<MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
start_time = datetime.datetime.now()
latencies = []
@@ -216,7 +209,7 @@ def run_latency_loopback_bist(ctrls, duration, rate_tuple):
ctrls['master'].poke(MST_MAC_REG_BASE + MAC_REG_CTRL, 0)
# Compure latency
mst_latency_cyc = 16.0*((mst_status & MAC_STATUS_BIST_LATENCY_MSK) >> MAC_STATUS_BIST_LATENCY_OFFSET)
- mst_latency_us = 1e6*mst_latency_cyc/AURORA_CLK_RATE
+ mst_latency_us = 1e6*mst_latency_cyc/BUS_CLK_RATE
latencies.append(mst_latency_us)
except KeyboardInterrupt:
print('[WARNING] Operation cancelled by user.')
@@ -233,7 +226,7 @@ def run_latency_loopback_bist(ctrls, duration, rate_tuple):
print('- Elapsed Time = ' + str(stop_time - start_time))
print('- Roundtrip Latency Mean = %.2fus'%(numpy.mean(latencies)))
print('- Roundtrip Latency Stdev = %.2fus'%(numpy.std(latencies)))
- # Turn off BIST loopback
+ # Turn off BIST loopback
time.sleep(0.5)
if 'slave' in ctrls:
ctrls['slave'].poke(SLA_MAC_REG_BASE + MAC_REG_CTRL, 0)
@@ -304,4 +297,3 @@ if __name__=='__main__':
run_ber_loopback_bist(ctrls, options.duration, get_rate_setting(options.rate))
else:
run_latency_loopback_bist(ctrls, options.duration, get_rate_setting(options.rate))
-