summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--firmware/README8
-rw-r--r--firmware/microblaze/.gitignore46
-rw-r--r--firmware/microblaze/COPYING674
-rw-r--r--firmware/microblaze/ChangeLog1
-rw-r--r--firmware/microblaze/INSTALL234
-rw-r--r--firmware/microblaze/Makefile.am29
-rw-r--r--firmware/microblaze/Makefile.common88
-rw-r--r--firmware/microblaze/NEWS0
-rw-r--r--firmware/microblaze/README3
-rw-r--r--firmware/microblaze/apps/bitrot/tx_drop.c261
-rw-r--r--firmware/microblaze/apps/bitrot/tx_drop2.c292
-rw-r--r--firmware/microblaze/apps/bitrot/tx_drop_rate_limited.c233
-rw-r--r--firmware/microblaze/apps/cruft/Makefile.am82
-rw-r--r--firmware/microblaze/apps/cruft/app_passthru_v2.c251
-rw-r--r--firmware/microblaze/apps/cruft/app_passthru_v2.h54
-rw-r--r--firmware/microblaze/apps/cruft/blink_leds2.c53
-rw-r--r--firmware/microblaze/apps/cruft/buf_ram_test.c89
-rw-r--r--firmware/microblaze/apps/cruft/burn_dbsrx_eeprom.c106
-rw-r--r--firmware/microblaze/apps/cruft/burnrev30.c162
-rw-r--r--firmware/microblaze/apps/cruft/burnrev31.c162
-rw-r--r--firmware/microblaze/apps/cruft/can_i_sub.c25
-rw-r--r--firmware/microblaze/apps/cruft/double_buffer_fragment.c138
-rw-r--r--firmware/microblaze/apps/cruft/eth_serdes.c233
-rw-r--r--firmware/microblaze/apps/cruft/factory_test.c438
-rw-r--r--firmware/microblaze/apps/cruft/gen_eth_packets.c187
-rw-r--r--firmware/microblaze/apps/cruft/gen_pause_frames.c207
-rw-r--r--firmware/microblaze/apps/cruft/hello.c30
-rw-r--r--firmware/microblaze/apps/cruft/ibs_rx_test.c82
-rw-r--r--firmware/microblaze/apps/cruft/ibs_tx_test.c160
-rw-r--r--firmware/microblaze/apps/cruft/mimo_app_common_v2.c582
-rw-r--r--firmware/microblaze/apps/cruft/mimo_app_common_v2.h63
-rw-r--r--firmware/microblaze/apps/cruft/mimo_tx.c363
-rw-r--r--firmware/microblaze/apps/cruft/mimo_tx_slave.c376
-rw-r--r--firmware/microblaze/apps/cruft/rcv_eth_packets.c233
-rw-r--r--firmware/microblaze/apps/cruft/read_dbids.c59
-rw-r--r--firmware/microblaze/apps/cruft/sd_bounce.c153
-rw-r--r--firmware/microblaze/apps/cruft/sd_gentest.c269
-rw-r--r--firmware/microblaze/apps/cruft/serdes_to_dsp.c179
-rw-r--r--firmware/microblaze/apps/cruft/serdes_txrx.c368
-rw-r--r--firmware/microblaze/apps/cruft/set_hw_rev.c45
-rw-r--r--firmware/microblaze/apps/cruft/test1.c282
-rw-r--r--firmware/microblaze/apps/cruft/test_db_spi.c35
-rw-r--r--firmware/microblaze/apps/cruft/test_i2c.c108
-rw-r--r--firmware/microblaze/apps/cruft/test_lsadc.c57
-rw-r--r--firmware/microblaze/apps/cruft/test_lsdac.c51
-rw-r--r--firmware/microblaze/apps/cruft/test_phy_comm.c113
-rw-r--r--firmware/microblaze/apps/cruft/test_ram.c105
-rw-r--r--firmware/microblaze/apps/cruft/test_sd.c81
-rw-r--r--firmware/microblaze/apps/cruft/timer_test.c57
-rw-r--r--firmware/microblaze/apps/cruft/tx_standalone.c339
-rwxr-xr-xfirmware/microblaze/bootstrap26
-rw-r--r--firmware/microblaze/configure.ac54
-rw-r--r--firmware/microblaze/lib/Makefile.inc50
-rw-r--r--firmware/microblaze/lib/bootconfig.c101
-rw-r--r--firmware/microblaze/lib/bsm12.c319
-rw-r--r--firmware/microblaze/lib/bsm12.h83
-rw-r--r--firmware/microblaze/lib/buffer_pool.c72
-rw-r--r--firmware/microblaze/lib/buffer_pool.h75
-rw-r--r--firmware/microblaze/lib/dbsm.c299
-rw-r--r--firmware/microblaze/lib/dbsm.h90
-rw-r--r--firmware/microblaze/lib/gdbstub2.c506
-rw-r--r--firmware/microblaze/lib/mdelay.c73
-rw-r--r--firmware/microblaze/lib/net/.gitignore2
-rw-r--r--firmware/microblaze/lib/usrp2_bytesex.h66
-rw-r--r--firmware/microblaze/lib/wb16550.h98
-rwxr-xr-xfirmware/microblaze/u2_flash_tool116
-rw-r--r--firmware/microblaze/usrp2/.gitignore9
-rw-r--r--firmware/microblaze/usrp2/udp_fw_update.c34
-rw-r--r--firmware/microblaze/usrp2p/.gitignore9
-rw-r--r--firmware/microblaze/usrp2p/Makefile.am71
-rw-r--r--firmware/microblaze/usrp2p/bootloader/.gitignore11
-rw-r--r--firmware/microblaze/usrp2p/bootloader/Makefile.am39
-rw-r--r--firmware/microblaze/usrp2p/bootloader_utils.c39
-rw-r--r--firmware/zpu/.gitignore1
-rw-r--r--firmware/zpu/AUTHORS (renamed from firmware/microblaze/AUTHORS)1
-rw-r--r--firmware/zpu/CMakeLists.txt121
-rw-r--r--firmware/zpu/README16
-rw-r--r--firmware/zpu/apps/blinkenlights.c (renamed from firmware/microblaze/apps/blinkenlights.c)4
-rw-r--r--firmware/zpu/apps/flash_test.c (renamed from firmware/microblaze/apps/flash_test.c)0
-rw-r--r--firmware/zpu/apps/hardware_testbed.c (renamed from firmware/microblaze/apps/hardware_testbed.c)0
-rw-r--r--firmware/zpu/apps/txrx_uhd.c (renamed from firmware/microblaze/apps/txrx_uhd.c)339
-rw-r--r--firmware/zpu/apps/uart_flash_loader.c (renamed from firmware/microblaze/apps/uart_flash_loader.c)4
-rwxr-xr-xfirmware/zpu/bin/bin_to_mif.py (renamed from firmware/microblaze/bin/bin_to_mif.py)0
-rwxr-xr-xfirmware/zpu/bin/bin_to_ram_macro_init.py (renamed from firmware/microblaze/bin/bin_to_ram_macro_init.py)5
-rwxr-xr-xfirmware/zpu/bin/divisors.py (renamed from firmware/microblaze/divisors.py)0
-rwxr-xr-xfirmware/zpu/bin/elf_to_sbf (renamed from firmware/microblaze/bin/elf_to_sbf)0
-rwxr-xr-x[-rw-r--r--]firmware/zpu/bin/sbf.py (renamed from firmware/microblaze/bin/sbf.py)0
-rwxr-xr-xfirmware/zpu/bin/serial_loader (renamed from firmware/microblaze/bin/serial_loader)0
-rwxr-xr-xfirmware/zpu/bin/uart_ihex_flash_loader.py (renamed from firmware/microblaze/bin/uart_ihex_flash_loader.py)0
-rwxr-xr-xfirmware/zpu/bin/uart_ihex_ram_loader.py (renamed from firmware/microblaze/bin/uart_ihex_ram_loader.py)0
-rw-r--r--firmware/zpu/lib/CMakeLists.txt47
-rw-r--r--firmware/zpu/lib/_exit.c (renamed from firmware/microblaze/lib/_exit.c)0
-rw-r--r--firmware/zpu/lib/abort.c (renamed from firmware/microblaze/lib/abort.c)0
-rw-r--r--firmware/zpu/lib/ad9510.c (renamed from firmware/microblaze/lib/ad9510.c)0
-rw-r--r--firmware/zpu/lib/ad9510.h (renamed from firmware/microblaze/lib/ad9510.h)0
-rw-r--r--firmware/zpu/lib/arp_cache.c (renamed from firmware/microblaze/lib/arp_cache.c)2
-rw-r--r--firmware/zpu/lib/arp_cache.h (renamed from firmware/microblaze/lib/arp_cache.h)2
-rw-r--r--firmware/zpu/lib/banal.c (renamed from firmware/microblaze/lib/banal.c)2
-rw-r--r--firmware/zpu/lib/banal.h (renamed from firmware/microblaze/lib/banal.h)23
-rw-r--r--firmware/zpu/lib/clock_bits.h (renamed from firmware/microblaze/lib/clock_bits.h)0
-rw-r--r--firmware/zpu/lib/clocks.c (renamed from firmware/microblaze/lib/clocks.c)0
-rw-r--r--firmware/zpu/lib/clocks.h (renamed from firmware/microblaze/lib/clocks.h)0
-rw-r--r--firmware/zpu/lib/compiler.h (renamed from firmware/microblaze/lib/compiler.h)3
-rw-r--r--firmware/zpu/lib/eeprom.c (renamed from firmware/microblaze/lib/eeprom.c)0
-rw-r--r--firmware/zpu/lib/eth_addrs.c (renamed from firmware/microblaze/lib/eth_addrs.c)12
-rw-r--r--firmware/zpu/lib/eth_mac.c (renamed from firmware/microblaze/lib/eth_mac.c)4
-rw-r--r--firmware/zpu/lib/eth_mac.h (renamed from firmware/microblaze/lib/eth_mac.h)0
-rw-r--r--firmware/zpu/lib/eth_mac_regs.h (renamed from firmware/microblaze/lib/eth_mac_regs.h)0
-rw-r--r--firmware/zpu/lib/ethernet.h (renamed from firmware/microblaze/lib/ethernet.h)0
-rw-r--r--firmware/zpu/lib/ethertype.h (renamed from firmware/microblaze/lib/ethertype.h)2
-rw-r--r--firmware/zpu/lib/exit.c (renamed from firmware/microblaze/lib/exit.c)0
-rw-r--r--firmware/zpu/lib/hal_io.c (renamed from firmware/microblaze/lib/hal_io.c)4
-rw-r--r--firmware/zpu/lib/hal_io.h (renamed from firmware/microblaze/lib/hal_io.h)26
-rw-r--r--firmware/zpu/lib/hal_uart.c (renamed from firmware/microblaze/lib/hal_uart.c)13
-rw-r--r--firmware/zpu/lib/hal_uart.h (renamed from firmware/microblaze/lib/hal_uart.h)6
-rw-r--r--firmware/zpu/lib/i2c.c (renamed from firmware/microblaze/lib/i2c.c)0
-rw-r--r--firmware/zpu/lib/i2c.h (renamed from firmware/microblaze/lib/i2c.h)0
-rw-r--r--firmware/zpu/lib/i2c_async.c (renamed from firmware/microblaze/lib/i2c_async.c)0
-rw-r--r--firmware/zpu/lib/i2c_async.h (renamed from firmware/microblaze/lib/i2c_async.h)0
-rw-r--r--firmware/zpu/lib/if_arp.h (renamed from firmware/microblaze/lib/if_arp.h)0
-rw-r--r--firmware/zpu/lib/ihex.c (renamed from firmware/microblaze/lib/ihex.c)0
-rw-r--r--firmware/zpu/lib/ihex.h (renamed from firmware/microblaze/lib/ihex.h)0
-rw-r--r--firmware/zpu/lib/mdelay.c (renamed from firmware/microblaze/apps/cruft/blink_leds.c)29
-rw-r--r--firmware/zpu/lib/mdelay.h (renamed from firmware/microblaze/lib/mdelay.h)0
-rw-r--r--firmware/zpu/lib/memcpy_wa.c (renamed from firmware/microblaze/lib/memcpy_wa.c)0
-rw-r--r--firmware/zpu/lib/memcpy_wa.h (renamed from firmware/microblaze/lib/memcpy_wa.h)0
-rw-r--r--firmware/zpu/lib/memset_wa.c (renamed from firmware/microblaze/lib/memset_wa.c)0
-rw-r--r--firmware/zpu/lib/memset_wa.h (renamed from firmware/microblaze/lib/memset_wa.h)0
-rw-r--r--firmware/zpu/lib/net/eth_mac_addr.h (renamed from firmware/microblaze/lib/net/eth_mac_addr.h)2
-rw-r--r--firmware/zpu/lib/net/padded_eth_hdr.h (renamed from firmware/microblaze/lib/net/padded_eth_hdr.h)0
-rw-r--r--firmware/zpu/lib/net/socket_address.h (renamed from firmware/microblaze/lib/net/socket_address.h)0
-rw-r--r--firmware/zpu/lib/net_common.c (renamed from firmware/microblaze/lib/net_common.c)124
-rw-r--r--firmware/zpu/lib/net_common.h (renamed from firmware/microblaze/lib/net_common.h)19
-rw-r--r--firmware/zpu/lib/nonstdio.c (renamed from firmware/microblaze/lib/nonstdio.c)0
-rw-r--r--firmware/zpu/lib/nonstdio.h (renamed from firmware/microblaze/lib/nonstdio.h)9
-rw-r--r--firmware/zpu/lib/pic.c (renamed from firmware/microblaze/lib/pic.c)21
-rw-r--r--firmware/zpu/lib/pic.h (renamed from firmware/microblaze/lib/pic.h)3
-rw-r--r--firmware/zpu/lib/pkt_ctrl.c100
-rw-r--r--firmware/zpu/lib/pkt_ctrl.h63
-rw-r--r--firmware/zpu/lib/print_addrs.c (renamed from firmware/microblaze/lib/print_mac_addr.c)9
-rw-r--r--firmware/zpu/lib/print_buffer.c (renamed from firmware/microblaze/lib/print_buffer.c)0
-rw-r--r--firmware/zpu/lib/print_rmon_regs.c (renamed from firmware/microblaze/lib/print_rmon_regs.c)0
-rw-r--r--firmware/zpu/lib/print_rmon_regs.h (renamed from firmware/microblaze/lib/print_rmon_regs.h)0
-rw-r--r--firmware/zpu/lib/printf.c (renamed from firmware/microblaze/lib/printf.c)0
-rw-r--r--firmware/zpu/lib/printf.c.smaller (renamed from firmware/microblaze/lib/printf.c.smaller)0
-rw-r--r--firmware/zpu/lib/spi.c (renamed from firmware/microblaze/lib/spi.c)6
-rw-r--r--firmware/zpu/lib/spi.h (renamed from firmware/microblaze/lib/spi.h)8
-rw-r--r--firmware/zpu/lib/stdint.h (renamed from firmware/microblaze/lib/stdint.h)0
-rw-r--r--firmware/zpu/lib/stdio.h (renamed from firmware/microblaze/lib/stdio.h)0
-rw-r--r--firmware/zpu/lib/u2_init.c (renamed from firmware/microblaze/lib/u2_init.c)41
-rw-r--r--firmware/zpu/lib/u2_init.h (renamed from firmware/microblaze/lib/u2_init.h)0
-rw-r--r--firmware/zpu/lib/udp_fw_update.h (renamed from firmware/microblaze/lib/udp_fw_update.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/CHANGELOG (renamed from firmware/microblaze/lwip/lwip-1.3.1/CHANGELOG)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/COPYING (renamed from firmware/microblaze/lwip/lwip-1.3.1/COPYING)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/FILES (renamed from firmware/microblaze/lwip/lwip-1.3.1/FILES)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/README (renamed from firmware/microblaze/lwip/lwip-1.3.1/README)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/doc/FILES (renamed from firmware/microblaze/lwip/lwip-1.3.1/doc/FILES)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/doc/contrib.txt (renamed from firmware/microblaze/lwip/lwip-1.3.1/doc/contrib.txt)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/doc/rawapi.txt (renamed from firmware/microblaze/lwip/lwip-1.3.1/doc/rawapi.txt)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/doc/savannah.txt (renamed from firmware/microblaze/lwip/lwip-1.3.1/doc/savannah.txt)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/doc/snmp_agent.txt (renamed from firmware/microblaze/lwip/lwip-1.3.1/doc/snmp_agent.txt)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/doc/sys_arch.txt (renamed from firmware/microblaze/lwip/lwip-1.3.1/doc/sys_arch.txt)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/.hgignore (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/.hgignore)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/FILES (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/FILES)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/api_lib.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/api_lib.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/api_msg.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/api_msg.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/err.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/err.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/netbuf.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/netbuf.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/netdb.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/netdb.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/netifapi.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/netifapi.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/sockets.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/sockets.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/api/tcpip.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/api/tcpip.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/#tcp_out.c# (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/#tcp_out.c#)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/dhcp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/dhcp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/dns.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/dns.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/init.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/init.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/autoip.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/autoip.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/icmp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/icmp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/igmp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/igmp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/inet.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/inet.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/inet_chksum.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/inet_chksum.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip_addr.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip_addr.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip_frag.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip_frag.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/README (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/README)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/icmp6.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/icmp6.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/inet6.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/inet6.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/ip6.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/ip6.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/ip6_addr.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/ip6_addr.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/mem.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/mem.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/memp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/memp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/netif.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/netif.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/pbuf.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/pbuf.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/raw.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/raw.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/asn1_dec.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/asn1_dec.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/asn1_enc.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/asn1_enc.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/mib2.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/mib2.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/mib_structs.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/mib_structs.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/msg_in.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/msg_in.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/msg_out.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/msg_out.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/stats.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/stats.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/sys.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/sys.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/tcp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/tcp_in.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp_in.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/tcp_out.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp_out.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/core/udp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/core/udp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/autoip.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/autoip.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/icmp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/icmp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/igmp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/igmp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet_chksum.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet_chksum.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_addr.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_addr.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_frag.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_frag.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/icmp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/icmp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/inet.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/inet.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip_addr.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip_addr.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/api.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/api.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/api_msg.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/api_msg.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/arch.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/arch.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/debug.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/debug.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/def.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/def.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/dhcp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/dhcp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/dns.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/dns.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/err.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/err.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/init.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/init.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/mem.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/mem.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/memp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/memp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/memp_std.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/memp_std.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netbuf.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netbuf.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netdb.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netdb.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netif.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netif.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netifapi.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netifapi.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/opt.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/opt.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/pbuf.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/pbuf.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/raw.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/raw.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sio.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sio.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_asn1.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_asn1.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_msg.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_msg.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_structs.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_structs.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sockets.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sockets.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/stats.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/stats.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sys.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sys.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/tcp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/tcp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/tcpip.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/tcpip.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/udp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/udp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/netif/etharp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/etharp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/netif/loopif.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/loopif.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/netif/ppp_oe.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/ppp_oe.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/include/netif/slipif.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/slipif.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/FILES (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/FILES)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/etharp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/etharp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ethernetif.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ethernetif.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/loopif.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/loopif.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/auth.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/auth.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/auth.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/auth.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chap.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chap.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chap.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chap.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chpms.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chpms.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chpms.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chpms.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/fsm.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/fsm.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/fsm.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/fsm.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ipcp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ipcp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ipcp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ipcp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/lcp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/lcp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/lcp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/lcp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/magic.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/magic.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/magic.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/magic.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/md5.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/md5.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/md5.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/md5.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pap.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pap.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pap.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pap.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp_oe.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp_oe.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pppdebug.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pppdebug.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/randm.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/randm.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/randm.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/randm.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vj.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vj.c)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vj.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vj.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vjbsdhdr.h (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vjbsdhdr.h)0
-rw-r--r--firmware/zpu/lwip/lwip-1.3.1/src/netif/slipif.c (renamed from firmware/microblaze/lwip/lwip-1.3.1/src/netif/slipif.c)0
-rw-r--r--firmware/zpu/lwip/lwipopts.h (renamed from firmware/microblaze/lwip/lwipopts.h)0
-rw-r--r--firmware/zpu/lwip/lwippools.h (renamed from firmware/microblaze/lwip/lwippools.h)0
-rw-r--r--firmware/zpu/lwip_port/arch/cc.h (renamed from firmware/microblaze/lwip_port/arch/cc.h)0
-rw-r--r--firmware/zpu/lwip_port/arch/perf.h (renamed from firmware/microblaze/lwip_port/arch/perf.h)0
-rw-r--r--firmware/zpu/lwip_port/netif/eth_driver.c (renamed from firmware/microblaze/lwip_port/netif/eth_driver.c)0
-rw-r--r--firmware/zpu/lwip_port/netif/eth_driver.h (renamed from firmware/microblaze/lwip_port/netif/eth_driver.h)0
-rw-r--r--firmware/zpu/usrp2/CMakeLists.txt37
-rw-r--r--firmware/zpu/usrp2/eth_phy.h (renamed from firmware/microblaze/usrp2/eth_phy.h)0
-rw-r--r--firmware/zpu/usrp2/ethernet.c (renamed from firmware/microblaze/usrp2/ethernet.c)0
-rw-r--r--firmware/zpu/usrp2/memory_map.h (renamed from firmware/microblaze/usrp2/memory_map.h)183
-rw-r--r--firmware/zpu/usrp2/sd.c (renamed from firmware/microblaze/usrp2/sd.c)2
-rw-r--r--firmware/zpu/usrp2/sd.h (renamed from firmware/microblaze/usrp2/sd.h)2
-rw-r--r--firmware/zpu/usrp2p/CMakeLists.txt51
-rw-r--r--firmware/zpu/usrp2p/bootconfig.h (renamed from firmware/microblaze/usrp2p/bootconfig.h)2
-rw-r--r--firmware/zpu/usrp2p/bootloader/CMakeLists.txt40
-rw-r--r--firmware/zpu/usrp2p/bootloader/fpga_bootloader.c (renamed from firmware/microblaze/usrp2p/bootloader/fpga_bootloader.c)2
-rw-r--r--firmware/zpu/usrp2p/bootloader/fw_bootloader.c (renamed from firmware/microblaze/usrp2p/bootloader/fw_bootloader.c)2
-rw-r--r--firmware/zpu/usrp2p/bootloader/icap_test.c (renamed from firmware/microblaze/usrp2p/bootloader/icap_test.c)0
-rw-r--r--firmware/zpu/usrp2p/bootloader/init_bootloader.c (renamed from firmware/microblaze/usrp2p/bootloader/init_bootloader.c)31
-rw-r--r--firmware/zpu/usrp2p/bootloader/serial_loader_burner.c (renamed from firmware/microblaze/usrp2p/bootloader/serial_loader_burner.c)2
-rw-r--r--firmware/zpu/usrp2p/bootloader/spi_bootloader.c (renamed from firmware/microblaze/usrp2p/bootloader/spi_bootloader.c)2
-rw-r--r--firmware/zpu/usrp2p/bootloader/u2p2-rom.ld (renamed from firmware/microblaze/usrp2p/bootloader/u2p2-rom.ld)0
-rw-r--r--firmware/zpu/usrp2p/bootloader_utils.c48
-rw-r--r--firmware/zpu/usrp2p/bootloader_utils.h (renamed from firmware/microblaze/usrp2p/bootloader_utils.h)6
-rw-r--r--firmware/zpu/usrp2p/eth_phy.h (renamed from firmware/microblaze/usrp2p/eth_phy.h)0
-rw-r--r--firmware/zpu/usrp2p/ethernet.c (renamed from firmware/microblaze/usrp2p/ethernet.c)95
-rw-r--r--firmware/zpu/usrp2p/memory_map.h (renamed from firmware/microblaze/usrp2p/memory_map.h)253
-rw-r--r--firmware/zpu/usrp2p/spi_flash.c (renamed from firmware/microblaze/usrp2p/spi_flash.c)2
-rw-r--r--firmware/zpu/usrp2p/spi_flash.h (renamed from firmware/microblaze/usrp2p/spi_flash.h)19
-rw-r--r--firmware/zpu/usrp2p/spi_flash_private.h (renamed from firmware/microblaze/usrp2p/spi_flash_private.h)2
-rw-r--r--firmware/zpu/usrp2p/spi_flash_read.c (renamed from firmware/microblaze/usrp2p/spi_flash_read.c)71
-rw-r--r--firmware/zpu/usrp2p/spif.c (renamed from firmware/microblaze/usrp2p/spif.c)2
-rw-r--r--firmware/zpu/usrp2p/u2p_init.c (renamed from firmware/microblaze/apps/cruft/echo.c)28
-rw-r--r--firmware/zpu/usrp2p/u2p_init.h (renamed from firmware/microblaze/lib/gdbstub2.h)11
-rw-r--r--firmware/zpu/usrp2p/udp_fw_update.c (renamed from firmware/microblaze/usrp2p/udp_fw_update.c)0
-rw-r--r--firmware/zpu/usrp2p/xilinx_s3_icap.c (renamed from firmware/microblaze/usrp2p/xilinx_s3_icap.c)2
-rw-r--r--firmware/zpu/usrp2p/xilinx_s3_icap.h (renamed from firmware/microblaze/usrp2p/xilinx_s3_icap.h)2
-rwxr-xr-xfix-copyright-years71
-rw-r--r--fpga/usrp2/control_lib/Makefile.srcs1
-rw-r--r--fpga/usrp2/control_lib/wb_readback_mux_16LE.v73
-rw-r--r--fpga/usrp2/coregen/_xmsgs/pn_parser.xmsgs15
-rw-r--r--fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_18to36.ncf0
-rw-r--r--fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_36to18.ncf0
-rw-r--r--fpga/usrp2/fifo/Makefile.srcs6
-rw-r--r--fpga/usrp2/fifo/buffer_int.v1
-rw-r--r--fpga/usrp2/fifo/buffer_int2.v173
-rw-r--r--fpga/usrp2/fifo/crossbar36.v42
-rw-r--r--fpga/usrp2/fifo/dsp_framer36.v98
-rw-r--r--fpga/usrp2/fifo/packet_router.v535
-rw-r--r--fpga/usrp2/fifo/splitter36.v68
-rw-r--r--fpga/usrp2/fifo/valve36.v29
-rw-r--r--fpga/usrp2/opencores/Makefile.srcs8
-rw-r--r--fpga/usrp2/opencores/zpu/core/zpu_config.vhd15
-rw-r--r--fpga/usrp2/opencores/zpu/core/zpu_core.vhd949
-rw-r--r--fpga/usrp2/opencores/zpu/core/zpupkg.vhd169
-rw-r--r--fpga/usrp2/opencores/zpu/wishbone/wishbone_pkg.vhd86
-rw-r--r--fpga/usrp2/opencores/zpu/wishbone/zpu_system.vhd106
-rw-r--r--fpga/usrp2/opencores/zpu/wishbone/zpu_wb_bridge.vhd83
-rw-r--r--fpga/usrp2/opencores/zpu/zpu_top_pkg.vhd46
-rw-r--r--fpga/usrp2/opencores/zpu/zpu_wb_top.vhd76
-rw-r--r--fpga/usrp2/simple_gemac/Makefile.srcs1
-rw-r--r--fpga/usrp2/simple_gemac/address_filter_promisc.v32
-rw-r--r--fpga/usrp2/simple_gemac/eth_tasks_f36.v6
-rw-r--r--fpga/usrp2/simple_gemac/simple_gemac_rx.v10
-rw-r--r--fpga/usrp2/simple_gemac/simple_gemac_wb.v27
-rwxr-xr-xfpga/usrp2/simple_gemac/simple_gemac_wrapper.build2
-rwxr-xr-xfpga/usrp2/simple_gemac/simple_gemac_wrapper19.build2
-rw-r--r--fpga/usrp2/simple_gemac/simple_gemac_wrapper19_tb.v10
-rw-r--r--fpga/usrp2/simple_gemac/simple_gemac_wrapper_tb.v6
-rw-r--r--fpga/usrp2/timing/time_64bit.v8
-rw-r--r--fpga/usrp2/timing/time_receiver.v36
-rw-r--r--fpga/usrp2/top/u1e/u1e_core.v20
-rw-r--r--fpga/usrp2/top/u2_rev3/u2_core.v183
-rw-r--r--fpga/usrp2/top/u2_rev3/u2_rev3.v2
-rw-r--r--fpga/usrp2/top/u2plus/bootloader.rmi481
-rw-r--r--fpga/usrp2/top/u2plus/u2plus_core.v247
-rw-r--r--fpga/usrp2/udp/prot_eng_tx.v56
-rw-r--r--fpga/usrp2/udp/prot_eng_tx_tb.v27
-rw-r--r--fpga/usrp2/vrt/gen_context_pkt.v7
-rw-r--r--fpga/usrp2/vrt/vita_tx_chain.v7
-rw-r--r--fpga/usrp2/vrt/vita_tx_control.v34
-rw-r--r--host/CMakeLists.txt26
-rw-r--r--host/Modules/FindDocutils.cmake2
-rw-r--r--host/Modules/FindGit.cmake46
-rw-r--r--host/Modules/UHDComponent.cmake27
-rw-r--r--host/Modules/UHDVersion.cmake6
-rw-r--r--host/docs/CMakeLists.txt4
-rw-r--r--host/docs/transport.rst2
-rw-r--r--host/docs/usrp1.rst46
-rw-r--r--host/docs/usrp2.rst64
-rw-r--r--host/examples/rx_ascii_art_dft.cpp8
-rw-r--r--host/examples/rx_samples_to_file.cpp7
-rw-r--r--host/examples/rx_samples_to_udp.cpp7
-rw-r--r--host/examples/rx_timed_samples.cpp8
-rw-r--r--host/examples/test_pps_input.cpp37
-rw-r--r--host/examples/tx_from_file.cpp15
-rw-r--r--host/examples/tx_timed_samples.cpp16
-rw-r--r--host/examples/tx_waveforms.cpp10
-rw-r--r--host/include/uhd/CMakeLists.txt3
-rw-r--r--host/include/uhd/config.hpp92
-rw-r--r--host/include/uhd/convert.hpp90
-rw-r--r--host/include/uhd/transport/CMakeLists.txt7
-rw-r--r--host/include/uhd/transport/alignment_buffer.hpp69
-rw-r--r--host/include/uhd/transport/alignment_buffer.ipp144
-rw-r--r--host/include/uhd/transport/bounded_buffer.ipp13
-rw-r--r--host/include/uhd/transport/buffer_pool.hpp59
-rw-r--r--host/include/uhd/transport/convert_types.hpp96
-rw-r--r--host/include/uhd/transport/convert_types.ipp43
-rw-r--r--host/include/uhd/transport/if_addrs.hpp8
-rw-r--r--host/include/uhd/types/CMakeLists.txt4
-rw-r--r--host/include/uhd/types/clock_config.hpp9
-rw-r--r--host/include/uhd/types/dict.hpp24
-rw-r--r--host/include/uhd/types/dict.ipp23
-rw-r--r--host/include/uhd/types/ranges.hpp44
-rw-r--r--host/include/uhd/types/ranges.ipp188
-rw-r--r--host/include/uhd/types/sensors.hpp131
-rw-r--r--host/include/uhd/usrp/CMakeLists.txt1
-rw-r--r--host/include/uhd/usrp/codec_props.hpp6
-rw-r--r--host/include/uhd/usrp/dboard_iface.hpp8
-rw-r--r--host/include/uhd/usrp/gps_ctrl.hpp (renamed from host/lib/usrp/usrp2/gps_ctrl.hpp)13
-rw-r--r--host/include/uhd/usrp/mboard_props.hpp2
-rw-r--r--host/include/uhd/usrp/multi_usrp.hpp40
-rw-r--r--host/include/uhd/usrp/single_usrp.hpp28
-rw-r--r--host/include/uhd/usrp/subdev_props.hpp6
-rw-r--r--host/include/uhd/utils/algorithm.hpp31
-rw-r--r--host/include/uhd/utils/gain_group.hpp10
-rw-r--r--host/include/uhd/utils/static.hpp15
-rw-r--r--host/lib/CMakeLists.txt27
-rw-r--r--host/lib/convert/CMakeLists.txt65
-rw-r--r--host/lib/convert/convert_common.hpp90
-rw-r--r--host/lib/convert/convert_impl.cpp111
-rw-r--r--host/lib/convert/convert_with_neon.cpp61
-rw-r--r--host/lib/convert/convert_with_sse2.cpp148
-rw-r--r--host/lib/convert/gen_convert_general.py93
-rw-r--r--host/lib/convert/gen_convert_pred.py163
-rw-r--r--host/lib/gain_group.cpp149
-rw-r--r--host/lib/transport/CMakeLists.txt42
-rw-r--r--host/lib/transport/buffer_pool.cpp80
-rw-r--r--host/lib/transport/convert_types_impl.hpp345
-rwxr-xr-xhost/lib/transport/gen_convert_types.py211
-rw-r--r--host/lib/transport/libusb1_zero_copy.cpp29
-rw-r--r--host/lib/transport/udp_zero_copy_asio.cpp26
-rw-r--r--host/lib/transport/vrt_packet_handler.hpp46
-rw-r--r--host/lib/types.cpp350
-rw-r--r--host/lib/types/CMakeLists.txt (renamed from firmware/microblaze/usrp2/Makefile.am)42
-rw-r--r--host/lib/types/clock_config.cpp44
-rw-r--r--host/lib/types/device_addr.cpp73
-rw-r--r--host/lib/types/mac_addr.cpp76
-rw-r--r--host/lib/types/ranges.cpp163
-rw-r--r--host/lib/types/sensors.cpp81
-rw-r--r--host/lib/types/serial.cpp56
-rw-r--r--host/lib/types/time_spec.cpp86
-rw-r--r--host/lib/types/tune.cpp52
-rw-r--r--host/lib/types/types.cpp86
-rw-r--r--host/lib/usrp/CMakeLists.txt1
-rw-r--r--host/lib/usrp/dboard/db_basic_and_lf.cpp10
-rw-r--r--host/lib/usrp/dboard/db_dbsrx.cpp24
-rw-r--r--host/lib/usrp/dboard/db_dbsrx2.cpp24
-rw-r--r--host/lib/usrp/dboard/db_rfx.cpp30
-rw-r--r--host/lib/usrp/dboard/db_tvrx.cpp22
-rw-r--r--host/lib/usrp/dboard/db_unknown.cpp10
-rw-r--r--host/lib/usrp/dboard/db_wbx.cpp36
-rw-r--r--host/lib/usrp/dboard/db_xcvr2450.cpp48
-rw-r--r--host/lib/usrp/gps_ctrl.cpp (renamed from host/lib/usrp/usrp2/gps_ctrl.cpp)43
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp12
-rw-r--r--host/lib/usrp/misc_utils.cpp22
-rw-r--r--host/lib/usrp/multi_usrp.cpp44
-rw-r--r--host/lib/usrp/single_usrp.cpp20
-rw-r--r--host/lib/usrp/subdev_spec.cpp14
-rw-r--r--host/lib/usrp/usrp1/CMakeLists.txt3
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp38
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.hpp19
-rw-r--r--host/lib/usrp/usrp1/codec_impl.cpp8
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp10
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp39
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp25
-rw-r--r--host/lib/usrp/usrp1/soft_time_ctrl.cpp224
-rw-r--r--host/lib/usrp/usrp1/soft_time_ctrl.hpp69
-rw-r--r--host/lib/usrp/usrp1/usrp1_ctrl.cpp29
-rw-r--r--host/lib/usrp/usrp1/usrp1_ctrl.hpp17
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp6
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp9
-rw-r--r--host/lib/usrp/usrp2/CMakeLists.txt4
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.cpp57
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.hpp12
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.cpp8
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.hpp6
-rw-r--r--host/lib/usrp/usrp2/codec_impl.cpp12
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp12
-rw-r--r--host/lib/usrp/usrp2/fw_common.h59
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp216
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp117
-rw-r--r--host/lib/usrp/usrp2/serdes_ctrl.cpp46
-rw-r--r--host/lib/usrp/usrp2/serdes_ctrl.hpp40
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp22
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.hpp18
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp45
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp26
-rw-r--r--host/lib/usrp/usrp2/usrp2_regs.cpp10
-rw-r--r--host/lib/usrp/usrp2/usrp2_regs.hpp18
-rw-r--r--host/lib/usrp/usrp_e100/codec_ctrl.cpp32
-rw-r--r--host/lib/usrp/usrp_e100/codec_ctrl.hpp14
-rw-r--r--host/lib/usrp/usrp_e100/codec_impl.cpp8
-rw-r--r--host/lib/usrp/usrp_e100/dboard_iface.cpp10
-rw-r--r--host/lib/usrp/usrp_e100/dsp_impl.cpp4
-rw-r--r--host/lib/usrp/usrp_e100/mboard_impl.cpp30
-rw-r--r--host/lib/usrp/usrp_e100/usrp_e100_impl.hpp2
-rw-r--r--host/lib/usrp/usrp_e100/usrp_e100_regs.hpp10
-rw-r--r--host/lib/utils/CMakeLists.txt3
-rw-r--r--host/lib/utils/gain_group.cpp20
-rw-r--r--host/lib/utils/paths.cpp10
-rw-r--r--host/lib/utils/static.cpp (renamed from host/lib/transport/msvc/stdint.h)67
-rw-r--r--host/lib/utils/warning.cpp10
-rw-r--r--host/msvc/inttypes.h301
-rw-r--r--host/msvc/stdint.h226
-rw-r--r--host/tests/CMakeLists.txt (renamed from host/test/CMakeLists.txt)5
-rw-r--r--host/tests/addr_test.cpp (renamed from host/test/addr_test.cpp)0
-rw-r--r--host/tests/buffer_test.cpp (renamed from host/test/buffer_test.cpp)51
-rw-r--r--host/tests/byteswap_test.cpp (renamed from host/test/byteswap_test.cpp)0
-rw-r--r--host/tests/convert_test.cpp (renamed from host/test/convert_types_test.cpp)99
-rw-r--r--host/tests/dict_test.cpp (renamed from host/test/dict_test.cpp)0
-rw-r--r--host/tests/error_test.cpp (renamed from host/test/error_test.cpp)0
-rw-r--r--host/tests/gain_group_test.cpp (renamed from host/test/gain_group_test.cpp)38
-rw-r--r--host/tests/module_test.cpp (renamed from host/test/module_test.cpp)0
-rw-r--r--host/tests/ranges_test.cpp (renamed from host/test/ranges_test.cpp)16
-rw-r--r--host/tests/subdev_spec_test.cpp (renamed from host/test/subdev_spec_test.cpp)0
-rw-r--r--host/tests/time_spec_test.cpp (renamed from host/test/time_spec_test.cpp)0
-rw-r--r--host/tests/tune_helper_test.cpp (renamed from host/test/tune_helper_test.cpp)0
-rw-r--r--host/tests/vrt_test.cpp (renamed from host/test/vrt_test.cpp)0
-rw-r--r--host/tests/warning_test.cpp (renamed from host/test/warning_test.cpp)0
-rw-r--r--host/tests/wax_test.cpp (renamed from host/test/wax_test.cpp)0
-rw-r--r--host/utils/CMakeLists.txt1
-rw-r--r--host/utils/uhd_usrp_probe.cpp7
-rw-r--r--host/utils/usrp-e-debug-pins.c3
-rw-r--r--host/utils/usrp_e_regs.hpp196
-rw-r--r--images/CMakeLists.txt1
-rw-r--r--images/Makefile48
522 files changed, 8351 insertions, 15091 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index b275f0e49..000000000
--- a/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*~
-\#*\#
-a.out
diff --git a/firmware/README b/firmware/README
index a010493c8..251486955 100644
--- a/firmware/README
+++ b/firmware/README
@@ -1,4 +1,6 @@
-This is a placeholder for the firmware code (microblaze and 8051).
+########################################################################
+# Firmware for USRP devices
+########################################################################
-The layout should have a common library of source and header files.
-Each usrp-like will have its own device-specific libs and apps.
+fx2 - firmware for USRP1
+zpu - firmware for USRP2 and N Series
diff --git a/firmware/microblaze/.gitignore b/firmware/microblaze/.gitignore
deleted file mode 100644
index e867fe87c..000000000
--- a/firmware/microblaze/.gitignore
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-stamp
-/*.a
-/*.bin
-/*.dump
-/*.log
-/*.rom
-/.deps
-/*.guess
-/*.sub
-/Makefile
-/Makefile.in
-/aclocal.m4
-/autom4te.cache
-/blink_leds
-/blink_leds2
-/build
-/compile
-/config.h
-/config.h.in
-/config.log
-/config.status
-/configure
-/depcomp
-/eth_test
-/gen_eth_packets
-/ibs_rx_test
-/ibs_tx_test
-/install-sh
-/libtool
-/ltmain.sh
-/missing
-/py-compile
-/rcv_eth_packets
-/run_tests.sh
-/stamp-h1
-/test1
-/test_phy_comm
-/timer_test
-/buf_ram_test
-/buf_ram_zero
-/hello
-/configure.lineno
-/configure.guess
-/configure.sub
-*.deps
-*.o
diff --git a/firmware/microblaze/COPYING b/firmware/microblaze/COPYING
deleted file mode 100644
index 94a9ed024..000000000
--- a/firmware/microblaze/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/firmware/microblaze/ChangeLog b/firmware/microblaze/ChangeLog
deleted file mode 100644
index 8b1378917..000000000
--- a/firmware/microblaze/ChangeLog
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/firmware/microblaze/INSTALL b/firmware/microblaze/INSTALL
deleted file mode 100644
index 5458714e1..000000000
--- a/firmware/microblaze/INSTALL
+++ /dev/null
@@ -1,234 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006 Free Software Foundation, Inc.
-
-This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-Basic Installation
-==================
-
-Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package. The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
- It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
- The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system.
-
- Running `configure' might take a while. While running, it prints
- some messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about. Run `./configure --help' for
-details on some of the pertinent environment variables.
-
- You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment. Here
-is an example:
-
- ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
- *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
-You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you can use GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory. After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
-Installation Names
-==================
-
-By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc. You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
-Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
-`--build=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
- CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
- OS KERNEL-OS
-
- See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
- If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
- If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
-Variables not defined in a site shell script can be set in the
-environment passed to `configure'. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug. Until the bug is fixed you can use this workaround:
-
- CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-`configure' Invocation
-======================
-
-`configure' recognizes the following options to control how it operates.
-
-`--help'
-`-h'
- Print a summary of the options to `configure', and exit.
-
-`--version'
-`-V'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`--cache-file=FILE'
- Enable the cache: use and save the results of the tests in FILE,
- traditionally `config.cache'. FILE defaults to `/dev/null' to
- disable caching.
-
-`--config-cache'
-`-C'
- Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`configure' also accepts some other, not widely useful, options. Run
-`configure --help' for more details.
-
diff --git a/firmware/microblaze/Makefile.am b/firmware/microblaze/Makefile.am
deleted file mode 100644
index 52fa649c2..000000000
--- a/firmware/microblaze/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright 2010 Ettus Research LLC
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-#
-# 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/>.
-#
-
-include $(top_srcdir)/Makefile.common
-
-EXTRA_DIST = \
- u2_flash_tool
-
-SUBDIRS = \
- usrp2 \
- usrp2p \
- usrp2p/bootloader
-
diff --git a/firmware/microblaze/Makefile.common b/firmware/microblaze/Makefile.common
deleted file mode 100644
index 4e726edab..000000000
--- a/firmware/microblaze/Makefile.common
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Copyright 2010 Ettus Research LLC
-#
-# Copyright 2007 Free Software Foundation, Inc.
-#
-# 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/>.
-#
-
-include $(top_srcdir)/lib/Makefile.inc
-
-########################################################################
-# lwIP header include dirs
-########################################################################
-LWIPDIR = $(top_srcdir)/lwip/lwip-1.3.1
-
-LWIP_INCLUDES = \
- -I$(top_srcdir)/lwip \
- -I$(top_srcdir)/lwip_port \
- -I$(LWIPDIR)/src/include \
- -I$(LWIPDIR)/src/include/ipv4
-
-########################################################################
-# misc flags for the mb-gcc compiler
-########################################################################
-MBGCC_CFLAGS = \
- --std=gnu99 -Wall -Werror-implicit-function-declaration \
- -mxl-soft-div -msoft-float -mxl-soft-mul -mxl-barrel-shift
-
-########################################################################
-# define for the hal io (FIXME move?)
-########################################################################
-#HAL_IO = -DHAL_IO_USES_DBOARD_PINS
-HAL_IO = -DHAL_IO_USES_UART
-
-########################################################################
-# common cflags and ldflags
-########################################################################
-COMMON_CFLAGS = \
- -I$(top_srcdir)/../../host/lib/usrp \
- -I$(top_srcdir)/lib \
- $(MBGCC_CFLAGS) \
- $(LWIP_INCLUDES) \
- $(HAL_IO)
-
-COMMON_LFLAGS = \
- -Wl,-Map -Wl,$(@:.elf=.map)
-
-########################################################################
-# Common stuff for building top level microblaze images
-########################################################################
-#we use COMMON_IHX_ARGS to relocate the reset and interrupt vectors to
-#just below the start of code. upon creating the BIN, any leading padding
-#is thrown out, so the .bin file is valid for uploading to USRP2P. this
-#does not affect USRP2 because the USRP2 already starts at 0x0000, and
-#because the relocate_args are not defined for USRP2's Makefile.am.
-.elf.bin:
- $(MB_OBJCOPY) -O binary $(RELOCATE_ARGS) $< $@
-
-.elf.dump:
- $(MB_OBJDUMP) -DSC $< > $@
-
-.bin.rom:
- $(HEXDUMP) -v -e'1/1 "%.2X\n"' $< > $@
-
-.elf.ihx:
- $(MB_OBJCOPY) -O ihex $(RELOCATE_ARGS) $< $@
-
-_generated_from_elf = \
- $(noinst_PROGRAMS:.elf=.map) \
- $(noinst_PROGRAMS:.elf=.bin) \
- $(noinst_PROGRAMS:.elf=.dump) \
- $(noinst_PROGRAMS:.elf=.rom) \
- $(noinst_PROGRAMS:.elf=.ihx)
-
-noinst_DATA = $(_generated_from_elf)
-
-MOSTLYCLEANFILES = $(_generated_from_elf)
diff --git a/firmware/microblaze/NEWS b/firmware/microblaze/NEWS
deleted file mode 100644
index e69de29bb..000000000
--- a/firmware/microblaze/NEWS
+++ /dev/null
diff --git a/firmware/microblaze/README b/firmware/microblaze/README
deleted file mode 100644
index 1479ffe1f..000000000
--- a/firmware/microblaze/README
+++ /dev/null
@@ -1,3 +0,0 @@
-./bootstrap
-./configure --host=mb
-make
diff --git a/firmware/microblaze/apps/bitrot/tx_drop.c b/firmware/microblaze/apps/bitrot/tx_drop.c
deleted file mode 100644
index 3a336e938..000000000
--- a/firmware/microblaze/apps/bitrot/tx_drop.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common.h"
-#include "print_rmon_regs.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-/*
- * Like tx_only.c, but we discard data packets instead of sending them to the
- * DSP TX pipeline.
- */
-
-int total_rx_pkts = 0;
-int total_rx_bytes = 0;
-
-
-static int timer_delta = MASTER_CLK_RATE/1000; // tick at 1kHz
-
-/*
- * This program can respond to queries from the host
- * and stream rx samples.
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-//#define CPU_TX_BUF 1 // cpu -> eth
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-
-/*
- * ================================================================
- * configure DSP TX double buffering state machine
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE 4
-#define DSP_TX_SAMPLES_PER_FRAME 250 // not used except w/ debugging
-#define DSP_TX_EXTRA_LINES 2 // reads word0 + timestamp
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past ethernet header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-
-// ----------------------------------------------------------------
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
-}
-
-// Tx DSP underrun
-void
-underrun_irq_handler(unsigned irq)
-{
- putchar('U');
-
- dbsm_stop(&dsp_tx_sm);
- dsp_tx_regs->clear_state = 1;
- dbsm_start(&dsp_tx_sm); // restart sm so we're listening to ethernet again
-
- // putstr("\nirq: underrun\n");
-}
-
-
-void
-start_rx_cmd(const eth_mac_addr_t *host, op_start_rx_t *p)
-{
-}
-
-void
-stop_rx_cmd(void)
-{
-}
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
- int tx_scale = 256;
- int interp = 32;
-
- op_config_tx_t def_config;
- memset(&def_config, 0, sizeof(def_config));
- def_config.phase_inc = 408021893; // 9.5 MHz [2**32 * fc/fsample]
- def_config.scale_iq = (tx_scale << 16) | tx_scale;
- def_config.interp = interp;
-
- // setup Tx DSP regs
- config_tx_cmd(&def_config);
-}
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- if (status & BPS_ERROR_ALL){
- // FIXME rare path, handle error conditions
- putstr("Errors! status = ");
- puthex32_nl(status);
-
- printf("total_rx_pkts = %d\n", total_rx_pkts);
- printf("total_rx_bytes = %d\n", total_rx_bytes);
-
- print_rmon_regs();
-
- if (status & (BPS_ERROR(DSP_TX_BUF_0) | BPS_ERROR(DSP_TX_BUF_1))){
- dbsm_stop(&dsp_tx_sm);
- dsp_tx_regs->clear_state = 1; // try to restart
- dbsm_start(&dsp_tx_sm);
- return;
- }
- }
-
- dbsm_process_status(&dsp_tx_sm, status);
-
- if (status & BPS_DONE(CPU_TX_BUF)){
- bp_clear_buf(CPU_TX_BUF);
- }
-}
-
-
-/*
- * Called when an ethernet packet is received.
- *
- * Claim that we handled all the packets,
- * dropping those destined for the TX DSP chain
- * on the ground.
- */
-bool
-nop_eth_pkt_inspector(dbsm_t *sm, int bufno)
-{
- hal_toggle_leds(0x1);
-
- u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno);
- size_t byte_len = (buffer_pool_status->last_line[bufno] - 1) * 4;
-
- total_rx_pkts++;
- total_rx_bytes += byte_len;
-
- // inspect rcvd frame and figure out what do do.
-
- if (pkt->ehdr.ethertype != U2_ETHERTYPE)
- return true; // ignore, probably bogus PAUSE frame from MAC
-
- int chan = u2p_chan(&pkt->fixed);
-
- switch (chan){
- case CONTROL_CHAN:
- handle_control_chan_frame(pkt, byte_len);
- return true; // we handled the packet
- break;
-
- case 0:
- default:
- return true; // We handled the data by dropping it :)
- break;
- }
-}
-
-
-int
-main(void)
-{
- u2_init();
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- hal_gpio_set_tx_mode(15, 0, GPIOM_FPGA_1);
- hal_gpio_set_rx_mode(15, 0, GPIOM_FPGA_1);
-
- putstr("\ntx_drop\n");
-
- // Control LEDs
- hal_set_leds(0x0, 0x3);
-
- pic_register_handler(IRQ_UNDERRUN, underrun_irq_handler);
-
- ethernet_register_link_changed_callback(link_changed_callback);
- ethernet_init();
-
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- nop_eth_pkt_inspector);
-
- // program tx registers
- setup_tx();
-
- // kick off the state machine
- dbsm_start(&dsp_tx_sm);
-
- while(1){
- buffer_irq_handler(0);
- }
-}
-
diff --git a/firmware/microblaze/apps/bitrot/tx_drop2.c b/firmware/microblaze/apps/bitrot/tx_drop2.c
deleted file mode 100644
index 3afd722e6..000000000
--- a/firmware/microblaze/apps/bitrot/tx_drop2.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common.h"
-#include "print_rmon_regs.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-/*
- * Like tx_only.c, but we discard data packets instead of sending them to the
- * DSP TX pipeline.
- */
-
-int total_rx_pkts = 0;
-int total_rx_bytes = 0;
-
-
-static int timer_delta = MASTER_CLK_RATE/1000; // tick at 1kHz
-
-/*
- * This program can respond to queries from the host
- * and stream rx samples.
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-//#define CPU_TX_BUF 1 // cpu -> eth
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-
-/*
- * ================================================================
- * configure DSP RX double buffering state machine
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line (word0)
-// DSP Rx writes timestamp followed by nlines_per_frame of samples
-#define DSP_RX_FIRST_LINE 5
-#define DSP_RX_SAMPLES_PER_FRAME 128
-#define DSP_RX_EXTRA_LINES 1 // writes timestamp
-
-// Receive from DSP Rx
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to ethernet
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_ETH,
- 0, // starts with ethernet header in line 0
- 0, // filled in from last_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-/*
- * ================================================================
- * configure DSP TX double buffering state machine
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE 4
-#define DSP_TX_SAMPLES_PER_FRAME 250 // not used except w/ debugging
-#define DSP_TX_EXTRA_LINES 2 // reads word0 + timestamp
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past ethernet header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-
-// ----------------------------------------------------------------
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
-}
-
-// Tx DSP underrun
-void
-underrun_irq_handler(unsigned irq)
-{
- putchar('U');
-
- dbsm_stop(&dsp_tx_sm);
- dsp_tx_regs->clear_state = 1;
- dbsm_start(&dsp_tx_sm); // restart sm so we're listening to ethernet again
-
- // putstr("\nirq: underrun\n");
-}
-
-
-void
-start_rx_cmd(const eth_mac_addr_t *host, op_start_rx_t *p)
-{
-}
-
-void
-stop_rx_cmd(void)
-{
-}
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
-#if 1
- int tx_scale = 256;
- int interp = 32;
-
- op_config_tx_t def_config;
- memset(&def_config, 0, sizeof(def_config));
- def_config.phase_inc = 408021893; // 9.5 MHz [2**32 * fc/fsample]
- def_config.scale_iq = (tx_scale << 16) | tx_scale;
- def_config.interp = interp;
-
- // setup Tx DSP regs
- config_tx_cmd(&def_config);
-#endif
-}
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- if (status & BPS_ERROR_ALL){
- // FIXME rare path, handle error conditions
- putstr("Errors! status = ");
- puthex32_nl(status);
-
- printf("total_rx_pkts = %d\n", total_rx_pkts);
- printf("total_rx_bytes = %d\n", total_rx_bytes);
-
- print_rmon_regs();
-
- if (status & (BPS_ERROR(DSP_TX_BUF_0) | BPS_ERROR(DSP_TX_BUF_1))){
- dbsm_stop(&dsp_tx_sm);
- dsp_tx_regs->clear_state = 1; // try to restart
- dbsm_start(&dsp_tx_sm);
- return;
- }
- }
-
- dbsm_process_status(&dsp_tx_sm, status);
-
- if (status & BPS_DONE(CPU_TX_BUF)){
- bp_clear_buf(CPU_TX_BUF);
- }
-}
-
-/*
- * Called when an ethernet packet is received.
- * Return true if we handled it here (always!)
- */
-bool
-nop_eth_pkt_inspector(dbsm_t *sm, int bufno)
-{
- hal_toggle_leds(0x1);
-
- u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno);
- size_t byte_len = (buffer_pool_status->last_line[bufno] - 1) * 4;
-
- total_rx_pkts++;
- total_rx_bytes += byte_len;
-
- // inspect rcvd frame and figure out what do do.
-
- if (pkt->ehdr.ethertype != U2_ETHERTYPE)
- return true; // ignore, probably bogus PAUSE frame from MAC
-
- int chan = u2p_chan(&pkt->fixed);
-
- switch (chan){
- case CONTROL_CHAN:
- handle_control_chan_frame(pkt, byte_len);
- return true; // we handled the packet
- break;
-
- case 0:
- default:
- return true; // say we handled it
- break;
- }
-}
-
-
-int
-main(void)
-{
- u2_init();
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- hal_gpio_set_tx_mode(15, 0, GPIOM_FPGA_1);
- hal_gpio_set_rx_mode(15, 0, GPIOM_FPGA_1); // no printing...
-
- putstr("\ntx_drop2\n");
-
- // Control LEDs
- hal_set_leds(0x0, 0x3);
-
- // pic_register_handler(IRQ_OVERRUN, overrun_irq_handler);
- pic_register_handler(IRQ_UNDERRUN, underrun_irq_handler);
-
- //pic_register_handler(IRQ_TIMER, timer_irq_handler);
- //hal_set_timeout(timer_delta);
-
- ethernet_register_link_changed_callback(link_changed_callback);
-
- ethernet_init();
-
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- nop_eth_pkt_inspector);
-
- // program tx registers
- setup_tx();
-
- // kick off the state machine
- dbsm_start(&dsp_tx_sm);
-
- while(1){
- buffer_irq_handler(0);
- }
-}
-
diff --git a/firmware/microblaze/apps/bitrot/tx_drop_rate_limited.c b/firmware/microblaze/apps/bitrot/tx_drop_rate_limited.c
deleted file mode 100644
index 2b8db7f7d..000000000
--- a/firmware/microblaze/apps/bitrot/tx_drop_rate_limited.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common.h"
-#include "print_rmon_regs.h"
-#include "eth_mac.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-/*
- * receive packets from ethernet at a fixed rate and discard them
- */
-
-int total_rx_pkts = 0;
-int total_rx_bytes = 0;
-
-
-static int timer_delta = (int)(MASTER_CLK_RATE * 10e-6); // 10us / tick
-
-
-/*
- * This program can respond to queries from the host
- * and stream rx samples.
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-//#define CPU_TX_BUF 1 // cpu -> eth
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-
-
-// ----------------------------------------------------------------
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-static volatile bool receive_packet_now = false;
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
- receive_packet_now = true;
-}
-
-
-// Tx DSP underrun
-void
-underrun_irq_handler(unsigned irq)
-{
- putchar('U');
-}
-
-
-void
-start_rx_cmd(const eth_mac_addr_t *host, op_start_rx_t *p)
-{
-}
-
-void
-stop_rx_cmd(void)
-{
-}
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
- int tx_scale = 256;
- int interp = 32;
-
- op_config_tx_t def_config;
- memset(&def_config, 0, sizeof(def_config));
- def_config.phase_inc = 408021893; // 9.5 MHz [2**32 * fc/fsample]
- def_config.scale_iq = (tx_scale << 16) | tx_scale;
- def_config.interp = interp;
-
- // setup Tx DSP regs
- config_tx_cmd(&def_config);
-}
-
-
-/*
- * Called when an ethernet packet is received.
- *
- * Claim that we handled all the packets,
- * dropping those destined for the TX DSP chain
- * on the ground.
- */
-bool
-nop_eth_pkt_inspector(dbsm_t *sm, int bufno)
-{
- hal_toggle_leds(0x1);
-
- u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno);
- size_t byte_len = (buffer_pool_status->last_line[bufno] - 1) * 4;
-
- total_rx_pkts++;
- total_rx_bytes += byte_len;
-
- // inspect rcvd frame and figure out what do do.
-
- if (pkt->ehdr.ethertype != U2_ETHERTYPE)
- return true; // ignore, probably bogus PAUSE frame from MAC
-
- int chan = u2p_chan(&pkt->fixed);
-
- switch (chan){
- case CONTROL_CHAN:
- handle_control_chan_frame(pkt, byte_len);
- return true; // we handled the packet
- break;
-
- case 0:
- default:
- return true; // We handled the data by dropping it :)
- break;
- }
-}
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- if (status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF)))
- bp_clear_buf(CPU_TX_BUF);
-
- if (status & (BPS_DONE(DSP_TX_BUF_0) | BPS_ERROR(DSP_TX_BUF_0))){
- bp_clear_buf(DSP_TX_BUF_0);
-
- if (status & BPS_ERROR(DSP_TX_BUF_0)){
- int crc = eth_mac_read_rmon(0x05);
- int fifo_full = eth_mac_read_rmon(0x06);
- int too_short_too_long = eth_mac_read_rmon(0x07);
- putstr("Errors! status = ");
- puthex32_nl(status);
-
- printf("crc_err\t\t= %d\n", crc);
- printf("fifo_full\t\t= %d\n", fifo_full);
- printf("too_short_too_long\t= %d\n", too_short_too_long);
-
- printf("total_rx_pkts = %d\n", total_rx_pkts);
- printf("total_rx_bytes = %d\n", total_rx_bytes);
- }
- else
- nop_eth_pkt_inspector(0, DSP_TX_BUF_0);
- }
-
- if (receive_packet_now && (status & BPS_IDLE(DSP_TX_BUF_0))){
- receive_packet_now = false;
- bp_receive_to_buf(DSP_TX_BUF_0, PORT_ETH, 1, 0, BP_LAST_LINE);
- }
-}
-
-
-int
-main(void)
-{
- u2_init();
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- hal_gpio_set_tx_mode(15, 0, GPIOM_FPGA_1);
- hal_gpio_set_rx_mode(15, 0, GPIOM_FPGA_1);
-
- putstr("\ntx_drop_rate_limited\n");
-
- // Control LEDs
- hal_set_leds(0x0, 0x3);
-
- pic_register_handler(IRQ_UNDERRUN, underrun_irq_handler);
-
- pic_register_handler(IRQ_TIMER, timer_irq_handler);
- hal_set_timeout(timer_delta);
-
- ethernet_register_link_changed_callback(link_changed_callback);
- ethernet_init();
-
- // program tx registers
- setup_tx();
-
- // start a receive from ethernet
- bp_receive_to_buf(DSP_TX_BUF_0, PORT_ETH, 1, 0, BP_LAST_LINE);
-
- while(1){
- buffer_irq_handler(0);
- }
-}
-
diff --git a/firmware/microblaze/apps/cruft/Makefile.am b/firmware/microblaze/apps/cruft/Makefile.am
deleted file mode 100644
index a4f79935b..000000000
--- a/firmware/microblaze/apps/cruft/Makefile.am
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Copyright 2010 Ettus Research LLC
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-#
-# 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/>.
-#
-
-include $(top_srcdir)/Makefile.common
-
-LDADD = $(top_srcdir)/lib/libu2fw.a
-
-AM_CFLAGS += -I$(top_srcdir)/../../host/lib/usrp
-
-noinst_PROGRAMS = txrx_uhd.elf
-
-# blink_leds \
-# blink_leds2 \
-# buf_ram_test \
-# burn_dbsrx_eeprom \
-# can_i_sub \
-# echo \
-# hello \
-# read_dbids \
-# set_hw_rev \
-# test1 \
-# test_db_spi \
-# test_i2c \
-# test_sd \
-# test_ram \
-# test_phy_comm \
-# test_lsadc \
-# test_lsdac \
-# timer_test \
-# txrx \
-# burnrev30 \
-# burnrev31 \
-# burnrev40 \
-# sd_gentest \
-# sd_bounce
-#
-
-#nononono = \
-# eth_serdes \
-# gen_eth_packets \
-# rcv_eth_packets \
-# tx_standalone \
-# factory_test \
-# serdes_txrx \
-# mimo_tx \
-# mimo_tx_slave \
-# ibs_rx_test \
-# ibs_tx_test
-
-# tx_drop_SOURCES = tx_drop.c app_common.c
-# tx_drop_rate_limited_SOURCES = tx_drop_rate_limited.c app_common.c
-# tx_drop2_SOURCES = tx_drop2.c app_common.c
-txrx_uhd_elf_SOURCES = txrx_uhd.c
-# app_common_v2.c
-#factory_test_SOURCES = factory_test.c app_common_v2.c
-#eth_serdes_SOURCES = eth_serdes.c app_passthru_v2.c
-#serdes_txrx_SOURCES = serdes_txrx.c app_common_v2.c
-#mimo_tx_SOURCES = mimo_tx.c mimo_app_common_v2.c
-#mimo_tx_slave_SOURCES = mimo_tx_slave.c app_common_v2.c
-
-#noinst_HEADERS = \
-# app_common_v2.h \
-# app_passthru_v2.h \
-# mimo_app_common_v2.h
-#
-
diff --git a/firmware/microblaze/apps/cruft/app_passthru_v2.c b/firmware/microblaze/apps/cruft/app_passthru_v2.c
deleted file mode 100644
index 406c56b3b..000000000
--- a/firmware/microblaze/apps/cruft/app_passthru_v2.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "app_passthru_v2.h"
-#include "buffer_pool.h"
-#include "memcpy_wa.h"
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "print_rmon_regs.h"
-#include "db.h"
-#include "clocks.h"
-#include <string.h>
-
-volatile bool link_is_up = false; // eth handler sets this
-
-
-// If this is non-zero, this dbsm could be writing to the ethernet
-dbsm_t *ac_could_be_sending_to_eth;
-
-//static unsigned char exp_seqno = 0;
-
-void
-set_reply_hdr(u2_eth_packet_t *reply_pkt, u2_eth_packet_t const *cmd_pkt)
-{
- reply_pkt->ehdr.dst = cmd_pkt->ehdr.src;
- reply_pkt->ehdr.src = *ethernet_mac_addr();
- reply_pkt->ehdr.ethertype = U2_ETHERTYPE;
- reply_pkt->thdr.flags = 0;
- reply_pkt->thdr.fifo_status = 0; // written by protocol engine
- reply_pkt->thdr.seqno = 0; // written by protocol engine
- reply_pkt->thdr.ack = 0; // written by protocol engine
- u2p_set_word0(&reply_pkt->fixed, 0, CONTROL_CHAN);
- reply_pkt->fixed.timestamp = timer_regs->time;
-}
-
-static void
-send_reply(unsigned char *reply, size_t reply_len)
-{
- if (reply_len < 64)
- reply_len = 64;
-
- // wait for buffer to become idle
- hal_set_leds(0x4, 0x4);
- while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0)
- ;
- hal_set_leds(0x0, 0x4);
-
- // copy reply into CPU_TX_BUF
- memcpy_wa(buffer_ram(CPU_TX_BUF), reply, reply_len);
-
- // wait until nobody else is sending to the ethernet
- if (ac_could_be_sending_to_eth){
- hal_set_leds(0x8, 0x8);
- dbsm_wait_for_opening(ac_could_be_sending_to_eth);
- hal_set_leds(0x0, 0x8);
- }
-
- // fire it off
- bp_send_from_buf(CPU_TX_BUF, PORT_ETH, 1, 0, reply_len/4);
-
- // wait for it to complete (not long, it's a small pkt)
- while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0)
- ;
-
- bp_clear_buf(CPU_TX_BUF);
-}
-
-
-static size_t
-op_id_cmd(const op_generic_t *p,
- void *reply_payload, size_t reply_payload_space)
-{
- op_id_reply_t *r = (op_id_reply_t *) reply_payload;
- if (reply_payload_space < sizeof(*r)) // no room
- return 0;
-
- // Build reply subpacket
-
- r->opcode = OP_ID_REPLY;
- r->len = sizeof(op_id_reply_t);
- r->rid = p->rid;
- r->addr = *ethernet_mac_addr();
- r->hw_rev = 0x0000; // FIXME
- // r->fpga_md5sum = ; // FIXME
- // r->sw_md5sum = ; // FIXME
-
- // FIXME Add d'board info, including dbid, min/max gain, min/max freq
-
- return r->len;
-}
-
-static size_t
-add_eop(void *reply_payload, size_t reply_payload_space)
-{
- op_generic_t *r = (op_generic_t *) reply_payload;
- if (reply_payload_space < sizeof(*r))
- return 0; // no room
-
- r->opcode = OP_EOP;
- r->len = sizeof(*r);
- r->rid = 0;
- r->ok = 0;
-
- return r->len;
-}
-
-bool
-handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
-{
- unsigned char reply[sizeof(u2_eth_packet_t) + 4 * sizeof(u2_subpkt_t)] _AL4;
- unsigned char *reply_payload = &reply[sizeof(u2_eth_packet_t)];
- int reply_payload_space = sizeof(reply) - sizeof(u2_eth_packet_t);
-
- bool handled_it = false;
-
- // initialize reply
- memset(reply, 0, sizeof(reply));
- set_reply_hdr((u2_eth_packet_t *) reply, pkt);
-
- // point to beginning of payload (subpackets)
- unsigned char *payload = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t);
- int payload_len = len - sizeof(u2_eth_packet_t);
-
- size_t subpktlen = 0;
-
- while (payload_len >= sizeof(op_generic_t)){
- const op_generic_t *gp = (const op_generic_t *) payload;
- subpktlen = 0;
-
- switch(gp->opcode){
- case OP_EOP: // end of subpackets
- goto end_of_subpackets;
-
- case OP_ID:
- subpktlen = op_id_cmd(gp, reply_payload, reply_payload_space);
- handled_it = true;
- break;
-
- default:
- if (0){
- printf("\npassing on %d\n", gp->opcode);
- }
- break;
- }
-
- int t = (gp->len + 3) & ~3; // bump to a multiple of 4
- payload += t;
- payload_len -= t;
-
- subpktlen = (subpktlen + 3) & ~3; // bump to a multiple of 4
- reply_payload += subpktlen;
- reply_payload_space -= subpktlen;
- }
-
- end_of_subpackets:
-
- if (handled_it){
- // add the EOP marker
- subpktlen = add_eop(reply_payload, reply_payload_space);
- subpktlen = (subpktlen + 3) & ~3; // bump to a multiple of 4
- reply_payload += subpktlen;
- reply_payload_space -= subpktlen;
-
- send_reply(reply, reply_payload - reply);
- }
-
- return handled_it;
-}
-
-
-/*
- * Called when an ethernet packet is received.
- * Return true if we handled it here, otherwise
- * it'll be passed on to the DSP Tx pipe
- */
-bool
-eth_pkt_inspector(dbsm_t *sm, int bufno)
-{
- u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno);
- size_t byte_len = (buffer_pool_status->last_line[bufno] - 3) * 4;
-
- //static size_t last_len = 0;
-
- // hal_toggle_leds(0x1);
-
- // inspect rcvd frame and figure out what do do.
-
- if (pkt->ehdr.ethertype != U2_ETHERTYPE)
- return true; // ignore, probably bogus PAUSE frame from MAC
-
- int chan = u2p_chan(&pkt->fixed);
-
- switch (chan){
- case CONTROL_CHAN:
- return handle_control_chan_frame(pkt, byte_len);
- break;
-
- case 0:
- default:
-#if 0
- if (last_len != 0){
- if (byte_len != last_len){
- printf("Len: %d last: %d\n", byte_len, last_len);
- }
- }
- last_len = byte_len;
-
- if((pkt->thdr.seqno) == exp_seqno){
- exp_seqno++;
- //putchar('.');
- }
- else {
- // putchar('S');
- //printf("S%d %d ",exp_seqno,pkt->thdr.seqno);
- exp_seqno = pkt->thdr.seqno + 1;
- }
-#endif
- return false; // pass it on to Tx DSP
- break;
- }
-}
-
-/*
- * Called when eth phy state changes (w/ interrupts disabled)
- */
-void
-link_changed_callback(int speed)
-{
- link_is_up = speed != 0;
- hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45);
- printf("\neth link changed: speed = %d\n", speed);
-}
diff --git a/firmware/microblaze/apps/cruft/app_passthru_v2.h b/firmware/microblaze/apps/cruft/app_passthru_v2.h
deleted file mode 100644
index 3904c670f..000000000
--- a/firmware/microblaze/apps/cruft/app_passthru_v2.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifndef INCLUDED_APP_COMMON_H
-#define INCLUDED_APP_COMMON_H
-
-#include <stdbool.h>
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "memory_map.h"
-#include "hal_io.h"
-#include <stddef.h>
-#include <db.h>
-
-#define CPU_TX_BUF 7 // cpu -> eth
-
-#define _AL4 __attribute__((aligned (4)))
-
-extern volatile bool link_is_up; // eth handler sets this
-
-
-// If there's a dbsm that sends to the ethernet, put it's address here
-extern dbsm_t *ac_could_be_sending_to_eth;
-
-
-void set_reply_hdr(u2_eth_packet_t *reply_pkt, u2_eth_packet_t const *cmd_pkt);
-
-/*
- * Called when an ethernet packet is received.
- * Return true if we handled it here, otherwise
- * it'll be passed on to the DSP Tx pipe
- */
-bool eth_pkt_inspector(dbsm_t *sm, int bufno);
-
-void link_changed_callback(int speed);
-
-bool handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len);
-
-#endif /* INCLUDED_APP_COMMON_H */
diff --git a/firmware/microblaze/apps/cruft/blink_leds2.c b/firmware/microblaze/apps/cruft/blink_leds2.c
deleted file mode 100644
index 13e78afb3..000000000
--- a/firmware/microblaze/apps/cruft/blink_leds2.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "hal_io.h"
-#include "pic.h"
-#include "nonstdio.h"
-
-//#define DELTA_T (MASTER_CLK_RATE/2) // 0.5s (10ns per tick)
-#define DELTA_T 5000 // 5 us (10ns per tick)
-
-
-void
-timer_handler(unsigned irq)
-{
- hal_set_timeout(DELTA_T); // schedule next timeout
- hal_toggle_leds(0x2);
-}
-
-int
-main(void)
-{
- u2_init();
-
- putstr("blink_leds2\n");
- pic_register_handler(IRQ_ONETIME, timer_handler);
- hal_set_timeout(DELTA_T); // schedule next timeout
-
- while(1){
- hal_toggle_leds(0x1);
- }
-
- return 0;
-}
diff --git a/firmware/microblaze/apps/cruft/buf_ram_test.c b/firmware/microblaze/apps/cruft/buf_ram_test.c
deleted file mode 100644
index 1aca2aec5..000000000
--- a/firmware/microblaze/apps/cruft/buf_ram_test.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include <stdbool.h>
-#include "nonstdio.h"
-#include "hal_io.h"
-#include "mdelay.h"
-
-
-static void
-write_bufs(void)
-{
- int i, n;
- int counter = 0;
-
- for (n = 0; n < NBUFFERS; n++){
- volatile int *p = buffer_ram(n);
- for (i = 0; i < BP_NLINES; i++)
- p[i] = counter++;
- }
-}
-
-// return number of errors detected
-static int
-check_bufs(void)
-{
- int i, n;
- int counter = 0;
- int nerrors = 0;
-
- for (n = 0; n < NBUFFERS; n++){
- volatile int *p = buffer_ram(n);
- for (i = 0; i < BP_NLINES; i++, counter++){
- int rd = p[i];
- if (rd != counter){
- putchar('b');
- putchar(n + '0');
- putchar('[');
- puthex16(i);
- putstr("] exp: ");
- puthex32(counter);
- putstr(" got: ");
- puthex32_nl(rd);
- nerrors++;
- }
- }
- }
- return nerrors;
-}
-
-
-int
-main(void)
-{
- u2_init();
-
- output_regs->leds = 0;
-
- write_bufs();
- int nerrors = check_bufs();
-
- if (nerrors == 0){
- output_regs->leds = 0x3; // leds on -> PASS
- putstr("PASS\n");
- }
- else {
- output_regs->leds = 0x0; // leds off -> FAIL
- putstr("FAIL\n");
- }
-
- hal_finish();
- return 0;
-}
diff --git a/firmware/microblaze/apps/cruft/burn_dbsrx_eeprom.c b/firmware/microblaze/apps/cruft/burn_dbsrx_eeprom.c
deleted file mode 100644
index 116d4d8d0..000000000
--- a/firmware/microblaze/apps/cruft/burn_dbsrx_eeprom.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "i2c.h"
-#include "usrp2_i2c_addr.h"
-#include "mdelay.h"
-#include "hal_io.h"
-#include "nonstdio.h"
-#include <stdbool.h>
-
-
-
-int read_dboard_eeprom(int i2c_addr);
-
-
-#define USRP_DBID_DBS_RX 0x0002
-#define USRP_DBID_DBS_RX_WITH_CLOCK_MOD 0x000d
-
-const char dbs_rx_rev2_eeprom[] = {
- 0xdb, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18
-};
-
-#define LED_VALS (LED_A | LED_B | LED_C | LED_D)
-#define LED_MASK (LED_A | LED_B | LED_C | LED_D)
-
-int
-main(void)
-{
- u2_init();
-
- puts("\nburn_dbsrx_eeprom\n");
-
- hal_set_leds(0, ~0); // all off
-
- int i2c_addr = I2C_ADDR_RX_A;
- int dbid = read_dboard_eeprom(i2c_addr);
- bool ok;
- const char *msg = 0;
-
- switch (dbid){
- case -1:
- msg = "No RX daughterboard found";
- goto bad;
-
- case -2:
- msg = "Invalid RX EEPROM contents";
- goto bad;
-
- case USRP_DBID_DBS_RX_WITH_CLOCK_MOD:
- msg = "RX Daughterboard already reports being a DBS RX w/ CLOCK_MOD";
- goto good;
-
- case USRP_DBID_DBS_RX:
- // Says it's a DBS_RX, attempt to burn the EEPROM
- ok = eeprom_write(i2c_addr, 0,
- dbs_rx_rev2_eeprom, sizeof(dbs_rx_rev2_eeprom));
- if (ok){
- msg = "Successfully programmed db as DBS RX Rev 2.1";
- goto good;
- }
- else {
- msg = "Failed to write daugherboard eeprom";
- goto bad;
- }
-
- default:
- msg = "Daughterboard is not a DBS RX; ignored";
- goto bad;
- }
-
- good:
- puts(msg);
- hal_set_leds(LED_VALS, LED_MASK);
- while (1)
- ;
-
- bad:
- puts(msg);
- while(1){
- hal_toggle_leds(LED_VALS);
- mdelay(50);
- }
-}
diff --git a/firmware/microblaze/apps/cruft/burnrev30.c b/firmware/microblaze/apps/cruft/burnrev30.c
deleted file mode 100644
index 40fa53e34..000000000
--- a/firmware/microblaze/apps/cruft/burnrev30.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common_v2.h"
-#include "memcpy_wa.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <i2c.h>
-#include <usrp2_i2c_addr.h>
-#include <clocks.h>
-#include "sd.h"
-#include "mdelay.h"
-
-#define HW_REV_MAJOR 3
-#define HW_REV_MINOR 0
-
-int test_ram()
-{
- int i,j,k;
- output_regs->ram_page = 1<<10;
-
- extram[0] = 0xDEADBEEF;
- extram[1] = 0xF00D1234;
- extram[7] = 0x76543210;
-
- output_regs->ram_page = 2<<10;
- extram[7] = 0x55555555;
- extram[1] = 0xaaaaaaaa;
- extram[0] = 0xeeeeeeee;
-
- output_regs->ram_page = 1<<10;
-
- i = extram[0];
- k = extram[1];
- j = extram[7];
-
- if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) {
- puts("RAM FAIL1!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
-
- output_regs->ram_page = 2<<10;
-
- j = extram[7];
- k = extram[1];
- i = extram[0];
-
- if((i != 0xeeeeeeee)||(j!=0x55555555)||(k!=0xaaaaaaaa)) {
- puts("RAM FAIL2!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
- return 1;
-}
-
-int test_sd()
-{
- int i = sd_init();
- if(i==0) {
- puts("FAILED INIT of Card\n");
- return 0;
- }
-
- unsigned char buf[512];
- i = sd_read_block(2048,buf);
- if(i == 0) {
- puts("READ Command Rejected\n");
- return 0;
- }
- if((buf[0]==0xb8)&&(buf[1]==0x08)&&(buf[2]==0x00)&&(buf[3]==0x50))
- ;
- else {
- puts("Read bad data from SD Card\n");
- return 0;
- }
- return 1;
-}
-
-int
-main(void)
-{
- u2_init();
-
- putstr("\nFactory Test, Board Rev 3.0\n");
-
- bool ok = true;
- unsigned char maj = HW_REV_MAJOR;
- unsigned char min = HW_REV_MINOR;
- ok = eeprom_write(I2C_ADDR_MBOARD, MBOARD_REV_MSB, &maj, 1);
- ok &= eeprom_write(I2C_ADDR_MBOARD, MBOARD_REV_LSB, &min, 1);
-
- putstr("\nset_hw_rev\n");
- if (ok)
- printf("OK: set h/w rev to %d.%d\n", HW_REV_MAJOR, HW_REV_MINOR);
- else {
- printf("FAILED to set h/w rev to %d.%d\n", HW_REV_MAJOR, HW_REV_MINOR);
- hal_finish();
- return 0;
- }
-
- if(test_sd())
- puts("SD OK\n");
- else {
- puts("SD FAIL\n");
- //hal_finish();
- //return 0;
- }
- if(test_ram())
- puts("RAM OK\n");
- else {
- puts("RAM FAIL\n");
- hal_finish();
- return 0;
- }
-
- print_mac_addr(ethernet_mac_addr()->addr);
- newline();
-
- clocks_mimo_config(MC_WE_LOCK_TO_SMA);
-
- while (!clocks_lock_detect()) {
- puts("No Lock");
- mdelay(1000);
- }
- puts("Clock Locked\n");
-
-}
diff --git a/firmware/microblaze/apps/cruft/burnrev31.c b/firmware/microblaze/apps/cruft/burnrev31.c
deleted file mode 100644
index f6b08d187..000000000
--- a/firmware/microblaze/apps/cruft/burnrev31.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common_v2.h"
-#include "memcpy_wa.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <i2c.h>
-#include <usrp2_i2c_addr.h>
-#include <clocks.h>
-#include "sd.h"
-#include "mdelay.h"
-
-#define HW_REV_MAJOR 3
-#define HW_REV_MINOR 1
-
-int test_ram()
-{
- int i,j,k;
- output_regs->ram_page = 1<<10;
-
- extram[0] = 0xDEADBEEF;
- extram[1] = 0xF00D1234;
- extram[7] = 0x76543210;
-
- output_regs->ram_page = 2<<10;
- extram[7] = 0x55555555;
- extram[1] = 0xaaaaaaaa;
- extram[0] = 0xeeeeeeee;
-
- output_regs->ram_page = 1<<10;
-
- i = extram[0];
- k = extram[1];
- j = extram[7];
-
- if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) {
- puts("RAM FAIL1!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
-
- output_regs->ram_page = 2<<10;
-
- j = extram[7];
- k = extram[1];
- i = extram[0];
-
- if((i != 0xeeeeeeee)||(j!=0x55555555)||(k!=0xaaaaaaaa)) {
- puts("RAM FAIL2!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
- return 1;
-}
-
-int test_sd()
-{
- int i = sd_init();
- if(i==0) {
- puts("FAILED INIT of Card\n");
- return 0;
- }
-
- unsigned char buf[512];
- i = sd_read_block(2048,buf);
- if(i == 0) {
- puts("READ Command Rejected\n");
- return 0;
- }
- if((buf[0]==0xb8)&&(buf[1]==0x08)&&(buf[2]==0x00)&&(buf[3]==0x50))
- ;
- else {
- puts("Read bad data from SD Card\n");
- return 0;
- }
- return 1;
-}
-
-int
-main(void)
-{
- u2_init();
-
- putstr("\nFactory Test, Board Rev 3.1\n");
-
- bool ok = true;
- unsigned char maj = HW_REV_MAJOR;
- unsigned char min = HW_REV_MINOR;
- ok = eeprom_write(I2C_ADDR_MBOARD, MBOARD_REV_MSB, &maj, 1);
- ok &= eeprom_write(I2C_ADDR_MBOARD, MBOARD_REV_LSB, &min, 1);
-
- putstr("\nset_hw_rev\n");
- if (ok)
- printf("OK: set h/w rev to %d.%d\n", HW_REV_MAJOR, HW_REV_MINOR);
- else {
- printf("FAILED to set h/w rev to %d.%d\n", HW_REV_MAJOR, HW_REV_MINOR);
- hal_finish();
- return 0;
- }
-
- if(test_sd())
- puts("SD OK\n");
- else {
- puts("SD FAIL\n");
- //hal_finish();
- //return 0;
- }
- if(test_ram())
- puts("RAM OK\n");
- else {
- puts("RAM FAIL\n");
- hal_finish();
- return 0;
- }
-
- print_mac_addr(ethernet_mac_addr()->addr);
- newline();
-
- clocks_mimo_config(MC_WE_LOCK_TO_SMA);
-
- while (!clocks_lock_detect()) {
- puts("No Lock");
- mdelay(1000);
- }
- puts("Clock Locked\n");
-
-}
diff --git a/firmware/microblaze/apps/cruft/can_i_sub.c b/firmware/microblaze/apps/cruft/can_i_sub.c
deleted file mode 100644
index ed49791f0..000000000
--- a/firmware/microblaze/apps/cruft/can_i_sub.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <u2_init.h>
-#include <nonstdio.h>
-
-//typedef long long int64_t;
-
-
-int64_t sub(int64_t a, int64_t b);
-void print(int64_t d);
-
-int main(void)
-{
- u2_init();
-
- int64_t d = sub(462550990848000LL, 462028800000000LL);
- print_uint64(d);
- newline();
- return 0;
-}
-
-int64_t sub(int64_t a, int64_t b)
-{
- return a - b;
-}
-
-
diff --git a/firmware/microblaze/apps/cruft/double_buffer_fragment.c b/firmware/microblaze/apps/cruft/double_buffer_fragment.c
deleted file mode 100644
index cfc061247..000000000
--- a/firmware/microblaze/apps/cruft/double_buffer_fragment.c
+++ /dev/null
@@ -1,138 +0,0 @@
-#if 0
-void
-double_buffering(int port) {
- unsigned int localstatus = buffer_pool_status->status;
-
- if(localstatus & BPS_DONE_0) {
- bp_clear_buf(0);
- if(buffer_state[0] == FILLING) {
- buffer_state[0] = FULL;
- if(buffer_state[1] == EMPTY) {
- bp_receive_to_buf(1, 1, 1, 10, 509); // DSP_RX to buffer 1, use 500 lines
- buffer_state[1] = FILLING;
- }
- else
- dsp_rx_idle = 1;
- if(serdes_tx_idle) {
- serdes_tx_idle = 0;
- bp_send_from_buf(0, port, 1, 10, 509); // SERDES_TX from buffer 0
- buffer_state[0] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[0] = EMPTY;
- if(dsp_rx_idle) {
- dsp_rx_idle = 0;
- bp_receive_to_buf(0, 1, 1, 10, 509); // DSP_RX to buffer 0, use 500 lines
- buffer_state[0] = FILLING;
- }
- if(buffer_state[1] == FULL) {
- bp_send_from_buf(1, port, 1, 10, 509); // SERDES_TX from buffer 1
- buffer_state[1] = EMPTYING;
- }
- else
- serdes_tx_idle = 1;
- }
- putstr("Int Proc'ed 0\n");
- }
-
- if(localstatus & BPS_DONE_1) {
- bp_clear_buf(1);
- if(buffer_state[1] == FILLING) {
- buffer_state[1] = FULL;
- if(buffer_state[0] == EMPTY) {
- bp_receive_to_buf(0, 1, 1, 10, 509); // DSP_RX to buffer 1, use 500 lines
- buffer_state[0] = FILLING;
- }
- else
- dsp_rx_idle = 1;
- if(serdes_tx_idle) {
- serdes_tx_idle = 0;
- bp_send_from_buf(1, port, 1, 10, 509); // SERDES_TX from buffer 1
- buffer_state[1] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[1] = EMPTY;
- if(dsp_rx_idle) {
- dsp_rx_idle = 0;
- bp_receive_to_buf(1, 1, 1, 10, 509); // DSP_RX to buffer 1, use 500 lines
- buffer_state[1] = FILLING;
- }
- if(buffer_state[0] == FULL) {
- bp_send_from_buf(0, port, 1, 10, 509); // SERDES_TX from buffer 0
- buffer_state[0] = EMPTYING;
- }
- else
- serdes_tx_idle = 1;
- }
- putstr("Int Proc'ed 1\n");
- }
-
- if(localstatus & BPS_DONE_2) {
- bp_clear_buf(2);
- if(buffer_state[2] == FILLING) {
- buffer_state[2] = FULL;
- if(buffer_state[3] == EMPTY) {
- bp_receive_to_buf(3, port, 1, 5, 504); // SERDES_RX to buffer 3, use 500 lines
- buffer_state[3] = FILLING;
- }
- else
- serdes_rx_idle = 1;
- if(dsp_tx_idle) {
- dsp_tx_idle = 0;
- bp_send_from_buf(2, 1, 1, 5, 504); // DSP_TX from buffer 2
- buffer_state[2] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[2] = EMPTY;
- if(serdes_rx_idle) {
- serdes_rx_idle = 0;
- bp_receive_to_buf(2, port, 1, 5, 504); // SERDES_RX to buffer 2
- buffer_state[2] = FILLING;
- }
- if(buffer_state[3] == FULL) {
- bp_send_from_buf(3, 1, 1, 5, 504); // DSP_TX from buffer 3
- buffer_state[3] = EMPTYING;
- }
- else
- dsp_tx_idle = 1;
- }
- putstr("Int Proc'ed 2\n");
- }
-
- if(localstatus & BPS_DONE_3) {
- bp_clear_buf(3);
- if(buffer_state[3] == FILLING) {
- buffer_state[3] = FULL;
- if(buffer_state[2] == EMPTY) {
- bp_receive_to_buf(2, port, 1, 5, 504); // SERDES_RX to buffer 2, use 500 lines
- buffer_state[2] = FILLING;
- }
- else
- serdes_rx_idle = 1;
- if(dsp_tx_idle) {
- dsp_tx_idle = 0;
- bp_send_from_buf(3, 1, 1, 5, 504); // DSP_TX from buffer 3
- buffer_state[3] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[3] = EMPTY;
- if(serdes_rx_idle) {
- serdes_rx_idle = 0;
- bp_receive_to_buf(3, port, 1, 5, 504); // SERDES_RX to buffer 3
- buffer_state[3] = FILLING;
- }
- if(buffer_state[2] == FULL) {
- bp_send_from_buf(2, 1, 1, 5, 504); // DSP_TX from buffer 2
- buffer_state[2] = EMPTYING;
- }
- else
- dsp_tx_idle = 1;
- }
- putstr("Int Proc'ed 3\n");
- }
-}
-#endif
diff --git a/firmware/microblaze/apps/cruft/eth_serdes.c b/firmware/microblaze/apps/cruft/eth_serdes.c
deleted file mode 100644
index 2d2ddc1ca..000000000
--- a/firmware/microblaze/apps/cruft/eth_serdes.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_passthru_v2.h"
-#include "memcpy_wa.h"
-#include "clocks.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
-
-#if (FW_SETS_SEQNO)
-static int fw_seqno __attribute__((unused)); // used when f/w is filling in sequence numbers
-#endif
-
-
-/*
- * Full duplex Tx and Rx between ethernet and serdes
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-
-#define DSP_RX_BUF_0 2 // serdes -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // serdes -> eth
-#define DSP_TX_BUF_0 4 // eth -> serdes (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> serdes
-
-/*
- * ================================================================
- * configure serdes double buffering state machine (eth -> serdes)
- * ================================================================
- */
-
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to serdes
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_SERDES,
- 0,
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-/*
- * ====================================================================
- * configure serdes RX double buffering state machine (serdes -> eth)
- * ====================================================================
- */
-
-// receive from serdes
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_SERDES,
- 0,
- BP_LAST_LINE
-};
-
-// send to ETH
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_ETH,
- 0, // starts with ethernet header in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-// ----------------------------------------------------------------
-
-
-#if (FW_SETS_SEQNO)
-/*
- * Debugging ONLY. This will be handled by the tx_protocol_engine.
- *
- * This is called when the DSP Rx chain has filled in a packet.
- * We set and increment the seqno, then return false, indicating
- * that we didn't handle the packet. A bit of a kludge
- * but it should work.
- */
-
-bool
-fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false
-{
-#if 0
- uint32_t *p = buffer_ram(buf_this);
- uint32_t last_line = buffer_pool_status->last_line[buf_this] - sm->last_line_adj;
- printf("fw_sets_seqno_inspector: buf_this = %d, last_line = %d\n",
- buf_this, last_line);
-
- print_buffer(p, (last_line + 1));
-#endif
-
-#if 0
- uint32_t *p = buffer_ram(buf_this);
- uint32_t seqno = fw_seqno++;
-
- // KLUDGE all kinds of nasty magic numbers and embedded knowledge
- uint32_t t = p[4];
- t = (t & 0xffff00ff) | ((seqno & 0xff) << 8);
- p[4] = t;
-#endif
-
- return false; // we didn't handle the packet
-}
-#endif
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- if (0 && (status & ~BPS_IDLE_ALL)){
- putstr("status = ");
- puthex32_nl(status);
- }
-
- dbsm_process_status(&dsp_tx_sm, status);
- dbsm_process_status(&dsp_rx_sm, status);
-}
-
-int
-main(void)
-{
- u2_init();
-
- output_regs->led_src = 0x3; // h/w controls bottom two bits
- clocks_enable_test_clk(true, 1);
-
- putstr("\neth <-> serdes\n");
-
- ethernet_register_link_changed_callback(link_changed_callback);
- ethernet_init();
-
- // clocks_mimo_config(MC_WE_LOCK_TO_SMA | MC_PROVIDE_CLK_TO_MIMO);
- clocks_mimo_config(MC_WE_DONT_LOCK | MC_PROVIDE_CLK_TO_MIMO);
-
-#if 0
- // make bit 15 of Tx gpio's be a s/w output
- hal_gpio_set_sel(GPIO_TX_BANK, 15, 's');
- hal_gpio_set_ddr(GPIO_TX_BANK, 0x8000, 0x8000);
-#endif
-
-#if 1
- output_regs->debug_mux_ctrl = 1;
- hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
- hal_gpio_set_ddr(GPIO_TX_BANK, 0xffff, 0xffff);
- hal_gpio_set_ddr(GPIO_RX_BANK, 0xffff, 0xffff);
-#endif
-
-
- // initialize double buffering state machine for ethernet -> serdes
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- eth_pkt_inspector);
-
-
- // initialize double buffering state machine for serdes -> ethernet
-
- if (FW_SETS_SEQNO){
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- fw_sets_seqno_inspector);
- }
- else {
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_nop_inspector);
- }
-
- // tell app_common that this dbsm could be sending to the ethernet
- ac_could_be_sending_to_eth = &dsp_rx_sm;
-
-
- // kick off the state machines
- dbsm_start(&dsp_tx_sm);
- dbsm_start(&dsp_rx_sm);
-
- //int which = 0;
-
- while(1){
- // hal_gpio_write(GPIO_TX_BANK, which, 0x8000);
- // which ^= 0x8000;
-
- buffer_irq_handler(0);
- }
-}
diff --git a/firmware/microblaze/apps/cruft/factory_test.c b/firmware/microblaze/apps/cruft/factory_test.c
deleted file mode 100644
index e1fbb0e40..000000000
--- a/firmware/microblaze/apps/cruft/factory_test.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common_v2.h"
-#include "memcpy_wa.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <i2c.h>
-#include <usrp2_i2c_addr.h>
-#include <clocks.h>
-#include "sd.h"
-
-#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
-
-#if (FW_SETS_SEQNO)
-static int fw_seqno; // used when f/w is filling in sequence numbers
-#endif
-
-
-/*
- * Full duplex Tx and Rx between ethernet and DSP pipelines
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-/*
- * ================================================================
- * configure DSP TX double buffering state machine (eth -> dsp)
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4)
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-/*
- * ================================================================
- * configure DSP RX double buffering state machine (dsp -> eth)
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 1 line (word0)
-// DSP Rx writes timestamp followed by nlines_per_frame of samples
-#define DSP_RX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4 + 1)
-
-// receive from DSP
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to ETH
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_ETH,
- 0, // starts with ethernet header in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-// variables for streaming mode
-
-static bool streaming_p = false;
-static unsigned int streaming_items_per_frame = 0;
-static int streaming_frame_count = 0;
-#define FRAMES_PER_CMD 1000
-
-bool is_streaming(void){ return streaming_p; }
-
-// ----------------------------------------------------------------
-
-
-void
-restart_streaming(void)
-{
- // setup RX DSP regs
- dsp_rx_regs->clear_state = 1; // reset
-
- streaming_p = true;
- streaming_frame_count = FRAMES_PER_CMD;
-
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1); // set "chain" bit
-
- // kick off the state machine
- dbsm_start(&dsp_rx_sm);
-
- dsp_rx_regs->rx_time = 0; // enqueue first of two commands
-
- // make sure this one and the rest have the "now" and "chain" bits set.
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1);
-
- dsp_rx_regs->rx_time = 0; // enqueue second command
-}
-
-void
-start_rx_streaming_cmd(const eth_mac_addr_t *host, op_start_rx_streaming_t *p)
-{
- host_mac_addr = *host; // remember who we're sending to
-
- /*
- * Construct ethernet header and word0 and preload into two buffers
- */
- u2_eth_packet_t pkt;
- memset(&pkt, 0, sizeof(pkt));
- pkt.ehdr.dst = *host;
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
- u2p_set_word0(&pkt.fixed, 0, 0);
- // DSP RX will fill in timestamp
-
- memcpy_wa(buffer_ram(DSP_RX_BUF_0), &pkt, sizeof(pkt));
- memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt));
-
-
- if (FW_SETS_SEQNO)
- fw_seqno = 0;
-
- streaming_items_per_frame = p->items_per_frame;
- restart_streaming();
-}
-
-
-void
-stop_rx_cmd(void)
-{
- streaming_p = false;
- dsp_rx_regs->clear_state = 1; // flush cmd queue
- bp_clear_buf(DSP_RX_BUF_0);
- bp_clear_buf(DSP_RX_BUF_1);
-}
-
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
- int tx_scale = 256;
- int interp = 32;
-
- // setup some defaults
-
- dsp_tx_regs->freq = 0;
- dsp_tx_regs->scale_iq = (tx_scale << 16) | tx_scale;
- dsp_tx_regs->interp_rate = interp;
-}
-
-
-#if (FW_SETS_SEQNO)
-/*
- * Debugging ONLY. This will be handled by the tx_protocol_engine.
- *
- * This is called when the DSP Rx chain has filled in a packet.
- * We set and increment the seqno, then return false, indicating
- * that we didn't handle the packet. A bit of a kludge
- * but it should work.
- */
-bool
-fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false
-{
- uint32_t *p = buffer_ram(buf_this);
- uint32_t seqno = fw_seqno++;
-
- // KLUDGE all kinds of nasty magic numbers and embedded knowledge
- uint32_t t = p[4];
- t = (t & 0xffff00ff) | ((seqno & 0xff) << 8);
- p[4] = t;
-
- // queue up another rx command when required
- if (streaming_p && --streaming_frame_count == 0){
- streaming_frame_count = FRAMES_PER_CMD;
- dsp_rx_regs->rx_time = 0;
- }
-
- return false; // we didn't handle the packet
-}
-#endif
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- dbsm_process_status(&dsp_tx_sm, status);
- dbsm_process_status(&dsp_rx_sm, status);
-}
-
-int test_ram()
-{
- int i,j,k;
- output_regs->ram_page = 1<<10;
-
- extram[0] = 0xDEADBEEF;
- extram[1] = 0xF00D1234;
- extram[7] = 0x76543210;
-
- output_regs->ram_page = 2<<10;
- extram[7] = 0x55555555;
- extram[1] = 0xaaaaaaaa;
- extram[0] = 0xeeeeeeee;
-
- output_regs->ram_page = 1<<10;
-
- i = extram[0];
- k = extram[1];
- j = extram[7];
-
- if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) {
- puts("RAM FAIL1!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
-
- output_regs->ram_page = 2<<10;
-
- j = extram[7];
- k = extram[1];
- i = extram[0];
-
- if((i != 0xeeeeeeee)||(j!=0x55555555)||(k!=0xaaaaaaaa)) {
- puts("RAM FAIL2!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
- return 1;
-}
-
-int test_sd()
-{
- int i = sd_init();
- if(i==0) {
- puts("FAILED INIT of Card\n");
- return 0;
- }
-
- unsigned char buf[512];
- i = sd_read_block(2048,buf);
- if(i == 0) {
- puts("READ Command Rejected\n");
- return 0;
- }
- if((buf[0]==0xb8)&&(buf[1]==0x08)&&(buf[2]==0x00)&&(buf[3]==0x50))
- ;
- else {
- puts("Read bad data from SD Card\n");
- return 0;
- }
- return 1;
-}
-
-int
-main(void)
-{
- u2_init();
-
- putstr("\nFactory Test\n");
-
- print_mac_addr(ethernet_mac_addr()->addr);
- newline();
-
- if(test_sd())
- puts("SD OK\n");
- else {
- puts("SD FAIL\n");
- // hal_finish();
- //return 0;
- }
- if(test_ram())
- puts("RAM OK\n");
- else {
- puts("RAM FAIL\n");
- hal_finish();
- return 0;
- }
-
- print_mac_addr(ethernet_mac_addr()->addr);
- newline();
-
- output_regs->led_src = 0x7; // make bottom 3 controlled by HW
-
- ethernet_register_link_changed_callback(link_changed_callback);
- ethernet_init();
-
- clocks_enable_tx_dboard(true,1);
- clocks_mimo_config(MC_WE_LOCK_TO_SMA);
-#if 0
- // make bit 15 of Tx gpio's be a s/w output
- hal_gpio_set_sel(GPIO_TX_BANK, 15, 's');
- hal_gpio_set_ddr(GPIO_TX_BANK, 0x8000, 0x8000);
-#endif
-
- output_regs->debug_mux_ctrl = 1;
-#if 0
- hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
- hal_gpio_set_ddr(GPIO_TX_BANK, 0xffff, 0xffff);
- hal_gpio_set_ddr(GPIO_RX_BANK, 0xffff, 0xffff);
-#endif
-
-
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- eth_pkt_inspector);
-
-
- // initialize double buffering state machine for DSP RX -> Ethernet
-
- if (FW_SETS_SEQNO){
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- fw_sets_seqno_inspector);
- }
- else {
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_nop_inspector);
- }
-
- // tell app_common that this dbsm could be sending to the ethernet
- ac_could_be_sending_to_eth = &dsp_rx_sm;
-
-
- // program tx registers
- setup_tx();
-
- // kick off the state machine
- dbsm_start(&dsp_tx_sm);
-
- //int which = 0;
-
- while(1){
- // hal_gpio_write(GPIO_TX_BANK, which, 0x8000);
- // which ^= 0x8000;
-
- buffer_irq_handler(0);
-
- int pending = pic_regs->pending; // poll for under or overrun
-
- if (pending & PIC_UNDERRUN_INT){
- dbsm_handle_tx_underrun(&dsp_tx_sm);
- pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
- putchar('U');
- }
-
- if (pending & PIC_OVERRUN_INT){
- dbsm_handle_rx_overrun(&dsp_rx_sm);
- pic_regs->pending = PIC_OVERRUN_INT; // clear pending interrupt
-
- // FIXME Figure out how to handle this robustly.
- // Any buffers that are emptying should be allowed to drain...
-
- if (streaming_p){
- // restart_streaming();
- // FIXME report error
- }
- else {
- // FIXME report error
- }
- putchar('O');
- }
- }
-}
diff --git a/firmware/microblaze/apps/cruft/gen_eth_packets.c b/firmware/microblaze/apps/cruft/gen_eth_packets.c
deleted file mode 100644
index 4d521f6bf..000000000
--- a/firmware/microblaze/apps/cruft/gen_eth_packets.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "memcpy_wa.h"
-#include "print_rmon_regs.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-// ----------------------------------------------------------------
-
-static eth_mac_addr_t dst_mac_addr =
- {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }};
-
-// ----------------------------------------------------------------
-
-// #define PACKET_SIZE 1500 // bytes
-// #define ETH_DATA_RATE 1000000 // 1MB/s
-// #define ETH_PACKET_RATE (ETH_DATA_RATE/PACKET_SIZE) // 13,3333 pkts/s
-
-// static int timer_delta = MASTER_CLK_RATE/ETH_PACKET_RATE; // ticks between interrupts
-
-static int timer_delta = (int)(MASTER_CLK_RATE * 1e-3); // tick at 1 kHz
-static int sim_timer_delta = (int)(MASTER_CLK_RATE * 100e-6); // tick at 10 kHz
-
-static volatile bool send_packet_now = false; // timer handler sets this
-static volatile bool link_is_up = false; // eth handler sets this
-
-int packet_number = 0;
-
-
-#define CPU_TX_BUF 0 // cpu xmits ethernet frames from here
-#define CPU_RX_BUF 1 // receive ethernet frames here
-
-// ----------------------------------------------------------------
-
-/*
- * Called when eth phy state changes (w/ interrupts disabled)
- */
-void
-link_changed_callback(int speed)
-{
- link_is_up = speed == 0 ? false : true;
- hal_set_leds(link_is_up ? 0x2 : 0x0, 0x2);
- printf("\neth link changed: speed = %d\n", speed);
-}
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
- send_packet_now = 1;
-}
-
-
-static void
-init_packet(int *buf, const u2_eth_packet_t *pkt, int bufnum)
-{
- int i = 0;
- int mark = ((bufnum & 0xff) << 24) | 0x005A0000;
-
- for (i = 0; i < BP_NLINES; i++){
- buf[i] = mark | i;
- mark ^= 0x00FF0000;
- }
-
- // copy header into buffer
- memcpy_wa(buf, pkt, sizeof(*pkt));
-}
-
-static void
-init_packets(void)
-{
- u2_eth_packet_t pkt __attribute__((aligned (4)));
-
- memset(&pkt, 0, sizeof(pkt));
-
- pkt.ehdr.dst = dst_mac_addr;
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
- pkt.fixed.word0 = 0x01234567;
- pkt.fixed.timestamp = 0xffffffff;
-
- // init just the one we're using
- init_packet((void *)buffer_ram(CPU_TX_BUF), &pkt, CPU_TX_BUF);
-}
-
-int
-main(void)
-{
- int npackets_sent = 0;
-
- u2_init();
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
-
- putstr("\ngen_eth_packets\n");
-
- hal_set_leds(0x0, 0x3);
-
- init_packets();
-
- pic_register_handler(IRQ_TIMER, timer_irq_handler);
-
- if (hwconfig_simulation_p())
- timer_delta = sim_timer_delta;
-
- hal_set_timeout(timer_delta);
-
- ethernet_register_link_changed_callback(link_changed_callback);
- ethernet_init();
-
- /*
- if (hwconfig_simulation_p()){
- eth_mac->speed = 4; // hardcode mac speed to 1000
- link_is_up = true;
- }
- */
-
- // fire off a receive from the ethernet
- bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, BP_LAST_LINE);
-
- while(1){
- uint32_t status = buffer_pool_status->status;
-
- if (status & (BPS_DONE(CPU_RX_BUF) | BPS_ERROR(CPU_RX_BUF))){
- bp_clear_buf(CPU_RX_BUF);
- // ignore incoming ethernet packets; they were looped back in sim
- bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, BP_LAST_LINE);
- }
-
- if (status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))){
- if (status & BPS_ERROR(CPU_TX_BUF)){
- putchar('E');
- }
- bp_clear_buf(CPU_TX_BUF);
- npackets_sent++;
- if ((npackets_sent & 0xF) == 0){ // print after every 16 packets
- //print_rmon_regs();
- putchar('.');
- }
- }
-
- if (link_is_up && send_packet_now && (status & BPS_IDLE(CPU_TX_BUF))){
- send_packet_now = false;
-
- // kick off the next packet
- // FIXME set packet number in packet
-
- bp_send_from_buf(CPU_TX_BUF, PORT_ETH, 1, 0, 255); // 1KB total
- hal_toggle_leds(0x1);
- }
- }
-
- hal_finish();
- return 1;
-}
diff --git a/firmware/microblaze/apps/cruft/gen_pause_frames.c b/firmware/microblaze/apps/cruft/gen_pause_frames.c
deleted file mode 100644
index 0f81dafff..000000000
--- a/firmware/microblaze/apps/cruft/gen_pause_frames.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "u2_eth_packet.h"
-#include "memcpy_wa.h"
-#include <stddef.h>
-#include <stdlib.h>
-
-
-// ----------------------------------------------------------------
-
-unsigned char dst_mac_addr[6] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
-// ----------------------------------------------------------------
-
-// #define PACKET_SIZE 1500 // bytes
-// #define ETH_DATA_RATE 1000000 // 1MB/s
-// #define ETH_PACKET_RATE (ETH_DATA_RATE/PACKET_SIZE) // 13,3333 pkts/s
-
-// static int timer_delta = MASTER_CLK_RATE/ETH_PACKET_RATE; // ticks between interrupts
-
-static int timer_delta = MASTER_CLK_RATE/1000; // tick at 1kHz
-
-static volatile bool send_packet_now = false; // timer handler sets this
-static volatile bool link_is_up = false; // eth handler sets this
-
-int packet_number = 0;
-
-// ----------------------------------------------------------------
-
-// debugging output on tx pins
-#define LS_MASK 0xE0000
-#define LS_1000 0x80000
-#define LS_100 0x40000
-#define LS_10 0x20000
-
-
-/*
- * Called when eth phy state changes (w/ interrupts disabled)
- */
-void
-link_changed_callback(int speed)
-{
- int v = 0;
- switch(speed){
- case 10:
- v = LS_10;
- link_is_up = true;
- break;
-
- case 100:
- v = LS_100;
- link_is_up = true;
- break;
-
- case 1000:
- v = LS_100;
- link_is_up = true;
- break;
-
- default:
- v = 0;
- link_is_up = false;
- break;
- }
-
- hal_gpio_set_tx(v, LS_MASK); /* set debug bits on d'board */
-
- putstr("\neth link changed: speed = ");
- puthex16_nl(speed);
-}
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
- send_packet_now = 1;
-}
-
-
-void
-buffer_irq_handler(unsigned irq)
-{
- // FIXME
-}
-
-static void
-init_packet(int *buf, const u2_eth_packet_t *pkt, int bufnum)
-{
- int i = 0;
- int mark = ((bufnum & 0xff) << 24) | 0x005A0000;
-
- for (i = 0; i < BP_NLINES; i++){
- buf[i] = mark | i;
- mark ^= 0x00FF0000;
- }
-
- // copy header into buffer
- memcpy_wa(buf, pkt, sizeof(*pkt));
-}
-
-static void
-init_packets(void)
-{
- int i;
-
- u2_eth_packet_t pkt __attribute__((aligned (4)));
-
- for (i = 0; i < 6; i++){
- pkt.ehdr.dst.addr[i] = dst_mac_addr[i];
- }
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
-
- // fill ALL buffers for debugging
- for (i = 0; i < 8; i++)
- init_packet((void *)buffer_ram(i), &pkt, i);
-}
-
-static int led_counter = 0;
-
-int
-main(void)
-{
- int send_pause = 1;
-
- u2_init();
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
-
- putstr("\ngen_eth_packets\n");
-
- // Control LEDs
- output_regs->leds = 0x00;
-
- init_packets();
-
- // pic_register_handler(IRQ_BUFFER, buffer_irq_handler); // poll for now
- pic_register_handler(IRQ_TIMER, timer_irq_handler);
- hal_set_timeout(timer_delta);
-
- ethernet_register_link_changed_callback(link_changed_callback);
-
- ethernet_init();
-
- eth_mac->pause_frame_send_en = 1;
- eth_mac->pause_quanta_set = 16384 / 512;
-
- // eth_mac->speed = 4; // FIXME hardcode mac speed to 1000
-
- while(1){
- if (link_is_up && send_packet_now){
- send_packet_now = false;
-
-
- if (send_pause)
- eth_mac->xon_cpu = 1;
- else
- eth_mac->xon_cpu = 0;
-
- send_pause ^= 1;
-
- // kick off the next packet
- // FIXME set packet number in packet
-
-#if 0
- bp_send_from_buf(0, PORT_ETH, 1, 0, 255); // 1KB total
-
- while ((buffer_pool_status->status & (BPS_DONE_0|BPS_ERROR_0)) == 0)
- ;
- bp_clear_buf(0);
-#endif
-
- output_regs->leds = ((++led_counter) & 0x1) | (link_is_up ? 0x2 : 0x0);
- }
- }
-
- hal_finish();
- return 1;
-}
diff --git a/firmware/microblaze/apps/cruft/hello.c b/firmware/microblaze/apps/cruft/hello.c
deleted file mode 100644
index bce843093..000000000
--- a/firmware/microblaze/apps/cruft/hello.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include "u2_init.h"
-#include "stdio.h"
-
-int
-main(void)
-{
- u2_init();
-
- puts("Hello World");
- puts("Goodbye World");
-
- return 0;
-}
diff --git a/firmware/microblaze/apps/cruft/ibs_rx_test.c b/firmware/microblaze/apps/cruft/ibs_rx_test.c
deleted file mode 100644
index bdc04747e..000000000
--- a/firmware/microblaze/apps/cruft/ibs_rx_test.c
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "nonstdio.h"
-
-#define PORT 2 // ethernet = 2, serdes = 0
-int dsp_rx_buf, dsp_tx_buf, serdes_rx_buf, serdes_tx_buf;
-int dsp_rx_idle, dsp_tx_idle, serdes_rx_idle, serdes_tx_idle;
-
-int buffer_state[4];
-
-static void __attribute__((unused))
-wait_until_status_nonzero(void)
-{
- while (buffer_pool_status->status == 0)
- ;
-}
-
-int
-main(void)
-{
- int i;
-
- u2_init();
-
- output_regs->adc_ctrl = 0x0A;
-
- dsp_rx_regs->freq = 0;
- dsp_rx_regs->scale_iq = (1 << 16) | 1;
- dsp_rx_regs->decim_rate = 8;
-
- volatile unsigned int *buffer0 = buffer_ram(0);
- volatile unsigned int *buffer1 = buffer_ram(1);
- volatile unsigned int *buffer2 = buffer_ram(2);
-
- putstr("Starting RX\n");
- bp_clear_buf(0);
- bp_receive_to_buf(0, 1, 1, 0, 99);
-
- dsp_rx_regs->rx_command = (50 << 9) | 100; // Numlines, lines per frame
- dsp_rx_regs->rx_time = 0x2000;
-
- dsp_rx_regs->rx_command = (137 << 9) | 50; // Numlines, lines per frame
- dsp_rx_regs->rx_time = 0x2200;
-
- while (buffer_pool_status->status == 0)
- ;
- bp_clear_buf(0);
- bp_clear_buf(1);
- bp_receive_to_buf(1, 1, 1, 0, 99);
- while (buffer_pool_status->status == 0)
- ;
- bp_clear_buf(2);
- bp_receive_to_buf(2, 1, 1, 0, 99);
- while (buffer_pool_status->status == 0)
- ;
-
- for(i=0;i<100;i++) {
- puthex(i);
- putstr(" ");
- puthex_nl(buffer0[i]);
- }
- for(i=0;i<60;i++) {
- puthex(i);
- putstr(" ");
- puthex_nl(buffer1[i]);
- }
- for(i=0;i<60;i++) {
- puthex(i);
- putstr(" ");
- puthex_nl(buffer2[i]);
- }
- //while(timer_regs -> time < 0x6000)
- // {}
-
- putstr("Done\n");
- hal_finish();
-
- return 1;
-}
diff --git a/firmware/microblaze/apps/cruft/ibs_tx_test.c b/firmware/microblaze/apps/cruft/ibs_tx_test.c
deleted file mode 100644
index ff9446d92..000000000
--- a/firmware/microblaze/apps/cruft/ibs_tx_test.c
+++ /dev/null
@@ -1,160 +0,0 @@
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "nonstdio.h"
-
-// Globals
-#define EMPTY 0
-#define FILLING 1
-#define FULL 2
-#define EMPTYING 3
-
-#define PORT 2 // ethernet = 2, serdes = 0
-int dsp_rx_buf, dsp_tx_buf, serdes_rx_buf, serdes_tx_buf;
-int dsp_rx_idle, dsp_tx_idle, serdes_rx_idle, serdes_tx_idle;
-
-int buffer_state[4];
-
-static void
-wait_until_status_nonzero(void)
-{
- while (buffer_pool_status->status == 0)
- ;
-}
-
-int
-main(void)
-{
- int i;
-
- u2_init();
-
- dsp_tx_regs->freq = 0;
- dsp_tx_regs->scale_iq = (1 << 16) | 1;
- dsp_tx_regs->interp_rate = 8;
-
- // Write data to be sent into the first buffer
- volatile unsigned int *buffer0 = buffer_ram(0);
- volatile unsigned int *buffer1 = buffer_ram(1);
-
-
- putstr("Starting to fill in RAM\n");
- for(i=0;i<512;i++)
- buffer0[i] = i;
- putstr("Filled in RAM\n");
-
- buffer0[0] = 7; // start and end of buffer, send immediately
- buffer0[1] = 0x0000; // start time
- bp_clear_buf(0);
- bp_send_from_buf(0, 1, 1, 0, 9);
- while (buffer_pool_status->status == 0)
- ;
- while(timer_regs -> time < 0x6000)
- {}
-
- buffer0[0] = 3; // start and end of buffer
- buffer0[1] = 0x8000; // start time
- bp_clear_buf(0);
- bp_send_from_buf(0, 1, 1, 0, 9);
- while (buffer_pool_status->status == 0)
- ;
- while(timer_regs -> time < 0x8400)
- {}
-
- buffer0[0] = 3; // start and end of buffer
- buffer0[1] = 0x8800; // start time
- bp_clear_buf(0);
- bp_send_from_buf(0, 1, 1, 0, 9);
- while (buffer_pool_status->status == 0)
- ;
- while(timer_regs -> time < 0x9000)
- {}
-
- buffer0[0] = 0x2; // not last
- buffer0[1] = 0x9100; // start time
- bp_clear_buf(0);
- bp_send_from_buf(0, 1, 1, 0, 9);
- while (buffer_pool_status->status == 0)
- ;
- buffer0[0] = 0x1; // last
- buffer0[1] = 0x0000; // start time
- bp_clear_buf(0);
- bp_send_from_buf(0, 1, 1, 0, 9);
- while (buffer_pool_status->status == 0)
- ;
-
-
- buffer0[0] = 0x3; // first and last
- buffer0[1] = 0x8000; // Time in the past
- bp_clear_buf(0);
- bp_send_from_buf(0, 1, 1, 0, 9);
- while (buffer_pool_status->status == 0)
- ;
-
- /*
- buffer0[0] = 0x2; // not last
- buffer0[1] = 0x9600; // start time
- bp_clear_buf(0);
- bp_send_from_buf(0, 1, 1, 0, 9);
- while (buffer_pool_status->status == 0)
- ;
- */
-
- while(timer_regs -> time < 0xa000)
- {}
-
- putstr("Done\n");
-
- while(1)
- {}
- hal_finish();
-
- // Send a bunch, let them pile up in FIFO
- bp_send_from_buf(0, 2, 1, 21, 80); wait_until_status_nonzero();
- bp_clear_buf(0);
- putstr("First add'l TX done\n");
- bp_send_from_buf(0, 2, 1, 81, 288); wait_until_status_nonzero();
- bp_clear_buf(0);
- bp_send_from_buf(0, 2, 1, 289, 292); wait_until_status_nonzero();
- bp_clear_buf(0);
- bp_send_from_buf(0, 2, 1, 293, 326); wait_until_status_nonzero();
- bp_clear_buf(0);
- bp_send_from_buf(0, 2, 1, 327, 399); wait_until_status_nonzero();
- bp_clear_buf(0);
- bp_send_from_buf(0, 2, 1, 400, 511); wait_until_status_nonzero();
- bp_clear_buf(0);
- putstr("All add'l TX done\n");
-
- bp_receive_to_buf(1, 2, 1, 21, 80); wait_until_status_nonzero();
- bp_clear_buf(1);
- putstr("First add'l RX done\n");
- bp_receive_to_buf(1, 2, 1, 81, 288); wait_until_status_nonzero();
- bp_clear_buf(1);
- bp_receive_to_buf(1, 2, 1, 289, 292); wait_until_status_nonzero();
- bp_clear_buf(1);
- bp_receive_to_buf(1, 2, 1, 293, 326); wait_until_status_nonzero();
- bp_clear_buf(1);
- bp_receive_to_buf(1, 2, 1, 327, 399); wait_until_status_nonzero();
- bp_clear_buf(1);
- bp_receive_to_buf(1, 2, 1, 400, 511); wait_until_status_nonzero();
- bp_clear_buf(1);
- putstr("All add'l RX done\n");
-
- for(i=0;i<512;i++)
- if(buffer0[i] != buffer1[i]) {
- putstr("ERROR at location: ");
- puthex_nl(i);
- putstr("Value sent: ");
- puthex_nl(buffer0[i]);
- putstr("Value rcvd: ");
- puthex_nl(buffer1[i]);
- //break;
- }
-
- putstr("Done Testing\n");
-
- hal_finish();
- return 1;
-}
diff --git a/firmware/microblaze/apps/cruft/mimo_app_common_v2.c b/firmware/microblaze/apps/cruft/mimo_app_common_v2.c
deleted file mode 100644
index 5dbecb0d0..000000000
--- a/firmware/microblaze/apps/cruft/mimo_app_common_v2.c
+++ /dev/null
@@ -1,582 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "mimo_app_common_v2.h"
-#include "buffer_pool.h"
-#include "memcpy_wa.h"
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "print_rmon_regs.h"
-#include "db.h"
-#include "db_base.h"
-#include "clocks.h"
-#include "u2_init.h"
-#include <string.h>
-
-volatile bool link_is_up = false; // eth handler sets this
-int cpu_tx_buf_dest_port = PORT_ETH;
-
-// If this is non-zero, this dbsm could be writing to the ethernet
-dbsm_t *ac_could_be_sending_to_eth;
-
-static unsigned char exp_seqno __attribute__((unused)) = 0;
-
-void abort(void);
-
-static bool
-burn_mac_addr(const op_burn_mac_addr_t *p)
-{
- return ethernet_set_mac_addr(&p->addr);
-}
-
-static bool
-sync_to_pps(const op_generic_t *p)
-{
- timesync_regs->sync_on_next_pps = 1;
- putstr("SYNC to PPS\n");
- return true;
-}
-
-static bool
-config_mimo_cmd(const op_config_mimo_t *p)
-{
- clocks_mimo_config(p->flags);
- return true;
-}
-
-void
-set_reply_hdr(u2_eth_packet_t *reply_pkt, u2_eth_packet_t const *cmd_pkt)
-{
- reply_pkt->ehdr.dst = cmd_pkt->ehdr.src;
- reply_pkt->ehdr.src = *ethernet_mac_addr();
- reply_pkt->ehdr.ethertype = U2_ETHERTYPE;
- reply_pkt->thdr.flags = 0;
- reply_pkt->thdr.fifo_status = 0; // written by protocol engine
- reply_pkt->thdr.seqno = 0; // written by protocol engine
- reply_pkt->thdr.ack = 0; // written by protocol engine
- u2p_set_word0(&reply_pkt->fixed, 0, CONTROL_CHAN);
- reply_pkt->fixed.timestamp = timer_regs->time;
-}
-
-static void
-send_reply(unsigned char *reply, size_t reply_len)
-{
- if (reply_len < 64)
- reply_len = 64;
-
- // wait for buffer to become idle
- hal_set_leds(0x4, 0x4);
- while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0)
- ;
- hal_set_leds(0x0, 0x4);
-
- // copy reply into CPU_TX_BUF
- memcpy_wa(buffer_ram(CPU_TX_BUF), reply, reply_len);
-
- // wait until nobody else is sending to the ethernet
- if (ac_could_be_sending_to_eth){
- hal_set_leds(0x8, 0x8);
- dbsm_wait_for_opening(ac_could_be_sending_to_eth);
- hal_set_leds(0x0, 0x8);
- }
-
- if (0){
- printf("sending_reply to port %d, len = %d\n", cpu_tx_buf_dest_port, (int)reply_len);
- print_buffer(buffer_ram(CPU_TX_BUF), reply_len/4);
- }
-
- // fire it off
- bp_send_from_buf(CPU_TX_BUF, cpu_tx_buf_dest_port, 1, 0, reply_len/4);
-
- // wait for it to complete (not long, it's a small pkt)
- while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0)
- ;
-
- bp_clear_buf(CPU_TX_BUF);
-}
-
-
-static size_t
-op_id_cmd(const op_generic_t *p,
- void *reply_payload, size_t reply_payload_space)
-{
- op_id_reply_t *r = (op_id_reply_t *) reply_payload;
- if (reply_payload_space < sizeof(*r)) // no room
- return 0;
-
- // Build reply subpacket
-
- r->opcode = OP_ID_REPLY;
- r->len = sizeof(op_id_reply_t);
- r->rid = p->rid;
- r->addr = *ethernet_mac_addr();
- r->hw_rev = (u2_hw_rev_major << 8) | u2_hw_rev_minor;
- // r->fpga_md5sum = ; // FIXME
- // r->sw_md5sum = ; // FIXME
-
- return r->len;
-}
-
-
-static size_t
-config_tx_v2_cmd(const op_config_tx_v2_t *p,
- void *reply_payload, size_t reply_payload_space)
-{
- op_config_tx_reply_v2_t *r = (op_config_tx_reply_v2_t *) reply_payload;
- if (reply_payload_space < sizeof(*r))
- return 0; // no room
-
- struct tune_result tune_result;
- memset(&tune_result, 0, sizeof(tune_result));
-
- bool ok = true;
-
-#if 0
- if (p->valid & CFGV_GAIN){
- ok &= db_set_gain(tx_dboard, p->gain);
- }
-
- if (p->valid & CFGV_FREQ){
- bool was_streaming = is_streaming();
- if (was_streaming)
- stop_rx_cmd();
-
- u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
- bool tune_ok = db_tune(tx_dboard, f, &tune_result);
- ok &= tune_ok;
- print_tune_result("Tx", tune_ok, f, &tune_result);
-
- if (was_streaming)
- restart_streaming();
- }
-
- if (p->valid & CFGV_INTERP_DECIM){
- int interp = p->interp;
- int hb1 = 0;
- int hb2 = 0;
-
- if (!(interp & 1)){
- hb2 = 1;
- interp = interp >> 1;
- }
-
- if (!(interp & 1)){
- hb1 = 1;
- interp = interp >> 1;
- }
-
- if (interp < MIN_CIC_INTERP || interp > MAX_CIC_INTERP)
- ok = false;
- else {
- dsp_tx_regs->interp_rate = (hb1<<9) | (hb2<<8) | interp;
- // printf("Interp: %d, register %d\n", p->interp, (hb1<<9) | (hb2<<8) | interp);
- }
- }
-
- if (p->valid & CFGV_SCALE_IQ){
- dsp_tx_regs->scale_iq = p->scale_iq;
- }
-#endif
-
- // Build reply subpacket
-
- r->opcode = OP_CONFIG_TX_REPLY_V2;
- r->len = sizeof(*r);
- r->rid = p->rid;
- r->ok = ok;
- r->inverted = tune_result.inverted;
- r->baseband_freq_hi = u2_fxpt_freq_hi(tune_result.baseband_freq);
- r->baseband_freq_lo = u2_fxpt_freq_lo(tune_result.baseband_freq);
- r->duc_freq_hi = u2_fxpt_freq_hi(tune_result.dxc_freq);
- r->duc_freq_lo = u2_fxpt_freq_lo(tune_result.dxc_freq);
- r->residual_freq_hi = u2_fxpt_freq_hi(tune_result.residual_freq);
- r->residual_freq_lo = u2_fxpt_freq_lo(tune_result.residual_freq);
- return r->len;
-}
-
-static size_t
-config_rx_v2_cmd(const op_config_rx_v2_t *p,
- void *reply_payload, size_t reply_payload_space)
-{
- op_config_rx_reply_v2_t *r = (op_config_rx_reply_v2_t *) reply_payload;
- if (reply_payload_space < sizeof(*r))
- return 0; // no room
-
- struct tune_result tune_result;
- memset(&tune_result, 0, sizeof(tune_result));
-
- bool ok = true;
-
- if (p->valid & CFGV_GAIN){
- ok &= db_set_gain(rx_dboard, p->gain);
- }
-
- if (p->valid & CFGV_FREQ){
- bool was_streaming = is_streaming();
- if (was_streaming)
- stop_rx_cmd();
-
- u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
- bool tune_ok = db_tune(rx_dboard, f, &tune_result);
- ok &= tune_ok;
- print_tune_result("Rx", tune_ok, f, &tune_result);
-
- if (was_streaming)
- restart_streaming();
- }
-
- if (p->valid & CFGV_INTERP_DECIM){
- int decim = p->decim;
- int hb1 = 0;
- int hb2 = 0;
-
- if(!(decim & 1)) {
- hb2 = 1;
- decim = decim >> 1;
- }
-
- if(!(decim & 1)) {
- hb1 = 1;
- decim = decim >> 1;
- }
-
- if (decim < MIN_CIC_DECIM || decim > MAX_CIC_DECIM)
- ok = false;
- else {
- dsp_rx_regs->decim_rate = (hb1<<9) | (hb2<<8) | decim;
- // printf("Decim: %d, register %d\n", p->decim, (hb1<<9) | (hb2<<8) | decim);
- }
- }
-
- if (p->valid & CFGV_SCALE_IQ){
- dsp_rx_regs->scale_iq = p->scale_iq;
- }
-
- // Build reply subpacket
-
- r->opcode = OP_CONFIG_RX_REPLY_V2;
- r->len = sizeof(*r);
- r->rid = p->rid;
- r->ok = ok;
- r->inverted = tune_result.inverted;
- r->baseband_freq_hi = u2_fxpt_freq_hi(tune_result.baseband_freq);
- r->baseband_freq_lo = u2_fxpt_freq_lo(tune_result.baseband_freq);
- r->ddc_freq_hi = u2_fxpt_freq_hi(tune_result.dxc_freq);
- r->ddc_freq_lo = u2_fxpt_freq_lo(tune_result.dxc_freq);
- r->residual_freq_hi = u2_fxpt_freq_hi(tune_result.residual_freq);
- r->residual_freq_lo = u2_fxpt_freq_lo(tune_result.residual_freq);
-
- return r->len;
-}
-
-static size_t
-read_time_cmd(const op_generic_t *p,
- void *reply_payload, size_t reply_payload_space)
-{
- op_read_time_reply_t *r = (op_read_time_reply_t *) reply_payload;
- if (reply_payload_space < sizeof(*r))
- return 0; // no room
-
- r->opcode = OP_READ_TIME_REPLY;
- r->len = sizeof(*r);
- r->rid = p->rid;
- r->time = timer_regs->time;
-
- return r->len;
-}
-
-static void
-fill_db_info(u2_db_info_t *p, const struct db_base *db)
-{
- p->dbid = db->dbid;
- p->freq_min_hi = u2_fxpt_freq_hi(db->freq_min);
- p->freq_min_lo = u2_fxpt_freq_lo(db->freq_min);
- p->freq_max_hi = u2_fxpt_freq_hi(db->freq_max);
- p->freq_max_lo = u2_fxpt_freq_lo(db->freq_max);
- p->gain_min = db->gain_min;
- p->gain_max = db->gain_max;
- p->gain_step_size = db->gain_step_size;
-}
-
-static size_t
-dboard_info_cmd(const op_generic_t *p,
- void *reply_payload, size_t reply_payload_space)
-{
- op_dboard_info_reply_t *r = (op_dboard_info_reply_t *) reply_payload;
- if (reply_payload_space < sizeof(*r))
- return 0; // no room
-
- r->opcode = OP_DBOARD_INFO_REPLY;
- r->len = sizeof(*r);
- r->rid = p->rid;
- r->ok = true;
-
- fill_db_info(&r->tx_db_info, tx_dboard);
- fill_db_info(&r->rx_db_info, rx_dboard);
-
- return r->len;
-}
-
-static size_t
-peek_cmd(const op_peek_t *p,
- void *reply_payload, size_t reply_payload_space)
-{
- op_generic_t *r = (op_generic_t *) reply_payload;
-
- putstr("peek: addr="); puthex32(p->addr);
- printf(" bytes=%u\n", p->bytes);
-
- if ((reply_payload_space < (sizeof(*r) + p->bytes)) ||
- p->bytes > MAX_SUBPKT_LEN - sizeof(op_generic_t)) {
- putstr("peek: insufficient reply packet space\n");
- return 0; // FIXME do partial read?
- }
-
- r->opcode = OP_PEEK_REPLY;
- r->len = sizeof(*r)+p->bytes;
- r->rid = p->rid;
- r->ok = true;
-
- memcpy_wa(reply_payload+sizeof(*r), (void *)p->addr, p->bytes);
-
- return r->len;
-}
-
-static bool
-poke_cmd(const op_poke_t *p)
-{
- int bytes = p->len - sizeof(*p);
- putstr("poke: addr="); puthex32(p->addr);
- printf(" bytes=%u\n", bytes);
-
- uint8_t *src = (uint8_t *)p + sizeof(*p);
- memcpy_wa((void *)p->addr, src, bytes);
-
- return true;
-}
-
-static size_t
-generic_reply(const op_generic_t *p,
- void *reply_payload, size_t reply_payload_space,
- bool ok)
-{
- op_generic_t *r = (op_generic_t *) reply_payload;
- if (reply_payload_space < sizeof(*r))
- return 0; // no room
-
- r->opcode = p->opcode | OP_REPLY_BIT;
- r->len = sizeof(*r);
- r->rid = p->rid;
- r->ok = ok;
-
- return r->len;
-}
-
-static size_t
-add_eop(void *reply_payload, size_t reply_payload_space)
-{
- op_generic_t *r = (op_generic_t *) reply_payload;
- if (reply_payload_space < sizeof(*r))
- return 0; // no room
-
- r->opcode = OP_EOP;
- r->len = sizeof(*r);
- r->rid = 0;
- r->ok = 0;
-
- return r->len;
-}
-
-void
-handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
-{
- unsigned char reply[sizeof(u2_eth_packet_t) + 4 * sizeof(u2_subpkt_t)] _AL4;
- unsigned char *reply_payload = &reply[sizeof(u2_eth_packet_t)];
- int reply_payload_space = sizeof(reply) - sizeof(u2_eth_packet_t);
-
- // initialize reply
- memset(reply, 0, sizeof(reply));
- set_reply_hdr((u2_eth_packet_t *) reply, pkt);
-
- // point to beginning of payload (subpackets)
- unsigned char *payload = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t);
- int payload_len = len - sizeof(u2_eth_packet_t);
-
- size_t subpktlen = 0;
-
- while (payload_len >= sizeof(op_generic_t)){
- const op_generic_t *gp = (const op_generic_t *) payload;
- subpktlen = 0;
-
- // printf("\nopcode = %d\n", gp->opcode);
-
- switch(gp->opcode){
- case OP_EOP: // end of subpackets
- goto end_of_subpackets;
-
- case OP_ID:
- subpktlen = op_id_cmd(gp, reply_payload, reply_payload_space);
- break;
-
- case OP_CONFIG_TX_V2:
- subpktlen = config_tx_v2_cmd((op_config_tx_v2_t *) payload,
- reply_payload, reply_payload_space);
- break;
-
- case OP_CONFIG_RX_V2:
- subpktlen = config_rx_v2_cmd((op_config_rx_v2_t *) payload,
- reply_payload, reply_payload_space);
- break;
-
- case OP_START_RX_STREAMING:
- start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload);
- subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true);
- break;
-
- case OP_STOP_RX:
- stop_rx_cmd();
- subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true);
- break;
-
- case OP_BURN_MAC_ADDR:
- subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
- burn_mac_addr((op_burn_mac_addr_t *) payload));
- break;
-
- case OP_CONFIG_MIMO:
- subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
- config_mimo_cmd((op_config_mimo_t *) payload));
- break;
-
- case OP_READ_TIME:
- subpktlen = read_time_cmd(gp, reply_payload, reply_payload_space);
- break;
-
- case OP_DBOARD_INFO:
- subpktlen = dboard_info_cmd(gp, reply_payload, reply_payload_space);
- break;
-
- case OP_SYNC_TO_PPS:
- subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
- sync_to_pps((op_generic_t *) payload));
- break;
-
- case OP_PEEK:
- subpktlen = peek_cmd((op_peek_t *)payload, reply_payload, reply_payload_space);
- break;
-
- case OP_POKE:
- subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
- poke_cmd((op_poke_t *)payload));
- break;
-
- default:
- printf("app_common_v2: unhandled opcode = %d\n", gp->opcode);
- break;
- }
-
- int t = (gp->len + 3) & ~3; // bump to a multiple of 4
- payload += t;
- payload_len -= t;
-
- subpktlen = (subpktlen + 3) & ~3; // bump to a multiple of 4
- reply_payload += subpktlen;
- reply_payload_space -= subpktlen;
- }
-
- end_of_subpackets:
-
- // add the EOP marker
- subpktlen = add_eop(reply_payload, reply_payload_space);
- subpktlen = (subpktlen + 3) & ~3; // bump to a multiple of 4
- reply_payload += subpktlen;
- reply_payload_space -= subpktlen;
-
- send_reply(reply, reply_payload - reply);
-}
-
-
-/*
- * Called when an ethernet packet is received.
- * Return true if we handled it here, otherwise
- * it'll be passed on to the DSP Tx pipe
- */
-int
-eth_pkt_inspector(bsm12_t *sm, int bufno)
-{
- u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno);
- size_t byte_len = (buffer_pool_status->last_line[bufno] - 3) * 4;
-
- //static size_t last_len = 0;
-
- // hal_toggle_leds(0x1);
-
- // inspect rcvd frame and figure out what do do.
-
- if (pkt->ehdr.ethertype != U2_ETHERTYPE)
- return true; // ignore, probably bogus PAUSE frame from MAC
-
- int chan = u2p_chan(&pkt->fixed);
-
- switch (chan){
- case CONTROL_CHAN:
- handle_control_chan_frame(pkt, byte_len);
- return -1;
- break;
-
- case 0:
- return 0; // pass it off to DSP TX
-
- case 1:
- return 1; // pass it off to SERDES TX
-
- default:
- abort();
- break;
- }
-}
-
-/*
- * Called when eth phy state changes (w/ interrupts disabled)
- */
-void
-link_changed_callback(int speed)
-{
- link_is_up = speed != 0;
- hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45);
- printf("\neth link changed: speed = %d\n", speed);
-}
-
-
-void
-print_tune_result(char *msg, bool tune_ok,
- u2_fxpt_freq_t target_freq, struct tune_result *r)
-{
-#if 0
- printf("db_tune %s %s\n", msg, tune_ok ? "true" : "false");
- putstr(" target_freq "); print_fxpt_freq(target_freq); newline();
- putstr(" baseband_freq "); print_fxpt_freq(r->baseband_freq); newline();
- putstr(" dxc_freq "); print_fxpt_freq(r->dxc_freq); newline();
- putstr(" residual_freq "); print_fxpt_freq(r->residual_freq); newline();
- printf(" inverted %s\n", r->inverted ? "true" : "false");
-#endif
-}
diff --git a/firmware/microblaze/apps/cruft/mimo_app_common_v2.h b/firmware/microblaze/apps/cruft/mimo_app_common_v2.h
deleted file mode 100644
index 1e62ced37..000000000
--- a/firmware/microblaze/apps/cruft/mimo_app_common_v2.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifndef INCLUDED_APP_COMMON_H
-#define INCLUDED_APP_COMMON_H
-
-#include <stdbool.h>
-#include "usrp2_eth_packet.h"
-#include "bsm12.h"
-#include "memory_map.h"
-#include "hal_io.h"
-#include <stddef.h>
-#include <db.h>
-
-#define CPU_TX_BUF 7 // cpu -> eth
-
-#define _AL4 __attribute__((aligned (4)))
-
-extern volatile bool link_is_up; // eth handler sets this
-
-// If there's a dbsm that sends to the ethernet, put it's address here
-extern dbsm_t *ac_could_be_sending_to_eth;
-
-extern int cpu_tx_buf_dest_port;
-
-void set_reply_hdr(u2_eth_packet_t *reply_pkt, u2_eth_packet_t const *cmd_pkt);
-
-/*
- * Called when an ethernet packet is received.
- */
-int eth_pkt_inspector(bsm12_t *sm, int bufno);
-
-
-void link_changed_callback(int speed);
-
-void
-print_tune_result(char *msg, bool tune_ok,
- u2_fxpt_freq_t target_freq, struct tune_result *r);
-
-
-void start_rx_streaming_cmd(const eth_mac_addr_t *host, op_start_rx_streaming_t *p);
-void stop_rx_cmd(void);
-void restart_streaming(void);
-bool is_streaming(void);
-
-void handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len);
-
-#endif /* INCLUDED_APP_COMMON_H */
diff --git a/firmware/microblaze/apps/cruft/mimo_tx.c b/firmware/microblaze/apps/cruft/mimo_tx.c
deleted file mode 100644
index e0f8aa6fa..000000000
--- a/firmware/microblaze/apps/cruft/mimo_tx.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-/*
- * This is a down and dirty test program that confirms that the we can
- * coherently transmit different signals to two USRP2s connected via a
- * mimo cable. This code runs in the USRP2 connected to the ethernet.
- * The other USRP runs mimo_tx_slave. The host runs test_mimo_tx.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "bsm12.h"
-#include "mimo_app_common_v2.h"
-#include "memcpy_wa.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include "clocks.h"
-
-#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
-
-#if (FW_SETS_SEQNO)
-static int fw_seqno; // used when f/w is filling in sequence numbers
-#endif
-
-
-/*
- * Experimental code to transmit packets to DSP Tx and SERDES
- *
- * Hard wire the Tx config so we don't have to deal with control stuff yet.
- */
-
-#define BUF_BSM12_0 4
-#define BUF_BSM12_1 5
-#define BUF_BSM12_2 6
-
-//#define CPU_TX_BUF 7 // cpu -> eth
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4)
-
-// Receive from ethernet
-buf_cmd_args_t bsm12_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t bsm12_send0_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-// send to SERDES
-buf_cmd_args_t bsm12_send1_args = {
- PORT_SERDES,
- 0, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-bsm12_t bsm12_sm; // the state machine
-
-#if 0
-/*
- * ================================================================
- * configure DSP RX double buffering state machine (dsp -> eth)
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 1 line (word0)
-// DSP Rx writes timestamp followed by nlines_per_frame of samples
-#define DSP_RX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4 + 1)
-
-// receive from DSP
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to ETH
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_ETH,
- 0, // starts with ethernet header in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-#endif
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-// variables for streaming mode
-
-static bool streaming_p = false;
-static unsigned int streaming_items_per_frame = 0;
-static int streaming_frame_count = 0;
-#define FRAMES_PER_CMD 1000
-
-bool is_streaming(void){ return streaming_p; }
-
-
-// ----------------------------------------------------------------
-
-
-void
-restart_streaming(void)
-{
-#if 0
- // setup RX DSP regs
- dsp_rx_regs->clear_state = 1; // reset
-
- streaming_p = true;
- streaming_frame_count = FRAMES_PER_CMD;
-
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1); // set "chain" bit
-
- // kick off the state machine
- dbsm_start(&dsp_rx_sm);
-
- dsp_rx_regs->rx_time = 0; // enqueue first of two commands
-
- // make sure this one and the rest have the "now" and "chain" bits set.
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1);
-
- dsp_rx_regs->rx_time = 0; // enqueue second command
-#endif
-}
-
-void
-start_rx_streaming_cmd(const eth_mac_addr_t *host, op_start_rx_streaming_t *p)
-{
-#if 0
- host_mac_addr = *host; // remember who we're sending to
-
- /*
- * Construct ethernet header and word0 and preload into two buffers
- */
- u2_eth_packet_t pkt;
- memset(&pkt, 0, sizeof(pkt));
- pkt.ehdr.dst = *host;
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
- u2p_set_word0(&pkt.fixed, 0, 0);
- // DSP RX will fill in timestamp
-
- memcpy_wa(buffer_ram(DSP_RX_BUF_0), &pkt, sizeof(pkt));
- memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt));
-
-
- if (FW_SETS_SEQNO)
- fw_seqno = 0;
-
- streaming_items_per_frame = p->items_per_frame;
- restart_streaming();
-#endif
-}
-
-
-void
-stop_rx_cmd(void)
-{
-#if 0
- streaming_p = false;
- dsp_rx_regs->clear_state = 1; // flush cmd queue
- bp_clear_buf(DSP_RX_BUF_0);
- bp_clear_buf(DSP_RX_BUF_1);
-#endif
-}
-
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
-
- int tx_scale = 2500;
- int interp = 8; // * 4
-
- // setup some defaults
-
- dsp_tx_regs->freq = 429496730; // 10MHz
- dsp_tx_regs->scale_iq = (tx_scale << 16) | tx_scale;
- dsp_tx_regs->interp_rate = (1 << 9) | (1 << 8) | interp;
-}
-
-
-#if 0
-#if (FW_SETS_SEQNO)
-/*
- * Debugging ONLY. This will be handled by the tx_protocol_engine.
- *
- * This is called when the DSP Rx chain has filled in a packet.
- * We set and increment the seqno, then return false, indicating
- * that we didn't handle the packet. A bit of a kludge
- * but it should work.
- */
-int
-fw_sets_seqno_inspector(bsm12_t *sm, int buf_this)
-{
- uint32_t *p = buffer_ram(buf_this);
- uint32_t seqno = fw_seqno++;
-
- // KLUDGE all kinds of nasty magic numbers and embedded knowledge
- uint32_t t = p[4];
- t = (t & 0xffff00ff) | ((seqno & 0xff) << 8);
- p[4] = t;
-
- // queue up another rx command when required
- if (streaming_p && --streaming_frame_count == 0){
- streaming_frame_count = FRAMES_PER_CMD;
- dsp_rx_regs->rx_time = 0;
- }
-
- return false; // we didn't handle the packet
-}
-#endif
-#endif
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- bsm12_process_status(&bsm12_sm, status);
-}
-
-int
-main(void)
-{
- u2_init();
-
- putstr("\nMIMO Tx\n");
- print_mac_addr(ethernet_mac_addr()->addr);
- newline();
-
- ethernet_register_link_changed_callback(link_changed_callback);
- ethernet_init();
-
- clocks_mimo_config(MC_WE_DONT_LOCK | MC_PROVIDE_CLK_TO_MIMO);
-
-#if 0
- // make bit 15 of Tx gpio's be a s/w output
- hal_gpio_set_sel(GPIO_TX_BANK, 15, 's');
- hal_gpio_set_ddr(GPIO_TX_BANK, 0x8000, 0x8000);
-#endif
-
- output_regs->debug_mux_ctrl = 1;
-#if 0
- hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
- hal_gpio_set_ddr(GPIO_TX_BANK, 0xffff, 0xffff);
- hal_gpio_set_ddr(GPIO_RX_BANK, 0xffff, 0xffff);
-#endif
-
-
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- bsm12_init(&bsm12_sm, BUF_BSM12_0,
- &bsm12_recv_args, &bsm12_send0_args, &bsm12_send1_args,
- eth_pkt_inspector);
-
-
-#if 0
- // initialize double buffering state machine for DSP RX -> Ethernet
-
- if (FW_SETS_SEQNO){
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- fw_sets_seqno_inspector);
- }
- else {
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_nop_inspector);
- }
-
- // tell app_common that this dbsm could be sending to the ethernet
- ac_could_be_sending_to_eth = &dsp_rx_sm;
-#endif
-
-
- // program tx registers
- setup_tx();
-
- // kick off the state machine
- bsm12_start(&bsm12_sm);
-
- //int which = 0;
-
- while(1){
- // hal_gpio_write(GPIO_TX_BANK, which, 0x8000);
- // which ^= 0x8000;
-
- buffer_irq_handler(0);
-
- int pending = pic_regs->pending; // poll for under or overrun
-
- if (pending & PIC_UNDERRUN_INT){
- // dbsm_handle_tx_underrun(&dsp_tx_sm);
- pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
- putchar('U');
- }
-
- if (pending & PIC_OVERRUN_INT){
- // dbsm_handle_rx_overrun(&dsp_rx_sm);
- pic_regs->pending = PIC_OVERRUN_INT; // clear pending interrupt
-
- // FIXME Figure out how to handle this robustly.
- // Any buffers that are emptying should be allowed to drain...
-
- if (streaming_p){
- // restart_streaming();
- // FIXME report error
- }
- else {
- // FIXME report error
- }
- putchar('O');
- }
- }
-}
diff --git a/firmware/microblaze/apps/cruft/mimo_tx_slave.c b/firmware/microblaze/apps/cruft/mimo_tx_slave.c
deleted file mode 100644
index cdf9c03c2..000000000
--- a/firmware/microblaze/apps/cruft/mimo_tx_slave.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-/*
- * This is a down and dirty test program that confirms that the we can
- * coherently transmit different signals to two USRP2s connected via a
- * mimo cable. This code runs in the USRP2 NOT connected to the
- * ethernet. The USRP connected to the ethernet runs mimo_tx. The
- * host runs test_mimo_tx.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common_v2.h"
-#include "memcpy_wa.h"
-#include "clocks.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
-
-#if (FW_SETS_SEQNO)
-static int fw_seqno; // used when f/w is filling in sequence numbers
-#endif
-
-
-/*
- * Full duplex Tx and Rx between serdes and DSP pipelines
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to serdes flow
- * Buffers 4 and 5 are used to double-buffer the serdes to DSP Tx flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-
-#define DSP_RX_BUF_0 2 // dsp rx -> serdes (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> serdes
-#define DSP_TX_BUF_0 4 // serdes -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // serdes -> dsp tx
-
-/*
- * ==================================================================
- * configure DSP TX double buffering state machine (serdes -> dsp)
- * ==================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4)
-
-// Receive from serdes
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_SERDES,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-/*
- * =================================================================
- * configure DSP RX double buffering state machine (dsp -> serdes)
- * =================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 1 line (word0)
-// DSP Rx writes timestamp followed by nlines_per_frame of samples
-#define DSP_RX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4 + 1)
-
-// receive from DSP
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to serdes
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_SERDES,
- 0, // starts with ethernet header in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-// variables for streaming mode
-
-static bool streaming_p = false;
-static unsigned int streaming_items_per_frame = 0;
-static int streaming_frame_count = 0;
-#define FRAMES_PER_CMD 1000
-
-bool is_streaming(void){ return streaming_p; }
-
-// ----------------------------------------------------------------
-
-
-void
-restart_streaming(void)
-{
- // setup RX DSP regs
- dsp_rx_regs->clear_state = 1; // reset
-
- streaming_p = true;
- streaming_frame_count = FRAMES_PER_CMD;
-
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1); // set "chain" bit
-
- // kick off the state machine
- dbsm_start(&dsp_rx_sm);
-
- dsp_rx_regs->rx_time = 0; // enqueue first of two commands
-
- // make sure this one and the rest have the "now" and "chain" bits set.
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1);
-
- dsp_rx_regs->rx_time = 0; // enqueue second command
-}
-
-void
-start_rx_streaming_cmd(const eth_mac_addr_t *host, op_start_rx_streaming_t *p)
-{
- host_mac_addr = *host; // remember who we're sending to
-
- /*
- * Construct ethernet header and word0 and preload into two buffers
- */
- u2_eth_packet_t pkt;
- memset(&pkt, 0, sizeof(pkt));
- pkt.ehdr.dst = *host;
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
- u2p_set_word0(&pkt.fixed, 0, 0);
- // DSP RX will fill in timestamp
-
- memcpy_wa(buffer_ram(DSP_RX_BUF_0), &pkt, sizeof(pkt));
- memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt));
-
-
- if (FW_SETS_SEQNO)
- fw_seqno = 0;
-
- streaming_items_per_frame = p->items_per_frame;
- restart_streaming();
-}
-
-
-void
-stop_rx_cmd(void)
-{
- streaming_p = false;
- dsp_rx_regs->clear_state = 1; // flush cmd queue
- bp_clear_buf(DSP_RX_BUF_0);
- bp_clear_buf(DSP_RX_BUF_1);
-}
-
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
- int tx_scale = 2500;
- int interp = 8; // * 4
-
- // setup some defaults
-
- dsp_tx_regs->freq = 429496730; // 10MHz
- dsp_tx_regs->scale_iq = (tx_scale << 16) | tx_scale;
- dsp_tx_regs->interp_rate = (1 << 9) | (1 << 8) | interp;
-}
-
-
-#if (FW_SETS_SEQNO)
-/*
- * Debugging ONLY. This will be handled by the tx_protocol_engine.
- *
- * This is called when the DSP Rx chain has filled in a packet.
- * We set and increment the seqno, then return false, indicating
- * that we didn't handle the packet. A bit of a kludge
- * but it should work.
- */
-bool
-fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false
-{
- uint32_t *p = buffer_ram(buf_this);
- uint32_t seqno = fw_seqno++;
-
- // KLUDGE all kinds of nasty magic numbers and embedded knowledge
- uint32_t t = p[4];
- t = (t & 0xffff00ff) | ((seqno & 0xff) << 8);
- p[4] = t;
-
- // queue up another rx command when required
- if (streaming_p && --streaming_frame_count == 0){
- streaming_frame_count = FRAMES_PER_CMD;
- dsp_rx_regs->rx_time = 0;
- }
-
- return false; // we didn't handle the packet
-}
-#endif
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- // hal_toggle_leds(LED_A);
-
- uint32_t status = buffer_pool_status->status;
-
- if (0 && (status & ~BPS_IDLE_ALL)){
- putstr("status = ");
- puthex32_nl(status);
- }
-
- dbsm_process_status(&dsp_tx_sm, status);
- dbsm_process_status(&dsp_rx_sm, status);
-}
-
-int
-main(void)
-{
- u2_init();
-
- output_regs->led_src = 0x3; // h/w controls bottom two bits
- clocks_enable_test_clk(true, 1);
-
- putstr("\nMIMO Tx Slave\n");
-
- cpu_tx_buf_dest_port = PORT_SERDES;
-
- // ethernet_register_link_changed_callback(link_changed_callback);
- // ethernet_init();
-
- clocks_mimo_config(MC_WE_LOCK_TO_MIMO);
-
- // puts("post clocks_mimo_config");
-
-#if 0
- // make bit 15 of Tx gpio's be a s/w output
- hal_gpio_set_sel(GPIO_TX_BANK, 15, 's');
- hal_gpio_set_ddr(GPIO_TX_BANK, 0x8000, 0x8000);
-#endif
-
-#if 0
- output_regs->debug_mux_ctrl = 1;
- hal_gpio_set_sels(GPIO_TX_BANK, "0000000000000000");
- hal_gpio_set_sels(GPIO_RX_BANK, "0000000000000000");
- hal_gpio_set_ddr(GPIO_TX_BANK, 0xffff, 0xffff);
- hal_gpio_set_ddr(GPIO_RX_BANK, 0xffff, 0xffff);
-#endif
-
-
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- eth_pkt_inspector);
-
-
- //output_regs->flush_icache = 1;
-
- // initialize double buffering state machine for DSP RX -> Ethernet
-
- if (FW_SETS_SEQNO){
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- fw_sets_seqno_inspector);
- }
- else {
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_nop_inspector);
- }
-
- // puts("post dbsm_init's");
-
- // tell app_common that this dbsm could be sending to the ethernet
- ac_could_be_sending_to_eth = &dsp_rx_sm;
-
-
- // program tx registers
- setup_tx();
-
- // puts("post setup_tx");
-
- // kick off the state machine
- dbsm_start(&dsp_tx_sm);
-
- // puts("post dbsm_start");
-
- //int which = 0;
-
- while(1){
- // hal_gpio_write(GPIO_TX_BANK, which, 0x8000);
- // which ^= 0x8000;
-
- buffer_irq_handler(0);
-
- int pending = pic_regs->pending; // poll for under or overrun
-
- if (pending & PIC_UNDERRUN_INT){
- dbsm_handle_tx_underrun(&dsp_tx_sm);
- pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
- putchar('U');
- }
-
- if (pending & PIC_OVERRUN_INT){
- dbsm_handle_rx_overrun(&dsp_rx_sm);
- pic_regs->pending = PIC_OVERRUN_INT; // clear pending interrupt
-
- // FIXME Figure out how to handle this robustly.
- // Any buffers that are emptying should be allowed to drain...
-
- if (streaming_p){
- // restart_streaming();
- // FIXME report error
- }
- else {
- // FIXME report error
- }
- putchar('O');
- }
- }
-}
diff --git a/firmware/microblaze/apps/cruft/rcv_eth_packets.c b/firmware/microblaze/apps/cruft/rcv_eth_packets.c
deleted file mode 100644
index 03fc94354..000000000
--- a/firmware/microblaze/apps/cruft/rcv_eth_packets.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "memcpy_wa.h"
-#include <stddef.h>
-#include <stdlib.h>
-
-
-// ----------------------------------------------------------------
-
-static eth_mac_addr_t dst_mac_addr =
- {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }};
-
-
-// ----------------------------------------------------------------
-
-#define PACKET_SIZE 1500 // bytes
-#define ETH_DATA_RATE 1000000 // 1MB/s
-#define ETH_PACKET_RATE (ETH_DATA_RATE/PACKET_SIZE) // 13,3333 pkts/s
-
-#define TIMER_RATE 100000000 // 100 MHz clock
-
-static int timer_delta = TIMER_RATE/ETH_PACKET_RATE; // ticks between interrupts
-
-static volatile bool send_packet_now = false; // timer handler sets this
-static volatile bool link_is_up = false; // eth handler sets this
-
-int packet_number = 0;
-
-// ----------------------------------------------------------------
-
-// debugging output on tx pins
-#define LS_MASK 0xE0000
-#define LS_1000 0x80000
-#define LS_100 0x40000
-#define LS_10 0x20000
-
-
-/*
- * Called when eth phy state changes (w/ interrupts disabled)
- */
-void
-link_changed_callback(int speed)
-{
- int v = 0;
- switch(speed){
- case 10:
- v = LS_10;
- link_is_up = true;
- break;
-
- case 100:
- v = LS_100;
- link_is_up = true;
- break;
-
- case 1000:
- v = LS_100;
- link_is_up = true;
- break;
-
- default:
- v = 0;
- link_is_up = false;
- break;
- }
-
- //hal_gpio_set_tx(v, LS_MASK); /* set debug bits on d'board */
-
- putstr("\neth link changed: speed = ");
- puthex16_nl(speed);
-}
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
- send_packet_now = 1;
-}
-
-
-void
-buffer_irq_handler(unsigned irq)
-{
- // FIXME
-}
-
-static void
-init_packet(int *buf, const u2_eth_packet_t *pkt, int bufnum)
-{
- int i = 0;
- int mark = ((bufnum & 0xff) << 24) | 0x005A0000;
-
- for (i = 0; i < BP_NLINES; i++){
- buf[i] = mark | i;
- mark ^= 0x00FF0000;
- }
-
- // copy header into buffer
- memcpy_wa(buf, pkt, sizeof(*pkt));
-}
-
-static void
-init_packets(void)
-{
- int i;
-
- u2_eth_packet_t pkt __attribute__((aligned (4)));
-
- pkt.ehdr.dst = dst_mac_addr;
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
-
- // fill ALL buffers for debugging
- for (i = 0; i < 8; i++)
- init_packet((void *)buffer_ram(i), &pkt, i);
-}
-
-int
-main(void)
-{
- u2_init();
-
- int prev_leds = -1;
- int new_leds = 0x00;
- output_regs->leds = 0x00;
-
- int peak_hold_count = 0;
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
-
- putstr("\nrcv_eth_packets\n");
-
- init_packets();
-
- // pic_register_handler(IRQ_BUFFER, buffer_irq_handler); // poll for now
-
- // FIXME turn off timer since I don't think MTS and MFS instructions are implemented
- // pic_register_handler(IRQ_TIMER, timer_irq_handler);
- // hal_set_timeout(timer_delta);
-
- ethernet_register_link_changed_callback(link_changed_callback);
-
- ethernet_init();
-
- //eth_mac->speed = 4; // FIXME hardcode mac speed to 1000
-
- // kick off a receive
- bp_receive_to_buf(2, PORT_ETH, 1, 0, 511);
-
- while(1){
- // u2_eth_packet_t pkt;
-
- new_leds = 0;
- if (link_is_up)
- new_leds = 0x2;
-
- if ((buffer_pool_status->status & (BPS_DONE_2|BPS_ERROR_2)) != 0){
- // we've got a packet!
-
-#if 0
- // copy to stack buffer so we can byte address it
- memcpy_wa(&pkt, (void *)buffer_ram(2), sizeof(pkt));
-
- putstr("Rx: src: ");
- print_mac_addr(pkt.ehdr.dst_addr);
- putstr(" dst: ");
- print_mac_addr(pkt.ehdr.src_addr);
- putstr(" ethtype: ");
- puthex16(pkt.ehdr.ethertype);
- putstr(" len: ");
- int len = (buffer_pool_status->last_line[2] + 1) * 4;
- puthex16_nl(len);
-#else
- volatile int *bp = buffer_ram(2);
- int i;
- for (i = 0; i < 16; i++){
- puthex8(i);
- putchar(':');
- puthex32_nl(bp[i]);
- }
-#endif
-
- // kick off next receive
- bp_clear_buf(2);
- bp_receive_to_buf(2, PORT_ETH, 1, 0, 511);
-
- peak_hold_count = 2048 * 10;
- }
-
- if (peak_hold_count > 0){
- peak_hold_count--;
- new_leds |= 0x1;
- }
-
- if (new_leds != prev_leds){
- prev_leds = new_leds;
- output_regs->leds = new_leds;
- }
- }
-
- hal_finish();
- return 1;
-}
diff --git a/firmware/microblaze/apps/cruft/read_dbids.c b/firmware/microblaze/apps/cruft/read_dbids.c
deleted file mode 100644
index 24c6d9ab4..000000000
--- a/firmware/microblaze/apps/cruft/read_dbids.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include <nonstdio.h>
-#include <u2_init.h>
-#include <stdbool.h>
-#include <usrp2_i2c_addr.h>
-#include <i2c.h>
-
-
-int main(void)
-{
- u2_init();
-
- puts("\nread_dbids");
-
- unsigned char dbid_tx[2];
- unsigned char dbid_rx[2];
- bool ok;
-
- ok = eeprom_read(I2C_ADDR_TX_A, 1, dbid_tx, 2);
- if (!ok){
- puts("failed to read Tx Daugherboard EEPROM");
- }
- else {
- putstr("Tx Daugherboard ID: ");
- puthex8(dbid_tx[1]); // MSB
- puthex8(dbid_tx[0]); // LSB
- newline();
- }
-
- ok = eeprom_read(I2C_ADDR_RX_A, 1, dbid_rx, 2);
- if (!ok){
- puts("failed to read Rx Daugherboard EEPROM");
- }
- else {
- putstr("Rx Daugherboard ID: ");
- puthex8(dbid_rx[1]); // MSB
- puthex8(dbid_rx[0]); // LSB
- newline();
- }
-
- return 0;
-}
diff --git a/firmware/microblaze/apps/cruft/sd_bounce.c b/firmware/microblaze/apps/cruft/sd_bounce.c
deleted file mode 100644
index c1b48f170..000000000
--- a/firmware/microblaze/apps/cruft/sd_bounce.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-/*
- * Loopback SERDES to SERDES
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "nonstdio.h"
-#include "memset_wa.h"
-#include <dbsm.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <clocks.h>
-
-
-
-// ----------------------------------------------------------------
-
-#define SERDES_RX_BUF_0 0
-#define SERDES_RX_BUF_1 1
-
-/*
- * ================================================================
- * configure SD RX double buffering state machine
- * ================================================================
- */
-
-// receive from SERDES
-buf_cmd_args_t sd_recv_args = {
- PORT_SERDES,
- 0,
- BP_LAST_LINE
-};
-
-// send to SERDES
-buf_cmd_args_t sd_send_args = {
- PORT_SERDES,
- 0, // starts with packet in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t sd_sm; // the state machine
-
-
-
-
-// ----------------------------------------------------------------
-
-#if 0
-static bool
-check_packet(int *buf, int nlines)
-{
- bool ok = true;
- int i = 0;
- for (i = 0; i < nlines; i++){
- int expected = ((2*i + 0) << 16) | (2*i+1);
- if (buf[i] != expected){
- ok = false;
- printf("buf[%d] = 0x%x expected = 0x%x\n", i, buf[i], expected);
- }
- }
- return ok;
-}
-
-static void
-zero_buffer(int bufno)
-{
- memset_wa(buffer_ram(bufno), 0, BP_NLINES * 4);
-}
-#endif
-
-
-bool
-sd_rx_inspector(dbsm_t *sm, int buf_this)
-{
- hal_toggle_leds(0x2);
-
-#if 0
- int last_line = buffer_pool_status->last_line[buf_this];
- bool ok = check_packet(buffer_ram(buf_this), last_line);
- static int good = 0;
- static int bad = 0;
-
- if (ok)
- good++;
- else
- bad++;
-
- if(good+bad == 10000) {
- printf("Good %d\tBad %d\n",good,bad);
- good = 0;
- bad = 0;
- }
-#endif
-
- return false;
-}
-
-
-inline static void
-buffer_irq_handler(void)
-{
- uint32_t status = buffer_pool_status->status;
- dbsm_process_status(&sd_sm, status);
-}
-
-
-int
-main(void)
-{
- u2_init();
-
- putstr("\nsd_bounce\n");
-
- // Get our clock from the mimo interface
- clocks_mimo_config(MC_WE_LOCK_TO_MIMO);
-
- dbsm_init(&sd_sm, SERDES_RX_BUF_0,
- &sd_recv_args, &sd_send_args,
- sd_rx_inspector);
-
- // kick off the state machine
- dbsm_start(&sd_sm);
-
- while(1){
- buffer_irq_handler();
- }
-}
diff --git a/firmware/microblaze/apps/cruft/sd_gentest.c b/firmware/microblaze/apps/cruft/sd_gentest.c
deleted file mode 100644
index 35e912615..000000000
--- a/firmware/microblaze/apps/cruft/sd_gentest.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "nonstdio.h"
-#include "memset_wa.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <clocks.h>
-#include <mdelay.h>
-
-// ----------------------------------------------------------------
-
-int packet_number = 0;
-volatile bool send_packet_now = 0;
-
-#define SERDES_TX_BUF 0
-#define SERDES_RX_BUF 1
-
-
-#define NLINES_PER_PKT 380
-
-
-// ----------------------------------------------------------------
-
-//static int timer_delta = (int)(MASTER_CLK_RATE * 100e-6);
-static int timer_delta = 1000000; // .01 second
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
- send_packet_now = true;
-}
-
-
-static void
-init_packet(int *buf)
-{
- int i = 0;
- for (i = 0; i < BP_NLINES; i++){
- buf[i] = ((2*i + 0) << 16) | (2*i+1);
- }
-}
-
-static bool
-check_packet(int *buf, int nlines)
-{
- bool ok = true;
- int i = 0;
- for (i = 0; i < nlines; i++){
- int expected = ((2*i + 0) << 16) | (2*i+1);
- if (buf[i] != expected){
- ok = false;
- printf("buf[%d] = 0x%x expected = 0x%x\n", i, buf[i], expected);
- }
- }
- return ok;
-}
-
-static void
-zero_buffer(int bufno)
-{
- memset_wa(buffer_ram(bufno), 0, BP_NLINES * 4);
-}
-
-static void
-init_packets(void)
-{
- // init just the one we're using
- init_packet(buffer_ram(SERDES_TX_BUF));
-}
-
-int
-main(void)
-{
- u2_init();
-
- // We're free running and provide clock to the MIMO interface
- clocks_mimo_config(MC_WE_DONT_LOCK | MC_PROVIDE_CLK_TO_MIMO);
-
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- // output_regs->debug_mux_ctrl = 1;
- // hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- // hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
-
- putstr("\nsd_gentest\n");
-
- // Set up serdes (already enabled)
- //output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN | SERDES_LOOPEN);
- //output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN);
-
- init_packets();
-
- // pic_register_handler(IRQ_TIMER, timer_irq_handler);
-
- //if (hwconfig_simulation_p())
- // timer_delta = sim_timer_delta;
-
- // start a receive from sd
- zero_buffer(SERDES_RX_BUF);
- bp_receive_to_buf(SERDES_RX_BUF, PORT_SERDES, 1, 0, BP_LAST_LINE);
-
- // fire off the first packet
- bp_send_from_buf(SERDES_TX_BUF, PORT_SERDES, 1, 0, NLINES_PER_PKT);
- hal_set_timeout(timer_delta);
- int ready_to_send = 0;
-
- int counter __attribute__((unused)) = 0;
- int sent = 1;
- int txerr = 0;
- int rxerr = 0;
- int rcvd = 0;
- int rxcrc = 0;
- int sent_acc = 0;
- int txerr_acc = 0;
- int rxerr_acc = 0;
- int rcvd_acc = 0;
- int rxcrc_acc = 0;
-
-#define EXPECTING_PKT() ((counter & 0x1) == 0)
-#define SEND_PKT() ((counter & 0x1) != 0)
-
- bool got_packet = false;
-
- while(1){
- uint32_t status = buffer_pool_status->status;
-
- if (status & (BPS_DONE(SERDES_RX_BUF))){
- bp_clear_buf(SERDES_RX_BUF);
- got_packet = true;
-
- //hal_toggle_leds(0x2);
-
- // check packet
- int last_line = buffer_pool_status->last_line[SERDES_RX_BUF]-1;
- bool ok = check_packet(buffer_ram(SERDES_RX_BUF), last_line);
-
- if (ok) {
- rcvd++;
- //putchar('r');
- }
- else {
- rcvd++;
- rxcrc++;
- //putchar('P');
- }
- // start a receive from sd
- zero_buffer(SERDES_RX_BUF);
- bp_receive_to_buf(SERDES_RX_BUF, PORT_SERDES, 1, 0, BP_LAST_LINE);
- }
-
- if (status & (BPS_ERROR(SERDES_RX_BUF))){
- bp_clear_buf(SERDES_RX_BUF);
- got_packet = true;
- rcvd++;
- rxerr++;
- //putchar('E');
-
- // start a receive from sd
- zero_buffer(SERDES_RX_BUF);
- bp_receive_to_buf(SERDES_RX_BUF, PORT_SERDES, 1, 0, BP_LAST_LINE);
- }
-
- if (status & (BPS_DONE(SERDES_TX_BUF))){
- bp_clear_buf(SERDES_TX_BUF);
- //putchar('t');
- bp_send_from_buf(SERDES_TX_BUF, PORT_SERDES, 1, 0, NLINES_PER_PKT);
- //mdelay(1);
- int i;
- for (i = 0; i < 50; i++){
- asm volatile ("or r0, r0, r0\n\
- or r0, r0, r0\n \
- or r0, r0, r0\n \
- or r0, r0, r0\n \
- or r0, r0, r0\n \
- or r0, r0, r0\n \
- or r0, r0, r0\n");
- }
- sent ++;
- ready_to_send = 1;
- //hal_toggle_leds(0x1);
- }
-
- if (status & BPS_ERROR(SERDES_TX_BUF)){
- bp_clear_buf(SERDES_TX_BUF);
- sent++;
- txerr++;
- ready_to_send = 1;
- //putchar('X');
- }
-
- if(sent >=1000) {
- printf("Status\tSENT %d\tTXERR %d\t",sent,txerr);
- printf("RX %d\tERR %d\tCRC %d\tMISSED %d\n",rcvd, rxerr, rxcrc, sent-rcvd);
- sent_acc += sent; sent = 0;
- txerr_acc += txerr; txerr = 0;
- rcvd_acc += rcvd; rcvd = 0;
- rxerr_acc += rxerr; rxerr = 0;
- rxcrc_acc += rxcrc; rxcrc = 0;
- }
-
- if(sent_acc >=10000) {
- printf("\nOverall\tSENT %d\tTXERR %d\t",sent_acc,txerr_acc);
- printf("RX %d\tERR %d\tCRC %d\tMISSED %d\n\n",rcvd_acc, rxerr_acc, rxcrc_acc, sent_acc-rcvd_acc);
- sent_acc = 0;
- txerr_acc = 0;
- rcvd_acc = 0;
- rxerr_acc = 0;
- rxcrc_acc = 0;
- }
-#if 0
- int pending = pic_regs->pending;
- if (pending & PIC_TIMER_INT){
- hal_set_timeout(timer_delta);
-
- /*
- if (EXPECTING_PKT()){
- if (!got_packet)
- putchar('T');
- got_packet = false;
- }
-
- if (SEND_PKT()){
- if (status & BPS_IDLE(SERDES_TX_BUF))
- bp_send_from_buf(SERDES_TX_BUF, PORT_SERDES, 1, 0, NLINES_PER_PKT);
- }
- counter++;
- */
-
- putchar('T');
- if(ready_to_send) {
- bp_send_from_buf(SERDES_TX_BUF, PORT_SERDES, 1, 0, NLINES_PER_PKT);
- counter++;
- ready_to_send = 0;
- }
-
- pic_regs->pending = PIC_TIMER_INT; // clear pending interrupt
- }
-#endif
- }
-
- return 0;
-}
diff --git a/firmware/microblaze/apps/cruft/serdes_to_dsp.c b/firmware/microblaze/apps/cruft/serdes_to_dsp.c
deleted file mode 100644
index 4994e0a69..000000000
--- a/firmware/microblaze/apps/cruft/serdes_to_dsp.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-/*
- * This program can respond to queries from the host
- * and stream rx samples.
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-//#define CPU_TX_BUF 1 // cpu -> eth
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-/*
- * ================================================================
- * configure DSP TX double buffering state machine
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4)
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_SERDES,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-
-// ----------------------------------------------------------------
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-void
-start_rx_cmd(const eth_mac_addr_t *host, op_start_rx_t *p)
-{
-}
-
-void
-stop_rx_cmd(void)
-{
-}
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
- int tx_scale = 256;
- int interp = 32;
-
- op_config_tx_t def_config;
- memset(&def_config, 0, sizeof(def_config));
- def_config.phase_inc = 408021893; // 9.5 MHz [2**32 * fc/fsample]
- def_config.scale_iq = (tx_scale << 16) | tx_scale;
- def_config.interp = interp;
-
- // setup Tx DSP regs
- config_tx_cmd(&def_config);
-}
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- //hal_toggle_leds(0x2);
-
- uint32_t status = buffer_pool_status->status;
-
- dbsm_process_status(&dsp_tx_sm, status);
-
- if (status & BPS_DONE(CPU_TX_BUF)){
- bp_clear_buf(CPU_TX_BUF);
- }
-}
-
-int
-main(void)
-{
- u2_init();
-
- // Get our clock from the mimo interface
-
- clocks_enable_test_clk(true,1);
- clocks_mimo_config(MC_WE_LOCK_TO_MIMO);
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
-
- putstr("\nserdes_to_dsp\n");
-
- ethernet_register_link_changed_callback(link_changed_callback);
- ethernet_init();
-
-
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- eth_pkt_inspector);
-
- // program tx registers
- setup_tx();
-
- // kick off the state machine
- dbsm_start(&dsp_tx_sm);
-
- while(1){
- buffer_irq_handler(0);
-
- int pending = pic_regs->pending; // poll for under or overrun
-
- if (pending & PIC_UNDERRUN_INT){
- dbsm_handle_tx_underrun(&dsp_tx_sm);
- pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
- putchar('U');
- }
- }
-}
-
diff --git a/firmware/microblaze/apps/cruft/serdes_txrx.c b/firmware/microblaze/apps/cruft/serdes_txrx.c
deleted file mode 100644
index 2c47c9628..000000000
--- a/firmware/microblaze/apps/cruft/serdes_txrx.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "dbsm.h"
-#include "app_common_v2.h"
-#include "memcpy_wa.h"
-#include "clocks.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
-
-#if (FW_SETS_SEQNO)
-static int fw_seqno; // used when f/w is filling in sequence numbers
-#endif
-
-
-/*
- * Full duplex Tx and Rx between serdes and DSP pipelines
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to serdes flow
- * Buffers 4 and 5 are used to double-buffer the serdes to DSP Tx flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-
-#define DSP_RX_BUF_0 2 // dsp rx -> serdes (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> serdes
-#define DSP_TX_BUF_0 4 // serdes -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // serdes -> dsp tx
-
-/*
- * ==================================================================
- * configure DSP TX double buffering state machine (serdes -> dsp)
- * ==================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4)
-
-// Receive from serdes
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_SERDES,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-/*
- * =================================================================
- * configure DSP RX double buffering state machine (dsp -> serdes)
- * =================================================================
- */
-
-// 4 lines of ethernet hdr + 1 line transport hdr + 1 line (word0)
-// DSP Rx writes timestamp followed by nlines_per_frame of samples
-#define DSP_RX_FIRST_LINE ((sizeof(u2_eth_hdr_t) + sizeof(u2_transport_hdr_t))/4 + 1)
-
-// receive from DSP
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to serdes
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_SERDES,
- 0, // starts with ethernet header in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-// variables for streaming mode
-
-static bool streaming_p = false;
-static unsigned int streaming_items_per_frame = 0;
-static int streaming_frame_count = 0;
-#define FRAMES_PER_CMD 1000
-
-bool is_streaming(void){ return streaming_p; }
-
-// ----------------------------------------------------------------
-
-
-void
-restart_streaming(void)
-{
- // setup RX DSP regs
- dsp_rx_regs->clear_state = 1; // reset
-
- streaming_p = true;
- streaming_frame_count = FRAMES_PER_CMD;
-
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1); // set "chain" bit
-
- // kick off the state machine
- dbsm_start(&dsp_rx_sm);
-
- dsp_rx_regs->rx_time = 0; // enqueue first of two commands
-
- // make sure this one and the rest have the "now" and "chain" bits set.
- dsp_rx_regs->rx_command =
- MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
- streaming_items_per_frame,
- 1, 1);
-
- dsp_rx_regs->rx_time = 0; // enqueue second command
-}
-
-void
-start_rx_streaming_cmd(const eth_mac_addr_t *host, op_start_rx_streaming_t *p)
-{
- host_mac_addr = *host; // remember who we're sending to
-
- /*
- * Construct ethernet header and word0 and preload into two buffers
- */
- u2_eth_packet_t pkt;
- memset(&pkt, 0, sizeof(pkt));
- pkt.ehdr.dst = *host;
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
- u2p_set_word0(&pkt.fixed, 0, 0);
- // DSP RX will fill in timestamp
-
- memcpy_wa(buffer_ram(DSP_RX_BUF_0), &pkt, sizeof(pkt));
- memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt));
-
-
- if (FW_SETS_SEQNO)
- fw_seqno = 0;
-
- streaming_items_per_frame = p->items_per_frame;
- restart_streaming();
-}
-
-
-void
-stop_rx_cmd(void)
-{
- streaming_p = false;
- dsp_rx_regs->clear_state = 1; // flush cmd queue
- bp_clear_buf(DSP_RX_BUF_0);
- bp_clear_buf(DSP_RX_BUF_1);
-}
-
-
-static void
-setup_tx()
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
- int tx_scale = 256;
- int interp = 32;
-
- // setup some defaults
-
- dsp_tx_regs->freq = 0;
- dsp_tx_regs->scale_iq = (tx_scale << 16) | tx_scale;
- dsp_tx_regs->interp_rate = interp;
-}
-
-
-#if (FW_SETS_SEQNO)
-/*
- * Debugging ONLY. This will be handled by the tx_protocol_engine.
- *
- * This is called when the DSP Rx chain has filled in a packet.
- * We set and increment the seqno, then return false, indicating
- * that we didn't handle the packet. A bit of a kludge
- * but it should work.
- */
-bool
-fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false
-{
- uint32_t *p = buffer_ram(buf_this);
- uint32_t seqno = fw_seqno++;
-
- // KLUDGE all kinds of nasty magic numbers and embedded knowledge
- uint32_t t = p[4];
- t = (t & 0xffff00ff) | ((seqno & 0xff) << 8);
- p[4] = t;
-
- // queue up another rx command when required
- if (streaming_p && --streaming_frame_count == 0){
- streaming_frame_count = FRAMES_PER_CMD;
- dsp_rx_regs->rx_time = 0;
- }
-
- return false; // we didn't handle the packet
-}
-#endif
-
-
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- // hal_toggle_leds(LED_A);
-
- uint32_t status = buffer_pool_status->status;
-
- if (0 && (status & ~BPS_IDLE_ALL)){
- putstr("status = ");
- puthex32_nl(status);
- }
-
- dbsm_process_status(&dsp_tx_sm, status);
- dbsm_process_status(&dsp_rx_sm, status);
-}
-
-int
-main(void)
-{
- u2_init();
-
- output_regs->led_src = 0x3; // h/w controls bottom two bits
- clocks_enable_test_clk(true, 1);
-
- putstr("\nSERDES TxRx\n");
-
- cpu_tx_buf_dest_port = PORT_SERDES;
-
- // ethernet_register_link_changed_callback(link_changed_callback);
- // ethernet_init();
-
- clocks_mimo_config(MC_WE_LOCK_TO_MIMO);
-
- // puts("post clocks_mimo_config");
-
-#if 0
- // make bit 15 of Tx gpio's be a s/w output
- hal_gpio_set_sel(GPIO_TX_BANK, 15, 's');
- hal_gpio_set_ddr(GPIO_TX_BANK, 0x8000, 0x8000);
-#endif
-
-#if 0
- output_regs->debug_mux_ctrl = 1;
- hal_gpio_set_sels(GPIO_TX_BANK, "0000000000000000");
- hal_gpio_set_sels(GPIO_RX_BANK, "0000000000000000");
- hal_gpio_set_ddr(GPIO_TX_BANK, 0xffff, 0xffff);
- hal_gpio_set_ddr(GPIO_RX_BANK, 0xffff, 0xffff);
-#endif
-
-
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- eth_pkt_inspector);
-
-
- //output_regs->flush_icache = 1;
-
- // initialize double buffering state machine for DSP RX -> Ethernet
-
- if (FW_SETS_SEQNO){
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- fw_sets_seqno_inspector);
- }
- else {
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_nop_inspector);
- }
-
- // puts("post dbsm_init's");
-
- // tell app_common that this dbsm could be sending to the ethernet
- ac_could_be_sending_to_eth = &dsp_rx_sm;
-
-
- // program tx registers
- setup_tx();
-
- // puts("post setup_tx");
-
- // kick off the state machine
- dbsm_start(&dsp_tx_sm);
-
- // puts("post dbsm_start");
-
- //int which = 0;
-
- while(1){
- // hal_gpio_write(GPIO_TX_BANK, which, 0x8000);
- // which ^= 0x8000;
-
- buffer_irq_handler(0);
-
- int pending = pic_regs->pending; // poll for under or overrun
-
- if (pending & PIC_UNDERRUN_INT){
- dbsm_handle_tx_underrun(&dsp_tx_sm);
- pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
- putchar('U');
- }
-
- if (pending & PIC_OVERRUN_INT){
- dbsm_handle_rx_overrun(&dsp_rx_sm);
- pic_regs->pending = PIC_OVERRUN_INT; // clear pending interrupt
-
- // FIXME Figure out how to handle this robustly.
- // Any buffers that are emptying should be allowed to drain...
-
- if (streaming_p){
- // restart_streaming();
- // FIXME report error
- }
- else {
- // FIXME report error
- }
- putchar('O');
- }
- }
-}
diff --git a/firmware/microblaze/apps/cruft/set_hw_rev.c b/firmware/microblaze/apps/cruft/set_hw_rev.c
deleted file mode 100644
index d4ac8ff81..000000000
--- a/firmware/microblaze/apps/cruft/set_hw_rev.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-#include <u2_init.h>
-#include <nonstdio.h>
-#include <i2c.h>
-#include <usrp2_i2c_addr.h>
-
-#define HW_REV_MAJOR 0
-#define HW_REV_MINOR 3
-
-int
-main(void)
-{
- u2_init();
-
- putstr("\nset_hw_rev\n");
-
- bool ok = true;
- unsigned char maj = HW_REV_MAJOR;
- unsigned char min = HW_REV_MINOR;
- ok = eeprom_write(I2C_ADDR_MBOARD, MBOARD_REV_MSB, &maj, 1);
- ok &= eeprom_write(I2C_ADDR_MBOARD, MBOARD_REV_LSB, &min, 1);
-
- if (ok)
- printf("OK: set h/w rev to %d.%d\n", HW_REV_MAJOR, HW_REV_MINOR);
- else
- printf("FAILED to set h/w rev to %d.%d\n", HW_REV_MAJOR, HW_REV_MINOR);
-
- return 0;
-}
diff --git a/firmware/microblaze/apps/cruft/test1.c b/firmware/microblaze/apps/cruft/test1.c
deleted file mode 100644
index c3cc3be56..000000000
--- a/firmware/microblaze/apps/cruft/test1.c
+++ /dev/null
@@ -1,282 +0,0 @@
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include "nonstdio.h"
-
-// Globals
-#define EMPTY 0
-#define FILLING 1
-#define FULL 2
-#define EMPTYING 3
-
-#define PORT 2 // ethernet = 2, serdes = 0
-int dsp_rx_buf, dsp_tx_buf, serdes_rx_buf, serdes_tx_buf;
-int dsp_rx_idle, dsp_tx_idle, serdes_rx_idle, serdes_tx_idle;
-
-int buffer_state[4];
-
-
-void double_buffering(int port);
-
-//
-// We register this in the secondary interrupt vector.
-// It's called on buffer manager interrupts
-//
-void
-buffer_irq_handler(unsigned irq)
-{
- double_buffering(PORT);
-}
-
-int
-main(void)
-{
- int i;
-
- u2_init();
-
- // Control LEDs
- output_regs->leds = 0x02;
-
- // Turn on ADCs
- output_regs->adc_ctrl = 0x0A;
-
- // Set up TX Chain
- dsp_tx_regs->freq = 0;
- dsp_tx_regs->scale_iq = (1 << 16) | 1;
- dsp_tx_regs->interp_rate = 8;
-
- // Set up RX Chain
- dsp_rx_regs->freq = 0;
- dsp_rx_regs->scale_iq = (1 << 16) | 1;
- dsp_rx_regs->decim_rate = 8;
-
- // Set up buffer control, using only 4 for now
- for(i=0;i<4;i++)
- buffer_state[i] = EMPTY;
-
- // Set up DSP RX
- buffer_state[0] = FILLING;
- serdes_tx_idle = 1;
- bp_receive_to_buf(0, 1, 1, 10, 509); // DSP_RX to buffer 0, use 500 lines
-
- //dsp_rx_regs->run_rx = 1; // Start DSP_RX
- putstr("Done DSP RX setup\n");
-
- // Set up serdes RX
- buffer_state[2] = FILLING;
- dsp_tx_idle = 1;
- bp_receive_to_buf(2, PORT, 1, 5, 504);
-
- while (buffer_pool_status->status == 0) // wait for completion of DSP RX
- ;
-
- putstr("Done DSP TX setup\n");
- //dsp_tx_regs->run_tx = 1;
-
- // register interrupt handler
- pic_register_handler(IRQ_BUFFER, buffer_irq_handler);
-
- while (1)
- ;
-
- hal_finish();
- return 1;
-}
-
-void
-double_buffering(int port) {
- unsigned int localstatus = buffer_pool_status->status;
-
- if(localstatus & BPS_DONE_0) {
- bp_clear_buf(0);
- if(buffer_state[0] == FILLING) {
- buffer_state[0] = FULL;
- if(buffer_state[1] == EMPTY) {
- bp_receive_to_buf(1, 1, 1, 10, 509); // DSP_RX to buffer 1, use 500 lines
- buffer_state[1] = FILLING;
- }
- else
- dsp_rx_idle = 1;
- if(serdes_tx_idle) {
- serdes_tx_idle = 0;
- bp_send_from_buf(0, port, 1, 10, 509); // SERDES_TX from buffer 0
- buffer_state[0] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[0] = EMPTY;
- if(dsp_rx_idle) {
- dsp_rx_idle = 0;
- bp_receive_to_buf(0, 1, 1, 10, 509); // DSP_RX to buffer 0, use 500 lines
- buffer_state[0] = FILLING;
- }
- if(buffer_state[1] == FULL) {
- bp_send_from_buf(1, port, 1, 10, 509); // SERDES_TX from buffer 1
- buffer_state[1] = EMPTYING;
- }
- else
- serdes_tx_idle = 1;
- }
- putstr("Int Proc'ed 0\n");
- }
- if(localstatus & BPS_DONE_1) {
- bp_clear_buf(1);
- if(buffer_state[1] == FILLING) {
- buffer_state[1] = FULL;
- if(buffer_state[0] == EMPTY) {
- bp_receive_to_buf(0, 1, 1, 10, 509); // DSP_RX to buffer 1, use 500 lines
- buffer_state[0] = FILLING;
- }
- else
- dsp_rx_idle = 1;
- if(serdes_tx_idle) {
- serdes_tx_idle = 0;
- bp_send_from_buf(1, port, 1, 10, 509); // SERDES_TX from buffer 1
- buffer_state[1] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[1] = EMPTY;
- if(dsp_rx_idle) {
- dsp_rx_idle = 0;
- bp_receive_to_buf(1, 1, 1, 10, 509); // DSP_RX to buffer 1, use 500 lines
- buffer_state[1] = FILLING;
- }
- if(buffer_state[0] == FULL) {
- bp_send_from_buf(0, port, 1, 10, 509); // SERDES_TX from buffer 0
- buffer_state[0] = EMPTYING;
- }
- else
- serdes_tx_idle = 1;
- }
- putstr("Int Proc'ed 1\n");
- }
- if(localstatus & BPS_DONE_2) {
- bp_clear_buf(2);
- if(buffer_state[2] == FILLING) {
- buffer_state[2] = FULL;
- if(buffer_state[3] == EMPTY) {
- bp_receive_to_buf(3, port, 1, 5, 504); // SERDES_RX to buffer 3, use 500 lines
- buffer_state[3] = FILLING;
- }
- else
- serdes_rx_idle = 1;
- if(dsp_tx_idle) {
- dsp_tx_idle = 0;
- bp_send_from_buf(2, 1, 1, 5, 504); // DSP_TX from buffer 2
- buffer_state[2] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[2] = EMPTY;
- if(serdes_rx_idle) {
- serdes_rx_idle = 0;
- bp_receive_to_buf(2, port, 1, 5, 504); // SERDES_RX to buffer 2
- buffer_state[2] = FILLING;
- }
- if(buffer_state[3] == FULL) {
- bp_send_from_buf(3, 1, 1, 5, 504); // DSP_TX from buffer 3
- buffer_state[3] = EMPTYING;
- }
- else
- dsp_tx_idle = 1;
- }
- putstr("Int Proc'ed 2\n");
- }
- if(localstatus & BPS_DONE_3) {
- bp_clear_buf(3);
- if(buffer_state[3] == FILLING) {
- buffer_state[3] = FULL;
- if(buffer_state[2] == EMPTY) {
- bp_receive_to_buf(2, port, 1, 5, 504); // SERDES_RX to buffer 2, use 500 lines
- buffer_state[2] = FILLING;
- }
- else
- serdes_rx_idle = 1;
- if(dsp_tx_idle) {
- dsp_tx_idle = 0;
- bp_send_from_buf(3, 1, 1, 5, 504); // DSP_TX from buffer 3
- buffer_state[3] = EMPTYING;
- }
- }
- else { // buffer was emptying
- buffer_state[3] = EMPTY;
- if(serdes_rx_idle) {
- serdes_rx_idle = 0;
- bp_receive_to_buf(3, port, 1, 5, 504); // SERDES_RX to buffer 3
- buffer_state[3] = FILLING;
- }
- if(buffer_state[2] == FULL) {
- bp_send_from_buf(2, 1, 1, 5, 504); // DSP_TX from buffer 2
- buffer_state[2] = EMPTYING;
- }
- else
- dsp_tx_idle = 1;
- }
- putstr("Int Proc'ed 3\n");
- }
-}
-
-// Spare Code
-
-#if 0
- // Set up LSDAC
- int i = 0;
- while(1) {
- int command = (3 << 19) | (0 << 16) | (i & 0xffff);
- spi_transact(SPI_TXONLY, SPI_SS_TX_DAC, command, 24, 1); // negate TX phase
- i++;
- }
-#endif
-
-#if 0
- // Write to buffer 0
- int *buf = (int *)(BUFFER_BASE + BUFFER_0);
- puthex_nl((int)buf);
-
- for(i=0;i<BUFFER_SIZE;i++)
- buf[i] = i;
-
- putstr("Filled buffer 0\n");
-
- // Write to buffer 1
- buf = (int *)(BUFFER_BASE + BUFFER_1);
- puthex_nl((int)buf);
- for(i=0;i<BUFFER_SIZE;i++)
- buf[i] = i + ((i^0xFFFF) << 16);
-
- putstr("Filled buffer 1\n");
-
-#endif
-
-#if 0
- // rx SERDES into buffer #2 (buf,port,step,fl,ll)
- bp_receive_to_buf(2, 0, 1, 10, 300);
- putstr("SERDES RX buffer setup\n");
-
- // send SERDES from buffer #0 (buf,port,step,fl,ll)
- bp_send_from_buf(0, 0, 1, 20, 200);
- putstr("SERDES TX buffer setup\n");
-
-#endif
-
-#if 0
- // send to DACs from buffer #1
- bp_send_from_buf(1 /*buf#*/, 1 /*port*/, 1 /*step*/, 20 /*fl*/, 250 /*ll*/);
- putstr("DAC Buffer setup\n");
-#endif
-
-#if 0
- //putstr("ENTER INT\n");
- for(i=0;i<8;i++)
- if(*status & (1<<i)) {
- //putstr("Clearing buf ");
- puthex_nl(i);
- bp_clear_buf(i);
- }
- //putstr("EXIT INT\n");
-#endif
diff --git a/firmware/microblaze/apps/cruft/test_db_spi.c b/firmware/microblaze/apps/cruft/test_db_spi.c
deleted file mode 100644
index f4fa98ef1..000000000
--- a/firmware/microblaze/apps/cruft/test_db_spi.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include <u2_init.h>
-#include <nonstdio.h>
-#include <hal_io.h>
-#include <spi.h>
-
-int
-main(void)
-{
- u2_init();
-
- puts("\ntest_db_spi");
-
- while(1){
- spi_transact(SPI_TXONLY, SPI_SS_RX_DB, 0xCC33, 16, SPIF_PUSH_FALL);
- spi_transact(SPI_TXONLY, SPI_SS_TX_DB, 0x33CC, 16, SPIF_PUSH_FALL);
- }
-}
diff --git a/firmware/microblaze/apps/cruft/test_i2c.c b/firmware/microblaze/apps/cruft/test_i2c.c
deleted file mode 100644
index f349ead88..000000000
--- a/firmware/microblaze/apps/cruft/test_i2c.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <u2_init.h> /* FIXME */
-#include <i2c.h>
-#include <usrp2_i2c_addr.h>
-#include <string.h>
-#include <hal_io.h>
-
-
-
-#define ASSERT_TRUE(x) \
- do { \
- if (!(x)){ \
- printf("ASSERT_TRUE failed on line %d\n", __LINE__); \
- nerrors++; \
- } \
- } while(0)
-
-#define ASSERT_FALSE(x) \
- do { \
- if (x){ \
- printf("ASSERT_FALSE failed on line %d\n", __LINE__); \
- nerrors++; \
- } \
- } while(0)
-
-
-#define BUFSIZE 128
-
-int
-main(void)
-{
- int i;
- bool ok;
- int nerrors = 0;
- uint8_t buf[BUFSIZE];
- int not_dev_addr = 0x35; // no device with this address on the i2c bus.
- int offset;
- int len;
-
- u2_init();
-
- puts("test_i2c\n");
-
- // try writing a non-existent device
- buf[0] = 0xA5;
- ok = i2c_write(not_dev_addr, buf, 1);
- ASSERT_FALSE(ok);
-
- // try read from non-existent device
- buf[0] = 0;
- ok = i2c_read(not_dev_addr, buf, 1);
- ASSERT_FALSE(ok);
-
- // try writing eeprom
- offset = 31;
- len = 8;
- memset(buf, 0, sizeof(buf));
- for (i = 0; i < len; i++)
- buf[i] = i;
- ok = eeprom_write(I2C_ADDR_MBOARD, offset, buf, len);
- ASSERT_TRUE(ok);
-
- // now try to read it back
- offset = 31;
- len = 8;
- memset(buf, 0, sizeof(buf));
- ok = eeprom_read(I2C_ADDR_MBOARD, offset, buf, len);
- ASSERT_TRUE(ok);
-
- // check result
- for (i = 0; i < len; i++){
- if (buf[i] != i){
- printf("buf[%d] = %d, should be %d\n", i, buf[i], i);
- nerrors++;
- }
- }
-
- if (nerrors == 0){
- output_regs->leds = 0x3;
- puts("PASSED\n");
- }
- else {
- output_regs->leds = 0x0;
- puts("FAILED\n");
- }
-
- hal_finish();
- return 0;
-}
-
diff --git a/firmware/microblaze/apps/cruft/test_lsadc.c b/firmware/microblaze/apps/cruft/test_lsadc.c
deleted file mode 100644
index 5fda29cd7..000000000
--- a/firmware/microblaze/apps/cruft/test_lsadc.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include <lsadc.h>
-#include <lsdac.h>
-#include <u2_init.h>
-#include <nonstdio.h>
-#include <hal_io.h>
-
-int
-main(void)
-{
- u2_init();
-
- puts("\ntest_lsadc");
-
- uint32_t r;
-
- unsigned int up_counter = 0;
-
- while (1){
- unsigned int v;
- v = up_counter;
-
- lsdac_write_rx(0, v << 0);
- lsdac_write_rx(2, v << 1);
-
-#if 1
- r = lsadc_read_rx(0);
- lsdac_write_rx(1, r & 0x0fff);
- //puthex32_nl(r);
-#endif
-
-#if 1
- r = lsadc_read_rx(1);
- lsdac_write_rx(3, r & 0x0fff);
- //puthex32_nl(r);
-#endif
-
- up_counter++;
- }
-}
diff --git a/firmware/microblaze/apps/cruft/test_lsdac.c b/firmware/microblaze/apps/cruft/test_lsdac.c
deleted file mode 100644
index 8c1bf333b..000000000
--- a/firmware/microblaze/apps/cruft/test_lsdac.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include <lsdac.h>
-#include <u2_init.h>
-#include <nonstdio.h>
-#include <hal_io.h>
-
-int
-main(void)
-{
- u2_init();
-
- puts("\ntest_lsdac");
-
- unsigned int up_counter = 0;
- unsigned int dn_counter = 0;
-
- while(1){
- unsigned int v;
- v = up_counter;
- lsdac_write_rx(0, v << 0);
- lsdac_write_rx(1, v << 1);
- lsdac_write_rx(2, v << 2);
- lsdac_write_rx(3, v << 3);
-
- v = up_counter;
- lsdac_write_tx(0, v << 0);
- lsdac_write_tx(1, v << 1);
- lsdac_write_tx(2, v << 2);
- lsdac_write_tx(3, v << 3);
-
- up_counter++;
- dn_counter--;
- }
-}
diff --git a/firmware/microblaze/apps/cruft/test_phy_comm.c b/firmware/microblaze/apps/cruft/test_phy_comm.c
deleted file mode 100644
index d312ca4cc..000000000
--- a/firmware/microblaze/apps/cruft/test_phy_comm.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-// check communication with ethernet PHY chip
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "hal_io.h"
-#include "ethernet.h"
-#include "pic.h"
-#include "nonstdio.h"
-
-
-#define DELTA_T 12500000 // .125s (10ns per tick)
-//#define DELTA_T 10000
-
-// debugging output on tx pins
-#define LS_MASK 0xE0000
-#define LS_1000 0x80000
-#define LS_100 0x40000
-#define LS_10 0x20000
-
-
-
-#define U2_ETHERTYPE 0xBEEF
-
-
-static volatile int led_link_up_flag = 0;
-
-/*
- * Called when eth phy state changes (w/ interrupts disabled)
- */
-void
-link_changed_callback(int speed)
-{
- int v = 0;
- switch(speed){
- case 10:
- v = LS_10;
- led_link_up_flag = 0x2;
- break;
-
- case 100:
- v = LS_100;
- led_link_up_flag = 0x2;
- break;
-
- case 1000:
- v = LS_100;
- led_link_up_flag = 0x2;
- break;
-
- default:
- v = 0;
- led_link_up_flag = 0;
- break;
- }
-
- //hal_gpio_set_tx(v, LS_MASK); /* set debug bits on d'board */
-
- putstr("\neth link changed: speed = ");
- puthex_nl(speed);
-}
-
-void
-timer_handler(unsigned irq)
-{
- static int led_counter = 0;
-
- hal_set_timeout(DELTA_T); // schedule next timeout
- output_regs->leds = (led_counter++ & 0x1) | led_link_up_flag;
-}
-
-int
-main(void)
-{
- u2_init();
-
- putstr("\n test_phy_comm\n");
-
- pic_register_handler(IRQ_ONETIME, timer_handler);
- hal_set_timeout(DELTA_T); // schedule timeout
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
-
- ethernet_register_link_changed_callback(link_changed_callback);
-
- output_regs->phy_ctrl = 1; /* reset the eth PHY */
- output_regs->phy_ctrl = 0;
-
- ethernet_init();
-
- while(1)
- ;
-
- return 0;
-}
diff --git a/firmware/microblaze/apps/cruft/test_ram.c b/firmware/microblaze/apps/cruft/test_ram.c
deleted file mode 100644
index 77ee693f6..000000000
--- a/firmware/microblaze/apps/cruft/test_ram.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <u2_init.h> /* FIXME */
-#include <sd.h>
-#include <string.h>
-#include <hal_io.h>
-#include <nonstdio.h>
-#include <hal_uart.h>
-
-#define ASSERT_TRUE(x) \
- do { \
- if (!(x)){ \
- printf("ASSERT_TRUE failed on line %d\n", __LINE__); \
- nerrors++; \
- } \
- } while(0)
-
-#define ASSERT_FALSE(x) \
- do { \
- if (x){ \
- printf("ASSERT_FALSE failed on line %d\n", __LINE__); \
- nerrors++; \
- } \
- } while(0)
-
-
-#define BUFSIZE 128
-
-int test_ram()
-{
- int i,j,k;
- output_regs->ram_page = 1<<10;
-
- extram[0] = 0xDEADBEEF;
- extram[1] = 0xF00D1234;
- extram[7] = 0x76543210;
-
- output_regs->ram_page = 2<<10;
- extram[7] = 0x55555555;
- extram[1] = 0xaaaaaaaa;
- extram[0] = 0xeeeeeeee;
-
- output_regs->ram_page = 1<<10;
-
- i = extram[0];
- k = extram[1];
- j = extram[7];
-
- if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) {
- puts("RAM FAIL1!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
-
- output_regs->ram_page = 2<<10;
-
- j = extram[7];
- k = extram[1];
- i = extram[0];
-
- if((i != 0xeeeeeeee)||(j!=0x55555555)||(k!=0xaaaaaaaa)) {
- puts("RAM FAIL2!\n");
- puthex32_nl(i);
- puthex32_nl(j);
- puthex32_nl(k);
- return 0;
- }
- return 1;
-}
-
-int
-main(void)
-{
-
- u2_init();
- puts("\ntest_ram\n");
- int success = test_ram();
- if(success)
- puts("RAM Passed Tests\n");
- else
- puts("RAM Failed\n");
-
- hal_finish();
- return 0;
-}
-
diff --git a/firmware/microblaze/apps/cruft/test_sd.c b/firmware/microblaze/apps/cruft/test_sd.c
deleted file mode 100644
index 494432d7f..000000000
--- a/firmware/microblaze/apps/cruft/test_sd.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <u2_init.h> /* FIXME */
-#include <sd.h>
-#include <string.h>
-#include <hal_io.h>
-#include <nonstdio.h>
-
-
-#define ASSERT_TRUE(x) \
- do { \
- if (!(x)){ \
- printf("ASSERT_TRUE failed on line %d\n", __LINE__); \
- nerrors++; \
- } \
- } while(0)
-
-#define ASSERT_FALSE(x) \
- do { \
- if (x){ \
- printf("ASSERT_FALSE failed on line %d\n", __LINE__); \
- nerrors++; \
- } \
- } while(0)
-
-
-#define BUFSIZE 128
-
-int
-main(void)
-{
- int i;
- unsigned char buf[512];
-
- u2_init();
-
- puts("\ntest_sd\n");
-
-
- i = sd_init();
- if(i)
- puts("Successfully Init'ed Card\n");
- else
- puts("FAILED INIT of Card\n");
-
- i = sd_read_block(2048,buf);
- if(i) {
- puts("READ Command accepted\n");
- for(i=0;i<512;i++)
- if((i&15) == 15)
- puthex8_nl(buf[i]);
- else {
- puthex8(buf[i]);
- putchar(' ');
- }
- }
- else
- puts("READ Command Rejected\n");
-
- puts("Done");
- hal_finish();
- return 0;
-}
-
diff --git a/firmware/microblaze/apps/cruft/timer_test.c b/firmware/microblaze/apps/cruft/timer_test.c
deleted file mode 100644
index 44e80b5f1..000000000
--- a/firmware/microblaze/apps/cruft/timer_test.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include "nonstdio.h"
-#include "hal_io.h"
-
-#define DELTA_T 500 // 5 us (10ns per tick)
-
-
-void
-timer_handler(unsigned irq)
-{
- hal_set_timeout(DELTA_T);
-
- putstr("Tick: ");
- puthex_nl(0);
-}
-
-int
-main(void)
-{
- u2_init();
-
- // setup timer
-
- putstr("Setting up timer\n");
- pic_register_handler(IRQ_ONETIME, timer_handler);
-
- hal_set_timeout(DELTA_T);
-
- while (1)
- ;
-
- putstr("Done Testing\n");
-
- hal_finish();
- return 1;
-}
diff --git a/firmware/microblaze/apps/cruft/tx_standalone.c b/firmware/microblaze/apps/cruft/tx_standalone.c
deleted file mode 100644
index 1645fa8ba..000000000
--- a/firmware/microblaze/apps/cruft/tx_standalone.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
-#include "memory_map.h"
-#include "spi.h"
-#include "hal_io.h"
-#include "buffer_pool.h"
-#include "pic.h"
-#include <stdbool.h>
-#include "ethernet.h"
-#include "nonstdio.h"
-#include "usrp2_eth_packet.h"
-#include "memcpy_wa.h"
-#include "dbsm.h"
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define _AL4 __attribute__((aligned (4)))
-
-#define USE_BUFFER_INTERRUPT 0 // 0 or 1
-
-
-static int timer_delta = MASTER_CLK_RATE/1000; // tick at 1kHz
-
-/*
- * This program can respond to queries from the host
- * and stream rx samples.
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-#define CPU_TX_BUF 1 // cpu -> eth
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-
-/*
- * ================================================================
- * configure DSP RX double buffering state machine
- * ================================================================
- */
-
-
-// 4 lines of ethernet hdr + 1 line (word0)
-// DSP Rx writes timestamp followed by nlines_per_frame of samples
-#define DSP_RX_FIRST_LINE 5
-#define DSP_RX_SAMPLES_PER_FRAME 128
-#define DSP_RX_EXTRA_LINES 1 // writes timestamp
-
-// Receive from DSP Rx
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to ethernet
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_ETH,
- 0, // starts with ethernet header in line 0
- 0, // filled in from last_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-/*
- * ================================================================
- * configure DSP TX double buffering state machine
- * ================================================================
- */
-
-// 4 lines of ethernet hdr + 2 lines (word0 + timestamp)
-// DSP Tx reads word0 (flags) + timestamp followed by samples
-
-#define DSP_TX_FIRST_LINE 4
-#define DSP_TX_SAMPLES_PER_FRAME 250 // not used except w/ debugging
-#define DSP_TX_EXTRA_LINES 2 // reads word0 + timestamp
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past ethernet header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-/*
- * send constant buffer to DSP TX
- */
-static inline void
-SEND_CONST_TO_DSP_TX(void)
-{
- bp_send_from_buf(DSP_TX_BUF_0, PORT_DSP, 1,
- DSP_TX_FIRST_LINE,
- DSP_TX_FIRST_LINE + DSP_TX_EXTRA_LINES + DSP_TX_SAMPLES_PER_FRAME - 1);
-}
-
-// ----------------------------------------------------------------
-
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
-
-void link_changed_callback(int speed);
-static volatile bool link_is_up = false; // eth handler sets this
-
-
-void
-timer_irq_handler(unsigned irq)
-{
- hal_set_timeout(timer_delta); // schedule next timeout
-}
-
-// Tx DSP underrun
-void
-underrun_irq_handler(unsigned irq)
-{
- dsp_tx_regs->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
- dbsm_stop(&dsp_tx_sm);
-
- // FIXME anything else?
-
- putstr("\nirq: underrun\n");
-}
-
-// Rx DSP overrun
-void
-overrun_irq_handler(unsigned irq)
-{
- dsp_rx_regs->clear_state = 1;
- bp_clear_buf(DSP_RX_BUF_0);
- bp_clear_buf(DSP_RX_BUF_1);
- dbsm_stop(&dsp_rx_sm);
-
- // FIXME anything else?
-
- putstr("\nirq: overrun\n");
-}
-
-static void
-start_tx_transfers(void)
-{
- bp_clear_buf(DSP_TX_BUF_0); // FIXME, really goes in state machine
- bp_clear_buf(DSP_TX_BUF_1);
-
- // fill everything with a constant 32k + 0j
-
- uint32_t const_sample = (32000 << 16) | 0;
- int i;
- for (i = 0; i < BP_NLINES; i++){
- buffer_ram(DSP_TX_BUF_0)[i] = const_sample;
- buffer_ram(DSP_TX_BUF_1)[i] = const_sample;
- }
-
- /*
- * Construct ethernet header and word0 and preload into two buffers
- */
- u2_eth_packet_t pkt;
- memset(&pkt, 0, sizeof(pkt));
- //pkt.ehdr.dst = *host;
- pkt.ehdr.src = *ethernet_mac_addr();
- pkt.ehdr.ethertype = U2_ETHERTYPE;
- u2p_set_word0(&pkt.fixed,
- U2P_TX_IMMEDIATE | U2P_TX_START_OF_BURST, 0);
- u2p_set_timestamp(&pkt.fixed, T_NOW);
-
- memcpy_wa(buffer_ram(DSP_TX_BUF_0), &pkt, sizeof(pkt));
- memcpy_wa(buffer_ram(DSP_TX_BUF_1), &pkt, sizeof(pkt));
-
-
- int tx_scale = 256;
-
- // setup Tx DSP regs
- dsp_tx_regs->clear_state = 1; // reset
- dsp_tx_regs->freq = 408021893; // 9.5 MHz [2**32 * fc/fsample]
- dsp_tx_regs->scale_iq = (tx_scale << 16) | tx_scale;
- dsp_tx_regs->interp_rate = 32;
-
- // kick off the state machine
- // dbsm_start(&dsp_rx_sm);
-
- SEND_CONST_TO_DSP_TX(); // send constant buffer to DSP TX
-}
-
-
-void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- if (0){
- putstr("irq: ");
- puthex32(status);
- putchar('\n');
- }
-
- if (status & BPS_ERROR_ALL){
- // FIXME rare path, handle error conditions
- }
-
- if (status & BPS_DONE(DSP_TX_BUF_0)){
- bp_clear_buf(DSP_TX_BUF_0);
- SEND_CONST_TO_DSP_TX();
- hal_toggle_leds(0x1);
- }
-
-}
-
-int
-main(void)
-{
- u2_init();
-
- // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
- //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
- //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
-
- putstr("\ntx_only\n");
-
- // Control LEDs
- hal_set_leds(0x0, 0x3);
-
- if (USE_BUFFER_INTERRUPT)
- pic_register_handler(IRQ_BUFFER, buffer_irq_handler);
-
- pic_register_handler(IRQ_OVERRUN, overrun_irq_handler);
- pic_register_handler(IRQ_UNDERRUN, underrun_irq_handler);
-
- //pic_register_handler(IRQ_TIMER, timer_irq_handler);
- //hal_set_timeout(timer_delta);
-
- ethernet_register_link_changed_callback(link_changed_callback);
-
- ethernet_init();
-
- // initialize double buffering state machine for DSP RX -> Ethernet
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_nop_inspector);
-
- // setup receive from ETH
- // bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, BP_LAST_LINE);
-
-#if 0
- if (hwconfig_simulation_p()){
- // If we're simulating, pretend that we got a start command from the host
- eth_mac_addr_t host = {{ 0x00, 0x0A, 0xE4, 0x3E, 0xD2, 0xD5 }};
- start_rx_cmd(&host);
- }
-#endif
-
- start_tx_transfers(); // send constant buffers to DSP TX
-
- while(1){
- if (!USE_BUFFER_INTERRUPT)
- buffer_irq_handler(0);
- }
-}
-
-// ----------------------------------------------------------------
-
-// debugging output on tx pins
-#define LS_MASK 0xE0000
-#define LS_1000 0x80000
-#define LS_100 0x40000
-#define LS_10 0x20000
-
-/*
- * Called when eth phy state changes (w/ interrupts disabled)
- */
-void
-link_changed_callback(int speed)
-{
- int v = 0;
- switch(speed){
- case 10:
- v = LS_10;
- link_is_up = true;
- break;
-
- case 100:
- v = LS_100;
- link_is_up = true;
- break;
-
- case 1000:
- v = LS_100;
- link_is_up = true;
- break;
-
- default:
- v = 0;
- link_is_up = false;
- break;
- }
-
- //hal_gpio_set_tx(v, LS_MASK); /* set debug bits on d'board */
-
- // hal_set_leds(link_is_up ? 0x2 : 0x0, 0x2);
-
- printf("\neth link changed: speed = %d\n", speed);
-}
diff --git a/firmware/microblaze/bootstrap b/firmware/microblaze/bootstrap
deleted file mode 100755
index 26987b0ec..000000000
--- a/firmware/microblaze/bootstrap
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# Copyright 2010 Ettus Research LLC
-#
-# 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/>.
-#
-
-rm -rf *.cache
-rm -rf libusrp2/.deps
-rm -rf libusrp2p/.deps
-
-aclocal
-autoconf
-libtoolize --automake
-automake --add-missing --gnu --warnings=all
diff --git a/firmware/microblaze/configure.ac b/firmware/microblaze/configure.ac
deleted file mode 100644
index f6986f2dd..000000000
--- a/firmware/microblaze/configure.ac
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright 2010 Ettus Research LLC
-#
-# 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/>.
-#
-
-##################################################
-## Setup Autotools
-##################################################
-AC_PREREQ(2.60)
-AC_INIT
-AM_INIT_AUTOMAKE(uhd-mb, 0)
-
-##################################################
-## Setup Compiler
-##################################################
-dnl Fix 2.64 cross compile detection for AVR and RTEMS
-dnl by not trying to compile fopen.
-m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
- [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
- [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])])
-
-AC_PROG_CC([mb-gcc])
-AM_PROG_CC_C_O
-LT_INIT
-
-##################################################
-## Setup Tools
-##################################################
-AC_PATH_PROG([MB_OBJCOPY], [mb-objcopy])
-AC_PATH_PROG([MB_OBJDUMP], [mb-objdump])
-AC_PATH_PROG([HEXDUMP], [hexdump])
-
-##################################################
-## Create Files
-##################################################
-AC_CONFIG_FILES([ \
- Makefile \
- usrp2p/bootloader/Makefile \
- usrp2/Makefile \
- usrp2p/Makefile \
-])
-AC_OUTPUT
diff --git a/firmware/microblaze/lib/Makefile.inc b/firmware/microblaze/lib/Makefile.inc
deleted file mode 100644
index 38c630df4..000000000
--- a/firmware/microblaze/lib/Makefile.inc
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Copyright 2010 Ettus Research LLC
-#
-# Copyright 2007 Free Software Foundation, Inc.
-#
-# 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/>.
-#
-
-COMMON_SRCS = \
- $(top_srcdir)/lib/u2_init.c \
- $(top_srcdir)/lib/abort.c \
- $(top_srcdir)/lib/ad9510.c \
- $(top_srcdir)/lib/bsm12.c \
- $(top_srcdir)/lib/buffer_pool.c \
- $(top_srcdir)/lib/clocks.c \
- $(top_srcdir)/lib/dbsm.c \
- $(top_srcdir)/lib/eeprom.c \
- $(top_srcdir)/lib/eth_addrs.c \
- $(top_srcdir)/lib/eth_mac.c \
- $(top_srcdir)/lib/_exit.c \
- $(top_srcdir)/lib/exit.c \
- $(top_srcdir)/lib/hal_io.c \
- $(top_srcdir)/lib/hal_uart.c \
- $(top_srcdir)/lib/i2c.c \
- $(top_srcdir)/lib/i2c_async.c \
- $(top_srcdir)/lib/mdelay.c \
- $(top_srcdir)/lib/memcpy_wa.c \
- $(top_srcdir)/lib/memset_wa.c \
- $(top_srcdir)/lib/nonstdio.c \
- $(top_srcdir)/lib/pic.c \
- $(top_srcdir)/lib/print_mac_addr.c \
- $(top_srcdir)/lib/print_rmon_regs.c \
- $(top_srcdir)/lib/print_buffer.c \
- $(top_srcdir)/lib/printf.c \
- $(top_srcdir)/lib/ihex.c \
- $(top_srcdir)/lib/spi.c \
- $(top_srcdir)/lib/net_common.c \
- $(top_srcdir)/lib/arp_cache.c \
- $(top_srcdir)/lib/banal.c
diff --git a/firmware/microblaze/lib/bootconfig.c b/firmware/microblaze/lib/bootconfig.c
deleted file mode 100644
index 93adc05c2..000000000
--- a/firmware/microblaze/lib/bootconfig.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2009 Ettus Research LLC
- *
- * 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/>.
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "bootconfig.h"
-#include "bootconfig_private.h"
-#include <stdint.h>
-#include <stddef.h>
-#include <i2c.h>
-#include <quadradio/i2c_addr.h>
-#include <mdelay.h>
-#include <xilinx_v5_icap.h>
-#include <nonstdio.h>
-
-eeprom_boot_info_t eeprom_shadow;
-
-static eeprom_boot_info_t eeprom_default = {
- .magic = EEPROM_BOOT_INFO_MAGIC,
- .nattempts = 1,
- .next_boot.fpga_image_number = 0,
- .next_boot.firmware_image_number = 0,
- .default_boot.fpga_image_number = 0,
- .default_boot.firmware_image_number = 0
-};
-
-eeprom_boot_info_t *
-_bc_get_eeprom_shadow(void)
-{
- return &eeprom_shadow;
-}
-
-
-bool
-_bc_write_eeprom_shadow(void)
-{
- return eeprom_write(I2C_ADDR_MBOARD, BOOT_INFO_OFFSET, &eeprom_shadow, sizeof(eeprom_shadow));
-}
-
-void
-bootconfig_init(void)
-{
- if (!eeprom_read(I2C_ADDR_MBOARD, BOOT_INFO_OFFSET, &eeprom_shadow, sizeof(eeprom_shadow))
- || eeprom_shadow.magic != EEPROM_BOOT_INFO_MAGIC){
- eeprom_shadow = eeprom_default;
- _bc_write_eeprom_shadow();
- }
-}
-
-bootconfig_t
-bootconfig_get_default(void)
-{
- return eeprom_shadow.default_boot;
-}
-
-bool
-bootconfig_set_default(bootconfig_t bc)
-{
- if (!validate_bootconfig(bc))
- return false;
-
- eeprom_shadow.default_boot = bc;
- eeprom_shadow.next_boot = bc;
- return _bc_write_eeprom_shadow();
-}
-
-void
-bootconfig_boot(bootconfig_t bc)
-{
- if (!validate_bootconfig(bc))
- return;
-
- eeprom_shadow.next_boot = bc;
- eeprom_shadow.nattempts = 1;
- _bc_write_eeprom_shadow();
-
- if (1){
- puts("\nbootconfig: chaining to FPGA slot 0 bootloader");
- mdelay(100);
- }
-
- while (1){
- // Reload fpga with code from SPI flash address 0x0.
- icap_reload_fpga(0x00000000);
- }
-}
diff --git a/firmware/microblaze/lib/bsm12.c b/firmware/microblaze/lib/bsm12.c
deleted file mode 100644
index 3f17fe42d..000000000
--- a/firmware/microblaze/lib/bsm12.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-/*
- * buffer state machine: 1 input to two outputs
- *
- * Typically used to read packets from the ethernet and then after inspecting,
- * handle the packet in firmware or pass it on to 1 of the 2 buffer destinations.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "bsm12.h"
-#include "memory_map.h"
-#include "buffer_pool.h"
-#include <stdbool.h>
-#include "nonstdio.h"
-#include <stdlib.h>
-
-typedef enum {
- BS_EMPTY,
- BS_FILLING,
- BS_FULL,
- BS_EMPTYING,
-} buffer_state_t;
-
-static buffer_state_t buffer_state[NBUFFERS];
-static uint32_t last_send_ctrl[NBUFFERS];
-static int8_t buffer_target[NBUFFERS]; // -1, 0 or 1.
-static uint8_t buffer_dst[NBUFFERS]; // 0 or 1. Valid only when BF_EMPTYING
-
-#define ST_IDLE (-1)
-
-void
-bsm12_init(bsm12_t *sm, int buf0,
- const buf_cmd_args_t *recv,
- const buf_cmd_args_t *send0,
- const buf_cmd_args_t *send1,
- bsm12_inspector_t inspect)
-{
- if (buf0 & 0x3) // precondition: buf0 % 4 == 0
- abort();
-
- sm->buf0 = buf0;
- sm->running = false;
- sm->recv_args = *recv;
- sm->send_args[0] = *send0;
- sm->send_args[1] = *send1;
-
- sm->rx_state = ST_IDLE;
- sm->tx_state[0] = ST_IDLE;
- sm->tx_state[1] = ST_IDLE;
-
- sm->inspect = inspect;
-
- sm->bps_error = BPS_ERROR(buf0 + 0) | BPS_ERROR(buf0 + 1) | BPS_ERROR(buf0 + 2);
- sm->bps_done = BPS_DONE(buf0 + 0) | BPS_DONE(buf0 + 1) | BPS_DONE(buf0 + 2);
- sm->bps_error_or_done = sm->bps_error | sm->bps_done;
-
- // How much to adjust the last_line register.
- // It's 1 for everything but the ethernet.
- sm->last_line_adj = recv->port == PORT_ETH ? 3 : 1;
-
- buffer_state[sm->buf0 + 0] = BS_EMPTY;
- buffer_state[sm->buf0 + 1] = BS_EMPTY;
- buffer_state[sm->buf0 + 2] = BS_EMPTY;
-
- buffer_target[sm->buf0 + 0] = -1;
- buffer_target[sm->buf0 + 1] = -1;
- buffer_target[sm->buf0 + 2] = -1;
-
- for (int i = 0; i < NBUFFERS; i++)
- sm->next_buf[i] = buf0;
-
- sm->next_buf[buf0 + 0] = buf0 + 1;
- sm->next_buf[buf0 + 1] = buf0 + 2;
- sm->next_buf[buf0 + 2] = buf0 + 0;
-
- for (int i = 0; i < 3; i++){
- sm->precomputed_receive_to_buf_ctrl_word[i] =
- (BPC_READ
- | BPC_BUFFER(sm->buf0 + i)
- | BPC_PORT(sm->recv_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->recv_args.first_line)
- | BPC_LAST_LINE(sm->recv_args.last_line));
-
- for (int j = 0; j < 2; j++){
- sm->precomputed_send_from_buf_ctrl_word[i][j] =
- (BPC_WRITE
- | BPC_BUFFER(sm->buf0 + i)
- | BPC_PORT(sm->send_args[j].port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->send_args[j].first_line)
- | BPC_LAST_LINE(0)); // last line filled in at runtime
- }
- }
-}
-
-static inline void
-bsm12_receive_to_buf(bsm12_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl = sm->precomputed_receive_to_buf_ctrl_word[bufno & 0x3];
-}
-
-static inline void
-bsm12_send_from_buf(bsm12_t *sm, int bufno, int dst_idx)
-{
- dst_idx &= 0x1;
-
- uint32_t t =
- (sm->precomputed_send_from_buf_ctrl_word[bufno & 0x3][dst_idx]
- | BPC_LAST_LINE(buffer_pool_status->last_line[bufno] - sm->last_line_adj));
-
- buffer_pool_ctrl->ctrl = t;
- last_send_ctrl[bufno] = t;
- buffer_dst[bufno] = dst_idx;
-}
-
-static inline void
-bsm12_resend_from_buf(bsm12_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl = last_send_ctrl[bufno];
-}
-
-void
-bsm12_start(bsm12_t *sm)
-{
- sm->running = true;
-
- buffer_state[sm->buf0 + 0] = BS_EMPTY;
- buffer_state[sm->buf0 + 1] = BS_EMPTY;
- buffer_state[sm->buf0 + 2] = BS_EMPTY;
-
- buffer_target[sm->buf0 + 0] = -1;
- buffer_target[sm->buf0 + 1] = -1;
- buffer_target[sm->buf0 + 2] = -1;
-
- bp_clear_buf(sm->buf0 + 0);
- bp_clear_buf(sm->buf0 + 1);
- bp_clear_buf(sm->buf0 + 2);
-
- sm->rx_state = 0;
- sm->tx_state[0] = ST_IDLE;
- sm->tx_state[1] = ST_IDLE;
- bsm12_receive_to_buf(sm, sm->buf0);
- buffer_state[sm->buf0] = BS_FILLING;
-}
-
-void
-bsm12_stop(bsm12_t *sm)
-{
- sm->running = false;
- bp_clear_buf(sm->buf0 + 0);
- bp_clear_buf(sm->buf0 + 1);
- bp_clear_buf(sm->buf0 + 2);
- buffer_state[sm->buf0 + 0] = BS_EMPTY;
- buffer_state[sm->buf0 + 1] = BS_EMPTY;
- buffer_state[sm->buf0 + 2] = BS_EMPTY;
-}
-
-static void bsm12_process_helper(bsm12_t *sm, int buf_this);
-static void bsm12_error_helper(bsm12_t *sm, int buf_this);
-
-void
-bsm12_process_status(bsm12_t *sm, uint32_t status)
-{
- // anything for us?
- if ((status & sm->bps_error_or_done) == 0 || !sm->running)
- return;
-
- if (status & sm->bps_error){
- // Most likely an ethernet Rx error. We just restart the transfer.
- if (status & (BPS_ERROR(sm->buf0 + 0)))
- bsm12_error_helper(sm, sm->buf0 + 0);
-
- if (status & (BPS_ERROR(sm->buf0 + 1)))
- bsm12_error_helper(sm, sm->buf0 + 1);
-
- if (status & (BPS_ERROR(sm->buf0 + 2)))
- bsm12_error_helper(sm, sm->buf0 + 2);
- }
-
- if (status & BPS_DONE(sm->buf0 + 0))
- bsm12_process_helper(sm, sm->buf0 + 0);
-
- if (status & BPS_DONE(sm->buf0 + 1))
- bsm12_process_helper(sm, sm->buf0 + 1);
-
- if (status & BPS_DONE(sm->buf0 + 2))
- bsm12_process_helper(sm, sm->buf0 + 2);
-}
-
- static void
-bsm12_process_helper(bsm12_t *sm, int buf_this)
-{
- bp_clear_buf(buf_this);
-
- if (buffer_state[buf_this] == BS_FILLING){
-
- buffer_state[buf_this] = BS_FULL;
- buffer_target[buf_this] = -1;
-
- //
- // where does this packet go?
- //
- int dst = sm->inspect(sm, buf_this);
- if (dst == -1){
- //
- // f/w handled the packet; refill the buffer
- //
- bsm12_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- buffer_target[buf_this] = -1;
- sm->rx_state = buf_this & 0x3;
- }
- else { // goes to dst 0 or 1
- //
- // If the next buffer is empty, start a receive on it
- //
- int t = sm->next_buf[buf_this];
- if (buffer_state[t] == BS_EMPTY){
- bsm12_receive_to_buf(sm, t);
- buffer_state[t] = BS_FILLING;
- buffer_target[t] = -1;
- sm->rx_state = t & 0x3;
- }
- else
- sm->rx_state = ST_IDLE;
-
- //
- // If the destination is idle, start the xfer, othewise remember it
- //
- if (sm->tx_state[dst] == ST_IDLE){
- bsm12_send_from_buf(sm, buf_this, dst);
- sm->tx_state[dst] = buf_this & 0x3;
- buffer_state[buf_this] = BS_EMPTYING;
- buffer_target[buf_this] = -1;
- }
- else {
- buffer_target[buf_this] = dst;
- }
- }
- }
-
- else { // BS_EMPTYING
-
- buffer_state[buf_this] = BS_EMPTY;
- buffer_target[buf_this] = -1;
-
- if (sm->rx_state == ST_IDLE){ // fire off another receive
- sm->rx_state = buf_this & 0x3;
- bsm12_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- buffer_target[buf_this] = -1;
- }
-
- int dst = buffer_dst[buf_this]; // the dst we were emptying into
- // is the next buffer full and for us?
- int t = sm->next_buf[buf_this];
- if (buffer_target[t] == dst){ // yes,
- bsm12_send_from_buf(sm, t, dst); // send it
- buffer_state[t] = BS_EMPTYING;
- buffer_target[t] = -1;
- sm->tx_state[dst] = t & 0x3;
- }
- // how about the one after that?
- else if (buffer_target[t=sm->next_buf[t]] == dst){ // yes,
- bsm12_send_from_buf(sm, t, dst); // send it
- buffer_state[t] = BS_EMPTYING;
- buffer_target[t] = -1;
- sm->tx_state[dst] = t & 0x3;
- }
- else {
- sm->tx_state[dst] = ST_IDLE;
- }
- }
-}
-
-static void
-bsm12_error_helper(bsm12_t *sm, int buf_this)
-{
- bp_clear_buf(buf_this); // clears ERROR flag
-
- if (buffer_state[buf_this] == BS_FILLING){
- bsm12_receive_to_buf(sm, buf_this); // restart the xfer
- }
- else { // buffer was emptying
- bsm12_resend_from_buf(sm, buf_this); // restart the xfer
- }
-}
-
-
-void
-bsm12_handle_tx_underrun(bsm12_t *sm)
-{
-}
-
-void
-bsm12_handle_rx_overrun(bsm12_t *sm)
-{
-}
diff --git a/firmware/microblaze/lib/bsm12.h b/firmware/microblaze/lib/bsm12.h
deleted file mode 100644
index b8e576b79..000000000
--- a/firmware/microblaze/lib/bsm12.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifndef INCLUDED_BSM12_H
-#define INCLUDED_BSM12_H
-
-#include "dbsm.h"
-#include "memory_map.h"
-
-/*!
- * buffer state machine: 1 input to two outputs
- *
- * Typically used to read packets from the ethernet and then after inspecting,
- * handle the packet in firmware or pass it on to 1 of the 2 buffer destinations.
- */
-
-struct _bsm12;
-typedef struct _bsm12 bsm12_t;
-
-/*!
- * Pointer to function that does packet inspection.
- *
- * \param sm the state machine
- * \param buf_this the index of the buffer to inspect and/or pass on
- *
- * Returns -1, 0 or 1. If it returns -1, it means that the s/w
- * handled that packet, and that it should NOT be passed on to one of
- * the buffer endpoints. 0 indicates the first endpoint, 1 the second endpoint.
- */
-typedef int (*bsm12_inspector_t)(bsm12_t *sm, int buf_this);
-
-
-/*!
- * buffer state machine: 1 input to two outputs
- */
-struct _bsm12
-{
- uint8_t buf0; // This machine uses buf0, buf0+1 and buf0+2. buf0 % 4 == 0.
- uint8_t running;
- int8_t rx_state; // -1, 0, 1, 2 which buffer we're receiving into
- int8_t tx_state[2]; // -1, 0, 1, 2 which buffer we're sending from
- buf_cmd_args_t recv_args;
- buf_cmd_args_t send_args[2];
- bsm12_inspector_t inspect;
- int last_line_adj;
- uint32_t bps_error;
- uint32_t bps_done;
- uint32_t bps_error_or_done;
- uint8_t next_buf[NBUFFERS];
- uint32_t precomputed_receive_to_buf_ctrl_word[3];
- uint32_t precomputed_send_from_buf_ctrl_word[4][2]; // really only 3, not 4
- // (easier addr comp)
-};
-
-void bsm12_init(bsm12_t *sm, int buf0,
- const buf_cmd_args_t *recv,
- const buf_cmd_args_t *send0,
- const buf_cmd_args_t *send1,
- bsm12_inspector_t inspect);
-
-void bsm12_start(bsm12_t *sm);
-void bsm12_stop(bsm12_t *sm);
-void bsm12_process_status(bsm12_t *sm, uint32_t status);
-void bsm12_handle_tx_underrun(bsm12_t *sm);
-void bsm12_handle_rx_overrun(bsm12_t *sm);
-
-
-#endif /* INCLUDED_BSM12_H */
diff --git a/firmware/microblaze/lib/buffer_pool.c b/firmware/microblaze/lib/buffer_pool.c
deleted file mode 100644
index 77e7c5213..000000000
--- a/firmware/microblaze/lib/buffer_pool.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include "memory_map.h"
-#include "buffer_pool.h"
-#include "hal_io.h"
-
-void
-bp_init(void)
-{
- int i;
- bp_disable_port(PORT_SERDES);
- bp_disable_port(PORT_DSP);
- bp_disable_port(PORT_ETH);
- bp_disable_port(PORT_RAM);
-
- for (i = 0; i < NBUFFERS; i++)
- bp_clear_buf(i);
-}
-
-#ifndef INLINE_BUFFER_POOL
-
-void
-bp_clear_buf(int bufnum)
-{
- buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR;
-}
-
-void
-bp_disable_port(int portnum)
-{
- // disable buffer connections to this port
- buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum);
-}
-
-void
-bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_READ
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-
-void
-bp_send_from_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_WRITE
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-
-#endif
diff --git a/firmware/microblaze/lib/buffer_pool.h b/firmware/microblaze/lib/buffer_pool.h
deleted file mode 100644
index 145b20f8d..000000000
--- a/firmware/microblaze/lib/buffer_pool.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#ifndef INCLUDED_BUFFER_POOL_H
-#define INCLUDED_BUFFER_POOL_H
-
-#include "memory_map.h"
-
-// Buffer Pool Management
-
-
-// define to have common buffer operations inlined
-#define INLINE_BUFFER_POOL 1
-
-void bp_init(void);
-
-#ifndef INLINE_BUFFER_POOL
-
-void bp_clear_buf(int bufnum);
-void bp_disable_port(int portnum);
-void bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll);
-void bp_send_from_buf(int bufnum, int port, int step, int fl, int ll);
-
-#else
-
-static inline void
-bp_clear_buf(int bufnum)
-{
- buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR;
-}
-
-static inline void
-bp_disable_port(int portnum)
-{
- // disable buffer connections to this port
- buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum);
-}
-
-static inline void
-bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_READ
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-
-static inline void
-bp_send_from_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_WRITE
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-#endif
-#endif
diff --git a/firmware/microblaze/lib/dbsm.c b/firmware/microblaze/lib/dbsm.c
deleted file mode 100644
index cee343eaa..000000000
--- a/firmware/microblaze/lib/dbsm.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-/*
- * Double Buffering State Machine
- */
-
-#include "dbsm.h"
-#include "memory_map.h"
-#include "buffer_pool.h"
-#include <stdbool.h>
-#include "nonstdio.h"
-#include <stdlib.h>
-
-typedef enum {
- BS_EMPTY,
- BS_FILLING,
- BS_FULL,
- BS_EMPTYING,
-} buffer_state_t;
-
-static buffer_state_t buffer_state[NBUFFERS];
-
-bool
-dbsm_nop_inspector(dbsm_t *sm, int buf_this)
-{
- return false;
-}
-
-void
-dbsm_init(dbsm_t *sm, int buf0,
- const buf_cmd_args_t *recv, const buf_cmd_args_t *send,
- inspector_t inspect)
-{
- if (buf0 & 0x1) // must be even
- abort();
-
- sm->buf0 = buf0;
- sm->running = false;
- sm->recv_args = *recv;
- sm->send_args = *send;
-
- sm->rx_idle = true;
- sm->tx_idle = true;
-
- sm->inspect = inspect;
-
- // How much to adjust the last_line register.
- // It's 1 for everything but the ethernet.
- //sm->last_line_adj = recv->port == PORT_ETH ? 3 : 1;
- sm->last_line_adj = 1;
-
- buffer_state[sm->buf0] = BS_EMPTY;
- buffer_state[sm->buf0 ^ 1] = BS_EMPTY;
-
- sm->precomputed_receive_to_buf_ctrl_word[0] =
- (BPC_READ
- | BPC_BUFFER(sm->buf0)
- | BPC_PORT(sm->recv_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->recv_args.first_line)
- | BPC_LAST_LINE(sm->recv_args.last_line));
-
- sm->precomputed_receive_to_buf_ctrl_word[1] =
- (BPC_READ
- | BPC_BUFFER(sm->buf0 ^ 1)
- | BPC_PORT(sm->recv_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->recv_args.first_line)
- | BPC_LAST_LINE(sm->recv_args.last_line));
-
- sm->precomputed_send_from_buf_ctrl_word[0] =
- (BPC_WRITE
- | BPC_BUFFER(sm->buf0)
- | BPC_PORT(sm->send_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->send_args.first_line)
- | BPC_LAST_LINE(0)); // last line filled in at runtime
-
- sm->precomputed_send_from_buf_ctrl_word[1] =
- (BPC_WRITE
- | BPC_BUFFER(sm->buf0 ^ 1)
- | BPC_PORT(sm->send_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->send_args.first_line)
- | BPC_LAST_LINE(0)); // last line filled in at runtime
-
-}
-
-static inline void
-dbsm_receive_to_buf(dbsm_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl = sm->precomputed_receive_to_buf_ctrl_word[bufno & 1];
-}
-
-static inline void
-dbsm_send_from_buf(dbsm_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl =
- (sm->precomputed_send_from_buf_ctrl_word[bufno & 1]
- | BPC_LAST_LINE(buffer_pool_status->last_line[bufno] - sm->last_line_adj));
-}
-
-void
-dbsm_start(dbsm_t *sm)
-{
- // printf("dbsm_start: buf0 = %d, recv_port = %d\n", sm->buf0, sm->recv_args.port);
-
- sm->running = true;
-
- buffer_state[sm->buf0] = BS_EMPTY;
- buffer_state[sm->buf0 ^ 1] = BS_EMPTY;
-
- bp_clear_buf(sm->buf0);
- bp_clear_buf(sm->buf0 ^ 1);
-
- sm->tx_idle = true;
- sm->rx_idle = false;
- dbsm_receive_to_buf(sm, sm->buf0);
- buffer_state[sm->buf0] = BS_FILLING;
-
-}
-
-
-void
-dbsm_stop(dbsm_t *sm)
-{
- sm->running = false;
- bp_clear_buf(sm->buf0);
- bp_clear_buf(sm->buf0 ^ 1);
- buffer_state[sm->buf0] = BS_EMPTY;
- buffer_state[sm->buf0 ^ 1] = BS_EMPTY;
-}
-
-static void dbsm_process_helper(dbsm_t *sm, int buf_this);
-static void dbsm_error_helper(dbsm_t *sm, int buf_this);
-
-void
-dbsm_process_status(dbsm_t *sm, uint32_t status)
-{
- if (!sm->running)
- return;
-
- if (status & (BPS_ERROR(sm->buf0) | BPS_ERROR(sm->buf0 ^ 1))){
- putchar('E');
- // Most likely an ethernet Rx error. We just restart the transfer.
- if (status & (BPS_ERROR(sm->buf0)))
- dbsm_error_helper(sm, sm->buf0);
- //dbsm_process_helper(sm, sm->buf0); //forward errors
-
- if (status & (BPS_ERROR(sm->buf0 ^ 1)))
- dbsm_error_helper(sm, sm->buf0 ^ 1);
- //dbsm_process_helper(sm, sm->buf0 ^ 1); //forward errors
- }
-
- if (status & BPS_DONE(sm->buf0))
- dbsm_process_helper(sm, sm->buf0);
-
- if (status & BPS_DONE(sm->buf0 ^ 1))
- dbsm_process_helper(sm, sm->buf0 ^ 1);
-}
-
-static void
-dbsm_process_helper(dbsm_t *sm, int buf_this)
-{
- int buf_other = buf_this ^ 1;
-
- bp_clear_buf(buf_this);
-
- if (buffer_state[buf_this] == BS_FILLING){
- buffer_state[buf_this] = BS_FULL;
- //
- // does s/w handle this packet?
- //
- if (sm->inspect(sm, buf_this)){
- // s/w handled the packet; refill the buffer
- dbsm_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- }
-
- else { // s/w didn't handle this; pass it on
-
- if(buffer_state[buf_other] == BS_EMPTY){
- dbsm_receive_to_buf(sm, buf_other);
- buffer_state[buf_other] = BS_FILLING;
- }
- else
- sm->rx_idle = true;
-
- if (sm->tx_idle){
- sm->tx_idle = false;
- dbsm_send_from_buf(sm, buf_this);
- buffer_state[buf_this] = BS_EMPTYING;
- }
- }
- }
- else { // buffer was emptying
- buffer_state[buf_this] = BS_EMPTY;
- if (sm->rx_idle){
- sm->rx_idle = false;
- dbsm_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- }
- if (buffer_state[buf_other] == BS_FULL){
- dbsm_send_from_buf(sm, buf_other);
- buffer_state[buf_other] = BS_EMPTYING;
- }
- else
- sm->tx_idle = true;
- }
-}
-
-static void
-dbsm_error_helper(dbsm_t *sm, int buf_this)
-{
- bp_clear_buf(buf_this); // clears ERROR flag
-
- if (buffer_state[buf_this] == BS_FILLING){
- dbsm_receive_to_buf(sm, buf_this); // restart the xfer
- }
- else { // buffer was emptying
- dbsm_send_from_buf(sm, buf_this); // restart the xfer
- }
-}
-
-/*
- * Handle DSP Tx underrun
- */
-void
-dbsm_handle_tx_underrun(dbsm_t *sm)
-{
- // clear the DSP Tx state machine
- sr_tx_ctrl->clear_state = 1;
-
- // If there's a buffer that's empyting, clear it & flush xfer
-
- if (buffer_state[sm->buf0] == BS_EMPTYING){
- bp_clear_buf(sm->buf0);
- sr_tx_ctrl->clear_state = 1; // flush partial packet
- // drop frame in progress on ground. Pretend it finished
- dbsm_process_helper(sm, sm->buf0);
- }
- else if (buffer_state[sm->buf0 ^ 1] == BS_EMPTYING){
- bp_clear_buf(sm->buf0 ^ 1);
- sr_tx_ctrl->clear_state = 1; // flush partial packet
- // drop frame in progress on ground. Pretend it finished
- dbsm_process_helper(sm, sm->buf0 ^ 1);
- }
-}
-
-/*
- * Handle DSP Rx overrun
- */
-void
-dbsm_handle_rx_overrun(dbsm_t *sm)
-{
- sr_rx_ctrl->clear_overrun = 1;
-
- // If there's a buffer that's filling, clear it.
- // Any restart will be the job of the caller.
-
- if (buffer_state[sm->buf0] == BS_FILLING)
- bp_clear_buf(sm->buf0);
-
- if (buffer_state[sm->buf0 ^1] == BS_FILLING)
- bp_clear_buf(sm->buf0 ^ 1);
-}
-
-void
-dbsm_wait_for_opening(dbsm_t *sm)
-{
- if (buffer_state[sm->buf0] == BS_EMPTYING){
- // wait for xfer to complete
- int mask = BPS_DONE(sm->buf0) | BPS_ERROR(sm->buf0) | BPS_IDLE(sm->buf0);
- while ((buffer_pool_status->status & mask) == 0)
- ;
- }
- else if (buffer_state[sm->buf0 ^ 1] == BS_EMPTYING){
- // wait for xfer to complete
- int mask = BPS_DONE(sm->buf0 ^ 1) | BPS_ERROR(sm->buf0 ^ 1) | BPS_IDLE(sm->buf0 ^ 1);
- while ((buffer_pool_status->status & mask) == 0)
- ;
- }
-}
diff --git a/firmware/microblaze/lib/dbsm.h b/firmware/microblaze/lib/dbsm.h
deleted file mode 100644
index cb7e12fc3..000000000
--- a/firmware/microblaze/lib/dbsm.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-#ifndef INCLUDED_DBSM_H
-#define INCLUDED_DBSM_H
-
-/*
- * Double Buffering State Machine
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-
-struct _dbsm;
-typedef struct _dbsm dbsm_t;
-
-/*
- * pointer to function that does packet inspection.
- *
- * If one of these returns true, it means that the s/w
- * handled that packet, and that it should NOT be passed
- * on to the normal destination port.
- */
-typedef bool (*inspector_t)(dbsm_t *sm, int buf_this);
-
-bool dbsm_nop_inspector(dbsm_t *sm, int buf_this); // returns false
-
-
-typedef struct
-{
- uint16_t port;
- uint16_t first_line;
- uint16_t last_line;
-} buf_cmd_args_t;
-
-/*!
- * double buffer state machine
- */
-struct _dbsm
-{
- uint8_t buf0; // Must be even. This machine uses buf0 and buf0+1
- uint8_t running;
- uint8_t rx_idle;
- uint8_t tx_idle;
- buf_cmd_args_t recv_args;
- buf_cmd_args_t send_args;
- inspector_t inspect;
- uint32_t precomputed_receive_to_buf_ctrl_word[2];
- uint32_t precomputed_send_from_buf_ctrl_word[2];
- int last_line_adj;
-};
-
-void dbsm_init(dbsm_t *sm, int buf0,
- const buf_cmd_args_t *recv, const buf_cmd_args_t *send,
- inspector_t inspect);
-
-void dbsm_start(dbsm_t *sm);
-void dbsm_stop(dbsm_t *sm);
-void dbsm_process_status(dbsm_t *sm, uint32_t status);
-void dbsm_handle_tx_underrun(dbsm_t *sm);
-void dbsm_handle_rx_overrun(dbsm_t *sm);
-
-/*
- * The cpu calls this when it want to ensure that it can send a buffer
- * to the same destination being used by this state machine.
- *
- * If neither buffer is EMPTYING it returns immediately. If a buffer
- * is EMPYTING, it waits for the h/w to transition to the DONE or
- * ERROR state.
- *
- * When this function returns, the caller queues it's buffer and busy
- * waits for it to complete.
- */
-void dbsm_wait_for_opening(dbsm_t *sm);
-
-#endif /* INCLUDED_DBSM_H */
diff --git a/firmware/microblaze/lib/gdbstub2.c b/firmware/microblaze/lib/gdbstub2.c
deleted file mode 100644
index 4c63dfce2..000000000
--- a/firmware/microblaze/lib/gdbstub2.c
+++ /dev/null
@@ -1,506 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Ettus Research LLC
- *
- * 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/>.
- */
-
-/*
- * Implement a eensy weensy part of the GDB Remote Serial Protocol
- *
- * See Appendix D of the GDB manual
- *
- * m<addr>,<length> -- read <length> bytes of memory starting at <addr>
- * Reply:
- * XX... XX... is memory contents in hex
- * ENN ENN NN is a hex error number
- *
- * M<addr>,<length>:XX... -- write memory, data in hex
- * Reply:
- * OK for success
- * ENN for an error. NN is a hex error number
- *
- * X<addr>,<length>:XX... -- write memory, data in binary
- * Reply:
- * OK for success
- * ENN for an error. NN is a hex error number
- *
- * c<addr> -- continue. <addr> is the address to resume (goto).
- * Reply: <none>
- *
- * \x80 New Format...
- */
-
-#include "gdbstub2.h"
-#include "loader_parser.h"
-#include "hal_uart.h"
-#include <stdbool.h>
-#include <stddef.h>
-
-#define MAX_PACKET 1024
-
-/*
- * Get raw character from serial port, no echo.
- */
-static inline int
-gdb_getc(void)
-{
- return hal_uart_getc();
-}
-
-/*
- * Put character to serial port. Raw output.
- */
-static inline void
-gdb_putc(int ch)
-{
- hal_uart_putc(ch);
-}
-
-// ------------------------------------------------------------------------
-
-#define GDB_ESCAPE 0x7d
-
-static unsigned char hex_table[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
-};
-
-static int
-put_hex8_checksum(int ch, int checksum)
-{
- unsigned char t = hex_table[(ch >> 4) & 0xf];
- checksum += t;
- gdb_putc(t);
-
- t = hex_table[ch & 0xf];
- checksum += t;
- gdb_putc(t);
- return checksum;
-}
-
-static void
-put_hex8(int ch)
-{
- put_hex8_checksum(ch, 0);
-}
-
-static bool
-hex4_to_bin(int ch, int *value)
-{
- if ('0' <= ch && ch <= '9'){
- *value = ch - '0';
- return true;
- }
- if ('a' <= ch && ch <= 'f'){
- *value = ch - 'a' + 10;
- return true;
- }
- if ('A' <= ch && ch <= 'F'){
- *value = ch - 'A' + 10;
- return true;
- }
- *value = 0;
- return false;
-}
-
-static bool
-hex8_to_bin(const unsigned char *s, int *value)
-{
- int v0, v1;
- if (hex4_to_bin(s[0], &v0) && hex4_to_bin(s[1], &v1)){
- *value = (v0 << 4) | v1;
- return true;
- }
- return false;
-}
-
-static bool
-hex_to_bin_array(unsigned char *binary_data, const unsigned char *hex_data, size_t nbytes)
-{
- for (size_t i = 0; i < nbytes; i++){
- int t;
- if (!hex8_to_bin(&hex_data[2*i], &t))
- return false;
- binary_data[i] = t;
- }
- return true;
-}
-
-static bool
-needs_escaping(int ch)
-{
- return ch == '$' || ch == '#' || ch == GDB_ESCAPE;
-}
-
-/*
- * \brief Wait for a packet.
- * \param[out] pkt_buf gets the received packet payload.
- * \param[in] max_size is the maximum number of bytes to write into \p pkt_buf.
- * \param[out] actual_size is the number of bytes written to \p pkt_buf.
- *
- * \returns true iff the payload fits and the checksum is OK.
- *
- * Packets have this format:
- *
- * $<packet-data>#<checksum>
- *
- * Where <packet-data> is anything and <checksum> is a two byte hex
- * checksum. In <packet-data> '$', '#' and 0x7d are escaped with 0x7d.
- * The checksum is computed as the modulo 256 sum of all characters
- * btween the leading '$' and the trailing '#' (an 8-bit unsigned
- * checksum).
- */
-static bool
-get_packet(unsigned char *pkt_buf, size_t max_size, size_t *actual_size)
-{
- typedef enum states {
- LOOKING_FOR_DOLLAR,
- LOOKING_FOR_HASH,
- CSUM1,
- CSUM2,
- } state_t;
-
- *actual_size = 0;
- unsigned char csum[2] = {0, 0};
- state_t state = LOOKING_FOR_DOLLAR;
- size_t pi = 0;
-
- while (1){
- int ch = gdb_getc();
-
- switch (state){
- case LOOKING_FOR_DOLLAR:
- if (ch == '$'){
- pi = 0;
- state = LOOKING_FOR_HASH;
- }
- else if (ch == '#'){ // most likely missed the $
- return false;
- }
- break;
-
- case LOOKING_FOR_HASH:
- if (ch == '$'){
- return false;
- }
- else if (ch == '#'){
- state = CSUM1;
- }
- else {
- if (pi >= max_size) // payload too big
- return false;
-
- if (ch == GDB_ESCAPE)
- ch = gdb_getc();
-
- pkt_buf[pi++] = ch;
- }
- break;
-
- case CSUM1:
- csum[0] = ch;
- state = CSUM2;
- break;
-
- case CSUM2:
- csum[1] = ch;
- *actual_size = pi;
-
- // accept .. as a correct checksum
- if (csum[0] == '.' && csum[1] == '.')
- return true;
-
- int expected_checksum;
- if (!hex8_to_bin(csum, &expected_checksum))
- return false;
-
- int checksum = 0;
- for (size_t i = 0; i < pi; i++)
- checksum += pkt_buf[i];
-
- checksum &= 0xff;
- return checksum == expected_checksum;
- }
- }
-}
-
-static void
-put_packet_trailer(int checksum)
-{
- gdb_putc('#');
- put_hex8(checksum & 0xff);
- gdb_putc('\r');
- gdb_putc('\n');
-}
-
-static void
-put_packet(const unsigned char *pkt_buf, size_t size)
-{
- gdb_putc('$');
-
- int checksum = 0;
- for (size_t i = 0; i < size; i++){
- int ch = pkt_buf[i];
- if (needs_escaping(ch))
- gdb_putc(GDB_ESCAPE);
- gdb_putc(ch);
- checksum += ch;
- }
- put_packet_trailer(checksum);
-}
-
-/*!
- * Read a hex number
- *
- * \param[inout] bufptr - pointer to pointer to buffer (updated on return)
- * \param[in] end - one past end of valid data in buf
- * \param[out] value - the parsed value
- *
- * \returns true iff a valid hex number was read from bufptr
- */
-static bool
-parse_number(const unsigned char **bufptr, const unsigned char *end, unsigned int *value)
-{
- const unsigned char *buf = *bufptr;
- unsigned int v = 0;
- bool valid = false;
- int nibble;
-
- while (buf < end && hex4_to_bin(*buf, &nibble)){
- valid = true;
- v = (v << 4) | nibble;
- buf++;
- }
-
- *value = v;
- *bufptr = buf;
- return valid;
-}
-
-static bool
-parse_char(const unsigned char **bufptr, const unsigned char *end, unsigned char *ch)
-{
- const unsigned char *buf = *bufptr;
- if (buf < end){
- *ch = *buf++;
- *bufptr = buf;
- return true;
- }
- return false;
-}
-
-static bool
-expect_char(const unsigned char **bufptr, const unsigned char *end, unsigned char expected)
-{
- unsigned char ch;
- return parse_char(bufptr, end, &ch) && ch == expected;
-}
-
-static bool
-expect_end(const unsigned char **bufptr, const unsigned char *end)
-{
- return *bufptr == end;
-}
-
-static bool
-parse_addr_length(const unsigned char **bufptr, const unsigned char *end,
- unsigned int *addr, unsigned int *length)
-{
- return (parse_number(bufptr, end, addr)
- && expect_char(bufptr, end, ',')
- && parse_number(bufptr, end, length));
-}
-
-static void
-put_error(int error)
-{
- unsigned char buf[3];
- buf[0] = 'E';
- buf[1] = hex_table[(error >> 4) & 0xf];
- buf[2] = hex_table[error & 0xf];
-
- put_packet(buf, sizeof(buf));
-}
-
-static void
-put_ok(void)
-{
- const unsigned char buf[2] = "OK";
- put_packet(buf, sizeof(buf));
-}
-
-/*
- * Read memory and send the reply.
- * We do it on the fly so that our packet size is effectively unlimited
- */
-static void
-read_memory(unsigned int addr, unsigned int nbytes)
-{
- int checksum = 0;
- gdb_putc('$');
-
- if ((addr & 0x3) == 0 && (nbytes & 0x3) == 0){ // word aligned
- union {
- unsigned int i;
- unsigned char c[4];
- } u;
-
- unsigned int *p = (unsigned int *) addr;
- unsigned int length = nbytes / 4;
-
- for (unsigned int i = 0; i < length; i++){
- u.i = p[i]; // do a word read
- checksum = put_hex8_checksum(u.c[0], checksum);
- checksum = put_hex8_checksum(u.c[1], checksum);
- checksum = put_hex8_checksum(u.c[2], checksum);
- checksum = put_hex8_checksum(u.c[3], checksum);
- }
- }
- else { // byte aligned
- unsigned char *p = (unsigned char *) addr;
- for (unsigned int i = 0; i < nbytes; i++)
- checksum = put_hex8_checksum(p[i], checksum);
- }
-
- put_packet_trailer(checksum);
-}
-
-static unsigned int
-get_unaligned_int(const unsigned char *p)
-{
- // we're bigendian
- return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]);
-}
-
-static bool
-write_memory(unsigned int addr, size_t nbytes,
- const unsigned char *data)
-{
- if ((addr & 0x3) == 0 && (nbytes & 0x3) == 0){ // word-aligned dst
- unsigned int *dst = (unsigned int *) addr;
- size_t length = nbytes / 4;
- for (size_t i = 0; i < length; i++){
- unsigned int t = get_unaligned_int(&data[4*i]);
- dst[i] = t; // word writes
- }
- }
- else { // non-word-aligned dst
- unsigned char *dst = (unsigned char *) addr;
- for (size_t i = 0; i < nbytes; i++){
- dst[i] = data[i];
- }
- }
- return true;
-}
-
-void
-gdbstub2_main_loop(void)
-{
- unsigned char inpkt[MAX_PACKET + 24];
- unsigned char binary_data[MAX_PACKET/2] __attribute__((aligned (4)));
-
- hal_uart_set_mode(UART_MODE_RAW); //tell UART HAL not to map \n to \r\n
-
- while (1){
- size_t inpkt_len;
- bool ok = get_packet(inpkt, sizeof(inpkt), &inpkt_len);
- if (!ok){
- gdb_putc('-');
- continue;
- }
- gdb_putc('+');
-
- const unsigned char *buf = inpkt;
- const unsigned char *end = inpkt + inpkt_len;
- unsigned char ch;
-
- if (!parse_char(&buf, end, &ch)){ // empty packet
- put_packet(0, 0);
- continue;
- }
-
- unsigned int addr;
- unsigned int length;
-
- switch(ch){
- case 'm': // m<addr>,<length> -- read <length> bytes starting at <addr>
- if (!(parse_addr_length(&buf, end, &addr, &length) && expect_end(&buf, end))){
- put_error(1);
- }
- else {
- read_memory(addr, length);
- }
- break;
-
- case 'M': // M<addr>,<length>:XX... -- write <length> bytes starting at <addr>
- // XX... is the data in hex
- if (!(parse_addr_length(&buf, end, &addr, &length)
- && expect_char(&buf, end, ':')
- && (end - buf) == 2 * length)){
- put_error(1);
- }
- else {
- if (!hex_to_bin_array(binary_data, buf, length))
- put_error(2);
- else if (!write_memory(addr, length, binary_data))
- put_error(3);
- else
- put_ok();
- }
- break;
-
- case 'X': // X<addr>,<length>:XX... -- write <length> bytes starting at <addr>
- // XX... is the data in binary
- if (!(parse_addr_length(&buf, end, &addr, &length)
- && expect_char(&buf, end, ':')
- && (end - buf) == length)){
- put_error(1);
- }
- else {
- if (!write_memory(addr, length, buf))
- put_error(3);
- else
- put_ok();
- }
- break;
-
- case 'c': // c<addr> -- continue. <addr> is the address to resume (goto).
- if (!(parse_number(&buf, end, &addr)
- && expect_end(&buf, end))){
- put_error(1);
- }
- else {
- typedef void (*fptr_t)(void);
- (*(fptr_t) addr)(); // most likely no return
- }
- break;
-/*
- case 0x80:
- {
- unsigned char *output = binary_data; // reuse
- size_t sizeof_output = sizeof(binary_data);
- size_t actual_olen;
- loader_parser(buf, end-buf,
- output, sizeof_output, &actual_olen);
- put_packet(output, actual_olen);
- }
- break;
-*/
- default: // unknown packet type
- put_packet(0, 0);
- break;
- }
- }
-}
diff --git a/firmware/microblaze/lib/mdelay.c b/firmware/microblaze/lib/mdelay.c
deleted file mode 100644
index c8c119b1a..000000000
--- a/firmware/microblaze/lib/mdelay.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-#include "mdelay.h"
-#include "memory_map.h"
-
-// Delay about one millisecond.
-//
-// Need 33,333 cycles at 33 MHz.
-// Each time around the loop is 10 cycles
-//
-
-#define LOOPCNT(wb_div) (MASTER_CLK_RATE/(wb_div) / 10000)
-
-inline static void
-delay_1ms(int loop_count)
-{
- int i;
- for (i = 0; i < loop_count; i++){
- asm volatile ("or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n");
- }
-}
-
-// delay about ms milliseconds
-void
-mdelay(int ms)
-{
- static int loop_count = -1;
-
- if (hwconfig_simulation_p())
- return;
-
- if (loop_count < 0){
- // set correct loop_count
- static unsigned short lc[8] = {
- 0,
- LOOPCNT(1),
- LOOPCNT(2),
- LOOPCNT(3),
- LOOPCNT(4),
- LOOPCNT(5),
- LOOPCNT(6),
- LOOPCNT(7)
- };
-
- loop_count = lc[hwconfig_wishbone_divisor() & 0x7];
- }
-
- int i;
- for (i = 0; i < ms; i++)
- delay_1ms(loop_count);
-}
diff --git a/firmware/microblaze/lib/net/.gitignore b/firmware/microblaze/lib/net/.gitignore
deleted file mode 100644
index 282522db0..000000000
--- a/firmware/microblaze/lib/net/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/firmware/microblaze/lib/usrp2_bytesex.h b/firmware/microblaze/lib/usrp2_bytesex.h
deleted file mode 100644
index 2b74f2a0b..000000000
--- a/firmware/microblaze/lib/usrp2_bytesex.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-#ifndef INCLUDED_USRP2_BYTESEX_H
-#define INCLUDED_USRP2_BYTESEX_H
-
-// The USRP2 speaks big-endian...
-// Use the standard include files or provide substitutions for
-// htons and friends
-
-#if defined(HAVE_ARPA_INET_H)
-#include <arpa/inet.h>
-#elif defined(HAVE_NETINET_IN_H)
-#include <netinet/in.h>
-#else
-#include <stdint.h>
-
-#ifdef WORDS_BIGENDIAN // nothing to do...
-
-static inline uint32_t htonl(uint32_t x){ return x; }
-static inline uint16_t htons(uint16_t x){ return x; }
-static inline uint32_t ntohl(uint32_t x){ return x; }
-static inline uint16_t ntohs(uint16_t x){ return x; }
-
-#else
-
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
-#else
-
-static inline uint16_t
-bswap_16 (uint16_t x)
-{
- return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
-}
-
-static inline uint32_t
-bswap_32 (uint32_t x)
-{
- return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
- | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
-}
-#endif
-
-static inline uint32_t htonl(uint32_t x){ return bswap_32(x); }
-static inline uint16_t htons(uint16_t x){ return bswap_16(x); }
-static inline uint32_t ntohl(uint32_t x){ return bswap_32(x); }
-static inline uint16_t ntohs(uint16_t x){ return bswap_16(x); }
-
-#endif
-#endif
-#endif /* INCLUDED_USRP2_BYTESEX_H */
diff --git a/firmware/microblaze/lib/wb16550.h b/firmware/microblaze/lib/wb16550.h
deleted file mode 100644
index 7522f4438..000000000
--- a/firmware/microblaze/lib/wb16550.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * 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/>.
- */
-
-
-// Wishbone National Semiconductor 16550A compatible UART
-
-#ifndef INCLUDED_WB16550_H
-#define INCLUDED_WB16550_H
-
-#include <stdint.h>
-
-typedef struct {
- volatile uint8_t data; // 0 r/w: r: rx fifo, w: tx fifo (if DLAB: LSB of divisor)
- volatile uint8_t ier; // 1 r/w: Interrupt Enable Register (if DLAB: MSB of divisor)
- volatile uint8_t iir_fcr; // 2 r/w: r: Interrupt ID Register,
- // w: Fifo Control Register
- volatile uint8_t lcr; // 3 r/w: Line Control Register
- volatile uint8_t mcr; // 4 w: Modem Control Register
- volatile uint8_t lsr; // 5 r: Line Status Register
- volatile uint8_t msr; // 6 r: Modem Status Register
-
-} wb16550_reg_t;
-
-#define UART_IER_RDI 0x01 // Enable received data interrupt
-#define UART_IER_THRI 0x02 // Enable transmitter holding reg empty int.
-#define UART_IER_RLSI 0x04 // Enable receiver line status interrupt
-#define UART_IER_MSI 0x08 // Enable modem status interrupt
-
-#define UART_IIR_NO_INT 0x01 // No interrupts pending
-#define UART_IIR_ID_MASK 0x06 // Mask for interrupt ID
-#define UART_IIR_MSI 0x00 // Modem status interrupt
-#define UART_IIR_THRI 0x02 // Tx holding register empty int
-#define UART_IIR_RDI 0x04 // Rx data available int
-#define UART_IIR_RLSI 0x06 // Receiver line status int
-
-#define UART_FCR_ENABLE_FIFO 0x01 // ignore, always enabled
-#define UART_FCR_CLEAR_RCVR 0x02 // Clear the RCVR FIFO
-#define UART_FCR_CLEAR_XMIT 0x04 // Clear the XMIT FIFO
-#define UART_FCR_TRIGGER_MASK 0xC0 // Mask for FIFO trigger range
-#define UART_FCR_TRIGGER_1 0x00 // Rx fifo trigger level: 1 byte
-#define UART_FCR_TRIGGER_4 0x40 // Rx fifo trigger level: 4 bytes
-#define UART_FCR_TRIGGER_8 0x80 // Rx fifo trigger level: 8 bytes
-#define UART_FCR_TRIGGER_14 0xC0 // Rx fifo trigger level: 14 bytes
-
-#define UART_LCR_DLAB 0x80 // Divisor latch access bit
-#define UART_LCR_SBC 0x40 // Set break control
-#define UART_LCR_SPAR 0x20 // Stick parity
-#define UART_LCR_EPAR 0x10 // Even parity select
-#define UART_LCR_PARITY 0x08 // Parity Enable
-#define UART_LCR_STOP 0x04 // Stop bits: 0=1 bit, 1=2 bits
-#define UART_LCR_WLEN5 0x00 // Wordlength: 5 bits
-#define UART_LCR_WLEN6 0x01 // Wordlength: 6 bits
-#define UART_LCR_WLEN7 0x02 // Wordlength: 7 bits
-#define UART_LCR_WLEN8 0x03 // Wordlength: 8 bits
-
-#define UART_MCR_LOOP 0x10 // Enable loopback test mode
-#define UART_MCR_OUT2n 0x08 // Out2 complement (loopback mode)
-#define UART_MCR_OUT1n 0x04 // Out1 complement (loopback mode)
-#define UART_MCR_RTSn 0x02 // RTS complement
-#define UART_MCR_DTRn 0x01 // DTR complement
-
-#define UART_LSR_TEMT 0x40 // Transmitter empty
-#define UART_LSR_THRE 0x20 // Transmit-hold-register empty
-#define UART_LSR_BI 0x10 // Break interrupt indicator
-#define UART_LSR_FE 0x08 // Frame error indicator
-#define UART_LSR_PE 0x04 // Parity error indicator
-#define UART_LSR_OE 0x02 // Overrun error indicator
-#define UART_LSR_DR 0x01 // Receiver data ready
-#define UART_LSR_BRK_ERROR_BITS 0x1E // BI, FE, PE, OE bits
-#define UART_LSR_ERROR 0x80 // At least 1 PE, FE or BI are in the fifo
-
-#define UART_MSR_DCD 0x80 // Data Carrier Detect
-#define UART_MSR_RI 0x40 // Ring Indicator
-#define UART_MSR_DSR 0x20 // Data Set Ready
-#define UART_MSR_CTS 0x10 // Clear to Send
-#define UART_MSR_DDCD 0x08 // Delta DCD
-#define UART_MSR_TERI 0x04 // Trailing edge ring indicator
-#define UART_MSR_DDSR 0x02 // Delta DSR
-#define UART_MSR_DCTS 0x01 // Delta CTS
-#define UART_MSR_ANY_DELTA 0x0F // Any of the delta bits!
-
-
-#endif // INCLUDED_WB16550_H
diff --git a/firmware/microblaze/u2_flash_tool b/firmware/microblaze/u2_flash_tool
deleted file mode 100755
index 2b66a4ac0..000000000
--- a/firmware/microblaze/u2_flash_tool
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-from optparse import OptionParser
-
-SECTOR_SIZE = 512 # bytes
-MAX_FILE_SIZE = 1 * (2**20) # maximum number of bytes we'll burn to a slot
-
-FPGA_OFFSET = 0 # offset in flash to fpga image
-FIRMWARE_OFFSET = 1 * (2**20) # offset in flash to firmware image
-
-def read_file_data(filename):
- f = open(filename, "rb")
- file_data = f.read(MAX_FILE_SIZE)
- t = len(file_data) % SECTOR_SIZE
- if t != 0:
- file_data += (SECTOR_SIZE - t)*chr(0) # pad to an even sector size w/ zeros
- return file_data
-
-
-def write_flash(offset, filename, devname):
- file_data = read_file_data(filename)
- dev = open(devname, "wb")
- dev.seek(offset, 0) # seek to absolute byte offset
- dev.write(file_data)
- dev.flush()
- dev.close()
- return True
-
-
-def verify_flash(offset, filename, devname):
- file_data = read_file_data(filename)
- dev = open(devname, "rb")
- dev.seek(offset, 0) # seek to absolute byte offset
- dev_data = dev.read(len(file_data))
- if len(dev_data) != len(file_data):
- sys.stderr.write("short read on device %s\n" % (devname,))
- return False
-
- if file_data == dev_data:
- return True
-
- # doesn't match
- nwrong = 0
- for i in range(len(file_data)):
- if dev_data[i] != file_data[i]:
- sys.stderr.write("mismatch at offset %7d. Expected 0x%02x, got 0x%02x\n" % (
- i, ord(file_data[i]), ord(dev_data[i])))
- nwrong += 1
- if nwrong > 16:
- sys.stderr.write("> 16 errors, stopping comparison\n")
- break
- return False
-
-def read_flash(offset, filename, devname):
- dev = open(devname, "rb")
- dev.seek(offset, 0) # seek to absolute byte offset
- dev_data = dev.read(MAX_FILE_SIZE)
- dev.close()
- open(filename, "wb").write(dev_data)
-
-
-def main():
- parser = OptionParser(usage="%prog: [options] filename")
- parser.add_option("-w", "--write", action="store_const", const="write", dest="mode",
- help="write FILE to TARGET slot")
- parser.add_option("-v", "--verify", action="store_const", const="verify", dest="mode",
- help="verify FILE against TARGET slot")
- parser.add_option("-r", "--read", action="store_const", const="read", dest="mode",
- help="read TARGET slot, write to FILE")
- parser.add_option("-t", "--target", type="choice", choices=("fpga", "s/w"), default="s/w",
- help="select TARGET slot from: fpga, s/w [default=%default]")
- parser.add_option("", "--dev", default=None,
- help="specify flash device file, e.g., /dev/sdb. Be careful!")
- parser.set_defaults(target="s/w", mode=None)
-
- (options, args) = parser.parse_args()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit
-
- filename = args[0]
-
- if options.mode is None:
- sys.stderr.write("specify mode with -w, -v or -r\n")
- parser.print_help()
- raise SystemExit
-
- if options.dev is None:
- sys.stderr.write("specify the device file with --dev\n")
- parser.print_help()
- raise SystemExit
-
- offset = { "fpga" : FPGA_OFFSET, "s/w" : FIRMWARE_OFFSET }[options.target]
-
- if options.mode == "write":
- r = (write_flash(offset, filename, options.dev)
- and verify_flash(offset, filename, options.dev))
- elif options.mode == "verify":
- r = verify_flash(offset, filename, options.dev)
- elif options.mode == "read":
- r = read_flash(offset, filename, options.dev)
- else:
- raise NotImplemented
-
- if not r:
- raise SystemExit, 1
-
-
-if __name__ == "__main__":
- main()
-
-
-
-
-
diff --git a/firmware/microblaze/usrp2/.gitignore b/firmware/microblaze/usrp2/.gitignore
deleted file mode 100644
index 18f715618..000000000
--- a/firmware/microblaze/usrp2/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-/Makefile
-/Makefile.in
-/*.a
-/*.bin
-/*.dump
-/*.ihx
-/*.elf
-/*.rom
-/*.map
diff --git a/firmware/microblaze/usrp2/udp_fw_update.c b/firmware/microblaze/usrp2/udp_fw_update.c
deleted file mode 100644
index 14eb0b1ee..000000000
--- a/firmware/microblaze/usrp2/udp_fw_update.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2010 Ettus Research LLC
- *
- * 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/>.
- */
-
-//Routines to handle updating the SPI Flash firmware via UDP
-
-#include "net_common.h"
-#include "usrp2/fw_common.h"
-#include <nonstdio.h>
-#include "udp_fw_update.h"
-
-//Firmware update packet handler
-void handle_udp_fw_update_packet(struct socket_address src, struct socket_address dst,
- unsigned char *payload, int payload_len) {
-
- usrp2_fw_update_data_t update_data_out;
- update_data_out.id = USRP2_FW_UPDATE_ID_WAT;
-
- send_udp_pkt(USRP2_UDP_UPDATE_PORT, src, &update_data_out, sizeof(update_data_out));
-}
diff --git a/firmware/microblaze/usrp2p/.gitignore b/firmware/microblaze/usrp2p/.gitignore
deleted file mode 100644
index 18f715618..000000000
--- a/firmware/microblaze/usrp2p/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-/Makefile
-/Makefile.in
-/*.a
-/*.bin
-/*.dump
-/*.ihx
-/*.elf
-/*.rom
-/*.map
diff --git a/firmware/microblaze/usrp2p/Makefile.am b/firmware/microblaze/usrp2p/Makefile.am
deleted file mode 100644
index 40766b406..000000000
--- a/firmware/microblaze/usrp2p/Makefile.am
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Copyright 2010 Ettus Research LLC
-#
-# 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/>.
-#
-
-include $(top_srcdir)/Makefile.common
-
-AM_CFLAGS = \
- $(COMMON_CFLAGS) \
- -DUSRP2P
-
-AM_LDFLAGS = \
- $(COMMON_LFLAGS) \
- -Wl,-defsym -Wl,_TEXT_START_ADDR=0x8050 \
- -Wl,-defsym -Wl,_STACK_SIZE=3072
-
-LDADD = libusrp2p.a
-
-#all of this here is to relocate the hardware vectors to somewhere normal.
-RELOCATE_ARGS = \
- --change-section-address .vectors.sw_exception+0x8000 \
- --change-section-address .vectors.hw_exception+0x8000 \
- --change-section-address .vectors.interrupt+0x8000 \
- --change-section-address .vectors.reset+0x8000
-
-# $(MB_OBJCOPY) -O ihex $< $@
-# the below would work if objcopy weren't written by apes
-# $(MB_OBJCOPY) -O ihex -w --change-section-address .vectors*+0x8000 $< $@
-# using the below will throw away the interrupt vectors when they get relocated below 0x0000.
-# $(MB_OBJCOPY) -O ihex --change-addresses -0x8000 $< $@
-
-########################################################################
-# USRP2P specific library and programs
-########################################################################
-noinst_LIBRARIES = libusrp2p.a
-
-libusrp2p_a_SOURCES = \
- $(COMMON_SRCS) \
- spif.c \
- spi_flash.c \
- spi_flash_read.c \
- bootloader_utils.c \
- ethernet.c \
- xilinx_s3_icap.c \
- udp_fw_update.c
-
-noinst_PROGRAMS = \
- usrp2p_txrx_uhd.elf \
- usrp2p_blinkenlights.elf \
- usrp2p_uart_flash_loader.elf
-
-usrp2p_txrx_uhd_elf_SOURCES = \
- $(top_srcdir)/apps/txrx_uhd.c
-
-usrp2p_blinkenlights_elf_SOURCES = \
- $(top_srcdir)/apps/blinkenlights.c
-
-usrp2p_uart_flash_loader_elf_SOURCES = \
- $(top_srcdir)/apps/uart_flash_loader.c
diff --git a/firmware/microblaze/usrp2p/bootloader/.gitignore b/firmware/microblaze/usrp2p/bootloader/.gitignore
deleted file mode 100644
index 17b0f82f3..000000000
--- a/firmware/microblaze/usrp2p/bootloader/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-/*.ihx
-/*.rmi
-/*_rom
-/*.elf
-/*.bin
-/*.dump
-/*.log
-/*.rom
-/*.map
-/Makefile
-/Makefile.in
diff --git a/firmware/microblaze/usrp2p/bootloader/Makefile.am b/firmware/microblaze/usrp2p/bootloader/Makefile.am
deleted file mode 100644
index 1fc5daf9c..000000000
--- a/firmware/microblaze/usrp2p/bootloader/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright 2007,2008,2009 Free Software Foundation, Inc.
-#
-# 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/>.
-#
-
-include $(top_srcdir)/Makefile.common
-
-ROM_LINKER_SCRIPT = u2p2-rom.ld
-
-# loads into 8K boot ram located at 0x0000_0000
-AM_CFLAGS = $(COMMON_CFLAGS) -I$(top_srcdir)/usrp2p
-AM_LDFLAGS = -Wl,-T,$(ROM_LINKER_SCRIPT) $(COMMON_LFLAGS) -Wl,-defsym -Wl,_STACK_SIZE=1024
-
-EXTRA_DIST = $(ROM_LINKER_SCRIPT)
-
-LDADD = $(top_srcdir)/usrp2p/libusrp2p.a
-
-noinst_PROGRAMS = \
- init_bootloader.elf
-
-init_bootloader_elf_SOURCES = init_bootloader.c
-
-.bin.rmi:
- $(top_srcdir)/bin/bin_to_ram_macro_init.py $< $@
-
-_generated_from_elf += \
- $(noinst_PROGRAMS:.elf=.rmi)
diff --git a/firmware/microblaze/usrp2p/bootloader_utils.c b/firmware/microblaze/usrp2p/bootloader_utils.c
deleted file mode 100644
index fadd225bb..000000000
--- a/firmware/microblaze/usrp2p/bootloader_utils.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2010 Ettus Research LLC
- *
- */
-
-//contains routines for loading programs from Flash. depends on Flash libraries.
-//also contains routines for reading / writing EEPROM flags for the bootloader
-#include <stdbool.h>
-#include <string.h>
-#include <bootloader_utils.h>
-#include <spi_flash.h>
-
-int is_valid_fpga_image(uint32_t addr) {
- uint8_t imgbuf[64];
- spi_flash_read(addr, 64, imgbuf);
- //we're just looking for leading 0xFF padding, followed by the sync bytes 0xAA 0x99
- int i = 0;
- for(i; i<63; i++) {
- if(imgbuf[i] == 0xFF) continue;
- if(imgbuf[i] == 0xAA && imgbuf[i+1] == 0x99) return 1;
- }
-
- return 0;
-}
-
-int is_valid_fw_image(uint32_t addr) {
- static const uint8_t fwheader[] = {0xB0, 0x00, 0x00, 0x00, 0xB8, 0x08}; //just lookin for a jump to anywhere located at the reset vector
- uint8_t buf[12];
- spi_flash_read(addr, 6, buf);
- return memcmp(buf, fwheader, 6) == 0;
-}
-
-void start_program(uint32_t addr)
-{
- memcpy(0x00000000, addr+0x00000000, 36); //copy the whole vector table, with the reset vector, into boot RAM
- typedef void (*fptr_t)(void);
- (*(fptr_t) 0x00000000)(); // most likely no return
-}
diff --git a/firmware/zpu/.gitignore b/firmware/zpu/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/firmware/zpu/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/firmware/microblaze/AUTHORS b/firmware/zpu/AUTHORS
index c365261f8..c230624fb 100644
--- a/firmware/microblaze/AUTHORS
+++ b/firmware/zpu/AUTHORS
@@ -1,3 +1,4 @@
Eric Blossom <eb@comsec.com>
Matt Ettus <matt@ettus.com>
Josh Blum <josh@ettus.com>
+Nick Foster <nick@ettus.com>
diff --git a/firmware/zpu/CMakeLists.txt b/firmware/zpu/CMakeLists.txt
new file mode 100644
index 000000000..d7cedbfb9
--- /dev/null
+++ b/firmware/zpu/CMakeLists.txt
@@ -0,0 +1,121 @@
+#
+# Copyright 2010-2011 Ettus Research LLC
+#
+# 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/>.
+#
+
+########################################################################
+# setup project and compiler
+########################################################################
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+#force the compiler because the check wont use the special flag below
+INCLUDE(CMakeForceCompiler)
+CMAKE_FORCE_C_COMPILER(zpu-elf-gcc GNU)
+PROJECT(USRP_NXXX_FW C)
+
+########################################################################
+# lwIP header include dirs
+########################################################################
+SET(LWIPDIR ${CMAKE_SOURCE_DIR}/lwip/lwip-1.3.1)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/lwip
+ ${CMAKE_SOURCE_DIR}/lwip_port
+ ${LWIPDIR}/src/include
+ ${LWIPDIR}/src/include/ipv4
+)
+
+########################################################################
+# misc flags for the gcc compiler
+########################################################################
+SET(CMAKE_C_FLAGS -phi) #always needed compile time and link time
+ADD_DEFINITIONS(-Os)
+ADD_DEFINITIONS(--std=gnu99)
+ADD_DEFINITIONS(-Wall)
+ADD_DEFINITIONS(-Werror-implicit-function-declaration)
+ADD_DEFINITIONS(-ffunction-sections)
+
+MACRO(ADD_LINKER_FLAGS flags)
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flags}")
+ENDMACRO(ADD_LINKER_FLAGS)
+
+ADD_LINKER_FLAGS("-Wl,--gc-sections")
+ADD_LINKER_FLAGS("-Wl,--relax")
+
+########################################################################
+# define for the hal io (FIXME move?)
+########################################################################
+#ADD_DEFINITIONS(-DHAL_IO_USES_DBOARD_PINS)
+ADD_DEFINITIONS(-DHAL_IO_USES_UART)
+
+########################################################################
+# common cflags and ldflags
+########################################################################
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/../../host/lib/usrp
+ ${CMAKE_SOURCE_DIR}/lib
+)
+
+########################################################################
+# setup programs for output files
+########################################################################
+FIND_PROGRAM(LINKER zpu-elf-ld)
+FIND_PROGRAM(OBJCOPY zpu-elf-objcopy)
+FIND_PROGRAM(OBJDUMP zpu-elf-objdump)
+FIND_PROGRAM(HEXDUMP hexdump)
+
+########################################################################
+# helper functions to build output formats
+########################################################################
+SET(GEN_OUTPUTS_BIN_SIZE "bin_size_not_set") #set before calling
+MACRO(GEN_OUTPUTS target)
+ GET_FILENAME_COMPONENT(name ${target} NAME_WE)
+ #command to create a map from elf
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${name}.map DEPENDS ${target}
+ COMMAND ${LINKER} -Map ${name}.map ${target}
+ )
+ #command to create a bin from elf
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${name}.bin DEPENDS ${target}
+ COMMAND ${OBJCOPY} -O binary ${target} ${name}.bin
+ --pad-to ${GEN_OUTPUTS_BIN_SIZE}
+ )
+ #command to create a ihx from elf
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${name}.ihx DEPENDS ${target}
+ COMMAND ${OBJCOPY} -O ihex ${target} ${name}.ihx
+ --pad-to ${GEN_OUTPUTS_BIN_SIZE}
+ )
+ #command to create a dump from elf
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${name}.dump DEPENDS ${target}
+ COMMAND ${OBJDUMP} -DSC ${target} > ${name}.dump
+ )
+ #command to create a rom from bin
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${name}.rom DEPENDS ${name}.bin
+ COMMAND ${HEXDUMP} -v -e'1/1 \"%.2X\\n\"' ${name}.bin > ${name}.rom
+ )
+ #add a top level target for output files
+ ADD_CUSTOM_TARGET(
+ ${name}_outputs ALL DEPENDS ${name}.map ${name}.bin ${name}.ihx ${name}.dump ${name}.rom
+ )
+ENDMACRO(GEN_OUTPUTS)
+
+########################################################################
+# Add the subdirectories
+########################################################################
+ADD_SUBDIRECTORY(usrp2)
+ADD_SUBDIRECTORY(usrp2p)
diff --git a/firmware/zpu/README b/firmware/zpu/README
new file mode 100644
index 000000000..ba0aa11eb
--- /dev/null
+++ b/firmware/zpu/README
@@ -0,0 +1,16 @@
+########################################################################
+# ZPU firmware code for USRP2 and N Series
+########################################################################
+This code requires the gcc-zpu tool-chain which can be found here:
+
+http://opensource.zylin.com/zpudownload.html
+
+zpu-elf-gcc should be in your $PATH
+
+########################################################################
+# Run the following commands to build
+########################################################################
+mkdir build
+cd build
+cmake ../
+make
diff --git a/firmware/microblaze/apps/blinkenlights.c b/firmware/zpu/apps/blinkenlights.c
index 4cebe5c9d..30cb33a7f 100644
--- a/firmware/microblaze/apps/blinkenlights.c
+++ b/firmware/zpu/apps/blinkenlights.c
@@ -12,9 +12,11 @@ int main(int argc, char *argv[]) {
uint32_t c = 0;
uint8_t i = 0;
+ output_regs->led_src = 0;
+
while(1) {
//delay(5000000);
- for(c=0;c<5000000;c++) asm("NOP");
+ for(c=0;c<50000;c++) asm("NOP");
output_regs->leds = (i++ % 2) ? 0xFF : 0x00; //blink everything on that register
}
diff --git a/firmware/microblaze/apps/flash_test.c b/firmware/zpu/apps/flash_test.c
index 5b4569030..5b4569030 100644
--- a/firmware/microblaze/apps/flash_test.c
+++ b/firmware/zpu/apps/flash_test.c
diff --git a/firmware/microblaze/apps/hardware_testbed.c b/firmware/zpu/apps/hardware_testbed.c
index e68e68ff7..e68e68ff7 100644
--- a/firmware/microblaze/apps/hardware_testbed.c
+++ b/firmware/zpu/apps/hardware_testbed.c
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/zpu/apps/txrx_uhd.c
index 9c1873e1c..4ccb585e2 100644
--- a/firmware/microblaze/apps/txrx_uhd.c
+++ b/firmware/zpu/apps/txrx_uhd.c
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
/*
* Copyright 2007,2008 Free Software Foundation, Inc.
@@ -28,12 +28,10 @@
#include "memory_map.h"
#include "spi.h"
#include "hal_io.h"
-#include "buffer_pool.h"
#include "pic.h"
#include <stdbool.h>
#include "ethernet.h"
#include "nonstdio.h"
-#include "dbsm.h"
#include <net/padded_eth_hdr.h>
#include <net_common.h>
#include "memcpy_wa.h"
@@ -42,87 +40,12 @@
#include <string.h>
#include "clocks.h"
#include "usrp2/fw_common.h"
-#include <i2c_async.h>
#include <i2c.h>
#include <ethertype.h>
#include <arp_cache.h>
#include "udp_fw_update.h"
-
-/*
- * Full duplex Tx and Rx between ethernet and DSP pipelines
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-/*
- * ================================================================
- * configure DSP TX double buffering state machine (eth -> dsp)
- * ================================================================
- */
-
-// DSP Tx reads ethernet header words
-#define DSP_TX_FIRST_LINE ((sizeof(padded_eth_hdr_t) + sizeof(struct ip_hdr) + sizeof(struct udp_hdr))/sizeof(uint32_t))
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-/*
- * ================================================================
- * configure DSP RX double buffering state machine (dsp -> eth)
- * ================================================================
- */
-
-static const uint32_t rx_ctrl_word = 1 << 16;
-
-// DSP Rx writes ethernet header words
-#define DSP_RX_FIRST_LINE sizeof(rx_ctrl_word)/sizeof(uint32_t)
-
-static bool dbsm_rx_inspector(dbsm_t *sm, int buf_this){
- size_t num_lines = buffer_pool_status->last_line[buf_this]-DSP_RX_FIRST_LINE;
- ((uint32_t*)buffer_ram(buf_this))[0] = (num_lines*sizeof(uint32_t)) | (1 << 16);
- return false;
-}
-
-// receive from DSP
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to ETH
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_ETH,
- 0, // starts with ethernet header in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
+#include "pkt_ctrl.h"
+#include "banal.h"
static void setup_network(void);
@@ -130,78 +53,50 @@ static void setup_network(void);
// the fast-path setup global variables
// ----------------------------------------------------------------
static eth_mac_addr_t fp_mac_addr_src, fp_mac_addr_dst;
-static struct socket_address fp_socket_src, fp_socket_dst;
-
-// ----------------------------------------------------------------
-void start_rx_streaming_cmd(void);
-void stop_rx_cmd(void);
+extern struct socket_address fp_socket_src, fp_socket_dst;
-static void print_ip_addr(const void *t){
- uint8_t *p = (uint8_t *)t;
- printf("%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+static void handle_udp_err0_packet(
+ struct socket_address src, struct socket_address dst,
+ unsigned char *payload, int payload_len
+){
+ sr_udp_sm->err0_port = (((uint32_t)dst.port) << 16) | src.port;
+ printf("Storing for async error path:\n");
+ printf(" source udp port: %d\n", dst.port);
+ printf(" destination udp port: %d\n", src.port);
+ newline();
}
-void handle_udp_data_packet(
+static void handle_udp_data_packet(
struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len
){
- //its a tiny payload, load the fast-path variables
fp_mac_addr_src = *ethernet_mac_addr();
arp_cache_lookup_mac(&src.addr, &fp_mac_addr_dst);
fp_socket_src = dst;
fp_socket_dst = src;
+ sr_udp_sm->dsp0_port = (((uint32_t)dst.port) << 16) | src.port;
printf("Storing for fast path:\n");
printf(" source mac addr: ");
- print_mac_addr(fp_mac_addr_src.addr); newline();
+ print_mac_addr(&fp_mac_addr_src); newline();
printf(" source ip addr: ");
print_ip_addr(&fp_socket_src.addr); newline();
printf(" source udp port: %d\n", fp_socket_src.port);
printf(" destination mac addr: ");
- print_mac_addr(fp_mac_addr_dst.addr); newline();
+ print_mac_addr(&fp_mac_addr_dst); newline();
printf(" destination ip addr: ");
print_ip_addr(&fp_socket_dst.addr); newline();
printf(" destination udp port: %d\n", fp_socket_dst.port);
newline();
- //setup network and vrt
+ //setup network
setup_network();
- // kick off the state machine
- dbsm_start(&dsp_rx_sm);
-
}
#define OTW_GPIO_BANK_TO_NUM(bank) \
(((bank) == USRP2_DIR_RX)? (GPIO_RX_BANK) : (GPIO_TX_BANK))
-//setup the output data
-static usrp2_ctrl_data_t ctrl_data_out;
-static struct socket_address i2c_src;
-static struct socket_address spi_src;
-
-static volatile bool i2c_done = false;
-void i2c_read_done_callback(void) {
- //printf("I2C read done callback\n");
- i2c_async_data_ready(ctrl_data_out.data.i2c_args.data);
- i2c_done = true;
- i2c_register_callback(0);
-}
-
-void i2c_write_done_callback(void) {
- //printf("I2C write done callback\n");
- i2c_done = true;
- i2c_register_callback(0);
-}
-
-static volatile bool spi_done = false;
-static volatile uint32_t spi_readback_data;
-void get_spi_readback_data(void) {
- ctrl_data_out.data.spi_args.data = spi_get_data();
- spi_done = true;
- spi_register_callback(0);
-}
-
-void handle_udp_ctrl_packet(
+static void handle_udp_ctrl_packet(
struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len
){
@@ -226,6 +121,7 @@ void handle_udp_ctrl_packet(
}
//setup the output data
+ usrp2_ctrl_data_t ctrl_data_out;
ctrl_data_out.proto_ver = USRP2_FW_COMPAT_NUM;
ctrl_data_out.id=USRP2_CTRL_ID_HUH_WHAT;
ctrl_data_out.seq=ctrl_data_in->seq;
@@ -239,7 +135,6 @@ void handle_udp_ctrl_packet(
case USRP2_CTRL_ID_WAZZUP_BRO:
ctrl_data_out.id = USRP2_CTRL_ID_WAZZUP_DUDE;
memcpy(&ctrl_data_out.data.ip_addr, get_ip_addr(), sizeof(struct ip_addr));
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
/*******************************************************************
@@ -247,21 +142,19 @@ void handle_udp_ctrl_packet(
******************************************************************/
case USRP2_CTRL_ID_TRANSACT_ME_SOME_SPI_BRO:{
//transact
- bool success = spi_async_transact(
- //(ctrl_data_in->data.spi_args.readback == 0)? SPI_TXONLY : SPI_TXRX,
+ uint32_t result = spi_transact(
+ (ctrl_data_in->data.spi_args.readback == 0)? SPI_TXONLY : SPI_TXRX,
ctrl_data_in->data.spi_args.dev, //which device
ctrl_data_in->data.spi_args.data, //32 bit data
ctrl_data_in->data.spi_args.num_bits, //length in bits
- (ctrl_data_in->data.spi_args.mosi_edge == USRP2_CLK_EDGE_RISE)? SPIF_PUSH_FALL : SPIF_PUSH_RISE | //flags
- (ctrl_data_in->data.spi_args.miso_edge == USRP2_CLK_EDGE_RISE)? SPIF_LATCH_RISE : SPIF_LATCH_FALL,
- get_spi_readback_data //callback
+ (ctrl_data_in->data.spi_args.mosi_edge == USRP2_CLK_EDGE_RISE)? SPIF_PUSH_FALL : SPIF_PUSH_RISE |
+ (ctrl_data_in->data.spi_args.miso_edge == USRP2_CLK_EDGE_RISE)? SPIF_LATCH_RISE : SPIF_LATCH_FALL
);
//load output
+ ctrl_data_out.data.spi_args.data = result;
ctrl_data_out.id = USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE;
- spi_src = src;
}
-// send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
/*******************************************************************
@@ -269,13 +162,11 @@ void handle_udp_ctrl_packet(
******************************************************************/
case USRP2_CTRL_ID_DO_AN_I2C_READ_FOR_ME_BRO:{
uint8_t num_bytes = ctrl_data_in->data.i2c_args.bytes;
- i2c_register_callback(i2c_read_done_callback);
- i2c_async_read(
+ i2c_read(
ctrl_data_in->data.i2c_args.addr,
+ ctrl_data_out.data.i2c_args.data,
num_bytes
);
- i2c_src = src;
-// i2c_dst = dst;
ctrl_data_out.id = USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE;
ctrl_data_out.data.i2c_args.bytes = num_bytes;
}
@@ -283,14 +174,11 @@ void handle_udp_ctrl_packet(
case USRP2_CTRL_ID_WRITE_THESE_I2C_VALUES_BRO:{
uint8_t num_bytes = ctrl_data_in->data.i2c_args.bytes;
- i2c_register_callback(i2c_read_done_callback);
- i2c_async_write(
+ i2c_write(
ctrl_data_in->data.i2c_args.addr,
ctrl_data_in->data.i2c_args.data,
num_bytes
);
- i2c_src = src;
-// i2c_dst = dst;
ctrl_data_out.id = USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE;
ctrl_data_out.data.i2c_args.bytes = num_bytes;
}
@@ -304,10 +192,6 @@ void handle_udp_ctrl_packet(
printf("error! tried to poke into 0x%x\n", ctrl_data_in->data.poke_args.addr);
}
else switch(ctrl_data_in->data.poke_args.num_bytes){
- case sizeof(uint64_t):
- *((uint32_t *) ctrl_data_in->data.poke_args.addrhi) = (uint32_t)ctrl_data_in->data.poke_args.datahi;
- //continue to uint32_t for low addr:
-
case sizeof(uint32_t):
*((uint32_t *) ctrl_data_in->data.poke_args.addr) = (uint32_t)ctrl_data_in->data.poke_args.data;
break;
@@ -322,15 +206,10 @@ void handle_udp_ctrl_packet(
}
ctrl_data_out.id = USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
case USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO:
switch(ctrl_data_in->data.poke_args.num_bytes){
- case sizeof(uint64_t):
- ctrl_data_out.data.poke_args.datahi = *((uint32_t *) ctrl_data_in->data.poke_args.addrhi);
- //continue to uint32_t for low addr:
-
case sizeof(uint32_t):
ctrl_data_out.data.poke_args.data = *((uint32_t *) ctrl_data_in->data.poke_args.addr);
break;
@@ -345,14 +224,13 @@ void handle_udp_ctrl_packet(
}
ctrl_data_out.id = USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
case USRP2_CTRL_ID_SO_LIKE_CAN_YOU_READ_THIS_UART_BRO:{
//executes a readline()-style read, up to num_bytes long, up to and including newline
int num_bytes = ctrl_data_in->data.uart_args.bytes;
if(num_bytes > 20) num_bytes = 20;
- num_bytes = fngets_timeout(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_out.data.uart_args.data, num_bytes);
+ num_bytes = fngets_noblock(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_out.data.uart_args.data, num_bytes);
ctrl_data_out.id = USRP2_CTRL_ID_I_HELLA_READ_THAT_UART_DUDE;
ctrl_data_out.data.uart_args.bytes = num_bytes;
break;
@@ -372,32 +250,11 @@ void handle_udp_ctrl_packet(
default:
ctrl_data_out.id = USRP2_CTRL_ID_HUH_WHAT;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
}
-
+ send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
}
-/*
- * Called when an ethernet packet is received.
- * Return true if we handled it here, otherwise
- * it'll be passed on to the DSP Tx pipe
- */
-static bool
-eth_pkt_inspector(dbsm_t *sm, int bufno)
-{
- //point me to the ethernet frame
- uint32_t *buff = (uint32_t *)buffer_ram(bufno);
-
- //treat this as fast-path data?
- // We have to do this operation as fast as possible.
- // Therefore, we do not check all the headers,
- // just check that the udp port matches
- // and that the vrt header is non zero.
- // In the future, a hardware state machine will do this...
- if ( //warning! magic numbers approaching....
- (((buff + ((2 + 14 + 20)/sizeof(uint32_t)))[0] & 0xffff) == USRP2_UDP_DATA_PORT) &&
- ((buff + ((2 + 14 + 20 + 8)/sizeof(uint32_t)))[1] != USRP2_INVALID_VRT_HEADER)
- ) return false;
+static void handle_inp_packet(uint32_t *buff, size_t num_lines){
//test if its an ip recovery packet
typedef struct{
@@ -411,42 +268,30 @@ eth_pkt_inspector(dbsm_t *sm, int bufno)
if (recovery_packet->eth_hdr.ethertype == 0xbeee && strncmp(recovery_packet->code, "addr", 4) == 0){
printf("Got ip recovery packet: "); print_ip_addr(&recovery_packet->data.ip_addr); newline();
set_ip_addr(&recovery_packet->data.ip_addr);
- return true;
+ return;
}
//pass it to the slow-path handler
- size_t len = buffer_pool_status->last_line[bufno] - 3;
- handle_eth_packet(buff, len);
- return true;
+ handle_eth_packet(buff, num_lines);
}
-//------------------------------------------------------------------
-/*
- * 1's complement sum for IP and UDP headers
- *
- * init chksum to zero to start.
- */
-static unsigned int
-CHKSUM(unsigned int x, unsigned int *chksum)
-{
- *chksum += x;
- *chksum = (*chksum & 0xffff) + (*chksum>>16);
- *chksum = (*chksum & 0xffff) + (*chksum>>16);
- return x;
-}
+//------------------------------------------------------------------
/*
* Called when eth phy state changes (w/ interrupts disabled)
*/
-volatile bool link_is_up = false; // eth handler sets this
-void
-link_changed_callback(int speed)
-{
- link_is_up = speed != 0;
- hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45);
- printf("\neth link changed: speed = %d\n", speed);
- if (link_is_up) send_gratuitous_arp();
+void link_changed_callback(int speed){
+ printf("\neth link changed: speed = %d\n", speed);
+ if (speed != 0){
+ hal_set_leds(LED_RJ45, LED_RJ45);
+ pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_MASTER);
+ send_gratuitous_arp();
+ }
+ else{
+ hal_set_leds(0x0, LED_RJ45);
+ pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_SLAVE);
+ }
}
static void setup_network(void){
@@ -477,110 +322,62 @@ static void setup_network(void){
sr_udp_sm->ip_hdr.checksum = UDP_SM_INS_IP_HDR_CHKSUM | (chksum & 0xffff);
//setup the udp header machine
- sr_udp_sm->udp_hdr.src_port = fp_socket_src.port;
- sr_udp_sm->udp_hdr.dst_port = fp_socket_dst.port;
+ sr_udp_sm->udp_hdr.src_port = UDP_SM_INS_UDP_SRC_PORT;
+ sr_udp_sm->udp_hdr.dst_port = UDP_SM_INS_UDP_DST_PORT;
sr_udp_sm->udp_hdr.length = UDP_SM_INS_UDP_LEN;
sr_udp_sm->udp_hdr.checksum = UDP_SM_LAST_WORD; // zero UDP checksum
}
-inline static void
-buffer_irq_handler(unsigned irq)
-{
- uint32_t status = buffer_pool_status->status;
-
- dbsm_process_status(&dsp_tx_sm, status);
- dbsm_process_status(&dsp_rx_sm, status);
-}
-
int
main(void)
{
u2_init();
-//we do this to see if we should set a default ip addr or not
-#ifdef USRP2P
- bool safe_fw = find_safe_booted_flag();
- set_safe_booted_flag(0);
- if(safe_fw) {
- set_default_ip_addr();
- set_default_mac_addr();
- }
-#endif
-
- putstr("\nTxRx-NEWETH\n");
- print_mac_addr(ethernet_mac_addr()->addr);
- newline();
+ putstr("\nTxRx-UHD-ZPU\n");
+ print_mac_addr(ethernet_mac_addr()); newline();
print_ip_addr(get_ip_addr()); newline();
printf("FPGA compatibility number: %d\n", USRP2_FPGA_COMPAT_NUM);
printf("Firmware compatibility number: %d\n", USRP2_FW_COMPAT_NUM);
//1) register the addresses into the network stack
- register_mac_addr(ethernet_mac_addr());
- register_ip_addr(get_ip_addr());
-
+ register_addrs(ethernet_mac_addr(), get_ip_addr());
+ pkt_ctrl_program_inspector(get_ip_addr(), USRP2_UDP_DATA_PORT);
+
//2) register callbacks for udp ports we service
+ init_udp_listeners();
register_udp_listener(USRP2_UDP_CTRL_PORT, handle_udp_ctrl_packet);
register_udp_listener(USRP2_UDP_DATA_PORT, handle_udp_data_packet);
+ register_udp_listener(USRP2_UDP_ERR0_PORT, handle_udp_err0_packet);
+#ifdef USRP2P
register_udp_listener(USRP2_UDP_UPDATE_PORT, handle_udp_fw_update_packet);
+#endif
- //3) setup ethernet hardware to bring the link up
+ //3) set the routing mode to slave to set defaults
+ pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_SLAVE);
+
+ //4) setup ethernet hardware to bring the link up
ethernet_register_link_changed_callback(link_changed_callback);
ethernet_init();
- // initialize double buffering state machine for ethernet -> DSP Tx
-
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- eth_pkt_inspector);
-
-
- // initialize double buffering state machine for DSP RX -> Ethernet
-
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_rx_inspector);
+ while(true){
- sr_tx_ctrl->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
-
- // kick off the state machine
- dbsm_start(&dsp_tx_sm);
-
- //int which = 0;
-
- while(1){
- // hal_gpio_write(GPIO_TX_BANK, which, 0x8000);
- // which ^= 0x8000;
-
- buffer_irq_handler(0);
-
- if(i2c_done) {
- i2c_done = false;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, i2c_src, &ctrl_data_out, sizeof(ctrl_data_out));
- //printf("Sending UDP packet from main loop for I2C...\n");
- }
-
- if(spi_done) {
- spi_done = false;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, spi_src, &ctrl_data_out, sizeof(ctrl_data_out));
+ size_t num_lines;
+ void *buff = pkt_ctrl_claim_incoming_buffer(&num_lines);
+ if (buff != NULL){
+ handle_inp_packet((uint32_t *)buff, num_lines);
+ pkt_ctrl_release_incoming_buffer();
}
+ pic_interrupt_handler();
int pending = pic_regs->pending; // poll for under or overrun
if (pending & PIC_UNDERRUN_INT){
- //dbsm_handle_tx_underrun(&dsp_tx_sm);
pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
putchar('U');
}
if (pending & PIC_OVERRUN_INT){
- //dbsm_handle_rx_overrun(&dsp_rx_sm);
- pic_regs->pending = PIC_OVERRUN_INT; // clear pending interrupt
-
- // FIXME Figure out how to handle this robustly.
- // Any buffers that are emptying should be allowed to drain...
-
+ pic_regs->pending = PIC_OVERRUN_INT; // clear interrupt
putchar('O');
}
}
diff --git a/firmware/microblaze/apps/uart_flash_loader.c b/firmware/zpu/apps/uart_flash_loader.c
index d67b84677..4ec89284a 100644
--- a/firmware/microblaze/apps/uart_flash_loader.c
+++ b/firmware/zpu/apps/uart_flash_loader.c
@@ -139,8 +139,8 @@ void delay(uint32_t t) {
}
int main(int argc, char *argv[]) {
- uint8_t buf[32];
- int i = 0;
+ //uint8_t buf[32];
+ //int i = 0;
hal_disable_ints(); // In case we got here via jmp 0x0
diff --git a/firmware/microblaze/bin/bin_to_mif.py b/firmware/zpu/bin/bin_to_mif.py
index cefce4e92..cefce4e92 100755
--- a/firmware/microblaze/bin/bin_to_mif.py
+++ b/firmware/zpu/bin/bin_to_mif.py
diff --git a/firmware/microblaze/bin/bin_to_ram_macro_init.py b/firmware/zpu/bin/bin_to_ram_macro_init.py
index 65cf2dbdf..085045290 100755
--- a/firmware/microblaze/bin/bin_to_ram_macro_init.py
+++ b/firmware/zpu/bin/bin_to_ram_macro_init.py
@@ -12,8 +12,9 @@ def bin_to_ram_macro_init(bin_input_file, ram_init_output_file):
ifile = open(bin_input_file, 'rb')
ofile = open(ram_init_output_file, 'w')
idata = ifile.read()
- fmt = ">%dI" % ((len(idata) / 4),)
- words = struct.unpack(fmt, idata)
+ idata_words = len(idata) / 4
+ fmt = ">%dI"%idata_words
+ words = struct.unpack(fmt, idata[:idata_words*4])
# pad to a multiple of 8 words
r = len(words) % 8
diff --git a/firmware/microblaze/divisors.py b/firmware/zpu/bin/divisors.py
index d31bd4dad..d31bd4dad 100755
--- a/firmware/microblaze/divisors.py
+++ b/firmware/zpu/bin/divisors.py
diff --git a/firmware/microblaze/bin/elf_to_sbf b/firmware/zpu/bin/elf_to_sbf
index d1be10c0d..d1be10c0d 100755
--- a/firmware/microblaze/bin/elf_to_sbf
+++ b/firmware/zpu/bin/elf_to_sbf
diff --git a/firmware/microblaze/bin/sbf.py b/firmware/zpu/bin/sbf.py
index 8e2c868a5..8e2c868a5 100644..100755
--- a/firmware/microblaze/bin/sbf.py
+++ b/firmware/zpu/bin/sbf.py
diff --git a/firmware/microblaze/bin/serial_loader b/firmware/zpu/bin/serial_loader
index 9bd5aada7..9bd5aada7 100755
--- a/firmware/microblaze/bin/serial_loader
+++ b/firmware/zpu/bin/serial_loader
diff --git a/firmware/microblaze/bin/uart_ihex_flash_loader.py b/firmware/zpu/bin/uart_ihex_flash_loader.py
index 5a3300f34..5a3300f34 100755
--- a/firmware/microblaze/bin/uart_ihex_flash_loader.py
+++ b/firmware/zpu/bin/uart_ihex_flash_loader.py
diff --git a/firmware/microblaze/bin/uart_ihex_ram_loader.py b/firmware/zpu/bin/uart_ihex_ram_loader.py
index c90fbe1d8..c90fbe1d8 100755
--- a/firmware/microblaze/bin/uart_ihex_ram_loader.py
+++ b/firmware/zpu/bin/uart_ihex_ram_loader.py
diff --git a/firmware/zpu/lib/CMakeLists.txt b/firmware/zpu/lib/CMakeLists.txt
new file mode 100644
index 000000000..193d63cfa
--- /dev/null
+++ b/firmware/zpu/lib/CMakeLists.txt
@@ -0,0 +1,47 @@
+#
+# Copyright 2010 Ettus Research LLC
+#
+# 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/>.
+#
+
+########################################################################
+SET(COMMON_SRCS
+ ${CMAKE_SOURCE_DIR}/lib/u2_init.c
+ ${CMAKE_SOURCE_DIR}/lib/abort.c
+ ${CMAKE_SOURCE_DIR}/lib/ad9510.c
+ ${CMAKE_SOURCE_DIR}/lib/clocks.c
+ ${CMAKE_SOURCE_DIR}/lib/eeprom.c
+ ${CMAKE_SOURCE_DIR}/lib/eth_addrs.c
+ ${CMAKE_SOURCE_DIR}/lib/eth_mac.c
+ ${CMAKE_SOURCE_DIR}/lib/_exit.c
+ ${CMAKE_SOURCE_DIR}/lib/exit.c
+ ${CMAKE_SOURCE_DIR}/lib/hal_io.c
+ ${CMAKE_SOURCE_DIR}/lib/hal_uart.c
+ ${CMAKE_SOURCE_DIR}/lib/i2c.c
+ ${CMAKE_SOURCE_DIR}/lib/mdelay.c
+ ${CMAKE_SOURCE_DIR}/lib/memcpy_wa.c
+ ${CMAKE_SOURCE_DIR}/lib/memset_wa.c
+ ${CMAKE_SOURCE_DIR}/lib/nonstdio.c
+ ${CMAKE_SOURCE_DIR}/lib/pic.c
+ ${CMAKE_SOURCE_DIR}/lib/pkt_ctrl.c
+ ${CMAKE_SOURCE_DIR}/lib/print_addrs.c
+ ${CMAKE_SOURCE_DIR}/lib/print_rmon_regs.c
+ ${CMAKE_SOURCE_DIR}/lib/print_buffer.c
+ ${CMAKE_SOURCE_DIR}/lib/printf.c
+ ${CMAKE_SOURCE_DIR}/lib/ihex.c
+ ${CMAKE_SOURCE_DIR}/lib/spi.c
+ ${CMAKE_SOURCE_DIR}/lib/net_common.c
+ ${CMAKE_SOURCE_DIR}/lib/arp_cache.c
+ ${CMAKE_SOURCE_DIR}/lib/banal.c
+)
diff --git a/firmware/microblaze/lib/_exit.c b/firmware/zpu/lib/_exit.c
index 9b40ab2ee..9b40ab2ee 100644
--- a/firmware/microblaze/lib/_exit.c
+++ b/firmware/zpu/lib/_exit.c
diff --git a/firmware/microblaze/lib/abort.c b/firmware/zpu/lib/abort.c
index d1d709392..d1d709392 100644
--- a/firmware/microblaze/lib/abort.c
+++ b/firmware/zpu/lib/abort.c
diff --git a/firmware/microblaze/lib/ad9510.c b/firmware/zpu/lib/ad9510.c
index 4d3acb65d..4d3acb65d 100644
--- a/firmware/microblaze/lib/ad9510.c
+++ b/firmware/zpu/lib/ad9510.c
diff --git a/firmware/microblaze/lib/ad9510.h b/firmware/zpu/lib/ad9510.h
index a395e5223..a395e5223 100644
--- a/firmware/microblaze/lib/ad9510.h
+++ b/firmware/zpu/lib/ad9510.h
diff --git a/firmware/microblaze/lib/arp_cache.c b/firmware/zpu/lib/arp_cache.c
index 9c586fa6b..8e14d8f17 100644
--- a/firmware/microblaze/lib/arp_cache.c
+++ b/firmware/zpu/lib/arp_cache.c
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/lib/arp_cache.h b/firmware/zpu/lib/arp_cache.h
index 8e84a1f94..e0e125d89 100644
--- a/firmware/microblaze/lib/arp_cache.h
+++ b/firmware/zpu/lib/arp_cache.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/lib/banal.c b/firmware/zpu/lib/banal.c
index 42937957f..dfb8df355 100644
--- a/firmware/microblaze/lib/banal.c
+++ b/firmware/zpu/lib/banal.c
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/lib/banal.h b/firmware/zpu/lib/banal.h
index 7b3c71a20..e9e55bca5 100644
--- a/firmware/microblaze/lib/banal.h
+++ b/firmware/zpu/lib/banal.h
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
@@ -19,24 +19,8 @@
#define INCLUDED_BANAL_H
#include <stdint.h>
-#include <lwip/ip_addr.h>
-/*
- * 1's complement sum for IP and UDP headers
- *
- * init chksum to zero to start.
- */
-static inline unsigned int
-CHKSUM(unsigned int x, unsigned int *chksum)
-{
- *chksum += x;
- *chksum = (*chksum & 0xffff) + (*chksum>>16);
- *chksum = (*chksum & 0xffff) + (*chksum>>16);
- return x;
-}
-
-unsigned int
-chksum_buffer(unsigned short *buf, int nshorts, unsigned int initial_chksum);
+#define dimof(x) (sizeof(x)/sizeof(x[0]))
//-------------- unsigned get_int 8, 16, 32, 64 --------------//
@@ -84,7 +68,4 @@ get_int64(const unsigned char *s)
return get_uint64(s);
}
-void
-print_ip(struct ip_addr ip);
-
#endif /* INCLUDED_BANAL_H */
diff --git a/firmware/microblaze/lib/clock_bits.h b/firmware/zpu/lib/clock_bits.h
index d2052e941..d2052e941 100644
--- a/firmware/microblaze/lib/clock_bits.h
+++ b/firmware/zpu/lib/clock_bits.h
diff --git a/firmware/microblaze/lib/clocks.c b/firmware/zpu/lib/clocks.c
index 2b352a385..2b352a385 100644
--- a/firmware/microblaze/lib/clocks.c
+++ b/firmware/zpu/lib/clocks.c
diff --git a/firmware/microblaze/lib/clocks.h b/firmware/zpu/lib/clocks.h
index 28d1d542f..28d1d542f 100644
--- a/firmware/microblaze/lib/clocks.h
+++ b/firmware/zpu/lib/clocks.h
diff --git a/firmware/microblaze/lib/compiler.h b/firmware/zpu/lib/compiler.h
index 4fa9b49f8..f677bdc3b 100644
--- a/firmware/microblaze/lib/compiler.h
+++ b/firmware/zpu/lib/compiler.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009, 2010 Ettus Research LLC
*
* 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
@@ -21,5 +21,6 @@
// FIXME gcc specific.
#define _AL4 __attribute__((aligned (4)))
+#define FORCE_INLINE inline __attribute__((always_inline))
#endif /* INCLUDED_COMPILER_H */
diff --git a/firmware/microblaze/lib/eeprom.c b/firmware/zpu/lib/eeprom.c
index d4e170046..d4e170046 100644
--- a/firmware/microblaze/lib/eeprom.c
+++ b/firmware/zpu/lib/eeprom.c
diff --git a/firmware/microblaze/lib/eth_addrs.c b/firmware/zpu/lib/eth_addrs.c
index ff5d04f4d..c45ce7559 100644
--- a/firmware/microblaze/lib/eth_addrs.c
+++ b/firmware/zpu/lib/eth_addrs.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Ettus Research LLC
+ * Copyright 2010-2011 Ettus Research LLC
* Copyright 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
@@ -23,12 +23,6 @@
#include "i2c.h"
#include "usrp2/fw_common.h"
-////////////////////////////////////////////////////////////////////////
-// EEPROM Layout
-////////////////////////////////////////////////////////////////////////
-#define USRP2_EE_MBOARD_MAC_ADDR 0x02 //6 bytes
-#define USRP2_EE_MBOARD_IP_ADDR 0x0C //uint32, big-endian
-
static bool
unprogrammed(const void *t, size_t len)
{
@@ -45,7 +39,7 @@ unprogrammed(const void *t, size_t len)
//////////////////// MAC Addr Stuff ///////////////////////
-static int8_t src_mac_addr_initialized = false;
+static bool src_mac_addr_initialized = false;
static const eth_mac_addr_t default_mac_addr = {{
0x00, 0x50, 0xC2, 0x85, 0x3f, 0xff
@@ -98,7 +92,7 @@ ethernet_set_mac_addr(const eth_mac_addr_t *t)
//////////////////// IP Addr Stuff ///////////////////////
-static int8_t src_ip_addr_initialized = false;
+static bool src_ip_addr_initialized = false;
static const struct ip_addr default_ip_addr = {
(192 << 24 | 168 << 16 | 10 << 8 | 2 << 0)
diff --git a/firmware/microblaze/lib/eth_mac.c b/firmware/zpu/lib/eth_mac.c
index 034a4d494..581a5c69f 100644
--- a/firmware/microblaze/lib/eth_mac.c
+++ b/firmware/zpu/lib/eth_mac.c
@@ -28,6 +28,7 @@
void
eth_mac_set_addr(const eth_mac_addr_t *src)
{
+ /* disable because MAC_SET_PASS_ALL is set below
eth_mac->ucast_hi =
(((unsigned int)src->addr[0])<<8) +
((unsigned int)src->addr[1]);
@@ -36,6 +37,7 @@ eth_mac_set_addr(const eth_mac_addr_t *src)
(((unsigned int)src->addr[3])<<16) +
(((unsigned int)src->addr[4])<<8) +
(((unsigned int)src->addr[5]));
+*/
}
@@ -45,7 +47,7 @@ eth_mac_init(const eth_mac_addr_t *src)
eth_mac->miimoder = 25; // divider from CPU clock (50MHz/25 = 2MHz)
eth_mac_set_addr(src);
- eth_mac->settings = MAC_SET_PAUSE_EN | MAC_SET_PASS_BCAST | MAC_SET_PASS_UCAST | MAC_SET_PAUSE_SEND_EN;
+ eth_mac->settings = MAC_SET_PAUSE_EN | MAC_SET_PASS_BCAST | MAC_SET_PASS_UCAST | MAC_SET_PAUSE_SEND_EN | MAC_SET_PASS_ALL;
eth_mac->pause_time = 38;
eth_mac->pause_thresh = 1200;
diff --git a/firmware/microblaze/lib/eth_mac.h b/firmware/zpu/lib/eth_mac.h
index 73feec955..73feec955 100644
--- a/firmware/microblaze/lib/eth_mac.h
+++ b/firmware/zpu/lib/eth_mac.h
diff --git a/firmware/microblaze/lib/eth_mac_regs.h b/firmware/zpu/lib/eth_mac_regs.h
index d680f8de0..d680f8de0 100644
--- a/firmware/microblaze/lib/eth_mac_regs.h
+++ b/firmware/zpu/lib/eth_mac_regs.h
diff --git a/firmware/microblaze/lib/ethernet.h b/firmware/zpu/lib/ethernet.h
index 52b297349..52b297349 100644
--- a/firmware/microblaze/lib/ethernet.h
+++ b/firmware/zpu/lib/ethernet.h
diff --git a/firmware/microblaze/lib/ethertype.h b/firmware/zpu/lib/ethertype.h
index 11f4bafec..235981193 100644
--- a/firmware/microblaze/lib/ethertype.h
+++ b/firmware/zpu/lib/ethertype.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/lib/exit.c b/firmware/zpu/lib/exit.c
index 95a3bf4de..95a3bf4de 100644
--- a/firmware/microblaze/lib/exit.c
+++ b/firmware/zpu/lib/exit.c
diff --git a/firmware/microblaze/lib/hal_io.c b/firmware/zpu/lib/hal_io.c
index be4c570c7..1d137943c 100644
--- a/firmware/microblaze/lib/hal_io.c
+++ b/firmware/zpu/lib/hal_io.c
@@ -253,11 +253,11 @@ fngets(hal_uart_name_t u, char * const s, int len)
}
int
-fngets_timeout(hal_uart_name_t u, char * const s, int len)
+fngets_noblock(hal_uart_name_t u, char * const s, int len)
{
char *x = s;
- while(((*x=(char)hal_uart_getc_timeout(u)) != '\n') && (*x != -1) && ((x-s) < len)) x++;
+ while(((*x=(char)hal_uart_getc_noblock(u)) != '\n') && (*x != 255) && ((x-s) < len)) x++;
*x = 0;
//printf("Returning from fngets() with string %d of length %d\n", s[0], x-s);
return (x-s);
diff --git a/firmware/microblaze/lib/hal_io.h b/firmware/zpu/lib/hal_io.h
index 950f8d591..7a617685c 100644
--- a/firmware/microblaze/lib/hal_io.h
+++ b/firmware/zpu/lib/hal_io.h
@@ -28,7 +28,7 @@ char *gets(char * const s);
int fputstr(hal_uart_name_t u, const char *s);
int fnputstr(hal_uart_name_t u, const char *s, int len);
int fngets(hal_uart_name_t u, char * const s, int len);
-int fngets_timeout(hal_uart_name_t u, char * const s, int len);
+int fngets_noblock(hal_uart_name_t u, char * const s, int len);
/*
* ------------------------------------------------------------------------
@@ -70,13 +70,7 @@ hal_set_timeout(int delta_ticks)
static inline int
hal_disable_ints(void)
{
- int result, t0;
-
- asm volatile("mfs %0, rmsr \n\
- andni %1, %0, 0x2 \n\
- mts rmsr, %1"
- : "=r" (result), "=r" (t0));
- return result;
+ return 0; /* NOP */
}
/*!
@@ -86,13 +80,7 @@ hal_disable_ints(void)
static inline int
hal_enable_ints(void)
{
- int result, t0;
-
- asm volatile("mfs %0, rmsr \n\
- ori %1, %0, 0x2 \n\
- mts rmsr, %1"
- : "=r" (result), "=r" (t0));
- return result;
+ return 0; /* NOP */
}
/*!
@@ -102,13 +90,7 @@ hal_enable_ints(void)
static inline void
hal_restore_ints(int prev_state)
{
- int t0, t1;
- asm volatile("andi %0, %2, 0x2 \n\
- mfs %1, rmsr \n\
- andni %1, %1, 0x2 \n\
- or %1, %1, %0 \n\
- mts rmsr, %1"
- : "=r" (t0), "=r"(t1) : "r" (prev_state));
+ /* NOP */
}
#endif /* INCLUDED_HAL_IO_H */
diff --git a/firmware/microblaze/lib/hal_uart.c b/firmware/zpu/lib/hal_uart.c
index 7836240fe..6a37cceb6 100644
--- a/firmware/microblaze/lib/hal_uart.c
+++ b/firmware/zpu/lib/hal_uart.c
@@ -103,17 +103,18 @@ hal_uart_getc(hal_uart_name_t u)
}
int
-hal_uart_getc_timeout(hal_uart_name_t u)
+hal_uart_getc_noblock(hal_uart_name_t u)
{
- int timeout = 0;
- while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS))
- mdelay(1);
- return (timeout >= HAL_UART_TIMEOUT_MS) ? -1 : uart_regs[u].rxchar; //return -1 if nothing there, cause fngets to quit
+// int timeout = 0;
+// while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS))
+// mdelay(1);
+ if(uart_regs[u].rxlevel == 0) return 255;
+ return uart_regs[u].rxchar;
}
int hal_uart_rx_flush(hal_uart_name_t u)
{
- char x;
+ char x = 0;
while(uart_regs[u].rxlevel) x = uart_regs[u].rxchar;
return x;
}
diff --git a/firmware/microblaze/lib/hal_uart.h b/firmware/zpu/lib/hal_uart.h
index 758c8cb5e..793aface0 100644
--- a/firmware/microblaze/lib/hal_uart.h
+++ b/firmware/zpu/lib/hal_uart.h
@@ -27,8 +27,6 @@
#define DEFAULT_UART UART_DEBUG //which UART printf, gets, etc. use
-#define HAL_UART_TIMEOUT_MS 300
-
typedef enum {
US_9600 = 0,
US_19200 = 1,
@@ -85,9 +83,9 @@ void hal_uart_putc_nowait(hal_uart_name_t u, int ch);
int hal_uart_getc(hal_uart_name_t u);
/*
- * \brief Blocking read of next char from serial port with timeout
+ * \brief Non-blocking read of next char from serial port, return -1 if nothing available
*/
-int hal_uart_getc_timeout(hal_uart_name_t u);
+int hal_uart_getc_noblock(hal_uart_name_t u);
int hal_uart_rx_flush(hal_uart_name_t u);
diff --git a/firmware/microblaze/lib/i2c.c b/firmware/zpu/lib/i2c.c
index d230f462c..d230f462c 100644
--- a/firmware/microblaze/lib/i2c.c
+++ b/firmware/zpu/lib/i2c.c
diff --git a/firmware/microblaze/lib/i2c.h b/firmware/zpu/lib/i2c.h
index 1af4d72df..1af4d72df 100644
--- a/firmware/microblaze/lib/i2c.h
+++ b/firmware/zpu/lib/i2c.h
diff --git a/firmware/microblaze/lib/i2c_async.c b/firmware/zpu/lib/i2c_async.c
index 05c4c3a09..05c4c3a09 100644
--- a/firmware/microblaze/lib/i2c_async.c
+++ b/firmware/zpu/lib/i2c_async.c
diff --git a/firmware/microblaze/lib/i2c_async.h b/firmware/zpu/lib/i2c_async.h
index e6095fca6..e6095fca6 100644
--- a/firmware/microblaze/lib/i2c_async.h
+++ b/firmware/zpu/lib/i2c_async.h
diff --git a/firmware/microblaze/lib/if_arp.h b/firmware/zpu/lib/if_arp.h
index 63519c4be..63519c4be 100644
--- a/firmware/microblaze/lib/if_arp.h
+++ b/firmware/zpu/lib/if_arp.h
diff --git a/firmware/microblaze/lib/ihex.c b/firmware/zpu/lib/ihex.c
index 97ecf73b6..97ecf73b6 100644
--- a/firmware/microblaze/lib/ihex.c
+++ b/firmware/zpu/lib/ihex.c
diff --git a/firmware/microblaze/lib/ihex.h b/firmware/zpu/lib/ihex.h
index 9f471fbe2..9f471fbe2 100644
--- a/firmware/microblaze/lib/ihex.h
+++ b/firmware/zpu/lib/ihex.h
diff --git a/firmware/microblaze/apps/cruft/blink_leds.c b/firmware/zpu/lib/mdelay.c
index 682ca8db2..8f9b14112 100644
--- a/firmware/microblaze/apps/cruft/blink_leds.c
+++ b/firmware/zpu/lib/mdelay.c
@@ -1,3 +1,4 @@
+/* -*- c -*- */
/*
* Copyright 2007 Free Software Foundation, Inc.
*
@@ -15,26 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "u2_init.h"
+#include "mdelay.h"
#include "memory_map.h"
-#include "hal_io.h"
-#include "nonstdio.h"
-
-int
-main(void)
-{
- int counter = 0;
- u2_init();
-
- putstr("blink_leds\n");
- while(1){
- output_regs->leds = (counter++ & 0x3);
+void mdelay(int ms){
+ if (hwconfig_simulation_p()) return;
+ for(int i = 0; i < ms; i++){
+ static const uint32_t num_ticks = MASTER_CLK_RATE/1000;
+ const uint32_t ticks_begin = router_status->time64_ticks_rb;
+ while((router_status->time64_ticks_rb - ticks_begin) < num_ticks){
+ /*NOP*/
+ }
}
-
- return 0;
}
diff --git a/firmware/microblaze/lib/mdelay.h b/firmware/zpu/lib/mdelay.h
index 226bbb3f7..226bbb3f7 100644
--- a/firmware/microblaze/lib/mdelay.h
+++ b/firmware/zpu/lib/mdelay.h
diff --git a/firmware/microblaze/lib/memcpy_wa.c b/firmware/zpu/lib/memcpy_wa.c
index ef20efaa9..ef20efaa9 100644
--- a/firmware/microblaze/lib/memcpy_wa.c
+++ b/firmware/zpu/lib/memcpy_wa.c
diff --git a/firmware/microblaze/lib/memcpy_wa.h b/firmware/zpu/lib/memcpy_wa.h
index 072fc148f..072fc148f 100644
--- a/firmware/microblaze/lib/memcpy_wa.h
+++ b/firmware/zpu/lib/memcpy_wa.h
diff --git a/firmware/microblaze/lib/memset_wa.c b/firmware/zpu/lib/memset_wa.c
index da5da21ab..da5da21ab 100644
--- a/firmware/microblaze/lib/memset_wa.c
+++ b/firmware/zpu/lib/memset_wa.c
diff --git a/firmware/microblaze/lib/memset_wa.h b/firmware/zpu/lib/memset_wa.h
index 46d903d53..46d903d53 100644
--- a/firmware/microblaze/lib/memset_wa.h
+++ b/firmware/zpu/lib/memset_wa.h
diff --git a/firmware/microblaze/lib/net/eth_mac_addr.h b/firmware/zpu/lib/net/eth_mac_addr.h
index b44fb68f7..01bf91988 100644
--- a/firmware/microblaze/lib/net/eth_mac_addr.h
+++ b/firmware/zpu/lib/net/eth_mac_addr.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/lib/net/padded_eth_hdr.h b/firmware/zpu/lib/net/padded_eth_hdr.h
index df816734f..df816734f 100644
--- a/firmware/microblaze/lib/net/padded_eth_hdr.h
+++ b/firmware/zpu/lib/net/padded_eth_hdr.h
diff --git a/firmware/microblaze/lib/net/socket_address.h b/firmware/zpu/lib/net/socket_address.h
index 336f30a0c..336f30a0c 100644
--- a/firmware/microblaze/lib/net/socket_address.h
+++ b/firmware/zpu/lib/net/socket_address.h
diff --git a/firmware/microblaze/lib/net_common.c b/firmware/zpu/lib/net_common.c
index 6305408d6..ec9198090 100644
--- a/firmware/microblaze/lib/net_common.c
+++ b/firmware/zpu/lib/net_common.c
@@ -22,7 +22,6 @@
#include "net_common.h"
#include "banal.h"
#include <hal_io.h>
-#include <buffer_pool.h>
#include <memory_map.h>
#include <memcpy_wa.h>
#include <ethernet.h>
@@ -36,28 +35,21 @@
#include "if_arp.h"
#include <ethertype.h>
#include <string.h>
+#include "pkt_ctrl.h"
+static const bool debug = false;
-int cpu_tx_buf_dest_port = PORT_ETH;
+static const eth_mac_addr_t BCAST_MAC_ADDR = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
-// If this is non-zero, this dbsm could be writing to the ethernet
-dbsm_t *ac_could_be_sending_to_eth;
-
-static inline bool
-ip_addr_eq(const struct ip_addr a, const struct ip_addr b)
-{
- return a.addr == b.addr;
-}
+//used in the top level application...
+struct socket_address fp_socket_src, fp_socket_dst;
// ------------------------------------------------------------------------
static eth_mac_addr_t _local_mac_addr;
-void register_mac_addr(const eth_mac_addr_t *mac_addr){
- _local_mac_addr = *mac_addr;
-}
-
static struct ip_addr _local_ip_addr;
-void register_ip_addr(const struct ip_addr *ip_addr){
+void register_addrs(const eth_mac_addr_t *mac_addr, const struct ip_addr *ip_addr){
+ _local_mac_addr = *mac_addr;
_local_ip_addr = *ip_addr;
}
@@ -72,6 +64,12 @@ struct listener_entry {
static struct listener_entry listeners[MAX_UDP_LISTENERS];
+void init_udp_listeners(void){
+ for (int i = 0; i < MAX_UDP_LISTENERS; i++){
+ listeners[i].rcvr = NULL;
+ }
+}
+
static struct listener_entry *
find_listener_by_port(unsigned short port)
{
@@ -86,7 +84,7 @@ static struct listener_entry *
find_free_listener(void)
{
for (int i = 0; i < MAX_UDP_LISTENERS; i++){
- if (listeners[i].rcvr == 0)
+ if (listeners[i].rcvr == NULL)
return &listeners[i];
}
abort();
@@ -126,13 +124,6 @@ send_pkt(eth_mac_addr_t dst, int ethertype,
const void *buf1, size_t len1,
const void *buf2, size_t len2)
{
- // Wait for buffer to become idle
- // FIXME can this ever not be ready?
-
- //hal_set_leds(LED_BUF_BUSY, LED_BUF_BUSY);
- while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0)
- ;
- //hal_set_leds(0, LED_BUF_BUSY);
// Assemble the header
padded_eth_hdr_t ehdr;
@@ -141,9 +132,10 @@ send_pkt(eth_mac_addr_t dst, int ethertype,
ehdr.src = _local_mac_addr;
ehdr.ethertype = ethertype;
- uint32_t *p = buffer_ram(CPU_TX_BUF);
+ uint32_t *buff = (uint32_t *)pkt_ctrl_claim_outgoing_buffer();
// Copy the pieces into the buffer
+ uint32_t *p = buff;
*p++ = 0x0; // slow path
memcpy_wa(p, &ehdr, sizeof(ehdr)); // 4 lines
p += sizeof(ehdr)/sizeof(uint32_t);
@@ -173,34 +165,23 @@ send_pkt(eth_mac_addr_t dst, int ethertype,
p += len2/sizeof(uint32_t);
}
- size_t total_len = (p - buffer_ram(CPU_TX_BUF)) * sizeof(uint32_t);
+ size_t total_len = (p - buff) * sizeof(uint32_t);
if (total_len < 60) // ensure that we don't try to send a short packet
total_len = 60;
-
- // wait until nobody else is sending to the ethernet
- if (ac_could_be_sending_to_eth){
- //hal_set_leds(LED_ETH_BUSY, LED_ETH_BUSY);
- dbsm_wait_for_opening(ac_could_be_sending_to_eth);
- //hal_set_leds(0x0, LED_ETH_BUSY);
- }
-
- if (0){
- printf("send_pkt to port %d, len = %d\n",
- cpu_tx_buf_dest_port, (int) total_len);
- print_buffer(buffer_ram(CPU_TX_BUF), total_len/4);
- }
-
- // fire it off
- bp_send_from_buf(CPU_TX_BUF, cpu_tx_buf_dest_port, 1, 0, total_len/4);
- // wait for it to complete (not long, it's a small pkt)
- while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0)
- ;
+ pkt_ctrl_commit_outgoing_buffer(total_len/4);
+ if (debug) printf("sent %d bytes\n", (int)total_len);
+}
- bp_clear_buf(CPU_TX_BUF);
+unsigned int CHKSUM(unsigned int x, unsigned int *chksum)
+{
+ *chksum += x;
+ *chksum = (*chksum & 0xffff) + (*chksum>>16);
+ *chksum = (*chksum & 0xffff) + (*chksum>>16);
+ return x;
}
-unsigned int
+static unsigned int
chksum_buffer(unsigned short *buf, int nshorts, unsigned int initial_chksum)
{
unsigned int chksum = initial_chksum;
@@ -210,7 +191,6 @@ chksum_buffer(unsigned short *buf, int nshorts, unsigned int initial_chksum)
return chksum;
}
-
void
send_ip_pkt(struct ip_addr dst, int protocol,
const void *buf0, size_t len0,
@@ -235,7 +215,7 @@ send_ip_pkt(struct ip_addr dst, int protocol,
bool found = arp_cache_lookup_mac(&ip.dest, &dst_mac);
if (!found){
printf("net_common: failed to hit cache looking for ");
- print_ip(ip.dest);
+ print_ip_addr(&ip.dest);
newline();
return;
}
@@ -294,6 +274,11 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst,
if (icmp->code == ICMP_DUR_PORT){ // port unreachable
//handle destination port unreachable (the host ctrl+c'd the app):
+ //filter out non udp data response
+ struct ip_hdr *ip = (struct ip_hdr *)(((uint8_t*)icmp) + sizeof(struct icmp_echo_hdr));
+ struct udp_hdr *udp = (struct udp_hdr *)(((char *)ip) + IP_HLEN);
+ if (IPH_PROTO(ip) != IP_PROTO_UDP || udp->dest != fp_socket_dst.port) return;
+
//end async update packets per second
sr_tx_ctrl->cyc_per_up = 0;
@@ -335,12 +320,6 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst,
}
}
-static void __attribute__((unused))
-print_arp_ip(const unsigned char ip[4])
-{
- printf("%d.%d.%d.%d", ip[0], ip[1], ip[2],ip[3]);
-}
-
static void
send_arp_reply(struct arp_eth_ipv4 *req, eth_mac_addr_t our_mac)
{
@@ -373,8 +352,7 @@ void send_gratuitous_arp(void){
memcpy(req.ar_tip, get_ip_addr(), sizeof(struct ip_addr));
//send the request with a broadcast ethernet mac address
- eth_mac_addr_t t; memset(&t, 0xff, sizeof(t));
- send_pkt(t, ETHERTYPE_ARP, &req, sizeof(req), 0, 0, 0, 0);
+ send_pkt(BCAST_MAC_ADDR, ETHERTYPE_ARP, &req, sizeof(req), 0, 0, 0, 0);
}
static void
@@ -392,9 +370,9 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size)
printf("ar_pln = %d\n", p->ar_pln);
printf("ar_op = %d\n", p->ar_op);
printf("ar_sha = "); print_mac_addr(p->ar_sha); newline();
- printf("ar_sip = "); print_arp_ip(p->ar_sip); newline();
+ printf("ar_sip = "); print_ip_addr (p->ar_sip); newline();
printf("ar_tha = "); print_mac_addr(p->ar_tha); newline();
- printf("ar_tip = "); print_arp_ip(p->ar_tip); newline();
+ printf("ar_tip = "); print_ip_addr (p->ar_tip); newline();
}
if (p->ar_hrd != ARPHRD_ETHER
@@ -412,7 +390,7 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size)
sip.addr = get_int32(p->ar_sip);
tip.addr = get_int32(p->ar_tip);
- if (ip_addr_eq(tip, _local_ip_addr)){ // They're looking for us...
+ if (memcmp(&tip, &_local_ip_addr, sizeof(_local_ip_addr)) == 0){ // They're looking for us...
send_arp_reply(p, _local_mac_addr);
}
}
@@ -420,15 +398,17 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size)
void
handle_eth_packet(uint32_t *p, size_t nlines)
{
- //print_buffer(p, nlines);
+ static size_t bcount = 0;
+ if (debug) printf("===> %d\n", (int)bcount++);
+ if (debug) print_buffer(p, nlines);
- int ethertype = p[3] & 0xffff;
+ padded_eth_hdr_t *eth_hdr = (padded_eth_hdr_t *)p;
- if (ethertype == ETHERTYPE_ARP){
+ if (eth_hdr->ethertype == ETHERTYPE_ARP){
struct arp_eth_ipv4 *arp = (struct arp_eth_ipv4 *)(p + 4);
handle_arp_packet(arp, nlines*sizeof(uint32_t) - 14);
}
- else if (ethertype == ETHERTYPE_IPV4){
+ else if (eth_hdr->ethertype == ETHERTYPE_IPV4){
struct ip_hdr *ip = (struct ip_hdr *)(p + 4);
if (IPH_V(ip) != 4 || IPH_HL(ip) != 5) // ignore pkts w/ bad version or options
return;
@@ -436,7 +416,10 @@ handle_eth_packet(uint32_t *p, size_t nlines)
if (IPH_OFFSET(ip) & (IP_MF | IP_OFFMASK)) // ignore fragmented packets
return;
- // FIXME filter on dest ip addr (should be broadcast or for us)
+ // filter on dest ip addr (should be broadcast or for us)
+ bool is_bcast = memcmp(&eth_hdr->dst, &BCAST_MAC_ADDR, sizeof(BCAST_MAC_ADDR)) == 0;
+ bool is_my_ip = memcmp(&ip->dest, &_local_ip_addr, sizeof(_local_ip_addr)) == 0;
+ if (!is_bcast && !is_my_ip) return;
arp_cache_update(&ip->src, (eth_mac_addr_t *)(((char *)p)+8));
@@ -459,16 +442,3 @@ handle_eth_packet(uint32_t *p, size_t nlines)
else
return; // Not ARP or IPV4, ignore
}
-
-// ------------------------------------------------------------------------
-
-void
-print_ip(struct ip_addr ip)
-{
- unsigned int t = ntohl(ip.addr);
- printf("%d.%d.%d.%d",
- (t >> 24) & 0xff,
- (t >> 16) & 0xff,
- (t >> 8) & 0xff,
- t & 0xff);
-}
diff --git a/firmware/microblaze/lib/net_common.h b/firmware/zpu/lib/net_common.h
index 3040e5ef3..409022352 100644
--- a/firmware/microblaze/lib/net_common.h
+++ b/firmware/zpu/lib/net_common.h
@@ -20,25 +20,22 @@
#include <stdint.h>
#include <stddef.h>
-#include <dbsm.h>
#include <net/socket_address.h>
#include <net/eth_mac_addr.h>
-#define CPU_TX_BUF 7 // cpu -> eth
-
-extern int cpu_tx_buf_dest_port;
-
-// If this is non-zero, this dbsm could be writing to the ethernet
-extern dbsm_t *ac_could_be_sending_to_eth;
-
-void stop_streaming(void);
+/*
+ * 1's complement sum for IP and UDP headers
+ *
+ * init chksum to zero to start.
+ */
+unsigned int CHKSUM(unsigned int x, unsigned int *chksum);
typedef void (*udp_receiver_t)(struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len);
-void register_mac_addr(const eth_mac_addr_t *mac_addr);
+void init_udp_listeners(void);
-void register_ip_addr(const struct ip_addr *ip_addr);
+void register_addrs(const eth_mac_addr_t *mac_addr, const struct ip_addr *ip_addr);
void register_udp_listener(int port, udp_receiver_t rcvr);
diff --git a/firmware/microblaze/lib/nonstdio.c b/firmware/zpu/lib/nonstdio.c
index 4b5fa4123..4b5fa4123 100644
--- a/firmware/microblaze/lib/nonstdio.c
+++ b/firmware/zpu/lib/nonstdio.c
diff --git a/firmware/microblaze/lib/nonstdio.h b/firmware/zpu/lib/nonstdio.h
index 62ebfa46d..a47a6df6e 100644
--- a/firmware/microblaze/lib/nonstdio.h
+++ b/firmware/zpu/lib/nonstdio.h
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
/*
* Copyright 2007 Free Software Foundation, Inc.
@@ -38,11 +38,10 @@ void puthex32_nl(unsigned long x);
#define puthex_nl puthex32_nl
void newline(); // putchar('\n')
-void print_mac_addr(const unsigned char addr[6]);
-void print_uint64(uint64_t v);
+void print_mac_addr(const void *addr);
+
+void print_ip_addr(const void *addr);
void print_buffer(uint32_t *buf, size_t n);
-//char *itoa(signed long value, char *result, int base);
-//void reverse(char s[]);
#endif /* INCLUDED_NONSTDIO_H */
diff --git a/firmware/microblaze/lib/pic.c b/firmware/zpu/lib/pic.c
index 226da5f85..bd627ce6b 100644
--- a/firmware/microblaze/lib/pic.c
+++ b/firmware/zpu/lib/pic.c
@@ -26,17 +26,7 @@
/*
* Our secondary interrupt vector.
*/
-irq_handler_t pic_vector[NVECTORS] = {
- nop_handler,
- nop_handler,
- nop_handler,
- nop_handler,
- nop_handler,
- nop_handler,
- nop_handler,
- nop_handler
-};
-
+irq_handler_t pic_vector[NVECTORS];
void
pic_init(void)
@@ -47,6 +37,10 @@ pic_init(void)
pic_regs->edge_enable = PIC_ONETIME_INT | PIC_UNDERRUN_INT | PIC_OVERRUN_INT | PIC_PPS_INT;
pic_regs->polarity = ~0 & ~PIC_PHY_INT; // rising edge
pic_regs->pending = ~0; // clear all pending ints
+
+ for (int i = 0; i < NVECTORS; i++){
+ pic_vector[i] = pic_nop_handler;
+ }
}
/*
@@ -54,7 +48,8 @@ pic_init(void)
* system interrupt handler with the appropriate prologue and
* epilogue.
*/
-void pic_interrupt_handler() __attribute__ ((interrupt_handler));
+//FIXME zpu-gcc does not install interrupt_handler like this
+//void pic_interrupt_handler() __attribute__ ((interrupt_handler));
void pic_interrupt_handler()
{
@@ -88,7 +83,7 @@ pic_register_handler(unsigned irq, irq_handler_t handler)
}
void
-nop_handler(unsigned irq)
+pic_nop_handler(unsigned irq)
{
// nop
}
diff --git a/firmware/microblaze/lib/pic.h b/firmware/zpu/lib/pic.h
index 68918f9ad..cfdf721f4 100644
--- a/firmware/microblaze/lib/pic.h
+++ b/firmware/zpu/lib/pic.h
@@ -24,12 +24,13 @@ typedef void (*irq_handler_t)(unsigned irq);
void pic_init(void);
void pic_register_handler(unsigned irq, irq_handler_t handler);
-void nop_handler(unsigned irq); // default handler does nothing
+void pic_nop_handler(unsigned irq); // default handler does nothing
// FIXME inline assembler
int pic_disable_interrupts();
int pic_enable_interrupts();
void pic_restore_interrupts(int prev_status);
+void pic_interrupt_handler();
#endif /* INCLUDED_PIC_H */
diff --git a/firmware/zpu/lib/pkt_ctrl.c b/firmware/zpu/lib/pkt_ctrl.c
new file mode 100644
index 000000000..2bbe2f843
--- /dev/null
+++ b/firmware/zpu/lib/pkt_ctrl.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2010-2011 Ettus Research LLC
+ *
+ * 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/>.
+ */
+
+#include "pkt_ctrl.h"
+#include "memory_map.h"
+#include <nonstdio.h>
+
+//status signals from WB into PR
+#define CPU_STAT_RD_DONE (1 << 0)
+#define CPU_STAT_RD_EROR (1 << 1)
+#define CPU_STAT_RD_IDLE (1 << 2)
+
+//status signals from PR into WB
+#define CPU_STAT_WR_DONE (1 << 4)
+#define CPU_STAT_WR_EROR (1 << 5)
+#define CPU_STAT_WR_IDLE (1 << 6)
+
+//control signals from WB into PR
+#define CPU_CTRL_RD_CLEAR (1 << 0)
+#define CPU_CTRL_RD_START (1 << 1)
+
+//control signals from PR into WB
+#define CPU_CTRL_WR_CLEAR (1 << 2)
+#define CPU_CTRL_WR_START (1 << 3)
+
+void pkt_ctrl_program_inspector(
+ const struct ip_addr *ip_addr, uint16_t data_port
+){
+ router_ctrl->ip_addr = ip_addr->addr;
+ router_ctrl->data_ports = data_port;
+}
+
+void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){
+ //About to change the mode; ensure that we are accepting packets.
+ //The plumbing will not switch if it cannot pass an end of packet.
+ pkt_ctrl_release_incoming_buffer();
+
+ //Change the mode; this switches the valves and crossbars.
+ router_ctrl->mode_ctrl = mode;
+}
+
+static inline void cpu_stat_wait_for(int bm){
+ while((router_status->status & bm) == 0){
+ /* NOP */
+ }
+}
+
+void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines){
+ uint32_t status = router_status->status;
+
+ //if done: clear the read and return the buffer
+ if (status & CPU_STAT_RD_DONE){
+ *num_lines = (router_status->status >> 16) & 0xffff;
+ return ((uint32_t *) ROUTER_RAM_BASE);
+ }
+
+ //if error: drop the packet and start a new read
+ if (status & CPU_STAT_RD_EROR){
+ putstr("E");
+ pkt_ctrl_release_incoming_buffer();
+ }
+
+ //otherwise null for nothing ready
+ return NULL;
+}
+
+void pkt_ctrl_release_incoming_buffer(void){
+ //clear, wait for idle, and start a new read
+ router_ctrl->iface_ctrl = CPU_CTRL_RD_CLEAR;
+ cpu_stat_wait_for(CPU_STAT_RD_IDLE);
+ router_ctrl->iface_ctrl = CPU_CTRL_RD_START;
+}
+
+void *pkt_ctrl_claim_outgoing_buffer(void){
+ //wait for idle and return the buffer
+ cpu_stat_wait_for(CPU_STAT_WR_IDLE);
+ return ((uint32_t *) ROUTER_RAM_BASE);
+}
+
+void pkt_ctrl_commit_outgoing_buffer(size_t num_lines){
+ //start a new write with the given length
+ router_ctrl->iface_ctrl = ((num_lines & 0xffff) << 16) | CPU_CTRL_WR_START;
+ //wait for the write to become done
+ cpu_stat_wait_for(CPU_STAT_WR_DONE);
+ router_ctrl->iface_ctrl = CPU_CTRL_WR_CLEAR;
+}
diff --git a/firmware/zpu/lib/pkt_ctrl.h b/firmware/zpu/lib/pkt_ctrl.h
new file mode 100644
index 000000000..15e4b0c4d
--- /dev/null
+++ b/firmware/zpu/lib/pkt_ctrl.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2010-2011 Ettus Research LLC
+ *
+ * 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/>.
+ */
+
+#ifndef INCLUDED_PKT_CTRL_H
+#define INCLUDED_PKT_CTRL_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <lwip/ip_addr.h>
+
+typedef enum {
+ PKT_CTRL_ROUTING_MODE_SLAVE = 0,
+ PKT_CTRL_ROUTING_MODE_MASTER = 1
+} pkt_ctrl_routing_mode_t;
+
+//! Program the decision values into the packet inspector
+void pkt_ctrl_program_inspector(
+ const struct ip_addr *ip_addr, uint16_t data_port
+);
+
+//! Set the routing mode for this device
+void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode);
+
+/*!
+ * Try to claim an incomming buffer.
+ * \param num_lines filled with the buffer size
+ * \return a pointer to the buffer memory or NULL
+ */
+void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines);
+
+/*!
+ * Release the incoming buffer. Call when done.
+ */
+void pkt_ctrl_release_incoming_buffer(void);
+
+/*!
+ * Claim an outgoing buffer.
+ * \return a pointer to the buffer
+ */
+void *pkt_ctrl_claim_outgoing_buffer(void);
+
+/*!
+ * Commit the outgoing buffer.
+ * \param num_lines how many lines written.
+ */
+void pkt_ctrl_commit_outgoing_buffer(size_t num_lines);
+
+#endif /* INCLUDED_PKT_CTRL_H */
diff --git a/firmware/microblaze/lib/print_mac_addr.c b/firmware/zpu/lib/print_addrs.c
index 475082325..fa2a49fc3 100644
--- a/firmware/microblaze/lib/print_mac_addr.c
+++ b/firmware/zpu/lib/print_addrs.c
@@ -18,11 +18,16 @@
#include "nonstdio.h"
void
-print_mac_addr(const unsigned char addr[6])
+print_mac_addr(const void *addr)
{
+ uint8_t *p = (uint8_t *)addr;
for(size_t i = 0; i < 6; i++){
if(i) putchar(':');
- puthex8(addr[i]);
+ puthex8(p[i]);
}
}
+void print_ip_addr(const void *addr){
+ uint8_t *p = (uint8_t *)addr;
+ printf("%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+}
diff --git a/firmware/microblaze/lib/print_buffer.c b/firmware/zpu/lib/print_buffer.c
index 9f9104bb5..9f9104bb5 100644
--- a/firmware/microblaze/lib/print_buffer.c
+++ b/firmware/zpu/lib/print_buffer.c
diff --git a/firmware/microblaze/lib/print_rmon_regs.c b/firmware/zpu/lib/print_rmon_regs.c
index 6d9986909..6d9986909 100644
--- a/firmware/microblaze/lib/print_rmon_regs.c
+++ b/firmware/zpu/lib/print_rmon_regs.c
diff --git a/firmware/microblaze/lib/print_rmon_regs.h b/firmware/zpu/lib/print_rmon_regs.h
index 44e52da84..44e52da84 100644
--- a/firmware/microblaze/lib/print_rmon_regs.h
+++ b/firmware/zpu/lib/print_rmon_regs.h
diff --git a/firmware/microblaze/lib/printf.c b/firmware/zpu/lib/printf.c
index 45bd57cb9..45bd57cb9 100644
--- a/firmware/microblaze/lib/printf.c
+++ b/firmware/zpu/lib/printf.c
diff --git a/firmware/microblaze/lib/printf.c.smaller b/firmware/zpu/lib/printf.c.smaller
index 4d858648d..4d858648d 100644
--- a/firmware/microblaze/lib/printf.c.smaller
+++ b/firmware/zpu/lib/printf.c.smaller
diff --git a/firmware/microblaze/lib/spi.c b/firmware/zpu/lib/spi.c
index 2a41a1bfa..af0d8a68f 100644
--- a/firmware/microblaze/lib/spi.c
+++ b/firmware/zpu/lib/spi.c
@@ -20,9 +20,9 @@
#include "pic.h"
#include "nonstdio.h"
-void (*volatile spi_callback)(void); //SPI callback when xfer complete.
+//void (*volatile spi_callback)(void); //SPI callback when xfer complete.
-static void spi_irq_handler(unsigned irq);
+//static void spi_irq_handler(unsigned irq);
void
spi_init(void)
@@ -66,6 +66,7 @@ spi_transact(bool readback, int slave, uint32_t data, int length, uint32_t flags
return 0;
}
+/*
void spi_register_callback(void (*volatile callback)(void)) {
spi_callback = callback;
}
@@ -106,3 +107,4 @@ spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*
return true;
}
+*/
diff --git a/firmware/microblaze/lib/spi.h b/firmware/zpu/lib/spi.h
index 54618cedd..71245150a 100644
--- a/firmware/microblaze/lib/spi.h
+++ b/firmware/zpu/lib/spi.h
@@ -48,12 +48,12 @@ void spi_wait(void);
uint32_t
spi_transact(bool readback, int slave, uint32_t data, int length, uint32_t flags);
-uint32_t spi_get_data(void);
+//uint32_t spi_get_data(void);
//static void spi_irq_handler(unsigned irq);
-void spi_register_callback(void (*volatile callback)(void));
+//void spi_register_callback(void (*volatile callback)(void));
-bool
-spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*volatile callback)(void));
+//bool
+//spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*volatile callback)(void));
// ----------------------------------------------------------------
// Routines that manipulate the FLASH SPI BUS
diff --git a/firmware/microblaze/lib/stdint.h b/firmware/zpu/lib/stdint.h
index b5a8611a9..b5a8611a9 100644
--- a/firmware/microblaze/lib/stdint.h
+++ b/firmware/zpu/lib/stdint.h
diff --git a/firmware/microblaze/lib/stdio.h b/firmware/zpu/lib/stdio.h
index 12a7ed0bb..12a7ed0bb 100644
--- a/firmware/microblaze/lib/stdio.h
+++ b/firmware/zpu/lib/stdio.h
diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/zpu/lib/u2_init.c
index 4a553a713..db26be538 100644
--- a/firmware/microblaze/lib/u2_init.c
+++ b/firmware/zpu/lib/u2_init.c
@@ -20,24 +20,15 @@
#include "spi.h"
#include "pic.h"
#include "hal_io.h"
-#include "buffer_pool.h"
#include "hal_uart.h"
#include "i2c.h"
-#include "i2c_async.h"
#include "mdelay.h"
#include "clocks.h"
#include "usrp2/fw_common.h"
#include "nonstdio.h"
-
-unsigned char u2_hw_rev_major;
-unsigned char u2_hw_rev_minor;
-
-static inline void
-get_hw_rev(void)
-{
- bool ok = eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV, &u2_hw_rev_minor, 1);
- ok &= eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV+1, &u2_hw_rev_major, 1);
-}
+#ifdef USRP2P
+#include "u2p_init.h"
+#endif
/*
* We ought to arrange for this to be called before main, but for now,
@@ -60,18 +51,24 @@ u2_init(void)
// init i2c so we can read our rev
pic_init(); // progammable interrupt controller
i2c_init();
- i2c_register_handler(); //for using async I2C
hal_enable_ints();
- bp_init(); // buffer pool
-
-
+#ifdef USRP2P
+ u2p_init();
+#endif
// flash all leds to let us know board is alive
- hal_set_leds(0x0, 0x1f);
- mdelay(100);
- hal_set_leds(0x1f, 0x1f);
- mdelay(100);
+ hal_set_led_src(0x0, 0x1f); /* software ctrl */
+ hal_set_leds(0x0, 0x1f); mdelay(300);
+ hal_set_leds(LED_E, LED_E); mdelay(300);
+ hal_set_leds(LED_C, LED_C); mdelay(300);
+ hal_set_leds(LED_A, LED_A); mdelay(300);
+ for (int i = 0; i < 3; i++){ //blink all
+ static const int blinks = LED_E | LED_C | LED_A;
+ hal_set_leds(0x0, 0x1f); mdelay(100);
+ hal_set_leds(blinks, 0x1f); mdelay(100);
+ }
+ hal_set_led_src(0x1f & ~LED_D, 0x1f); /* hardware ctrl */
hal_set_leds(LED_D, 0x1f); // Leave one on
#if 0
@@ -85,6 +82,8 @@ u2_init(void)
printf("ad9510 reg[0x%x] = 0x%x\n", rr, vv);
}
#endif
-
+
+ output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN);
+
return true;
}
diff --git a/firmware/microblaze/lib/u2_init.h b/firmware/zpu/lib/u2_init.h
index 848bd88de..848bd88de 100644
--- a/firmware/microblaze/lib/u2_init.h
+++ b/firmware/zpu/lib/u2_init.h
diff --git a/firmware/microblaze/lib/udp_fw_update.h b/firmware/zpu/lib/udp_fw_update.h
index d25525bd2..d25525bd2 100644
--- a/firmware/microblaze/lib/udp_fw_update.h
+++ b/firmware/zpu/lib/udp_fw_update.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/CHANGELOG b/firmware/zpu/lwip/lwip-1.3.1/CHANGELOG
index a45765010..a45765010 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/CHANGELOG
+++ b/firmware/zpu/lwip/lwip-1.3.1/CHANGELOG
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/COPYING b/firmware/zpu/lwip/lwip-1.3.1/COPYING
index e23898b5e..e23898b5e 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/COPYING
+++ b/firmware/zpu/lwip/lwip-1.3.1/COPYING
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/FILES b/firmware/zpu/lwip/lwip-1.3.1/FILES
index 66253196f..66253196f 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/FILES
+++ b/firmware/zpu/lwip/lwip-1.3.1/FILES
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/README b/firmware/zpu/lwip/lwip-1.3.1/README
index 8dda4b468..8dda4b468 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/README
+++ b/firmware/zpu/lwip/lwip-1.3.1/README
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/doc/FILES b/firmware/zpu/lwip/lwip-1.3.1/doc/FILES
index 05d356f4f..05d356f4f 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/doc/FILES
+++ b/firmware/zpu/lwip/lwip-1.3.1/doc/FILES
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/doc/contrib.txt b/firmware/zpu/lwip/lwip-1.3.1/doc/contrib.txt
index 39596fca3..39596fca3 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/doc/contrib.txt
+++ b/firmware/zpu/lwip/lwip-1.3.1/doc/contrib.txt
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/doc/rawapi.txt b/firmware/zpu/lwip/lwip-1.3.1/doc/rawapi.txt
index 8eec6e786..8eec6e786 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/doc/rawapi.txt
+++ b/firmware/zpu/lwip/lwip-1.3.1/doc/rawapi.txt
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/doc/savannah.txt b/firmware/zpu/lwip/lwip-1.3.1/doc/savannah.txt
index 409905b10..409905b10 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/doc/savannah.txt
+++ b/firmware/zpu/lwip/lwip-1.3.1/doc/savannah.txt
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/doc/snmp_agent.txt b/firmware/zpu/lwip/lwip-1.3.1/doc/snmp_agent.txt
index 9b58616a6..9b58616a6 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/doc/snmp_agent.txt
+++ b/firmware/zpu/lwip/lwip-1.3.1/doc/snmp_agent.txt
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/doc/sys_arch.txt b/firmware/zpu/lwip/lwip-1.3.1/doc/sys_arch.txt
index 66310a91e..66310a91e 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/doc/sys_arch.txt
+++ b/firmware/zpu/lwip/lwip-1.3.1/doc/sys_arch.txt
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/.hgignore b/firmware/zpu/lwip/lwip-1.3.1/src/.hgignore
index f88587df3..f88587df3 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/.hgignore
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/.hgignore
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/FILES b/firmware/zpu/lwip/lwip-1.3.1/src/FILES
index 952aeabb4..952aeabb4 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/FILES
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/FILES
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/api_lib.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/api_lib.c
index 86df911ea..86df911ea 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/api_lib.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/api_lib.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/api_msg.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/api_msg.c
index 28d101019..28d101019 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/api_msg.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/api_msg.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/err.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/err.c
index a90cb98c8..a90cb98c8 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/err.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/err.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/netbuf.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/netbuf.c
index af44eefc7..af44eefc7 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/netbuf.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/netbuf.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/netdb.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/netdb.c
index 8aa237f4c..8aa237f4c 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/netdb.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/netdb.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/netifapi.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/netifapi.c
index 491837378..491837378 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/netifapi.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/netifapi.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/sockets.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/sockets.c
index f177261e1..f177261e1 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/sockets.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/sockets.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/api/tcpip.c b/firmware/zpu/lwip/lwip-1.3.1/src/api/tcpip.c
index 002df90b2..002df90b2 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/api/tcpip.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/api/tcpip.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/#tcp_out.c# b/firmware/zpu/lwip/lwip-1.3.1/src/core/#tcp_out.c#
index ca72d9dcc..ca72d9dcc 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/#tcp_out.c#
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/#tcp_out.c#
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/dhcp.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/dhcp.c
index df0f97881..df0f97881 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/dhcp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/dhcp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/dns.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/dns.c
index 62a2592e9..62a2592e9 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/dns.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/dns.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/init.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/init.c
index 277811a6a..277811a6a 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/init.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/init.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/autoip.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/autoip.c
index 367adb060..367adb060 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/autoip.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/autoip.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/icmp.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/icmp.c
index b97a587a7..b97a587a7 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/icmp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/icmp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/igmp.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/igmp.c
index 7c07bc465..7c07bc465 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/igmp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/igmp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/inet.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/inet.c
index 69baf1d50..69baf1d50 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/inet.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/inet.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/inet_chksum.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/inet_chksum.c
index 185881efd..185881efd 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/inet_chksum.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/inet_chksum.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip.c
index 7e404a9f3..7e404a9f3 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip_addr.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip_addr.c
index 94bf4678a..94bf4678a 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip_addr.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip_addr.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip_frag.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip_frag.c
index 1939d831b..1939d831b 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv4/ip_frag.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv4/ip_frag.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/README b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/README
index 362000486..362000486 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/README
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/README
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/icmp6.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/icmp6.c
index 4fcc89551..4fcc89551 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/icmp6.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/icmp6.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/inet6.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/inet6.c
index c3de85c09..c3de85c09 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/inet6.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/inet6.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/ip6.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/ip6.c
index 7e4342001..7e4342001 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/ip6.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/ip6.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/ip6_addr.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/ip6_addr.c
index 2da6cea42..2da6cea42 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/ipv6/ip6_addr.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/ipv6/ip6_addr.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/mem.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/mem.c
index b5f13ab3b..b5f13ab3b 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/mem.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/mem.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/memp.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/memp.c
index dfc32213d..dfc32213d 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/memp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/memp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/netif.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/netif.c
index c9b6b9b5e..c9b6b9b5e 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/netif.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/netif.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/pbuf.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/pbuf.c
index 50b22c354..50b22c354 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/pbuf.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/pbuf.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/raw.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/raw.c
index 589950e75..589950e75 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/raw.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/raw.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/asn1_dec.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/asn1_dec.c
index 650fb4037..650fb4037 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/asn1_dec.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/asn1_dec.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/asn1_enc.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/asn1_enc.c
index 77af6b4ba..77af6b4ba 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/asn1_enc.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/asn1_enc.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/mib2.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/mib2.c
index 33eeee66c..33eeee66c 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/mib2.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/mib2.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/mib_structs.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/mib_structs.c
index af8994ed2..af8994ed2 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/mib_structs.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/mib_structs.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/msg_in.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/msg_in.c
index d0c3c7534..d0c3c7534 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/msg_in.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/msg_in.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/msg_out.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/msg_out.c
index b705aaca7..b705aaca7 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/snmp/msg_out.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/snmp/msg_out.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/stats.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/stats.c
index a036d83bb..a036d83bb 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/stats.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/stats.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/sys.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/sys.c
index d1fbda4e6..d1fbda4e6 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/sys.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/sys.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/tcp.c
index 0f3fd41c3..0f3fd41c3 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/tcp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp_in.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/tcp_in.c
index 362a4a62d..362a4a62d 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp_in.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/tcp_in.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp_out.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/tcp_out.c
index ca72d9dcc..ca72d9dcc 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/tcp_out.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/tcp_out.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/core/udp.c b/firmware/zpu/lwip/lwip-1.3.1/src/core/udp.c
index d8d644d44..d8d644d44 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/core/udp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/core/udp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/autoip.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/autoip.h
index 076a2ed23..076a2ed23 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/autoip.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/autoip.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/icmp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/icmp.h
index ff838f43a..ff838f43a 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/icmp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/icmp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/igmp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/igmp.h
index 59c933f35..59c933f35 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/igmp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/igmp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet.h
index 6f30d0d12..6f30d0d12 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet_chksum.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet_chksum.h
index 5cae59cbd..5cae59cbd 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet_chksum.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/inet_chksum.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip.h
index 14eba3ca5..14eba3ca5 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_addr.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_addr.h
index f2e4c2233..f2e4c2233 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_addr.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_addr.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_frag.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_frag.h
index 380e604dc..380e604dc 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_frag.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv4/lwip/ip_frag.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/icmp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/icmp.h
index 87e9ffd96..87e9ffd96 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/icmp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/icmp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/inet.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/inet.h
index de1a0b636..de1a0b636 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/inet.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/inet.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip.h
index a01cfc65b..a01cfc65b 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip_addr.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip_addr.h
index b2d8ae566..b2d8ae566 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip_addr.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/ipv6/lwip/ip_addr.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/api.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/api.h
index f6b1f7434..f6b1f7434 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/api.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/api.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/api_msg.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/api_msg.h
index 4272d77cc..4272d77cc 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/api_msg.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/api_msg.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/arch.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/arch.h
index 3a5a0e4f2..3a5a0e4f2 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/arch.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/arch.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/debug.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/debug.h
index d5c4e4747..d5c4e4747 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/debug.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/debug.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/def.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/def.h
index d2ed251df..d2ed251df 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/def.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/def.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/dhcp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/dhcp.h
index 825dba6ec..825dba6ec 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/dhcp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/dhcp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/dns.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/dns.h
index e5f4b7a3d..e5f4b7a3d 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/dns.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/dns.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/err.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/err.h
index 696764454..696764454 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/err.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/err.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/init.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/init.h
index a4dc0577f..a4dc0577f 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/init.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/init.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/mem.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/mem.h
index 327c2049f..327c2049f 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/mem.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/mem.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/memp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/memp.h
index f0d073994..f0d073994 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/memp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/memp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/memp_std.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/memp_std.h
index 344690328..344690328 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/memp_std.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/memp_std.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netbuf.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netbuf.h
index 6d84dd073..6d84dd073 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netbuf.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netbuf.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netdb.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netdb.h
index 0f7b2ec04..0f7b2ec04 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netdb.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netdb.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netif.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netif.h
index a32503052..a32503052 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netif.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netif.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netifapi.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netifapi.h
index 36c6bd0a2..36c6bd0a2 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/netifapi.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/netifapi.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/opt.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/opt.h
index e8bd8b89e..e8bd8b89e 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/opt.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/opt.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/pbuf.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/pbuf.h
index 8380f65da..8380f65da 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/pbuf.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/pbuf.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/raw.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/raw.h
index 20b0a11bb..20b0a11bb 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/raw.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/raw.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sio.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sio.h
index 7d9162e49..7d9162e49 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sio.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sio.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp.h
index dd03d5d70..dd03d5d70 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_asn1.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_asn1.h
index 8a602881f..8a602881f 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_asn1.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_asn1.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_msg.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_msg.h
index b2f69c4be..b2f69c4be 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_msg.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_msg.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_structs.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_structs.h
index 9f3f8a94e..9f3f8a94e 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/snmp_structs.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/snmp_structs.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sockets.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sockets.h
index 7b52e151c..7b52e151c 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sockets.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sockets.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/stats.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/stats.h
index aa179f5c0..aa179f5c0 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/stats.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/stats.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sys.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sys.h
index 0cc84ddf1..0cc84ddf1 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/sys.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/sys.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/tcp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/tcp.h
index 8f6b9d3c1..8f6b9d3c1 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/tcp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/tcp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/tcpip.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/tcpip.h
index 75393ee91..75393ee91 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/tcpip.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/tcpip.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/udp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/udp.h
index d7b2a3820..d7b2a3820 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/lwip/udp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/lwip/udp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/etharp.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/etharp.h
index db691d91d..db691d91d 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/etharp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/etharp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/loopif.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/loopif.h
index 304af4b39..304af4b39 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/loopif.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/loopif.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/ppp_oe.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/ppp_oe.h
index 3aa55aec7..3aa55aec7 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/ppp_oe.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/ppp_oe.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/slipif.h b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/slipif.h
index aa08ada4a..aa08ada4a 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/include/netif/slipif.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/include/netif/slipif.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/FILES b/firmware/zpu/lwip/lwip-1.3.1/src/netif/FILES
index 1c4f5928d..1c4f5928d 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/FILES
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/FILES
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/etharp.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/etharp.c
index 73ea21173..73ea21173 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/etharp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/etharp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ethernetif.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ethernetif.c
index ccd7bd67f..ccd7bd67f 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ethernetif.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ethernetif.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/loopif.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/loopif.c
index 1e1f28cf1..1e1f28cf1 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/loopif.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/loopif.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/auth.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/auth.c
index 4c0ee6a8e..4c0ee6a8e 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/auth.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/auth.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/auth.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/auth.h
index 86ff04945..86ff04945 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/auth.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/auth.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chap.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chap.c
index 6d9c3c3ce..6d9c3c3ce 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chap.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chap.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chap.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chap.h
index 83dafd734..83dafd734 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chap.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chap.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chpms.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chpms.c
index 0c7521f20..0c7521f20 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chpms.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chpms.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chpms.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chpms.h
index df070fb35..df070fb35 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/chpms.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/chpms.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/fsm.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/fsm.c
index c073f1e36..c073f1e36 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/fsm.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/fsm.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/fsm.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/fsm.h
index 14034ec7f..14034ec7f 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/fsm.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/fsm.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ipcp.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ipcp.c
index 3a403a0a6..3a403a0a6 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ipcp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ipcp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ipcp.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ipcp.h
index dfcf4fba6..dfcf4fba6 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ipcp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ipcp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/lcp.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/lcp.c
index 85a0add95..85a0add95 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/lcp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/lcp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/lcp.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/lcp.h
index 1a5e5a4c0..1a5e5a4c0 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/lcp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/lcp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/magic.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/magic.c
index d3922bb56..d3922bb56 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/magic.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/magic.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/magic.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/magic.h
index bc5174993..bc5174993 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/magic.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/magic.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/md5.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/md5.c
index d65ecedbf..d65ecedbf 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/md5.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/md5.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/md5.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/md5.h
index e129533f3..e129533f3 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/md5.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/md5.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pap.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pap.c
index 7c3fd7e4c..7c3fd7e4c 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pap.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pap.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pap.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pap.h
index 0a09fc841..0a09fc841 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pap.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pap.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp.c
index 8720c3368..8720c3368 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp.h
index d5caa0a7e..d5caa0a7e 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp_oe.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp_oe.c
index c34c529b6..c34c529b6 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/ppp_oe.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/ppp_oe.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pppdebug.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pppdebug.h
index 6253863c9..6253863c9 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/pppdebug.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/pppdebug.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/randm.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/randm.c
index 0c622a0b0..0c622a0b0 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/randm.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/randm.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/randm.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/randm.h
index a0984b020..a0984b020 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/randm.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/randm.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vj.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vj.c
index 814ea72c5..814ea72c5 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vj.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vj.c
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vj.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vj.h
index b9617da4d..b9617da4d 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vj.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vj.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vjbsdhdr.h b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vjbsdhdr.h
index f46267614..f46267614 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/ppp/vjbsdhdr.h
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/ppp/vjbsdhdr.h
diff --git a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/slipif.c b/firmware/zpu/lwip/lwip-1.3.1/src/netif/slipif.c
index 6cb2db442..6cb2db442 100644
--- a/firmware/microblaze/lwip/lwip-1.3.1/src/netif/slipif.c
+++ b/firmware/zpu/lwip/lwip-1.3.1/src/netif/slipif.c
diff --git a/firmware/microblaze/lwip/lwipopts.h b/firmware/zpu/lwip/lwipopts.h
index 3839eea83..3839eea83 100644
--- a/firmware/microblaze/lwip/lwipopts.h
+++ b/firmware/zpu/lwip/lwipopts.h
diff --git a/firmware/microblaze/lwip/lwippools.h b/firmware/zpu/lwip/lwippools.h
index caee23c82..caee23c82 100644
--- a/firmware/microblaze/lwip/lwippools.h
+++ b/firmware/zpu/lwip/lwippools.h
diff --git a/firmware/microblaze/lwip_port/arch/cc.h b/firmware/zpu/lwip_port/arch/cc.h
index d8d53ecf8..d8d53ecf8 100644
--- a/firmware/microblaze/lwip_port/arch/cc.h
+++ b/firmware/zpu/lwip_port/arch/cc.h
diff --git a/firmware/microblaze/lwip_port/arch/perf.h b/firmware/zpu/lwip_port/arch/perf.h
index f0906d03f..f0906d03f 100644
--- a/firmware/microblaze/lwip_port/arch/perf.h
+++ b/firmware/zpu/lwip_port/arch/perf.h
diff --git a/firmware/microblaze/lwip_port/netif/eth_driver.c b/firmware/zpu/lwip_port/netif/eth_driver.c
index 18c6eaf3e..18c6eaf3e 100644
--- a/firmware/microblaze/lwip_port/netif/eth_driver.c
+++ b/firmware/zpu/lwip_port/netif/eth_driver.c
diff --git a/firmware/microblaze/lwip_port/netif/eth_driver.h b/firmware/zpu/lwip_port/netif/eth_driver.h
index 72a212091..72a212091 100644
--- a/firmware/microblaze/lwip_port/netif/eth_driver.h
+++ b/firmware/zpu/lwip_port/netif/eth_driver.h
diff --git a/firmware/zpu/usrp2/CMakeLists.txt b/firmware/zpu/usrp2/CMakeLists.txt
new file mode 100644
index 000000000..e54499084
--- /dev/null
+++ b/firmware/zpu/usrp2/CMakeLists.txt
@@ -0,0 +1,37 @@
+#
+# Copyright 2010-2011 Ettus Research LLC
+#
+# 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/>.
+#
+
+########################################################################
+INCLUDE(${CMAKE_SOURCE_DIR}/lib/CMakeLists.txt)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+ADD_LIBRARY(libusrp2fw STATIC
+ ${COMMON_SRCS}
+ sd.c
+ ethernet.c
+)
+
+########################################################################
+SET(GEN_OUTPUTS_BIN_SIZE 0x3fff)
+
+ADD_EXECUTABLE(usrp2_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c)
+TARGET_LINK_LIBRARIES(usrp2_txrx_uhd.elf libusrp2fw)
+GEN_OUTPUTS(usrp2_txrx_uhd.elf)
+
+ADD_EXECUTABLE(usrp2_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c)
+TARGET_LINK_LIBRARIES(usrp2_blinkenlights.elf libusrp2fw)
+GEN_OUTPUTS(usrp2_blinkenlights.elf)
diff --git a/firmware/microblaze/usrp2/eth_phy.h b/firmware/zpu/usrp2/eth_phy.h
index 6c16f97b7..6c16f97b7 100644
--- a/firmware/microblaze/usrp2/eth_phy.h
+++ b/firmware/zpu/usrp2/eth_phy.h
diff --git a/firmware/microblaze/usrp2/ethernet.c b/firmware/zpu/usrp2/ethernet.c
index 5d4654bda..5d4654bda 100644
--- a/firmware/microblaze/usrp2/ethernet.c
+++ b/firmware/zpu/usrp2/ethernet.c
diff --git a/firmware/microblaze/usrp2/memory_map.h b/firmware/zpu/usrp2/memory_map.h
index eac0c217f..e728a1ddb 100644
--- a/firmware/microblaze/usrp2/memory_map.h
+++ b/firmware/zpu/usrp2/memory_map.h
@@ -18,7 +18,7 @@
/* Overall Memory Map
* 0000-7FFF 32K RAM space (16K on 1500, 24K on 2000, 32K on DSP)
- * 8000-BFFF 16K Buffer Pool
+ * 8000-BFFF 16K Packet Router
* C000-FFFF 16K Peripherals
*/
@@ -45,23 +45,13 @@
#define RAM_BASE 0x0000
////////////////////////////////////////////////////////////////
-// Buffer Pool RAM, Slave 1
+// Packet Router RAM, Slave 1
//
-// The buffers themselves are located in Slave 1, Buffer Pool RAM.
-// The status registers are in Slave 5, Buffer Pool Status.
+// The buffers themselves are located in Slave 1, Packet Router RAM.
+// The status registers are in Slave 5, Packet Router Status.
// The control register is in Slave 7, Settings Bus.
-#define BUFFER_POOL_RAM_BASE 0x8000
-
-#define NBUFFERS 8
-#define BP_NLINES 0x0200 // number of 32-bit lines in a buffer
-#define BP_LAST_LINE (BP_NLINES - 1) // last line in a buffer
-
-#define buffer_pool_ram \
- ((uint32_t *) BUFFER_POOL_RAM_BASE)
-
-#define buffer_ram(n) (&buffer_pool_ram[(n) * BP_NLINES])
-
+#define ROUTER_RAM_BASE 0x8000
/////////////////////////////////////////////////////
// SPI Core, Slave 2. See core docs for more info
@@ -164,93 +154,25 @@ typedef struct {
#define gpio_base ((gpio_regs_t *) GPIO_BASE)
///////////////////////////////////////////////////
-// Buffer Pool Status, Slave 5
+// Packet Router Status, Slave 5
//
-// The buffers themselves are located in Slave 1, Buffer Pool RAM.
-// The status registers are in Slave 5, Buffer Pool Status.
+// The buffers themselves are located in Slave 1, Packet Router RAM.
+// The status registers are in Slave 5, Packet Router Status.
// The control register is in Slave 7, Settings Bus.
-#define BUFFER_POOL_STATUS_BASE 0xCC00
+#define ROUTER_STATUS_BASE 0xCC00
typedef struct {
- volatile uint32_t last_line[NBUFFERS]; // last line xfer'd in buffer
- volatile uint32_t status; // error and done flags
+ volatile uint32_t _padding[8];
+ volatile uint32_t status;
volatile uint32_t hw_config; // see below
- volatile uint32_t dummy[3];
+ volatile uint32_t time64_secs_rb;
+ volatile uint32_t time64_ticks_rb;
+ volatile uint32_t compat_num;
volatile uint32_t irqs;
- volatile uint32_t pri_enc_bp_status;
- volatile uint32_t cycle_count;
-} buffer_pool_status_t;
-
-#define buffer_pool_status ((buffer_pool_status_t *) BUFFER_POOL_STATUS_BASE)
-
-/*
- * Buffer n's xfer is done.
- * Clear this bit by issuing bp_clear_buf(n)
- */
-#define BPS_DONE(n) (0x00000001 << (n))
-#define BPS_DONE_0 BPS_DONE(0)
-#define BPS_DONE_1 BPS_DONE(1)
-#define BPS_DONE_2 BPS_DONE(2)
-#define BPS_DONE_3 BPS_DONE(3)
-#define BPS_DONE_4 BPS_DONE(4)
-#define BPS_DONE_5 BPS_DONE(5)
-#define BPS_DONE_6 BPS_DONE(6)
-#define BPS_DONE_7 BPS_DONE(7)
-
-/*
- * Buffer n's xfer had an error.
- * Clear this bit by issuing bp_clear_buf(n)
- */
-#define BPS_ERROR(n) (0x00000100 << (n))
-#define BPS_ERROR_0 BPS_ERROR(0)
-#define BPS_ERROR_1 BPS_ERROR(1)
-#define BPS_ERROR_2 BPS_ERROR(2)
-#define BPS_ERROR_3 BPS_ERROR(3)
-#define BPS_ERROR_4 BPS_ERROR(4)
-#define BPS_ERROR_5 BPS_ERROR(5)
-#define BPS_ERROR_6 BPS_ERROR(6)
-#define BPS_ERROR_7 BPS_ERROR(7)
-
-/*
- * Buffer n is idle. A buffer is idle if it's not
- * DONE, ERROR, or processing a transaction. If it's
- * IDLE, it's safe to start a new transaction.
- *
- * Clear this bit by starting a xfer with
- * bp_send_from_buf or bp_receive_to_buf.
- */
-#define BPS_IDLE(n) (0x00010000 << (n))
-#define BPS_IDLE_0 BPS_IDLE(0)
-#define BPS_IDLE_1 BPS_IDLE(1)
-#define BPS_IDLE_2 BPS_IDLE(2)
-#define BPS_IDLE_3 BPS_IDLE(3)
-#define BPS_IDLE_4 BPS_IDLE(4)
-#define BPS_IDLE_5 BPS_IDLE(5)
-#define BPS_IDLE_6 BPS_IDLE(6)
-#define BPS_IDLE_7 BPS_IDLE(7)
+} router_status_t;
-/*
- * Buffer n has a "slow path" packet in it.
- * This bit is orthogonal to the bits above and indicates that
- * the FPGA ethernet rx protocol engine has identified this packet
- * as one requiring firmware intervention.
- */
-#define BPS_SLOWPATH(n) (0x01000000 << (n))
-#define BPS_SLOWPATH_0 BPS_SLOWPATH(0)
-#define BPS_SLOWPATH_1 BPS_SLOWPATH(1)
-#define BPS_SLOWPATH_2 BPS_SLOWPATH(2)
-#define BPS_SLOWPATH_3 BPS_SLOWPATH(3)
-#define BPS_SLOWPATH_4 BPS_SLOWPATH(4)
-#define BPS_SLOWPATH_5 BPS_SLOWPATH(5)
-#define BPS_SLOWPATH_6 BPS_SLOWPATH(6)
-#define BPS_SLOWPATH_7 BPS_SLOWPATH(7)
-
-
-#define BPS_DONE_ALL 0x000000ff // mask of all dones
-#define BPS_ERROR_ALL 0x0000ff00 // mask of all errors
-#define BPS_IDLE_ALL 0x00ff0000 // mask of all idles
-#define BPS_SLOWPATH_ALL 0xff000000 // mask of all slowpaths
+#define router_status ((router_status_t *) ROUTER_STATUS_BASE)
// The hw_config register
@@ -263,7 +185,7 @@ typedef struct {
inline static int
hwconfig_simulation_p(void)
{
- return buffer_pool_status->hw_config & HWC_SIMULATION;
+ return router_status->hw_config & HWC_SIMULATION;
}
/*!
@@ -273,7 +195,7 @@ hwconfig_simulation_p(void)
inline static int
hwconfig_wishbone_divisor(void)
{
- return buffer_pool_status->hw_config & HWC_WB_CLK_DIV_MASK;
+ return router_status->hw_config & HWC_WB_CLK_DIV_MASK;
}
///////////////////////////////////////////////////
@@ -295,13 +217,13 @@ hwconfig_wishbone_divisor(void)
#define MISC_OUTPUT_BASE 0xD400
#define TX_PROTOCOL_ENGINE_BASE 0xD480
#define RX_PROTOCOL_ENGINE_BASE 0xD4C0
-#define BUFFER_POOL_CTRL_BASE 0xD500
+#define ROUTER_CTRL_BASE 0xD500
#define LAST_SETTING_REG 0xD7FC // last valid setting register
#define SR_MISC 0
#define SR_TX_PROT_ENG 32
#define SR_RX_PROT_ENG 48
-#define SR_BUFFER_POOL_CTRL 64
+#define SR_ROUTER_CTRL 64
#define SR_UDP_SM 96
#define SR_TX_DSP 208
#define SR_TX_CTRL 224
@@ -313,53 +235,16 @@ hwconfig_wishbone_divisor(void)
#define _SR_ADDR(sr) (MISC_OUTPUT_BASE + (sr) * sizeof(uint32_t))
-// --- buffer pool control regs ---
+// --- packet router control regs ---
typedef struct {
- volatile uint32_t ctrl;
-} buffer_pool_ctrl_t;
-
-// buffer pool ports
-
-#define PORT_SERDES 0 // serial/deserializer
-#define PORT_DSP 1 // DSP tx or rx pipeline
-#define PORT_ETH 2 // ethernet tx or rx
-#define PORT_RAM 3 // RAM tx or rx
-
-// the buffer pool ctrl register fields
-
-#define BPC_BUFFER(n) (((n) & 0xf) << 28)
-#define BPC_BUFFER_MASK BPC_BUFFER(~0)
-#define BPC_BUFFER_0 BPC_BUFFER(0)
-#define BPC_BUFFER_1 BPC_BUFFER(1)
-#define BPC_BUFFER_2 BPC_BUFFER(2)
-#define BPC_BUFFER_3 BPC_BUFFER(3)
-#define BPC_BUFFER_4 BPC_BUFFER(4)
-#define BPC_BUFFER_5 BPC_BUFFER(5)
-#define BPC_BUFFER_6 BPC_BUFFER(6)
-#define BPC_BUFFER_7 BPC_BUFFER(7)
-#define BPC_BUFFER_NIL BPC_BUFFER(0x8) // disable
-
-#define BPC_PORT(n) (((n) & 0x7) << 25)
-#define BPC_PORT_MASK BPC_PORT(~0)
-#define BPC_PORT_SERDES BPC_PORT(PORT_SERDES)
-#define BPC_PORT_DSP BPC_PORT(PORT_DSP)
-#define BPC_PORT_ETH BPC_PORT(PORT_ETH)
-#define BPC_PORT_RAM BPC_PORT(PORT_RAM)
-#define BPC_PORT_NIL BPC_PORT(0x4) // disable
-
-#define BPC_CLR (1 << 24) // mutually excl commands
-#define BPC_READ (1 << 23)
-#define BPC_WRITE (1 << 22)
-
-#define BPC_STEP(step) (((step) & 0xf) << 18)
-#define BPC_STEP_MASK BPC_STEP(~0)
-#define BPC_LAST_LINE(line) (((line) & 0x1ff) << 9)
-#define BPC_LAST_LINE_MASK BPC_LAST_LINE(~0)
-#define BPC_FIRST_LINE(line) (((line) & 0x1ff) << 0)
-#define BPC_FIRST_LINE_MASK BPC_FIRST_LINE(~0)
-
-#define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE)
+ volatile uint32_t mode_ctrl;
+ volatile uint32_t ip_addr;
+ volatile uint32_t data_ports; //dsp0 (low 16) dsp1 (high 16)
+ volatile uint32_t iface_ctrl;
+} router_ctrl_t;
+
+#define router_ctrl ((router_ctrl_t *) ROUTER_CTRL_BASE)
// --- misc outputs ---
@@ -435,11 +320,21 @@ typedef struct {
uint32_t length;
uint32_t checksum; //word 22
} udp_hdr;
- volatile uint32_t _pad[32-23];
+ volatile uint32_t _pad[1];
+ volatile uint32_t dsp0_port;
+ volatile uint32_t err0_port;
+ volatile uint32_t dsp1_port;
+ volatile uint32_t err1_port;
} sr_udp_sm_t;
// control bits (all expect UDP_SM_LAST_WORD are mutually exclusive)
+// Insert a UDP source port from the table
+#define UDP_SM_INS_UDP_SRC_PORT (1 << 21)
+
+// Insert a UDP dest port from the table
+#define UDP_SM_INS_UDP_DST_PORT (1 << 20)
+
// This is the last word of the header
#define UDP_SM_LAST_WORD (1 << 19)
diff --git a/firmware/microblaze/usrp2/sd.c b/firmware/zpu/usrp2/sd.c
index d000b28ae..d634baea8 100644
--- a/firmware/microblaze/usrp2/sd.c
+++ b/firmware/zpu/usrp2/sd.c
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2008 Ettus Research LLC
+ * Copyright 2008-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2/sd.h b/firmware/zpu/usrp2/sd.h
index e2d0ae38e..e4b4aae8b 100644
--- a/firmware/microblaze/usrp2/sd.h
+++ b/firmware/zpu/usrp2/sd.h
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2008 Ettus Research LLC
+ * Copyright 2008-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/zpu/usrp2p/CMakeLists.txt b/firmware/zpu/usrp2p/CMakeLists.txt
new file mode 100644
index 000000000..c7ab9abdb
--- /dev/null
+++ b/firmware/zpu/usrp2p/CMakeLists.txt
@@ -0,0 +1,51 @@
+#
+# Copyright 2010-2011 Ettus Research LLC
+#
+# 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/>.
+#
+
+########################################################################
+INCLUDE(${CMAKE_SOURCE_DIR}/lib/CMakeLists.txt)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+ADD_DEFINITIONS(-DUSRP2P)
+
+ADD_LIBRARY(libusrp2pfw STATIC
+ ${COMMON_SRCS}
+ spif.c
+ spi_flash.c
+ spi_flash_read.c
+ bootloader_utils.c
+ ethernet.c
+ xilinx_s3_icap.c
+ udp_fw_update.c
+ u2p_init.c
+)
+
+ADD_SUBDIRECTORY(bootloader)
+
+########################################################################
+SET(GEN_OUTPUTS_BIN_SIZE 0x3fff)
+
+ADD_EXECUTABLE(usrp2p_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c)
+TARGET_LINK_LIBRARIES(usrp2p_txrx_uhd.elf libusrp2pfw)
+GEN_OUTPUTS(usrp2p_txrx_uhd.elf)
+
+ADD_EXECUTABLE(usrp2p_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c)
+TARGET_LINK_LIBRARIES(usrp2p_blinkenlights.elf libusrp2pfw)
+GEN_OUTPUTS(usrp2p_blinkenlights.elf)
+
+ADD_EXECUTABLE(usrp2p_uart_flash_loader.elf ${CMAKE_SOURCE_DIR}/apps/uart_flash_loader.c)
+TARGET_LINK_LIBRARIES(usrp2p_uart_flash_loader.elf libusrp2pfw)
+GEN_OUTPUTS(usrp2p_uart_flash_loader.elf)
diff --git a/firmware/microblaze/usrp2p/bootconfig.h b/firmware/zpu/usrp2p/bootconfig.h
index 35c2726ed..b64834d22 100644
--- a/firmware/microblaze/usrp2p/bootconfig.h
+++ b/firmware/zpu/usrp2p/bootconfig.h
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* This file is part of GNU Radio
*
diff --git a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt
new file mode 100644
index 000000000..2c7efb43a
--- /dev/null
+++ b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt
@@ -0,0 +1,40 @@
+#
+# Copyright 2010-2011 Ettus Research LLC
+#
+# 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/>.
+#
+
+########################################################################
+INCLUDE(FindPythonInterp)
+
+MACRO(GEN_RMI target)
+ GET_FILENAME_COMPONENT(name ${target} NAME_WE)
+ #command to create a rmi from elf
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${name}.rmi DEPENDS ${name}.bin
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${CMAKE_SOURCE_DIR}/bin/bin_to_ram_macro_init.py ${name}.bin ${name}.rmi
+ )
+ #add a top level target for output files
+ ADD_CUSTOM_TARGET(
+ ${name}_rmi ALL DEPENDS ${name}.rmi
+ )
+ENDMACRO(GEN_RMI)
+
+########################################################################
+ADD_EXECUTABLE(init_bootloader.elf init_bootloader.c)
+TARGET_LINK_LIBRARIES(init_bootloader.elf libusrp2pfw)
+SET(GEN_OUTPUTS_BIN_SIZE 0x1fff)
+GEN_OUTPUTS(init_bootloader.elf)
+GEN_RMI(init_bootloader.bin)
diff --git a/firmware/microblaze/usrp2p/bootloader/fpga_bootloader.c b/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c
index 9feff6ecd..f5a71a8bb 100644
--- a/firmware/microblaze/usrp2p/bootloader/fpga_bootloader.c
+++ b/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2p/bootloader/fw_bootloader.c b/firmware/zpu/usrp2p/bootloader/fw_bootloader.c
index a2c32bf8e..de561cf22 100644
--- a/firmware/microblaze/usrp2p/bootloader/fw_bootloader.c
+++ b/firmware/zpu/usrp2p/bootloader/fw_bootloader.c
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2p/bootloader/icap_test.c b/firmware/zpu/usrp2p/bootloader/icap_test.c
index 5feb9d014..5feb9d014 100644
--- a/firmware/microblaze/usrp2p/bootloader/icap_test.c
+++ b/firmware/zpu/usrp2p/bootloader/icap_test.c
diff --git a/firmware/microblaze/usrp2p/bootloader/init_bootloader.c b/firmware/zpu/usrp2p/bootloader/init_bootloader.c
index 1d9d681d7..f8b432c46 100644
--- a/firmware/microblaze/usrp2p/bootloader/init_bootloader.c
+++ b/firmware/zpu/usrp2p/bootloader/init_bootloader.c
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2010 Ettus Research LLC
+ * Copyright 2010-2011 Ettus Research LLC
*
*/
@@ -11,6 +11,7 @@
#include <spi_flash.h>
#include <spi_flash_private.h>
//#include <clocks.h>
+#include <mdelay.h>
#include <ihex.h>
#include <bootloader_utils.h>
#include <string.h>
@@ -18,7 +19,7 @@
#include <i2c.h>
#include "usrp2/fw_common.h"
-void pic_interrupt_handler() __attribute__ ((interrupt_handler));
+//void pic_interrupt_handler() __attribute__ ((interrupt_handler));
void pic_interrupt_handler()
{
@@ -42,26 +43,22 @@ void load_ihex(void) { //simple IHEX parser to load proper records into RAM. loa
} else if(ihex_record.type == 1) { //end of record
puts("OK");
//load main firmware
- start_program(RAM_BASE);
+ start_program();
puts("ERROR: main image returned! Back in IHEX load mode.");
} else puts("NOK"); //RAM loads do not support extended segment address records (04) -- upper 16 bits are always "0".
} else puts("NOK");
}
}
-void delay(uint32_t t) {
- while(t-- != 0) asm("NOP");
-}
-
int main(int argc, char *argv[]) {
- hal_disable_ints(); // In case we got here via jmp 0x0
+ hal_disable_ints(); // In case we got here via jmp 0x0
output_regs->leds = 0xFF;
- delay(500000);
+ mdelay(100);
output_regs->leds = 0x00;
hal_uart_init();
spif_init();
i2c_init(); //for EEPROM
- puts("USRP2+ bootloader\n");
+ puts("USRP2+ bootloader super ultra ZPU edition\n");
bool production_image = find_safe_booted_flag();
set_safe_booted_flag(0); //haven't booted yet
@@ -71,7 +68,7 @@ int main(int argc, char *argv[]) {
if(is_valid_fw_image(SAFE_FW_IMAGE_LOCATION_ADDR)) {
set_safe_booted_flag(1); //let the firmware know it's the safe image
spi_flash_read(SAFE_FW_IMAGE_LOCATION_ADDR, FW_IMAGE_SIZE_BYTES, (void *)RAM_BASE);
- start_program(RAM_BASE);
+ start_program();
puts("ERROR: return from main program! This should never happen!");
icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR);
} else {
@@ -85,7 +82,7 @@ int main(int argc, char *argv[]) {
if(is_valid_fpga_image(PROD_FPGA_IMAGE_LOCATION_ADDR)) {
puts("Valid production FPGA image found. Attempting to boot.");
set_safe_booted_flag(1);
- delay(30000); //so serial output can finish
+ mdelay(300); //so serial output can finish
icap_reload_fpga(PROD_FPGA_IMAGE_LOCATION_ADDR);
}
puts("No valid production FPGA image found.\nAttempting to load production firmware...");
@@ -93,17 +90,23 @@ int main(int argc, char *argv[]) {
if(is_valid_fw_image(PROD_FW_IMAGE_LOCATION_ADDR)) {
puts("Valid production firmware found. Loading...");
spi_flash_read(PROD_FW_IMAGE_LOCATION_ADDR, FW_IMAGE_SIZE_BYTES, (void *)RAM_BASE);
- start_program(RAM_BASE);
+ puts("Finished loading. Starting image.");
+ mdelay(300);
+ start_program();
puts("ERROR: Return from main program! This should never happen!");
//if this happens, though, the safest thing to do is reboot the whole FPGA and start over.
+ mdelay(300);
icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR);
return 1;
}
puts("No valid production firmware found. Trying safe firmware...");
if(is_valid_fw_image(SAFE_FW_IMAGE_LOCATION_ADDR)) {
spi_flash_read(SAFE_FW_IMAGE_LOCATION_ADDR, FW_IMAGE_SIZE_BYTES, (void *)RAM_BASE);
- start_program(RAM_BASE);
+ puts("Finished loading. Starting image.");
+ mdelay(300);
+ start_program();
puts("ERROR: return from main program! This should never happen!");
+ mdelay(300);
icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR);
return 1;
}
diff --git a/firmware/microblaze/usrp2p/bootloader/serial_loader_burner.c b/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c
index 4ac4df454..6d5d135ab 100644
--- a/firmware/microblaze/usrp2p/bootloader/serial_loader_burner.c
+++ b/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2p/bootloader/spi_bootloader.c b/firmware/zpu/usrp2p/bootloader/spi_bootloader.c
index 678e66cf7..3e66d41cb 100644
--- a/firmware/microblaze/usrp2p/bootloader/spi_bootloader.c
+++ b/firmware/zpu/usrp2p/bootloader/spi_bootloader.c
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2p/bootloader/u2p2-rom.ld b/firmware/zpu/usrp2p/bootloader/u2p2-rom.ld
index 4c9eaa8e5..4c9eaa8e5 100644
--- a/firmware/microblaze/usrp2p/bootloader/u2p2-rom.ld
+++ b/firmware/zpu/usrp2p/bootloader/u2p2-rom.ld
diff --git a/firmware/zpu/usrp2p/bootloader_utils.c b/firmware/zpu/usrp2p/bootloader_utils.c
new file mode 100644
index 000000000..371c518a7
--- /dev/null
+++ b/firmware/zpu/usrp2p/bootloader_utils.c
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 Ettus Research LLC
+ *
+ */
+
+//contains routines for loading programs from Flash. depends on Flash libraries.
+//also contains routines for reading / writing EEPROM flags for the bootloader
+#include <stdbool.h>
+#include <string.h>
+#include <bootloader_utils.h>
+#include <spi_flash.h>
+#include <memory_map.h>
+#include <nonstdio.h>
+
+int is_valid_fpga_image(uint32_t addr) {
+// printf("is_valid_fpga_image(): starting with addr=%x...\n", addr);
+ uint8_t imgbuf[64];
+ spi_flash_read(addr, 64, imgbuf);
+ //we're just looking for leading 0xFF padding, followed by the sync bytes 0xAA 0x99
+ for(size_t i = 0; i<63; i++) {
+ if(imgbuf[i] == 0xFF) continue;
+ if(imgbuf[i] == 0xAA && imgbuf[i+1] == 0x99) {
+ //printf("is_valid_fpga_image(): found valid FPGA image\n");
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+int is_valid_fw_image(uint32_t addr) {
+ static const uint8_t fwheader[] = {0x0b, 0x0b, 0x0b, 0x0b}; //just lookin for a jump to anywhere located at the reset vector
+ //printf("is_valid_fw_image(): starting with addr=%x...\n", addr);
+ uint8_t buf[12];
+ spi_flash_read(addr, 4, buf);
+ //printf("is_valid_fw_image(): read ");
+ //for(int i = 0; i < 5; i++) printf("%x ", buf[i]);
+ //printf("\n");
+ return memcmp(buf, fwheader, 4) == 0;
+}
+
+void start_program(void)
+{
+ //ignoring the addr now
+ //all this does is tap that register
+ *((volatile uint32_t *) SR_ADDR_BLDRDONE) = 1;
+}
diff --git a/firmware/microblaze/usrp2p/bootloader_utils.h b/firmware/zpu/usrp2p/bootloader_utils.h
index f597c0113..0f49ae6cd 100644
--- a/firmware/microblaze/usrp2p/bootloader_utils.h
+++ b/firmware/zpu/usrp2p/bootloader_utils.h
@@ -9,8 +9,8 @@
//we're working in bytes and byte addresses so we can run the same code with Flash chips of different sector sizes.
//it's really 1463736, but rounded up to 1.5MB
#define FPGA_IMAGE_SIZE_BYTES 1572864
-//instead of 32K, we write 31K because we're using the top 1K for stack space!
-#define FW_IMAGE_SIZE_BYTES 31744
+//16K
+#define FW_IMAGE_SIZE_BYTES 0x3fff
#define SAFE_FPGA_IMAGE_LOCATION_ADDR 0x00000000
#define SAFE_FW_IMAGE_LOCATION_ADDR 0x003F0000
@@ -19,4 +19,4 @@
int is_valid_fpga_image(uint32_t addr);
int is_valid_fw_image(uint32_t addr);
-void start_program(uint32_t addr);
+void start_program(void);
diff --git a/firmware/microblaze/usrp2p/eth_phy.h b/firmware/zpu/usrp2p/eth_phy.h
index d233e96e8..d233e96e8 100644
--- a/firmware/microblaze/usrp2p/eth_phy.h
+++ b/firmware/zpu/usrp2p/eth_phy.h
diff --git a/firmware/microblaze/usrp2p/ethernet.c b/firmware/zpu/usrp2p/ethernet.c
index 36d6a17ca..03891f959 100644
--- a/firmware/microblaze/usrp2p/ethernet.c
+++ b/firmware/zpu/usrp2p/ethernet.c
@@ -279,101 +279,6 @@ ethernet_init(void)
eth_mac_miim_write(PHY_CTRL, t | MII_CR_RESTART_AUTO_NEG);
}
-static bool
-unprogrammed(const void *t, size_t len)
-{
- int i;
- uint8_t *p = (uint8_t *)t;
- bool all_zeros = true;
- bool all_ones = true;
- for (i = 0; i < len; i++){
- all_zeros &= p[i] == 0x00;
- all_ones &= p[i] == 0xff;
- }
- return all_ones | all_zeros;
-}
-
-//////////////////// MAC Addr Stuff ///////////////////////
-/*
-static int8_t src_mac_addr_initialized = false;
-static eth_mac_addr_t src_mac_addr = {{
- 0x00, 0x50, 0xC2, 0x85, 0x3f, 0xff
- }};
-
-const eth_mac_addr_t *
-ethernet_mac_addr(void)
-{
- if (!src_mac_addr_initialized){ // fetch from eeprom
- src_mac_addr_initialized = true;
-
- // if we're simulating, don't read the EEPROM model, it's REALLY slow
- if (hwconfig_simulation_p())
- return &src_mac_addr;
-
- eth_mac_addr_t tmp;
- bool ok = eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, &tmp, sizeof(tmp));
- if (!ok || unprogrammed(&tmp, sizeof(tmp))){
- // use the default
- }
- else
- src_mac_addr = tmp;
- }
-
- return &src_mac_addr;
-}
-
-bool
-ethernet_set_mac_addr(const eth_mac_addr_t *t)
-{
- bool ok = eeprom_write(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, t, sizeof(eth_mac_addr_t));
- if (ok){
- src_mac_addr = *t;
- src_mac_addr_initialized = true;
- //eth_mac_set_addr(t); //this breaks the link
- }
-
- return ok;
-}
-
-//////////////////// IP Addr Stuff ///////////////////////
-
-static int8_t src_ip_addr_initialized = false;
-static struct ip_addr src_ip_addr = {
- (192 << 24 | 168 << 16 | 10 << 8 | 2 << 0)
-};
-
-
-const struct ip_addr *get_ip_addr(void)
-{
- if (!src_ip_addr_initialized){ // fetch from eeprom
- src_ip_addr_initialized = true;
-
- // if we're simulating, don't read the EEPROM model, it's REALLY slow
- if (hwconfig_simulation_p())
- return &src_ip_addr;
-
- struct ip_addr tmp;
- bool ok = eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_IP_ADDR, &tmp, sizeof(tmp));
- if (!ok || unprogrammed(&tmp, sizeof(tmp))){
- // use the default
- }
- else
- src_ip_addr = tmp;
- }
-
- return &src_ip_addr;
-}
-
-bool set_ip_addr(const struct ip_addr *t){
- bool ok = eeprom_write(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_IP_ADDR, t, sizeof(struct ip_addr));
- if (ok){
- src_ip_addr = *t;
- src_ip_addr_initialized = true;
- }
-
- return ok;
-}
-*/
int
ethernet_check_errors(void)
{
diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/zpu/usrp2p/memory_map.h
index 3b2dc0057..36d8ac9f2 100644
--- a/firmware/microblaze/usrp2p/memory_map.h
+++ b/firmware/zpu/usrp2p/memory_map.h
@@ -16,38 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Overall Memory Map
- * 0000-FFFF 64K RAM space
- *
- * 0000-1FFF 8K Boot RAM
- * 2000-5FFF 16K Buffer pool
- * 6000-7FFF 8K Peripherals
- * 8000-FFFF 32K Main System RAM
-
-
-From u2plus_core.v:
-wb_1master #(.decode_w(8),
-.s0_addr(8'b0000_0000),.s0_mask(8'b1110_0000), // 0-8K, Boot RAM
-.s1_addr(8'b0100_0000),.s1_mask(8'b1100_0000), // 16K-32K, Buffer Pool
-.s2_addr(8'b0011_0000),.s2_mask(8'b1111_1111), // SPI 0x3000
-.s3_addr(8'b0011_0001),.s3_mask(8'b1111_1111), // I2C 0x3100
-.s4_addr(8'b0011_0010),.s4_mask(8'b1111_1111), // GPIO 0x3200
-.s5_addr(8'b0011_0011),.s5_mask(8'b1111_1111), // Readback 0x3300
-.s6_addr(8'b0011_0100),.s6_mask(8'b1111_1111), // Ethernet MAC 0x3400
-.s7_addr(8'b0010_0000),.s7_mask(8'b1111_0000), // 8-12K, Settings Bus (only uses 1K) 0x2000-0x2FFF
-.s8_addr(8'b0011_0101),.s8_mask(8'b1111_1111), // PIC 0x3500
-.s9_addr(8'b0011_0110),.s9_mask(8'b1111_1111), // Unused 0x3600
-.sa_addr(8'b0011_0111),.sa_mask(8'b1111_1111), // UART 0x3700
-.sb_addr(8'b0011_1000),.sb_mask(8'b1111_1111), // ATR 0x3800
-.sc_addr(8'b0011_1001),.sc_mask(8'b1111_1111), // Unused 0x3900
-.sd_addr(8'b0011_1010),.sd_mask(8'b1111_1111), // ICAP 0x3A00
-.se_addr(8'b0011_1011),.se_mask(8'b1111_1111), // SPI Flash 0x3B00
-.sf_addr(8'b1000_0000),.sf_mask(8'b1000_0000), // 32-64K, Main RAM 0x8000-0xFFFF
- .dw(dw),.aw(aw),.sw(sw)) wb_1master
-
- */
-
-
#ifndef INCLUDED_MEMORY_MAP_H
#define INCLUDED_MEMORY_MAP_H
@@ -70,27 +38,17 @@ wb_1master #(.decode_w(8),
////////////////////////////////////////////////////////////////
-// Buffer Pool RAM, Slave 1
+// Packet Router RAM, Slave 1
//
-// The buffers themselves are located in Slave 1, Buffer Pool RAM.
-// The status registers are in Slave 5, Buffer Pool Status.
+// The buffers themselves are located in Slave 1, Packet Router RAM.
+// The status registers are in Slave 5, Packet Router Status.
// The control register is in Slave 7, Settings Bus.
-#define BUFFER_POOL_RAM_BASE 0x4000
-
-#define NBUFFERS 8
-#define BP_NLINES 0x0200 // number of 32-bit lines in a buffer
-#define BP_LAST_LINE (BP_NLINES - 1) // last line in a buffer
-
-#define buffer_pool_ram \
- ((uint32_t *) BUFFER_POOL_RAM_BASE)
-
-#define buffer_ram(n) (&buffer_pool_ram[(n) * BP_NLINES])
-
+#define ROUTER_RAM_BASE 0x4000
/////////////////////////////////////////////////////
// SPI Core, Slave 2. See core docs for more info
-#define SPI_BASE 0x3000 // Base address (16-bit) is base peripheral addr
+#define SPI_BASE 0x6000 // Base address (16-bit) is base peripheral addr
typedef struct {
volatile uint32_t txrx0;
@@ -129,7 +87,7 @@ typedef struct {
// I2C, Slave 3
// See Wishbone I2C-Master Core Specification.
-#define I2C_BASE 0x3100
+#define I2C_BASE 0x6100
typedef struct {
volatile uint32_t prescaler_lo; // r/w
@@ -171,7 +129,7 @@ typedef struct {
//
// These go to the daughterboard i/o pins
-#define GPIO_BASE 0x3200
+#define GPIO_BASE 0x6200
typedef struct {
volatile uint32_t io; // tx data in high 16, rx in low 16
@@ -189,95 +147,27 @@ typedef struct {
#define gpio_base ((gpio_regs_t *) GPIO_BASE)
///////////////////////////////////////////////////
-// Buffer Pool Status, Slave 5
+// Packet Router Status, Slave 5
//
-// The buffers themselves are located in Slave 1, Buffer Pool RAM.
-// The status registers are in Slave 5, Buffer Pool Status.
+// The buffers themselves are located in Slave 1, Packet Router RAM.
+// The status registers are in Slave 5, Packet Router Status.
// The control register is in Slave 7, Settings Bus.
-#define BUFFER_POOL_STATUS_BASE 0x3300
+#define ROUTER_STATUS_BASE 0x6300
typedef struct {
- volatile uint32_t last_line[NBUFFERS]; // last line xfer'd in buffer
- volatile uint32_t status; // error and done flags
+ volatile uint32_t _padding[8];
+ volatile uint32_t status;
volatile uint32_t hw_config; // see below
- volatile uint32_t dummy[3];
+ volatile uint32_t time64_secs_rb;
+ volatile uint32_t time64_ticks_rb;
+ volatile uint32_t compat_num;
volatile uint32_t irqs;
- volatile uint32_t pri_enc_bp_status;
- volatile uint32_t cycle_count;
-} buffer_pool_status_t;
-
-#define buffer_pool_status ((buffer_pool_status_t *) BUFFER_POOL_STATUS_BASE)
-
-#define BUTTON_PUSHED ((buffer_pool_status->irqs & PIC_BUTTON) ? 0 : 1)
-
-/*
- * Buffer n's xfer is done.
- * Clear this bit by issuing bp_clear_buf(n)
- */
-#define BPS_DONE(n) (0x00000001 << (n))
-#define BPS_DONE_0 BPS_DONE(0)
-#define BPS_DONE_1 BPS_DONE(1)
-#define BPS_DONE_2 BPS_DONE(2)
-#define BPS_DONE_3 BPS_DONE(3)
-#define BPS_DONE_4 BPS_DONE(4)
-#define BPS_DONE_5 BPS_DONE(5)
-#define BPS_DONE_6 BPS_DONE(6)
-#define BPS_DONE_7 BPS_DONE(7)
+} router_status_t;
-/*
- * Buffer n's xfer had an error.
- * Clear this bit by issuing bp_clear_buf(n)
- */
-#define BPS_ERROR(n) (0x00000100 << (n))
-#define BPS_ERROR_0 BPS_ERROR(0)
-#define BPS_ERROR_1 BPS_ERROR(1)
-#define BPS_ERROR_2 BPS_ERROR(2)
-#define BPS_ERROR_3 BPS_ERROR(3)
-#define BPS_ERROR_4 BPS_ERROR(4)
-#define BPS_ERROR_5 BPS_ERROR(5)
-#define BPS_ERROR_6 BPS_ERROR(6)
-#define BPS_ERROR_7 BPS_ERROR(7)
+#define router_status ((router_status_t *) ROUTER_STATUS_BASE)
-/*
- * Buffer n is idle. A buffer is idle if it's not
- * DONE, ERROR, or processing a transaction. If it's
- * IDLE, it's safe to start a new transaction.
- *
- * Clear this bit by starting a xfer with
- * bp_send_from_buf or bp_receive_to_buf.
- */
-#define BPS_IDLE(n) (0x00010000 << (n))
-#define BPS_IDLE_0 BPS_IDLE(0)
-#define BPS_IDLE_1 BPS_IDLE(1)
-#define BPS_IDLE_2 BPS_IDLE(2)
-#define BPS_IDLE_3 BPS_IDLE(3)
-#define BPS_IDLE_4 BPS_IDLE(4)
-#define BPS_IDLE_5 BPS_IDLE(5)
-#define BPS_IDLE_6 BPS_IDLE(6)
-#define BPS_IDLE_7 BPS_IDLE(7)
-
-/*
- * Buffer n has a "slow path" packet in it.
- * This bit is orthogonal to the bits above and indicates that
- * the FPGA ethernet rx protocol engine has identified this packet
- * as one requiring firmware intervention.
- */
-#define BPS_SLOWPATH(n) (0x01000000 << (n))
-#define BPS_SLOWPATH_0 BPS_SLOWPATH(0)
-#define BPS_SLOWPATH_1 BPS_SLOWPATH(1)
-#define BPS_SLOWPATH_2 BPS_SLOWPATH(2)
-#define BPS_SLOWPATH_3 BPS_SLOWPATH(3)
-#define BPS_SLOWPATH_4 BPS_SLOWPATH(4)
-#define BPS_SLOWPATH_5 BPS_SLOWPATH(5)
-#define BPS_SLOWPATH_6 BPS_SLOWPATH(6)
-#define BPS_SLOWPATH_7 BPS_SLOWPATH(7)
-
-
-#define BPS_DONE_ALL 0x000000ff // mask of all dones
-#define BPS_ERROR_ALL 0x0000ff00 // mask of all errors
-#define BPS_IDLE_ALL 0x00ff0000 // mask of all idles
-#define BPS_SLOWPATH_ALL 0xff000000 // mask of all slowpaths
+#define BUTTON_PUSHED ((router_status->irqs & PIC_BUTTON) ? 0 : 1)
// The hw_config register
@@ -290,7 +180,7 @@ typedef struct {
inline static int
hwconfig_simulation_p(void)
{
- return buffer_pool_status->hw_config & HWC_SIMULATION;
+ return router_status->hw_config & HWC_SIMULATION;
}
/*!
@@ -300,13 +190,13 @@ hwconfig_simulation_p(void)
inline static int
hwconfig_wishbone_divisor(void)
{
- return buffer_pool_status->hw_config & HWC_WB_CLK_DIV_MASK;
+ return router_status->hw_config & HWC_WB_CLK_DIV_MASK;
}
///////////////////////////////////////////////////
// Ethernet Core, Slave 6
-#define ETH_BASE 0x3400
+#define ETH_BASE 0x6400
#include "eth_mac_regs.h"
@@ -319,16 +209,12 @@ hwconfig_wishbone_divisor(void)
// 1KB of address space (== 256 32-bit write-only regs)
-#define MISC_OUTPUT_BASE 0x2000
-#define TX_PROTOCOL_ENGINE_BASE 0x2080
-#define RX_PROTOCOL_ENGINE_BASE 0x20C0
-#define BUFFER_POOL_CTRL_BASE 0x2100
-#define LAST_SETTING_REG 0x23FC // last valid setting register
+#define MISC_OUTPUT_BASE 0x5000
#define SR_MISC 0
#define SR_TX_PROT_ENG 32
#define SR_RX_PROT_ENG 48
-#define SR_BUFFER_POOL_CTRL 64
+#define SR_ROUTER_CTRL 64
#define SR_UDP_SM 96
#define SR_TX_DSP 208
#define SR_TX_CTRL 224
@@ -340,53 +226,18 @@ hwconfig_wishbone_divisor(void)
#define _SR_ADDR(sr) (MISC_OUTPUT_BASE + (sr) * sizeof(uint32_t))
-// --- buffer pool control regs ---
+#define SR_ADDR_BLDRDONE _SR_ADDR(5)
+
+// --- packet router control regs ---
typedef struct {
- volatile uint32_t ctrl;
-} buffer_pool_ctrl_t;
-
-// buffer pool ports
-
-#define PORT_SERDES 0 // serial/deserializer
-#define PORT_DSP 1 // DSP tx or rx pipeline
-#define PORT_ETH 2 // ethernet tx or rx
-#define PORT_RAM 3 // RAM tx or rx
-
-// the buffer pool ctrl register fields
-
-#define BPC_BUFFER(n) (((n) & 0xf) << 28)
-#define BPC_BUFFER_MASK BPC_BUFFER(~0)
-#define BPC_BUFFER_0 BPC_BUFFER(0)
-#define BPC_BUFFER_1 BPC_BUFFER(1)
-#define BPC_BUFFER_2 BPC_BUFFER(2)
-#define BPC_BUFFER_3 BPC_BUFFER(3)
-#define BPC_BUFFER_4 BPC_BUFFER(4)
-#define BPC_BUFFER_5 BPC_BUFFER(5)
-#define BPC_BUFFER_6 BPC_BUFFER(6)
-#define BPC_BUFFER_7 BPC_BUFFER(7)
-#define BPC_BUFFER_NIL BPC_BUFFER(0x8) // disable
-
-#define BPC_PORT(n) (((n) & 0x7) << 25)
-#define BPC_PORT_MASK BPC_PORT(~0)
-#define BPC_PORT_SERDES BPC_PORT(PORT_SERDES)
-#define BPC_PORT_DSP BPC_PORT(PORT_DSP)
-#define BPC_PORT_ETH BPC_PORT(PORT_ETH)
-#define BPC_PORT_RAM BPC_PORT(PORT_RAM)
-#define BPC_PORT_NIL BPC_PORT(0x4) // disable
-
-#define BPC_CLR (1 << 24) // mutually excl commands
-#define BPC_READ (1 << 23)
-#define BPC_WRITE (1 << 22)
-
-#define BPC_STEP(step) (((step) & 0xf) << 18)
-#define BPC_STEP_MASK BPC_STEP(~0)
-#define BPC_LAST_LINE(line) (((line) & 0x1ff) << 9)
-#define BPC_LAST_LINE_MASK BPC_LAST_LINE(~0)
-#define BPC_FIRST_LINE(line) (((line) & 0x1ff) << 0)
-#define BPC_FIRST_LINE_MASK BPC_FIRST_LINE(~0)
-
-#define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE)
+ volatile uint32_t mode_ctrl;
+ volatile uint32_t ip_addr;
+ volatile uint32_t data_ports; //dsp0 (low 16) dsp1 (high 16)
+ volatile uint32_t iface_ctrl;
+} router_ctrl_t;
+
+#define router_ctrl ((router_ctrl_t *) _SR_ADDR(SR_ROUTER_CTRL))
// --- misc outputs ---
@@ -416,11 +267,11 @@ typedef struct {
// crazy order that matches the labels on the case
-#define LED_A (1 << 2)
-#define LED_B (1 << 0)
-#define LED_E (1 << 3)
-#define LED_D (1 << 1)
-#define LED_C (1 << 4)
+#define LED_A (1 << 4)
+#define LED_B (1 << 1)
+#define LED_E (1 << 2)
+#define LED_D (1 << 0)
+#define LED_C (1 << 3)
// LED_F // controlled by CPLD
#define LED_RJ45 (1 << 5)
@@ -462,11 +313,21 @@ typedef struct {
uint32_t length;
uint32_t checksum; //word 22
} udp_hdr;
- volatile uint32_t _pad[32-23];
+ volatile uint32_t _pad[1];
+ volatile uint32_t dsp0_port;
+ volatile uint32_t err0_port;
+ volatile uint32_t dsp1_port;
+ volatile uint32_t err1_port;
} sr_udp_sm_t;
// control bits (all expect UDP_SM_LAST_WORD are mutually exclusive)
+// Insert a UDP source port from the table
+#define UDP_SM_INS_UDP_SRC_PORT (1 << 21)
+
+// Insert a UDP dest port from the table
+#define UDP_SM_INS_UDP_DST_PORT (1 << 20)
+
// This is the last word of the header
#define UDP_SM_LAST_WORD (1 << 19)
@@ -679,7 +540,7 @@ typedef struct {
volatile uint32_t seqno; // Write to init seqno. It autoincs on match
} tx_proto_engine_regs_t;
-#define tx_proto_engine ((tx_proto_engine_regs_t *) TX_PROTOCOL_ENGINE_BASE)
+#define tx_proto_engine ((tx_proto_engine_regs_t *) _SR_ADDR(SR_TX_PROT_ENG))
/*
* --- ethernet rx protocol engine regs (write only) ---
@@ -706,14 +567,14 @@ typedef struct {
volatile uint32_t ethertype_pad; // ethertype in high 16-bits
} rx_proto_engine_regs_t;
-#define rx_proto_engine ((rx_proto_engine_regs_t *) RX_PROTOCOL_ENGINE_BASE)
+#define rx_proto_engine ((rx_proto_engine_regs_t *) _SR_ADDR(SR_RX_PROT_ENG))
///////////////////////////////////////////////////
// Simple Programmable Interrupt Controller, Slave 8
-#define PIC_BASE 0x3500
+#define PIC_BASE 0x6500
// Interrupt request lines
// Bit numbers (LSB == 0) that correpond to interrupts into PIC
@@ -773,7 +634,7 @@ typedef struct {
///////////////////////////////////////////////////
// UART, Slave 10
-#define UART_BASE 0x3700
+#define UART_BASE 0x6700
typedef struct {
// All elements are 8 bits except for clkdiv (16), but we use uint32 to make
@@ -791,7 +652,7 @@ typedef struct {
///////////////////////////////////////////////////
// ATR Controller, Slave 11
-#define ATR_BASE 0x3800
+#define ATR_BASE 0x6800
typedef struct {
volatile uint32_t v[16];
@@ -810,7 +671,7 @@ typedef struct {
///////////////////////////////////////////////////
// ICAP, Slave 13
-#define ICAP_BASE 0x3A00
+#define ICAP_BASE 0x6A00
typedef struct {
uint32_t icap; //only the lower 8 bits matter
} icap_regs_t;
@@ -822,7 +683,7 @@ typedef struct {
// Control register definitions are the same as SPI, so use SPI_CTRL_ASS, etc.
// Peripheral mask not needed since bus is dedicated (CE held low)
-#define SPIF_BASE 0x3B00
+#define SPIF_BASE 0x6B00
typedef struct {
volatile uint32_t txrx0;
volatile uint32_t txrx1;
diff --git a/firmware/microblaze/usrp2p/spi_flash.c b/firmware/zpu/usrp2p/spi_flash.c
index 09b74a513..25fc239be 100644
--- a/firmware/microblaze/usrp2p/spi_flash.c
+++ b/firmware/zpu/usrp2p/spi_flash.c
@@ -1,7 +1,7 @@
/* -*- c++ -*- */
/*
* Copyright 2009 Free Software Foundation, Inc.
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2p/spi_flash.h b/firmware/zpu/usrp2p/spi_flash.h
index bbe7b650d..a10533e08 100644
--- a/firmware/microblaze/usrp2p/spi_flash.h
+++ b/firmware/zpu/usrp2p/spi_flash.h
@@ -1,7 +1,7 @@
/* -*- c -*- */
/*
* Copyright 2009 Free Software Foundation, Inc.
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
@@ -30,20 +30,11 @@
uint32_t spi_flash_rdid(void); /* Read ID */
uint32_t spi_flash_rdsr(void); /* Read Status Register */
-size_t spi_flash_log2_sector_size(void) __attribute__((pure)); /* either 16 or 18 */
-size_t spi_flash_log2_memory_size(void);
-static inline size_t
-spi_flash_sector_size(void)
-{
- return ((size_t) 1) << spi_flash_log2_sector_size();
-}
-
-static inline size_t
-spi_flash_memory_size(void)
-{
- return ((size_t) 1) << spi_flash_log2_memory_size();
-}
+size_t spi_flash_log2_memory_size(void);
+size_t spi_flash_log2_sector_size(void);
+size_t spi_flash_sector_size(void);
+size_t spi_flash_memory_size(void);
void spi_flash_read(uint32_t flash_addr, size_t nbytes, void *buf);
diff --git a/firmware/microblaze/usrp2p/spi_flash_private.h b/firmware/zpu/usrp2p/spi_flash_private.h
index 9a1b8d3e3..6bf06fda8 100644
--- a/firmware/microblaze/usrp2p/spi_flash_private.h
+++ b/firmware/zpu/usrp2p/spi_flash_private.h
@@ -1,7 +1,7 @@
/* -*- c++ -*- */
/*
* Copyright 2009 Free Software Foundation, Inc.
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2p/spi_flash_read.c b/firmware/zpu/usrp2p/spi_flash_read.c
index 4682c5fe6..fffc2a671 100644
--- a/firmware/microblaze/usrp2p/spi_flash_read.c
+++ b/firmware/zpu/usrp2p/spi_flash_read.c
@@ -1,7 +1,7 @@
/* -*- c++ -*- */
/*
* Copyright 2009 Free Software Foundation, Inc.
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
@@ -19,8 +19,7 @@
#include "spi_flash_private.h"
#include <stdlib.h> // abort
-
-static size_t _spi_flash_log2_memory_size;
+#include <nonstdio.h>
uint32_t
spi_flash_rdid(void)
@@ -28,46 +27,39 @@ spi_flash_rdid(void)
return spif_transact(SPI_TXRX, SPI_SS_FLASH, RDID_CMD << 24, 32, FLAGS) & 0xffffff;
}
-size_t
-spi_flash_log2_sector_size(void)
+size_t spi_flash_log2_memory_size(void)
{
- static size_t _spi_flash_log2_sector_size;
-
- if (_spi_flash_log2_sector_size != 0)
- return _spi_flash_log2_sector_size;
-
-
- uint32_t id = spi_flash_rdid();
- int type = (id >> 8) & 0xff;
- int size = id & 0xff;
- if (type != 0x20 || size < 22 || size > 24)
- abort();
-
- static unsigned char log2_sector_size[3] = {
- 16, /* M25P32 */
- 16, /* M25P64 */
- 18, /* M25P128 */
- };
-
- _spi_flash_log2_sector_size = log2_sector_size[size - 22];
- _spi_flash_log2_memory_size = size; //while we're at it
- return _spi_flash_log2_sector_size;
+ static size_t _spi_flash_log2_memory_size = 0;
+ if (_spi_flash_log2_memory_size == 0){
+ uint32_t id = spi_flash_rdid();
+ uint8_t type = (id >> 8) & 0xff;
+ uint8_t size = (id >> 0) & 0xff;
+ if (type != 0x20) abort();
+ _spi_flash_log2_memory_size = size;
+ }
+ if (_spi_flash_log2_memory_size < 22 ||
+ _spi_flash_log2_memory_size > 24 ) abort();
+ return _spi_flash_log2_memory_size;
}
-size_t
-spi_flash_log2_memory_size(void)
+size_t spi_flash_log2_sector_size(void)
{
- if (_spi_flash_log2_memory_size != 0)
- return _spi_flash_log2_memory_size;
+ static unsigned char log2_sector_size[3] = {
+ 16, /* M25P32 */
+ 16, /* M25P64 */
+ 18, /* M25P128 */
+ };
+ return log2_sector_size[spi_flash_log2_memory_size() - 22];
+}
- uint32_t id = spi_flash_rdid();
- int type = (id >> 8) & 0xff;
- int size = id & 0xff;
- if (type != 0x20 || size < 22 || size > 24)
- abort();
+size_t spi_flash_sector_size(void)
+{
+ return ((size_t) 1) << spi_flash_log2_sector_size();
+}
- _spi_flash_log2_memory_size = size;
- return _spi_flash_log2_memory_size;
+size_t spi_flash_memory_size(void)
+{
+ return ((size_t) 1) << spi_flash_log2_memory_size();
}
void
@@ -100,7 +92,8 @@ spi_flash_read(uint32_t flash_addr, size_t nbytes, void *buf)
*/
unsigned char *dst = (unsigned char *) buf;
size_t m;
- for (size_t n = 0; n < nbytes; n += m, dst += m){
+ for (size_t n = 0; n < nbytes; n += m){
+
spif_regs->ctrl = FLAGS | LEN(16 * 8); // xfer 16 bytes
spif_regs->ctrl = FLAGS | LEN(16 * 8) | SPI_CTRL_GO_BSY;
spif_wait();
@@ -113,7 +106,7 @@ spi_flash_read(uint32_t flash_addr, size_t nbytes, void *buf)
unsigned char *src = (unsigned char *) &w[0];
m = min(nbytes - n, 16);
for (size_t i = 0; i < m; i++)
- dst[i] = src[i];
+ *(dst++) = src[i];
}
spif_regs->ss = 0; // deassert chip select
}
diff --git a/firmware/microblaze/usrp2p/spif.c b/firmware/zpu/usrp2p/spif.c
index 1c1a348f4..91da73155 100644
--- a/firmware/microblaze/usrp2p/spif.c
+++ b/firmware/zpu/usrp2p/spif.c
@@ -1,6 +1,6 @@
/*
* Copyright 2007,2008,2009 Free Software Foundation, Inc.
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/apps/cruft/echo.c b/firmware/zpu/usrp2p/u2p_init.c
index 89108ee80..381987ae6 100644
--- a/firmware/microblaze/apps/cruft/echo.c
+++ b/firmware/zpu/usrp2p/u2p_init.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2011 Ettus Research LLC
*
* 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
@@ -15,20 +15,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "u2_init.h"
-#include "stdio.h"
+#include "u2p_init.h"
+#include "i2c.h"
+#include "ethernet.h"
-int
-main(void)
-{
- u2_init();
-
- puts("\n>>> echo <<<");
-
- while (1){
- int ch = getchar();
- putchar(ch);
- }
-
- return 0;
+void u2p_init(void){
+ //we do this to see if we should set a default ip addr or not
+ bool safe_fw = find_safe_booted_flag();
+ set_safe_booted_flag(0);
+ if (safe_fw) {
+ set_default_ip_addr();
+ set_default_mac_addr();
+ }
}
diff --git a/firmware/microblaze/lib/gdbstub2.h b/firmware/zpu/usrp2p/u2p_init.h
index 15cdde939..b0dc20f1f 100644
--- a/firmware/microblaze/lib/gdbstub2.h
+++ b/firmware/zpu/usrp2p/u2p_init.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2011 Ettus Research LLC
*
* 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
@@ -16,10 +15,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef INCLUDED_GDBSTUB_H
-#define INCLUDED_GDBSTUB_H
-
-void gdbstub2_main_loop(void);
-
-#endif /* INCLUDED_GDBSTUB_H */
-
+void u2p_init(void);
diff --git a/firmware/microblaze/usrp2p/udp_fw_update.c b/firmware/zpu/usrp2p/udp_fw_update.c
index ead08ad2c..ead08ad2c 100644
--- a/firmware/microblaze/usrp2p/udp_fw_update.c
+++ b/firmware/zpu/usrp2p/udp_fw_update.c
diff --git a/firmware/microblaze/usrp2p/xilinx_s3_icap.c b/firmware/zpu/usrp2p/xilinx_s3_icap.c
index 50c85231c..8995aa23d 100644
--- a/firmware/microblaze/usrp2p/xilinx_s3_icap.c
+++ b/firmware/zpu/usrp2p/xilinx_s3_icap.c
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/firmware/microblaze/usrp2p/xilinx_s3_icap.h b/firmware/zpu/usrp2p/xilinx_s3_icap.h
index 7b7e9eccc..d4238eee9 100644
--- a/firmware/microblaze/usrp2p/xilinx_s3_icap.h
+++ b/firmware/zpu/usrp2p/xilinx_s3_icap.h
@@ -1,6 +1,6 @@
/* -*- c -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009-2011 Ettus Research LLC
*
* 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
diff --git a/fix-copyright-years b/fix-copyright-years
new file mode 100755
index 000000000..97630041b
--- /dev/null
+++ b/fix-copyright-years
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+import re
+import optparse
+import datetime
+import subprocess
+import multiprocessing
+
+co_line_matcher = re.compile('^.*Copyright (.*) Ettus Research LLC$')
+
+def command(*args): return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
+
+def get_co_line(lines):
+ for i, line in enumerate(lines[:5]):
+ if co_line_matcher.match(line): return line, i
+ return None, None
+
+def fix_co_years(files, keep_years):
+ for file in files:
+ print file
+ lines = open(file).readlines()
+ line, num = get_co_line(lines)
+ if line is None: continue
+
+ #extract the years from the git history
+ log_years = map(
+ lambda l: int(l.split()[-2]),
+ filter(
+ lambda l: l.startswith('Date'),
+ command('git', 'log', file).splitlines(),
+ ),
+ )
+ log_years = min(log_years), max(log_years)
+
+ #extract years from co string
+ try:
+ co_years_str = co_line_matcher.match(line).groups()[0]
+ co_years = map(int, co_years_str.split('-'))
+ co_years = min(co_years), max(co_years)
+ except Exception, e:
+ print ' format error on line %d: "%s"'%(num, line), e
+ continue
+
+ #keep years means log years is a superset
+ if keep_years: log_years = min(co_years+log_years), max(co_years+log_years)
+
+ if log_years != co_years:
+ print ' log years: %s != copyright years: %s'%(log_years, co_years)
+ year_now = datetime.datetime.now().year
+ all_years = min(log_years), max(list(log_years)+[year_now]) #add the current year
+ all_years_str = '%s-%s'%all_years
+ if all_years[0] == all_years[1]: all_years_str = str(all_years[0])
+ new_text = ''.join(lines[:num] + [line.replace(co_years_str, all_years_str)] + lines[num+1:])
+ open(file, 'w').write(new_text)
+
+if __name__ == "__main__":
+ parser = optparse.OptionParser(usage="usage: %prog [options] path")
+ parser.add_option("-k", "--keep", action="store_true", help="keep copyright years", default=False)
+ (options, args) = parser.parse_args()
+
+ #get recursive list of files in the repo
+ files = command('git', 'ls-tree', '--name-only', 'HEAD', '-r', args[0]).splitlines()
+
+ #start n+1 processes to handle the files
+ num_procs = multiprocessing.cpu_count()
+ procs = [multiprocessing.Process(
+ target=lambda *files: fix_co_years(files, keep_years=options.keep),
+ args=files[num::num_procs],
+ ) for num in range(num_procs)]
+ map(multiprocessing.Process.start, procs)
+ map(multiprocessing.Process.join, procs)
diff --git a/fpga/usrp2/control_lib/Makefile.srcs b/fpga/usrp2/control_lib/Makefile.srcs
index d3bb7e2c8..751b40828 100644
--- a/fpga/usrp2/control_lib/Makefile.srcs
+++ b/fpga/usrp2/control_lib/Makefile.srcs
@@ -30,6 +30,7 @@ srl.v \
system_control.v \
wb_1master.v \
wb_readback_mux.v \
+wb_readback_mux_16LE.v \
quad_uart.v \
simple_uart.v \
simple_uart_tx.v \
diff --git a/fpga/usrp2/control_lib/wb_readback_mux_16LE.v b/fpga/usrp2/control_lib/wb_readback_mux_16LE.v
new file mode 100644
index 000000000..2b01898c1
--- /dev/null
+++ b/fpga/usrp2/control_lib/wb_readback_mux_16LE.v
@@ -0,0 +1,73 @@
+
+
+// Note -- clocks must be synchronous (derived from the same source)
+// Assumes alt_clk is running at a multiple of wb_clk
+
+// Note -- assumes that the lower-16 bits will be requested first,
+// and that the upper-16 bit request will come immediately after.
+
+module wb_readback_mux_16LE
+ (input wb_clk_i,
+ input wb_rst_i,
+ input wb_stb_i,
+ input [15:0] wb_adr_i,
+ output [15:0] wb_dat_o,
+ output reg wb_ack_o,
+
+ input [31:0] word00,
+ input [31:0] word01,
+ input [31:0] word02,
+ input [31:0] word03,
+ input [31:0] word04,
+ input [31:0] word05,
+ input [31:0] word06,
+ input [31:0] word07,
+ input [31:0] word08,
+ input [31:0] word09,
+ input [31:0] word10,
+ input [31:0] word11,
+ input [31:0] word12,
+ input [31:0] word13,
+ input [31:0] word14,
+ input [31:0] word15
+ );
+
+ wire ack_next = wb_stb_i & ~wb_ack_o;
+
+ always @(posedge wb_clk_i)
+ if(wb_rst_i)
+ wb_ack_o <= 0;
+ else
+ wb_ack_o <= ack_next;
+
+ reg [31:0] data;
+ assign wb_dat_o = data[15:0];
+
+ always @(posedge wb_clk_i)
+ if (wb_adr_i[1] & ack_next) begin //upper half
+ data[15:0] <= data[31:16];
+ end
+ else if (~wb_adr_i[1] & ack_next) begin //lower half
+ case(wb_adr_i[5:2])
+ 0 : data <= word00;
+ 1 : data <= word01;
+ 2 : data <= word02;
+ 3 : data <= word03;
+ 4 : data <= word04;
+ 5 : data <= word05;
+ 6 : data <= word06;
+ 7 : data <= word07;
+ 8 : data <= word08;
+ 9 : data <= word09;
+ 10: data <= word10;
+ 11: data <= word11;
+ 12: data <= word12;
+ 13: data <= word13;
+ 14: data <= word14;
+ 15: data <= word15;
+ endcase // case(wb_adr_i[5:2])
+ end
+
+endmodule // wb_readback_mux
+
+
diff --git a/fpga/usrp2/coregen/_xmsgs/pn_parser.xmsgs b/fpga/usrp2/coregen/_xmsgs/pn_parser.xmsgs
deleted file mode 100644
index d946af064..000000000
--- a/fpga/usrp2/coregen/_xmsgs/pn_parser.xmsgs
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- IMPORTANT: This is an internal file that has been generated -->
-<!-- by the Xilinx ISE software. Any direct editing or -->
-<!-- changes made to this file may result in unpredictable -->
-<!-- behavior or data corruption. It is strongly advised that -->
-<!-- users do not edit the contents of this file. -->
-<!-- -->
-<!-- Copyright (c) 1995-2010 Xilinx, Inc. All rights reserved. -->
-
-<messages>
-<msg type="info" file="ProjectMgmt" num="1062" ><arg fmt="%s" index="1">Parsing Verilog file &quot;/home/jblum/uhdpriv/fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_prog_full.v&quot; into library work</arg>
-</msg>
-
-</messages>
-
diff --git a/fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_18to36.ncf b/fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_18to36.ncf
deleted file mode 100644
index e69de29bb..000000000
--- a/fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_18to36.ncf
+++ /dev/null
diff --git a/fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_36to18.ncf b/fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_36to18.ncf
deleted file mode 100644
index e69de29bb..000000000
--- a/fpga/usrp2/coregen/fifo_xlnx_512x36_2clk_36to18.ncf
+++ /dev/null
diff --git a/fpga/usrp2/fifo/Makefile.srcs b/fpga/usrp2/fifo/Makefile.srcs
index c66979132..f0b5b7bae 100644
--- a/fpga/usrp2/fifo/Makefile.srcs
+++ b/fpga/usrp2/fifo/Makefile.srcs
@@ -7,7 +7,10 @@
##################################################
FIFO_SRCS = $(abspath $(addprefix $(BASE_DIR)/../fifo/, \
buffer_int.v \
+buffer_int2.v \
buffer_pool.v \
+crossbar36.v \
+dsp_framer36.v \
fifo_2clock.v \
fifo_2clock_cascade.v \
ll8_shortfifo.v \
@@ -22,4 +25,7 @@ fifo36_to_fifo19.v \
fifo19_to_fifo36.v \
fifo36_mux.v \
fifo36_demux.v \
+packet_router.v \
+splitter36.v \
+valve36.v \
))
diff --git a/fpga/usrp2/fifo/buffer_int.v b/fpga/usrp2/fifo/buffer_int.v
index b45ed3532..49ded8c8d 100644
--- a/fpga/usrp2/fifo/buffer_int.v
+++ b/fpga/usrp2/fifo/buffer_int.v
@@ -14,7 +14,6 @@ module buffer_int
output done,
output error,
output idle,
- output [1:0] flag,
// Buffer Interface
output en_o,
diff --git a/fpga/usrp2/fifo/buffer_int2.v b/fpga/usrp2/fifo/buffer_int2.v
new file mode 100644
index 000000000..765b125fb
--- /dev/null
+++ b/fpga/usrp2/fifo/buffer_int2.v
@@ -0,0 +1,173 @@
+
+// FIFO Interface to the 2K buffer RAMs
+// Read port is read-acknowledge
+// FIXME do we want to be able to interleave reads and writes?
+
+module buffer_int2
+ #(parameter BASE = 0,
+ parameter BUF_SIZE = 9)
+ (input clk, input rst,
+ input set_stb, input [7:0] set_addr, input [31:0] set_data,
+ output [31:0] status,
+
+ // Wishbone interface to RAM
+ input wb_clk_i,
+ input wb_rst_i,
+ input wb_we_i,
+ input wb_stb_i,
+ input [15:0] wb_adr_i,
+ input [31:0] wb_dat_i,
+ output [31:0] wb_dat_o,
+ output reg wb_ack_o,
+
+ // Write FIFO Interface
+ input [35:0] wr_data_i,
+ input wr_ready_i,
+ output wr_ready_o,
+
+ // Read FIFO Interface
+ output [35:0] rd_data_o,
+ output rd_ready_o,
+ input rd_ready_i
+ );
+
+ reg [BUF_SIZE-1:0] rd_addr, wr_addr;
+ wire [31:0] ctrl;
+ wire wr_done, wr_error, wr_idle;
+ wire rd_done, rd_error, rd_idle;
+ wire we, en, go;
+
+ reg [BUF_SIZE-1:0] lastline;
+ wire read = ctrl[3];
+ wire rd_clear = ctrl[2];
+ wire write = ctrl[1];
+ wire wr_clear = ctrl[0];
+
+ reg [2:0] rd_state, wr_state;
+ reg rd_sop, rd_eop;
+ wire wr_sop, wr_eop;
+ reg [1:0] rd_occ;
+ wire [1:0] wr_occ;
+
+ localparam IDLE = 3'd0;
+ localparam PRE_READ = 3'd1;
+ localparam READING = 3'd2;
+ localparam WRITING = 3'd3;
+ localparam ERROR = 3'd4;
+ localparam DONE = 3'd5;
+
+ // read state machine
+ always @(posedge clk)
+ if(rst | (rd_clear & go))
+ begin
+ rd_state <= IDLE;
+ rd_sop <= 0;
+ rd_eop <= 0;
+ rd_occ <= 0;
+ end
+ else
+ case(rd_state)
+ IDLE :
+ if(go & read)
+ begin
+ rd_addr <= 0;
+ rd_state <= PRE_READ;
+ lastline <= ctrl[15+BUF_SIZE:16];
+ end
+
+ PRE_READ :
+ begin
+ rd_state <= READING;
+ rd_addr <= rd_addr + 1;
+ rd_occ <= 2'b00;
+ rd_sop <= 1;
+ rd_eop <= 0;
+ end
+
+ READING :
+ if(rd_ready_i)
+ begin
+ rd_sop <= 0;
+ rd_addr <= rd_addr + 1;
+ if(rd_addr == lastline)
+ begin
+ rd_eop <= 1;
+ // FIXME assign occ here
+ rd_occ <= 0;
+ end
+ else
+ rd_eop <= 0;
+ if(rd_eop)
+ rd_state <= DONE;
+ end
+
+ endcase // case(rd_state)
+
+ // write state machine
+ always @(posedge clk)
+ if(rst | (wr_clear & go))
+ wr_state <= IDLE;
+ else
+ case(wr_state)
+ IDLE :
+ if(go & write)
+ begin
+ wr_addr <= 0;
+ wr_state <= WRITING;
+ end
+
+ WRITING :
+ if(wr_ready_i)
+ begin
+ wr_addr <= wr_addr + 1;
+ if(wr_sop & wr_eop)
+ wr_state <= ERROR; // Should save OCC flags here
+ else if(wr_eop)
+ wr_state <= DONE;
+ end // if (wr_ready_i)
+ endcase // case(wr_state)
+
+ assign rd_data_o[35:32] = { rd_occ[1:0], rd_eop, rd_sop };
+ assign rd_ready_o = (rd_state == READING);
+
+ assign wr_sop = wr_data_i[32];
+ assign wr_eop = wr_data_i[33];
+ assign wr_occ = wr_data_i[35:34];
+ assign wr_ready_o = (wr_state == WRITING);
+
+ assign we = (wr_state == WRITING); // always write to avoid timing issue
+ assign en = ~((rd_state==READING)& ~rd_ready_i); // FIXME potential critical path
+
+ assign rd_done = (rd_state == DONE);
+ assign wr_done = (wr_state == DONE);
+ assign rd_error = (rd_state == ERROR);
+ assign wr_error = (wr_state == ERROR);
+ assign rd_idle = (rd_state == IDLE);
+ assign wr_idle = (wr_state == IDLE);
+
+ ram_2port #(.DWIDTH(32),.AWIDTH(BUF_SIZE)) buffer_in // CPU reads here
+ (.clka(wb_clk_i),.ena(wb_stb_i),.wea(1'b0),
+ .addra(wb_adr_i[BUF_SIZE+1:2]),.dia(0),.doa(wb_dat_o),
+ .clkb(clk),.enb(1'b1),.web(we),
+ .addrb(wr_addr),.dib(wr_data_i[31:0]),.dob());
+
+ ram_2port #(.DWIDTH(32),.AWIDTH(BUF_SIZE)) buffer_out // CPU writes here
+ (.clka(wb_clk_i),.ena(wb_stb_i),.wea(wb_we_i),
+ .addra(wb_adr_i[BUF_SIZE+1:2]),.dia(wb_dat_i),.doa(),
+ .clkb(clk),.enb(en),.web(1'b0),
+ .addrb(rd_addr),.dib(0),.dob(rd_data_o[31:0]));
+
+ always @(posedge wb_clk_i)
+ if(wb_rst_i)
+ wb_ack_o <= 0;
+ else
+ wb_ack_o <= wb_stb_i & ~wb_ack_o;
+
+ setting_reg #(.my_addr(BASE))
+ sreg(.clk(clk),.rst(rst),.strobe(set_stb),.addr(set_addr),.in(set_data),
+ .out(ctrl),.changed(go));
+
+ assign status = { {(16-BUF_SIZE){1'b0}},wr_addr,
+ 8'b0,1'b0,rd_idle,rd_error,rd_done, 1'b0,wr_idle,wr_error,wr_done};
+
+endmodule // buffer_int2
diff --git a/fpga/usrp2/fifo/crossbar36.v b/fpga/usrp2/fifo/crossbar36.v
new file mode 100644
index 000000000..2a046d8bf
--- /dev/null
+++ b/fpga/usrp2/fifo/crossbar36.v
@@ -0,0 +1,42 @@
+
+
+module crossbar36
+ (input clk, input reset, input clear,
+ input cross,
+ input [35:0] data0_i, input src0_rdy_i, output dst0_rdy_o,
+ input [35:0] data1_i, input src1_rdy_i, output dst1_rdy_o,
+ output [35:0] data0_o, output src0_rdy_o, input dst0_rdy_i,
+ output [35:0] data1_o, output src1_rdy_o, input dst1_rdy_i);
+
+ reg cross_int, active0, active1;
+ wire active0_next = (src0_rdy_i & dst0_rdy_o)? ~data0_i[33] : active0;
+ wire active1_next = (src1_rdy_i & dst1_rdy_o)? ~data1_i[33] : active1;
+
+ assign data0_o = cross_int ? data1_i : data0_i;
+ assign data1_o = cross_int ? data0_i : data1_i;
+
+ assign src0_rdy_o = cross_int ? src1_rdy_i : src0_rdy_i;
+ assign src1_rdy_o = cross_int ? src0_rdy_i : src1_rdy_i;
+
+ assign dst0_rdy_o = cross_int ? dst1_rdy_i : dst0_rdy_i;
+ assign dst1_rdy_o = cross_int ? dst0_rdy_i : dst1_rdy_i;
+
+ always @(posedge clk)
+ if(reset | clear)
+ active0 <= 0;
+ else
+ active0 <= active0_next;
+
+ always @(posedge clk)
+ if(reset | clear)
+ active1 <= 0;
+ else
+ active1 <= active1_next;
+
+ always @(posedge clk)
+ if(reset | clear)
+ cross_int <= 0;
+ else if(~active0_next & ~active1_next)
+ cross_int <= cross;
+
+endmodule // crossbar36
diff --git a/fpga/usrp2/fifo/dsp_framer36.v b/fpga/usrp2/fifo/dsp_framer36.v
new file mode 100644
index 000000000..34a05d91e
--- /dev/null
+++ b/fpga/usrp2/fifo/dsp_framer36.v
@@ -0,0 +1,98 @@
+
+// Frame DSP packets with a header line to be handled by the protocol machine
+
+module dsp_framer36
+ #(parameter BUF_SIZE = 9)
+ (
+ input clk, input rst, input clr,
+ input [35:0] inp_data, input inp_valid, output inp_ready,
+ output [35:0] out_data, output out_valid, input out_ready
+ );
+
+ localparam DSP_FRM_STATE_WAIT_SOF = 0;
+ localparam DSP_FRM_STATE_WAIT_EOF = 1;
+ localparam DSP_FRM_STATE_WRITE_HDR = 2;
+ localparam DSP_FRM_STATE_WRITE = 3;
+
+ reg [1:0] dsp_frm_state;
+ reg [BUF_SIZE-1:0] dsp_frm_addr;
+ reg [BUF_SIZE-1:0] dsp_frm_count;
+ wire [BUF_SIZE-1:0] dsp_frm_addr_next = dsp_frm_addr + 1'b1;
+
+ //DSP input stream ready in the following states
+ assign inp_ready = (
+ dsp_frm_state == DSP_FRM_STATE_WAIT_SOF ||
+ dsp_frm_state == DSP_FRM_STATE_WAIT_EOF
+ )? 1'b1 : 1'b0;
+
+ //DSP framer output data mux (header or BRAM):
+ //The header is generated here from the count.
+ wire [31:0] dsp_frm_data_bram;
+ wire [15:0] dsp_frm_bytes = {dsp_frm_count, 2'b00};
+ assign out_data =
+ (dsp_frm_state == DSP_FRM_STATE_WRITE_HDR)? {4'b0001, 16'b1, dsp_frm_bytes} : (
+ (dsp_frm_addr == dsp_frm_count) ? {4'b0010, dsp_frm_data_bram} : (
+ {4'b0000, dsp_frm_data_bram}));
+ assign out_valid = (
+ (dsp_frm_state == DSP_FRM_STATE_WRITE_HDR) ||
+ (dsp_frm_state == DSP_FRM_STATE_WRITE)
+ )? 1'b1 : 1'b0;
+
+ RAMB16_S36_S36 dsp_frm_buff(
+ //port A = DSP input interface (writes to BRAM)
+ .DOA(),.ADDRA(dsp_frm_addr),.CLKA(clk),.DIA(inp_data[31:0]),.DIPA(4'h0),
+ .ENA(inp_ready & inp_valid),.SSRA(0),.WEA(inp_ready & inp_valid),
+ //port B = DSP framer interface (reads from BRAM)
+ .DOB(dsp_frm_data_bram),.ADDRB(dsp_frm_addr),.CLKB(clk),.DIB(36'b0),.DIPB(4'h0),
+ .ENB(out_ready & out_valid),.SSRB(0),.WEB(1'b0)
+ );
+
+ always @(posedge clk)
+ if(rst | clr) begin
+ dsp_frm_state <= DSP_FRM_STATE_WAIT_SOF;
+ dsp_frm_addr <= 0;
+ end
+ else begin
+ case(dsp_frm_state)
+ DSP_FRM_STATE_WAIT_SOF: begin
+ if (inp_ready & inp_valid & inp_data[32]) begin
+ dsp_frm_addr <= dsp_frm_addr_next;
+ dsp_frm_state <= DSP_FRM_STATE_WAIT_EOF;
+ end
+ end
+
+ DSP_FRM_STATE_WAIT_EOF: begin
+ if (inp_ready & inp_valid) begin
+ if (inp_data[33]) begin
+ dsp_frm_count <= dsp_frm_addr_next;
+ dsp_frm_addr <= 0;
+ dsp_frm_state <= DSP_FRM_STATE_WRITE_HDR;
+ end
+ else begin
+ dsp_frm_addr <= dsp_frm_addr_next;
+ end
+ end
+ end
+
+ DSP_FRM_STATE_WRITE_HDR: begin
+ if (out_ready & out_valid) begin
+ dsp_frm_addr <= dsp_frm_addr_next;
+ dsp_frm_state <= DSP_FRM_STATE_WRITE;
+ end
+ end
+
+ DSP_FRM_STATE_WRITE: begin
+ if (out_ready & out_valid) begin
+ if (out_data[33]) begin
+ dsp_frm_addr <= 0;
+ dsp_frm_state <= DSP_FRM_STATE_WAIT_SOF;
+ end
+ else begin
+ dsp_frm_addr <= dsp_frm_addr_next;
+ end
+ end
+ end
+ endcase //dsp_frm_state
+ end
+
+endmodule //dsp_framer36
diff --git a/fpga/usrp2/fifo/packet_router.v b/fpga/usrp2/fifo/packet_router.v
new file mode 100644
index 000000000..161b59016
--- /dev/null
+++ b/fpga/usrp2/fifo/packet_router.v
@@ -0,0 +1,535 @@
+module packet_router
+ #(
+ parameter BUF_SIZE = 9,
+ parameter UDP_BASE = 0,
+ parameter CTRL_BASE = 0
+ )
+ (
+ //wishbone interface for memory mapped CPU frames
+ input wb_clk_i,
+ input wb_rst_i,
+ input wb_we_i,
+ input wb_stb_i,
+ input [15:0] wb_adr_i,
+ input [31:0] wb_dat_i,
+ output [31:0] wb_dat_o,
+ output wb_ack_o,
+ output wb_err_o,
+ output wb_rty_o,
+
+ //setting register interface
+ input set_stb, input [7:0] set_addr, input [31:0] set_data,
+
+ input stream_clk,
+ input stream_rst,
+ input stream_clr,
+
+ //output status register
+ output [31:0] status,
+
+ output sys_int_o, //want an interrupt?
+
+ output [31:0] debug,
+
+ // Input Interfaces (in to router)
+ input [35:0] ser_inp_data, input ser_inp_valid, output ser_inp_ready,
+ input [35:0] dsp_inp_data, input dsp_inp_valid, output dsp_inp_ready,
+ input [35:0] eth_inp_data, input eth_inp_valid, output eth_inp_ready,
+ input [35:0] err_inp_data, input err_inp_valid, output err_inp_ready,
+
+ // Output Interfaces (out of router)
+ output [35:0] ser_out_data, output ser_out_valid, input ser_out_ready,
+ output [35:0] dsp_out_data, output dsp_out_valid, input dsp_out_ready,
+ output [35:0] eth_out_data, output eth_out_valid, input eth_out_ready
+ );
+
+ assign wb_err_o = 1'b0; // Unused for now
+ assign wb_rty_o = 1'b0; // Unused for now
+
+ ////////////////////////////////////////////////////////////////////
+ // CPU interface to this packet router
+ ////////////////////////////////////////////////////////////////////
+ wire [35:0] cpu_inp_data, cpu_out_data;
+ wire cpu_inp_valid, cpu_out_valid;
+ wire cpu_inp_ready, cpu_out_ready;
+
+ ////////////////////////////////////////////////////////////////////
+ // Communication interfaces
+ ////////////////////////////////////////////////////////////////////
+ wire [35:0] com_inp_data, com_out_data, udp_out_data;
+ wire com_inp_valid, com_out_valid, udp_out_valid;
+ wire com_inp_ready, com_out_ready, udp_out_ready;
+
+ ////////////////////////////////////////////////////////////////////
+ // Control signals (setting registers and status signals)
+ // - handshake lines for the CPU communication
+ // - setting registers to program the inspector
+ ////////////////////////////////////////////////////////////////////
+
+ //setting register for mode control
+ wire [31:0] _sreg_mode_ctrl;
+ setting_reg #(.my_addr(CTRL_BASE+0), .width(1)) sreg_mode_ctrl(
+ .clk(stream_clk),.rst(stream_rst),
+ .strobe(set_stb),.addr(set_addr),.in(set_data),
+ .out(master_mode_flag),.changed()
+ );
+
+ //setting register to program the IP address
+ wire [31:0] my_ip_addr;
+ setting_reg #(.my_addr(CTRL_BASE+1)) sreg_ip_addr(
+ .clk(stream_clk),.rst(stream_rst),
+ .strobe(set_stb),.addr(set_addr),.in(set_data),
+ .out(my_ip_addr),.changed()
+ );
+
+ //setting register to program the UDP data ports
+ wire [15:0] dsp0_udp_port, dsp1_udp_port;
+ setting_reg #(.my_addr(CTRL_BASE+2)) sreg_data_ports(
+ .clk(stream_clk),.rst(stream_rst),
+ .strobe(set_stb),.addr(set_addr),.in(set_data),
+ .out({dsp1_udp_port, dsp0_udp_port}),.changed()
+ );
+
+ //assign status output signals
+ wire [31:0] cpu_iface_status;
+ assign status = {
+ cpu_iface_status[31:9], master_mode_flag, cpu_iface_status[7:0]
+ };
+
+ ////////////////////////////////////////////////////////////////////
+ // Communication input source crossbar
+ // When in master mode:
+ // - serdes input -> comm output combiner
+ // - ethernet input -> comm input inspector
+ // When in slave mode:
+ // - serdes input -> comm input inspector
+ // - ethernet input -> null sink
+ ////////////////////////////////////////////////////////////////////
+
+ //streaming signals from the crossbar to the combiner
+ wire [35:0] ext_inp_data;
+ wire ext_inp_valid;
+ wire ext_inp_ready;
+
+ //dummy signals for valve/xbar below
+ wire [35:0] _eth_inp_data;
+ wire _eth_inp_valid;
+ wire _eth_inp_ready;
+
+ valve36 eth_inp_valve (
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr), .shutoff(~master_mode_flag),
+ .data_i(eth_inp_data), .src_rdy_i(eth_inp_valid), .dst_rdy_o(eth_inp_ready),
+ .data_o(_eth_inp_data), .src_rdy_o(_eth_inp_valid), .dst_rdy_i(_eth_inp_ready)
+ );
+
+ crossbar36 com_inp_xbar (
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr), .cross(~master_mode_flag),
+ .data0_i(_eth_inp_data), .src0_rdy_i(_eth_inp_valid), .dst0_rdy_o(_eth_inp_ready),
+ .data1_i(ser_inp_data), .src1_rdy_i(ser_inp_valid), .dst1_rdy_o(ser_inp_ready),
+ .data0_o(com_inp_data), .src0_rdy_o(com_inp_valid), .dst0_rdy_i(com_inp_ready),
+ .data1_o(ext_inp_data), .src1_rdy_o(ext_inp_valid), .dst1_rdy_i(ext_inp_ready)
+ );
+
+ ////////////////////////////////////////////////////////////////////
+ // Communication output sink crossbar
+ // When in master mode:
+ // - comm output -> ethernet output
+ // - insp output -> serdes output
+ // When in slave mode:
+ // - com output -> serdes output
+ // - insp output -> null sink
+ ////////////////////////////////////////////////////////////////////
+
+ //streaming signals from the inspector to the crossbar
+ wire [35:0] ext_out_data;
+ wire ext_out_valid;
+ wire ext_out_ready;
+
+ //dummy signals for valve/xbar below
+ wire [35:0] _eth_out_data;
+ wire _eth_out_valid;
+ wire _eth_out_ready;
+
+ crossbar36 com_out_xbar (
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr), .cross(~master_mode_flag),
+ .data0_i(com_out_data), .src0_rdy_i(com_out_valid), .dst0_rdy_o(com_out_ready),
+ .data1_i(ext_out_data), .src1_rdy_i(ext_out_valid), .dst1_rdy_o(ext_out_ready),
+ .data0_o(_eth_out_data), .src0_rdy_o(_eth_out_valid), .dst0_rdy_i(_eth_out_ready),
+ .data1_o(ser_out_data), .src1_rdy_o(ser_out_valid), .dst1_rdy_i(ser_out_ready)
+ );
+
+ valve36 eth_out_valve (
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr), .shutoff(~master_mode_flag),
+ .data_i(_eth_out_data), .src_rdy_i(_eth_out_valid), .dst_rdy_o(_eth_out_ready),
+ .data_o(eth_out_data), .src_rdy_o(eth_out_valid), .dst_rdy_i(eth_out_ready)
+ );
+
+ ////////////////////////////////////////////////////////////////////
+ // Communication output source combiner (feeds UDP proto machine)
+ // - DSP framer
+ // - CPU input
+ // - ERR input
+ ////////////////////////////////////////////////////////////////////
+
+ //streaming signals from the dsp framer to the combiner
+ wire [35:0] dsp_frm_data;
+ wire dsp_frm_valid;
+ wire dsp_frm_ready;
+
+ //dummy signals to join the the muxes below
+ wire [35:0] _combiner0_data, _combiner1_data;
+ wire _combiner0_valid, _combiner1_valid;
+ wire _combiner0_ready, _combiner1_ready;
+
+ fifo36_mux _com_output_combiner0(
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .data0_i(dsp_frm_data), .src0_rdy_i(dsp_frm_valid), .dst0_rdy_o(dsp_frm_ready),
+ .data1_i(err_inp_data), .src1_rdy_i(err_inp_valid), .dst1_rdy_o(err_inp_ready),
+ .data_o(_combiner0_data), .src_rdy_o(_combiner0_valid), .dst_rdy_i(_combiner0_ready)
+ );
+
+ fifo36_mux _com_output_combiner1(
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .data0_i(32'b0), .src0_rdy_i(1'b0), .dst0_rdy_o(), //mux out from dsp1 can go here
+ .data1_i(cpu_inp_data), .src1_rdy_i(cpu_inp_valid), .dst1_rdy_o(cpu_inp_ready),
+ .data_o(_combiner1_data), .src_rdy_o(_combiner1_valid), .dst_rdy_i(_combiner1_ready)
+ );
+
+ fifo36_mux com_output_source(
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .data0_i(_combiner0_data), .src0_rdy_i(_combiner0_valid), .dst0_rdy_o(_combiner0_ready),
+ .data1_i(_combiner1_data), .src1_rdy_i(_combiner1_valid), .dst1_rdy_o(_combiner1_ready),
+ .data_o(udp_out_data), .src_rdy_o(udp_out_valid), .dst_rdy_i(udp_out_ready)
+ );
+
+ ////////////////////////////////////////////////////////////////////
+ // Interface CPU to memory mapped wishbone
+ ////////////////////////////////////////////////////////////////////
+ buffer_int2 #(.BASE(CTRL_BASE+3), .BUF_SIZE(BUF_SIZE)) cpu_to_wb(
+ .clk(stream_clk), .rst(stream_rst | stream_clr),
+ .set_stb(set_stb), .set_addr(set_addr), .set_data(set_data),
+ .status(cpu_iface_status),
+ // Wishbone interface to RAM
+ .wb_clk_i(wb_clk_i), .wb_rst_i(wb_rst_i),
+ .wb_we_i(wb_we_i), .wb_stb_i(wb_stb_i),
+ .wb_adr_i(wb_adr_i), .wb_dat_i(wb_dat_i),
+ .wb_dat_o(wb_dat_o), .wb_ack_o(wb_ack_o),
+ // Write FIFO Interface (from PR and into WB)
+ .wr_data_i(cpu_out_data),
+ .wr_ready_i(cpu_out_valid),
+ .wr_ready_o(cpu_out_ready),
+ // Read FIFO Interface (from WB and into PR)
+ .rd_data_o(cpu_inp_data),
+ .rd_ready_o(cpu_inp_valid),
+ .rd_ready_i(cpu_inp_ready)
+ );
+
+ ////////////////////////////////////////////////////////////////////
+ // Communication input inspector
+ // - inspect com input and send it to DSP, EXT, CPU, or BOTH
+ ////////////////////////////////////////////////////////////////////
+ localparam COM_INSP_STATE_READ_COM_PRE = 0;
+ localparam COM_INSP_STATE_READ_COM = 1;
+ localparam COM_INSP_STATE_WRITE_REGS = 2;
+ localparam COM_INSP_STATE_WRITE_LIVE = 3;
+
+ localparam COM_INSP_DEST_DSP = 0;
+ localparam COM_INSP_DEST_EXT = 1;
+ localparam COM_INSP_DEST_CPU = 2;
+ localparam COM_INSP_DEST_BOF = 3;
+
+ localparam COM_INSP_MAX_NUM_DREGS = 13; //padded_eth + ip + udp + seq + vrt_hdr
+ localparam COM_INSP_DREGS_DSP_OFFSET = 11; //offset to start dsp at
+
+ //output inspector interfaces
+ wire [35:0] com_insp_out_dsp_data;
+ wire com_insp_out_dsp_valid;
+ wire com_insp_out_dsp_ready;
+
+ wire [35:0] com_insp_out_ext_data;
+ wire com_insp_out_ext_valid;
+ wire com_insp_out_ext_ready;
+
+ wire [35:0] com_insp_out_cpu_data;
+ wire com_insp_out_cpu_valid;
+ wire com_insp_out_cpu_ready;
+
+ wire [35:0] com_insp_out_bof_data;
+ wire com_insp_out_bof_valid;
+ wire com_insp_out_bof_ready;
+
+ //connect this fast-path signals directly to the DSP out
+ assign dsp_out_data = com_insp_out_dsp_data;
+ assign dsp_out_valid = com_insp_out_dsp_valid;
+ assign com_insp_out_dsp_ready = dsp_out_ready;
+
+ reg [1:0] com_insp_state;
+ reg [1:0] com_insp_dest;
+ reg [3:0] com_insp_dreg_count; //data registers to buffer headers
+ wire [3:0] com_insp_dreg_count_next = com_insp_dreg_count + 1'b1;
+ wire com_insp_dreg_counter_done = (com_insp_dreg_count_next == COM_INSP_MAX_NUM_DREGS)? 1'b1 : 1'b0;
+ reg [35:0] com_insp_dregs [COM_INSP_MAX_NUM_DREGS-1:0];
+
+ //extract various packet components:
+ wire [47:0] com_insp_dregs_eth_dst_mac = {com_insp_dregs[0][15:0], com_insp_dregs[1][31:0]};
+ wire [15:0] com_insp_dregs_eth_type = com_insp_dregs[3][15:0];
+ wire [7:0] com_insp_dregs_ipv4_proto = com_insp_dregs[6][23:16];
+ wire [31:0] com_insp_dregs_ipv4_dst_addr = com_insp_dregs[8][31:0];
+ wire [15:0] com_insp_dregs_udp_dst_port = com_insp_dregs[9][15:0];
+ wire [15:0] com_insp_dregs_vrt_size = com_inp_data[15:0];
+
+ //Inspector output flags special case:
+ //Inject SOF into flags at first DSP line.
+ wire [3:0] com_insp_out_flags = (
+ (com_insp_dreg_count == COM_INSP_DREGS_DSP_OFFSET) &&
+ (com_insp_dest == COM_INSP_DEST_DSP)
+ )? 4'b0001 : com_insp_dregs[com_insp_dreg_count][35:32];
+
+ //The communication inspector ouput data and valid signals:
+ //Mux between com input and data registers based on the state.
+ wire [35:0] com_insp_out_data = (com_insp_state == COM_INSP_STATE_WRITE_REGS)?
+ {com_insp_out_flags, com_insp_dregs[com_insp_dreg_count][31:0]} : com_inp_data
+ ;
+ wire com_insp_out_valid =
+ (com_insp_state == COM_INSP_STATE_WRITE_REGS)? 1'b1 : (
+ (com_insp_state == COM_INSP_STATE_WRITE_LIVE)? com_inp_valid : (
+ 1'b0));
+
+ //The communication inspector ouput ready signal:
+ //Mux between the various destination ready signals.
+ wire com_insp_out_ready =
+ (com_insp_dest == COM_INSP_DEST_DSP)? com_insp_out_dsp_ready : (
+ (com_insp_dest == COM_INSP_DEST_EXT)? com_insp_out_ext_ready : (
+ (com_insp_dest == COM_INSP_DEST_CPU)? com_insp_out_cpu_ready : (
+ (com_insp_dest == COM_INSP_DEST_BOF)? com_insp_out_bof_ready : (
+ 1'b0))));
+
+ //Always connected output data lines.
+ assign com_insp_out_dsp_data = com_insp_out_data;
+ assign com_insp_out_ext_data = com_insp_out_data;
+ assign com_insp_out_cpu_data = com_insp_out_data;
+ assign com_insp_out_bof_data = com_insp_out_data;
+
+ //Destination output valid signals:
+ //Comes from inspector valid when destination is selected, and otherwise low.
+ assign com_insp_out_dsp_valid = (com_insp_dest == COM_INSP_DEST_DSP)? com_insp_out_valid : 1'b0;
+ assign com_insp_out_ext_valid = (com_insp_dest == COM_INSP_DEST_EXT)? com_insp_out_valid : 1'b0;
+ assign com_insp_out_cpu_valid = (com_insp_dest == COM_INSP_DEST_CPU)? com_insp_out_valid : 1'b0;
+ assign com_insp_out_bof_valid = (com_insp_dest == COM_INSP_DEST_BOF)? com_insp_out_valid : 1'b0;
+
+ //The communication inspector ouput ready signal:
+ //Always ready when storing to data registers,
+ //comes from inspector ready output when live,
+ //and otherwise low.
+ assign com_inp_ready =
+ (com_insp_state == COM_INSP_STATE_READ_COM_PRE) ? 1'b1 : (
+ (com_insp_state == COM_INSP_STATE_READ_COM) ? 1'b1 : (
+ (com_insp_state == COM_INSP_STATE_WRITE_LIVE) ? com_insp_out_ready : (
+ 1'b0)));
+
+ always @(posedge stream_clk)
+ if(stream_rst | stream_clr) begin
+ com_insp_state <= COM_INSP_STATE_READ_COM_PRE;
+ com_insp_dreg_count <= 0;
+ end
+ else begin
+ case(com_insp_state)
+ COM_INSP_STATE_READ_COM_PRE: begin
+ if (com_inp_ready & com_inp_valid & com_inp_data[32]) begin
+ com_insp_state <= COM_INSP_STATE_READ_COM;
+ com_insp_dreg_count <= com_insp_dreg_count_next;
+ com_insp_dregs[com_insp_dreg_count] <= com_inp_data;
+ end
+ end
+
+ COM_INSP_STATE_READ_COM: begin
+ if (com_inp_ready & com_inp_valid) begin
+ com_insp_dregs[com_insp_dreg_count] <= com_inp_data;
+ if (com_insp_dreg_counter_done | com_inp_data[33]) begin
+ com_insp_state <= COM_INSP_STATE_WRITE_REGS;
+ com_insp_dreg_count <= 0;
+
+ //---------- begin inspection decision -----------//
+ //EOF or bcast or not IPv4 or not UDP:
+ if (
+ com_inp_data[33] || (com_insp_dregs_eth_dst_mac == 48'hffffffffffff) ||
+ (com_insp_dregs_eth_type != 16'h800) || (com_insp_dregs_ipv4_proto != 8'h11)
+ ) begin
+ com_insp_dest <= COM_INSP_DEST_BOF;
+ end
+
+ //not my IP address:
+ else if (com_insp_dregs_ipv4_dst_addr != my_ip_addr) begin
+ com_insp_dest <= COM_INSP_DEST_EXT;
+ end
+
+ //UDP data port and VRT:
+ else if ((com_insp_dregs_udp_dst_port == dsp0_udp_port) && (com_insp_dregs_vrt_size != 16'h0)) begin
+ com_insp_dest <= COM_INSP_DEST_DSP;
+ com_insp_dreg_count <= COM_INSP_DREGS_DSP_OFFSET;
+ end
+
+ //other:
+ else begin
+ com_insp_dest <= COM_INSP_DEST_CPU;
+ end
+ //---------- end inspection decision -------------//
+
+ end
+ else begin
+ com_insp_dreg_count <= com_insp_dreg_count_next;
+ end
+ end
+ end
+
+ COM_INSP_STATE_WRITE_REGS: begin
+ if (com_insp_out_ready & com_insp_out_valid) begin
+ if (com_insp_out_data[33]) begin
+ com_insp_state <= COM_INSP_STATE_READ_COM_PRE;
+ com_insp_dreg_count <= 0;
+ end
+ else if (com_insp_dreg_counter_done) begin
+ com_insp_state <= COM_INSP_STATE_WRITE_LIVE;
+ com_insp_dreg_count <= 0;
+ end
+ else begin
+ com_insp_dreg_count <= com_insp_dreg_count_next;
+ end
+ end
+ end
+
+ COM_INSP_STATE_WRITE_LIVE: begin
+ if (com_insp_out_ready & com_insp_out_valid & com_insp_out_data[33]) begin
+ com_insp_state <= COM_INSP_STATE_READ_COM_PRE;
+ end
+ end
+
+ endcase //com_insp_state
+ end
+
+ ////////////////////////////////////////////////////////////////////
+ // Splitter and output muxes for the bof packets
+ // - split the bof packets into two streams
+ // - mux split packets into cpu out and ext out
+ ////////////////////////////////////////////////////////////////////
+
+ //dummy signals to join the the splitter and muxes below
+ wire [35:0] _split_to_ext_data, _split_to_cpu_data, _cpu_out_data;
+ wire _split_to_ext_valid, _split_to_cpu_valid, _cpu_out_valid;
+ wire _split_to_ext_ready, _split_to_cpu_ready, _cpu_out_ready;
+
+ splitter36 bof_out_splitter(
+ .clk(stream_clk), .rst(stream_rst), .clr(stream_clr),
+ .inp_data(com_insp_out_bof_data), .inp_valid(com_insp_out_bof_valid), .inp_ready(com_insp_out_bof_ready),
+ .out0_data(_split_to_ext_data), .out0_valid(_split_to_ext_valid), .out0_ready(_split_to_ext_ready),
+ .out1_data(_split_to_cpu_data), .out1_valid(_split_to_cpu_valid), .out1_ready(_split_to_cpu_ready)
+ );
+
+ fifo36_mux ext_out_mux(
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .data0_i(com_insp_out_ext_data), .src0_rdy_i(com_insp_out_ext_valid), .dst0_rdy_o(com_insp_out_ext_ready),
+ .data1_i(_split_to_ext_data), .src1_rdy_i(_split_to_ext_valid), .dst1_rdy_o(_split_to_ext_ready),
+ .data_o(ext_out_data), .src_rdy_o(ext_out_valid), .dst_rdy_i(ext_out_ready)
+ );
+
+ fifo36_mux cpu_out_mux(
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .data0_i(com_insp_out_cpu_data), .src0_rdy_i(com_insp_out_cpu_valid), .dst0_rdy_o(com_insp_out_cpu_ready),
+ .data1_i(_split_to_cpu_data), .src1_rdy_i(_split_to_cpu_valid), .dst1_rdy_o(_split_to_cpu_ready),
+ .data_o(_cpu_out_data), .src_rdy_o(_cpu_out_valid), .dst_rdy_i(_cpu_out_ready)
+ );
+
+ fifo_cascade #(.WIDTH(36), .SIZE(9/*512 lines plenty for short pkts*/)) cpu_out_fifo (
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .datain(_cpu_out_data), .src_rdy_i(_cpu_out_valid), .dst_rdy_o(_cpu_out_ready),
+ .dataout(cpu_out_data), .src_rdy_o(cpu_out_valid), .dst_rdy_i(cpu_out_ready)
+ );
+
+ ////////////////////////////////////////////////////////////////////
+ // DSP input framer
+ ////////////////////////////////////////////////////////////////////
+
+ dsp_framer36 #(.BUF_SIZE(BUF_SIZE)) dsp0_framer36(
+ .clk(stream_clk), .rst(stream_rst), .clr(stream_clr),
+ .inp_data(dsp_inp_data), .inp_valid(dsp_inp_valid), .inp_ready(dsp_inp_ready),
+ .out_data(dsp_frm_data), .out_valid(dsp_frm_valid), .out_ready(dsp_frm_ready)
+ );
+
+ ////////////////////////////////////////////////////////////////////
+ // UDP TX Protocol machine
+ ////////////////////////////////////////////////////////////////////
+
+ //dummy signals to connect the components below
+ wire [18:0] _udp_r2s_data, _udp_s2p_data, _udp_p2s_data, _udp_s2r_data;
+ wire _udp_r2s_valid, _udp_s2p_valid, _udp_p2s_valid, _udp_s2r_valid;
+ wire _udp_r2s_ready, _udp_s2p_ready, _udp_p2s_ready, _udp_s2r_ready;
+
+ wire [35:0] _com_out_data;
+ wire _com_out_valid, _com_out_ready;
+
+ fifo36_to_fifo19 udp_fifo36_to_fifo19
+ (.clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .f36_datain(udp_out_data), .f36_src_rdy_i(udp_out_valid), .f36_dst_rdy_o(udp_out_ready),
+ .f19_dataout(_udp_r2s_data), .f19_src_rdy_o(_udp_r2s_valid), .f19_dst_rdy_i(_udp_r2s_ready) );
+
+ fifo_short #(.WIDTH(19)) udp_shortfifo19_inp
+ (.clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .datain(_udp_r2s_data), .src_rdy_i(_udp_r2s_valid), .dst_rdy_o(_udp_r2s_ready),
+ .dataout(_udp_s2p_data), .src_rdy_o(_udp_s2p_valid), .dst_rdy_i(_udp_s2p_ready),
+ .space(), .occupied() );
+
+ prot_eng_tx #(.BASE(UDP_BASE)) udp_prot_eng_tx
+ (.clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .set_stb(set_stb), .set_addr(set_addr), .set_data(set_data),
+ .datain(_udp_s2p_data), .src_rdy_i(_udp_s2p_valid), .dst_rdy_o(_udp_s2p_ready),
+ .dataout(_udp_p2s_data), .src_rdy_o(_udp_p2s_valid), .dst_rdy_i(_udp_p2s_ready) );
+
+ fifo_short #(.WIDTH(19)) udp_shortfifo19_out
+ (.clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .datain(_udp_p2s_data), .src_rdy_i(_udp_p2s_valid), .dst_rdy_o(_udp_p2s_ready),
+ .dataout(_udp_s2r_data), .src_rdy_o(_udp_s2r_valid), .dst_rdy_i(_udp_s2r_ready),
+ .space(), .occupied() );
+
+ fifo19_to_fifo36 udp_fifo19_to_fifo36
+ (.clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .f19_datain(_udp_s2r_data), .f19_src_rdy_i(_udp_s2r_valid), .f19_dst_rdy_o(_udp_s2r_ready),
+ .f36_dataout(_com_out_data), .f36_src_rdy_o(_com_out_valid), .f36_dst_rdy_i(_com_out_ready) );
+
+ fifo36_mux com_out_mux(
+ .clk(stream_clk), .reset(stream_rst), .clear(stream_clr),
+ .data0_i(ext_inp_data), .src0_rdy_i(ext_inp_valid), .dst0_rdy_o(ext_inp_ready),
+ .data1_i(_com_out_data), .src1_rdy_i(_com_out_valid), .dst1_rdy_o(_com_out_ready),
+ .data_o(com_out_data), .src_rdy_o(com_out_valid), .dst_rdy_i(com_out_ready)
+ );
+
+ ////////////////////////////////////////////////////////////////////
+ // Assign debugs
+ ////////////////////////////////////////////////////////////////////
+
+ assign debug = {
+ //inputs to the router (8)
+ dsp_inp_ready, dsp_inp_valid,
+ ser_inp_ready, ser_inp_valid,
+ eth_inp_ready, eth_inp_valid,
+ cpu_inp_ready, cpu_inp_valid,
+
+ //outputs from the router (8)
+ dsp_out_ready, dsp_out_valid,
+ ser_out_ready, ser_out_valid,
+ eth_out_ready, eth_out_valid,
+ cpu_out_ready, cpu_out_valid,
+
+ //inspector interfaces (8)
+ com_insp_out_dsp_ready, com_insp_out_dsp_valid,
+ com_insp_out_ext_ready, com_insp_out_ext_valid,
+ com_insp_out_cpu_ready, com_insp_out_cpu_valid,
+ com_insp_out_bof_ready, com_insp_out_bof_valid,
+
+ //other interfaces (8)
+ ext_inp_ready, ext_inp_valid,
+ com_out_ready, com_out_valid,
+ ext_out_ready, ext_out_valid,
+ com_inp_ready, com_inp_valid
+ };
+
+endmodule // packet_router
diff --git a/fpga/usrp2/fifo/splitter36.v b/fpga/usrp2/fifo/splitter36.v
new file mode 100644
index 000000000..ed998b4f5
--- /dev/null
+++ b/fpga/usrp2/fifo/splitter36.v
@@ -0,0 +1,68 @@
+
+// Split packets from a fifo based interface so it goes out identically on two interfaces
+
+module splitter36
+ (
+ input clk, input rst, input clr,
+ input [35:0] inp_data, input inp_valid, output inp_ready,
+ output [35:0] out0_data, output out0_valid, input out0_ready,
+ output [35:0] out1_data, output out1_valid, input out1_ready
+ );
+
+ localparam STATE_COPY_BOTH = 0;
+ localparam STATE_COPY_ZERO = 1;
+ localparam STATE_COPY_ONE = 2;
+
+ reg [1:0] state;
+ reg [35:0] data_reg;
+
+ assign out0_data = (state == STATE_COPY_BOTH)? inp_data : data_reg;
+ assign out1_data = (state == STATE_COPY_BOTH)? inp_data : data_reg;
+
+ assign out0_valid =
+ (state == STATE_COPY_BOTH)? inp_valid : (
+ (state == STATE_COPY_ZERO)? 1'b1 : (
+ 1'b0));
+
+ assign out1_valid =
+ (state == STATE_COPY_BOTH)? inp_valid : (
+ (state == STATE_COPY_ONE)? 1'b1 : (
+ 1'b0));
+
+ assign inp_ready = (state == STATE_COPY_BOTH)? (out0_ready | out1_ready) : 1'b0;
+
+ always @(posedge clk)
+ if (rst | clr) begin
+ state <= STATE_COPY_BOTH;
+ end
+ else begin
+ case (state)
+
+ STATE_COPY_BOTH: begin
+ if ((out0_valid & out0_ready) & ~(out1_valid & out1_ready)) begin
+ state <= STATE_COPY_ONE;
+ end
+ else if (~(out0_valid & out0_ready) & (out1_valid & out1_ready)) begin
+ state <= STATE_COPY_ZERO;
+ end
+ data_reg <= inp_data;
+ end
+
+ STATE_COPY_ZERO: begin
+ if (out0_valid & out0_ready) begin
+ state <= STATE_COPY_BOTH;
+ end
+ end
+
+ STATE_COPY_ONE: begin
+ if (out1_valid & out1_ready) begin
+ state <= STATE_COPY_BOTH;
+ end
+ end
+
+ endcase //state
+ end
+
+
+
+endmodule //splitter36
diff --git a/fpga/usrp2/fifo/valve36.v b/fpga/usrp2/fifo/valve36.v
new file mode 100644
index 000000000..d45eee497
--- /dev/null
+++ b/fpga/usrp2/fifo/valve36.v
@@ -0,0 +1,29 @@
+
+
+module valve36
+ (input clk, input reset, input clear,
+ input shutoff,
+ input [35:0] data_i, input src_rdy_i, output dst_rdy_o,
+ output [35:0] data_o, output src_rdy_o, input dst_rdy_i);
+
+ reg shutoff_int, active;
+ wire active_next = (src_rdy_i & dst_rdy_o)? ~data_i[33] : active;
+
+ assign data_o = data_i;
+
+ assign dst_rdy_o = shutoff_int ? 1'b1 : dst_rdy_i;
+ assign src_rdy_o = shutoff_int ? 1'b0 : src_rdy_i;
+
+ always @(posedge clk)
+ if(reset | clear)
+ active <= 0;
+ else
+ active <= active_next;
+
+ always @(posedge clk)
+ if(reset | clear)
+ shutoff_int <= 0;
+ else if(~active_next)
+ shutoff_int <= shutoff;
+
+endmodule // valve36
diff --git a/fpga/usrp2/opencores/Makefile.srcs b/fpga/usrp2/opencores/Makefile.srcs
index 284578b39..838b1b813 100644
--- a/fpga/usrp2/opencores/Makefile.srcs
+++ b/fpga/usrp2/opencores/Makefile.srcs
@@ -25,4 +25,12 @@ spi/rtl/verilog/spi_defines.v \
spi/rtl/verilog/spi_shift.v \
spi/rtl/verilog/spi_top.v \
spi/rtl/verilog/spi_top16.v \
+zpu/zpu_top_pkg.vhd \
+zpu/zpu_wb_top.vhd \
+zpu/wishbone/wishbone_pkg.vhd \
+zpu/wishbone/zpu_system.vhd \
+zpu/wishbone/zpu_wb_bridge.vhd \
+zpu/core/zpu_config.vhd \
+zpu/core/zpu_core.vhd \
+zpu/core/zpupkg.vhd \
))
diff --git a/fpga/usrp2/opencores/zpu/core/zpu_config.vhd b/fpga/usrp2/opencores/zpu/core/zpu_config.vhd
new file mode 100644
index 000000000..b7e894232
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/core/zpu_config.vhd
@@ -0,0 +1,15 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.std_logic_unsigned.all;
+
+package zpu_config is
+ -- generate trace output or not.
+ constant Generate_Trace : boolean := false;
+ constant wordPower : integer := 5;
+ -- during simulation, set this to '0' to get matching trace.txt
+ constant DontCareValue : std_logic := '0';
+ -- Clock frequency in MHz.
+ constant ZPU_Frequency : std_logic_vector(7 downto 0) := x"40";
+ -- This is the msb address bit. bytes=2^(maxAddrBitIncIO+1)
+ constant maxAddrBitIncIO : integer := 15;
+end zpu_config;
diff --git a/fpga/usrp2/opencores/zpu/core/zpu_core.vhd b/fpga/usrp2/opencores/zpu/core/zpu_core.vhd
new file mode 100644
index 000000000..24586b2f6
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/core/zpu_core.vhd
@@ -0,0 +1,949 @@
+
+-- Company: ZPU4 generic memory interface CPU
+-- Engineer: Øyvind Harboe
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+use IEEE.STD_LOGIC_arith.ALL;
+
+library work;
+use work.zpu_config.all;
+use work.zpupkg.all;
+
+
+
+
+
+entity zpu_core is
+ Port ( clk : in std_logic;
+ areset : in std_logic;
+ enable : in std_logic;
+ mem_req : out std_logic;
+ mem_we : out std_logic;
+ mem_ack : in std_logic;
+ mem_read : in std_logic_vector(wordSize-1 downto 0);
+ mem_write : out std_logic_vector(wordSize-1 downto 0);
+ out_mem_addr : out std_logic_vector(maxAddrBitIncIO downto 0);
+ mem_writeMask: out std_logic_vector(wordBytes-1 downto 0);
+ stack_start : in std_logic_vector(maxAddrBitIncIO downto 0);
+ interrupt : in std_logic;
+ break : out std_logic;
+ zpu_status : out std_logic_vector(63 downto 0));
+end zpu_core;
+
+architecture behave of zpu_core is
+
+type InsnType is
+(
+State_AddTop,
+State_Dup,
+State_DupStackB,
+State_Pop,
+State_Popdown,
+State_Add,
+State_Or,
+State_And,
+State_Store,
+State_AddSP,
+State_Shift,
+State_Nop,
+State_Im,
+State_LoadSP,
+State_StoreSP,
+State_Emulate,
+State_Load,
+State_PushPC,
+State_PushSP,
+State_PopPC,
+State_PopPCRel,
+State_Not,
+State_Flip,
+State_PopSP,
+State_Neqbranch,
+State_Eq,
+State_Loadb,
+State_Mult,
+State_Lessthan,
+State_Lessthanorequal,
+State_Ulessthanorequal,
+State_Ulessthan,
+State_Pushspadd,
+State_Call,
+State_Callpcrel,
+State_Sub,
+State_Break,
+State_Storeb,
+State_Interrupt,
+State_InsnFetch
+);
+
+type StateType is
+(
+State_Idle, -- using first state first on the list out of paranoia
+State_Load2,
+State_Popped,
+State_LoadSP2,
+State_LoadSP3,
+State_AddSP2,
+State_Fetch,
+State_Execute,
+State_Decode,
+State_Decode2,
+State_Resync,
+
+State_StoreSP2,
+State_Resync2,
+State_Resync3,
+State_Loadb2,
+State_Storeb2,
+State_Mult2,
+State_Mult3,
+State_Mult5,
+State_Mult6,
+State_Mult4,
+State_BinaryOpResult
+);
+
+
+signal pc : std_logic_vector(maxAddrBitIncIO downto 0);
+signal sp : std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+signal incSp : std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+signal incIncSp : std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+signal decSp : std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+signal stackA : std_logic_vector(wordSize-1 downto 0);
+signal binaryOpResult : std_logic_vector(wordSize-1 downto 0);
+signal multResult2 : std_logic_vector(wordSize-1 downto 0);
+signal multResult3 : std_logic_vector(wordSize-1 downto 0);
+signal multResult : std_logic_vector(wordSize-1 downto 0);
+signal multA : std_logic_vector(wordSize-1 downto 0);
+signal multB : std_logic_vector(wordSize-1 downto 0);
+signal stackB : std_logic_vector(wordSize-1 downto 0);
+signal idim_flag : std_logic;
+signal busy : std_logic;
+signal mem_readEnable : std_logic;
+signal mem_addr : std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+signal mem_delayAddr : std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+signal mem_delayReadEnable : std_logic;
+signal mem_busy : std_logic;
+signal decodeWord : std_logic_vector(wordSize-1 downto 0);
+
+
+signal state : StateType;
+signal insn : InsnType;
+type InsnArray is array(0 to wordBytes-1) of InsnType;
+signal decodedOpcode : InsnArray;
+
+type OpcodeArray is array(0 to wordBytes-1) of std_logic_vector(7 downto 0);
+
+signal opcode : OpcodeArray;
+
+
+
+
+signal begin_inst : std_logic;
+signal trace_opcode : std_logic_vector(7 downto 0);
+signal trace_pc : std_logic_vector(maxAddrBitIncIO downto 0);
+signal trace_sp : std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+signal trace_topOfStack : std_logic_vector(wordSize-1 downto 0);
+signal trace_topOfStackB : std_logic_vector(wordSize-1 downto 0);
+
+signal out_mem_req : std_logic;
+
+signal inInterrupt : std_logic;
+
+-- state machine.
+
+begin
+
+ zpu_status(maxAddrBitIncIO downto 0) <= trace_pc;
+ zpu_status(31) <= '1';
+ zpu_status(39 downto 32) <= trace_opcode;
+ zpu_status(40) <= '1' when (state = State_Idle) else '0';
+ zpu_status(62) <= '1';
+
+ traceFileGenerate:
+ if Generate_Trace generate
+ trace_file: trace port map (
+ clk => clk,
+ begin_inst => begin_inst,
+ pc => trace_pc,
+ opcode => trace_opcode,
+ sp => trace_sp,
+ memA => trace_topOfStack,
+ memB => trace_topOfStackB,
+ busy => busy,
+ intsp => (others => 'U')
+ );
+ end generate;
+
+
+ -- the memory subsystem will tell us one cycle later whether or
+ -- not it is busy
+ out_mem_addr(maxAddrBitIncIO downto minAddrBit) <= mem_addr;
+ out_mem_addr(minAddrBit-1 downto 0) <= (others => '0');
+ mem_req <= out_mem_req;
+
+ incSp <= sp + 1;
+ incIncSp <= sp + 2;
+ decSp <= sp - 1;
+
+ mem_busy <= out_mem_req and not mem_ack; -- '1' when the memory is busy
+
+ opcodeControl:
+ process(clk, areset)
+ variable tOpcode : std_logic_vector(OpCode_Size-1 downto 0);
+ variable spOffset : std_logic_vector(4 downto 0);
+ variable tSpOffset : std_logic_vector(4 downto 0);
+ variable nextPC : std_logic_vector(maxAddrBitIncIO downto 0);
+ variable tNextState : InsnType;
+ variable tDecodedOpcode : InsnArray;
+ variable tMultResult : std_logic_vector(wordSize*2-1 downto 0);
+ begin
+ if areset = '1' then
+ state <= State_Idle;
+ break <= '0';
+ sp <= stack_start(maxAddrBitIncIO downto minAddrBit);
+
+ pc <= (others => '0');
+ idim_flag <= '0';
+ begin_inst <= '0';
+ mem_we <= '0';
+ multA <= (others => '0');
+ multB <= (others => '0');
+ mem_writeMask <= (others => '1');
+ out_mem_req <= '0';
+ mem_addr <= (others => DontCareValue);
+ mem_write <= (others => DontCareValue);
+ inInterrupt <= '0';
+ elsif (clk'event and clk = '1') then
+ -- we must multiply unconditionally to get pipelined multiplication
+ tMultResult := multA * multB;
+ multResult3 <= multResult2;
+ multResult2 <= multResult;
+ multResult <= tMultResult(wordSize-1 downto 0);
+
+
+ spOffset(4):=not opcode(conv_integer(pc(byteBits-1 downto 0)))(4);
+ spOffset(3 downto 0):=opcode(conv_integer(pc(byteBits-1 downto 0)))(3 downto 0);
+ nextPC := pc + 1;
+
+ -- prepare trace snapshot
+ trace_opcode <= opcode(conv_integer(pc(byteBits-1 downto 0)));
+ trace_pc <= pc;
+ trace_sp <= sp;
+ trace_topOfStack <= stackA;
+ trace_topOfStackB <= stackB;
+ begin_inst <= '0';
+
+ -- we terminate the requeset as soon as we get acknowledge
+ if mem_ack = '1' then
+ out_mem_req <= '0';
+ mem_we <= '0';
+ end if;
+
+ if interrupt='0' then
+ inInterrupt <= '0'; -- no longer in an interrupt
+ end if;
+
+ case state is
+ when State_Idle =>
+ if enable='1' then
+ state <= State_Resync;
+ end if;
+ -- Initial state of ZPU, fetch top of stack + first instruction
+ when State_Resync =>
+ if mem_busy='0' then
+ mem_addr <= sp;
+ out_mem_req <= '1';
+ state <= State_Resync2;
+ end if;
+ when State_Resync2 =>
+ if mem_busy='0' then
+ stackA <= mem_read;
+ mem_addr <= incSp;
+ out_mem_req <= '1';
+ state <= State_Resync3;
+ end if;
+ when State_Resync3 =>
+ if mem_busy='0' then
+ stackB <= mem_read;
+ mem_addr <= pc(maxAddrBitIncIO downto minAddrBit);
+ out_mem_req <= '1';
+ state <= State_Decode;
+ end if;
+ when State_Decode =>
+ if mem_busy='0' then
+ decodeWord <= mem_read;
+ state <= State_Decode2;
+ end if;
+ when State_Decode2 =>
+ -- decode 4 instructions in parallel
+ for i in 0 to wordBytes-1 loop
+ tOpcode := decodeWord((wordBytes-1-i+1)*8-1 downto (wordBytes-1-i)*8);
+
+ tSpOffset(4):=not tOpcode(4);
+ tSpOffset(3 downto 0):=tOpcode(3 downto 0);
+
+ opcode(i) <= tOpcode;
+ if (tOpcode(7 downto 7)=OpCode_Im) then
+ tNextState:=State_Im;
+ elsif (tOpcode(7 downto 5)=OpCode_StoreSP) then
+ if tSpOffset = 0 then
+ tNextState := State_Pop;
+ elsif tSpOffset=1 then
+ tNextState := State_PopDown;
+ else
+ tNextState :=State_StoreSP;
+ end if;
+ elsif (tOpcode(7 downto 5)=OpCode_LoadSP) then
+ if tSpOffset = 0 then
+ tNextState :=State_Dup;
+ elsif tSpOffset = 1 then
+ tNextState :=State_DupStackB;
+ else
+ tNextState :=State_LoadSP;
+ end if;
+ elsif (tOpcode(7 downto 5)=OpCode_Emulate) then
+ tNextState :=State_Emulate;
+ if tOpcode(5 downto 0)=OpCode_Neqbranch then
+ tNextState :=State_Neqbranch;
+ elsif tOpcode(5 downto 0)=OpCode_Eq then
+ tNextState :=State_Eq;
+ elsif tOpcode(5 downto 0)=OpCode_Lessthan then
+ tNextState :=State_Lessthan;
+ elsif tOpcode(5 downto 0)=OpCode_Lessthanorequal then
+ --tNextState :=State_Lessthanorequal;
+ elsif tOpcode(5 downto 0)=OpCode_Ulessthan then
+ tNextState :=State_Ulessthan;
+ elsif tOpcode(5 downto 0)=OpCode_Ulessthanorequal then
+ --tNextState :=State_Ulessthanorequal;
+ elsif tOpcode(5 downto 0)=OpCode_Loadb then
+ tNextState :=State_Loadb;
+ elsif tOpcode(5 downto 0)=OpCode_Mult then
+ tNextState :=State_Mult;
+ elsif tOpcode(5 downto 0)=OpCode_Storeb then
+ tNextState :=State_Storeb;
+ elsif tOpcode(5 downto 0)=OpCode_Pushspadd then
+ tNextState :=State_Pushspadd;
+ elsif tOpcode(5 downto 0)=OpCode_Callpcrel then
+ tNextState :=State_Callpcrel;
+ elsif tOpcode(5 downto 0)=OpCode_Call then
+ --tNextState :=State_Call;
+ elsif tOpcode(5 downto 0)=OpCode_Sub then
+ tNextState :=State_Sub;
+ elsif tOpcode(5 downto 0)=OpCode_PopPCRel then
+ --tNextState :=State_PopPCRel;
+ end if;
+ elsif (tOpcode(7 downto 4)=OpCode_AddSP) then
+ if tSpOffset = 0 then
+ tNextState := State_Shift;
+ elsif tSpOffset = 1 then
+ tNextState := State_AddTop;
+ else
+ tNextState :=State_AddSP;
+ end if;
+ else
+ case tOpcode(3 downto 0) is
+ when OpCode_Nop =>
+ tNextState :=State_Nop;
+ when OpCode_PushSP =>
+ tNextState :=State_PushSP;
+ when OpCode_PopPC =>
+ tNextState :=State_PopPC;
+ when OpCode_Add =>
+ tNextState :=State_Add;
+ when OpCode_Or =>
+ tNextState :=State_Or;
+ when OpCode_And =>
+ tNextState :=State_And;
+ when OpCode_Load =>
+ tNextState :=State_Load;
+ when OpCode_Not =>
+ tNextState :=State_Not;
+ when OpCode_Flip =>
+ tNextState :=State_Flip;
+ when OpCode_Store =>
+ tNextState :=State_Store;
+ when OpCode_PopSP =>
+ tNextState :=State_PopSP;
+ when others =>
+ tNextState := State_Break;
+
+ end case;
+ end if;
+ tDecodedOpcode(i) := tNextState;
+
+ end loop;
+
+ insn <= tDecodedOpcode(conv_integer(pc(byteBits-1 downto 0)));
+
+ -- once we wrap, we need to fetch
+ tDecodedOpcode(0) := State_InsnFetch;
+
+ decodedOpcode <= tDecodedOpcode;
+ state <= State_Execute;
+
+
+
+ -- Each instruction must:
+ --
+ -- 1. set idim_flag
+ -- 2. increase pc if applicable
+ -- 3. set next state if appliable
+ -- 4. do it's operation
+
+ when State_Execute =>
+ insn <= decodedOpcode(conv_integer(nextPC(byteBits-1 downto 0)));
+
+ case insn is
+ when State_InsnFetch =>
+ state <= State_Fetch;
+ when State_Im =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '1';
+ pc <= pc + 1;
+
+ if idim_flag='1' then
+ stackA(wordSize-1 downto 7) <= stackA(wordSize-8 downto 0);
+ stackA(6 downto 0) <= opcode(conv_integer(pc(byteBits-1 downto 0)))(6 downto 0);
+ else
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= incSp;
+ mem_write <= stackB;
+ stackB <= stackA;
+ sp <= decSp;
+ for i in wordSize-1 downto 7 loop
+ stackA(i) <= opcode(conv_integer(pc(byteBits-1 downto 0)))(6);
+ end loop;
+ stackA(6 downto 0) <= opcode(conv_integer(pc(byteBits-1 downto 0)))(6 downto 0);
+ end if;
+ else
+ insn <= insn;
+ end if;
+ when State_StoreSP =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ state <= State_StoreSP2;
+
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= sp+spOffset;
+ mem_write <= stackA;
+ stackA <= stackB;
+ sp <= incSp;
+ else
+ insn <= insn;
+ end if;
+
+
+ when State_LoadSP =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ state <= State_LoadSP2;
+
+ sp <= decSp;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= incSp;
+ mem_write <= stackB;
+ else
+ insn <= insn;
+ end if;
+ when State_Emulate =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ sp <= decSp;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= incSp;
+ mem_write <= stackB;
+ stackA <= (others => DontCareValue);
+ stackA(maxAddrBitIncIO downto 0) <= pc + 1;
+ stackB <= stackA;
+
+ -- The emulate address is:
+ -- 98 7654 3210
+ -- 0000 00aa aaa0 0000
+ pc <= (others => '0');
+ pc(9 downto 5) <= opcode(conv_integer(pc(byteBits-1 downto 0)))(4 downto 0);
+ state <= State_Fetch;
+ else
+ insn <= insn;
+ end if;
+ when State_Callpcrel =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ stackA <= (others => DontCareValue);
+ stackA(maxAddrBitIncIO downto 0) <= pc + 1;
+
+ pc <= pc + stackA(maxAddrBitIncIO downto 0);
+ state <= State_Fetch;
+ else
+ insn <= insn;
+ end if;
+ when State_Call =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ stackA <= (others => DontCareValue);
+ stackA(maxAddrBitIncIO downto 0) <= pc + 1;
+ pc <= stackA(maxAddrBitIncIO downto 0);
+ state <= State_Fetch;
+ else
+ insn <= insn;
+ end if;
+ when State_AddSP =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ state <= State_AddSP2;
+
+ out_mem_req <= '1';
+ mem_addr <= sp+spOffset;
+ else
+ insn <= insn;
+ end if;
+ when State_PushSP =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ sp <= decSp;
+ stackA <= (others => '0');
+ stackA(maxAddrBitIncIO downto minAddrBit) <= sp;
+ stackB <= stackA;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= incSp;
+ mem_write <= stackB;
+ else
+ insn <= insn;
+ end if;
+ when State_PopPC =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= stackA(maxAddrBitIncIO downto 0);
+ sp <= incSp;
+
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= incSp;
+ mem_write <= stackB;
+ state <= State_Resync;
+ else
+ insn <= insn;
+ end if;
+ when State_PopPCRel =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= stackA(maxAddrBitIncIO downto 0) + pc;
+ sp <= incSp;
+
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= incSp;
+ mem_write <= stackB;
+ state <= State_Resync;
+ else
+ insn <= insn;
+ end if;
+ when State_Add =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ stackA <= stackA + stackB;
+
+ out_mem_req <= '1';
+ mem_addr <= incIncSp;
+ sp <= incSp;
+ state <= State_Popped;
+ else
+ insn <= insn;
+ end if;
+ when State_Sub =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+ binaryOpResult <= stackB - stackA;
+ state <= State_BinaryOpResult;
+ when State_Pop =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ mem_addr <= incIncSp;
+ out_mem_req <= '1';
+ sp <= incSp;
+ stackA <= stackB;
+ state <= State_Popped;
+ else
+ insn <= insn;
+ end if;
+ when State_PopDown =>
+ if mem_busy='0' then
+ -- PopDown leaves top of stack unchanged
+ begin_inst <= '1';
+ idim_flag <= '0';
+ mem_addr <= incIncSp;
+ out_mem_req <= '1';
+ sp <= incSp;
+ state <= State_Popped;
+ else
+ insn <= insn;
+ end if;
+ when State_Or =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ stackA <= stackA or stackB;
+ out_mem_req <= '1';
+ mem_addr <= incIncSp;
+ sp <= incSp;
+ state <= State_Popped;
+ else
+ insn <= insn;
+ end if;
+ when State_And =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+
+ stackA <= stackA and stackB;
+ out_mem_req <= '1';
+ mem_addr <= incIncSp;
+ sp <= incSp;
+ state <= State_Popped;
+ else
+ insn <= insn;
+ end if;
+ when State_Eq =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+
+ binaryOpResult <= (others => '0');
+ if (stackA=stackB) then
+ binaryOpResult(0) <= '1';
+ end if;
+ state <= State_BinaryOpResult;
+ when State_Ulessthan =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+
+ binaryOpResult <= (others => '0');
+ if (stackA<stackB) then
+ binaryOpResult(0) <= '1';
+ end if;
+ state <= State_BinaryOpResult;
+ when State_Ulessthanorequal =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+
+ binaryOpResult <= (others => '0');
+ if (stackA<=stackB) then
+ binaryOpResult(0) <= '1';
+ end if;
+ state <= State_BinaryOpResult;
+ when State_Lessthan =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+
+ binaryOpResult <= (others => '0');
+ if (signed(stackA)<signed(stackB)) then
+ binaryOpResult(0) <= '1';
+ end if;
+ state <= State_BinaryOpResult;
+ when State_Lessthanorequal =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+
+ binaryOpResult <= (others => '0');
+ if (signed(stackA)<=signed(stackB)) then
+ binaryOpResult(0) <= '1';
+ end if;
+ state <= State_BinaryOpResult;
+ when State_Load =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ state <= State_Load2;
+
+ mem_addr <= stackA(maxAddrBitIncIO downto minAddrBit);
+ out_mem_req <= '1';
+ else
+ insn <= insn;
+ end if;
+
+ when State_Dup =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ sp <= decSp;
+ stackB <= stackA;
+ mem_write <= stackB;
+ mem_addr <= incSp;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ else
+ insn <= insn;
+ end if;
+ when State_DupStackB =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ sp <= decSp;
+ stackA <= stackB;
+ stackB <= stackA;
+ mem_write <= stackB;
+ mem_addr <= incSp;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ else
+ insn <= insn;
+ end if;
+ when State_Store =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+ mem_addr <= stackA(maxAddrBitIncIO downto minAddrBit);
+ mem_write <= stackB;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ sp <= incIncSp;
+ state <= State_Resync;
+ else
+ insn <= insn;
+ end if;
+ when State_PopSP =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ mem_write <= stackB;
+ mem_addr <= incSp;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ sp <= stackA(maxAddrBitIncIO downto minAddrBit);
+ state <= State_Resync;
+ else
+ insn <= insn;
+ end if;
+ when State_Nop =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+ when State_Not =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ stackA <= not stackA;
+ when State_Flip =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ for i in 0 to wordSize-1 loop
+ stackA(i) <= stackA(wordSize-1-i);
+ end loop;
+ when State_AddTop =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ stackA <= stackA + stackB;
+ when State_Shift =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ stackA(wordSize-1 downto 1) <= stackA(wordSize-2 downto 0);
+ stackA(0) <= '0';
+ when State_Pushspadd =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+ pc <= pc + 1;
+
+ stackA <= (others => '0');
+ stackA(maxAddrBitIncIO downto minAddrBit) <= stackA(maxAddrBitIncIO-minAddrBit downto 0)+sp;
+ when State_Neqbranch =>
+ -- branches are almost always taken as they form loops
+ begin_inst <= '1';
+ idim_flag <= '0';
+ sp <= incIncSp;
+ if (stackB/=0) then
+ pc <= stackA(maxAddrBitIncIO downto 0) + pc;
+ else
+ pc <= pc + 1;
+ end if;
+ -- need to fetch stack again.
+ state <= State_Resync;
+ when State_Mult =>
+ begin_inst <= '1';
+ idim_flag <= '0';
+
+ multA <= stackA;
+ multB <= stackB;
+ state <= State_Mult2;
+ when State_Break =>
+ report "Break instruction encountered" severity failure;
+ break <= '1';
+
+ when State_Loadb =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ state <= State_Loadb2;
+
+ mem_addr <= stackA(maxAddrBitIncIO downto minAddrBit);
+ out_mem_req <= '1';
+ else
+ insn <= insn;
+ end if;
+ when State_Storeb =>
+ if mem_busy='0' then
+ begin_inst <= '1';
+ idim_flag <= '0';
+ state <= State_Storeb2;
+
+ mem_addr <= stackA(maxAddrBitIncIO downto minAddrBit);
+ out_mem_req <= '1';
+ else
+ insn <= insn;
+ end if;
+
+ when others =>
+-- sp <= (others => DontCareValue);
+ report "Illegal instruction" severity failure;
+ break <= '1';
+ end case;
+
+
+ when State_StoreSP2 =>
+ if mem_busy='0' then
+ mem_addr <= incSp;
+ out_mem_req <= '1';
+ state <= State_Popped;
+ end if;
+ when State_LoadSP2 =>
+ if mem_busy='0' then
+ state <= State_LoadSP3;
+ out_mem_req <= '1';
+ mem_addr <= sp+spOffset+1;
+ end if;
+ when State_LoadSP3 =>
+ if mem_busy='0' then
+ pc <= pc + 1;
+ state <= State_Execute;
+ stackB <= stackA;
+ stackA <= mem_read;
+ end if;
+ when State_AddSP2 =>
+ if mem_busy='0' then
+ pc <= pc + 1;
+ state <= State_Execute;
+ stackA <= stackA + mem_read;
+ end if;
+ when State_Load2 =>
+ if mem_busy='0' then
+ stackA <= mem_read;
+ pc <= pc + 1;
+ state <= State_Execute;
+ end if;
+ when State_Loadb2 =>
+ if mem_busy='0' then
+ stackA <= (others => '0');
+ stackA(7 downto 0) <= mem_read(((wordBytes-1-conv_integer(stackA(byteBits-1 downto 0)))*8+7) downto (wordBytes-1-conv_integer(stackA(byteBits-1 downto 0)))*8);
+ pc <= pc + 1;
+ state <= State_Execute;
+ end if;
+ when State_Storeb2 =>
+ if mem_busy='0' then
+ mem_addr <= stackA(maxAddrBitIncIO downto minAddrBit);
+ mem_write <= mem_read;
+ mem_write(((wordBytes-1-conv_integer(stackA(byteBits-1 downto 0)))*8+7) downto (wordBytes-1-conv_integer(stackA(byteBits-1 downto 0)))*8) <= stackB(7 downto 0) ;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ pc <= pc + 1;
+ sp <= incIncSp;
+ state <= State_Resync;
+ end if;
+ when State_Fetch =>
+ if mem_busy='0' then
+ if interrupt='1' and inInterrupt='0' and idim_flag='0' then
+ -- We got an interrupt
+ inInterrupt <= '1';
+
+ sp <= decSp;
+ out_mem_req <= '1';
+ mem_we <= '1';
+ mem_addr <= incSp;
+ mem_write <= stackB;
+ stackA <= (others => DontCareValue);
+ stackA(maxAddrBitIncIO downto 0) <= pc;
+ stackB <= stackA;
+
+ pc <= conv_std_logic_vector(32, maxAddrBitIncIo+1); -- interrupt address
+
+ report "ZPU jumped to interrupt!" severity note;
+ else
+ mem_addr <= pc(maxAddrBitIncIO downto minAddrBit);
+ out_mem_req <= '1';
+ state <= State_Decode;
+ end if;
+ end if;
+ when State_Mult2 =>
+ state <= State_Mult3;
+ when State_Mult3 =>
+ state <= State_Mult4;
+ when State_Mult4 =>
+ state <= State_Mult5;
+ when State_Mult5 =>
+ stackA <= multResult3;
+ state <= State_Mult6;
+ when State_Mult6 =>
+ if mem_busy='0' then
+ out_mem_req <= '1';
+ mem_addr <= incIncSp;
+ sp <= incSp;
+ state <= State_Popped;
+ end if;
+ when State_BinaryOpResult =>
+ if mem_busy='0' then
+ -- NB!!!! we know that the memory isn't busy at this point!!!!
+ out_mem_req <= '1';
+ mem_addr <= incIncSp;
+ sp <= incSp;
+ stackA <= binaryOpResult;
+ state <= State_Popped;
+ end if;
+ when State_Popped =>
+ if mem_busy='0' then
+ pc <= pc + 1;
+ stackB <= mem_read;
+ state <= State_Execute;
+ end if;
+ when others =>
+-- sp <= (others => DontCareValue);
+ report "Illegal state" severity failure;
+ break <= '1';
+ end case;
+ end if;
+ end process;
+
+
+
+end behave;
diff --git a/fpga/usrp2/opencores/zpu/core/zpupkg.vhd b/fpga/usrp2/opencores/zpu/core/zpupkg.vhd
new file mode 100644
index 000000000..eee967a09
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/core/zpupkg.vhd
@@ -0,0 +1,169 @@
+library IEEE;
+use IEEE.STD_LOGIC_1164.all;
+use IEEE.STD_LOGIC_ARITH.all;
+
+library work;
+use work.zpu_config.all;
+
+package zpupkg is
+
+ -- This bit is set for read/writes to IO
+ -- FIX!!! eventually this should be set to wordSize-1 so as to
+ -- to make the address of IO independent of amount of memory
+ -- reserved for CPU. Requires trivial tweaks in toolchain/runtime
+ -- libraries.
+
+ constant byteBits : integer := wordPower-3; -- # of bits in a word that addresses bytes
+ constant maxAddrBit : integer := maxAddrBitIncIO-1;
+ constant ioBit : integer := maxAddrBit+1;
+ constant wordSize : integer := 2**wordPower;
+ constant wordBytes : integer := wordSize/8;
+ constant minAddrBit : integer := byteBits;
+ -- configurable internal stack size. Probably going to be 16 after toolchain is done
+ constant stack_bits : integer := 5;
+ constant stack_size : integer := 2**stack_bits;
+
+ component dualport_ram is
+ port (clk : in std_logic;
+ memAWriteEnable : in std_logic;
+ memAAddr : in std_logic_vector(maxAddrBit downto minAddrBit);
+ memAWrite : in std_logic_vector(wordSize-1 downto 0);
+ memARead : out std_logic_vector(wordSize-1 downto 0);
+ memBWriteEnable : in std_logic;
+ memBAddr : in std_logic_vector(maxAddrBit downto minAddrBit);
+ memBWrite : in std_logic_vector(wordSize-1 downto 0);
+ memBRead : out std_logic_vector(wordSize-1 downto 0));
+ end component;
+
+ component dram is
+ port (clk : in std_logic;
+ areset : in std_logic;
+ mem_writeEnable : in std_logic;
+ mem_readEnable : in std_logic;
+ mem_addr : in std_logic_vector(maxAddrBit downto 0);
+ mem_write : in std_logic_vector(wordSize-1 downto 0);
+ mem_read : out std_logic_vector(wordSize-1 downto 0);
+ mem_busy : out std_logic;
+ mem_writeMask : in std_logic_vector(wordBytes-1 downto 0));
+ end component;
+
+
+ component trace is
+ port(
+ clk : in std_logic;
+ begin_inst : in std_logic;
+ pc : in std_logic_vector(maxAddrBitIncIO downto 0);
+ opcode : in std_logic_vector(7 downto 0);
+ sp : in std_logic_vector(maxAddrBitIncIO downto minAddrBit);
+ memA : in std_logic_vector(wordSize-1 downto 0);
+ memB : in std_logic_vector(wordSize-1 downto 0);
+ busy : in std_logic;
+ intSp : in std_logic_vector(stack_bits-1 downto 0)
+ );
+ end component;
+
+ component zpu_core is
+ port ( clk : in std_logic;
+ areset : in std_logic;
+ enable : in std_logic;
+ mem_req : out std_logic;
+ mem_we : out std_logic;
+ mem_ack : in std_logic;
+ mem_read : in std_logic_vector(wordSize-1 downto 0);
+ mem_write : out std_logic_vector(wordSize-1 downto 0);
+ out_mem_addr : out std_logic_vector(maxAddrBitIncIO downto 0);
+ mem_writeMask: out std_logic_vector(wordBytes-1 downto 0);
+ stack_start : in std_logic_vector(maxAddrBitIncIO downto 0);
+ interrupt : in std_logic;
+ break : out std_logic;
+ zpu_status : out std_logic_vector(63 downto 0));
+ end component;
+
+
+
+ component timer is
+ port(
+ clk : in std_logic;
+ areset : in std_logic;
+ sample : in std_logic;
+ reset : in std_logic;
+ counter : out std_logic_vector(63 downto 0));
+ end component;
+
+ component zpuio is
+ port ( areset : in std_logic;
+ cpu_clk : in std_logic;
+ clk_status : in std_logic_vector(2 downto 0);
+ cpu_din : in std_logic_vector(15 downto 0);
+ cpu_a : in std_logic_vector(20 downto 0);
+ cpu_we : in std_logic_vector(1 downto 0);
+ cpu_re : in std_logic;
+ cpu_dout : inout std_logic_vector(15 downto 0));
+ end component;
+
+
+
+
+ -- opcode decode constants
+ constant OpCode_Im : std_logic_vector(7 downto 7) := "1";
+ constant OpCode_StoreSP : std_logic_vector(7 downto 5) := "010";
+ constant OpCode_LoadSP : std_logic_vector(7 downto 5) := "011";
+ constant OpCode_Emulate : std_logic_vector(7 downto 5) := "001";
+ constant OpCode_AddSP : std_logic_vector(7 downto 4) := "0001";
+ constant OpCode_Short : std_logic_vector(7 downto 4) := "0000";
+
+ constant OpCode_Break : std_logic_vector(3 downto 0) := "0000";
+ constant OpCode_Shiftleft: std_logic_vector(3 downto 0) := "0001";
+ constant OpCode_PushSP : std_logic_vector(3 downto 0) := "0010";
+ constant OpCode_PushInt : std_logic_vector(3 downto 0) := "0011";
+
+ constant OpCode_PopPC : std_logic_vector(3 downto 0) := "0100";
+ constant OpCode_Add : std_logic_vector(3 downto 0) := "0101";
+ constant OpCode_And : std_logic_vector(3 downto 0) := "0110";
+ constant OpCode_Or : std_logic_vector(3 downto 0) := "0111";
+
+ constant OpCode_Load : std_logic_vector(3 downto 0) := "1000";
+ constant OpCode_Not : std_logic_vector(3 downto 0) := "1001";
+ constant OpCode_Flip : std_logic_vector(3 downto 0) := "1010";
+ constant OpCode_Nop : std_logic_vector(3 downto 0) := "1011";
+
+ constant OpCode_Store : std_logic_vector(3 downto 0) := "1100";
+ constant OpCode_PopSP : std_logic_vector(3 downto 0) := "1101";
+ constant OpCode_Compare : std_logic_vector(3 downto 0) := "1110";
+ constant OpCode_PopInt : std_logic_vector(3 downto 0) := "1111";
+
+ constant OpCode_Lessthan : std_logic_vector(5 downto 0) := conv_std_logic_vector(36, 6);
+ constant OpCode_Lessthanorequal : std_logic_vector(5 downto 0) := conv_std_logic_vector(37, 6);
+ constant OpCode_Ulessthan : std_logic_vector(5 downto 0) := conv_std_logic_vector(38, 6);
+ constant OpCode_Ulessthanorequal : std_logic_vector(5 downto 0) := conv_std_logic_vector(39, 6);
+
+ constant OpCode_Swap : std_logic_vector(5 downto 0) := conv_std_logic_vector(40, 6);
+ constant OpCode_Mult : std_logic_vector(5 downto 0) := conv_std_logic_vector(41, 6);
+
+ constant OpCode_Lshiftright : std_logic_vector(5 downto 0) := conv_std_logic_vector(42, 6);
+ constant OpCode_Ashiftleft : std_logic_vector(5 downto 0) := conv_std_logic_vector(43, 6);
+ constant OpCode_Ashiftright : std_logic_vector(5 downto 0) := conv_std_logic_vector(44, 6);
+ constant OpCode_Call : std_logic_vector(5 downto 0) := conv_std_logic_vector(45, 6);
+
+ constant OpCode_Eq : std_logic_vector(5 downto 0) := conv_std_logic_vector(46, 6);
+ constant OpCode_Neq : std_logic_vector(5 downto 0) := conv_std_logic_vector(47, 6);
+
+ constant OpCode_Sub : std_logic_vector(5 downto 0) := conv_std_logic_vector(49, 6);
+ constant OpCode_Loadb : std_logic_vector(5 downto 0) := conv_std_logic_vector(51, 6);
+ constant OpCode_Storeb : std_logic_vector(5 downto 0) := conv_std_logic_vector(52, 6);
+
+ constant OpCode_Eqbranch : std_logic_vector(5 downto 0) := conv_std_logic_vector(55, 6);
+ constant OpCode_Neqbranch : std_logic_vector(5 downto 0) := conv_std_logic_vector(56, 6);
+ constant OpCode_Poppcrel : std_logic_vector(5 downto 0) := conv_std_logic_vector(57, 6);
+
+ constant OpCode_Pushspadd : std_logic_vector(5 downto 0) := conv_std_logic_vector(61, 6);
+ constant OpCode_Mult16x16 : std_logic_vector(5 downto 0) := conv_std_logic_vector(62, 6);
+ constant OpCode_Callpcrel : std_logic_vector(5 downto 0) := conv_std_logic_vector(63, 6);
+
+
+
+ constant OpCode_Size : integer := 8;
+
+
+
+end zpupkg;
diff --git a/fpga/usrp2/opencores/zpu/wishbone/wishbone_pkg.vhd b/fpga/usrp2/opencores/zpu/wishbone/wishbone_pkg.vhd
new file mode 100644
index 000000000..375c9ac7e
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/wishbone/wishbone_pkg.vhd
@@ -0,0 +1,86 @@
+-- ZPU
+--
+-- Copyright 2004-2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
+--
+-- The FreeBSD license
+--
+-- Redistribution and use in source and binary forms, with or without
+-- modification, are permitted provided that the following conditions
+-- are met:
+--
+-- 1. Redistributions of source code must retain the above copyright
+-- notice, this list of conditions and the following disclaimer.
+-- 2. Redistributions in binary form must reproduce the above
+-- copyright notice, this list of conditions and the following
+-- disclaimer in the documentation and/or other materials
+-- provided with the distribution.
+--
+-- THIS SOFTWARE IS PROVIDED BY THE ZPU PROJECT ``AS IS'' AND ANY
+-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+-- ZPU PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+-- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--
+-- The views and conclusions contained in the software and documentation
+-- are those of the authors and should not be interpreted as representing
+-- official policies, either expressed or implied, of the ZPU Project.
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.all;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+package wishbone_pkg is
+
+ type wishbone_bus_in is record
+ adr : std_logic_vector(15 downto 0);
+ sel : std_logic_vector(3 downto 0);
+ we : std_logic;
+ dat : std_logic_vector(31 downto 0); -- Note! Data written with 'we'
+ cyc : std_logic;
+ stb : std_logic;
+ end record;
+
+ type wishbone_bus_out is record
+ dat : std_logic_vector(31 downto 0);
+ ack : std_logic;
+ end record;
+
+ type wishbone_bus is record
+ insig : wishbone_bus_in;
+ outsig : wishbone_bus_out;
+ end record;
+
+ component atomic32_access is
+ port ( cpu_clk : in std_logic;
+ areset : in std_logic;
+
+ -- Wishbone from CPU interface
+ wb_16_i : in wishbone_bus_in;
+ wb_16_o : out wishbone_bus_out;
+ -- Wishbone to FPGA registers and ethernet core
+ wb_32_i : in wishbone_bus_out;
+ wb_32_o : out wishbone_bus_in);
+ end component;
+
+ component eth_access_corr is
+ port ( cpu_clk : in std_logic;
+ areset : in std_logic;
+
+ -- Wishbone from Wishbone MUX
+ eth_raw_o : out wishbone_bus_out;
+ eth_raw_i : in wishbone_bus_in;
+
+ -- Wishbone ethernet core
+ eth_slave_i : in wishbone_bus_out;
+ eth_slave_o : out wishbone_bus_in);
+ end component;
+
+
+end wishbone_pkg;
diff --git a/fpga/usrp2/opencores/zpu/wishbone/zpu_system.vhd b/fpga/usrp2/opencores/zpu/wishbone/zpu_system.vhd
new file mode 100644
index 000000000..8af678b6a
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/wishbone/zpu_system.vhd
@@ -0,0 +1,106 @@
+-- ZPU
+--
+-- Copyright 2004-2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
+--
+-- The FreeBSD license
+--
+-- Redistribution and use in source and binary forms, with or without
+-- modification, are permitted provided that the following conditions
+-- are met:
+--
+-- 1. Redistributions of source code must retain the above copyright
+-- notice, this list of conditions and the following disclaimer.
+-- 2. Redistributions in binary form must reproduce the above
+-- copyright notice, this list of conditions and the following
+-- disclaimer in the documentation and/or other materials
+-- provided with the distribution.
+--
+-- THIS SOFTWARE IS PROVIDED BY THE ZPU PROJECT ``AS IS'' AND ANY
+-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+-- ZPU PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+-- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--
+-- The views and conclusions contained in the software and documentation
+-- are those of the authors and should not be interpreted as representing
+-- official policies, either expressed or implied, of the ZPU Project.
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.all;
+use IEEE.STD_LOGIC_UNSIGNED.all;
+
+library work;
+use work.zpu_top_pkg.all;
+use work.wishbone_pkg.all;
+use work.zpupkg.all;
+use work.zpu_config.all;
+
+entity zpu_system is
+ generic(
+ simulate : boolean := false);
+ port ( areset : in std_logic;
+ cpu_clk : in std_logic;
+
+ -- ZPU Control signals
+ enable : in std_logic;
+ interrupt : in std_logic;
+ stack_start : in std_logic_vector(maxAddrBitIncIO downto 0);
+ zpu_status : out std_logic_vector(63 downto 0);
+
+ -- wishbone interfaces
+ zpu_wb_i : in wishbone_bus_out;
+ zpu_wb_o : out wishbone_bus_in);
+end zpu_system;
+
+architecture behave of zpu_system is
+
+signal mem_req : std_logic;
+signal mem_we : std_logic;
+signal mem_ack : std_logic;
+signal mem_read : std_logic_vector(wordSize-1 downto 0);
+signal mem_write : std_logic_vector(wordSize-1 downto 0);
+signal out_mem_addr : std_logic_vector(maxAddrBitIncIO downto 0);
+signal mem_writeMask : std_logic_vector(wordBytes-1 downto 0);
+
+
+begin
+
+ my_zpu_core:
+ zpu_core port map (
+ clk => cpu_clk,
+ areset => areset,
+ enable => enable,
+ mem_req => mem_req,
+ mem_we => mem_we,
+ mem_ack => mem_ack,
+ mem_read => mem_read,
+ mem_write => mem_write,
+ out_mem_addr => out_mem_addr,
+ mem_writeMask => mem_writeMask,
+ stack_start => stack_start,
+ interrupt => interrupt,
+ zpu_status => zpu_status,
+ break => open);
+
+ my_zpu_wb_bridge:
+ zpu_wb_bridge port map (
+ clk => cpu_clk,
+ areset => areset,
+ mem_req => mem_req,
+ mem_we => mem_we,
+ mem_ack => mem_ack,
+ mem_read => mem_read,
+ mem_write => mem_write,
+ out_mem_addr => out_mem_addr,
+ mem_writeMask => mem_writeMask,
+ zpu_wb_i => zpu_wb_i,
+ zpu_wb_o => zpu_wb_o);
+
+end behave;
diff --git a/fpga/usrp2/opencores/zpu/wishbone/zpu_wb_bridge.vhd b/fpga/usrp2/opencores/zpu/wishbone/zpu_wb_bridge.vhd
new file mode 100644
index 000000000..104ee10b8
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/wishbone/zpu_wb_bridge.vhd
@@ -0,0 +1,83 @@
+-- ZPU
+--
+-- Copyright 2004-2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
+--
+-- The FreeBSD license
+--
+-- Redistribution and use in source and binary forms, with or without
+-- modification, are permitted provided that the following conditions
+-- are met:
+--
+-- 1. Redistributions of source code must retain the above copyright
+-- notice, this list of conditions and the following disclaimer.
+-- 2. Redistributions in binary form must reproduce the above
+-- copyright notice, this list of conditions and the following
+-- disclaimer in the documentation and/or other materials
+-- provided with the distribution.
+--
+-- THIS SOFTWARE IS PROVIDED BY THE ZPU PROJECT ``AS IS'' AND ANY
+-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+-- ZPU PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+-- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--
+-- The views and conclusions contained in the software and documentation
+-- are those of the authors and should not be interpreted as representing
+-- official policies, either expressed or implied, of the ZPU Project.
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+library work;
+use work.zpu_top_pkg.all;
+use work.wishbone_pkg.all;
+use work.zpupkg.all;
+use work.zpu_config.all;
+
+entity zpu_wb_bridge is
+ port ( -- Native ZPU interface
+ clk : in std_logic;
+ areset : in std_logic;
+
+ mem_req : in std_logic;
+ mem_we : in std_logic;
+ mem_ack : out std_logic;
+ mem_read : out std_logic_vector(wordSize-1 downto 0);
+ mem_write : in std_logic_vector(wordSize-1 downto 0);
+ out_mem_addr : in std_logic_vector(maxAddrBitIncIO downto 0);
+ mem_writeMask : in std_logic_vector(wordBytes-1 downto 0);
+
+ -- Wishbone from ZPU
+ zpu_wb_i : in wishbone_bus_out;
+ zpu_wb_o : out wishbone_bus_in);
+
+end zpu_wb_bridge;
+
+architecture behave of zpu_wb_bridge is
+
+begin
+
+ mem_read <= zpu_wb_i.dat;
+ mem_ack <= zpu_wb_i.ack;
+
+ zpu_wb_o.adr <= out_mem_addr;
+ zpu_wb_o.dat <= mem_write;
+ zpu_wb_o.sel <= mem_writeMask;
+ zpu_wb_o.stb <= mem_req;
+ zpu_wb_o.cyc <= mem_req;
+ zpu_wb_o.we <= mem_we;
+
+end behave;
+
+
+
+
+
diff --git a/fpga/usrp2/opencores/zpu/zpu_top_pkg.vhd b/fpga/usrp2/opencores/zpu/zpu_top_pkg.vhd
new file mode 100644
index 000000000..a158ab9c0
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/zpu_top_pkg.vhd
@@ -0,0 +1,46 @@
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+library work;
+use work.zpupkg.all;
+use work.zpu_config.all;
+use work.wishbone_pkg.all;
+
+package zpu_top_pkg is
+ component zpu_wb_bridge is
+ port ( -- Native ZPU interface
+ clk : in std_logic;
+ areset : in std_logic;
+
+ mem_req : in std_logic;
+ mem_we : in std_logic;
+ mem_ack : out std_logic;
+ mem_read : out std_logic_vector(wordSize-1 downto 0);
+ mem_write : in std_logic_vector(wordSize-1 downto 0);
+ out_mem_addr : in std_logic_vector(maxAddrBitIncIO downto 0);
+ mem_writeMask : in std_logic_vector(wordBytes-1 downto 0);
+
+ -- Wishbone from ZPU
+ zpu_wb_i : in wishbone_bus_out;
+ zpu_wb_o : out wishbone_bus_in);
+ end component;
+
+ component zpu_system is
+ generic(
+ simulate : boolean := false);
+ port ( areset : in std_logic;
+ cpu_clk : in std_logic;
+
+ -- ZPU Control signals
+ enable : in std_logic;
+ interrupt : in std_logic;
+ stack_start : in std_logic_vector(maxAddrBitIncIO downto 0);
+ zpu_status : out std_logic_vector(63 downto 0);
+
+ -- wishbone interfaces
+ zpu_wb_i : in wishbone_bus_out;
+ zpu_wb_o : out wishbone_bus_in);
+ end component;
+
+end zpu_top_pkg;
diff --git a/fpga/usrp2/opencores/zpu/zpu_wb_top.vhd b/fpga/usrp2/opencores/zpu/zpu_wb_top.vhd
new file mode 100644
index 000000000..9735c4b54
--- /dev/null
+++ b/fpga/usrp2/opencores/zpu/zpu_wb_top.vhd
@@ -0,0 +1,76 @@
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+library work;
+use work.zpu_top_pkg.all;
+use work.wishbone_pkg.all;
+use work.zpupkg.all;
+use work.zpu_config.all;
+
+------------------------------------------------------------------------
+-- Top level ZPU + wishbone componenent to use in a verilog design:
+-- zpu_wb_top wraps around the zpu_system component.
+-- All IO lines are exposed as std_logic for verilog.
+------------------------------------------------------------------------
+entity zpu_wb_top is
+ generic (
+ dat_w: integer := 32;
+ adr_w: integer := 16;
+ sel_w: integer := 4
+ );
+ port (
+ clk: in std_logic;
+ rst: in std_logic;
+ enb: in std_logic;
+
+ -- wishbone interface
+ dat_i: in std_logic_vector(dat_w-1 downto 0);
+ ack_i: in std_logic;
+ adr_o: out std_logic_vector(adr_w-1 downto 0);
+ sel_o: out std_logic_vector(sel_w-1 downto 0);
+ we_o: out std_logic;
+ dat_o: out std_logic_vector(dat_w-1 downto 0);
+ cyc_o: out std_logic;
+ stb_o: out std_logic;
+
+ -- misc zpu signals
+ interrupt: in std_logic;
+ stack_start: in std_logic_vector(adr_w-1 downto 0);
+ zpu_status: out std_logic_vector(63 downto 0)
+ );
+
+end zpu_wb_top;
+
+architecture syn of zpu_wb_top is
+
+--wishbone interface (records)
+signal zpu_wb_i: wishbone_bus_out;
+signal zpu_wb_o: wishbone_bus_in;
+
+begin
+
+--assign wishbone signals to records
+zpu_wb_i.dat <= dat_i;
+zpu_wb_i.ack <= ack_i;
+
+adr_o <= zpu_wb_o.adr;
+sel_o <= zpu_wb_o.sel;
+we_o <= zpu_wb_o.we;
+dat_o <= zpu_wb_o.dat;
+cyc_o <= zpu_wb_o.cyc;
+stb_o <= zpu_wb_o.stb;
+
+--instantiate the zpu system
+zpu_system0: zpu_system port map(
+ cpu_clk => clk,
+ areset => rst,
+ enable => enb,
+ interrupt => interrupt,
+ stack_start => stack_start,
+ zpu_status => zpu_status,
+ zpu_wb_i => zpu_wb_i,
+ zpu_wb_o => zpu_wb_o
+);
+
+end architecture syn;
diff --git a/fpga/usrp2/simple_gemac/Makefile.srcs b/fpga/usrp2/simple_gemac/Makefile.srcs
index 6480cd5a4..b82e64208 100644
--- a/fpga/usrp2/simple_gemac/Makefile.srcs
+++ b/fpga/usrp2/simple_gemac/Makefile.srcs
@@ -17,6 +17,7 @@ delay_line.v \
flow_ctrl_tx.v \
flow_ctrl_rx.v \
address_filter.v \
+address_filter_promisc.v \
ll8_to_txmac.v \
rxmac_to_ll8.v \
miim/eth_miim.v \
diff --git a/fpga/usrp2/simple_gemac/address_filter_promisc.v b/fpga/usrp2/simple_gemac/address_filter_promisc.v
new file mode 100644
index 000000000..6047e7c93
--- /dev/null
+++ b/fpga/usrp2/simple_gemac/address_filter_promisc.v
@@ -0,0 +1,32 @@
+
+
+module address_filter_promisc
+ (input clk,
+ input reset,
+ input go,
+ input [7:0] data,
+ output match,
+ output done);
+
+ reg [2:0] af_state;
+
+ always @(posedge clk)
+ if(reset)
+ af_state <= 0;
+ else
+ if(go)
+ af_state <= (data[0] == 1'b0) ? 1 : 7;
+ else
+ case(af_state)
+ 1 : af_state <= 2;
+ 2 : af_state <= 3;
+ 3 : af_state <= 4;
+ 4 : af_state <= 5;
+ 5 : af_state <= 6;
+ 6, 7 : af_state <= 0;
+ endcase // case (af_state)
+
+ assign match = (af_state==6);
+ assign done = (af_state==6)|(af_state==7);
+
+endmodule // address_filter_promisc
diff --git a/fpga/usrp2/simple_gemac/eth_tasks_f36.v b/fpga/usrp2/simple_gemac/eth_tasks_f36.v
index efd72778b..dc64971d4 100644
--- a/fpga/usrp2/simple_gemac/eth_tasks_f36.v
+++ b/fpga/usrp2/simple_gemac/eth_tasks_f36.v
@@ -4,11 +4,11 @@ task SendFlowCtrl;
input [15:0] fc_len;
begin
$display("Sending Flow Control, quanta = %d, time = %d", fc_len,$time);
- pause_time <= fc_len;
+ //pause_time <= fc_len;
@(posedge eth_clk);
- pause_req <= 1;
+ //pause_req <= 1;
@(posedge eth_clk);
- pause_req <= 0;
+ //pause_req <= 0;
$display("Sent Flow Control");
end
endtask // SendFlowCtrl
diff --git a/fpga/usrp2/simple_gemac/simple_gemac_rx.v b/fpga/usrp2/simple_gemac/simple_gemac_rx.v
index b02bb0758..32f517bb3 100644
--- a/fpga/usrp2/simple_gemac/simple_gemac_rx.v
+++ b/fpga/usrp2/simple_gemac/simple_gemac_rx.v
@@ -56,10 +56,10 @@ module simple_gemac_rx
else
rx_ack <= (rx_state == RX_GOODFRAME);
- wire is_ucast, is_bcast, is_mcast, is_pause;
- wire keep_packet = (pass_ucast & is_ucast) | (pass_mcast & is_mcast) |
- (pass_bcast & is_bcast) | (pass_pause & is_pause) | pass_all;
-
+ wire is_ucast, is_bcast, is_mcast, is_pause, is_any_ucast;
+ wire keep_packet = (pass_all & is_any_ucast) | (pass_ucast & is_ucast) | (pass_mcast & is_mcast) |
+ (pass_bcast & is_bcast) | (pass_pause & is_pause);
+
assign rx_data = rxd_del;
assign rx_error = (rx_state == RX_ERROR);
@@ -79,6 +79,8 @@ module simple_gemac_rx
.address(48'hFFFF_FFFF_FFFF), .match(is_bcast), .done());
address_filter af_pause (.clk(rx_clk), .reset(reset), .go(go_filt), .data(rxd_d1),
.address(48'h0180_c200_0001), .match(is_pause), .done());
+ address_filter_promisc af_promisc (.clk(rx_clk), .reset(reset), .go(go_filt), .data(rxd_d1),
+ .match(is_any_ucast), .done());
always @(posedge rx_clk)
go_filt <= (rx_state==RX_PREAMBLE) & (rxd_d1 == 8'hD5);
diff --git a/fpga/usrp2/simple_gemac/simple_gemac_wb.v b/fpga/usrp2/simple_gemac/simple_gemac_wb.v
index 6df277e3e..1ef38be11 100644
--- a/fpga/usrp2/simple_gemac/simple_gemac_wb.v
+++ b/fpga/usrp2/simple_gemac/simple_gemac_wb.v
@@ -1,16 +1,17 @@
module wb_reg
#(parameter ADDR=0,
- parameter DEFAULT=0)
+ parameter DEFAULT=0,
+ parameter WIDTH=32)
(input clk, input rst,
input [5:0] adr, input wr_acc,
- input [31:0] dat_i, output reg [31:0] dat_o);
+ input [31:0] dat_i, output reg [WIDTH-1:0] dat_o);
always @(posedge clk)
if(rst)
dat_o <= DEFAULT;
else if(wr_acc & (adr == ADDR))
- dat_o <= dat_i;
+ dat_o <= dat_i[WIDTH-1:0];
endmodule // wb_reg
@@ -41,19 +42,19 @@ module simple_gemac_wb
wire [6:0] misc_settings;
assign {pause_request_en, pass_ucast, pass_mcast, pass_bcast, pass_pause, pass_all, pause_respect_en} = misc_settings;
- wb_reg #(.ADDR(0),.DEFAULT(7'b0111001))
+ wb_reg #(.ADDR(0),.DEFAULT(7'b0111011),.WIDTH(7))
wb_reg_settings (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(misc_settings) );
- wb_reg #(.ADDR(1),.DEFAULT(0))
+ wb_reg #(.ADDR(1),.DEFAULT(0),.WIDTH(16))
wb_reg_ucast_h (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(ucast_addr[47:32]) );
- wb_reg #(.ADDR(2),.DEFAULT(0))
+ wb_reg #(.ADDR(2),.DEFAULT(0),.WIDTH(32))
wb_reg_ucast_l (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(ucast_addr[31:0]) );
- wb_reg #(.ADDR(3),.DEFAULT(0))
+ wb_reg #(.ADDR(3),.DEFAULT(0),.WIDTH(16))
wb_reg_mcast_h (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(mcast_addr[47:32]) );
- wb_reg #(.ADDR(4),.DEFAULT(0))
+ wb_reg #(.ADDR(4),.DEFAULT(0),.WIDTH(32))
wb_reg_mcast_l (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(mcast_addr[31:0]) );
@@ -80,15 +81,15 @@ module simple_gemac_wb
reg [15:0] MIIRX_DATA;
wire [2:0] MIISTATUS;
- wb_reg #(.ADDR(5),.DEFAULT(0))
+ wb_reg #(.ADDR(5),.DEFAULT(0),.WIDTH(9))
wb_reg_miimoder (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o({NoPre,Divider}) );
- wb_reg #(.ADDR(6),.DEFAULT(0))
+ wb_reg #(.ADDR(6),.DEFAULT(0),.WIDTH(13))
wb_reg_miiaddr (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(MIIADDRESS) );
- wb_reg #(.ADDR(7),.DEFAULT(0))
+ wb_reg #(.ADDR(7),.DEFAULT(0),.WIDTH(16))
wb_reg_miidata (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(CtrlData) );
@@ -133,11 +134,11 @@ module simple_gemac_wb
.WCtrlDataStart(WCtrlDataStart), .RStatStart(RStatStart),
.UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg) );
- wb_reg #(.ADDR(11),.DEFAULT(0))
+ wb_reg #(.ADDR(11),.DEFAULT(0),.WIDTH(16))
wb_reg_pausetime (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(pause_time) );
- wb_reg #(.ADDR(12),.DEFAULT(0))
+ wb_reg #(.ADDR(12),.DEFAULT(0),.WIDTH(16))
wb_reg_pausethresh (.clk(wb_clk), .rst(wb_rst), .adr(wb_adr[7:2]), .wr_acc(wr_acc),
.dat_i(wb_dat_i), .dat_o(pause_thresh) );
diff --git a/fpga/usrp2/simple_gemac/simple_gemac_wrapper.build b/fpga/usrp2/simple_gemac/simple_gemac_wrapper.build
index 30f65ab17..9293deca6 100755
--- a/fpga/usrp2/simple_gemac/simple_gemac_wrapper.build
+++ b/fpga/usrp2/simple_gemac/simple_gemac_wrapper.build
@@ -1 +1 @@
-iverilog -Wimplict -Wportbind -y ../control_lib/newfifo/ -y ../models/ -y . -y miim -y ../coregen/ -y ../control_lib/ -o simple_gemac_wrapper_tb simple_gemac_wrapper_tb.v
+iverilog -Wimplict -Wportbind -y ../fifo/ -y ../models/ -y . -y miim -y ../coregen/ -y ../control_lib/ -o simple_gemac_wrapper_tb simple_gemac_wrapper_tb.v
diff --git a/fpga/usrp2/simple_gemac/simple_gemac_wrapper19.build b/fpga/usrp2/simple_gemac/simple_gemac_wrapper19.build
index 4be0aac1f..b9475baa2 100755
--- a/fpga/usrp2/simple_gemac/simple_gemac_wrapper19.build
+++ b/fpga/usrp2/simple_gemac/simple_gemac_wrapper19.build
@@ -1 +1 @@
-iverilog -Wimplict -Wportbind -y ../control_lib/newfifo/ -y ../models/ -y . -y miim -y ../coregen/ -y ../control_lib/ -o simple_gemac_wrapper19_tb simple_gemac_wrapper19_tb.v
+iverilog -Wimplict -Wportbind -y ../fifo/ -y ../models/ -y . -y miim -y ../coregen/ -y ../control_lib/ -o simple_gemac_wrapper19_tb simple_gemac_wrapper19_tb.v
diff --git a/fpga/usrp2/simple_gemac/simple_gemac_wrapper19_tb.v b/fpga/usrp2/simple_gemac/simple_gemac_wrapper19_tb.v
index 7d57542dc..b61d60d30 100644
--- a/fpga/usrp2/simple_gemac/simple_gemac_wrapper19_tb.v
+++ b/fpga/usrp2/simple_gemac/simple_gemac_wrapper19_tb.v
@@ -44,12 +44,12 @@ module simple_gemac_wrapper19_tb;
reg wb_stb=0, wb_cyc=0, wb_we=0;
wire wb_ack;
- reg [18:0] tx_f19_data=0;
+ reg [19:0] tx_f19_data=0;
reg tx_f19_src_rdy = 0;
wire tx_f19_dst_rdy;
- wire [35:0] rx_f36_data;
- wire rx_f36_src_rdy;
- wire rx_f36_dst_rdy = 1;
+ wire [35:0] rx_f19_data;
+ wire rx_f19_src_rdy;
+ wire rx_f19_dst_rdy = 1;
simple_gemac_wrapper19 simple_gemac_wrapper19
(.clk125(eth_clk), .reset(reset),
@@ -59,7 +59,7 @@ module simple_gemac_wrapper19_tb;
.GMII_RX_ER(GMII_RX_ER), .GMII_RXD(GMII_RXD),
//.pause_req(pause_req), .pause_time(pause_time),
- .sys_clk(sys_clk), .rx_f36_data(rx_f36_data), .rx_f36_src_rdy(rx_f36_src_rdy), .rx_f36_dst_rdy(rx_f36_dst_rdy),
+ .sys_clk(sys_clk), .rx_f19_data(rx_f19_data), .rx_f19_src_rdy(rx_f19_src_rdy), .rx_f19_dst_rdy(rx_f19_dst_rdy),
.tx_f19_data(tx_f19_data), .tx_f19_src_rdy(tx_f19_src_rdy), .tx_f19_dst_rdy(tx_f19_dst_rdy),
.wb_clk(wb_clk), .wb_rst(wb_rst), .wb_stb(wb_stb), .wb_cyc(wb_cyc), .wb_ack(wb_ack), .wb_we(wb_we),
diff --git a/fpga/usrp2/simple_gemac/simple_gemac_wrapper_tb.v b/fpga/usrp2/simple_gemac/simple_gemac_wrapper_tb.v
index 26a471a49..0aadc7e93 100644
--- a/fpga/usrp2/simple_gemac/simple_gemac_wrapper_tb.v
+++ b/fpga/usrp2/simple_gemac/simple_gemac_wrapper_tb.v
@@ -24,9 +24,6 @@ module simple_gemac_wrapper_tb;
wire [7:0] rx_data, tx_data;
- reg [15:0] pause_time;
- reg pause_req = 0;
-
wire GMII_RX_CLK = GMII_GTX_CLK;
reg [7:0] FORCE_DAT_ERR = 0;
@@ -47,7 +44,7 @@ module simple_gemac_wrapper_tb;
reg [35:0] tx_f36_data=0;
reg tx_f36_src_rdy = 0;
wire tx_f36_dst_rdy;
- wire rx_f36_data;
+ wire [35:0] rx_f36_data;
wire rx_f36_src_rdy;
wire rx_f36_dst_rdy = 1;
@@ -57,7 +54,6 @@ module simple_gemac_wrapper_tb;
.GMII_TX_ER(GMII_TX_ER), .GMII_TXD(GMII_TXD),
.GMII_RX_CLK(GMII_RX_CLK), .GMII_RX_DV(GMII_RX_DV),
.GMII_RX_ER(GMII_RX_ER), .GMII_RXD(GMII_RXD),
- .pause_req(pause_req), .pause_time(pause_time),
.sys_clk(sys_clk), .rx_f36_data(rx_f36_data), .rx_f36_src_rdy(rx_f36_src_rdy), .rx_f36_dst_rdy(rx_f36_dst_rdy),
.tx_f36_data(tx_f36_data), .tx_f36_src_rdy(tx_f36_src_rdy), .tx_f36_dst_rdy(tx_f36_dst_rdy),
diff --git a/fpga/usrp2/timing/time_64bit.v b/fpga/usrp2/timing/time_64bit.v
index 33eb2b25a..8122cc6ea 100644
--- a/fpga/usrp2/timing/time_64bit.v
+++ b/fpga/usrp2/timing/time_64bit.v
@@ -6,7 +6,9 @@ module time_64bit
(input clk, input rst,
input set_stb, input [7:0] set_addr, input [31:0] set_data,
input pps,
- output [63:0] vita_time, output pps_int,
+ output [63:0] vita_time,
+ output reg [63:0] vita_time_pps,
+ output pps_int,
input exp_time_in, output exp_time_out,
output [31:0] debug
);
@@ -74,6 +76,10 @@ module time_64bit
pps_del <= {pps_del[0],pps_reg};
assign pps_edge = pps_del[0] & ~pps_del[1];
+
+ always @(posedge clk)
+ if(pps_edge)
+ vita_time_pps <= vita_time;
always @(posedge clk)
if(rst)
diff --git a/fpga/usrp2/timing/time_receiver.v b/fpga/usrp2/timing/time_receiver.v
index fd8651d29..897f71186 100644
--- a/fpga/usrp2/timing/time_receiver.v
+++ b/fpga/usrp2/timing/time_receiver.v
@@ -11,9 +11,14 @@ module time_receiver
reg [3:0] bit_count;
wire [8:0] dataout;
reg [8:0] dataout_reg;
-
+
+ reg exp_time_in_reg, exp_time_in_reg2;
+
+ always @(posedge clk) exp_time_in_reg <= exp_time_in;
+ always @(posedge clk) exp_time_in_reg2 <= exp_time_in_reg;
+
always @(posedge clk)
- shiftreg <= {exp_time_in, shiftreg[9:1]};
+ shiftreg <= {exp_time_in_reg2, shiftreg[9:1]};
localparam COMMA_0 = 10'h283;
localparam COMMA_1 = 10'h17c;
@@ -65,7 +70,9 @@ module time_receiver
localparam TAIL = 9'h1F7;
reg [3:0] state;
-
+ reg [63:0] vita_time_pre;
+ reg sync_rcvd_pre;
+
always @(posedge clk)
if(rst)
state <= STATE_IDLE;
@@ -79,42 +86,42 @@ module time_receiver
state <= STATE_T0;
STATE_T0 :
begin
- vita_time[63:56] <= dataout_reg[7:0];
+ vita_time_pre[63:56] <= dataout_reg[7:0];
state <= STATE_T1;
end
STATE_T1 :
begin
- vita_time[55:48] <= dataout_reg[7:0];
+ vita_time_pre[55:48] <= dataout_reg[7:0];
state <= STATE_T2;
end
STATE_T2 :
begin
- vita_time[47:40] <= dataout_reg[7:0];
+ vita_time_pre[47:40] <= dataout_reg[7:0];
state <= STATE_T3;
end
STATE_T3 :
begin
- vita_time[39:32] <= dataout_reg[7:0];
+ vita_time_pre[39:32] <= dataout_reg[7:0];
state <= STATE_T4;
end
STATE_T4 :
begin
- vita_time[31:24] <= dataout_reg[7:0];
+ vita_time_pre[31:24] <= dataout_reg[7:0];
state <= STATE_T5;
end
STATE_T5 :
begin
- vita_time[23:16] <= dataout_reg[7:0];
+ vita_time_pre[23:16] <= dataout_reg[7:0];
state <= STATE_T6;
end
STATE_T6 :
begin
- vita_time[15:8] <= dataout_reg[7:0];
+ vita_time_pre[15:8] <= dataout_reg[7:0];
state <= STATE_T7;
end
STATE_T7 :
begin
- vita_time[7:0] <= dataout_reg[7:0];
+ vita_time_pre[7:0] <= dataout_reg[7:0];
state <= STATE_TAIL;
end
STATE_TAIL :
@@ -123,8 +130,11 @@ module time_receiver
always @(posedge clk)
if(rst)
- sync_rcvd <= 0;
+ sync_rcvd_pre <= 0;
else
- sync_rcvd <= (complete_word & (state == STATE_TAIL) & (dataout_reg[8:0] == TAIL));
+ sync_rcvd_pre <= (complete_word & (state == STATE_TAIL) & (dataout_reg[8:0] == TAIL));
+
+ always @(posedge clk) sync_rcvd <= sync_rcvd_pre;
+ always @(posedge clk) vita_time <= vita_time_pre;
endmodule // time_sender
diff --git a/fpga/usrp2/top/u1e/u1e_core.v b/fpga/usrp2/top/u1e/u1e_core.v
index e7e798b34..d590b4fb1 100644
--- a/fpga/usrp2/top/u1e/u1e_core.v
+++ b/fpga/usrp2/top/u1e/u1e_core.v
@@ -36,13 +36,13 @@ module u1e_core
localparam SR_TX_CTRL = 24; // 2 regs
localparam SR_TIME64 = 28; // 4 regs
- wire [7:0] COMPAT_NUM = 8'd2;
+ wire [7:0] COMPAT_NUM = 8'd3;
wire wb_clk = clk_fpga;
wire wb_rst = rst_fpga;
wire pps_int;
- wire [63:0] vita_time;
+ wire [63:0] vita_time, vita_time_pps;
reg [15:0] reg_leds, reg_cgen_ctrl, reg_test, xfer_rate;
wire [7:0] set_addr;
@@ -299,7 +299,6 @@ module u1e_core
.sf_dat_o(sf_dat_mosi),.sf_adr_o(sf_adr),.sf_sel_o(sf_sel),.sf_we_o(sf_we),.sf_cyc_o(sf_cyc),.sf_stb_o(sf_stb),
.sf_dat_i(sf_dat_miso),.sf_ack_i(sf_ack),.sf_err_i(0),.sf_rty_i(0) );
- assign s7_ack = 0;
assign s8_ack = 0; assign s9_ack = 0; assign sa_ack = 0; assign sb_ack = 0;
assign sc_ack = 0; assign sd_ack = 0; assign se_ack = 0; assign sf_ack = 0;
@@ -427,13 +426,26 @@ module u1e_core
.we_i(s6_we), .stb_i(s6_stb), .cyc_i(s6_cyc), .ack_o(s6_ack),
.run_rx(run_rx), .run_tx(run_tx), .ctrl_lines(atr_lines));
+ // /////////////////////////////////////////////////////////////////////////
+ // Readback mux 32 -- Slave #7
+
+ wb_readback_mux_16LE readback_mux_32
+ (.wb_clk_i(wb_clk), .wb_rst_i(wb_rst), .wb_stb_i(s7_stb),
+ .wb_adr_i(s7_adr), .wb_dat_o(s7_dat_miso), .wb_ack_o(s7_ack),
+
+ .word00(vita_time[63:32]), .word01(vita_time[31:0]),
+ .word02(vita_time_pps[63:32]),.word03(vita_time_pps[31:0]),
+ .word04(32'b0),.word05(32'b0),.word06(32'b0),.word07(32'b0),
+ .word08(32'b0),.word09(32'b0),.word10(32'b0),.word11(32'b0),
+ .word12(32'b0),.word13(32'b0),.word14(32'b0),.word15(32'b0)
+ );
// /////////////////////////////////////////////////////////////////////////
// VITA Timing
time_64bit #(.TICKS_PER_SEC(32'd64000000),.BASE(SR_TIME64)) time_64bit
(.clk(wb_clk), .rst(wb_rst), .set_stb(set_stb), .set_addr(set_addr), .set_data(set_data),
- .pps(pps_in), .vita_time(vita_time), .pps_int(pps_int));
+ .pps(pps_in), .vita_time(vita_time), .vita_time_pps(vita_time_pps), .pps_int(pps_int));
// /////////////////////////////////////////////////////////////////////////////////////
// Debug circuitry
diff --git a/fpga/usrp2/top/u2_rev3/u2_core.v b/fpga/usrp2/top/u2_rev3/u2_core.v
index 30b47b818..ab2ed49f0 100644
--- a/fpga/usrp2/top/u2_rev3/u2_core.v
+++ b/fpga/usrp2/top/u2_rev3/u2_core.v
@@ -3,7 +3,7 @@
// ////////////////////////////////////////////////////////////////////////////////
module u2_core
- #(parameter RAM_SIZE=32768)
+ #(parameter RAM_SIZE=16384, parameter RAM_AW=14)
(// Clocks
input dsp_clk,
input wb_clk,
@@ -163,7 +163,7 @@ module u2_core
wire ram_loader_rst, wb_rst, dsp_rst;
assign dsp_rst = wb_rst;
- wire [31:0] status, status_b0, status_b1, status_b2, status_b3, status_b4, status_b5, status_b6, status_b7;
+ wire [31:0] status;
wire bus_error, spi_int, i2c_int, pps_int, onetime_int, periodic_int, buffer_int;
wire proc_int, overrun, underrun, uart_tx_int, uart_rx_int;
@@ -180,7 +180,7 @@ module u2_core
wire serdes_link_up;
wire epoch;
wire [31:0] irq;
- wire [63:0] vita_time;
+ wire [63:0] vita_time, vita_time_pps;
wire run_rx, run_tx;
reg run_rx_d1;
@@ -197,14 +197,14 @@ module u2_core
wire [dw-1:0] s0_dat_o, s1_dat_o, s0_dat_i, s1_dat_i, s2_dat_o, s3_dat_o, s2_dat_i, s3_dat_i,
s4_dat_o, s5_dat_o, s4_dat_i, s5_dat_i, s6_dat_o, s7_dat_o, s6_dat_i, s7_dat_i,
s8_dat_o, s9_dat_o, s8_dat_i, s9_dat_i, sa_dat_o, sa_dat_i, sb_dat_i, sb_dat_o,
- sc_dat_i, sc_dat_o, sd_dat_i, sd_dat_o, se_dat_i, se_dat_o;
- wire [aw-1:0] m0_adr,s0_adr,s1_adr,s2_adr,s3_adr,s4_adr,s5_adr,s6_adr,s7_adr,s8_adr,s9_adr,sa_adr,sb_adr,sc_adr, sd_adr, se_adr;
- wire [sw-1:0] m0_sel,s0_sel,s1_sel,s2_sel,s3_sel,s4_sel,s5_sel,s6_sel,s7_sel,s8_sel,s9_sel,sa_sel,sb_sel,sc_sel, sd_sel, se_sel;
- wire m0_ack,s0_ack,s1_ack,s2_ack,s3_ack,s4_ack,s5_ack,s6_ack,s7_ack,s8_ack,s9_ack,sa_ack,sb_ack,sc_ack, sd_ack, se_ack;
- wire m0_stb,s0_stb,s1_stb,s2_stb,s3_stb,s4_stb,s5_stb,s6_stb,s7_stb,s8_stb,s9_stb,sa_stb,sb_stb,sc_stb, sd_stb, se_stb;
- wire m0_cyc,s0_cyc,s1_cyc,s2_cyc,s3_cyc,s4_cyc,s5_cyc,s6_cyc,s7_cyc,s8_cyc,s9_cyc,sa_cyc,sb_cyc,sc_cyc, sd_cyc, se_cyc;
+ sc_dat_i, sc_dat_o, sd_dat_i, sd_dat_o, se_dat_i, se_dat_o, sf_dat_i, sf_dat_o;
+ wire [aw-1:0] m0_adr,s0_adr,s1_adr,s2_adr,s3_adr,s4_adr,s5_adr,s6_adr,s7_adr,s8_adr,s9_adr,sa_adr,sb_adr,sc_adr, sd_adr, se_adr, sf_adr;
+ wire [sw-1:0] m0_sel,s0_sel,s1_sel,s2_sel,s3_sel,s4_sel,s5_sel,s6_sel,s7_sel,s8_sel,s9_sel,sa_sel,sb_sel,sc_sel, sd_sel, se_sel, sf_sel;
+ wire m0_ack,s0_ack,s1_ack,s2_ack,s3_ack,s4_ack,s5_ack,s6_ack,s7_ack,s8_ack,s9_ack,sa_ack,sb_ack,sc_ack, sd_ack, se_ack, sf_ack;
+ wire m0_stb,s0_stb,s1_stb,s2_stb,s3_stb,s4_stb,s5_stb,s6_stb,s7_stb,s8_stb,s9_stb,sa_stb,sb_stb,sc_stb, sd_stb, se_stb, sf_stb;
+ wire m0_cyc,s0_cyc,s1_cyc,s2_cyc,s3_cyc,s4_cyc,s5_cyc,s6_cyc,s7_cyc,s8_cyc,s9_cyc,sa_cyc,sb_cyc,sc_cyc, sd_cyc, se_cyc, sf_cyc;
wire m0_err, m0_rty;
- wire m0_we,s0_we,s1_we,s2_we,s3_we,s4_we,s5_we,s6_we,s7_we,s8_we,s9_we,sa_we,sb_we,sc_we,sd_we, se_we;
+ wire m0_we,s0_we,s1_we,s2_we,s3_we,s4_we,s5_we,s6_we,s7_we,s8_we,s9_we,sa_we,sb_we,sc_we,sd_we,se_we,sf_we;
wb_1master #(.decode_w(6),
.s0_addr(6'b0000_00),.s0_mask(6'b100000),
@@ -257,8 +257,9 @@ module u2_core
.sd_dat_i(sd_dat_i),.sd_ack_i(sd_ack),.sd_err_i(0),.sd_rty_i(0),
.se_dat_o(se_dat_o),.se_adr_o(se_adr),.se_sel_o(se_sel),.se_we_o(se_we),.se_cyc_o(se_cyc),.se_stb_o(se_stb),
.se_dat_i(se_dat_i),.se_ack_i(se_ack),.se_err_i(0),.se_rty_i(0),
- .sf_dat_i(0),.sf_ack_i(0),.sf_err_i(0),.sf_rty_i(0) );
-
+ .sf_dat_o(sf_dat_o),.sf_adr_o(sf_adr),.sf_sel_o(sf_sel),.sf_we_o(sf_we),.sf_cyc_o(sf_cyc),.sf_stb_o(sf_stb),
+ .sf_dat_i(sf_dat_i),.sf_ack_i(sf_ack),.sf_err_i(0),.sf_rty_i(0));
+
//////////////////////////////////////////////////////////////////////////////////////////
// Reset Controller
system_control sysctrl (.wb_clk_i(wb_clk), // .por_i(por),
@@ -286,13 +287,11 @@ module u2_core
// ///////////////////////////////////////////////////////////////////
// RAM Loader
- wire [31:0] ram_loader_dat, if_dat;
+ wire [31:0] ram_loader_dat;
wire [15:0] ram_loader_adr;
- wire [14:0] if_adr;
wire [3:0] ram_loader_sel;
wire ram_loader_stb, ram_loader_we;
- wire iwb_ack, iwb_stb;
- ram_loader #(.AWIDTH(16),.RAM_SIZE(RAM_SIZE))
+ ram_loader #(.AWIDTH(aw),.RAM_SIZE(RAM_SIZE))
ram_loader (.wb_clk(wb_clk),.dsp_clk(dsp_clk),.ram_loader_rst(ram_loader_rst),
.wb_dat(ram_loader_dat),.wb_adr(ram_loader_adr),
.wb_stb(ram_loader_stb),.wb_sel(ram_loader_sel),
@@ -308,36 +307,34 @@ module u2_core
// /////////////////////////////////////////////////////////////////////////
// Processor
- aeMB_core_BE #(.ISIZ(16),.DSIZ(16),.MUL(0),.BSF(1))
- aeMB (.sys_clk_i(wb_clk), .sys_rst_i(wb_rst),
- // Instruction Wishbone bus to I-RAM
- .if_adr(if_adr),
- .if_dat(if_dat),
+
+ assign bus_error = m0_err | m0_rty;
+
+ wire [63:0] zpu_status;
+ zpu_wb_top #(.dat_w(dw), .adr_w(aw), .sel_w(sw))
+ zpu_top0 (.clk(wb_clk), .rst(wb_rst), .enb(ram_loader_done),
// Data Wishbone bus to system bus fabric
- .dwb_we_o(m0_we),.dwb_stb_o(m0_stb),.dwb_dat_o(m0_dat_i),.dwb_adr_o(m0_adr),
- .dwb_dat_i(m0_dat_o),.dwb_ack_i(m0_ack),.dwb_sel_o(m0_sel),.dwb_cyc_o(m0_cyc),
+ .we_o(m0_we),.stb_o(m0_stb),.dat_o(m0_dat_i),.adr_o(m0_adr),
+ .dat_i(m0_dat_o),.ack_i(m0_ack),.sel_o(m0_sel),.cyc_o(m0_cyc),
// Interrupts and exceptions
- .sys_int_i(proc_int),.sys_exc_i(bus_error) );
-
- assign bus_error = m0_err | m0_rty;
+ .stack_start(16'h3ff8), .zpu_status(zpu_status), .interrupt(proc_int & 1'b0));
// /////////////////////////////////////////////////////////////////////////
// Dual Ported RAM -- D-Port is Slave #0 on main Wishbone
// I-port connects directly to processor and ram loader
wire flush_icache;
- ram_harvard #(.AWIDTH(15),.RAM_SIZE(RAM_SIZE),.ICWIDTH(7),.DCWIDTH(6))
+ ram_harvard #(.AWIDTH(RAM_AW),.RAM_SIZE(RAM_SIZE),.ICWIDTH(7),.DCWIDTH(6))
sys_ram(.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),
- .ram_loader_adr_i(ram_loader_adr[14:0]), .ram_loader_dat_i(ram_loader_dat),
+ .ram_loader_adr_i(ram_loader_adr[RAM_AW-1:0]), .ram_loader_dat_i(ram_loader_dat),
.ram_loader_stb_i(ram_loader_stb), .ram_loader_sel_i(ram_loader_sel),
.ram_loader_we_i(ram_loader_we),
.ram_loader_done_i(ram_loader_done),
- .if_adr(if_adr),
- .if_data(if_dat),
+ .if_adr(16'b0), .if_data(),
- .dwb_adr_i(s0_adr[14:0]), .dwb_dat_i(s0_dat_o), .dwb_dat_o(s0_dat_i),
+ .dwb_adr_i(s0_adr[RAM_AW-1:0]), .dwb_dat_i(s0_dat_o), .dwb_dat_o(s0_dat_i),
.dwb_we_i(s0_we), .dwb_ack_o(s0_ack), .dwb_stb_i(s0_stb), .dwb_sel_i(s0_sel),
.flush_icache(flush_icache));
@@ -359,34 +356,33 @@ module u2_core
wire wr3_ready_i, wr3_ready_o;
wire [3:0] wr0_flags, wr1_flags, wr2_flags, wr3_flags;
wire [31:0] wr0_dat, wr1_dat, wr2_dat, wr3_dat;
-
- buffer_pool #(.BUF_SIZE(9), .SET_ADDR(SR_BUF_POOL)) buffer_pool
+
+ wire [35:0] tx_err_data;
+ wire tx_err_src_rdy, tx_err_dst_rdy;
+
+ wire [31:0] router_debug;
+
+ packet_router #(.BUF_SIZE(9), .UDP_BASE(SR_UDP_SM), .CTRL_BASE(SR_BUF_POOL)) packet_router
(.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),
- .wb_we_i(s1_we),.wb_stb_i(s1_stb),.wb_adr_i(s1_adr),.wb_dat_i(s1_dat_o),
+ .wb_we_i(s1_we),.wb_stb_i(s1_stb),.wb_adr_i(s1_adr),.wb_dat_i(s1_dat_o),
.wb_dat_o(s1_dat_i),.wb_ack_o(s1_ack),.wb_err_o(),.wb_rty_o(),
-
- .stream_clk(dsp_clk), .stream_rst(dsp_rst),
+
.set_stb(set_stb_dsp), .set_addr(set_addr_dsp), .set_data(set_data_dsp),
- .status(status),.sys_int_o(buffer_int),
-
- .s0(status_b0),.s1(status_b1),.s2(status_b2),.s3(status_b3),
- .s4(status_b4),.s5(status_b5),.s6(status_b6),.s7(status_b7),
-
- // Write Interfaces
- .wr0_data_i(wr0_dat), .wr0_flags_i(wr0_flags), .wr0_ready_i(wr0_ready_i), .wr0_ready_o(wr0_ready_o),
- .wr1_data_i(wr1_dat), .wr1_flags_i(wr1_flags), .wr1_ready_i(wr1_ready_i), .wr1_ready_o(wr1_ready_o),
- .wr2_data_i(wr2_dat), .wr2_flags_i(wr2_flags), .wr2_ready_i(wr2_ready_i), .wr2_ready_o(wr2_ready_o),
- .wr3_data_i(wr3_dat), .wr3_flags_i(wr3_flags), .wr3_ready_i(wr3_ready_i), .wr3_ready_o(wr3_ready_o),
- // Read Interfaces
- .rd0_data_o(rd0_dat), .rd0_flags_o(rd0_flags), .rd0_ready_i(rd0_ready_i), .rd0_ready_o(rd0_ready_o),
- .rd1_data_o(rd1_dat), .rd1_flags_o(rd1_flags), .rd1_ready_i(rd1_ready_i), .rd1_ready_o(rd1_ready_o),
- .rd2_data_o(rd2_dat), .rd2_flags_o(rd2_flags), .rd2_ready_i(rd2_ready_i), .rd2_ready_o(rd2_ready_o),
- .rd3_data_o(rd3_dat), .rd3_flags_o(rd3_flags), .rd3_ready_i(rd3_ready_i), .rd3_ready_o(rd3_ready_o)
+
+ .stream_clk(dsp_clk), .stream_rst(dsp_rst), .stream_clr(1'b0),
+
+ .status(status), .sys_int_o(buffer_int), .debug(router_debug),
+
+ .ser_inp_data({wr0_flags, wr0_dat}), .ser_inp_valid(wr0_ready_i), .ser_inp_ready(wr0_ready_o),
+ .dsp_inp_data({wr1_flags, wr1_dat}), .dsp_inp_valid(wr1_ready_i), .dsp_inp_ready(wr1_ready_o),
+ .eth_inp_data({wr2_flags, wr2_dat}), .eth_inp_valid(wr2_ready_i), .eth_inp_ready(wr2_ready_o),
+ .err_inp_data(tx_err_data), .err_inp_ready(tx_err_dst_rdy), .err_inp_valid(tx_err_src_rdy),
+
+ .ser_out_data({rd0_flags, rd0_dat}), .ser_out_valid(rd0_ready_o), .ser_out_ready(rd0_ready_i),
+ .dsp_out_data({rd1_flags, rd1_dat}), .dsp_out_valid(rd1_ready_o), .dsp_out_ready(rd1_ready_i),
+ .eth_out_data({rd2_flags, rd2_dat}), .eth_out_valid(rd2_ready_o), .eth_out_ready(rd2_ready_i)
);
- wire [31:0] status_enc;
- priority_enc priority_enc (.in({16'b0,status[15:0]}), .out(status_enc));
-
// /////////////////////////////////////////////////////////////////////////
// SPI -- Slave #2
spi_top shared_spi
@@ -419,31 +415,25 @@ module u2_core
// /////////////////////////////////////////////////////////////////////////
// Buffer Pool Status -- Slave #5
- reg [31:0] cycle_count;
- always @(posedge wb_clk)
- if(wb_rst)
- cycle_count <= 0;
- else
- cycle_count <= cycle_count + 1;
-
//compatibility number -> increment when the fpga has been sufficiently altered
- localparam compat_num = 32'd3;
+ localparam compat_num = 32'd4;
wb_readback_mux buff_pool_status
(.wb_clk_i(wb_clk), .wb_rst_i(wb_rst), .wb_stb_i(s5_stb),
.wb_adr_i(s5_adr), .wb_dat_o(s5_dat_i), .wb_ack_o(s5_ack),
-
- .word00(status_b0),.word01(status_b1),.word02(status_b2),.word03(status_b3),
- .word04(status_b4),.word05(status_b5),.word06(status_b6),.word07(status_b7),
+
+ .word00(32'b0),.word01(32'b0),.word02(32'b0),.word03(32'b0),
+ .word04(32'b0),.word05(32'b0),.word06(32'b0),.word07(32'b0),
.word08(status),.word09({sim_mode,27'b0,clock_divider[3:0]}),.word10(vita_time[63:32]),
- .word11(vita_time[31:0]),.word12(compat_num),.word13(irq),.word14(status_enc),.word15(cycle_count)
+ .word11(vita_time[31:0]),.word12(compat_num),.word13(irq),
+ .word14(vita_time_pps[63:32]),.word15(vita_time_pps[31:0])
);
// /////////////////////////////////////////////////////////////////////////
// Ethernet MAC Slave #6
wire [18:0] rx_f19_data, tx_f19_data;
- wire rx_f19_src_rdy, rx_f19_dst_rdy, rx_f36_src_rdy, rx_f36_dst_rdy;
+ wire rx_f19_src_rdy, rx_f19_dst_rdy, tx_f19_src_rdy, tx_f19_dst_rdy;
simple_gemac_wrapper19 #(.RXFIFOSIZE(11), .TXFIFOSIZE(6)) simple_gemac_wrapper19
(.clk125(clk_to_mac), .reset(wb_rst),
@@ -459,37 +449,39 @@ module u2_core
.mdio(MDIO), .mdc(MDC),
.debug(debug_mac));
- wire [35:0] udp_tx_data, udp_rx_data;
- wire udp_tx_src_rdy, udp_tx_dst_rdy, udp_rx_src_rdy, udp_rx_dst_rdy;
-
- udp_wrapper #(.BASE(SR_UDP_SM)) udp_wrapper
+ wire [35:0] rx_f36_data, tx_f36_data;
+ wire rx_f36_src_rdy, rx_f36_dst_rdy, tx_f36_src_rdy, tx_f36_dst_rdy;
+
+ wire [18:0] _rx_f19_data;
+ wire _rx_f19_src_rdy, _rx_f19_dst_rdy;
+
+ //mac rx to eth input...
+ fifo19_rxrealign fifo19_rxrealign
(.clk(dsp_clk), .reset(dsp_rst), .clear(0),
- .set_stb(set_stb_dsp), .set_addr(set_addr_dsp), .set_data(set_data_dsp),
- .rx_f19_data(rx_f19_data), .rx_f19_src_rdy_i(rx_f19_src_rdy), .rx_f19_dst_rdy_o(rx_f19_dst_rdy),
- .tx_f19_data(tx_f19_data), .tx_f19_src_rdy_o(tx_f19_src_rdy), .tx_f19_dst_rdy_i(tx_f19_dst_rdy),
- .rx_f36_data(udp_rx_data), .rx_f36_src_rdy_o(udp_rx_src_rdy), .rx_f36_dst_rdy_i(udp_rx_dst_rdy),
- .tx_f36_data(udp_tx_data), .tx_f36_src_rdy_i(udp_tx_src_rdy), .tx_f36_dst_rdy_o(udp_tx_dst_rdy),
- .debug(debug_udp) );
+ .datain(rx_f19_data), .src_rdy_i(rx_f19_src_rdy), .dst_rdy_o(rx_f19_dst_rdy),
+ .dataout(_rx_f19_data), .src_rdy_o(_rx_f19_src_rdy), .dst_rdy_i(_rx_f19_dst_rdy) );
- wire [35:0] tx_err_data, udp1_tx_data;
- wire tx_err_src_rdy, tx_err_dst_rdy, udp1_tx_src_rdy, udp1_tx_dst_rdy;
-
- fifo_cascade #(.WIDTH(36), .SIZE(ETH_TX_FIFOSIZE)) tx_eth_fifo
+ fifo19_to_fifo36 eth_inp_fifo19_to_fifo36
(.clk(dsp_clk), .reset(dsp_rst), .clear(0),
- .datain({rd2_flags,rd2_dat}), .src_rdy_i(rd2_ready_o), .dst_rdy_o(rd2_ready_i),
- .dataout(udp1_tx_data), .src_rdy_o(udp1_tx_src_rdy), .dst_rdy_i(udp1_tx_dst_rdy));
+ .f19_datain(_rx_f19_data), .f19_src_rdy_i(_rx_f19_src_rdy), .f19_dst_rdy_o(_rx_f19_dst_rdy),
+ .f36_dataout(rx_f36_data), .f36_src_rdy_o(rx_f36_src_rdy), .f36_dst_rdy_i(rx_f36_dst_rdy) );
- fifo36_mux #(.prio(0)) mux_err_stream
- (.clk(dsp_clk), .reset(dsp_reset), .clear(0),
- .data0_i(udp1_tx_data), .src0_rdy_i(udp1_tx_src_rdy), .dst0_rdy_o(udp1_tx_dst_rdy),
- .data1_i(tx_err_data), .src1_rdy_i(tx_err_src_rdy), .dst1_rdy_o(tx_err_dst_rdy),
- .data_o(udp_tx_data), .src_rdy_o(udp_tx_src_rdy), .dst_rdy_i(udp_tx_dst_rdy));
-
fifo_cascade #(.WIDTH(36), .SIZE(ETH_RX_FIFOSIZE)) rx_eth_fifo
(.clk(dsp_clk), .reset(dsp_rst), .clear(0),
- .datain(udp_rx_data), .src_rdy_i(udp_rx_src_rdy), .dst_rdy_o(udp_rx_dst_rdy),
+ .datain(rx_f36_data), .src_rdy_i(rx_f36_src_rdy), .dst_rdy_o(rx_f36_dst_rdy),
.dataout({wr2_flags,wr2_dat}), .src_rdy_o(wr2_ready_i), .dst_rdy_i(wr2_ready_o));
-
+
+ //eth output to mac tx...
+ fifo_cascade #(.WIDTH(36), .SIZE(ETH_TX_FIFOSIZE)) tx_eth_fifo
+ (.clk(dsp_clk), .reset(dsp_rst), .clear(0),
+ .datain({rd2_flags,rd2_dat}), .src_rdy_i(rd2_ready_o), .dst_rdy_o(rd2_ready_i),
+ .dataout(tx_f36_data), .src_rdy_o(tx_f36_src_rdy), .dst_rdy_i(tx_f36_dst_rdy));
+
+ fifo36_to_fifo19 eth_out_fifo36_to_fifo19
+ (.clk(dsp_clk), .reset(dsp_rst), .clear(0),
+ .f36_datain(tx_f36_data), .f36_src_rdy_i(tx_f36_src_rdy), .f36_dst_rdy_o(tx_f36_dst_rdy),
+ .f19_dataout(tx_f19_data), .f19_src_rdy_o(tx_f19_src_rdy), .f19_dst_rdy_i(tx_f19_dst_rdy) );
+
// /////////////////////////////////////////////////////////////////////////
// Settings Bus -- Slave #7
settings_bus settings_bus
@@ -691,7 +683,8 @@ module u2_core
vita_tx_chain #(.BASE_CTRL(SR_TX_CTRL), .BASE_DSP(SR_TX_DSP),
.REPORT_ERROR(1), .DO_FLOW_CONTROL(1),
- .PROT_ENG_FLAGS(1), .USE_TRANS_HEADER(1))
+ .PROT_ENG_FLAGS(1), .USE_TRANS_HEADER(1),
+ .DSP_NUMBER(0))
vita_tx_chain
(.clk(dsp_clk), .reset(dsp_rst),
.set_stb(set_stb_dsp),.set_addr(set_addr_dsp),.set_data(set_data_dsp),
@@ -721,13 +714,13 @@ module u2_core
// VITA Timing
wire [31:0] debug_sync;
-
+
time_64bit #(.TICKS_PER_SEC(32'd100000000),.BASE(SR_TIME64)) time_64bit
(.clk(dsp_clk), .rst(dsp_rst), .set_stb(set_stb_dsp), .set_addr(set_addr_dsp), .set_data(set_data_dsp),
- .pps(pps_in), .vita_time(vita_time), .pps_int(pps_int),
+ .pps(pps_in), .vita_time(vita_time), .vita_time_pps(vita_time_pps), .pps_int(pps_int),
.exp_time_in(exp_time_in), .exp_time_out(exp_time_out),
.debug(debug_sync));
-
+
// /////////////////////////////////////////////////////////////////////////////////////////
// Debug Pins
diff --git a/fpga/usrp2/top/u2_rev3/u2_rev3.v b/fpga/usrp2/top/u2_rev3/u2_rev3.v
index f2bba6c50..759f7b7b8 100644
--- a/fpga/usrp2/top/u2_rev3/u2_rev3.v
+++ b/fpga/usrp2/top/u2_rev3/u2_rev3.v
@@ -471,7 +471,7 @@ module u2_rev3
//
- u2_core #(.RAM_SIZE(32768))
+ u2_core #(.RAM_SIZE(16384), .RAM_AW(14))
u2_core(.dsp_clk (dsp_clk),
.wb_clk (wb_clk),
.clock_ready (clock_ready),
diff --git a/fpga/usrp2/top/u2plus/bootloader.rmi b/fpga/usrp2/top/u2plus/bootloader.rmi
index 7c15699db..a7d051630 100644
--- a/fpga/usrp2/top/u2plus/bootloader.rmi
+++ b/fpga/usrp2/top/u2plus/bootloader.rmi
@@ -1,231 +1,231 @@
-defparam bootram.RAM0.INIT_00=256'h00000000_00000000_00000000_b80801c0_00000000_b808175c_00000000_b8080050;
-defparam bootram.RAM0.INIT_01=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_b8081764;
-defparam bootram.RAM0.INIT_02=256'h3020ffe0_b0000000_30401e70_31a01e98_00000000_00000000_00000000_00000000;
-defparam bootram.RAM0.INIT_03=256'h3021ffe4_e060f800_b0000000_b8000000_30a30000_b9f40668_80000000_b9f400cc;
-defparam bootram.RAM0.INIT_04=256'he8830000_e8601e78_80000000_99fc2000_f8601e78_b8000044_bc030014_f9e10000;
-defparam bootram.RAM0.INIT_05=256'h80000000_99fc1800_30a01e8c_bc030010_30600000_b0000000_30630004_be24ffec;
-defparam bootram.RAM0.INIT_06=256'h30600000_b0000000_3021001c_b60f0008_e9e10000_f060f800_b0000000_30600001;
-defparam bootram.RAM0.INIT_07=256'h80000000_99fc1800_bc03000c_30c0f804_b0000000_30a01e8c_f9e10000_3021ffe4;
-defparam bootram.RAM0.INIT_08=256'h80000000_99fc2000_bc04000c_30a01e90_bc030014_30800000_b0000000_e8601e90;
-defparam bootram.RAM0.INIT_09=256'h06463800_20e01e98_20c01e98_f9e10000_2021ffec_3021001c_b60f0008_e9e10000;
-defparam bootram.RAM0.INIT_0A=256'hb0000000_20c0f800_b0000000_bc92fff4_06463800_20c60004_f8060000_bc720014;
-defparam bootram.RAM0.INIT_0B=256'hb9f415f8_bc92fff4_06463800_20c60004_f8060000_bc720014_06463800_20e0f82c;
-defparam bootram.RAM0.INIT_0C=256'h32630000_20a00000_b9f401c8_20e00000_20c00000_80000000_b9f41778_80000000;
-defparam bootram.RAM0.INIT_0D=256'h20210014_b60f0008_30730000_c9e10000_80000000_b9f415c4_80000000_b9f41780;
-defparam bootram.RAM0.INIT_0E=256'he9e10000_f9610004_fa410010_95608001_fa21000c_f9610008_f9e10000_3021ffec;
-defparam bootram.RAM0.INIT_0F=256'hbc050018_30210014_b62e0000_ea410010_ea21000c_e9610008_940bc001_e9610004;
-defparam bootram.RAM0.INIT_10=256'h3021ff2c_80000000_b60f0008_bc32fff4_16432800_30630001_80000000_10600000;
-defparam bootram.RAM0.INIT_11=256'hb9f4062c_32c1001c_3261004c_f8610028_f9e10000_fac100d0_fa6100cc_3061002c;
-defparam bootram.RAM0.INIT_12=256'h22407fff_e8610024_bc230038_30a01984_10b30000_b9f40da4_10d60000_10b30000;
-defparam bootram.RAM0.INIT_13=256'h30a01984_bc120040_aa430001_30a0194c_e061001c_10a30000_be520034_16439003;
-defparam bootram.RAM0.INIT_14=256'he8e10020_e8c10028_b800ffa8_80000000_b9f406c0_b800ffb4_80000000_b9f406cc;
-defparam bootram.RAM0.INIT_15=256'h80000000_b9f40694_b800ff88_80000000_b9f406a0_30a0194c_80000000_b9f4155c;
-defparam bootram.RAM0.INIT_16=256'hb800ff60_80000000_b9f40678_30a01950_80000000_b9f411e8_30a08000_b0000000;
-defparam bootram.RAM0.INIT_17=256'hbe030020_30a00050_31000001_30e1001c_30c000f7_f9e10000_a46500ff_3021ffe0;
-defparam bootram.RAM0.INIT_18=256'hb810ffe8_30210020_b60f0008_e9e10000_80000000_b9f40330_f081001c_3080005e;
-defparam bootram.RAM0.INIT_19=256'h31000001_b9f40280_f9e10000_30e1001c_30c000f7_30a00050_3021ffe0_308000dc;
-defparam bootram.RAM0.INIT_1A=256'h3021ffdc_30210020_b60f0008_6463001f_3063ffff_a863005e_e9e10000_e061001c;
-defparam bootram.RAM0.INIT_1B=256'h30a0a120_b0000007_9403c001_ac640002_94808001_fac10020_fa61001c_f9e10000;
-defparam bootram.RAM0.INIT_1C=256'hb9f40ea8_80000000_b9f4082c_f800200c_80000000_b9f4fe74_f860200c_306000ff;
-defparam bootram.RAM0.INIT_1D=256'h80000000_b9f4ff6c_80000000_b9f4059c_30a01988_80000000_b9f409ec_80000000;
-defparam bootram.RAM0.INIT_1E=256'h30a00000_b0000030_bc160100_bc130134_a6632000_e8603334_12c30000_be23017c;
-defparam bootram.RAM0.INIT_1F=256'hb0000000_80000000_b9f40558_30a01b04_12c30000_be030068_80000000_b9f41180;
-defparam bootram.RAM0.INIT_20=256'hb9f41094_30a08000_b0000000_30c07c00_b9f40e70_30a00000_b0000030_30e08000;
-defparam bootram.RAM0.INIT_21=256'he9e10000_30600001_10a00000_b9f41244_80000000_b9f40524_30a01b30_80000000;
-defparam bootram.RAM0.INIT_22=256'hb000003f_80000000_b9f404f8_30a01b6c_30210024_b60f0008_eac10020_ea61001c;
-defparam bootram.RAM0.INIT_23=256'h80000000_b9f404d4_30a019f8_12630000_be230024_80000000_b9f410fc_30a00000;
-defparam bootram.RAM0.INIT_24=256'h30a00000_b000003f_30e08000_b0000000_10730000_b810ffb4_80000000_b9f4fd9c;
-defparam bootram.RAM0.INIT_25=256'hb9f40490_30a019bc_80000000_b9f41000_30a08000_b0000000_30c07c00_b9f40ddc;
-defparam bootram.RAM0.INIT_26=256'h80000000_b9f40474_30a01a50_30600001_b810ff70_10b60000_b9f411b0_80000000;
-defparam bootram.RAM0.INIT_27=256'h80000000_b9f40454_30a01ab4_bc230098_80000000_b9f41000_30a00000_b0000018;
-defparam bootram.RAM0.INIT_28=256'h80000000_b9f41048_30a00000_b000003f_80000000_b9f40444_30a0199c_b800fed8;
-defparam bootram.RAM0.INIT_29=256'hb9f4fda4_b800fe9c_80000000_b9f4fcec_80000000_b9f40424_30a019f8_bc230028;
-defparam bootram.RAM0.INIT_2A=256'h30c07c00_b9f40d24_30a00000_b000003f_30e08000_b0000000_b800fe84_10a00000;
-defparam bootram.RAM0.INIT_2B=256'hb9f410f8_80000000_b9f403d8_30a019bc_80000000_b9f40f48_30a08000_b0000000;
-defparam bootram.RAM0.INIT_2C=256'hb9f4fc60_30a00001_b9f4fd4c_80000000_b9f403c0_30a01a7c_b800fe50_10b30000;
-defparam bootram.RAM0.INIT_2D=256'hfa610020_3021ffd4_b800ff40_80000000_b9f410c8_30a00000_b0000018_30a07530;
-defparam bootram.RAM0.INIT_2E=256'hfac10024_30e00001_30c1001c_12e70000_f0c1001c_fae10028_10b30000_a66500ff;
-defparam bootram.RAM0.INIT_2F=256'h10b30000_10f60000_10d70000_10830000_be030030_12c80000_b9f40898_f9e10000;
-defparam bootram.RAM0.INIT_30=256'h10640000_a8830001_6463001f_3063ffff_80000000_b9f407d0_30800001_be76001c;
-defparam bootram.RAM0.INIT_31=256'hfac10024_3021ffcc_3021002c_b60f0008_eae10028_eac10024_ea610020_e9e10000;
-defparam bootram.RAM0.INIT_32=256'hf9e10000_12c80000_12e70000_13250000_13060000_fb210030_fb01002c_fae10028;
-defparam bootram.RAM0.INIT_33=256'h32d6ffff_e0770000_f301001c_30e00002_be76005c_30c1001c_10b90000_fa610020;
-defparam bootram.RAM0.INIT_34=256'hbe33ffcc_32f70001_b9f4089c_30a0000a_12630000_33180001_b9f407f8_f061001d;
-defparam bootram.RAM0.INIT_35=256'heb210030_eb01002c_eae10028_eac10024_ea610020_e9e10000_10730000_10b90000;
-defparam bootram.RAM0.INIT_36=256'h80000000_b9f4f998_f9e10000_3021ffe4_30600001_b810ffe0_30210034_b60f0008;
-defparam bootram.RAM0.INIT_37=256'h12660000_fb21002c_fb010028_fae10024_fa61001c_3021ffd0_80000000_b60f0008;
-defparam bootram.RAM0.INIT_38=256'haa43ffff_12c00000_b810001c_f9e10000_fac10020_13260000_12e70000_13050000;
-defparam bootram.RAM0.INIT_39=256'h10960000_90630060_10b80000_b9f405ec_32730001_bcb2002c_16572001_bc120030;
-defparam bootram.RAM0.INIT_3A=256'he9e10000_10640000_f0130000_14999800_32d60001_be32ffd4_aa43000a_f0730000;
-defparam bootram.RAM0.INIT_3B=256'h3021ffd0_30210030_b60f0008_eb21002c_eb010028_eae10024_eac10020_ea61001c;
-defparam bootram.RAM0.INIT_3C=256'h13260000_12e70000_13050000_12660000_fb21002c_fb010028_fae10024_fa61001c;
-defparam bootram.RAM0.INIT_3D=256'hb9f4051c_32730001_bcb2002c_16572001_12c00000_b8100014_f9e10000_fac10020;
-defparam bootram.RAM0.INIT_3E=256'h14999800_32d60001_be32ffdc_aa43000a_f0730000_10960000_90630060_10b80000;
-defparam bootram.RAM0.INIT_3F=256'heb21002c_eb010028_eae10024_eac10020_ea61001c_e9e10000_10640000_f0130000;
-defparam bootram.RAM1.INIT_00=256'h12e60000_12c50000_fae10024_fac10020_fa61001c_3021ffd8_30210030_b60f0008;
-defparam bootram.RAM1.INIT_01=256'hbe32ffec_aa43000a_f0730000_90630060_10b60000_b9f404b0_12660000_f9e10000;
-defparam bootram.RAM1.INIT_02=256'heae10024_eac10020_ea61001c_e9e10000_10770000_f0130000_3273ffff_32730001;
-defparam bootram.RAM1.INIT_03=256'he9e10000_10a00000_b9f4ff94_f9e10000_3021ffe4_10c50000_30210028_b60f0008;
-defparam bootram.RAM1.INIT_04=256'hb60f0008_e9e10000_80000000_b9f40448_f9e10000_3021ffe4_3021001c_b60f0008;
-defparam bootram.RAM1.INIT_05=256'h3021001c_b60f0008_e9e10000_10a00000_b9f4ffdc_f9e10000_3021ffe4_3021001c;
-defparam bootram.RAM1.INIT_06=256'hbe060024_90c30060_12660000_e0660000_f9e10000_fac10020_fa61001c_3021ffdc;
-defparam bootram.RAM1.INIT_07=256'h10b60000_be26fff0_90c30060_e0730000_32730001_b9f40324_10b60000_12c50000;
-defparam bootram.RAM1.INIT_08=256'hfac1001c_3021ffe0_30210024_b60f0008_10600000_eac10020_ea61001c_e9e10000;
-defparam bootram.RAM1.INIT_09=256'heac1001c_e9e10000_30c0000a_b9f402dc_10b60000_12c50000_b9f4ff9c_f9e10000;
-defparam bootram.RAM1.INIT_0A=256'h10a00000_b9f4ffc0_f9e10000_3021ffe4_10c50000_30210020_b60f0008_10600000;
-defparam bootram.RAM1.INIT_0B=256'h10a00000_b9f4ff48_f9e10000_3021ffe4_10c50000_3021001c_b60f0008_e9e10000;
-defparam bootram.RAM1.INIT_0C=256'he9e10000_30c0000a_b9f40278_f9e10000_3021ffe4_3021001c_b60f0008_e9e10000;
-defparam bootram.RAM1.INIT_0D=256'hb9f40250_f9e10000_10a00000_12c50000_fac1001c_3021ffe0_3021001c_b60f0008;
-defparam bootram.RAM1.INIT_0E=256'hfac1001c_3021ffe0_30210020_b60f0008_eac1001c_e9e10000_10760000_10d60000;
-defparam bootram.RAM1.INIT_0F=256'h30210020_b60f0008_eac1001c_e9e10000_10760000_12c60000_b9f40228_f9e10000;
-defparam bootram.RAM1.INIT_10=256'h94e08001_3021001c_b60f0008_e9e10000_80000000_b9f401b8_f9e10000_3021ffe4;
-defparam bootram.RAM1.INIT_11=256'h80633000_84632000_84c62800_a866ffff_e880f81c_b0000000_9404c001_ac870002;
-defparam bootram.RAM1.INIT_12=256'h9404c001_80843800_ac840002_94808001_a4e70002_f860f81c_b0000000_f860200c;
-defparam bootram.RAM1.INIT_13=256'h88a52000_e880f81c_b0000000_9406c001_acc30002_94608001_80000000_b60f0008;
-defparam bootram.RAM1.INIT_14=256'h9404c001_80841800_ac840002_94808001_a4630002_f8a0f81c_b0000000_f8a0200c;
-defparam bootram.RAM1.INIT_15=256'ha866ffff_e880f820_b0000000_9404c001_ac870002_94e08001_80000000_b60f0008;
-defparam bootram.RAM1.INIT_16=256'h94808001_a4e70002_f860f820_b0000000_f8602020_80633000_84632000_84c62800;
-defparam bootram.RAM1.INIT_17=256'hfae10024_fa61001c_3021ffd4_80000000_b60f0008_9404c001_80843800_ac840002;
-defparam bootram.RAM1.INIT_18=256'hbe060040_90c30060_13050000_12e60000_e0660000_fac10020_f9e10000_fb010028;
-defparam bootram.RAM1.INIT_19=256'h10730000_be120028_16569800_32c70001_b8100014_32600001_be670038_12660000;
-defparam bootram.RAM1.INIT_1A=256'h10730000_3273ffff_32730001_be26ffe4_90c30060_c0779800_10b80000_b9f400cc;
-defparam bootram.RAM1.INIT_1B=256'h3021ffe4_3021002c_b60f0008_eb010028_eae10024_eac10020_ea61001c_e9e10000;
-defparam bootram.RAM1.INIT_1C=256'hf0c51e7c_3021001c_b60f0008_e9e10000_30c0000a_b9f40084_f9e10000_10a00000;
-defparam bootram.RAM1.INIT_1D=256'h80000000_b60f0008_f8653700_64a50405_e4661bac_10c63000_80000000_b60f0008;
-defparam bootram.RAM1.INIT_1E=256'h90c60060_b9f4ffc4_10b30000_e0d31e7c_12600000_f9e10000_fa61001c_3021ffe0;
-defparam bootram.RAM1.INIT_1F=256'he9e10000_bc32ffd8_aa530003_90c60060_b9f4ffbc_32730001_10b30000_e0d31ba8;
-defparam bootram.RAM1.INIT_20=256'h12c60000_f9e10000_fac10020_fa61001c_3021ffdc_30210020_b60f0008_ea61001c;
-defparam bootram.RAM1.INIT_21=256'hfac5000c_bc03fffc_e8650004_30a33700_64730405_12650000_be120030_aa46000a;
-defparam bootram.RAM1.INIT_22=256'hbc32ffd0_aa430001_e0651e7c_30210024_b60f0008_eac10020_ea61001c_e9e10000;
-defparam bootram.RAM1.INIT_23=256'hf9e10000_fac10020_fa61001c_3021ffdc_64730405_b810ffc8_30c0000d_b9f4ffac;
-defparam bootram.RAM1.INIT_24=256'hbc040008_e8830004_30633700_64730405_12650000_be120030_aa46000a_12c60000;
-defparam bootram.RAM1.INIT_25=256'haa430001_e0651e7c_30210024_b60f0008_eac10020_ea61001c_e9e10000_fac3000c;
-defparam bootram.RAM1.INIT_26=256'h30a53700_64a50405_64730405_b810ffc4_80000000_b9f4ff44_30c0000d_be32ffd0;
-defparam bootram.RAM1.INIT_27=256'he8650008_30a53700_64a50405_80000000_b60f0008_e8650010_bc03fffc_e8650008;
-defparam bootram.RAM1.INIT_28=256'h64a50405_80000000_b60f0008_90630060_be24fff8_e8850008_e8650010_bc030014;
-defparam bootram.RAM1.INIT_29=256'h32600001_be230040_e8760008_32c53700_fa61001c_f9e10000_fac10020_3021ffdc;
-defparam bootram.RAM1.INIT_2A=256'hbe03ffe8_e8760008_30a00001_b9f401e0_3060ffff_be120034_aa53012d_b8000010;
-defparam bootram.RAM1.INIT_2B=256'he9e10000_e8760010_3060ffff_be52000c_16539001_3240012b_3273ffff_32730001;
-defparam bootram.RAM1.INIT_2C=256'h32400004_a463000f_e8603324_f8003108_30210024_b60f0008_eac10020_ea61001c;
-defparam bootram.RAM1.INIT_2D=256'ha46300ff_64a30008_e4641bb8_10831800_30600004_10831800_beb20010_16439001;
-defparam bootram.RAM1.INIT_2E=256'ha4a500ff_be070088_80000000_b60f0008_f8603108_30600080_f8a03104_f8603100;
-defparam bootram.RAM1.INIT_2F=256'hf8803110_30800090_f860310c_a0630001_10652800_be23fff8_a4630040_e8603110;
-defparam bootram.RAM1.INIT_30=256'haa470001_10800000_be230058_a4630080_e8603110_bc23fff8_a4630002_e8603110;
-defparam bootram.RAM1.INIT_31=256'h30e7ffff_e860310c_bc23fff8_a4630002_e8603110_f8603110_30600020_be120038;
-defparam bootram.RAM1.INIT_32=256'h30600068_b810ffd0_30600020_be32ffd8_aa470001_30c60001_be07001c_f0660000;
-defparam bootram.RAM1.INIT_33=256'ha4a500ff_10640000_b60f0008_f8603110_30600040_10640000_b60f0008_30800001;
-defparam bootram.RAM1.INIT_34=256'h306000d0_30600090_be27000c_f860310c_10652800_be23fff8_a4630040_e8603110;
-defparam bootram.RAM1.INIT_35=256'h10800000_be23005c_a4630080_e8603110_bc23fff8_a4630002_e8603110_f8603110;
-defparam bootram.RAM1.INIT_36=256'hf8803110_bc120030_aa470001_f860310c_30800010_e0660000_30800001_be070068;
-defparam bootram.RAM1.INIT_37=256'hbe070028_30e7ffff_be23001c_a4630080_e8603110_bc23fff8_a4630002_e8603110;
-defparam bootram.RAM1.INIT_38=256'hb60f0008_f8603110_30600040_10800000_30800050_b810ffd4_b800ffc4_30c60001;
-defparam bootram.RAM1.INIT_39=256'hbc260054_a4c30000_b0008000_e8603324_10640000_b60f0008_30800001_10640000;
-defparam bootram.RAM1.INIT_3A=256'h80000000_10800000_bc660030_e8c01e80_10660000_be650048_bc430054_e8601e80;
-defparam bootram.RAM1.INIT_3B=256'h16443000_30840001_80000000_80000000_80000000_80000000_80000000_80000000;
-defparam bootram.RAM1.INIT_3C=256'ha4630007_e8603324_80000000_b60f0008_bc32ffc8_16432800_30630001_bc32ffdc;
-defparam bootram.RAM1.INIT_3D=256'h16459001_3240005a_3065ffa9_90a50060_b800ff9c_f8801e80_e4831bc4_10631800;
-defparam bootram.RAM1.INIT_3E=256'h3085ffd0_be52000c_16459001_32400039_a46300ff_3065ffc9_a46300ff_be520024;
-defparam bootram.RAM1.INIT_3F=256'hf9e10000_fb610034_13250000_fb21002c_3021ffc8_80000000_b60f0008_a46400ff;
-defparam bootram.RAM2.INIT_00=256'haa43003a_13660000_e0790000_fb410030_fb010028_fae10024_fac10020_fa61001c;
-defparam bootram.RAM2.INIT_01=256'heb010028_eae10024_eac10020_ea61001c_e9e10000_10650000_30a0ffff_be120034;
-defparam bootram.RAM2.INIT_02=256'hc085c800_30a00001_e8c01e84_30210038_b60f0008_eb610034_eb410030_eb21002c;
-defparam bootram.RAM2.INIT_03=256'hb810ffac_bc23ffe4_a4630044_c0662000_a4a300ff_be04001c_90840060_30650001;
-defparam bootram.RAM2.INIT_04=256'h12761800_66c30404_b9f4ff1c_e0b90002_80000000_b9f4ff28_e0b90001_30a0fffe;
-defparam bootram.RAM2.INIT_05=256'he0b90005_30a0fffd_be38ff74_93040060_e083000b_10791800_fa7b0004_10739800;
-defparam bootram.RAM2.INIT_06=256'h66c3040c_b9f4fed8_e0b90004_66e30404_b9f4fee4_e0b90003_13530000_b9f4fef0;
-defparam bootram.RAM2.INIT_07=256'he0b90007_fafb0008_12f7b000_12d61800_12d61800_b9f4fec8_64630408_e0b90006;
-defparam bootram.RAM2.INIT_08=256'hbe130060_f07b0000_1063b000_66c30404_b9f4fea4_e0b90008_80000000_b9f4feb0;
-defparam bootram.RAM2.INIT_09=256'hb9f4fe74_c0b6c800_a6d600ff_32d60009_12d8c000_ea7b000c_13580000_10f30000;
-defparam bootram.RAM2.INIT_0A=256'he8fb0004_ea7b000c_d0789800_1063b800_66e30404_b9f4fe68_e0b60001_12d9b000;
-defparam bootram.RAM2.INIT_0B=256'headb0008_a74300ff_be52ffb8_1647c003_107a1800_a70400ff_c073c000_30980001;
-defparam bootram.RAM2.INIT_0C=256'h107a1800_12c7b000_10632000_e0b70009_12f9b800_64760008_12e73800_e09b0000;
-defparam bootram.RAM2.INIT_0D=256'ha6d600ff_1063c000_16d60000_67030404_b9f4fe04_e0b7000a_12d61800_b9f4fe10;
-defparam bootram.RAM2.INIT_0E=256'ha4630100_e8603b10_10a00000_b810fe58_30a0fffb_be32fe60_1643b000_a46300ff;
-defparam bootram.RAM2.INIT_0F=256'ha4a500ff_80884800_a1292000_a508007f_a5290600_80000000_b60f0008_bc23fff8;
-defparam bootram.RAM2.INIT_10=256'ha0840100_f8603b18_a46600ff_f8803b10_f8e03b00_bc23fff8_a4630100_e8603b10;
-defparam bootram.RAM2.INIT_11=256'hb60f0008_e8603b00_bc23fff8_a4630100_e8603b10_10650000_be050018_f8803b10;
-defparam bootram.RAM2.INIT_12=256'h31200400_31000008_10a00000_f9e10000_3021ffe4_10e60000_10c00000_80000000;
-defparam bootram.RAM2.INIT_13=256'h3021ffc4_3021001c_b60f0008_e9e10000_80000000_b9f4ff84_f8603b14_30600001;
-defparam bootram.RAM2.INIT_14=256'hb9f4ff3c_fae10034_13060000_f9e10000_fb010038_fa61002c_12c50000_fac10030;
-defparam bootram.RAM2.INIT_15=256'hfac03b00_f8603b04_3060000b_66d60408_f8603b10_f8003b18_30600400_12670000;
-defparam bootram.RAM2.INIT_16=256'h80000000_b9f4ff00_f8603b10_30600528_f8803b10_30800428_f8603b18_30600001;
-defparam bootram.RAM2.INIT_17=256'hf8803b10_30800500_f8603b10_30600400_3261001c_12e00000_12d30000_be18009c;
-defparam bootram.RAM2.INIT_18=256'he8803b04_f8610020_e8603b08_f881001c_14b7c000_e8803b0c_80000000_b9f4fed8;
-defparam bootram.RAM2.INIT_19=256'h30a00010_10800000_beb20034_16459003_22400010_f8610028_e8603b00_f8810024;
-defparam bootram.RAM2.INIT_1A=256'hbeb20020_1658b803_12f72800_bc32fff0_16442800_30840001_d0762000_c0732000;
-defparam bootram.RAM2.INIT_1B=256'hf8003b18_12d62800_be52ff7c_1658b803_12f72800_bc25ffd8_b800ff8c_12d62800;
-defparam bootram.RAM2.INIT_1C=256'hb0009f00_3021003c_b60f0008_eb010038_eae10034_eac10030_ea61002c_e9e10000;
-defparam bootram.RAM2.INIT_1D=256'h31200400_b9f4fe34_f9e10000_31000020_30c00001_30a00001_3021ffe4_30e00000;
-defparam bootram.RAM2.INIT_1E=256'h3021ffe4_e860f828_b0000000_3021001c_b60f0008_a463ffff_b00000ff_e9e10000;
-defparam bootram.RAM2.INIT_1F=256'h64830008_80000000_b9f4ffa8_3021001c_b60f0008_e9e10000_bc030010_f9e10000;
-defparam bootram.RAM2.INIT_20=256'h16439001_32400015_80000000_b9f40330_a46300ff_be120010_aa440020_a48400ff;
-defparam bootram.RAM2.INIT_21=256'hb0000000_b800ffb0_f860f828_b0000000_bc52ffe4_16439001_32400018_bcb2fff0;
-defparam bootram.RAM2.INIT_22=256'hb9f4ff40_3021001c_b60f0008_e9e10000_bc030010_f9e10000_3021ffe4_e860f824;
-defparam bootram.RAM2.INIT_23=256'h80000000_b9f402c8_a4a300ff_be120010_aa440020_a48400ff_64830008_80000000;
-defparam bootram.RAM2.INIT_24=256'hb0000000_e0651bbe_bc52ffe4_16459001_32400018_bcb2fff0_16459001_32400015;
-defparam bootram.RAM2.INIT_25=256'h10c50000_12c00000_fac1001c_3021ffe0_b800ffa4_f860f824_b0000000_f8a0f828;
-defparam bootram.RAM2.INIT_26=256'heac1001c_e9e10000_80000000_99fcb000_30e00024_b9f40334_f9e10000_10b60000;
-defparam bootram.RAM2.INIT_27=256'hb810001c_30e1001c_b9f4fd88_f9e10000_30c00040_3021ffa4_30210020_b60f0008;
-defparam bootram.RAM2.INIT_28=256'he063001c_10612800_10600000_be520044_16459001_3240003e_30a50001_10a00000;
-defparam bootram.RAM2.INIT_29=256'haa440099_e083001c_10612800_30a50001_bc32ffd8_aa4300aa_bc12ffe0_aa4300ff;
-defparam bootram.RAM2.INIT_2A=256'h3021005c_b60f0008_e9e10000_3021005c_b60f0008_e9e10000_30600001_be32ffc8;
-defparam bootram.RAM2.INIT_2B=256'h10b60000_30c00006_b9f4fd08_f9e10000_10f60000_32c1001c_fac10028_3021ffd4;
-defparam bootram.RAM2.INIT_2C=256'heac10028_e9e10000_a884ffff_80841800_14830000_30e00006_b9f401f8_30c01bd8;
-defparam bootram.RAM2.INIT_2D=256'h65040403_64e40003_64a40007_64c40005_e0803a03_3021002c_b60f0008_6464001f;
-defparam bootram.RAM2.INIT_2E=256'ha4a50008_80e73000_90a40041_a4e70004_80c62800_a4c60002_64640407_65240405;
-defparam bootram.RAM2.INIT_2F=256'h81294000_a5290040_81082000_a5080020_80842800_a4840010_80a53800_10842000;
-defparam bootram.RAM2.INIT_30=256'h64e50403_64c50003_64650007_64850005_a4a500ff_a46300ff_b60f0008_80634800;
-defparam bootram.RAM2.INIT_31=256'ha4630008_80c62000_90650041_a4c60004_80841800_a4840002_65250407_65050405;
-defparam bootram.RAM2.INIT_32=256'h81083800_a5080040_80e72800_a4e70020_80a51800_a4a50010_80633000_10a52800;
-defparam bootram.RAM2.INIT_33=256'hb00000ff_fac1001c_3021ffe0_80000000_b60f0008_f9203a00_a52900ff_81294000;
-defparam bootram.RAM2.INIT_34=256'h30a0ffaa_b9f4ff74_30a0ffff_b9f4ff7c_30a0ffff_b9f4ff84_f9e10000_a6c5ffff;
-defparam bootram.RAM2.INIT_35=256'h30a00061_b9f4ff54_30a00032_b9f4ff5c_a2d60000_b0000b00_30a0ff99_b9f4ff6c;
-defparam bootram.RAM2.INIT_36=256'h30a0ff81_b9f4ff34_30a00032_b9f4ff3c_10b60000_b9f4ff44_64b60008_b9f4ff4c;
-defparam bootram.RAM2.INIT_37=256'h30a0ffa1_b9f4ff14_30a00030_b9f4ff1c_64b60010_b9f4ff24_30a0000b_b9f4ff2c;
-defparam bootram.RAM2.INIT_38=256'h10a00000_b9f4fef4_30a00020_b9f4fefc_30a0000e_b9f4ff04_10a00000_b9f4ff0c;
-defparam bootram.RAM2.INIT_39=256'h30210020_b60f0008_eac1001c_e9e10000_10a00000_b9f4fee4_30a00020_b9f4feec;
-defparam bootram.RAM2.INIT_3A=256'hb6110000_30a0ffff_b9f4e91c_80000000_b9f4f220_f9e10000_3021ffe4_30a01be0;
-defparam bootram.RAM2.INIT_3B=256'h22400003_80000000_b60f0008_80000000_b60f0008_80000000_b6910000_80000000;
-defparam bootram.RAM2.INIT_3C=256'h16432000_e8660000_e8850000_bc230050_a4630003_80653000_beb2005c_16479003;
-defparam bootram.RAM2.INIT_3D=256'h30e7ffff_30c60004_be52ffe0_16479003_22400003_30a50004_30e7fffc_bc320040;
-defparam bootram.RAM2.INIT_3E=256'h30c60001_30a50001_be320020_16434000_e0660000_e1050000_bc120028_aa47ffff;
-defparam bootram.RAM2.INIT_3F=256'h2240000f_14634000_b60f0008_10600000_b60f0008_bc32ffe0_aa47ffff_30e7ffff;
-defparam bootram.RAM3.INIT_00=256'hbc070024_11050000_be030034_a4630003_80662800_10850000_beb20018_16479003;
-defparam bootram.RAM3.INIT_01=256'h30c60001_be32fff0_16474000_31080001_f0680000_e0660000_10e72000_11040000;
-defparam bootram.RAM3.INIT_02=256'he8860008_f8680004_e8660004_f8880000_30e7fff0_e8860000_10650000_b60f0008;
-defparam bootram.RAM3.INIT_03=256'h31080010_be52ffd0_16479003_2240000f_f868000c_30c60010_e866000c_f8880008;
-defparam bootram.RAM3.INIT_04=256'h22400003_d8682000_30e7fffc_c8662000_10800000_bcb2002c_16479003_22400003;
-defparam bootram.RAM3.INIT_05=256'he860193c_10880000_b810ff68_11044000_10c43000_30840004_be52ffec_16479003;
-defparam bootram.RAM3.INIT_06=256'h3273fffc_99fc1800_bc120018_aa43ffff_3260193c_f9e10000_fa61001c_3021ffe0;
-defparam bootram.RAM3.INIT_07=256'h3021fff8_30210020_b60f0008_ea61001c_e9e10000_bc32fff0_aa43ffff_e8730000;
-defparam bootram.RAM3.INIT_08=256'h30210008_b60f0008_c9e00800_80000000_b9f4ffb0_80000000_b9f4e7d4_d9e00800;
-defparam bootram.RAM3.INIT_09=256'hffffffff_30210008_b60f0008_c9e00800_80000000_b9f4e74c_d9e00800_3021fff8;
-defparam bootram.RAM3.INIT_0A=256'h696d6167_61696e20_523a206d_4552524f_4f4b0000_00000000_ffffffff_00000000;
-defparam bootram.RAM3.INIT_0B=256'h64206d6f_206c6f61_49484558_20696e20_4261636b_65642120_7475726e_65207265;
-defparam bootram.RAM3.INIT_0C=256'h53746172_720a0000_6f616465_6f6f746c_322b2062_55535250_4e4f4b00_64652e00;
-defparam bootram.RAM3.INIT_0D=256'h4552524f_2e000000_6d6f6465_61666520_696e2073_50322b20_20555352_74696e67;
-defparam bootram.RAM3.INIT_0E=256'h20546869_72616d21_70726f67_61696e20_6f6d206d_6e206672_65747572_523a2072;
-defparam bootram.RAM3.INIT_0F=256'h523a206e_4552524f_6e210000_61707065_65722068_206e6576_6f756c64_73207368;
-defparam bootram.RAM3.INIT_10=256'h626c652e_61696c61_65206176_696d6167_61726520_69726d77_66652066_6f207361;
-defparam bootram.RAM3.INIT_11=256'h6c6f6164_20746f20_66726565_65656c20_6b2e2046_62726963_6d206120_20492061;
-defparam bootram.RAM3.INIT_12=256'h2076616c_20666f72_6b696e67_43686563_2e000000_2052414d_5820746f_20494845;
-defparam bootram.RAM3.INIT_13=256'h56616c69_2e2e2e00_6d616765_47412069_6e204650_6374696f_726f6475_69642070;
-defparam bootram.RAM3.INIT_14=256'h642e2041_666f756e_61676520_4120696d_20465047_74696f6e_6f647563_64207072;
-defparam bootram.RAM3.INIT_15=256'h2070726f_616c6964_4e6f2076_742e0000_20626f6f_6720746f_7074696e_7474656d;
-defparam bootram.RAM3.INIT_16=256'h74656d70_2e0a4174_6f756e64_67652066_20696d61_46504741_696f6e20_64756374;
-defparam bootram.RAM3.INIT_17=256'h77617265_6669726d_696f6e20_64756374_2070726f_6c6f6164_20746f20_74696e67;
-defparam bootram.RAM3.INIT_18=256'h6520666f_6d776172_20666972_74696f6e_6f647563_64207072_56616c69_2e2e2e00;
-defparam bootram.RAM3.INIT_19=256'h6e206672_65747572_523a2052_4552524f_2e2e2e00_64696e67_204c6f61_756e642e;
-defparam bootram.RAM3.INIT_1A=256'h206e6576_6f756c64_73207368_20546869_72616d21_70726f67_61696e20_6f6d206d;
-defparam bootram.RAM3.INIT_1B=256'h696f6e20_64756374_2070726f_616c6964_4e6f2076_6e210000_61707065_65722068;
-defparam bootram.RAM3.INIT_1C=256'h6669726d_61666520_6e672073_54727969_6e642e20_20666f75_77617265_6669726d;
-defparam bootram.RAM3.INIT_1D=256'h0018000f_ffff0031_01b200d9_05160364_14580a2c_05050400_2e2e2e00_77617265;
-defparam bootram.RAM3.INIT_1E=256'hb8080000_b0000000_10101200_06820594_09c407d0_13880d05_00002710_000b0000;
-defparam bootram.RAM3.INIT_1F=256'h20202020_28282820_20202828_20202020_00202020_00000000_6f72740a_0a0a6162;
-defparam bootram.RAM3.INIT_20=256'h10040404_10101010_10101010_10101010_20881010_20202020_20202020_20202020;
-defparam bootram.RAM3.INIT_21=256'h01010101_01010101_01010101_41414141_10104141_10101010_04040410_04040404;
-defparam bootram.RAM3.INIT_22=256'h02020202_02020202_02020202_42424242_10104242_10101010_01010101_01010101;
-defparam bootram.RAM3.INIT_23=256'h00000000_00000000_00000000_00000000_20000000_10101010_02020202_02020202;
+defparam bootram.RAM0.INIT_00=256'h00000000_00000000_00000000_a4a20400_3a0b0b0b_0bae840c_82700b0b_0b0b0b0b;
+defparam bootram.RAM0.INIT_01=256'h00000000_00000000_00000000_800c0400_880c840c_0ba4df2d_88080b0b_80088408;
+defparam bootram.RAM0.INIT_02=256'h00000000_00000000_04000000_ffff0652_832b2a83_81058205_72830609_71fd0608;
+defparam bootram.RAM0.INIT_03=256'h83a70400_0b0b0b0b_7383ffff_2b2b0906_05820583_83060981_83ffff73_71fd0608;
+defparam bootram.RAM0.INIT_04=256'h00000000_00000000_53510400_070a8106_73097306_09060906_72057373_72098105;
+defparam bootram.RAM0.INIT_05=256'h00000000_00000000_00000000_00000000_00000000_51040000_732e0753_72722473;
+defparam bootram.RAM0.INIT_06=256'h00000000_53510400_81065151_0a31050a_0a720a10_30720a10_71068106_71737109;
+defparam bootram.RAM0.INIT_07=256'h00000000_00000000_00000000_00000000_00000000_51040000_732e0753_72722673;
+defparam bootram.RAM0.INIT_08=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM0.INIT_09=256'h00000000_00000000_00000000_00000000_00000000_00000000_c3040000_0b0b0b88;
+defparam bootram.RAM0.INIT_0A=256'h00000000_00000000_00000000_00000000_00000000_00000000_0a535104_720a722b;
+defparam bootram.RAM0.INIT_0B=256'h00000000_00000000_00000000_00000000_05040000_0b0b88a6_0981050b_72729f06;
+defparam bootram.RAM0.INIT_0C=256'h00000000_00000000_04000000_06075351_8106ff05_0974090a_739f062a_72722aff;
+defparam bootram.RAM0.INIT_0D=256'h00000000_0c515104_0772fc06_832b0b2b_81058205_73830609_020d0406_71715351;
+defparam bootram.RAM0.INIT_0E=256'h00000000_00000000_00000000_51040000_0a810653_81050906_72050970_72098105;
+defparam bootram.RAM0.INIT_0F=256'h00000000_00000000_00000000_53510400_0a098106_81050906_72050970_72098105;
+defparam bootram.RAM0.INIT_10=256'h00000000_00000000_00000000_00000000_00000000_00000000_52040000_71098105;
+defparam bootram.RAM0.INIT_11=256'h00000000_00000000_00000000_00000000_00000000_04000000_05055351_72720981;
+defparam bootram.RAM0.INIT_12=256'h00000000_00000000_00000000_00000000_00000000_07535104_73730906_72097206;
+defparam bootram.RAM0.INIT_13=256'h00000000_00000000_04000000_81ff0652_1010102a_81058305_72830609_71fc0608;
+defparam bootram.RAM0.INIT_14=256'h00000000_00000000_88a90400_060b0b0b_10100508_f0738306_0b0b0bad_71fc0608;
+defparam bootram.RAM0.INIT_15=256'h00000000_0c510400_0c840c80_80085688_992d5050_0b0b0b9e_88087575_80088408;
+defparam bootram.RAM0.INIT_16=256'h00000000_0c510400_0c840c80_80085688_cb2d5050_0b0b0b9f_88087575_80088408;
+defparam bootram.RAM0.INIT_17=256'h04000000_07515151_05ff0506_73097274_70547106_8106ff05_0509060a_72097081;
+defparam bootram.RAM0.INIT_18=256'h51040000_06075151_7405ff05_06730972_05705471_098106ff_0509060a_72097081;
+defparam bootram.RAM0.INIT_19=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_05ff0504;
+defparam bootram.RAM0.INIT_1A=256'h00000000_00000000_00000000_00000000_00000000_51040000_0bae800c_810b0b0b;
+defparam bootram.RAM0.INIT_1B=256'h00000000_00000000_00000000_00000000_00000000_00000000_04000000_71810552;
+defparam bootram.RAM0.INIT_1C=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM0.INIT_1D=256'h00000000_00000000_00000000_00000000_00000000_04000000_10100552_02840572;
+defparam bootram.RAM0.INIT_1E=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM0.INIT_1F=256'h00000000_00000000_00000000_00000000_00000000_020d0400_05715351_717105ff;
+defparam bootram.RAM0.INIT_20=256'h10101010_10101010_10101010_10101010_10101010_10101010_ff3f0410_81f33f9d;
+defparam bootram.RAM0.INIT_21=256'h060c5151_2b0772fc_05101010_09810583_06738306_047381ff_10105351_10101010;
+defparam bootram.RAM0.INIT_22=256'h535104ae_ed385151_100a5372_1052720a_72060571_06ff0509_72807281_043c0472;
+defparam bootram.RAM0.INIT_23=256'hc00c8290_a0800bb5_b5bc0c82_0b0b0b0b_38838080_08822eb9_a138ae84_8008802e;
+defparam bootram.RAM0.INIT_24=256'h80808480_b5c00cf8_8082800b_bc0cf880_0b0b0bb5_8080a40b_0c04f880_800bb5c4;
+defparam bootram.RAM0.INIT_25=256'h0ba6b00b_c00c0b0b_80940bb5_0c80c0a8_0b0bb5bc_808c0b0b_0480c0a8_0bb5c40c;
+defparam bootram.RAM0.INIT_26=256'hae8c0c70_92388412_5270802e_08700852_a338ae8c_c8335170_ff3d0db5_b5c40c04;
+defparam bootram.RAM0.INIT_27=256'hb808802e_0b0b0bb5_04803d0d_833d0d04_0bb5c834_70f03881_70085252_2dae8c08;
+defparam bootram.RAM0.INIT_28=256'hf5e23f82_510b0b0b_0b0bb5b8_3d0d040b_06853882_802e0981_0b0b800b_8e380b0b;
+defparam bootram.RAM0.INIT_29=256'h518bb43f_d0055273_3fb23dfe_5254868c_59923d70_3dfee005_d03d0db2_3d0d0404;
+defparam bootram.RAM0.INIT_2A=256'h3d335473_519e3986_b43fa6b4_52735198_38765378_ff74278f_775481ff_8008b238;
+defparam bootram.RAM0.INIT_2B=256'hb039fc3d_858a3fff_39a6ec51_a6b85184_3f91c23f_b4518598_068f38a6_812e0981;
+defparam bootram.RAM0.INIT_2C=256'h3fa6f051_e03f86d6_85e13f8e_81a08c0c_fc3f800b_80e45189_81a08c0c_0d81ff0b;
+defparam bootram.RAM0.INIT_2D=256'h51547380_70810651_08708d2a_3f81c6b4_805182ed_81ff0655_ee3f8008_84e23f83;
+defparam bootram.RAM0.INIT_2E=256'h80805380_82c33f82_a6388151_8008802e_5190b53f_81fc8080_5184bd3f_c338a79c;
+defparam bootram.RAM0.INIT_2F=256'hf8518484_3f8a39a7_73519191_5184913f_c43fa7bc_8eaa3f90_fc808051_ffff5281;
+defparam bootram.RAM0.INIT_30=256'h5183e53f_9938a8fc_8008802e_518fa03f_3fb0800a_d05183f8_74b238a8_3ffea13f;
+defparam bootram.RAM0.INIT_31=256'h8fc63f80_98800a51_5183cd3f_d83fa9b4_800a5190_88df3fb0_3f82ac51_815181f9;
+defparam bootram.RAM0.INIT_32=256'h5183a53f_bb3faab0_800a518d_ffff5298_80805380_83ba3f82_38aa8451_08802eaa;
+defparam bootram.RAM0.INIT_33=256'h80085480_518f893f_81fc8080_5183913f_ba39ab90_3faad451_a43f8fc9_82ac5188;
+defparam bootram.RAM0.INIT_34=256'hac5187e9_82ea3f82_3faab051_80518d80_5281fc80_5380ffff_38828080_08802eb5;
+defparam bootram.RAM0.INIT_35=256'h82c63ffc_39a7f851_3f81548a_80518fd5_5187da3f_db3f82ac_a7bc5182_3f8f8e3f;
+defparam bootram.RAM0.INIT_36=256'hb7387581_54807425_74ff1656_5a575758_7a7c7f7f_04f83d0d_0c863d0d_e33f7380;
+defparam bootram.RAM0.INIT_37=256'hff065185_05527781_538a3dfc_a1053482_33028405_70810558_8a3d3476_17575473;
+defparam bootram.RAM0.INIT_38=256'h04fa3d0d_0c8a3d0d_81547380_8538c139_3f73802e_8a5186fd_81ff0654_cf3f8008;
+defparam bootram.RAM0.INIT_39=256'hd051ff89_81f75280_3dfc0553_34815488_5675883d_748338dc_5580de56_02a30533;
+defparam bootram.RAM0.INIT_3A=256'h70525684_02a70533_3dfc0552_34815389_0533893d_7c5702ab_04f93d0d_3f883d0d;
+defparam bootram.RAM0.INIT_3B=256'h3f800881_755183b2_76537b52_77259738_2e9e3880_56547380_81ff0670_ef3f8008;
+defparam bootram.RAM0.INIT_3C=256'h5381f752_883dfc05_3d0d8154_3d0d04fa_74800c89_83388155_5473802e_ff067056;
+defparam bootram.RAM0.INIT_3D=256'h3d0d04fb_75800c88_83388156_2e098106_567480de_883d3356_a03f800b_80d051ff;
+defparam bootram.RAM0.INIT_3E=256'h5581bb3f_06537652_157481ff_2e903881_54547280_7081ff06_56567433_3d0d7779;
+defparam bootram.RAM0.INIT_3F=256'h800b800c_51819f3f_3f8a5272_705253cb_0d747653_0d04fe3d_800c873d_e539800b;
+defparam bootram.RAM1.INIT_00=256'h81135374_55558439_76787055_04fc3d0d_3f833d0d_528051de_ff3d0d73_843d0d04;
+defparam bootram.RAM1.INIT_01=256'h863d0d04_3473800c_e7388073_2e098106_0652718a_800881ff_80087334_5181b23f;
+defparam bootram.RAM1.INIT_02=256'h0d04ff3d_1234823d_0533ae90_7251028f_04803d0d_3f833d0d_528051c9_ff3d0d73;
+defparam bootram.RAM1.INIT_03=256'hae901333_3d0d8053_3d0d04fe_0c535183_05702272_7510abcc_81ce8005_0d73a029;
+defparam bootram.RAM1.INIT_04=256'h0d767856_0d04fc3d_e738843d_53827325_d13f8113_33527251_3fae9413_527251c9;
+defparam bootram.RAM1.INIT_05=256'h73a02981_7351df3f_87388d52_2e098106_33537281_38ae9014_09810694_54748a2e;
+defparam bootram.RAM1.INIT_06=256'hce800552_73a02981_04ff3d0d_0c863d0d_38748c15_72802ef8_84140853_ce800554;
+defparam bootram.RAM1.INIT_07=256'hc6a40870_c2880c81_0d800b81_0d04ff3d_800c833d_38901208_70802ef8_88120851;
+defparam bootram.RAM1.INIT_08=256'h2a81c284_800c7088_ff0681c2_70227081_10ae9805_38845170_84712583_8f065151;
+defparam bootram.RAM1.INIT_09=256'h81517180_33555354_88059705_0d767802_0d04fd3d_880c833d_800b81c2_0c515181;
+defparam bootram.RAM1.INIT_0A=256'h81900b81_81c28c0c_72108107_5170f138_81065151_70862a70_81c29008_2e818638;
+defparam bootram.RAM1.INIT_0B=256'h06708132_872a7081_c2900870_70f13881_06515151_812a7081_c2900870_c2900c81;
+defparam bootram.RAM1.INIT_0C=256'h0c81c290_7081c290_8338a051_5171812e_b13880e8_3871802e_70802eba_51515151;
+defparam bootram.RAM1.INIT_0D=256'hcc398151_34ff1252_70810556_08517074_3881c28c_515170f1_70810651_0870812a;
+defparam bootram.RAM1.INIT_0E=256'h535481c2_97053355_78028805_fd3d0d76_853d0d04_0c70800c_0b81c290_883980c0;
+defparam bootram.RAM1.INIT_0F=256'h81905170_802e8438_81d05171_81c28c0c_f1387210_51515170_2a708106_90087086;
+defparam bootram.RAM1.INIT_10=256'h81067081_70872a70_81c29008_5170f138_81065151_70812a70_81c29008_81c2900c;
+defparam bootram.RAM1.INIT_11=256'h2e833890_d0517181_c28c0c80_38733381_802e80c5_80cf3871_5170802e_32515151;
+defparam bootram.RAM1.INIT_12=256'h2a708106_90087087_f13881c2_51515170_2a708106_90087081_900c81c2_517081c2;
+defparam bootram.RAM1.INIT_13=256'h81c2900c_3980c00b_3981518a_5354ffb7_8114ff13_802e8e38_51515170_70813251;
+defparam bootram.RAM1.INIT_14=256'h52717425_70a23870_06515254_0870810a_7581c6a4_04fd3d0d_0c853d0d_80517080;
+defparam bootram.RAM1.INIT_15=256'h853d0d04_1252e239_27f13881_868d9f71_74315151_c6ac0870_ac085381_9b3881c6;
+defparam bootram.RAM1.INIT_16=256'h06515171_127081ff_269638c9_527180da_ff065152_a9117081_8f0533ff_ff3d0d02;
+defparam bootram.RAM1.INIT_17=256'h335358ff_58568076_3d0d797b_3d0d04f9_70800c83_ff065151_d0127081_b9268938;
+defparam bootram.RAM1.INIT_18=256'h06721970_147081ff_aa387281_5371782e_81173353_ef38810b_09810682_5371ba2e;
+defparam bootram.RAM1.INIT_19=256'h71d83881_70335152_bd387216_71802e82_53515452_06515151_337080c4_33abdd11;
+defparam bootram.RAM1.INIT_1A=256'h7084190c_ff067205_3f800881_5252feec_06821733_842b9ff0_fb3f8008_163351fe;
+defparam bootram.RAM1.INIT_1B=256'h80068417_8c2bbfe0_cb3f8008_163351fe_828a3883_54fd5374_11335753_7010178b;
+defparam bootram.RAM1.INIT_1C=256'h9ff00673_8008842b_53fea93f_85173352_80067305_882b83fe_bb3f8008_335253fe;
+defparam bootram.RAM1.INIT_1D=256'h842b9ff0_873f8008_163351fe_88180c87_ff067305_3f800881_5253fe98_05861733;
+defparam bootram.RAM1.INIT_1E=256'hff068c19_89057081_d2387410_74742780_52717734_3f800812_5252fdf8_06881733;
+defparam bootram.RAM1.INIT_1F=256'h53fdc13f_06723352_842b9ff0_cf3f8008_565152fd_52335552_70708105_08177119;
+defparam bootram.RAM1.INIT_20=256'h51515284_065a525b_197081ff_81ff0681_33701a70_17081570_7274348c_80081353;
+defparam bootram.RAM1.INIT_21=256'h81ff0673_19703070_05547305_0571882a_08783372_17088818_ffb03884_17087526;
+defparam bootram.RAM1.INIT_22=256'h3f800812_5252fce4_068a1533_842b9ff0_f33f8008_515354fc_3356545b_101a8911;
+defparam bootram.RAM1.INIT_23=256'h3d0d0480_72800c89_83398053_8539fe53_81068938_77722e09_5152fb53_7081ff06;
+defparam bootram.RAM1.INIT_24=256'h337880ff_0d029305_0d04fe3d_f138823d_51515170_2a708106_90087088_3d0d81d6;
+defparam bootram.RAM1.INIT_25=256'h7681d680_5170f138_81065151_70882a70_81d69008_80075353_060780c0_067a8c80;
+defparam bootram.RAM1.INIT_26=256'h3881d690_72802e96_900c7251_800781d6_980c7182_ff0681d6_900c7581_0c7181d6;
+defparam bootram.RAM1.INIT_27=256'h810b81d6_04fc3d0d_0c843d0d_08517080_3881d680_515170f1_70810651_0870882a;
+defparam bootram.RAM1.INIT_28=256'h800b81d6_56fee43f_f63d0d7d_863d0d04_51ff873f_53805280_55885480_940c8880;
+defparam bootram.RAM1.INIT_29=256'h88a80b81_81d6980c_800c810b_882b81d6_d6840c7c_0c8b0b81_0b81d690_980c8880;
+defparam bootram.RAM1.INIT_2A=256'h900c8a80_800b81d6_80d33888_54737627_3f7e5580_900cfeb3_a80b81d6_d6900c8a;
+defparam bootram.RAM1.INIT_2B=256'h883d7675_d680085b_84085a81_085981d6_5881d688_81d68c08_0cfe983f_0b81d690;
+defparam bootram.RAM1.INIT_2C=256'h57348112_75708105_17517033_27913871_80527173_83387053_53707327_31525790;
+defparam bootram.RAM1.INIT_2D=256'hc0526851_70545780_3d0d883d_3d0d04ea_d6980c8c_39800b81_1454ffa9_52ec3972;
+defparam bootram.RAM1.INIT_2E=256'h81069438_81aa2e09_2e9d3873_547381ff_17703351_05575574_0284059d_fed23f80;
+defparam bootram.RAM1.INIT_2F=256'h5473800c_27d13880_1555be75_548b3981_06853881_992e0981_51547381_74167033;
+defparam bootram.RAM1.INIT_30=256'h85f73f80_d8527351_558453ab_fe823f80_84527951_3d705454_f93d0d86_983d0d04;
+defparam bootram.RAM1.INIT_31=256'h97053370_fd3d0d02_a0940c04_04810b81_0c893d0d_81557480_81068338_08752e09;
+defparam bootram.RAM1.INIT_32=256'h2ba00671_90067483_07077310_88067173_0672812a_71832a84_71872a07_852a8206;
+defparam bootram.RAM1.INIT_33=256'h51525351_81d4800c_7081ff06_78872b07_06707207_852b80c0_81ff0676_73070770;
+defparam bootram.RAM1.INIT_34=256'hff51ff98_ff9e3f81_5381ff51_81d00a07_74d00a06_04fe3d0d_52853d0d_55525555;
+defparam bootram.RAM1.INIT_35=256'h81ff0652_72882a70_51ff813f_873f80e1_3fb251ff_9951ff8c_ff923f81_3f81aa51;
+defparam bootram.RAM1.INIT_36=256'hdb3f7290_982a51fe_fee23f72_3f818151_b251fee8_51feed3f_7281ff06_52fef53f;
+defparam bootram.RAM1.INIT_37=256'hfeba3fa0_bf3f8e51_3f8051fe_a151fec4_feca3f81_cf3fb051_065253fe_2a7081ff;
+defparam bootram.RAM1.INIT_38=256'h8c0cf93d_398c0802_3d0d04ff_fea63f84_ab3f8051_3fa051fe_8051feb0_51feb53f;
+defparam bootram.RAM1.INIT_39=256'h800b8c08_0888050c_0508308c_388c0888_088025ab_8c088805_08fc050c_0d800b8c;
+defparam bootram.RAM1.INIT_3A=256'h088c0508_fc050c8c_05088c08_0c8c08f4_8c08f405_8838810b_08fc0508_f4050c8c;
+defparam bootram.RAM1.INIT_3B=256'h38810b8c_fc050888_050c8c08_0b8c08f0_8c050c80_08308c08_8c088c05_8025ab38;
+defparam bootram.RAM1.INIT_3C=256'h81a73f80_88050851_08528c08_8c088c05_050c8053_088c08fc_8c08f005_08f0050c;
+defparam bootram.RAM1.INIT_3D=256'h8c08f805_08f8050c_0508308c_388c08f8_08802e8c_8c08fc05_f8050c54_08708c08;
+defparam bootram.RAM1.INIT_3E=256'h88050880_050c8c08_0b8c08fc_fb3d0d80_08028c0c_8c0c048c_54893d0d_0870800c;
+defparam bootram.RAM1.INIT_3F=256'h8c388c08_05088025_0c8c088c_8c08fc05_050c810b_308c0888_08880508_2593388c;
+defparam bootram.RAM2.INIT_00=256'h8c08f805_3f800870_050851ad_528c0888_088c0508_0c81538c_8c088c05_8c050830;
+defparam bootram.RAM2.INIT_01=256'h800c5487_f8050870_050c8c08_308c08f8_08f80508_2e8c388c_fc050880_0c548c08;
+defparam bootram.RAM2.INIT_02=256'h088c0508_f8050c8c_800b8c08_08fc050c_0d810b8c_8c0cfd3d_048c0802_3d0d8c0c;
+defparam bootram.RAM2.INIT_03=256'h088c0508_2499388c_088c0508_38800b8c_08802ea3_8c08fc05_0827ac38_8c088805;
+defparam bootram.RAM2.INIT_04=256'h388c088c_802e80c9_08fc0508_0cc9398c_8c08fc05_fc050810_050c8c08_108c088c;
+defparam bootram.RAM2.INIT_05=256'hf805088c_050c8c08_318c0888_088c0508_8805088c_a1388c08_88050826_05088c08;
+defparam bootram.RAM2.INIT_06=256'h2a8c088c_8c050881_050c8c08_2a8c08fc_fc050881_050c8c08_078c08f8_08fc0508;
+defparam bootram.RAM2.INIT_07=256'h8c08f805_0c518d39_8c08f405_88050870_8f388c08_0508802e_398c0890_050cffaf;
+defparam bootram.RAM2.INIT_08=256'h56528372_78777956_04fc3d0d_3d0d8c0c_08800c85_8c08f405_f4050c51_08708c08;
+defparam bootram.RAM2.INIT_09=256'h72712e09_74335253_a0387433_5271ff2e_b038ff12_5170802e_74078306_278c3874;
+defparam bootram.RAM2.INIT_0A=256'h04747454_0c863d0d_38800b80_098106e2_5571ff2e_ff145455_81158115_8106bd38;
+defparam bootram.RAM2.INIT_0B=256'h55ffaf39_38707355_718326e9_14545451_118414fc_068f3884_082e0981_51700873;
+defparam bootram.RAM2.INIT_0C=256'h83065170_38727507_8f72278c_55555555_7670797b_04fc3d0d_0c863d0d_72713180;
+defparam bootram.RAM2.INIT_0D=256'hff2e0981_ff125271_81055634_54337470_72708105_ff2e9838_ff125271_802ea738;
+defparam bootram.RAM2.INIT_0E=256'h54087170_72708405_8405530c_54087170_72708405_0d047451_800c863d_06ea3874;
+defparam bootram.RAM2.INIT_0F=256'hf0125271_8405530c_54087170_72708405_8405530c_54087170_72708405_8405530c;
+defparam bootram.RAM2.INIT_10=256'h387054ff_718326ed_0cfc1252_70840553_05540871_38727084_83722795_8f26c938;
+defparam bootram.RAM2.INIT_11=256'ha4528151_e3c63fae_0ce4a83f_3873b5cc_72812e98_84085454_0d800bae_8339fd3d;
+defparam bootram.RAM2.INIT_12=256'h51843f00_a53f8008_528151e6_af3faea4_e4913fe3_72b5cc0c_08519b3f_e6bc3f80;
+defparam bootram.RAM2.INIT_13=256'hff058171_18841908_d9388188_77802e80_085a545a_0882c811_0d7baea8_ff39f73d;
+defparam bootram.RAM2.INIT_14=256'h77065372_81801908_88055656_822b7811_24b53873_e9388074_80742480_2b595559;
+defparam bootram.RAM2.INIT_15=256'h57547380_812c5a57_17fc1779_2dff14fc_74085372_53537951_78167008_802eb538;
+defparam bootram.RAM2.INIT_16=256'h2dff14fc_74085372_51f8c03f_08a53879_0853bc13_ad38aea8_085877ff_25d63877;
+defparam bootram.RAM2.INIT_17=256'h53722d79_51bc1308_ff943972_d2398057_25ffa938_57547380_812c5a57_17fc1779;
+defparam bootram.RAM2.INIT_18=256'h5270ff2e_12700852_38702dfc_70ff2e91_70085252_ac0bfc05_ff3d0db5_51f8943f;
+defparam bootram.RAM2.INIT_19=256'h523a206d_4552524f_4f4b0000_00000040_3f040000_0404e398_38833d0d_098106f1;
+defparam bootram.RAM2.INIT_1A=256'h49484558_20696e20_4261636b_65642120_7475726e_65207265_696d6167_61696e20;
+defparam bootram.RAM2.INIT_1B=256'h6f616465_6f6f746c_322b2062_55535250_4e4f4b00_64652e00_64206d6f_206c6f61;
+defparam bootram.RAM2.INIT_1C=256'h53746172_6e0a0000_6974696f_55206564_61205a50_756c7472_70657220_72207375;
+defparam bootram.RAM2.INIT_1D=256'h4552524f_2e000000_6d6f6465_61666520_696e2073_50322b20_20555352_74696e67;
+defparam bootram.RAM2.INIT_1E=256'h20546869_72616d21_70726f67_61696e20_6f6d206d_6e206672_65747572_523a2072;
+defparam bootram.RAM2.INIT_1F=256'h523a206e_4552524f_6e210000_61707065_65722068_206e6576_6f756c64_73207368;
+defparam bootram.RAM2.INIT_20=256'h626c652e_61696c61_65206176_696d6167_61726520_69726d77_66652066_6f207361;
+defparam bootram.RAM2.INIT_21=256'h6c6f6164_20746f20_66726565_65656c20_6b2e2046_62726963_6d206120_20492061;
+defparam bootram.RAM2.INIT_22=256'h2076616c_20666f72_6b696e67_43686563_2e000000_2052414d_5820746f_20494845;
+defparam bootram.RAM2.INIT_23=256'h56616c69_2e2e2e00_6d616765_47412069_6e204650_6374696f_726f6475_69642070;
+defparam bootram.RAM2.INIT_24=256'h642e2041_666f756e_61676520_4120696d_20465047_74696f6e_6f647563_64207072;
+defparam bootram.RAM2.INIT_25=256'h2070726f_616c6964_4e6f2076_742e0000_20626f6f_6720746f_7074696e_7474656d;
+defparam bootram.RAM2.INIT_26=256'h74656d70_2e0a4174_6f756e64_67652066_20696d61_46504741_696f6e20_64756374;
+defparam bootram.RAM2.INIT_27=256'h77617265_6669726d_696f6e20_64756374_2070726f_6c6f6164_20746f20_74696e67;
+defparam bootram.RAM2.INIT_28=256'h6520666f_6d776172_20666972_74696f6e_6f647563_64207072_56616c69_2e2e2e00;
+defparam bootram.RAM2.INIT_29=256'h64696e67_206c6f61_73686564_46696e69_2e2e2e00_64696e67_204c6f61_756e642e;
+defparam bootram.RAM2.INIT_2A=256'h65747572_523a2052_4552524f_2e000000_6d616765_6e672069_61727469_2e205374;
+defparam bootram.RAM2.INIT_2B=256'h6f756c64_73207368_20546869_72616d21_70726f67_61696e20_6f6d206d_6e206672;
+defparam bootram.RAM2.INIT_2C=256'h64756374_2070726f_616c6964_4e6f2076_6e210000_61707065_65722068_206e6576;
+defparam bootram.RAM2.INIT_2D=256'h61666520_6e672073_54727969_6e642e20_20666f75_77617265_6669726d_696f6e20;
+defparam bootram.RAM2.INIT_2E=256'h00202020_0b0b0b0b_01b200d9_05160364_14580a2c_2e2e2e00_77617265_6669726d;
+defparam bootram.RAM2.INIT_2F=256'h20881010_20202020_20202020_20202020_20202020_28282820_20202828_20202020;
+defparam bootram.RAM2.INIT_30=256'h10104141_10101010_04040410_04040404_10040404_10101010_10101010_10101010;
+defparam bootram.RAM2.INIT_31=256'h10104242_10101010_01010101_01010101_01010101_01010101_01010101_41414141;
+defparam bootram.RAM2.INIT_32=256'h20000000_10101010_02020202_02020202_02020202_02020202_02020202_42424242;
+defparam bootram.RAM2.INIT_33=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_34=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_35=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_36=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_37=256'hffffff00_ffff00ff_ff00ffff_00ffffff_43000000_65000000_792e6578_64756d6d;
+defparam bootram.RAM2.INIT_38=256'h0018000f_ffff0031_05050400_01010100_00001ab4_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_39=256'h00000000_00001a4c_000019f0_00001994_00000000_0000172c_000016e0_000b0000;
+defparam bootram.RAM2.INIT_3A=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_3B=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_000016ec;
+defparam bootram.RAM2.INIT_3C=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_3D=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_3E=256'h1234e66d_330eabcd_00000001_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM2.INIT_3F=256'h00000000_00000000_00000000_00000000_00000000_00000000_000b0000_deec0005;
+defparam bootram.RAM3.INIT_00=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_01=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_02=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_03=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_04=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_05=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_06=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_07=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_08=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_09=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_0A=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_0B=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_0C=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_0D=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_0E=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_0F=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_10=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_11=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_12=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_13=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_14=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_15=256'h00000000_00000000_00000000_ffffffff_00000000_ffffffff_00000000_00000000;
+defparam bootram.RAM3.INIT_16=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_17=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_18=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_19=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_1A=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_1B=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_1C=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_1D=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_1E=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_1F=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_20=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_21=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_22=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_23=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_24=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_25=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_26=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
@@ -233,13 +233,24 @@ defparam bootram.RAM3.INIT_27=256'h00000000_00000000_00000000_00000000_00000000_
defparam bootram.RAM3.INIT_28=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_29=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_2A=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
-defparam bootram.RAM3.INIT_2B=256'h28282020_20282828_20202020_20202020_00000000_00000000_00000000_00000000;
-defparam bootram.RAM3.INIT_2C=256'h10101010_10101010_10101010_88101010_20202020_20202020_20202020_20202020;
-defparam bootram.RAM3.INIT_2D=256'h01010101_01010101_41414101_10414141_10101010_04041010_04040404_04040404;
-defparam bootram.RAM3.INIT_2E=256'h02020202_02020202_42424202_10424242_10101010_01010110_01010101_01010101;
-defparam bootram.RAM3.INIT_2F=256'h00000000_00000000_00000000_00000000_10101020_02020210_02020202_02020202;
+defparam bootram.RAM3.INIT_2B=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_2C=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_2D=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_2E=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_2F=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_30=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_31=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
defparam bootram.RAM3.INIT_32=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
-defparam bootram.RAM3.INIT_33=256'h01010100_00001948_00000000_00000000_00000000_00000000_00000000_00000000;
-defparam bootram.RAM3.INIT_34=256'h00000000_00000000_00000000_00000000_00000000_00000000_00001d70_ffffffff;
+defparam bootram.RAM3.INIT_33=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_34=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_35=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_36=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_37=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_38=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_39=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_3A=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_3B=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_3C=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_3D=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_3E=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
+defparam bootram.RAM3.INIT_3F=256'h00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000;
diff --git a/fpga/usrp2/top/u2plus/u2plus_core.v b/fpga/usrp2/top/u2plus/u2plus_core.v
index 4e0b190ef..3edb539f7 100644
--- a/fpga/usrp2/top/u2plus/u2plus_core.v
+++ b/fpga/usrp2/top/u2plus/u2plus_core.v
@@ -131,7 +131,7 @@ module u2plus_core
output spiflash_cs, output spiflash_clk, input spiflash_miso, output spiflash_mosi
);
- localparam SR_BUF_POOL = 64; // Uses 1 reg
+ localparam SR_BUF_POOL = 64; // router
localparam SR_UDP_SM = 96; // 64 regs
localparam SR_RX_DSP = 160; // 16
localparam SR_RX_CTRL = 176; // 16
@@ -153,9 +153,9 @@ module u2plus_core
wire [31:0] set_data, set_data_dsp;
wire set_stb, set_stb_dsp;
- wire wb_rst, dsp_rst;
+ reg wb_rst; wire dsp_rst;
- wire [31:0] status, status_b0, status_b1, status_b2, status_b3, status_b4, status_b5, status_b6, status_b7;
+ wire [31:0] status;
wire bus_error, spi_int, i2c_int, pps_int, onetime_int, periodic_int, buffer_int;
wire proc_int, overrun, underrun;
wire [3:0] uart_tx_int, uart_rx_int;
@@ -173,7 +173,7 @@ module u2plus_core
wire serdes_link_up;
wire epoch;
wire [31:0] irq;
- wire [63:0] vita_time;
+ wire [63:0] vita_time, vita_time_pps;
wire run_rx, run_tx;
// ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -197,21 +197,21 @@ module u2plus_core
wb_1master #(.decode_w(8),
.s0_addr(8'b0000_0000),.s0_mask(8'b1110_0000), // 0-8K, Boot RAM
- .s1_addr(8'b0100_0000),.s1_mask(8'b1100_0000), // 16K-32K, Buffer Pool
- .s2_addr(8'b0011_0000),.s2_mask(8'b1111_1111), // SPI
- .s3_addr(8'b0011_0001),.s3_mask(8'b1111_1111), // I2C
- .s4_addr(8'b0011_0010),.s4_mask(8'b1111_1111), // GPIO
- .s5_addr(8'b0011_0011),.s5_mask(8'b1111_1111), // Readback
- .s6_addr(8'b0011_0100),.s6_mask(8'b1111_1111), // Ethernet MAC
- .s7_addr(8'b0010_0000),.s7_mask(8'b1111_0000), // 8-12K, Settings Bus (only uses 1K)
- .s8_addr(8'b0011_0101),.s8_mask(8'b1111_1111), // PIC
- .s9_addr(8'b0011_0110),.s9_mask(8'b1111_1111), // Unused
- .sa_addr(8'b0011_0111),.sa_mask(8'b1111_1111), // UART
- .sb_addr(8'b0011_1000),.sb_mask(8'b1111_1111), // ATR
- .sc_addr(8'b0011_1001),.sc_mask(8'b1111_1111), // Unused
- .sd_addr(8'b0011_1010),.sd_mask(8'b1111_1111), // ICAP
- .se_addr(8'b0011_1011),.se_mask(8'b1111_1111), // SPI Flash
- .sf_addr(8'b1000_0000),.sf_mask(8'b1000_0000), // 32-64K, Main RAM
+ .s1_addr(8'b0100_0000),.s1_mask(8'b1111_0000), // 16K-20K, Buffer Pool
+ .s2_addr(8'b0110_0000),.s2_mask(8'b1111_1111), // SPI
+ .s3_addr(8'b0110_0001),.s3_mask(8'b1111_1111), // I2C
+ .s4_addr(8'b0110_0010),.s4_mask(8'b1111_1111), // GPIO
+ .s5_addr(8'b0110_0011),.s5_mask(8'b1111_1111), // Readback
+ .s6_addr(8'b0110_0100),.s6_mask(8'b1111_1111), // Ethernet MAC
+ .s7_addr(8'b0101_0000),.s7_mask(8'b1111_0000), // 20K-24K, Settings Bus (only uses 1K)
+ .s8_addr(8'b0110_0101),.s8_mask(8'b1111_1111), // PIC
+ .s9_addr(8'b0110_0110),.s9_mask(8'b1111_1111), // Unused
+ .sa_addr(8'b0110_0111),.sa_mask(8'b1111_1111), // UART
+ .sb_addr(8'b0110_1000),.sb_mask(8'b1111_1111), // ATR
+ .sc_addr(8'b0110_1001),.sc_mask(8'b1111_1111), // Unused
+ .sd_addr(8'b0110_1010),.sd_mask(8'b1111_1111), // ICAP
+ .se_addr(8'b0110_1011),.se_mask(8'b1111_1111), // SPI Flash
+ .sf_addr(8'b1000_0000),.sf_mask(8'b1100_0000), // 32-48K, Main RAM
.dw(dw),.aw(aw),.sw(sw)) wb_1master
(.clk_i(wb_clk),.rst_i(wb_rst),
.m0_dat_o(m0_dat_o),.m0_ack_o(m0_ack),.m0_err_o(m0_err),.m0_rty_o(m0_rty),.m0_dat_i(m0_dat_i),
@@ -251,35 +251,75 @@ module u2plus_core
//////////////////////////////////////////////////////////////////////////////////////////
// Reset Controller
-
+
+ reg cpu_bldr_ctrl_state;
+ localparam CPU_BLDR_CTRL_WAIT = 0;
+ localparam CPU_BLDR_CTRL_DONE = 1;
+
+ wire bldr_done;
+ wire por_rst;
+ wire [aw-1:0] cpu_adr;
+ wire [aw-1:0] cpu_sp_init = (cpu_bldr_ctrl_state == CPU_BLDR_CTRL_DONE)?
+ 16'hfff8 : //top of 8K boot ram re-purposed at 56K
+ 16'h1ff8 ; //top of 8K boot ram
+
+ //When the main program runs, it will try to access system ram at 0.
+ //This logic re-maps the cpu address to force select the system ram.
+ assign m0_adr =
+ (cpu_bldr_ctrl_state == CPU_BLDR_CTRL_WAIT)? cpu_adr : ( //in bootloader
+ (cpu_adr[15:14] == 2'b00)? {2'b10, cpu_adr[13:0]} : ( //map 0-16 to 32-48 (main ram)
+ (cpu_adr[15:13] == 3'b111)? {3'b000, cpu_adr[12:0]} : ( //map 56-64 to 0-8 (boot ram)
+ cpu_adr))); //otherwise
+
+ system_control sysctrl (
+ .wb_clk_i(wb_clk), .wb_rst_o(por_rst), .ram_loader_done_i(1'b1)
+ );
+
+ always @(posedge wb_clk)
+ if(por_rst) begin
+ cpu_bldr_ctrl_state <= CPU_BLDR_CTRL_WAIT;
+ wb_rst <= 1'b1;
+ end
+ else begin
+ case(cpu_bldr_ctrl_state)
+
+ CPU_BLDR_CTRL_WAIT: begin
+ wb_rst <= 1'b0;
+ if (bldr_done == 1'b1) begin //set by the bootloader
+ cpu_bldr_ctrl_state <= CPU_BLDR_CTRL_DONE;
+ wb_rst <= 1'b1;
+ end
+ end
+
+ CPU_BLDR_CTRL_DONE: begin //stay here forever
+ wb_rst <= 1'b0;
+ end
+
+ endcase //cpu_bldr_ctrl_state
+ end
+
// /////////////////////////////////////////////////////////////////////////
// Processor
- wire [31:0] if_dat;
- wire [15:0] if_adr;
-
- aeMB_core_BE #(.ISIZ(16),.DSIZ(16),.MUL(0),.BSF(1))
- aeMB (.sys_clk_i(wb_clk), .sys_rst_i(wb_rst),
- // Instruction Wishbone bus to I-RAM
- .if_adr(if_adr),
- .if_dat(if_dat),
+
+ assign bus_error = m0_err | m0_rty;
+
+ wire [63:0] zpu_status;
+ zpu_wb_top #(.dat_w(dw), .adr_w(aw), .sel_w(sw))
+ zpu_top0 (.clk(wb_clk), .rst(wb_rst), .enb(~wb_rst),
// Data Wishbone bus to system bus fabric
- .dwb_we_o(m0_we),.dwb_stb_o(m0_stb),.dwb_dat_o(m0_dat_i),.dwb_adr_o(m0_adr),
- .dwb_dat_i(m0_dat_o),.dwb_ack_i(m0_ack),.dwb_sel_o(m0_sel),.dwb_cyc_o(m0_cyc),
+ .we_o(m0_we),.stb_o(m0_stb),.dat_o(m0_dat_i),.adr_o(cpu_adr),
+ .dat_i(m0_dat_o),.ack_i(m0_ack),.sel_o(m0_sel),.cyc_o(m0_cyc),
// Interrupts and exceptions
- .sys_int_i(proc_int),.sys_exc_i(bus_error) );
-
- assign bus_error = m0_err | m0_rty;
-
+ .stack_start(cpu_sp_init), .zpu_status(zpu_status), .interrupt(proc_int & 1'b0));
+
+
// /////////////////////////////////////////////////////////////////////////
// Dual Ported Boot RAM -- D-Port is Slave #0 on main Wishbone
// Dual Ported Main RAM -- D-Port is Slave #F on main Wishbone
// I-port connects directly to processor
- wire [31:0] if_dat_boot, if_dat_main;
- assign if_dat = if_adr[15] ? if_dat_main : if_dat_boot;
-
bootram bootram(.clk(wb_clk), .reset(wb_rst),
- .if_adr(if_adr[12:0]), .if_data(if_dat_boot),
+ .if_adr(13'b0), .if_data(),
.dwb_adr_i(s0_adr[12:0]), .dwb_dat_i(s0_dat_o), .dwb_dat_o(s0_dat_i),
.dwb_we_i(s0_we), .dwb_ack_o(s0_ack), .dwb_stb_i(s0_stb), .dwb_sel_i(s0_sel));
@@ -289,10 +329,10 @@ module u2plus_core
`include "bootloader.rmi"
- ram_harvard2 #(.AWIDTH(15),.RAM_SIZE(32768))
+ ram_harvard2 #(.AWIDTH(14),.RAM_SIZE(16384))
sys_ram(.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),
- .if_adr(if_adr[14:0]), .if_data(if_dat_main),
- .dwb_adr_i(sf_adr[14:0]), .dwb_dat_i(sf_dat_o), .dwb_dat_o(sf_dat_i),
+ .if_adr(14'b0), .if_data(),
+ .dwb_adr_i(sf_adr[13:0]), .dwb_dat_i(sf_dat_o), .dwb_dat_o(sf_dat_i),
.dwb_we_i(sf_we), .dwb_ack_o(sf_ack), .dwb_stb_i(sf_stb), .dwb_sel_i(sf_sel));
// /////////////////////////////////////////////////////////////////////////
@@ -310,34 +350,33 @@ module u2plus_core
wire wr3_ready_i, wr3_ready_o;
wire [3:0] wr0_flags, wr1_flags, wr2_flags, wr3_flags;
wire [31:0] wr0_dat, wr1_dat, wr2_dat, wr3_dat;
-
- buffer_pool #(.BUF_SIZE(9), .SET_ADDR(SR_BUF_POOL)) buffer_pool
+
+ wire [35:0] tx_err_data;
+ wire tx_err_src_rdy, tx_err_dst_rdy;
+
+ wire [31:0] router_debug;
+
+ packet_router #(.BUF_SIZE(9), .UDP_BASE(SR_UDP_SM), .CTRL_BASE(SR_BUF_POOL)) packet_router
(.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),
- .wb_we_i(s1_we),.wb_stb_i(s1_stb),.wb_adr_i(s1_adr),.wb_dat_i(s1_dat_o),
+ .wb_we_i(s1_we),.wb_stb_i(s1_stb),.wb_adr_i(s1_adr),.wb_dat_i(s1_dat_o),
.wb_dat_o(s1_dat_i),.wb_ack_o(s1_ack),.wb_err_o(),.wb_rty_o(),
-
- .stream_clk(dsp_clk), .stream_rst(dsp_rst),
+
.set_stb(set_stb_dsp), .set_addr(set_addr_dsp), .set_data(set_data_dsp),
- .status(status),.sys_int_o(buffer_int),
-
- .s0(status_b0),.s1(status_b1),.s2(status_b2),.s3(status_b3),
- .s4(status_b4),.s5(status_b5),.s6(status_b6),.s7(status_b7),
-
- // Write Interfaces
- .wr0_data_i(wr0_dat), .wr0_flags_i(wr0_flags), .wr0_ready_i(wr0_ready_i), .wr0_ready_o(wr0_ready_o),
- .wr1_data_i(wr1_dat), .wr1_flags_i(wr1_flags), .wr1_ready_i(wr1_ready_i), .wr1_ready_o(wr1_ready_o),
- .wr2_data_i(wr2_dat), .wr2_flags_i(wr2_flags), .wr2_ready_i(wr2_ready_i), .wr2_ready_o(wr2_ready_o),
- .wr3_data_i(wr3_dat), .wr3_flags_i(wr3_flags), .wr3_ready_i(wr3_ready_i), .wr3_ready_o(wr3_ready_o),
- // Read Interfaces
- .rd0_data_o(rd0_dat), .rd0_flags_o(rd0_flags), .rd0_ready_i(rd0_ready_i), .rd0_ready_o(rd0_ready_o),
- .rd1_data_o(rd1_dat), .rd1_flags_o(rd1_flags), .rd1_ready_i(rd1_ready_i), .rd1_ready_o(rd1_ready_o),
- .rd2_data_o(rd2_dat), .rd2_flags_o(rd2_flags), .rd2_ready_i(rd2_ready_i), .rd2_ready_o(rd2_ready_o),
- .rd3_data_o(rd3_dat), .rd3_flags_o(rd3_flags), .rd3_ready_i(rd3_ready_i), .rd3_ready_o(rd3_ready_o)
+
+ .stream_clk(dsp_clk), .stream_rst(dsp_rst), .stream_clr(1'b0),
+
+ .status(status), .sys_int_o(buffer_int), .debug(router_debug),
+
+ .ser_inp_data({wr0_flags, wr0_dat}), .ser_inp_valid(wr0_ready_i), .ser_inp_ready(wr0_ready_o),
+ .dsp_inp_data({wr1_flags, wr1_dat}), .dsp_inp_valid(wr1_ready_i), .dsp_inp_ready(wr1_ready_o),
+ .eth_inp_data({wr2_flags, wr2_dat}), .eth_inp_valid(wr2_ready_i), .eth_inp_ready(wr2_ready_o),
+ .err_inp_data(tx_err_data), .err_inp_ready(tx_err_dst_rdy), .err_inp_valid(tx_err_src_rdy),
+
+ .ser_out_data({rd0_flags, rd0_dat}), .ser_out_valid(rd0_ready_o), .ser_out_ready(rd0_ready_i),
+ .dsp_out_data({rd1_flags, rd1_dat}), .dsp_out_valid(rd1_ready_o), .dsp_out_ready(rd1_ready_i),
+ .eth_out_data({rd2_flags, rd2_dat}), .eth_out_valid(rd2_ready_o), .eth_out_ready(rd2_ready_i)
);
- wire [31:0] status_enc;
- priority_enc priority_enc (.in({16'b0,status[15:0]}), .out(status_enc));
-
// /////////////////////////////////////////////////////////////////////////
// SPI -- Slave #2
spi_top shared_spi
@@ -370,31 +409,25 @@ module u2plus_core
// /////////////////////////////////////////////////////////////////////////
// Buffer Pool Status -- Slave #5
- reg [31:0] cycle_count;
- always @(posedge wb_clk)
- if(wb_rst)
- cycle_count <= 0;
- else
- cycle_count <= cycle_count + 1;
-
//compatibility number -> increment when the fpga has been sufficiently altered
- localparam compat_num = 32'd3;
+ localparam compat_num = 32'd4;
wb_readback_mux buff_pool_status
(.wb_clk_i(wb_clk), .wb_rst_i(wb_rst), .wb_stb_i(s5_stb),
.wb_adr_i(s5_adr), .wb_dat_o(s5_dat_i), .wb_ack_o(s5_ack),
- .word00(status_b0),.word01(status_b1),.word02(status_b2),.word03(status_b3),
- .word04(status_b4),.word05(status_b5),.word06(status_b6),.word07(status_b7),
+ .word00(32'b0),.word01(32'b0),.word02(32'b0),.word03(32'b0),
+ .word04(32'b0),.word05(32'b0),.word06(32'b0),.word07(32'b0),
.word08(status),.word09({sim_mode,27'b0,clock_divider[3:0]}),.word10(vita_time[63:32]),
- .word11(vita_time[31:0]),.word12(compat_num),.word13(irq),.word14(status_enc),.word15(cycle_count)
+ .word11(vita_time[31:0]),.word12(compat_num),.word13(irq),
+ .word14(vita_time_pps[63:32]),.word15(vita_time_pps[31:0])
);
// /////////////////////////////////////////////////////////////////////////
// Ethernet MAC Slave #6
wire [18:0] rx_f19_data, tx_f19_data;
- wire rx_f19_src_rdy, rx_f19_dst_rdy, rx_f36_src_rdy, rx_f36_dst_rdy;
+ wire rx_f19_src_rdy, rx_f19_dst_rdy, tx_f19_src_rdy, tx_f19_dst_rdy;
simple_gemac_wrapper19 #(.RXFIFOSIZE(11), .TXFIFOSIZE(6)) simple_gemac_wrapper19
(.clk125(clk_to_mac), .reset(wb_rst),
@@ -410,36 +443,38 @@ module u2plus_core
.mdio(MDIO), .mdc(MDC),
.debug(debug_mac));
- wire [35:0] udp_tx_data, udp_rx_data;
- wire udp_tx_src_rdy, udp_tx_dst_rdy, udp_rx_src_rdy, udp_rx_dst_rdy;
-
- udp_wrapper #(.BASE(SR_UDP_SM)) udp_wrapper
+ wire [35:0] rx_f36_data, tx_f36_data;
+ wire rx_f36_src_rdy, rx_f36_dst_rdy, tx_f36_src_rdy, tx_f36_dst_rdy;
+
+ wire [18:0] _rx_f19_data;
+ wire _rx_f19_src_rdy, _rx_f19_dst_rdy;
+
+ //mac rx to eth input...
+ fifo19_rxrealign fifo19_rxrealign
(.clk(dsp_clk), .reset(dsp_rst), .clear(0),
- .set_stb(set_stb_dsp), .set_addr(set_addr_dsp), .set_data(set_data_dsp),
- .rx_f19_data(rx_f19_data), .rx_f19_src_rdy_i(rx_f19_src_rdy), .rx_f19_dst_rdy_o(rx_f19_dst_rdy),
- .tx_f19_data(tx_f19_data), .tx_f19_src_rdy_o(tx_f19_src_rdy), .tx_f19_dst_rdy_i(tx_f19_dst_rdy),
- .rx_f36_data(udp_rx_data), .rx_f36_src_rdy_o(udp_rx_src_rdy), .rx_f36_dst_rdy_i(udp_rx_dst_rdy),
- .tx_f36_data(udp_tx_data), .tx_f36_src_rdy_i(udp_tx_src_rdy), .tx_f36_dst_rdy_o(udp_tx_dst_rdy),
- .debug(debug_udp) );
+ .datain(rx_f19_data), .src_rdy_i(rx_f19_src_rdy), .dst_rdy_o(rx_f19_dst_rdy),
+ .dataout(_rx_f19_data), .src_rdy_o(_rx_f19_src_rdy), .dst_rdy_i(_rx_f19_dst_rdy) );
- wire [35:0] tx_err_data, udp1_tx_data;
- wire tx_err_src_rdy, tx_err_dst_rdy, udp1_tx_src_rdy, udp1_tx_dst_rdy;
-
- fifo_cascade #(.WIDTH(36), .SIZE(ETH_TX_FIFOSIZE)) tx_eth_fifo
+ fifo19_to_fifo36 eth_inp_fifo19_to_fifo36
(.clk(dsp_clk), .reset(dsp_rst), .clear(0),
- .datain({rd2_flags,rd2_dat}), .src_rdy_i(rd2_ready_o), .dst_rdy_o(rd2_ready_i),
- .dataout(udp1_tx_data), .src_rdy_o(udp1_tx_src_rdy), .dst_rdy_i(udp1_tx_dst_rdy));
+ .f19_datain(_rx_f19_data), .f19_src_rdy_i(_rx_f19_src_rdy), .f19_dst_rdy_o(_rx_f19_dst_rdy),
+ .f36_dataout(rx_f36_data), .f36_src_rdy_o(rx_f36_src_rdy), .f36_dst_rdy_i(rx_f36_dst_rdy) );
- fifo36_mux #(.prio(0)) mux_err_stream
- (.clk(dsp_clk), .reset(dsp_reset), .clear(0),
- .data0_i(udp1_tx_data), .src0_rdy_i(udp1_tx_src_rdy), .dst0_rdy_o(udp1_tx_dst_rdy),
- .data1_i(tx_err_data), .src1_rdy_i(tx_err_src_rdy), .dst1_rdy_o(tx_err_dst_rdy),
- .data_o(udp_tx_data), .src_rdy_o(udp_tx_src_rdy), .dst_rdy_i(udp_tx_dst_rdy));
-
fifo_cascade #(.WIDTH(36), .SIZE(ETH_RX_FIFOSIZE)) rx_eth_fifo
(.clk(dsp_clk), .reset(dsp_rst), .clear(0),
- .datain(udp_rx_data), .src_rdy_i(udp_rx_src_rdy), .dst_rdy_o(udp_rx_dst_rdy),
+ .datain(rx_f36_data), .src_rdy_i(rx_f36_src_rdy), .dst_rdy_o(rx_f36_dst_rdy),
.dataout({wr2_flags,wr2_dat}), .src_rdy_o(wr2_ready_i), .dst_rdy_i(wr2_ready_o));
+
+ //eth output to mac tx...
+ fifo_cascade #(.WIDTH(36), .SIZE(ETH_TX_FIFOSIZE)) tx_eth_fifo
+ (.clk(dsp_clk), .reset(dsp_rst), .clear(0),
+ .datain({rd2_flags,rd2_dat}), .src_rdy_i(rd2_ready_o), .dst_rdy_o(rd2_ready_i),
+ .dataout(tx_f36_data), .src_rdy_o(tx_f36_src_rdy), .dst_rdy_i(tx_f36_dst_rdy));
+
+ fifo36_to_fifo19 eth_out_fifo36_to_fifo19
+ (.clk(dsp_clk), .reset(dsp_rst), .clear(0),
+ .f36_datain(tx_f36_data), .f36_src_rdy_i(tx_f36_src_rdy), .f36_dst_rdy_o(tx_f36_dst_rdy),
+ .f19_dataout(tx_f19_data), .f19_src_rdy_o(tx_f19_src_rdy), .f19_dst_rdy_i(tx_f19_dst_rdy) );
// /////////////////////////////////////////////////////////////////////////
// Settings Bus -- Slave #7
@@ -471,6 +506,8 @@ module u2plus_core
.in(set_data),.out(adc_outs),.changed());
setting_reg #(.my_addr(4),.width(1)) sr_phy (.clk(wb_clk),.rst(wb_rst),.strobe(set_stb),.addr(set_addr),
.in(set_data),.out(phy_reset),.changed());
+ setting_reg #(.my_addr(5),.width(1)) sr_bldr (.clk(wb_clk),.rst(wb_rst),.strobe(set_stb),.addr(set_addr),
+ .in(set_data),.out(bldr_done),.changed());
// /////////////////////////////////////////////////////////////////////////
// LEDS
@@ -555,7 +592,7 @@ module u2plus_core
// ICAP for reprogramming the FPGA, Slave #13 (D)
s3a_icap_wb s3a_icap_wb
- (.clk(wb_clk), .reset(wb_rst), .cyc_i(sd_cyc), .stb_i(sd_stb),
+ (.clk(wb_clk), .reset(wb_rst), .cyc_i(sd_cyc), .stb_i(sd_stb),
.we_i(sd_we), .ack_o(sd_ack), .dat_i(sd_dat_o), .dat_o(sd_dat_i));
// /////////////////////////////////////////////////////////////////////////
@@ -652,7 +689,8 @@ module u2plus_core
vita_tx_chain #(.BASE_CTRL(SR_TX_CTRL), .BASE_DSP(SR_TX_DSP),
.REPORT_ERROR(1), .DO_FLOW_CONTROL(1),
- .PROT_ENG_FLAGS(1), .USE_TRANS_HEADER(1))
+ .PROT_ENG_FLAGS(1), .USE_TRANS_HEADER(1),
+ .DSP_NUMBER(0))
vita_tx_chain
(.clk(dsp_clk), .reset(dsp_rst),
.set_stb(set_stb_dsp),.set_addr(set_addr_dsp),.set_data(set_data_dsp),
@@ -681,10 +719,13 @@ module u2plus_core
// /////////////////////////////////////////////////////////////////////////
// VITA Timing
+ wire [31:0] debug_sync;
+
time_64bit #(.TICKS_PER_SEC(32'd100000000),.BASE(SR_TIME64)) time_64bit
(.clk(dsp_clk), .rst(dsp_rst), .set_stb(set_stb_dsp), .set_addr(set_addr_dsp), .set_data(set_data_dsp),
- .pps(pps_in), .vita_time(vita_time), .pps_int(pps_int),
- .exp_time_in(exp_time_in), .exp_time_out(exp_time_out));
+ .pps(pps_in), .vita_time(vita_time), .vita_time_pps(vita_time_pps), .pps_int(pps_int),
+ .exp_time_in(exp_time_in), .exp_time_out(exp_time_out),
+ .debug(debug_sync));
// /////////////////////////////////////////////////////////////////////////////////////////
// Debug Pins
diff --git a/fpga/usrp2/udp/prot_eng_tx.v b/fpga/usrp2/udp/prot_eng_tx.v
index a18eb73ae..c642842f6 100644
--- a/fpga/usrp2/udp/prot_eng_tx.v
+++ b/fpga/usrp2/udp/prot_eng_tx.v
@@ -7,6 +7,8 @@
// Odd means the last word is half full
// Flags[1:0] is {eop, sop}
// Protocol word format is:
+// 21 UDP Source Port Here
+// 20 UDP Dest Port Here
// 19 Last Header Line
// 18 IP Header Checksum XOR
// 17 IP Length Here
@@ -34,28 +36,40 @@ module prot_eng_tx
assign dst_rdy_o = dst_rdy_i & (do_payload | (state==0) | (state==1) | (state==30));
assign src_rdy_o = src_rdy_i & ~((state==0) | (state==1) | (state==30));
- localparam HDR_WIDTH = 16 + 4; // 16 bits plus flags
+ localparam HDR_WIDTH = 16 + 6; // 16 bits plus flags
localparam HDR_LEN = 32; // Up to 64 bytes of protocol
// Store header values in a small dual-port (distributed) ram
reg [HDR_WIDTH-1:0] header_ram[0:HDR_LEN-1];
wire [HDR_WIDTH-1:0] header_word;
- reg [15:0] chk_precompute;
-
+
+ reg [1:0] port_sel;
+ reg [31:0] per_port_data[0:3];
+ reg [15:0] udp_src_port, udp_dst_port, chk_precompute;
+
+ always @(posedge clk) udp_src_port <= per_port_data[port_sel][31:16];
+ always @(posedge clk) udp_dst_port <= per_port_data[port_sel][15:0];
+
always @(posedge clk)
if(set_stb & ((set_addr & 8'hE0) == BASE))
- begin
- header_ram[set_addr[4:0]] <= set_data;
- if(set_data[18])
- chk_precompute <= set_data[15:0];
- end
+ header_ram[set_addr[4:0]] <= set_data;
+
+ always @(posedge clk)
+ if(set_stb & (set_addr == (BASE + 14)))
+ chk_precompute <= set_data[15:0];
+
+ always @(posedge clk)
+ if(set_stb & ((set_addr & 8'hFC) == (BASE+24)))
+ per_port_data[set_addr[1:0]] <= set_data;
- assign header_word = header_ram[state];
+ wire do_udp_src_port = header_word[21];
+ wire do_udp_dst_port = header_word[20];
+ wire last_hdr_line = header_word[19];
+ wire do_ip_chk = header_word[18];
+ wire do_ip_len = header_word[17];
+ wire do_udp_len = header_word[16];
- wire last_hdr_line = header_word[19];
- wire ip_chk = header_word[18];
- wire ip_len = header_word[17];
- wire udp_len = header_word[16];
+ assign header_word = header_ram[state];
// Protocol State Machine
reg [15:0] length;
@@ -75,6 +89,7 @@ module prot_eng_tx
0 :
begin
fast_path <= datain[0];
+ port_sel <= datain[2:1];
state <= 1;
end
1 :
@@ -113,15 +128,18 @@ module prot_eng_tx
checksum_reg <= checksum;
always @*
- if(ip_chk)
- //dataout_int <= header_word[15:0] ^ ip_length;
+ if(do_payload)
+ dataout_int <= datain[15:0];
+ else if(do_ip_chk)
dataout_int <= 16'hFFFF ^ checksum_reg;
- else if(ip_len)
+ else if(do_ip_len)
dataout_int <= ip_length;
- else if(udp_len)
+ else if(do_udp_len)
dataout_int <= udp_length;
- else if(do_payload)
- dataout_int <= datain[15:0];
+ else if(do_udp_src_port)
+ dataout_int <= udp_src_port;
+ else if(do_udp_dst_port)
+ dataout_int <= udp_dst_port;
else
dataout_int <= header_word[15:0];
diff --git a/fpga/usrp2/udp/prot_eng_tx_tb.v b/fpga/usrp2/udp/prot_eng_tx_tb.v
index e7ffeb5e1..c8fffe605 100644
--- a/fpga/usrp2/udp/prot_eng_tx_tb.v
+++ b/fpga/usrp2/udp/prot_eng_tx_tb.v
@@ -80,7 +80,7 @@ module prot_eng_tx_tb();
begin
count <= 4;
src_rdy_f36i <= 1;
- f36_data <= 32'h0001_000c;
+ f36_data <= 32'h0003_000c;
f36_sof <= 1;
f36_eof <= 0;
f36_occ <= 0;
@@ -140,16 +140,23 @@ module prot_eng_tx_tb();
@(negedge rst);
@(posedge clk);
WriteSREG(BASE, {12'b0, 4'h0, 16'h0000});
- WriteSREG(BASE+1, {12'b0, 4'h0, 16'h0000});
- WriteSREG(BASE+2, {12'b0, 4'h0, 16'hABCD});
- WriteSREG(BASE+3, {12'b0, 4'h0, 16'h1234});
- WriteSREG(BASE+4, {12'b0, 4'h8, 16'h5678});
- WriteSREG(BASE+5, {12'b0, 4'h0, 16'hABCD});
- WriteSREG(BASE+6, {12'b0, 4'h0, 16'hABCD});
- WriteSREG(BASE+7, {12'b0, 4'h0, 16'hABCD});
- WriteSREG(BASE+8, {12'b0, 4'h0, 16'hABCD});
- WriteSREG(BASE+9, {12'b0, 4'h0, 16'hABCD});
+ WriteSREG(BASE+1, {11'b0, 5'h00, 16'h0000});
+ WriteSREG(BASE+2, {11'b0, 5'h00, 16'hABCD});
+ WriteSREG(BASE+3, {11'b0, 5'h00, 16'h1234});
+ WriteSREG(BASE+4, {11'b0, 5'h00, 16'h5678});
+ WriteSREG(BASE+5, {11'b0, 5'h00, 16'hF00D});
+ WriteSREG(BASE+6, {11'b0, 5'h00, 16'hBEEF});
+ WriteSREG(BASE+7, {11'b0, 5'h10, 16'hDCBA});
+ WriteSREG(BASE+8, {11'b0, 5'h00, 16'h4321});
+ WriteSREG(BASE+9, {11'b0, 5'h04, 16'hABCD});
+ WriteSREG(BASE+10, {11'b0, 5'h08, 16'hABCD});
@(posedge clk);
+
+ WriteSREG(BASE+24, 16'h6666);
+ WriteSREG(BASE+25, 16'h7777);
+ WriteSREG(BASE+26, 16'h8888);
+ WriteSREG(BASE+27, 16'h9999);
+
PutPacketInFIFO36(32'hA0B0C0D0,16);
@(posedge clk);
@(posedge clk);
diff --git a/fpga/usrp2/vrt/gen_context_pkt.v b/fpga/usrp2/vrt/gen_context_pkt.v
index 44bb7b548..cc34cceed 100644
--- a/fpga/usrp2/vrt/gen_context_pkt.v
+++ b/fpga/usrp2/vrt/gen_context_pkt.v
@@ -1,7 +1,8 @@
module gen_context_pkt
- #(parameter PROT_ENG_FLAGS=1)
+ #(parameter PROT_ENG_FLAGS=1,
+ parameter DSP_NUMBER=0)
(input clk, input reset, input clear,
input trigger, output sent,
input [31:0] streamid,
@@ -67,10 +68,10 @@ module gen_context_pkt
endcase // case (ctxt_state)
assign src_rdy_int = ~( (ctxt_state == CTXT_IDLE) | (ctxt_state == CTXT_DONE) );
-
+
always @*
case(ctxt_state)
- CTXT_PROT_ENG : data_int <= { 2'b01, 16'd1, 16'd28 };
+ CTXT_PROT_ENG : data_int <= { 2'b01, 13'b0, DSP_NUMBER[0], 1'b1, 1'b1, 16'd28 }; // UDP port 1 or 3
CTXT_HEADER : data_int <= { 1'b0, (PROT_ENG_FLAGS ? 1'b0 : 1'b1), 12'b010100001101, seqno, 16'd7 };
CTXT_STREAMID : data_int <= { 2'b00, streamid };
CTXT_SECS : data_int <= { 2'b00, err_time[63:32] };
diff --git a/fpga/usrp2/vrt/vita_tx_chain.v b/fpga/usrp2/vrt/vita_tx_chain.v
index 2ec78189b..6f567668d 100644
--- a/fpga/usrp2/vrt/vita_tx_chain.v
+++ b/fpga/usrp2/vrt/vita_tx_chain.v
@@ -5,7 +5,8 @@ module vita_tx_chain
parameter REPORT_ERROR=0,
parameter DO_FLOW_CONTROL=0,
parameter PROT_ENG_FLAGS=0,
- parameter USE_TRANS_HEADER=0)
+ parameter USE_TRANS_HEADER=0,
+ parameter DSP_NUMBER=0)
(input clk, input reset,
input set_stb, input [7:0] set_addr, input [31:0] set_data,
input [63:0] vita_time,
@@ -71,7 +72,7 @@ module vita_tx_chain
wire [35:0] flow_data, err_data_int;
wire flow_src_rdy, flow_dst_rdy, err_src_rdy_int, err_dst_rdy_int;
- gen_context_pkt #(.PROT_ENG_FLAGS(PROT_ENG_FLAGS)) gen_flow_pkt
+ gen_context_pkt #(.PROT_ENG_FLAGS(PROT_ENG_FLAGS),.DSP_NUMBER(DSP_NUMBER)) gen_flow_pkt
(.clk(clk), .reset(reset), .clear(clear_vita),
.trigger(trigger & (DO_FLOW_CONTROL==1)), .sent(),
.streamid(streamid), .vita_time(vita_time), .message(32'd0),
@@ -82,7 +83,7 @@ module vita_tx_chain
.set_stb(set_stb),.set_addr(set_addr),.set_data(set_data),
.packet_consumed(packet_consumed), .trigger(trigger));
- gen_context_pkt #(.PROT_ENG_FLAGS(PROT_ENG_FLAGS)) gen_tx_err_pkt
+ gen_context_pkt #(.PROT_ENG_FLAGS(PROT_ENG_FLAGS),.DSP_NUMBER(DSP_NUMBER)) gen_tx_err_pkt
(.clk(clk), .reset(reset), .clear(clear_vita),
.trigger((error|ack) & (REPORT_ERROR==1)), .sent(),
.streamid(streamid), .vita_time(vita_time), .message(message),
diff --git a/fpga/usrp2/vrt/vita_tx_control.v b/fpga/usrp2/vrt/vita_tx_control.v
index ab6da8bd0..e966d987c 100644
--- a/fpga/usrp2/vrt/vita_tx_control.v
+++ b/fpga/usrp2/vrt/vita_tx_control.v
@@ -17,14 +17,12 @@ module vita_tx_control
// To DSP Core
output [WIDTH-1:0] sample,
- output run,
+ output reg run,
input strobe,
output [31:0] debug
);
- assign sample = sample_fifo_i[5+64+16+WIDTH-1:5+64+16];
-
wire [63:0] send_time = sample_fifo_i[63:0];
wire [15:0] seqnum = sample_fifo_i[79:64];
wire eop = sample_fifo_i[80];
@@ -169,11 +167,39 @@ module vita_tx_control
send_error <= 0;
endcase // case (ibs_state)
+
assign sample_fifo_dst_rdy_o = (ibs_state == IBS_ERROR) | (strobe & (ibs_state == IBS_RUN)); // FIXME also cleanout
- assign run = (ibs_state == IBS_RUN) | (ibs_state == IBS_CONT_BURST);
+
+ assign sample = (ibs_state == IBS_RUN) ? sample_fifo_i[5+64+16+WIDTH-1:5+64+16] : {WIDTH{1'b0}};
+ //assign run = (ibs_state == IBS_RUN) | (ibs_state == IBS_CONT_BURST);
assign error = send_error;
assign ack = send_ack;
+ localparam MAX_IDLE = 1000000;
+ // approx 10 ms timeout with a 100 MHz clock, but burning samples will slow that down
+ reg [19:0] countdown;
+
+ always @(posedge clk)
+ if(reset | clear)
+ begin
+ run <= 0;
+ countdown <= 0;
+ end
+ else
+ if (ibs_state == IBS_RUN)
+ if(eob & eop & strobe & sample_fifo_src_rdy_i)
+ run <= 0;
+ else
+ begin
+ run <= 1;
+ countdown <= MAX_IDLE;
+ end
+ else
+ if (countdown == 0)
+ run <= 0;
+ else
+ countdown <= countdown - 1;
+
always @(posedge clk)
if(reset | clear)
packet_consumed <= 0;
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt
index f59cda23f..d0c576ee5 100644
--- a/host/CMakeLists.txt
+++ b/host/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -74,6 +74,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/msvc)
ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501) #minimum version required is windows xp
ADD_DEFINITIONS(-DNOMINMAX) #disables stupidity and enables std::min and std::max
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) #avoid warnings from boost::split
@@ -89,7 +90,7 @@ IF(UNIX AND EXISTS "/usr/lib64")
ENDIF(UNIX AND EXISTS "/usr/lib64")
SET(Boost_ADDITIONAL_VERSIONS "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44")
-FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS
+FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} COMPONENTS
date_time
filesystem
program_options
@@ -103,6 +104,23 @@ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
########################################################################
+# Check Python Modules
+########################################################################
+INCLUDE(UHDPython)
+
+PYTHON_CHECK_MODULE(
+ "Python version 2.6 or greater"
+ "platform" "platform.python_version() >= '2.6'"
+ HAVE_PYTHON_PLAT_MIN_VERSION
+)
+
+PYTHON_CHECK_MODULE(
+ "Cheetah templates 2.0.0 or greater"
+ "Cheetah" "Cheetah.Version >= '2.0.0'"
+ HAVE_PYTHON_MODULE_CHEETAH
+)
+
+########################################################################
# Create Uninstall Target
########################################################################
CONFIGURE_FILE(
@@ -140,7 +158,7 @@ INSTALL(FILES
########################################################################
# Register top level components
########################################################################
-SET(ENABLE_LIBUHD ON) #always enabled
+LIBUHD_REGISTER_COMPONENT("LibUHD" ENABLE_LIBUHD ON "Boost_FOUND;HAVE_PYTHON_PLAT_MIN_VERSION;HAVE_PYTHON_MODULE_CHEETAH" OFF)
LIBUHD_REGISTER_COMPONENT("Examples" ENABLE_EXAMPLES ON "ENABLE_LIBUHD" OFF)
LIBUHD_REGISTER_COMPONENT("Utils" ENABLE_UTILS ON "ENABLE_LIBUHD" OFF)
LIBUHD_REGISTER_COMPONENT("Tests" ENABLE_TESTS ON "ENABLE_LIBUHD" OFF)
@@ -161,7 +179,7 @@ IF(ENABLE_LIBUHD)
ENDIF(ENABLE_LIBUHD)
IF(ENABLE_TESTS)
- ADD_SUBDIRECTORY(test)
+ ADD_SUBDIRECTORY(tests)
ENDIF(ENABLE_TESTS)
IF(ENABLE_UTILS)
diff --git a/host/Modules/FindDocutils.cmake b/host/Modules/FindDocutils.cmake
index b9996f3f1..3a97d8643 100644
--- a/host/Modules/FindDocutils.cmake
+++ b/host/Modules/FindDocutils.cmake
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2011-2011 Ettus Research LLC
#
# 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
diff --git a/host/Modules/FindGit.cmake b/host/Modules/FindGit.cmake
new file mode 100644
index 000000000..2d8214287
--- /dev/null
+++ b/host/Modules/FindGit.cmake
@@ -0,0 +1,46 @@
+# The module defines the following variables:
+# GIT_EXECUTABLE - path to git command line client
+# GIT_FOUND - true if the command line client was found
+# Example usage:
+# find_package(Git)
+# if(GIT_FOUND)
+# message("git found: ${GIT_EXECUTABLE}")
+# endif()
+
+#=============================================================================
+# Copyright 2010 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distributed this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# Look for 'git' or 'eg' (easy git)
+#
+set(git_names git eg)
+
+# Prefer .cmd variants on Windows unless running in a Makefile
+# in the MSYS shell.
+#
+if(WIN32)
+ if(NOT CMAKE_GENERATOR MATCHES "MSYS")
+ set(git_names git.cmd git eg.cmd eg)
+ endif()
+endif()
+
+find_program(GIT_EXECUTABLE
+ NAMES ${git_names}
+ DOC "git command line client"
+ )
+mark_as_advanced(GIT_EXECUTABLE)
+
+# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
+# all listed variables are TRUE
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)
diff --git a/host/Modules/UHDComponent.cmake b/host/Modules/UHDComponent.cmake
index 0263b071f..4ea55bbb9 100644
--- a/host/Modules/UHDComponent.cmake
+++ b/host/Modules/UHDComponent.cmake
@@ -27,27 +27,17 @@ SET(_uhd_disabled_components "" CACHE INTERNAL "" FORCE)
# - deps a list of dependencies
# - dis the default disable setting
########################################################################
-FUNCTION(LIBUHD_REGISTER_COMPONENT name var enb deps dis)
- INCLUDE(CMakeDependentOption)
+MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis)
MESSAGE(STATUS "")
MESSAGE(STATUS "Configuring ${name} support...")
- IF(DEFINED ${var})
- MESSAGE(STATUS "${name} support configured ${var}=${${var}}")
- ELSE(DEFINED ${var}) #not defined: automatic enabling of component
- MESSAGE(STATUS "${name} support configured automatically")
- ENDIF(DEFINED ${var})
+ FOREACH(dep ${deps})
+ MESSAGE(STATUS " Dependency ${dep} = ${${dep}}")
+ ENDFOREACH(dep)
#setup the dependent option for this component
+ INCLUDE(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(${var} "enable ${name} support" ${enb} "${deps}" ${dis})
- #remove previous occurrence of component in either list
- IF(DEFINED _uhd_enabled_components)
- LIST(REMOVE_ITEM _uhd_enabled_components ${name})
- ENDIF(DEFINED _uhd_enabled_components)
- IF(DEFINED _uhd_disabled_components)
- LIST(REMOVE_ITEM _uhd_disabled_components ${name})
- ENDIF(DEFINED _uhd_disabled_components)
-
#append the component into one of the lists
IF(${var})
MESSAGE(STATUS " Enabling ${name} support.")
@@ -56,11 +46,12 @@ FUNCTION(LIBUHD_REGISTER_COMPONENT name var enb deps dis)
MESSAGE(STATUS " Disabling ${name} support.")
LIST(APPEND _uhd_disabled_components ${name})
ENDIF(${var})
+ MESSAGE(STATUS " Override with -D${var}=ON/OFF")
#make components lists into global variables
SET(_uhd_enabled_components ${_uhd_enabled_components} CACHE INTERNAL "" FORCE)
SET(_uhd_disabled_components ${_uhd_disabled_components} CACHE INTERNAL "" FORCE)
-ENDFUNCTION(LIBUHD_REGISTER_COMPONENT)
+ENDMACRO(LIBUHD_REGISTER_COMPONENT)
########################################################################
# Print the registered component summary
@@ -68,7 +59,7 @@ ENDFUNCTION(LIBUHD_REGISTER_COMPONENT)
FUNCTION(UHD_PRINT_COMPONENT_SUMMARY)
MESSAGE(STATUS "")
MESSAGE(STATUS "######################################################")
- MESSAGE(STATUS "# LibUHD enabled components ")
+ MESSAGE(STATUS "# UHD enabled components ")
MESSAGE(STATUS "######################################################")
FOREACH(comp ${_uhd_enabled_components})
MESSAGE(STATUS " * ${comp}")
@@ -76,7 +67,7 @@ FUNCTION(UHD_PRINT_COMPONENT_SUMMARY)
MESSAGE(STATUS "")
MESSAGE(STATUS "######################################################")
- MESSAGE(STATUS "# LibUHD disabled components ")
+ MESSAGE(STATUS "# UHD disabled components ")
MESSAGE(STATUS "######################################################")
FOREACH(comp ${_uhd_disabled_components})
MESSAGE(STATUS " * ${comp}")
diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake
index 4bd740185..c22286d59 100644
--- a/host/Modules/UHDVersion.cmake
+++ b/host/Modules/UHDVersion.cmake
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -21,7 +21,7 @@ INCLUDE(UHDPython) #requires python for parsing
########################################################################
# Setup Version Numbers
########################################################################
-SET(UHD_VERSION_MAJOR 0001) #API compatibility number
+SET(UHD_VERSION_MAJOR 002) #API compatibility number
SET(UHD_VERSION_MINOR 0) #Timestamp of git commit
SET(UHD_VERSION_PATCH 0) #Short hash of git commit
@@ -34,7 +34,7 @@ IF(GIT_FOUND)
#grab the git log entry for the current head
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMAND ${GIT_EXECUTABLE} log HEAD~..HEAD --date=raw
+ COMMAND ${GIT_EXECUTABLE} log HEAD~..HEAD --date=raw -n1
OUTPUT_VARIABLE _git_log OUTPUT_STRIP_TRAILING_WHITESPACE
)
diff --git a/host/docs/CMakeLists.txt b/host/docs/CMakeLists.txt
index 592d66526..ace48f008 100644
--- a/host/docs/CMakeLists.txt
+++ b/host/docs/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -36,7 +36,7 @@ SET(manual_sources
# Setup Manual
########################################################################
MESSAGE(STATUS "")
-FIND_PACKAGE(Docutils REQUIRED)
+FIND_PACKAGE(Docutils)
LIBUHD_REGISTER_COMPONENT("Manual" ENABLE_MANUAL ON "DOCUTILS_FOUND" OFF)
diff --git a/host/docs/transport.rst b/host/docs/transport.rst
index d9abd4923..018f909c1 100644
--- a/host/docs/transport.rst
+++ b/host/docs/transport.rst
@@ -36,7 +36,7 @@ The following parameters can be used to alter the transport's default behavior:
* **num_send_frames:** The number of send buffers to allocate
* **concurrency_hint:** The number of threads to run the IO service
-**Note:** num_send_frames and concurrency_hint will not have an effect
+**Note:** num_send_frames will not have an effect
as the asynchronous send implementation is currently disabled.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/host/docs/usrp1.rst b/host/docs/usrp1.rst
index 9038616a8..0a8224850 100644
--- a/host/docs/usrp1.rst
+++ b/host/docs/usrp1.rst
@@ -4,9 +4,9 @@ UHD - USRP1 Application Notes
.. contents:: Table of Contents
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+------------------------------------------------------------------------
Specify a non-standard image
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+------------------------------------------------------------------------
The standard USRP1 images installer comes with two FPGA images:
* **usrp1_fpga.rbf:** 2 DDCs + 2 DUCs
* **usrp1_fpga_4rx.rbf:** 4 DDCs + 0 DUCs
@@ -66,7 +66,37 @@ Notice that the subdevice name is always specified in the 3 possible cases.
B:B
------------------------------------------------------------------------
-OS Specific Notes
+Missing and emulated features
+------------------------------------------------------------------------
+The USRP1 FPGA does not have the necessary space to support the advanced
+streaming capabilities that are possible with the newer USRP devices.
+Some of these features are emulated in software to support the API.
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+List of emulated features
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+* Setting the current device time
+* Getting the current device time
+* Transmitting at a specific time
+* Receiving at a specific time
+* Receiving a specific number of samples
+* End of burst flags for transmit/receive
+
+**Note:**
+These emulated features rely on the host system's clock for timed operations,
+and therefore may not have sufficient precision for the application.
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+List of missing features
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+* Notification on late stream command
+* Notification on late transmit packet
+* Notification on broken chain error
+* Notification on underflow or overflow
+* Start of burst flags for transmit/receive
+
+------------------------------------------------------------------------
+OS specific notes
------------------------------------------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -90,13 +120,13 @@ On Windows, a driver must be installed the first time the USRP1 is attached to t
A download link for this driver can be found on the UHD wiki page.
Download and unpack the driver, and direct the Windows driver install wizard to the .inf file.
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Hardware setup notes
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
------------------------------------------------------------------------
-External Clock Modification
+Hardware setup notes
------------------------------------------------------------------------
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+External clock modification
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The USRP can be modified to accept an external clock reference instead of the 64MHz onboard reference.
* Solder SMA (LTI-SASF54GT) connector to J2001
* Move 0 ohm 0603 resistor R2029 to R2930
diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst
index 8e5743102..3031a0075 100644
--- a/host/docs/usrp2.rst
+++ b/host/docs/usrp2.rst
@@ -101,7 +101,7 @@ On some systems, the firewall will block UDP broadcast packets.
It is recommended that you change or disable your firewall settings.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Multiple device configuration
+Multiple devices per host
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For maximum throughput, one ethernet interface per USRP2 is recommended,
although multiple devices may be connected via a gigabit ethernet switch.
@@ -210,6 +210,66 @@ Example device address string representation for 2 USRP2s with IPv4 addresses 19
addr0=192.168.10.2, addr1=192.168.20.2
------------------------------------------------------------------------
+Using the MIMO Cable
+------------------------------------------------------------------------
+The MIMO cable allows two USRP devices to share reference clocks,
+time synchronization, and the ethernet interface.
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Shared ethernet mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+In shared ethernet mode,
+only one device in the configuration can be attached to the ethernet.
+This device will be referred to as the master, and the other device, the slave.
+
+* The master provides reference clock and time synchronization to the slave.
+* All data passing between the host and the slave is routed over the MIMO cable.
+* Both master and slave must have different IPv4 addresses in the same subnet.
+* The master and slave may be used individually or in a multi-device configuration.
+* External clocking is optional, and should only be supplied to the master device.
+* The role of slave and master may be switched with the "mimo_mode" device address (see dual ethernet mode).
+
+Example device address string representation for 2 USRP2s with IPv4 addresses 192.168.10.2 (master) and 192.168.10.3 (slave)
+::
+
+ -- Multi-device example --
+
+ addr0=192.168.10.2, addr1=192.168.10.3
+
+ -- Two single devices example --
+
+ addr=192.168.10.2
+
+ addr=192.168.10.3
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Dual ethernet mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+In dual ethernet mode,
+both devices in the configuration must be attached to the ethernet.
+One of the devices in the configuration will be configured to provide synchronization.
+This device will be referred to as the master, and the other device, the slave.
+
+* The master provides reference clock and time synchronization to the slave.
+* The devices require the special device address argument "mimo_mode" set.
+* Both master and slave must have different IPv4 addresses in different subnets.
+* The master and slave may be used individually or in a multi-device configuration.
+* External clocking is optional, and should only be supplied to the master device.
+
+Example device address string representation for 2 USRP2s with IPv4 addresses 192.168.10.2 (master) and 192.168.20.2 (slave)
+::
+
+ -- Multi-device example --
+
+ addr0=192.168.10.2, mimo_mode0=master, addr1=192.168.20.2, mimo_mode1=slave
+
+ -- Two single devices example --
+
+ addr=192.168.10.2, mimo_mode=master
+
+ addr=192.168.20.2, mimo_mode=slave
+
+------------------------------------------------------------------------
Hardware setup notes
------------------------------------------------------------------------
@@ -220,7 +280,7 @@ The LEDs on the front panel can be useful in debugging hardware and software iss
The LEDs reveal the following about the state of the device:
* **LED A:** transmitting
-* **LED B:** serdes link
+* **LED B:** mimo cable link
* **LED C:** receiving
* **LED D:** firmware loaded
* **LED E:** reference lock
diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp
index 5a24867b4..260feca24 100644
--- a/host/examples/rx_ascii_art_dft.cpp
+++ b/host/examples/rx_ascii_art_dft.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -34,8 +34,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
size_t num_bins;
- double rate, freq, frame_rate;
- float gain, ref_lvl, dyn_rng;
+ double rate, freq, gain, frame_rate;
+ float ref_lvl, dyn_rng;
//setup the program options
po::options_description desc("Allowed options");
@@ -45,7 +45,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
// hardware parameters
("rate", po::value<double>(&rate), "rate of incoming samples (sps)")
("freq", po::value<double>(&freq)->default_value(0), "RF center frequency in Hz")
- ("gain", po::value<float>(&gain)->default_value(0), "gain for the RF chain")
+ ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain")
// display parameters
("num-bins", po::value<size_t>(&num_bins)->default_value(512), "the number of bins in the DFT")
("frame-rate", po::value<double>(&frame_rate)->default_value(5), "frame rate of the display (fps)")
diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp
index c80d2a6de..81977035e 100644
--- a/host/examples/rx_samples_to_file.cpp
+++ b/host/examples/rx_samples_to_file.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -33,8 +33,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args, file;
size_t total_num_samps;
- double rate, freq;
- float gain;
+ double rate, freq, gain;
//setup the program options
po::options_description desc("Allowed options");
@@ -45,7 +44,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive")
("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of incoming samples")
("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
- ("gain", po::value<float>(&gain)->default_value(0), "gain for the RF chain")
+ ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp
index 488c95494..55b9a50ba 100644
--- a/host/examples/rx_samples_to_udp.cpp
+++ b/host/examples/rx_samples_to_udp.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -33,8 +33,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
size_t total_num_samps;
- double rate, freq;
- float gain;
+ double rate, freq, gain;
std::string addr, port;
//setup the program options
@@ -45,7 +44,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive")
("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of incoming samples")
("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
- ("gain", po::value<float>(&gain)->default_value(0), "gain for the RF chain")
+ ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain")
("port", po::value<std::string>(&port)->default_value("7124"), "server udp port")
("addr", po::value<std::string>(&addr)->default_value("192.168.1.10"), "resolvable server address")
;
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index 8a810811f..a19532f50 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -30,7 +30,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
- time_t seconds_in_future;
+ double seconds_in_future;
size_t total_num_samps;
double rate, freq;
@@ -39,7 +39,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
desc.add_options()
("help", "help message")
("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args")
- ("secs", po::value<time_t>(&seconds_in_future)->default_value(3), "number of seconds in the future to receive")
+ ("secs", po::value<double>(&seconds_in_future)->default_value(3), "number of seconds in the future to receive")
("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive")
("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of incoming samples")
("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
@@ -80,7 +80,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//setup streaming
std::cout << std::endl;
std::cout << boost::format(
- "Begin streaming %u samples, %d seconds in the future..."
+ "Begin streaming %u samples, %f seconds in the future..."
) % total_num_samps % seconds_in_future << std::endl;
uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
stream_cmd.num_samps = total_num_samps;
diff --git a/host/examples/test_pps_input.cpp b/host/examples/test_pps_input.cpp
index 4b2bb62a3..273c73df0 100644
--- a/host/examples/test_pps_input.cpp
+++ b/host/examples/test_pps_input.cpp
@@ -17,7 +17,7 @@
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
-#include <uhd/usrp/single_usrp.hpp>
+#include <uhd/usrp/multi_usrp.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <boost/thread.hpp>
@@ -31,7 +31,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
- double seconds;
//setup the program options
po::options_description desc("Allowed options");
@@ -52,35 +51,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//create a usrp device
std::cout << std::endl;
std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
- uhd::usrp::single_usrp::sptr sdev = uhd::usrp::single_usrp::make(args);
+ uhd::usrp::multi_usrp::sptr sdev = uhd::usrp::multi_usrp::make(args);
uhd::device::sptr dev = sdev->get_device();
std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl;
- //set a known time value
- std::cout << "Set time to known value (100.0) without regard to pps:" << std::endl;
- sdev->set_time_now(uhd::time_spec_t(100.0));
- boost::this_thread::sleep(boost::posix_time::seconds(1));
- std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl;
-
- //store the time to see if PPS resets it
- seconds = sdev->get_time_now().get_real_secs();
-
- //set a known time at next PPS, check that time increments
- uhd::time_spec_t time_spec = uhd::time_spec_t(0.0);
- std::cout << "Set time to known value (0.0) at next pps:" << std::endl;
- sdev->set_time_next_pps(time_spec);
- boost::this_thread::sleep(boost::posix_time::seconds(1));
- std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl;
-
- //finished
- if (seconds > sdev->get_time_now().get_real_secs()){
- std::cout << std::endl << "Success!" << std::endl << std::endl;
- return 0;
- } else {
- std::cout << std::endl << "Failed!" << std::endl << std::endl
- << "If you expected PPS to work:" << std::endl
- << "\tsee Device App Notes for PPS level information"
- << std::endl << std::endl;
- return -1;
- }
+ //set the time at an unknown pps (will throw if no pps)
+ std::cout << std::endl << "Attempt to detect the PPS and set the time..." << std::endl << std::endl;
+ sdev->set_time_unknown_pps(uhd::time_spec_t(0.0));
+ std::cout << std::endl << "Success!" << std::endl << std::endl;
+ return 0;
}
diff --git a/host/examples/tx_from_file.cpp b/host/examples/tx_from_file.cpp
index 9611cf47c..8af9b0f4a 100644
--- a/host/examples/tx_from_file.cpp
+++ b/host/examples/tx_from_file.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -31,24 +31,23 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
- time_t seconds_in_future;
+ double seconds_in_future;
size_t total_num_samps;
size_t samps_per_packet;
- double tx_rate, freq;
+ double tx_rate, freq, gain;
float ampl;
- float tx_gain;
//setup the program options
po::options_description desc("Allowed options");
desc.add_options()
("help", "help message")
("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args")
- ("secs", po::value<time_t>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit")
+ ("secs", po::value<double>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit")
("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to transmit")
("txrate", po::value<double>(&tx_rate)->default_value(100e6/16), "rate of outgoing samples")
("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of each sample")
- ("gain", po::value<float>(&tx_gain)->default_value(float(0)), "amplitude of each sample")
+ ("gain", po::value<double>(&gain)->default_value(0), "amplitude of each sample")
("dilv", "specify to disable inner-loop verbose")
;
po::variables_map vm;
@@ -78,7 +77,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
sdev->set_tx_freq(freq);
sdev->set_time_now(uhd::time_spec_t(0.0));
- sdev->set_tx_gain(tx_gain);
+ sdev->set_gain(gain);
//allocate data to send
std::vector<std::complex<short> > buff;
@@ -102,7 +101,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet;
for (size_t i = 0; i < num_packets; i++){
//setup the metadata flags and time spec
- md.start_of_burst = true; //always SOB (good for continuous streaming)
+ md.start_of_burst = (i == 0); //only first packet has SOB
md.end_of_burst = (i == num_packets-1); //only last packet has EOB
md.has_time_spec = (i == 0); //only first packet has time
md.time_spec = uhd::time_spec_t(seconds_in_future);
diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp
index 799da37e0..6d6aa7010 100644
--- a/host/examples/tx_timed_samples.cpp
+++ b/host/examples/tx_timed_samples.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -30,7 +30,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
- time_t seconds_in_future;
+ double seconds_in_future;
size_t total_num_samps;
size_t samps_per_packet;
double rate, freq;
@@ -41,7 +41,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
desc.add_options()
("help", "help message")
("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args")
- ("secs", po::value<time_t>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit")
+ ("secs", po::value<double>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit")
("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to transmit")
("spp", po::value<size_t>(&samps_per_packet)->default_value(1000), "number of samples per packet")
("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of outgoing samples")
@@ -84,15 +84,17 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//allocate data to send
std::vector<std::complex<float> > buff(samps_per_packet, std::complex<float>(ampl, ampl));
+ uhd::tx_metadata_t md;
+ md.time_spec = uhd::time_spec_t(seconds_in_future);
+
//send the data in multiple packets
size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet;
for (size_t i = 0; i < num_packets; i++){
- //setup the metadata flags and time spec
- uhd::tx_metadata_t md;
- md.start_of_burst = true; //always SOB (good for continuous streaming)
+
+ //setup the metadata flags per fragment
+ md.start_of_burst = (i == 0); //only first packet has SOB
md.end_of_burst = (i == num_packets-1); //only last packet has EOB
md.has_time_spec = (i == 0); //only first packet has time
- md.time_spec = uhd::time_spec_t(seconds_in_future);
size_t samps_to_send = std::min(total_num_samps - samps_per_packet*i, samps_per_packet);
diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp
index 50982cf88..7cc1f5ae0 100644
--- a/host/examples/tx_waveforms.cpp
+++ b/host/examples/tx_waveforms.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -63,8 +63,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args, wave_type;
size_t total_duration, spb;
- double rate, freq, wave_freq;
- float ampl, gain;
+ double rate, freq, gain, wave_freq;
+ float ampl;
//setup the program options
po::options_description desc("Allowed options");
@@ -76,7 +76,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("rate", po::value<double>(&rate)->default_value(1.5e6), "rate of outgoing samples")
("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of the waveform")
- ("gain", po::value<float>(&gain)->default_value(float(0)), "gain for the RF chain")
+ ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain")
("wave-type", po::value<std::string>(&wave_type)->default_value("CONST"), "waveform type (CONST, SQUARE, RAMP, SINE)")
("wave-freq", po::value<double>(&wave_freq)->default_value(0), "waveform frequency in Hz")
;
@@ -142,7 +142,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//setup the metadata flags
uhd::tx_metadata_t md;
- md.start_of_burst = true; //always SOB (good for continuous streaming)
+ md.start_of_burst = false; //never SOB when continuous
md.end_of_burst = false;
//send the data in multiple packets
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt
index ad528c9fb..fee1270e9 100644
--- a/host/include/uhd/CMakeLists.txt
+++ b/host/include/uhd/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -23,6 +23,7 @@ ADD_SUBDIRECTORY(utils)
INSTALL(FILES
config.hpp
+ convert.hpp
device.hpp
device.ipp
version.hpp
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 9a29fb246..912fbc204 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -18,9 +18,10 @@
#ifndef INCLUDED_UHD_CONFIG_HPP
#define INCLUDED_UHD_CONFIG_HPP
-// suppress warnings
#include <boost/config.hpp>
+
#ifdef BOOST_MSVC
+// suppress warnings
//# pragma warning(push)
//# pragma warning(disable: 4511) // copy constructor can't not be generated
//# pragma warning(disable: 4512) // assignment operator can't not be generated
@@ -37,76 +38,43 @@
//# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated
//# pragma warning(disable: 4250) // 'class' : inherits 'method' via dominance
# pragma warning(disable: 4200) // nonstandard extension used : zero-sized array in struct/union
-#endif
// define logical operators
-#ifdef BOOST_MSVC
- #include <ciso646>
-#endif
+#include <ciso646>
// define ssize_t
-#ifdef BOOST_MSVC
- #include <cstddef>
- typedef ptrdiff_t ssize_t;
-#endif
-
-// http://gcc.gnu.org/wiki/Visibility
-// Generic helper definitions for shared library support
-#if defined(BOOST_HAS_DECLSPEC)
- #define UHD_HELPER_DLL_IMPORT __declspec(dllimport)
- #define UHD_HELPER_DLL_EXPORT __declspec(dllexport)
- #define UHD_HELPER_DLL_LOCAL
- #define UHD_HELPER_EXIM_TMPL
-#elif defined(__GNUG__) && __GNUG__ >= 4
- #define UHD_HELPER_DLL_IMPORT __attribute__ ((visibility("default")))
- #define UHD_HELPER_DLL_EXPORT __attribute__ ((visibility("default")))
- #define UHD_HELPER_DLL_LOCAL __attribute__ ((visibility("hidden")))
- #define UHD_HELPER_EXIM_TMPL extern
-#else
- #define UHD_HELPER_DLL_IMPORT
- #define UHD_HELPER_DLL_EXPORT
- #define UHD_HELPER_DLL_LOCAL
- #define UHD_HELPER_EXIM_TMPL extern
-#endif
-
-// Now we use the generic helper definitions above to define UHD_API and UHD_LOCAL.
-// UHD_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build)
-// UHD_LOCAL is used for non-api symbols.
-
-#define UHD_DLL // defined here, put into configuration if we need to make static libs
+#include <cstddef>
+typedef ptrdiff_t ssize_t;
-#ifdef UHD_DLL // defined if UHD is compiled as a DLL
- #ifdef UHD_DLL_EXPORTS // defined if we are building the UHD DLL (instead of using it)
- #define UHD_API UHD_HELPER_DLL_EXPORT
- #define UHD_EXIM_TMPL UHD_HELPER_EXIM_TMPL
- #else
- #define UHD_API UHD_HELPER_DLL_IMPORT
- #define UHD_EXIM_TMPL UHD_HELPER_EXIM_TMPL
- #endif // UHD_DLL_EXPORTS
- #define UHD_LOCAL UHD_HELPER_DLL_LOCAL
-#else // UHD_DLL is not defined: this means UHD is a static lib.
- #define UHD_API
- #define UHD_LOCAL
- #define UHD_EXIM_TMPL
-#endif // UHD_DLL
+#endif //BOOST_MSVC
-// Define force inline macro
-#if defined(BOOST_MSVC)
- #define UHD_INLINE __forceinline
+//define cross platform attribute macros
+#if defined(BOOST_MSVC) || defined(BOOST_HAS_DECLSPEC)
+ #define UHD_EXPORT __declspec(dllexport)
+ #define UHD_IMPORT __declspec(dllimport)
+ #define UHD_INLINE __forceinline
+ #define UHD_DEPRECATED __declspec(deprecated)
+ #define UHD_ALIGNED(x) __declspec(align(x))
#elif defined(__GNUG__) && __GNUG__ >= 4
- #define UHD_INLINE inline __attribute__((always_inline))
+ #define UHD_EXPORT __attribute__((visibility("default")))
+ #define UHD_IMPORT __attribute__((visibility("default")))
+ #define UHD_INLINE inline __attribute__((always_inline))
+ #define UHD_DEPRECATED __attribute__((deprecated))
+ #define UHD_ALIGNED(x) __attribute__((aligned(x)))
#else
- #define UHD_INLINE inline
+ #define UHD_EXPORT
+ #define UHD_IMPORT
+ #define UHD_INLINE inline
+ #define UHD_DEPRECATED
+ #define UHD_ALIGNED(x)
#endif
-// Define deprecated attribute macro
-#if defined(BOOST_MSVC)
- #define UHD_DEPRECATED __declspec(deprecated)
-#elif defined(__GNUG__) && __GNUG__ >= 4
- #define UHD_DEPRECATED __attribute__ ((deprecated))
+// Define API declaration macro
+#ifdef UHD_DLL_EXPORTS
+ #define UHD_API UHD_EXPORT
#else
- #define UHD_DEPRECATED
-#endif
+ #define UHD_API UHD_IMPORT
+#endif // UHD_DLL_EXPORTS
// Platform defines for conditional parts of headers:
// Taken from boost/config/select_platform_config.hpp,
@@ -117,6 +85,8 @@
#define UHD_PLATFORM_WIN32
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
#define UHD_PLATFORM_MACOS
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+ #define UHD_PLATFORM_BSD
#endif
#endif /* INCLUDED_UHD_CONFIG_HPP */
diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp
new file mode 100644
index 000000000..bfe8c8267
--- /dev/null
+++ b/host/include/uhd/convert.hpp
@@ -0,0 +1,90 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#ifndef INCLUDED_UHD_CONVERT_HPP
+#define INCLUDED_UHD_CONVERT_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/types/io_type.hpp>
+#include <uhd/types/otw_type.hpp>
+#include <boost/function.hpp>
+#include <string>
+#include <vector>
+
+namespace uhd{ namespace convert{
+
+ typedef std::vector<void *> output_type;
+ typedef std::vector<const void *> input_type;
+ typedef boost::function<void(input_type&, output_type&, size_t)> function_type;
+
+ /*!
+ * Describe the priority of a converter function.
+ * A higher priority function takes precedence.
+ * The general case function are the lowest.
+ * Next comes the liborc implementations.
+ * Custom intrinsics implementations are highest.
+ */
+ enum priority_type{
+ PRIORITY_GENERAL = 0,
+ PRIORITY_LIBORC = 1,
+ PRIORITY_CUSTOM = 2,
+ PRIORITY_EMPTY = -1,
+ };
+
+ /*!
+ * Register a converter function that converts cpu type to/from otw type.
+ * \param markup representing the signature
+ * \param fcn a pointer to the converter
+ * \param prio the function priority
+ */
+ UHD_API void register_converter(
+ const std::string &markup,
+ function_type fcn,
+ priority_type prio
+ );
+
+ /*!
+ * Get a converter function that converts cpu to otw.
+ * \param io_type the type of the input samples
+ * \param otw_type the type of the output samples
+ * \param num_input_buffs the number of inputs
+ * \param num_output_buffs the number of outputs
+ */
+ UHD_API const function_type &get_converter_cpu_to_otw(
+ const io_type_t &io_type,
+ const otw_type_t &otw_type,
+ size_t num_input_buffs,
+ size_t num_output_buffs
+ );
+
+ /*!
+ * Get a converter function that converts otw to cpu.
+ * \param io_type the type of the input samples
+ * \param otw_type the type of the output samples
+ * \param num_input_buffs the number of inputs
+ * \param num_output_buffs the number of outputs
+ */
+ UHD_API const function_type &get_converter_otw_to_cpu(
+ const io_type_t &io_type,
+ const otw_type_t &otw_type,
+ size_t num_input_buffs,
+ size_t num_output_buffs
+ );
+
+}} //namespace
+
+#endif /* INCLUDED_UHD_CONVERT_HPP */
diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt
index 2c84c0724..14ca82226 100644
--- a/host/include/uhd/transport/CMakeLists.txt
+++ b/host/include/uhd/transport/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -17,12 +17,9 @@
INSTALL(FILES
- alignment_buffer.hpp
- alignment_buffer.ipp
bounded_buffer.hpp
bounded_buffer.ipp
- convert_types.hpp
- convert_types.ipp
+ buffer_pool.hpp
if_addrs.hpp
udp_simple.hpp
udp_zero_copy.hpp
diff --git a/host/include/uhd/transport/alignment_buffer.hpp b/host/include/uhd/transport/alignment_buffer.hpp
deleted file mode 100644
index f44a037f8..000000000
--- a/host/include/uhd/transport/alignment_buffer.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_UHD_TRANSPORT_ALIGNMENT_BUFFER_HPP
-#define INCLUDED_UHD_TRANSPORT_ALIGNMENT_BUFFER_HPP
-
-#include <uhd/config.hpp>
-#include <uhd/transport/bounded_buffer.hpp> //time_duration_t
-#include <boost/shared_ptr.hpp>
-#include <vector>
-
-namespace uhd{ namespace transport{
-
- /*!
- * Implement a templated alignment buffer:
- * Used for aligning asynchronously pushed elements with matching ids.
- */
- template <typename elem_type, typename seq_type> class alignment_buffer{
- public:
- typedef boost::shared_ptr<alignment_buffer<elem_type, seq_type> > sptr;
-
- /*!
- * Make a new alignment buffer object.
- * \param capacity the maximum elements per index
- * \param width the number of elements to align
- */
- static sptr make(size_t capacity, size_t width);
-
- /*!
- * Push an element with sequence id into the buffer at index.
- * \param elem the element to push
- * \param seq the sequence identifier
- * \param index the buffer index
- * \return true if the element fit without popping for space
- */
- virtual bool push_with_pop_on_full(
- const elem_type &elem, const seq_type &seq, size_t index
- ) = 0;
-
- /*!
- * Pop an aligned set of elements from this alignment buffer.
- * \param elems a collection to store the aligned elements
- * \param timeout the timeout in seconds
- * \return false when the operation times out
- */
- virtual bool pop_elems_with_timed_wait(
- std::vector<elem_type> &elems, double timeout
- ) = 0;
- };
-
-}} //namespace
-
-#include <uhd/transport/alignment_buffer.ipp>
-
-#endif /* INCLUDED_UHD_TRANSPORT_ALIGNMENT_BUFFER_HPP */
diff --git a/host/include/uhd/transport/alignment_buffer.ipp b/host/include/uhd/transport/alignment_buffer.ipp
deleted file mode 100644
index 833b5d399..000000000
--- a/host/include/uhd/transport/alignment_buffer.ipp
+++ /dev/null
@@ -1,144 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_UHD_TRANSPORT_ALIGNMENT_BUFFER_IPP
-#define INCLUDED_UHD_TRANSPORT_ALIGNMENT_BUFFER_IPP
-
-#include <uhd/transport/bounded_buffer.hpp>
-#include <boost/thread/condition_variable.hpp>
-#include <utility>
-
-namespace uhd{ namespace transport{ namespace{ /*anon*/
-
- /*!
- * Imlement a templated alignment buffer:
- * Used for aligning asynchronously pushed elements with matching ids.
- */
- template <typename elem_type, typename seq_type>
- class alignment_buffer_impl : public alignment_buffer<elem_type, seq_type>{
- public:
-
- alignment_buffer_impl(size_t capacity, size_t width) : _last_seqs(width){
- for (size_t i = 0; i < width; i++){
- _buffs.push_back(bounded_buffer<buff_contents_type>::make(capacity));
- _all_indexes.push_back(i);
- }
- _there_was_a_clear = false;
- }
-
- UHD_INLINE bool push_with_pop_on_full(
- const elem_type &elem, const seq_type &seq, size_t index
- ){
- //clear the buffer for this index if the seqs are mis-ordered
- if (seq < _last_seqs[index]){
- _buffs[index]->clear();
- _there_was_a_clear = true;
- } _last_seqs[index] = seq;
- return _buffs[index]->push_with_pop_on_full(buff_contents_type(elem, seq));
- }
-
- UHD_INLINE bool pop_elems_with_timed_wait(
- std::vector<elem_type> &elems, double timeout
- ){
- boost::system_time exit_time = boost::get_system_time() + to_time_dur(timeout);
- buff_contents_type buff_contents_tmp;
- std::list<size_t> indexes_to_do(_all_indexes);
-
- //do an initial pop to load an initial sequence id
- size_t index = indexes_to_do.front();
- if (not _buffs[index]->pop_with_timed_wait(
- buff_contents_tmp, from_time_dur(exit_time - boost::get_system_time())
- )) return false;
- elems[index] = buff_contents_tmp.first;
- seq_type expected_seq_id = buff_contents_tmp.second;
- indexes_to_do.pop_front();
-
- //get an aligned set of elements from the buffers:
- while(indexes_to_do.size() != 0){
-
- //respond to a clear by starting from scratch
- if(_there_was_a_clear){
- _there_was_a_clear = false;
- indexes_to_do = _all_indexes;
- index = indexes_to_do.front();
- if (not _buffs[index]->pop_with_timed_wait(
- buff_contents_tmp, from_time_dur(exit_time - boost::get_system_time())
- )) return false;
- elems[index] = buff_contents_tmp.first;
- expected_seq_id = buff_contents_tmp.second;
- indexes_to_do.pop_front();
- }
-
- //pop an element off for this index
- index = indexes_to_do.front();
- if (not _buffs[index]->pop_with_timed_wait(
- buff_contents_tmp, from_time_dur(exit_time - boost::get_system_time())
- )) return false;
-
- //if the sequence id matches:
- // store the popped element into the output,
- // remove this index from the list and continue
- if (buff_contents_tmp.second == expected_seq_id){
- elems[index] = buff_contents_tmp.first;
- indexes_to_do.pop_front();
- continue;
- }
-
- //if the sequence id is older:
- // continue with the same index to try again
- if (buff_contents_tmp.second < expected_seq_id){
- continue;
- }
-
- //if the sequence id is newer:
- // store the popped element into the output,
- // add all other indexes back into the list
- if (buff_contents_tmp.second > expected_seq_id){
- elems[index] = buff_contents_tmp.first;
- expected_seq_id = buff_contents_tmp.second;
- indexes_to_do = _all_indexes;
- indexes_to_do.remove(index);
- continue;
- }
- }
- return true;
- }
-
- private:
- //a vector of bounded buffers for each index
- typedef std::pair<elem_type, seq_type> buff_contents_type;
- std::vector<typename bounded_buffer<buff_contents_type>::sptr> _buffs;
- std::vector<seq_type> _last_seqs;
- std::list<size_t> _all_indexes;
- bool _there_was_a_clear;
- };
-
-}}} //namespace
-
-namespace uhd{ namespace transport{
-
- template <typename elem_type, typename seq_type>
- typename alignment_buffer<elem_type, seq_type>::sptr
- alignment_buffer<elem_type, seq_type>::make(size_t capacity, size_t width){
- return typename alignment_buffer<elem_type, seq_type>::sptr(
- new alignment_buffer_impl<elem_type, seq_type>(capacity, width)
- );
- }
-
-}} //namespace
-
-#endif /* INCLUDED_UHD_TRANSPORT_ALIGNMENT_BUFFER_IPP */
diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp
index edc7faa06..f7915d866 100644
--- a/host/include/uhd/transport/bounded_buffer.ipp
+++ b/host/include/uhd/transport/bounded_buffer.ipp
@@ -26,14 +26,6 @@
namespace uhd{ namespace transport{ namespace{ /*anon*/
- static UHD_INLINE boost::posix_time::time_duration to_time_dur(double timeout){
- return boost::posix_time::microseconds(long(timeout*1e6));
- }
-
- static UHD_INLINE double from_time_dur(const boost::posix_time::time_duration &time_dur){
- return 1e-6*time_dur.total_microseconds();
- }
-
template <typename elem_type>
class bounded_buffer_impl : public bounded_buffer<elem_type>{
public:
@@ -127,6 +119,11 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/
_buffer.pop_back();
return elem;
}
+
+ static UHD_INLINE boost::posix_time::time_duration to_time_dur(double timeout){
+ return boost::posix_time::microseconds(long(timeout*1e6));
+ }
+
};
}}} //namespace
diff --git a/host/include/uhd/transport/buffer_pool.hpp b/host/include/uhd/transport/buffer_pool.hpp
new file mode 100644
index 000000000..84a338097
--- /dev/null
+++ b/host/include/uhd/transport/buffer_pool.hpp
@@ -0,0 +1,59 @@
+//
+// Copyright 2011-2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#ifndef INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP
+#define INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP
+
+#include <uhd/config.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace uhd{ namespace transport{
+
+ /*!
+ * A buffer pool manages memory for a homogeneous set of buffers.
+ * Each buffer is the pool start at a 16-byte alignment boundary.
+ */
+ class UHD_API buffer_pool : boost::noncopyable{
+ public:
+ typedef boost::shared_ptr<buffer_pool> sptr;
+ typedef void * ptr_type;
+
+ /*!
+ * Make a new buffer pool.
+ * \param num_buffs the number of buffers to allocate
+ * \param buff_size the size of each buffer in bytes
+ * \param alignment the alignment boundary in bytes
+ * \return a new buffer pool buff_size X num_buffs
+ */
+ static sptr make(
+ const size_t num_buffs,
+ const size_t buff_size,
+ const size_t alignment = 16
+ );
+
+ //! Get a pointer to the buffer start at the specified index
+ virtual ptr_type at(const size_t index) const = 0;
+
+ //! Get the number of buffers in this pool
+ virtual size_t size(void) const = 0;
+ };
+
+}} //namespace
+
+
+#endif /* INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP */
diff --git a/host/include/uhd/transport/convert_types.hpp b/host/include/uhd/transport/convert_types.hpp
deleted file mode 100644
index dc7fa6c1a..000000000
--- a/host/include/uhd/transport/convert_types.hpp
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_UHD_TRANSPORT_CONVERT_TYPES_HPP
-#define INCLUDED_UHD_TRANSPORT_CONVERT_TYPES_HPP
-
-#include <uhd/config.hpp>
-#include <uhd/types/io_type.hpp>
-#include <uhd/types/otw_type.hpp>
-#include <vector>
-
-namespace uhd{ namespace transport{
-
-/*!
- * Convert IO samples to OWT samples.
- *
- * \param io_buff memory containing samples
- * \param io_type the type of these samples
- * \param otw_buff memory to write converted samples
- * \param otw_type the type of these samples
- * \param num_samps the number of samples in io_buff
- */
-UHD_API void convert_io_type_to_otw_type(
- const void *io_buff, const io_type_t &io_type,
- void *otw_buff, const otw_type_t &otw_type,
- size_t num_samps
-);
-
-/*!
- * Convert IO samples to OWT samples + interleave.
- *
- * \param io_buffs buffers containing samples
- * \param io_type the type of these samples
- * \param otw_buff memory to write converted samples
- * \param otw_type the type of these samples
- * \param nsamps_per_io_buff samples per io_buff
- */
-UHD_API void convert_io_type_to_otw_type(
- const std::vector<const void *> &io_buffs,
- const io_type_t &io_type,
- void *otw_buff,
- const otw_type_t &otw_type,
- size_t nsamps_per_io_buff
-);
-
-/*!
- * Convert OTW samples to IO samples.
- *
- * \param otw_buff memory containing samples
- * \param otw_type the type of these samples
- * \param io_buff memory to write converted samples
- * \param io_type the type of these samples
- * \param num_samps the number of samples in io_buff
- */
-UHD_API void convert_otw_type_to_io_type(
- const void *otw_buff, const otw_type_t &otw_type,
- void *io_buff, const io_type_t &io_type,
- size_t num_samps
-);
-
-/*!
- * Convert OTW samples to IO samples + de-interleave.
- *
- * \param otw_buff memory containing samples
- * \param otw_type the type of these samples
- * \param io_buffs buffers to write converted samples
- * \param io_type the type of these samples
- * \param nsamps_per_io_buff samples per io_buff
- */
-UHD_API void convert_otw_type_to_io_type(
- const void *otw_buff,
- const otw_type_t &otw_type,
- std::vector<void *> &io_buffs,
- const io_type_t &io_type,
- size_t nsamps_per_io_buff
-);
-
-}} //namespace
-
-#include <uhd/transport/convert_types.ipp>
-
-#endif /* INCLUDED_UHD_TRANSPORT_CONVERT_TYPES_HPP */
diff --git a/host/include/uhd/transport/convert_types.ipp b/host/include/uhd/transport/convert_types.ipp
deleted file mode 100644
index 914ca6f17..000000000
--- a/host/include/uhd/transport/convert_types.ipp
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_UHD_TRANSPORT_CONVERT_TYPES_IPP
-#define INCLUDED_UHD_TRANSPORT_CONVERT_TYPES_IPP
-
-UHD_INLINE void uhd::transport::convert_io_type_to_otw_type(
- const void *io_buff, const io_type_t &io_type,
- void *otw_buff, const otw_type_t &otw_type,
- size_t num_samps
-){
- std::vector<const void *> buffs(1, io_buff);
- return uhd::transport::convert_io_type_to_otw_type(
- buffs, io_type, otw_buff, otw_type, num_samps
- );
-}
-
-UHD_INLINE void uhd::transport::convert_otw_type_to_io_type(
- const void *otw_buff, const otw_type_t &otw_type,
- void *io_buff, const io_type_t &io_type,
- size_t num_samps
-){
- std::vector<void *> buffs(1, io_buff);
- return uhd::transport::convert_otw_type_to_io_type(
- otw_buff, otw_type, buffs, io_type, num_samps
- );
-}
-
-#endif /* INCLUDED_UHD_TRANSPORT_CONVERT_TYPES_IPP */
diff --git a/host/include/uhd/transport/if_addrs.hpp b/host/include/uhd/transport/if_addrs.hpp
index fbbb35e1d..c831750d7 100644
--- a/host/include/uhd/transport/if_addrs.hpp
+++ b/host/include/uhd/transport/if_addrs.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -15,8 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#ifndef INCLUDED_UHD_IFADDRS_HPP
-#define INCLUDED_UHD_IFADDRS_HPP
+#ifndef INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP
+#define INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP
#include <uhd/config.hpp>
#include <string>
@@ -44,4 +44,4 @@ namespace uhd{ namespace transport{
}} //namespace
-#endif /* INCLUDED_UHD_IFADDRS_HPP */
+#endif /* INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP */
diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt
index 1d2c0c41c..51be164aa 100644
--- a/host/include/uhd/types/CMakeLists.txt
+++ b/host/include/uhd/types/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -25,8 +25,8 @@ INSTALL(FILES
mac_addr.hpp
metadata.hpp
otw_type.hpp
- ranges.ipp
ranges.hpp
+ sensors.hpp
serial.hpp
stream_cmd.hpp
time_spec.hpp
diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp
index 9342fbb7b..a72eb63de 100644
--- a/host/include/uhd/types/clock_config.hpp
+++ b/host/include/uhd/types/clock_config.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -28,16 +28,19 @@ namespace uhd{
* The source and polarity for the PPS clock.
*/
struct UHD_API clock_config_t{
+ //------ simple usage --------//
+ static clock_config_t external(void);
+ static clock_config_t internal(void);
+
+ //------ advanced usage --------//
enum ref_source_t {
REF_AUTO = 'a', //automatic (device specific)
REF_INT = 'i', //internal reference
REF_SMA = 's', //external sma port
- REF_MIMO = 'm' //mimo cable (usrp2 only)
} ref_source;
enum pps_source_t {
PPS_INT = 'i', //there is no internal
PPS_SMA = 's', //external sma port
- PPS_MIMO = 'm' //mimo cable (usrp2 only)
} pps_source;
enum pps_polarity_t {
PPS_NEG = 'n', //negative edge
diff --git a/host/include/uhd/types/dict.hpp b/host/include/uhd/types/dict.hpp
index 6166140a0..97fa8f09c 100644
--- a/host/include/uhd/types/dict.hpp
+++ b/host/include/uhd/types/dict.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -54,14 +54,14 @@ namespace uhd{
* Key order depends on insertion precedence.
* \return vector of keys
*/
- const std::vector<Key> keys(void) const;
+ std::vector<Key> keys(void) const;
/*!
* Get a list of the values in this dict.
* Value order depends on insertion precedence.
* \return vector of values
*/
- const std::vector<Val> vals(void) const;
+ std::vector<Val> vals(void) const;
/*!
* Does the dictionary contain this key?
@@ -73,10 +73,24 @@ namespace uhd{
/*!
* Get a value in the dict or default.
* \param key the key to look for
- * \param def use if key not found
+ * \param other use if key not found
* \return the value or default
*/
- const Val &get(const Key &key, const Val &def) const;
+ const Val &get(const Key &key, const Val &other) const;
+
+ /*!
+ * Get a value in the dict or throw.
+ * \param key the key to look for
+ * \return the value or default
+ */
+ const Val &get(const Key &key) const;
+
+ /*!
+ * Set a value in the dict at the key.
+ * \param key the key to set at
+ * \param val the value to set
+ */
+ void set(const Key &key, const Val &val);
/*!
* Get a value for the given key if it exists.
diff --git a/host/include/uhd/types/dict.ipp b/host/include/uhd/types/dict.ipp
index f037d7988..0c014474e 100644
--- a/host/include/uhd/types/dict.ipp
+++ b/host/include/uhd/types/dict.ipp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -59,7 +59,7 @@ namespace uhd{
}
template <typename Key, typename Val>
- const std::vector<Key> dict<Key, Val>::keys(void) const{
+ std::vector<Key> dict<Key, Val>::keys(void) const{
std::vector<Key> keys;
BOOST_FOREACH(const pair_t &p, _map){
keys.push_back(p.first);
@@ -68,7 +68,7 @@ namespace uhd{
}
template <typename Key, typename Val>
- const std::vector<Val> dict<Key, Val>::vals(void) const{
+ std::vector<Val> dict<Key, Val>::vals(void) const{
std::vector<Val> vals;
BOOST_FOREACH(const pair_t &p, _map){
vals.push_back(p.second);
@@ -85,11 +85,24 @@ namespace uhd{
}
template <typename Key, typename Val>
- const Val &dict<Key, Val>::get(const Key &key, const Val &def) const{
+ const Val &dict<Key, Val>::get(const Key &key, const Val &other) const{
BOOST_FOREACH(const pair_t &p, _map){
if (p.first == key) return p.second;
}
- return def;
+ return other;
+ }
+
+ template <typename Key, typename Val>
+ const Val &dict<Key, Val>::get(const Key &key) const{
+ BOOST_FOREACH(const pair_t &p, _map){
+ if (p.first == key) return p.second;
+ }
+ throw key_not_found<Key, Val>(key);
+ }
+
+ template <typename Key, typename Val>
+ void dict<Key, Val>::set(const Key &key, const Val &val){
+ (*this)[key] = val;
}
template <typename Key, typename Val>
diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp
index 366efb1f3..f0d0e1c0b 100644
--- a/host/include/uhd/types/ranges.hpp
+++ b/host/include/uhd/types/ranges.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -22,7 +22,6 @@
#include <uhd/utils/pimpl.hpp>
#include <string>
#include <vector>
-#include <string>
namespace uhd{
@@ -30,14 +29,15 @@ namespace uhd{
* A range object describes a set of discrete values of the form:
* y = start + step*n, where n is an integer between 0 and (stop - start)/step
*/
- template <typename T> class range_t{
+ class UHD_API range_t{
public:
+
/*!
* Create a range from a single value.
* The step size will be taken as zero.
* \param value the only possible value in this range
*/
- range_t(const T &value = T(0));
+ range_t(double value = 0);
/*!
* Create a range from a full set of values.
@@ -46,28 +46,27 @@ namespace uhd{
* \param stop the maximum value for this range
* \param step the step size for this range
*/
- range_t(const T &start, const T &stop, const T &step = T(0));
+ range_t(double start, double stop, double step = 0);
//! Get the start value for this range.
- const T start(void) const;
+ double start(void) const;
//! Get the stop value for this range.
- const T stop(void) const;
+ double stop(void) const;
//! Get the step value for this range.
- const T step(void) const;
+ double step(void) const;
//! Convert this range to a printable string
const std::string to_pp_string(void) const;
- private:
- UHD_PIMPL_DECL(impl) _impl;
+ private: UHD_PIMPL_DECL(impl) _impl;
};
/*!
* A meta-range object holds a list of individual ranges.
*/
- template <typename T> struct meta_range_t : std::vector<range_t<T> >{
+ struct UHD_API meta_range_t : std::vector<range_t>{
//! A default constructor for an empty meta-range
meta_range_t(void);
@@ -79,7 +78,8 @@ namespace uhd{
* \param last the end iterator
*/
template <typename InputIterator>
- meta_range_t(InputIterator first, InputIterator last);
+ meta_range_t(InputIterator first, InputIterator last):
+ std::vector<range_t>(first, last){ /* NOP */ }
/*!
* A convenience constructor for a single range.
@@ -88,16 +88,16 @@ namespace uhd{
* \param stop the maximum value for this range
* \param step the step size for this range
*/
- meta_range_t(const T &start, const T &stop, const T &step = T(0));
+ meta_range_t(double start, double stop, double step = 0);
//! Get the overall start value for this meta-range.
- const T start(void) const;
+ double start(void) const;
//! Get the overall stop value for this meta-range.
- const T stop(void) const;
+ double stop(void) const;
//! Get the overall step value for this meta-range.
- const T step(void) const;
+ double step(void) const;
/*!
* Clip the target value to a possible range value.
@@ -105,22 +105,16 @@ namespace uhd{
* \param clip_step if true, clip to steps as well
* \return a value that is in one of the ranges
*/
- const T clip(const T &value, bool clip_step = false) const;
+ double clip(double value, bool clip_step = false) const;
//! Convert this meta-range to a printable string
const std::string to_pp_string(void) const;
};
- //!typedef for a gain meta-range
- typedef meta_range_t<float> gain_range_t;
-
- //!typedef for a frequency meta-range
- typedef meta_range_t<double> freq_range_t;
-
+ typedef meta_range_t gain_range_t;
+ typedef meta_range_t freq_range_t;
} //namespace uhd
-#include <uhd/types/ranges.ipp>
-
#endif /* INCLUDED_UHD_TYPES_RANGES_HPP */
diff --git a/host/include/uhd/types/ranges.ipp b/host/include/uhd/types/ranges.ipp
deleted file mode 100644
index 944ada51f..000000000
--- a/host/include/uhd/types/ranges.ipp
+++ /dev/null
@@ -1,188 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_UHD_TYPES_RANGES_IPP
-#define INCLUDED_UHD_TYPES_RANGES_IPP
-
-#include <boost/math/special_functions/round.hpp>
-#include <boost/foreach.hpp>
-#include <algorithm>
-#include <stdexcept>
-#include <sstream>
-
-namespace uhd{
-
- /*******************************************************************
- * range_t implementation code
- ******************************************************************/
- template <typename T> struct range_t<T>::impl{
- impl(const T &start, const T &stop, const T &step):
- start(start), stop(stop), step(step)
- {
- /* NOP */
- }
- const T start, stop, step;
- };
-
- template <typename T> range_t<T>::range_t(const T &value):
- _impl(UHD_PIMPL_MAKE(impl, (value, value, T(0))))
- {
- /* NOP */
- }
-
- template <typename T> range_t<T>::range_t(
- const T &start, const T &stop, const T &step
- ):
- _impl(UHD_PIMPL_MAKE(impl, (start, stop, step)))
- {
- if (stop < start){
- throw std::invalid_argument("cannot make range where stop < start");
- }
- }
-
- template <typename T> const T range_t<T>::start(void) const{
- return _impl->start;
- }
-
- template <typename T> const T range_t<T>::stop(void) const{
- return _impl->stop;
- }
-
- template <typename T> const T range_t<T>::step(void) const{
- return _impl->step;
- }
-
- template <typename T> const std::string range_t<T>::to_pp_string(void) const{
- std::stringstream ss;
- ss << "(" << this->start();
- if (this->start() != this->stop()) ss << ", " << this->stop();
- if (this->step() != T(0)) ss << ", " << this->step();
- ss << ")";
- return ss.str();
- }
-
- /*******************************************************************
- * meta_range_t implementation code
- ******************************************************************/
-
- namespace /*anon*/{
- template <typename T> inline
- void check_meta_range_monotonic(const meta_range_t<T> &mr){
- if (mr.empty()){
- throw std::runtime_error("meta-range cannot be empty");
- }
- for (size_t i = 1; i < mr.size(); i++){
- if (mr.at(i).start() < mr.at(i-1).stop()){
- throw std::runtime_error("meta-range is not monotonic");
- }
- }
- }
- } //namespace /*anon*/
-
-
- template <typename T> meta_range_t<T>::meta_range_t(void){
- /* NOP */
- }
-
- template <typename T> template <typename InputIterator>
- meta_range_t<T>::meta_range_t(
- InputIterator first, InputIterator last
- ):
- std::vector<range_t<T> >(first, last)
- {
- /* NOP */
- }
-
- template <typename T> meta_range_t<T>::meta_range_t(
- const T &start, const T &stop, const T &step
- ):
- std::vector<range_t<T> > (1, range_t<T>(start, stop, step))
- {
- /* NOP */
- }
-
- template <typename T> const T meta_range_t<T>::start(void) const{
- check_meta_range_monotonic(*this);
- T min_start = this->front().start();
- BOOST_FOREACH(const range_t<T> &r, (*this)){
- min_start = std::min(min_start, r.start());
- }
- return min_start;
- }
-
- template <typename T> const T meta_range_t<T>::stop(void) const{
- check_meta_range_monotonic(*this);
- T max_stop = this->front().stop();
- BOOST_FOREACH(const range_t<T> &r, (*this)){
- max_stop = std::max(max_stop, r.stop());
- }
- return max_stop;
- }
-
- template <typename T> const T meta_range_t<T>::step(void) const{
- check_meta_range_monotonic(*this);
- std::vector<T> non_zero_steps;
- range_t<T> last = this->front();
- BOOST_FOREACH(const range_t<T> &r, (*this)){
- //steps at each range
- if (r.step() > T(0)) non_zero_steps.push_back(r.step());
- //and steps in-between ranges
- T ibtw_step = r.start() - last.stop();
- if (ibtw_step > T(0)) non_zero_steps.push_back(ibtw_step);
- //store ref to last
- last = r;
- }
- if (non_zero_steps.empty()) return T(0); //all zero steps, its zero...
- return *std::min_element(non_zero_steps.begin(), non_zero_steps.end());
- }
-
- template <typename T> const T meta_range_t<T>::clip(
- const T &value, bool clip_step
- ) const{
- check_meta_range_monotonic(*this);
- T last_stop = this->front().stop();
- BOOST_FOREACH(const range_t<T> &r, (*this)){
- //in-between ranges, clip to nearest
- if (value < r.start()){
- return (std::abs(value - r.start()) < std::abs(value - last_stop))?
- r.start() : last_stop;
- }
- //in this range, clip here
- if (value <= r.stop()){
- if (not clip_step or r.step() == T(0)) return value;
- return boost::math::round((value - r.start())/r.step())*r.step() + r.start();
- }
- //continue on to the next range
- last_stop = r.stop();
- }
- return last_stop;
- }
-
- template <typename T> const std::string meta_range_t<T>::to_pp_string(void) const{
- std::stringstream ss;
- BOOST_FOREACH(const range_t<T> &r, (*this)){
- ss << r.to_pp_string() << std::endl;
- }
- return ss.str();
- }
-
- UHD_EXIM_TMPL template struct UHD_API meta_range_t<float>;
- UHD_EXIM_TMPL template struct UHD_API meta_range_t<double>;
-
-} //namespace uhd
-
-#endif /* INCLUDED_UHD_TYPES_RANGES_IPP */
diff --git a/host/include/uhd/types/sensors.hpp b/host/include/uhd/types/sensors.hpp
new file mode 100644
index 000000000..6f003bb40
--- /dev/null
+++ b/host/include/uhd/types/sensors.hpp
@@ -0,0 +1,131 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#ifndef INCLUDED_UHD_TYPES_SENSORS_HPP
+#define INCLUDED_UHD_TYPES_SENSORS_HPP
+
+#include <uhd/config.hpp>
+#include <string>
+
+namespace uhd{
+
+ /*!
+ * A sensor value stores a sensor reading as a string with unit and data type.
+ * The sensor value class can be used in the following way:
+ *
+ * sensor_value_t ref_lock_sensor("Reference", my_lock, "unlocked", "locked");
+ * std::cout << ref_lock_sensor.to_pp_string() << std::endl;
+ * //prints Reference: locked
+ *
+ * sensor_value_t temp_sensor("Temperature", my_temp, "C");
+ * std::cout << temp_sensor.to_pp_string() << std::endl;
+ * //prints Temperature: 38.5 C
+ */
+ struct UHD_API sensor_value_t{
+
+ //! typedef for the signed integer type
+ typedef signed int_type;
+
+ //! typedef for the real number type
+ typedef double real_type;
+
+ /*!
+ * Create a sensor value from a boolean.
+ * \param name the name of the sensor
+ * \param value the value true or false
+ * \param ufalse the unit string when value is false
+ * \param utrue the unit string when value is true
+ */
+ sensor_value_t(
+ const std::string &name,
+ bool value,
+ const std::string &ufalse,
+ const std::string &utrue
+ );
+
+ /*!
+ * Create a sensor value from an integer.
+ * \param name the name of the sensor
+ * \param value the signed integer value
+ * \param unit the associated unit type
+ * \param formatter the formatter string
+ */
+ sensor_value_t(
+ const std::string &name,
+ int_type value,
+ const std::string &unit,
+ const std::string &formatter = "%d"
+ );
+
+ /*!
+ * Create a sensor value from a real number.
+ * \param name the name of the sensor
+ * \param value the real number value
+ * \param unit the associated unit type
+ * \param formatter the formatter string
+ */
+ sensor_value_t(
+ const std::string &name,
+ real_type value,
+ const std::string &unit,
+ const std::string &formatter = "%f"
+ );
+
+ /*!
+ * Create a sensor value from a string.
+ * \param name the name of the sensor
+ * \param value the real number value
+ * \param unit the associated unit type
+ */
+ sensor_value_t(
+ const std::string &name,
+ const std::string &value,
+ const std::string &unit
+ );
+
+ //! The name of the sensor value
+ const std::string name;
+
+ /*!
+ * The sensor value as a string.
+ * For integer and real number types, this will be the output of the formatter.
+ * For boolean types, the value will be the string literal "true" or "false".
+ */
+ const std::string value;
+
+ /*!
+ * The sensor value's unit type.
+ * For boolean types, this will be the one of the two units
+ * depending upon the value of the boolean true or false.
+ */
+ const std::string unit;
+
+ //! The data type of the value
+ const enum{
+ BOOLEAN = 'b',
+ INTEGER = 'i',
+ REALNUM = 'r',
+ STRING = 's'
+ } type;
+
+ //! Convert this sensor value into a printable string
+ std::string to_pp_string(void) const;
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_SENSORS_HPP */
diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt
index c8d7281d3..f60b35e59 100644
--- a/host/include/uhd/usrp/CMakeLists.txt
+++ b/host/include/uhd/usrp/CMakeLists.txt
@@ -34,6 +34,7 @@ INSTALL(FILES
### utilities ###
dsp_utils.hpp
+ gps_ctrl.hpp
mboard_eeprom.hpp
misc_utils.hpp
subdev_spec.hpp
diff --git a/host/include/uhd/usrp/codec_props.hpp b/host/include/uhd/usrp/codec_props.hpp
index ab09b1703..5d0a2913c 100644
--- a/host/include/uhd/usrp/codec_props.hpp
+++ b/host/include/uhd/usrp/codec_props.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -30,8 +30,8 @@ namespace uhd{ namespace usrp{
enum codec_prop_t{
CODEC_PROP_NAME = 'n', //ro, std::string
CODEC_PROP_OTHERS = 'o', //ro, prop_names_t
- CODEC_PROP_GAIN_I = 'i', //rw, float
- CODEC_PROP_GAIN_Q = 'q', //rw, float
+ CODEC_PROP_GAIN_I = 'i', //rw, double
+ CODEC_PROP_GAIN_Q = 'q', //rw, double
CODEC_PROP_GAIN_RANGE = 'r', //ro, gain_range_t
CODEC_PROP_GAIN_NAMES = 'G' //ro, prop_names_t
};
diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp
index b04756c47..cfb727017 100644
--- a/host/include/uhd/usrp/dboard_iface.hpp
+++ b/host/include/uhd/usrp/dboard_iface.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -102,7 +102,7 @@ public:
* \param which_dac the dac index 0, 1, 2, 3...
* \param value the value in volts
*/
- virtual void write_aux_dac(unit_t unit, aux_dac_t which_dac, float value) = 0;
+ virtual void write_aux_dac(unit_t unit, aux_dac_t which_dac, double value) = 0;
/*!
* Read from an aux adc.
@@ -111,7 +111,7 @@ public:
* \param which_adc the adc index 0, 1, 2, 3...
* \return the value in volts
*/
- virtual float read_aux_adc(unit_t unit, aux_adc_t which_adc) = 0;
+ virtual double read_aux_adc(unit_t unit, aux_adc_t which_adc) = 0;
/*!
* Set a daughterboard output pin control source.
@@ -191,8 +191,6 @@ public:
*/
virtual boost::uint16_t get_gpio_out(unit_t unit);
- UHD_DEPRECATED void write_gpio(unit_t unit, boost::uint16_t value){set_gpio_out(unit, value);}
-
/*!
* Setup the GPIO debug mux.
*
diff --git a/host/lib/usrp/usrp2/gps_ctrl.hpp b/host/include/uhd/usrp/gps_ctrl.hpp
index 5936a6fb6..74f984ee0 100644
--- a/host/lib/usrp/usrp2/gps_ctrl.hpp
+++ b/host/include/uhd/usrp/gps_ctrl.hpp
@@ -18,21 +18,24 @@
#ifndef INCLUDED_GPS_CTRL_HPP
#define INCLUDED_GPS_CTRL_HPP
-#include "usrp2_iface.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
+#include <boost/function.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
using namespace boost::posix_time;
-class usrp2_gps_ctrl : boost::noncopyable{
+typedef boost::function<void(std::string)> gps_send_fn_t;
+typedef boost::function<std::string(void)> gps_recv_fn_t;
+
+class gps_ctrl : boost::noncopyable{
public:
- typedef boost::shared_ptr<usrp2_gps_ctrl> sptr;
+ typedef boost::shared_ptr<gps_ctrl> sptr;
/*!
* Make a GPS config for Jackson Labs or generic NMEA GPS devices
*/
- static sptr make(usrp2_iface::sptr iface);
+ static sptr make(gps_send_fn_t, gps_recv_fn_t);
/*!
* Get the current GPS time and date
@@ -50,4 +53,4 @@ public:
};
-#endif /* INCLUDED_CLOCK_CTRL_HPP */
+#endif /* INCLUDED_GPS_CTRL_HPP */
diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp
index df94d1678..c82bfc21a 100644
--- a/host/include/uhd/usrp/mboard_props.hpp
+++ b/host/include/uhd/usrp/mboard_props.hpp
@@ -43,7 +43,7 @@ namespace uhd{ namespace usrp{
MBOARD_PROP_TX_SUBDEV_SPEC = 'R', //rw, subdev_spec_t
MBOARD_PROP_CLOCK_CONFIG = 'C', //rw, clock_config_t
MBOARD_PROP_TIME_NOW = 't', //rw, time_spec_t
- MBOARD_PROP_TIME_NEXT_PPS = 'T', //wo, time_spec_t
+ MBOARD_PROP_TIME_PPS = 'T', //wo, time_spec_t
MBOARD_PROP_STREAM_CMD = 's', //wo, stream_cmd_t
MBOARD_PROP_EEPROM_MAP = 'M' //wr, mboard_eeprom_t::sptr
};
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp
index 98ba07fc0..b603d4324 100644
--- a/host/include/uhd/usrp/multi_usrp.hpp
+++ b/host/include/uhd/usrp/multi_usrp.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -51,7 +51,8 @@ namespace uhd{ namespace usrp{
*
* //create a multi_usrp with two boards in the configuration
* device_addr_t dev_addr;
- * dev_addr["addr"] = "192.168.10.2 192.168.10.3";
+ * dev_addr["addr0"] = "192.168.10.2"
+ * dev_addr["addr1"] = "192.168.10.3";
* multi_usrp::sptr dev = multi_usrp::make(dev_addr);
*
* //set the board on 10.2 to use the A RX subdevice (RX channel 0)
@@ -108,12 +109,18 @@ public:
virtual std::string get_mboard_name(size_t mboard) = 0;
/*!
- * Gets the current time in the usrp time registers.
+ * Get the current time in the usrp time registers.
* \return a timespec representing current usrp time
*/
virtual time_spec_t get_time_now(void) = 0;
/*!
+ * Get the time when the last pps pulse occured.
+ * \return a timespec representing the last pps
+ */
+ virtual time_spec_t get_time_last_pps(void) = 0;
+
+ /*!
* Set the time registers on the usrp at the next pps tick.
* The values will not be latched in until the pulse occurs.
* It is recommended that the user sleep(1) after calling to ensure
@@ -133,14 +140,13 @@ public:
* Ex: Host machine is not attached to serial port of GPSDO
* and can therefore not query the GPSDO for the PPS edge.
*
- * This is a 3-step process, and will take at most 3 seconds to complete.
+ * This is a 2-step process, and will take at most 2 seconds to complete.
* Upon completion, the times will be synchronized to the time provided.
*
- * - Step1: set the time at the next pps (potential race condition)
- * - Step2: wait for the seconds to rollover to catch the pps edge
- * - Step3: set the time at the next pps (synchronous for all boards)
+ * - Step1: wait for the last pps time to transition to catch the edge
+ * - Step2: set the time at the next pps (synchronous for all boards)
*
- * \param time_spec the time to latch into the usrp device
+ * \param time_spec the time to latch at the next pps after catching the edge
*/
virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
@@ -251,10 +257,10 @@ public:
* \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_gain(float gain, const std::string &name, size_t chan) = 0;
+ virtual void set_rx_gain(double gain, const std::string &name, size_t chan) = 0;
//! A convenience wrapper for setting overall RX gain
- void set_rx_gain(float gain, size_t chan){
+ void set_rx_gain(double gain, size_t chan){
return this->set_rx_gain(gain, ALL_GAINS, chan);
}
@@ -265,10 +271,10 @@ public:
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_rx_gain(const std::string &name, size_t chan) = 0;
+ virtual double get_rx_gain(const std::string &name, size_t chan) = 0;
//! A convenience wrapper for getting overall RX gain
- float get_rx_gain(size_t chan){
+ double get_rx_gain(size_t chan){
return this->get_rx_gain(ALL_GAINS, chan);
}
@@ -342,7 +348,7 @@ public:
* \return the rssi in dB
* \throw exception if RSSI readback not supported
*/
- virtual float read_rssi(size_t chan) = 0;
+ virtual double read_rssi(size_t chan) = 0;
/*!
* Get the dboard interface object for the RX subdevice.
@@ -430,10 +436,10 @@ public:
* \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_gain(float gain, const std::string &name, size_t chan) = 0;
+ virtual void set_tx_gain(double gain, const std::string &name, size_t chan) = 0;
//! A convenience wrapper for setting overall TX gain
- void set_tx_gain(float gain, size_t chan){
+ void set_tx_gain(double gain, size_t chan){
return this->set_tx_gain(gain, ALL_GAINS, chan);
}
@@ -444,10 +450,10 @@ public:
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_tx_gain(const std::string &name, size_t chan) = 0;
+ virtual double get_tx_gain(const std::string &name, size_t chan) = 0;
//! A convenience wrapper for getting overall TX gain
- float get_tx_gain(size_t chan){
+ double get_tx_gain(size_t chan){
return this->get_tx_gain(ALL_GAINS, chan);
}
diff --git a/host/include/uhd/usrp/single_usrp.hpp b/host/include/uhd/usrp/single_usrp.hpp
index 26303fe10..d80999300 100644
--- a/host/include/uhd/usrp/single_usrp.hpp
+++ b/host/include/uhd/usrp/single_usrp.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -77,12 +77,18 @@ public:
virtual std::string get_mboard_name(void) = 0;
/*!
- * Gets the current time in the usrp time registers.
+ * Get the current time in the usrp time registers.
* \return a timespec representing current usrp time
*/
virtual time_spec_t get_time_now(void) = 0;
/*!
+ * Get the time when the last pps pulse occured.
+ * \return a timespec representing the last pps
+ */
+ virtual time_spec_t get_time_last_pps(void) = 0;
+
+ /*!
* Sets the time registers on the usrp immediately.
* \param time_spec the time to latch into the usrp device
*/
@@ -184,10 +190,10 @@ public:
* \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_rx_gain(float gain, const std::string &name, size_t chan = 0) = 0;
+ virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
//! A convenience wrapper for setting overall RX gain
- void set_rx_gain(float gain, size_t chan = 0){
+ void set_rx_gain(double gain, size_t chan = 0){
return this->set_rx_gain(gain, ALL_GAINS, chan);
}
@@ -198,10 +204,10 @@ public:
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_rx_gain(const std::string &name, size_t chan = 0) = 0;
+ virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
//! A convenience wrapper for getting overall RX gain
- float get_rx_gain(size_t chan = 0){
+ double get_rx_gain(size_t chan = 0){
return this->get_rx_gain(ALL_GAINS, chan);
}
@@ -275,7 +281,7 @@ public:
* \return the rssi in dB
* \throw exception if RSSI readback not supported
*/
- virtual float read_rssi(size_t chan = 0) = 0;
+ virtual double read_rssi(size_t chan = 0) = 0;
/*!
* Get the dboard interface object for the RX subdevice.
@@ -353,10 +359,10 @@ public:
* \param name the name of the gain element
* \param chan the channel index 0 to N-1
*/
- virtual void set_tx_gain(float gain, const std::string &name, size_t chan = 0) = 0;
+ virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
//! A convenience wrapper for setting overall TX gain
- void set_tx_gain(float gain, size_t chan = 0){
+ void set_tx_gain(double gain, size_t chan = 0){
return this->set_tx_gain(gain, ALL_GAINS, chan);
}
@@ -367,10 +373,10 @@ public:
* \param chan the channel index 0 to N-1
* \return the gain in dB
*/
- virtual float get_tx_gain(const std::string &name, size_t chan = 0) = 0;
+ virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
//! A convenience wrapper for getting overall TX gain
- float get_tx_gain(size_t chan = 0){
+ double get_tx_gain(size_t chan = 0){
return this->get_tx_gain(ALL_GAINS, chan);
}
diff --git a/host/include/uhd/usrp/subdev_props.hpp b/host/include/uhd/usrp/subdev_props.hpp
index 8f096ffe4..8d05f4c27 100644
--- a/host/include/uhd/usrp/subdev_props.hpp
+++ b/host/include/uhd/usrp/subdev_props.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -44,7 +44,7 @@ namespace uhd{ namespace usrp{
enum subdev_prop_t{
SUBDEV_PROP_NAME = 'n', //ro, std::string
SUBDEV_PROP_OTHERS = 'o', //ro, prop_names_t
- SUBDEV_PROP_GAIN = 'g', //rw, float
+ SUBDEV_PROP_GAIN = 'g', //rw, double
SUBDEV_PROP_GAIN_RANGE = 'r', //ro, gain_range_t
SUBDEV_PROP_GAIN_NAMES = 'G', //ro, prop_names_t
SUBDEV_PROP_FREQ = 'f', //rw, double
@@ -55,7 +55,7 @@ namespace uhd{ namespace usrp{
SUBDEV_PROP_CONNECTION = 'c', //ro, subdev_conn_t
SUBDEV_PROP_ENABLED = 'e', //rw, bool
SUBDEV_PROP_USE_LO_OFFSET = 'l', //ro, bool
- SUBDEV_PROP_RSSI = 'R', //ro, float
+ SUBDEV_PROP_RSSI = 'R', //ro, double
SUBDEV_PROP_BANDWIDTH = 'B' //rw, double
};
diff --git a/host/include/uhd/utils/algorithm.hpp b/host/include/uhd/utils/algorithm.hpp
index 53c571e4e..5e2230371 100644
--- a/host/include/uhd/utils/algorithm.hpp
+++ b/host/include/uhd/utils/algorithm.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -22,9 +22,6 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
-#include <boost/algorithm/string.hpp>
-#include <vector>
-#include <string>
/*! \file algorithm.hpp
* Useful templated functions and classes that I like to pretend are part of stl.
@@ -33,24 +30,6 @@
namespace std{
/*!
- * Split a string at the separation characters.
- * \param string the string to split
- * \param sep the separator characters
- * \return a range of strings
- */
- inline std::vector<std::string> split_string(
- const std::string &string, const std::string &sep = "\t "
- ){
- std::vector<std::string> strings;
- if (not string.empty()) boost::split(
- // do not split an empty string:
- // let me tell you about the time when boost::split segfaulted...
- strings, string, boost::is_any_of(sep)
- );
- return strings;
- }
-
- /*!
* A wrapper around std::copy that takes ranges instead of iterators.
*
* Copy the elements of the source range into the destination range.
@@ -164,8 +143,12 @@ namespace std{
* \param bound2 the upper or lower bound
* \return the value clipped at the bounds
*/
- template<typename T> inline T clip(T val, T bound1, T bound2){
- return std::min(std::max(val, std::min(bound1, bound2)), std::max(bound1, bound2));
+ template<typename T> inline T clip(const T &val, const T &bound1, const T &bound2){
+ const T minimum = std::min(bound1, bound2);
+ if (val < minimum) return minimum;
+ const T maximum = std::max(bound1, bound2);
+ if (val > maximum) return maximum;
+ return val;
}
}//namespace std
diff --git a/host/include/uhd/utils/gain_group.hpp b/host/include/uhd/utils/gain_group.hpp
index c863248ce..7ef7bdcf5 100644
--- a/host/include/uhd/utils/gain_group.hpp
+++ b/host/include/uhd/utils/gain_group.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -33,8 +33,8 @@ namespace uhd{
*/
struct UHD_API gain_fcns_t{
boost::function<gain_range_t(void)> get_range;
- boost::function<float(void)> get_value;
- boost::function<void(float)> set_value;
+ boost::function<double(void)> get_value;
+ boost::function<void(double)> set_value;
};
class UHD_API gain_group : boost::noncopyable{
@@ -56,7 +56,7 @@ public:
* \param name name of the gain element (optional)
* \return a gain value of the element or all elements
*/
- virtual float get_value(const std::string &name = "") = 0;
+ virtual double get_value(const std::string &name = "") = 0;
/*!
* Set the gain value for the gain element specified by name.
@@ -66,7 +66,7 @@ public:
* \param gain the gain to set for the lement or across the group
* \param name name of the gain element (optional)
*/
- virtual void set_value(float gain, const std::string &name = "") = 0;
+ virtual void set_value(double gain, const std::string &name = "") = 0;
/*!
* Get a list of names of registered gain elements.
diff --git a/host/include/uhd/utils/static.hpp b/host/include/uhd/utils/static.hpp
index c61f10884..82cdf36d9 100644
--- a/host/include/uhd/utils/static.hpp
+++ b/host/include/uhd/utils/static.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -30,8 +30,17 @@
/*!
* Defines a static code block that will be called before main()
- * \param _x the name of the defined struct (must be unique in file)
+ * The static block will catch and print exceptions to std error.
+ * \param _x the unique name of the fixture (unique per source)
*/
-#define UHD_STATIC_BLOCK(_x) static struct _x{_x();}_x;_x::_x()
+#define UHD_STATIC_BLOCK(_x) \
+ void _x(void); \
+ static _uhd_static_fixture _x##_fixture(&_x, #_x); \
+ void _x(void)
+
+//! Helper for static block, constructor calls function
+struct UHD_API _uhd_static_fixture{
+ _uhd_static_fixture(void (*)(void), const char *);
+};
#endif /* INCLUDED_UHD_UTILS_STATIC_HPP */
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index 498841561..d2845ffda 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -16,27 +16,6 @@
#
########################################################################
-# Check Python Modules
-########################################################################
-INCLUDE(UHDPython)
-
-PYTHON_CHECK_MODULE(
- "Python version 2.6 or greater"
- "platform" "platform.python_version() >= '2.6'"
- HAVE_PYTHON_PLAT_MIN_VERSION
-)
-
-PYTHON_CHECK_MODULE(
- "Cheetah templates 2.0.0 or greater"
- "Cheetah" "Cheetah.Version >= '2.0.0'"
- HAVE_PYTHON_MODULE_CHEETAH
-)
-
-IF(NOT HAVE_PYTHON_PLAT_MIN_VERSION OR NOT HAVE_PYTHON_MODULE_CHEETAH)
- MESSAGE(FATAL_ERROR "Error: python requirements not met for the build system.")
-ENDIF(NOT HAVE_PYTHON_PLAT_MIN_VERSION OR NOT HAVE_PYTHON_MODULE_CHEETAH)
-
-########################################################################
# Helpful Macros
########################################################################
MACRO(LIBUHD_APPEND_SOURCES)
@@ -89,6 +68,8 @@ ENDMACRO(INCLUDE_SUBDIRECTORY)
# Include subdirectories (different than add)
########################################################################
INCLUDE_SUBDIRECTORY(ic_reg_maps)
+INCLUDE_SUBDIRECTORY(types)
+INCLUDE_SUBDIRECTORY(convert)
INCLUDE_SUBDIRECTORY(transport)
INCLUDE_SUBDIRECTORY(usrp)
INCLUDE_SUBDIRECTORY(utils)
@@ -116,7 +97,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_BINARY_DIR}/constants.hpp
${CMAKE_CURRENT_SOURCE_DIR}/device.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/types.cpp
${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wax.cpp
)
@@ -127,6 +107,7 @@ LIBUHD_APPEND_SOURCES(
ADD_LIBRARY(uhd SHARED ${libuhd_sources})
TARGET_LINK_LIBRARIES(uhd ${Boost_LIBRARIES} ${libuhd_libs})
SET_TARGET_PROPERTIES(uhd PROPERTIES DEFINE_SYMBOL "UHD_DLL_EXPORTS")
+SET_TARGET_PROPERTIES(uhd PROPERTIES SOVERSION ${UHD_VERSION_MAJOR})
INSTALL(TARGETS uhd
LIBRARY DESTINATION ${LIBRARY_DIR} # .so file
diff --git a/host/lib/convert/CMakeLists.txt b/host/lib/convert/CMakeLists.txt
new file mode 100644
index 000000000..a9f977cdc
--- /dev/null
+++ b/host/lib/convert/CMakeLists.txt
@@ -0,0 +1,65 @@
+#
+# Copyright 2011 Ettus Research LLC
+#
+# 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/>.
+#
+
+########################################################################
+# This file included, use CMake directory variables
+########################################################################
+INCLUDE(CheckIncludeFileCXX)
+MESSAGE(STATUS "")
+
+########################################################################
+# Check for SIMD headers
+########################################################################
+CHECK_INCLUDE_FILE_CXX(emmintrin.h HAVE_EMMINTRIN_H)
+IF(HAVE_EMMINTRIN_H)
+ LIBUHD_APPEND_SOURCES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_sse2.cpp
+ )
+ENDIF(HAVE_EMMINTRIN_H)
+
+CHECK_INCLUDE_FILE_CXX(arm_neon.h HAVE_ARM_NEON_H)
+IF(HAVE_ARM_NEON_H)
+ LIBUHD_APPEND_SOURCES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_neon.cpp
+ )
+ENDIF(HAVE_ARM_NEON_H)
+
+########################################################################
+# Convert types generation
+########################################################################
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+
+LIBUHD_PYTHON_GEN_SOURCE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gen_convert_pred.py
+ ${CMAKE_CURRENT_BINARY_DIR}/convert_pred.hpp
+)
+
+INCLUDE(AddFileDependencies)
+ADD_FILE_DEPENDENCIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/convert_impl.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/convert_pred.hpp
+)
+
+LIBUHD_PYTHON_GEN_SOURCE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gen_convert_general.py
+ ${CMAKE_CURRENT_BINARY_DIR}/convert_general.cpp
+)
+
+LIBUHD_APPEND_SOURCES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/convert_impl.cpp
+)
diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp
new file mode 100644
index 000000000..1a653a56f
--- /dev/null
+++ b/host/lib/convert/convert_common.hpp
@@ -0,0 +1,90 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#ifndef INCLUDED_LIBUHD_CONVERT_COMMON_HPP
+#define INCLUDED_LIBUHD_CONVERT_COMMON_HPP
+
+#include <uhd/convert.hpp>
+#include <uhd/utils/static.hpp>
+#include <boost/cstdint.hpp>
+#include <complex>
+
+#define DECLARE_CONVERTER(fcn, prio) \
+ static void fcn( \
+ uhd::convert::input_type &inputs, \
+ uhd::convert::output_type &outputs, \
+ size_t nsamps \
+ ); \
+ UHD_STATIC_BLOCK(register_##fcn##_##prio){ \
+ uhd::convert::register_converter(#fcn, fcn, prio); \
+ } \
+ static void fcn( \
+ uhd::convert::input_type &inputs, \
+ uhd::convert::output_type &outputs, \
+ size_t nsamps \
+ )
+
+/***********************************************************************
+ * Typedefs
+ **********************************************************************/
+typedef std::complex<float> fc32_t;
+typedef std::complex<boost::int16_t> sc16_t;
+typedef boost::uint32_t item32_t;
+
+/***********************************************************************
+ * Convert complex short buffer to items32
+ **********************************************************************/
+static UHD_INLINE item32_t sc16_to_item32(sc16_t num){
+ boost::uint16_t real = num.real();
+ boost::uint16_t imag = num.imag();
+ return (item32_t(real) << 16) | (item32_t(imag) << 0);
+}
+
+/***********************************************************************
+ * Convert items32 buffer to complex short
+ **********************************************************************/
+static UHD_INLINE sc16_t item32_to_sc16(item32_t item){
+ return sc16_t(
+ boost::int16_t(item >> 16),
+ boost::int16_t(item >> 0)
+ );
+}
+
+/***********************************************************************
+ * Convert complex float buffer to items32 (no swap)
+ **********************************************************************/
+static const float shorts_per_float = float(32767);
+
+static UHD_INLINE item32_t fc32_to_item32(fc32_t num){
+ boost::uint16_t real = boost::int16_t(num.real()*shorts_per_float);
+ boost::uint16_t imag = boost::int16_t(num.imag()*shorts_per_float);
+ return (item32_t(real) << 16) | (item32_t(imag) << 0);
+}
+
+/***********************************************************************
+ * Convert items32 buffer to complex float
+ **********************************************************************/
+static const float floats_per_short = float(1.0/shorts_per_float);
+
+static UHD_INLINE fc32_t item32_to_fc32(item32_t item){
+ return fc32_t(
+ float(boost::int16_t(item >> 16)*floats_per_short),
+ float(boost::int16_t(item >> 0)*floats_per_short)
+ );
+}
+
+#endif /* INCLUDED_LIBUHD_CONVERT_COMMON_HPP */
diff --git a/host/lib/convert/convert_impl.cpp b/host/lib/convert/convert_impl.cpp
new file mode 100644
index 000000000..6a5a1465d
--- /dev/null
+++ b/host/lib/convert/convert_impl.cpp
@@ -0,0 +1,111 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/convert.hpp>
+#include <uhd/utils/static.hpp>
+#include <uhd/utils/exception.hpp>
+#include <iostream>
+
+using namespace uhd;
+
+#include "convert_pred.hpp"
+
+static const bool debug = false;
+
+/***********************************************************************
+ * Define types for the function tables
+ **********************************************************************/
+struct fcn_table_entry_type{
+ convert::priority_type prio;
+ convert::function_type fcn;
+ fcn_table_entry_type(void)
+ : prio(convert::PRIORITY_EMPTY), fcn(NULL){
+ /* NOP */
+ }
+};
+typedef std::vector<fcn_table_entry_type> fcn_table_type;
+
+/***********************************************************************
+ * Setup the table registry
+ **********************************************************************/
+UHD_SINGLETON_FCN(fcn_table_type, get_cpu_to_otw_table);
+UHD_SINGLETON_FCN(fcn_table_type, get_otw_to_cpu_table);
+
+fcn_table_type &get_table(dir_type dir){
+ switch(dir){
+ case DIR_OTW_TO_CPU: return get_otw_to_cpu_table();
+ case DIR_CPU_TO_OTW: return get_cpu_to_otw_table();
+ }
+ UHD_THROW_INVALID_CODE_PATH();
+}
+
+/***********************************************************************
+ * The registry functions
+ **********************************************************************/
+void uhd::convert::register_converter(
+ const std::string &markup,
+ function_type fcn,
+ priority_type prio
+){
+ //extract the predicate and direction from the markup
+ dir_type dir;
+ pred_type pred = make_pred(markup, dir);
+
+ //get a reference to the function table
+ fcn_table_type &table = get_table(dir);
+
+ //resize the table so that its at least pred+1
+ if (table.size() <= pred) table.resize(pred+1);
+
+ //register the function if higher priority
+ if (table[pred].prio < prio){
+ table[pred].fcn = fcn;
+ table[pred].prio = prio;
+ }
+
+ //----------------------------------------------------------------//
+ if (debug) std::cout << "register_converter: " << markup << std::endl
+ << " prio: " << prio << std::endl
+ << " pred: " << pred << std::endl
+ << " dir: " << dir << std::endl
+ << std::endl
+ ;
+ //----------------------------------------------------------------//
+}
+
+/***********************************************************************
+ * The converter functions
+ **********************************************************************/
+const convert::function_type &convert::get_converter_cpu_to_otw(
+ const io_type_t &io_type,
+ const otw_type_t &otw_type,
+ size_t num_input_buffs,
+ size_t num_output_buffs
+){
+ pred_type pred = make_pred(io_type, otw_type, num_input_buffs, num_output_buffs);
+ return get_cpu_to_otw_table().at(pred).fcn;
+}
+
+const convert::function_type &convert::get_converter_otw_to_cpu(
+ const io_type_t &io_type,
+ const otw_type_t &otw_type,
+ size_t num_input_buffs,
+ size_t num_output_buffs
+){
+ pred_type pred = make_pred(io_type, otw_type, num_input_buffs, num_output_buffs);
+ return get_otw_to_cpu_table().at(pred).fcn;
+}
diff --git a/host/lib/convert/convert_with_neon.cpp b/host/lib/convert/convert_with_neon.cpp
new file mode 100644
index 000000000..3d677db5b
--- /dev/null
+++ b/host/lib/convert/convert_with_neon.cpp
@@ -0,0 +1,61 @@
+//
+// Copyright 2011-2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include "convert_common.hpp"
+#include <arm_neon.h>
+
+using namespace uhd::convert;
+
+DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){
+ const fc32_t *input = reinterpret_cast<const fc32_t *>(inputs[0]);
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ size_t i;
+
+ float32x4_t Q0 = vdupq_n_f32(shorts_per_float);
+ for (i=0; i < (nsamps & ~0x03); i+=2) {
+ float32x4_t Q1 = vld1q_f32(reinterpret_cast<const float *>(&input[i]));
+ float32x4_t Q2 = vmulq_f32(Q1, Q0);
+ int32x4_t Q3 = vcvtq_s32_f32(Q2);
+ int16x4_t D8 = vmovn_s32(Q3);
+ int16x4_t D9 = vrev32_s16(D8);
+ vst1_s16((reinterpret_cast<int16_t *>(&output[i])), D9);
+ }
+
+ for (; i < nsamps; i++)
+ output[i] = fc32_to_item32(input[i]);
+}
+
+DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ fc32_t *output = reinterpret_cast<fc32_t *>(outputs[0]);
+
+ size_t i;
+
+ float32x4_t Q1 = vdupq_n_f32(floats_per_short);
+ for (i=0; i < (nsamps & ~0x03); i+=2) {
+ int16x4_t D0 = vld1_s16(reinterpret_cast<const int16_t *>(&input[i]));
+ int16x4_t D1 = vrev32_s16(D0);
+ int32x4_t Q2 = vmovl_s16(D1);
+ float32x4_t Q3 = vcvtq_f32_s32(Q2);
+ float32x4_t Q4 = vmulq_f32(Q3, Q1);
+ vst1q_f32((reinterpret_cast<float *>(&output[i])), Q4);
+ }
+
+ for (; i < nsamps; i++)
+ output[i] = item32_to_fc32(input[i]);
+}
diff --git a/host/lib/convert/convert_with_sse2.cpp b/host/lib/convert/convert_with_sse2.cpp
new file mode 100644
index 000000000..96ee9134c
--- /dev/null
+++ b/host/lib/convert/convert_with_sse2.cpp
@@ -0,0 +1,148 @@
+//
+// Copyright 2011-2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include "convert_common.hpp"
+#include <uhd/utils/byteswap.hpp>
+#include <emmintrin.h>
+
+using namespace uhd::convert;
+
+DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){
+ const fc32_t *input = reinterpret_cast<const fc32_t *>(inputs[0]);
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ __m128 scalar = _mm_set_ps1(shorts_per_float);
+
+ //convert blocks of samples with intrinsics
+ size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
+ //load from input
+ __m128 tmplo = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+0));
+ __m128 tmphi = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+2));
+
+ //convert and scale
+ __m128i tmpilo = _mm_cvtps_epi32(_mm_mul_ps(tmplo, scalar));
+ __m128i tmpihi = _mm_cvtps_epi32(_mm_mul_ps(tmphi, scalar));
+
+ //pack + swap 16-bit pairs
+ __m128i tmpi = _mm_packs_epi32(tmpilo, tmpihi);
+ tmpi = _mm_shufflelo_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
+ tmpi = _mm_shufflehi_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
+
+ //store to output
+ _mm_storeu_si128(reinterpret_cast<__m128i *>(output+i), tmpi);
+ }
+
+ //convert remainder
+ for (; i < nsamps; i++){
+ output[i] = fc32_to_item32(input[i]);
+ }
+}
+
+DECLARE_CONVERTER(convert_fc32_1_to_item32_1_bswap, PRIORITY_CUSTOM){
+ const fc32_t *input = reinterpret_cast<const fc32_t *>(inputs[0]);
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ __m128 scalar = _mm_set_ps1(shorts_per_float);
+
+ //convert blocks of samples with intrinsics
+ size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
+ //load from input
+ __m128 tmplo = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+0));
+ __m128 tmphi = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+2));
+
+ //convert and scale
+ __m128i tmpilo = _mm_cvtps_epi32(_mm_mul_ps(tmplo, scalar));
+ __m128i tmpihi = _mm_cvtps_epi32(_mm_mul_ps(tmphi, scalar));
+
+ //pack + byteswap -> byteswap 16 bit words
+ __m128i tmpi = _mm_packs_epi32(tmpilo, tmpihi);
+ tmpi = _mm_or_si128(_mm_srli_epi16(tmpi, 8), _mm_slli_epi16(tmpi, 8));
+
+ //store to output
+ _mm_storeu_si128(reinterpret_cast<__m128i *>(output+i), tmpi);
+ }
+
+ //convert remainder
+ for (; i < nsamps; i++){
+ output[i] = uhd::byteswap(fc32_to_item32(input[i]));
+ }
+}
+
+DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ fc32_t *output = reinterpret_cast<fc32_t *>(outputs[0]);
+
+ __m128 scalar = _mm_set_ps1(floats_per_short/(1 << 16));
+ __m128i zeroi = _mm_setzero_si128();
+
+ //convert blocks of samples with intrinsics
+ size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
+ //load from input
+ __m128i tmpi = _mm_loadu_si128(reinterpret_cast<const __m128i *>(input+i));
+
+ //unpack + swap 16-bit pairs
+ tmpi = _mm_shufflelo_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
+ tmpi = _mm_shufflehi_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
+ __m128i tmpilo = _mm_unpacklo_epi16(zeroi, tmpi); //value in upper 16 bits
+ __m128i tmpihi = _mm_unpackhi_epi16(zeroi, tmpi);
+
+ //convert and scale
+ __m128 tmplo = _mm_mul_ps(_mm_cvtepi32_ps(tmpilo), scalar);
+ __m128 tmphi = _mm_mul_ps(_mm_cvtepi32_ps(tmpihi), scalar);
+
+ //store to output
+ _mm_storeu_ps(reinterpret_cast<float *>(output+i+0), tmplo);
+ _mm_storeu_ps(reinterpret_cast<float *>(output+i+2), tmphi);
+ }
+
+ //convert remainder
+ for (; i < nsamps; i++){
+ output[i] = item32_to_fc32(input[i]);
+ }
+}
+
+DECLARE_CONVERTER(convert_item32_1_to_fc32_1_bswap, PRIORITY_CUSTOM){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ fc32_t *output = reinterpret_cast<fc32_t *>(outputs[0]);
+
+ __m128 scalar = _mm_set_ps1(floats_per_short/(1 << 16));
+ __m128i zeroi = _mm_setzero_si128();
+
+ //convert blocks of samples with intrinsics
+ size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
+ //load from input
+ __m128i tmpi = _mm_loadu_si128(reinterpret_cast<const __m128i *>(input+i));
+
+ //byteswap + unpack -> byteswap 16 bit words
+ tmpi = _mm_or_si128(_mm_srli_epi16(tmpi, 8), _mm_slli_epi16(tmpi, 8));
+ __m128i tmpilo = _mm_unpacklo_epi16(zeroi, tmpi); //value in upper 16 bits
+ __m128i tmpihi = _mm_unpackhi_epi16(zeroi, tmpi);
+
+ //convert and scale
+ __m128 tmplo = _mm_mul_ps(_mm_cvtepi32_ps(tmpilo), scalar);
+ __m128 tmphi = _mm_mul_ps(_mm_cvtepi32_ps(tmpihi), scalar);
+
+ //store to output
+ _mm_storeu_ps(reinterpret_cast<float *>(output+i+0), tmplo);
+ _mm_storeu_ps(reinterpret_cast<float *>(output+i+2), tmphi);
+ }
+
+ //convert remainder
+ for (; i < nsamps; i++){
+ output[i] = item32_to_fc32(uhd::byteswap(input[i]));
+ }
+}
diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py
new file mode 100644
index 000000000..47c4cd7d0
--- /dev/null
+++ b/host/lib/convert/gen_convert_general.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# Copyright 2011 Ettus Research LLC
+#
+# 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/>.
+#
+
+TMPL_HEADER = """
+#import time
+/***********************************************************************
+ * This file was generated by $file on $time.strftime("%c")
+ **********************************************************************/
+
+\#include "convert_common.hpp"
+\#include <uhd/utils/byteswap.hpp>
+
+using namespace uhd::convert;
+"""
+
+TMPL_CONV_TO_FROM_ITEM32_1 = """
+DECLARE_CONVERTER(convert_$(cpu_type)_1_to_item32_1_$(swap), PRIORITY_GENERAL){
+ const $(cpu_type)_t *input = reinterpret_cast<const $(cpu_type)_t *>(inputs[0]);
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ for (size_t i = 0; i < nsamps; i++){
+ output[i] = $(swap_fcn)($(cpu_type)_to_item32(input[i]));
+ }
+}
+
+DECLARE_CONVERTER(convert_item32_1_to_$(cpu_type)_1_$(swap), PRIORITY_GENERAL){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ $(cpu_type)_t *output = reinterpret_cast<$(cpu_type)_t *>(outputs[0]);
+
+ for (size_t i = 0; i < nsamps; i++){
+ output[i] = item32_to_$(cpu_type)($(swap_fcn)(input[i]));
+ }
+}
+"""
+TMPL_CONV_TO_FROM_ITEM32_X = """
+DECLARE_CONVERTER(convert_$(cpu_type)_$(width)_to_item32_1_$(swap), PRIORITY_GENERAL){
+ #for $w in range($width)
+ const $(cpu_type)_t *input$(w) = reinterpret_cast<const $(cpu_type)_t *>(inputs[$(w)]);
+ #end for
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ for (size_t i = 0, j = 0; i < nsamps; i++){
+ #for $w in range($width)
+ output[j++] = $(swap_fcn)($(cpu_type)_to_item32(input$(w)[i]));
+ #end for
+ }
+}
+
+DECLARE_CONVERTER(convert_item32_1_to_$(cpu_type)_$(width)_$(swap), PRIORITY_GENERAL){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ #for $w in range($width)
+ $(cpu_type)_t *output$(w) = reinterpret_cast<$(cpu_type)_t *>(outputs[$(w)]);
+ #end for
+
+ for (size_t i = 0, j = 0; i < nsamps; i++){
+ #for $w in range($width)
+ output$(w)[i] = item32_to_$(cpu_type)($(swap_fcn)(input[j++]));
+ #end for
+ }
+}
+"""
+
+def parse_tmpl(_tmpl_text, **kwargs):
+ from Cheetah.Template import Template
+ return str(Template(_tmpl_text, kwargs))
+
+if __name__ == '__main__':
+ import sys, os
+ file = os.path.basename(__file__)
+ output = parse_tmpl(TMPL_HEADER, file=file)
+ for width in 1, 2, 3, 4:
+ for swap, swap_fcn in (('nswap', ''), ('bswap', 'uhd::byteswap')):
+ for cpu_type in 'fc32', 'sc16':
+ output += parse_tmpl(
+ TMPL_CONV_TO_FROM_ITEM32_1 if width == 1 else TMPL_CONV_TO_FROM_ITEM32_X,
+ width=width, swap=swap, swap_fcn=swap_fcn, cpu_type=cpu_type
+ )
+ open(sys.argv[1], 'w').write(output)
diff --git a/host/lib/convert/gen_convert_pred.py b/host/lib/convert/gen_convert_pred.py
new file mode 100644
index 000000000..1d573bf1a
--- /dev/null
+++ b/host/lib/convert/gen_convert_pred.py
@@ -0,0 +1,163 @@
+#!/usr/bin/env python
+#
+# Copyright 2011-2011 Ettus Research LLC
+#
+# 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/>.
+#
+
+TMPL_TEXT = """
+#import time
+/***********************************************************************
+ * This file was generated by $file on $time.strftime("%c")
+ **********************************************************************/
+typedef size_t pred_type;
+
+\#include <boost/tokenizer.hpp>
+\#include <boost/lexical_cast.hpp>
+\#include <boost/detail/endian.hpp>
+\#include <boost/cstdint.hpp>
+\#include <stdexcept>
+\#include <string>
+\#include <vector>
+
+enum dir_type{
+ DIR_OTW_TO_CPU = 0,
+ DIR_CPU_TO_OTW = 1
+};
+
+struct pred_error : std::runtime_error{
+ pred_error(const std::string &what)
+ :std::runtime_error("convert::make_pred: " + what){
+ /* NOP */
+ }
+};
+
+pred_type make_pred(const std::string &markup, dir_type &dir){
+ pred_type pred = 0;
+
+ try{
+ boost::tokenizer<boost::char_separator<char> > tokenizer(markup, boost::char_separator<char>("_"));
+ std::vector<std::string> tokens(tokenizer.begin(), tokenizer.end());
+ //token 0 is <convert>
+ std::string inp_type = tokens.at(1);
+ std::string num_inps = tokens.at(2);
+ //token 3 is <to>
+ std::string out_type = tokens.at(4);
+ std::string num_outs = tokens.at(5);
+ std::string swap_type = tokens.at(6);
+
+ std::string cpu_type, otw_type;
+ if (inp_type.find("item") == std::string::npos){
+ cpu_type = inp_type;
+ otw_type = out_type;
+ dir = DIR_CPU_TO_OTW;
+ }
+ else{
+ cpu_type = out_type;
+ otw_type = inp_type;
+ dir = DIR_OTW_TO_CPU;
+ }
+
+ if (cpu_type == "fc32") pred |= $ph.fc32_p;
+ else if (cpu_type == "sc16") pred |= $ph.sc16_p;
+ else throw pred_error("unhandled io type " + cpu_type);
+
+ if (otw_type == "item32") pred |= $ph.item32_p;
+ else throw pred_error("unhandled otw type " + otw_type);
+
+ int num_inputs = boost::lexical_cast<int>(num_inps);
+ int num_outputs = boost::lexical_cast<int>(num_outs);
+
+ switch(num_inputs*num_outputs){ //FIXME treated as one value
+ case 1: pred |= $ph.chan1_p; break;
+ case 2: pred |= $ph.chan2_p; break;
+ case 3: pred |= $ph.chan3_p; break;
+ case 4: pred |= $ph.chan4_p; break;
+ default: throw pred_error("unhandled number of channels");
+ }
+
+ if (swap_type == "bswap") pred |= $ph.bswap_p;
+ else if (swap_type == "nswap") pred |= $ph.nswap_p;
+ else throw pred_error("unhandled swap type");
+
+ }
+ catch(...){
+ throw pred_error("could not parse markup: " + markup);
+ }
+
+ return pred;
+}
+
+UHD_INLINE pred_type make_pred(
+ const io_type_t &io_type,
+ const otw_type_t &otw_type,
+ size_t num_inputs,
+ size_t num_outputs
+){
+ pred_type pred = 0;
+
+ switch(otw_type.byteorder){
+ \#ifdef BOOST_BIG_ENDIAN
+ case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.nswap_p; break;
+ case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.bswap_p; break;
+ \#else
+ case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.bswap_p; break;
+ case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.nswap_p; break;
+ \#endif
+ case otw_type_t::BO_NATIVE: pred |= $ph.nswap_p; break;
+ default: throw pred_error("unhandled otw byteorder type");
+ }
+
+ switch(otw_type.get_sample_size()){
+ case sizeof(boost::uint32_t): pred |= $ph.item32_p; break;
+ default: throw pred_error("unhandled otw sample size");
+ }
+
+ switch(io_type.tid){
+ case io_type_t::COMPLEX_FLOAT32: pred |= $ph.fc32_p; break;
+ case io_type_t::COMPLEX_INT16: pred |= $ph.sc16_p; break;
+ default: throw pred_error("unhandled io type id");
+ }
+
+ switch(num_inputs*num_outputs){ //FIXME treated as one value
+ case 1: pred |= $ph.chan1_p; break;
+ case 2: pred |= $ph.chan2_p; break;
+ case 3: pred |= $ph.chan3_p; break;
+ case 4: pred |= $ph.chan4_p; break;
+ default: throw pred_error("unhandled number of channels");
+ }
+
+ return pred;
+}
+"""
+
+def parse_tmpl(_tmpl_text, **kwargs):
+ from Cheetah.Template import Template
+ return str(Template(_tmpl_text, kwargs))
+
+class ph:
+ bswap_p = 0b00001
+ nswap_p = 0b00000
+ item32_p = 0b00000
+ sc16_p = 0b00010
+ fc32_p = 0b00000
+ chan1_p = 0b00000
+ chan2_p = 0b00100
+ chan3_p = 0b01000
+ chan4_p = 0b01100
+
+if __name__ == '__main__':
+ import sys, os
+ file = os.path.basename(__file__)
+ open(sys.argv[1], 'w').write(parse_tmpl(TMPL_TEXT, file=file, ph=ph))
diff --git a/host/lib/gain_group.cpp b/host/lib/gain_group.cpp
deleted file mode 100644
index 1be09dee2..000000000
--- a/host/lib/gain_group.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#include <uhd/utils/gain_group.hpp>
-#include <uhd/types/dict.hpp>
-#include <uhd/utils/algorithm.hpp>
-#include <uhd/utils/assert.hpp>
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-#include <algorithm>
-#include <vector>
-#include <iostream>
-
-using namespace uhd;
-
-static const bool verbose = false;
-
-static bool compare_by_step_size(
- const size_t &rhs, const size_t &lhs, std::vector<gain_fcns_t> &fcns
-){
- return fcns.at(rhs).get_range().step > fcns.at(lhs).get_range().step;
-}
-
-/***********************************************************************
- * gain group implementation
- **********************************************************************/
-class gain_group_impl : public gain_group{
-public:
- gain_group_impl(void){
- /*NOP*/
- }
-
- gain_range_t get_range(void){
- float overall_min = 0, overall_max = 0, overall_step = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
- const gain_range_t range = fcns.get_range();
- overall_min += range.min;
- overall_max += range.max;
- //the overall step is the min (zero is invalid, first run)
- if (overall_step == 0) overall_step = range.step;
- overall_step = std::min(overall_step, range.step);
- }
- return gain_range_t(overall_min, overall_max, overall_step);
- }
-
- float get_value(void){
- float overall_gain = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
- overall_gain += fcns.get_value();
- }
- return overall_gain;
- }
-
- void set_value(float gain){
- std::vector<gain_fcns_t> all_fcns = get_all_fcns();
- if (all_fcns.size() == 0) return; //nothing to set!
-
- //get the max step size among the gains
- float max_step = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
- max_step = std::max(max_step, fcns.get_range().step);
- }
-
- //create gain bucket to distribute power
- std::vector<float> gain_bucket;
-
- //distribute power according to priority (round to max step)
- float gain_left_to_distribute = gain;
- BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
- const gain_range_t range = fcns.get_range();
- gain_bucket.push_back(
- max_step*int(std::clip(gain_left_to_distribute, range.min, range.max)/max_step)
- );
- gain_left_to_distribute -= gain_bucket.back();
- }
-
- //get a list of indexes sorted by step size large to small
- std::vector<size_t> indexes_step_size_dec;
- for (size_t i = 0; i < all_fcns.size(); i++){
- indexes_step_size_dec.push_back(i);
- }
- std::sort(
- indexes_step_size_dec.begin(), indexes_step_size_dec.end(),
- boost::bind(&compare_by_step_size, _1, _2, all_fcns)
- );
- UHD_ASSERT_THROW(
- all_fcns.at(indexes_step_size_dec.front()).get_range().step >=
- all_fcns.at(indexes_step_size_dec.back()).get_range().step
- );
-
- //distribute the remainder (less than max step)
- //fill in the largest step sizes first that are less than the remainder
- BOOST_FOREACH(size_t i, indexes_step_size_dec){
- const gain_range_t range = all_fcns.at(i).get_range();
- float additional_gain = range.step*int(
- std::clip(gain_bucket.at(i) + gain_left_to_distribute, range.min, range.max
- )/range.step) - gain_bucket.at(i);
- gain_bucket.at(i) += additional_gain;
- gain_left_to_distribute -= additional_gain;
- }
- if (verbose) std::cout << "gain_left_to_distribute " << gain_left_to_distribute << std::endl;
-
- //now write the bucket out to the individual gain values
- for (size_t i = 0; i < gain_bucket.size(); i++){
- if (verbose) std::cout << gain_bucket.at(i) << std::endl;
- all_fcns.at(i).set_value(gain_bucket.at(i));
- }
- }
-
- void register_fcns(
- const gain_fcns_t &gain_fcns, size_t priority
- ){
- _registry[priority].push_back(gain_fcns);
- }
-
-private:
- //! get the gain function sets in order (highest priority first)
- std::vector<gain_fcns_t> get_all_fcns(void){
- std::vector<gain_fcns_t> all_fcns;
- BOOST_FOREACH(ssize_t key, std::sorted(_registry.keys())){
- const std::vector<gain_fcns_t> &fcns = _registry[key];
- all_fcns.insert(all_fcns.begin(), fcns.begin(), fcns.end());
- }
- return all_fcns;
- }
-
- uhd::dict<size_t, std::vector<gain_fcns_t> > _registry;
-};
-
-/***********************************************************************
- * gain group factory function
- **********************************************************************/
-gain_group::sptr gain_group::make(void){
- return sptr(new gain_group_impl());
-}
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt
index 0d6226e4c..8765c6703 100644
--- a/host/lib/transport/CMakeLists.txt
+++ b/host/lib/transport/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -23,7 +23,7 @@
# Setup libusb
########################################################################
MESSAGE(STATUS "")
-FIND_PACKAGE(USB1 REQUIRED)
+FIND_PACKAGE(USB1)
LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF)
@@ -37,9 +37,6 @@ IF(ENABLE_USB)
${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.hpp
)
- IF(MSVC) #include our custom stdint for libusb
- INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/msvc)
- ENDIF(MSVC)
ELSE(ENABLE_USB)
LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/usb_dummy_impl.cpp
@@ -47,25 +44,6 @@ ELSE(ENABLE_USB)
ENDIF(ENABLE_USB)
########################################################################
-# Check for SIMD headers
-########################################################################
-MESSAGE(STATUS "")
-
-INCLUDE(CheckIncludeFileCXX)
-CHECK_INCLUDE_FILE_CXX(emmintrin.h HAVE_EMMINTRIN_H)
-
-IF(HAVE_EMMINTRIN_H)
- ADD_DEFINITIONS(-DHAVE_EMMINTRIN_H)
-ENDIF(HAVE_EMMINTRIN_H)
-
-INCLUDE(CheckIncludeFileCXX)
-CHECK_INCLUDE_FILE_CXX(arm_neon.h HAVE_ARM_NEON_H)
-
-IF(HAVE_ARM_NEON_H)
- ADD_DEFINITIONS(-DHAVE_ARM_NEON_H)
-ENDIF(HAVE_ARM_NEON_H)
-
-########################################################################
# Setup defines for interface address discovery
########################################################################
MESSAGE(STATUS "")
@@ -93,22 +71,8 @@ LIBUHD_PYTHON_GEN_SOURCE(
${CMAKE_CURRENT_BINARY_DIR}/vrt_if_packet.cpp
)
-LIBUHD_PYTHON_GEN_SOURCE(
- ${CMAKE_CURRENT_SOURCE_DIR}/gen_convert_types.py
- ${CMAKE_CURRENT_BINARY_DIR}/convert_types.cpp
-)
-
-# append this directory to the include path so the generated convert types
-# can include the implementation convert types file in the source directory
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
-
-# make the generated convert types depend on the implementation header
-SET_SOURCE_FILES_PROPERTIES(
- ${CMAKE_CURRENT_BINARY_DIR}/convert_types.cpp PROPERTIES
- OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/convert_types_impl.hpp
-)
-
LIBUHD_APPEND_SOURCES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/buffer_pool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/if_addrs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/udp_simple.cpp
${CMAKE_CURRENT_SOURCE_DIR}/udp_zero_copy_asio.cpp
diff --git a/host/lib/transport/buffer_pool.cpp b/host/lib/transport/buffer_pool.cpp
new file mode 100644
index 000000000..971bbb75a
--- /dev/null
+++ b/host/lib/transport/buffer_pool.cpp
@@ -0,0 +1,80 @@
+//
+// Copyright 2011-2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/transport/buffer_pool.hpp>
+#include <boost/shared_array.hpp>
+#include <vector>
+
+using namespace uhd::transport;
+
+//! pad the byte count to a multiple of alignment
+static size_t pad_to_boundary(const size_t bytes, const size_t alignment){
+ return bytes + (alignment - bytes)%alignment;
+}
+
+/***********************************************************************
+ * Buffer pool implementation
+ **********************************************************************/
+class buffer_pool_impl : public buffer_pool{
+public:
+ buffer_pool_impl(
+ const std::vector<ptr_type> &ptrs,
+ boost::shared_array<char> mem
+ ): _ptrs(ptrs), _mem(mem){
+ /* NOP */
+ }
+
+ ptr_type at(const size_t index) const{
+ return _ptrs.at(index);
+ }
+
+ size_t size(void) const{
+ return _ptrs.size();
+ }
+
+private:
+ std::vector<ptr_type> _ptrs;
+ boost::shared_array<char> _mem;
+};
+
+/***********************************************************************
+ * Buffer pool factor function
+ **********************************************************************/
+buffer_pool::sptr buffer_pool::make(
+ const size_t num_buffs,
+ const size_t buff_size,
+ const size_t alignment
+){
+ //1) pad the buffer size to be a multiple of alignment
+ //2) pad the overall memory size for room after alignment
+ //3) allocate the memory in one block of sufficient size
+ const size_t padded_buff_size = pad_to_boundary(buff_size, alignment);
+ boost::shared_array<char> mem(new char[padded_buff_size*num_buffs + alignment-1]);
+
+ //Fill a vector with boundary-aligned points in the memory
+ const size_t mem_start = pad_to_boundary(size_t(mem.get()), alignment);
+ std::vector<ptr_type> ptrs(num_buffs);
+ for (size_t i = 0; i < num_buffs; i++){
+ ptrs[i] = ptr_type(mem_start + padded_buff_size*i);
+ }
+
+ //Create a new buffer pool implementation with:
+ // - the pre-computed pointers, and
+ // - the reference to allocated memory.
+ return sptr(new buffer_pool_impl(ptrs, mem));
+}
+
diff --git a/host/lib/transport/convert_types_impl.hpp b/host/lib/transport/convert_types_impl.hpp
deleted file mode 100644
index 48ff99725..000000000
--- a/host/lib/transport/convert_types_impl.hpp
+++ /dev/null
@@ -1,345 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_LIBUHD_TRANSPORT_CONVERT_TYPES_IMPL_HPP
-#define INCLUDED_LIBUHD_TRANSPORT_CONVERT_TYPES_IMPL_HPP
-
-#include <uhd/config.hpp>
-#include <uhd/utils/byteswap.hpp>
-#include <boost/cstdint.hpp>
-#include <cstring>
-#include <complex>
-
-#ifdef HAVE_EMMINTRIN_H
- #define USE_EMMINTRIN_H //use sse2 intrinsics
-#endif
-
-#if defined(USE_EMMINTRIN_H)
- #include <emmintrin.h>
-#endif
-
-#ifdef HAVE_ARM_NEON_H
- #define USE_ARM_NEON_H
-#endif
-
-#if defined(USE_ARM_NEON_H)
- #include <arm_neon.h>
-#endif
-
-/***********************************************************************
- * Typedefs
- **********************************************************************/
-typedef std::complex<float> fc32_t;
-typedef std::complex<boost::int16_t> sc16_t;
-typedef boost::uint32_t item32_t;
-
-/***********************************************************************
- * Convert complex short buffer to items32
- **********************************************************************/
-static UHD_INLINE item32_t sc16_to_item32(sc16_t num){
- boost::uint16_t real = num.real();
- boost::uint16_t imag = num.imag();
- return (item32_t(real) << 16) | (item32_t(imag) << 0);
-}
-
-static UHD_INLINE void sc16_to_item32_nswap(
- const sc16_t *input, item32_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = sc16_to_item32(input[i]);
- }
-}
-
-static UHD_INLINE void sc16_to_item32_bswap(
- const sc16_t *input, item32_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = uhd::byteswap(sc16_to_item32(input[i]));
- }
-}
-
-/***********************************************************************
- * Convert items32 buffer to complex short
- **********************************************************************/
-static UHD_INLINE sc16_t item32_to_sc16(item32_t item){
- return sc16_t(
- boost::int16_t(item >> 16),
- boost::int16_t(item >> 0)
- );
-}
-
-static UHD_INLINE void item32_to_sc16_nswap(
- const item32_t *input, sc16_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = item32_to_sc16(input[i]);
- }
-}
-
-static UHD_INLINE void item32_to_sc16_bswap(
- const item32_t *input, sc16_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = item32_to_sc16(uhd::byteswap(input[i]));
- }
-}
-
-/***********************************************************************
- * Convert complex float buffer to items32 (no swap)
- **********************************************************************/
-static const float shorts_per_float = float(32767);
-
-static UHD_INLINE item32_t fc32_to_item32(fc32_t num){
- boost::uint16_t real = boost::int16_t(num.real()*shorts_per_float);
- boost::uint16_t imag = boost::int16_t(num.imag()*shorts_per_float);
- return (item32_t(real) << 16) | (item32_t(imag) << 0);
-}
-
-////////////////////////////////////
-// none-swap
-////////////////////////////////////
-#if defined(USE_EMMINTRIN_H)
-static UHD_INLINE void fc32_to_item32_nswap(
- const fc32_t *input, item32_t *output, size_t nsamps
-){
- __m128 scalar = _mm_set_ps1(shorts_per_float);
-
- //convert blocks of samples with intrinsics
- size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
- //load from input
- __m128 tmplo = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+0));
- __m128 tmphi = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+2));
-
- //convert and scale
- __m128i tmpilo = _mm_cvtps_epi32(_mm_mul_ps(tmplo, scalar));
- __m128i tmpihi = _mm_cvtps_epi32(_mm_mul_ps(tmphi, scalar));
-
- //pack + swap 16-bit pairs
- __m128i tmpi = _mm_packs_epi32(tmpilo, tmpihi);
- tmpi = _mm_shufflelo_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
- tmpi = _mm_shufflehi_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
-
- //store to output
- _mm_storeu_si128(reinterpret_cast<__m128i *>(output+i), tmpi);
- }
-
- //convert remainder
- for (; i < nsamps; i++){
- output[i] = fc32_to_item32(input[i]);
- }
-}
-
-#elif defined(USE_ARM_NEON_H)
-static UHD_INLINE void fc32_to_item32_nswap(
- const fc32_t *input, item32_t *output, size_t nsamps)
-{
- size_t i;
-
- float32x4_t Q0 = vdupq_n_f32(shorts_per_float);
- for (i=0; i < (nsamps & ~0x03); i+=2) {
- float32x4_t Q1 = vld1q_f32(reinterpret_cast<const float *>(&input[i]));
- float32x4_t Q2 = vmulq_f32(Q1, Q0);
- int32x4_t Q3 = vcvtq_s32_f32(Q2);
- int16x4_t D8 = vmovn_s32(Q3);
- int16x4_t D9 = vrev32_s16(D8);
- vst1_s16((reinterpret_cast<int16_t *>(&output[i])), D9);
- }
-
- for (; i < nsamps; i++)
- output[i] = fc32_to_item32(input[i]);
-}
-
-#else
-static UHD_INLINE void fc32_to_item32_nswap(
- const fc32_t *input, item32_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = fc32_to_item32(input[i]);
- }
-}
-
-#endif
-
-////////////////////////////////////
-// byte-swap
-////////////////////////////////////
-#if defined(USE_EMMINTRIN_H)
-static UHD_INLINE void fc32_to_item32_bswap(
- const fc32_t *input, item32_t *output, size_t nsamps
-){
- __m128 scalar = _mm_set_ps1(shorts_per_float);
-
- //convert blocks of samples with intrinsics
- size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
- //load from input
- __m128 tmplo = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+0));
- __m128 tmphi = _mm_loadu_ps(reinterpret_cast<const float *>(input+i+2));
-
- //convert and scale
- __m128i tmpilo = _mm_cvtps_epi32(_mm_mul_ps(tmplo, scalar));
- __m128i tmpihi = _mm_cvtps_epi32(_mm_mul_ps(tmphi, scalar));
-
- //pack + byteswap -> byteswap 16 bit words
- __m128i tmpi = _mm_packs_epi32(tmpilo, tmpihi);
- tmpi = _mm_or_si128(_mm_srli_epi16(tmpi, 8), _mm_slli_epi16(tmpi, 8));
-
- //store to output
- _mm_storeu_si128(reinterpret_cast<__m128i *>(output+i), tmpi);
- }
-
- //convert remainder
- for (; i < nsamps; i++){
- output[i] = uhd::byteswap(fc32_to_item32(input[i]));
- }
-}
-
-#else
-static UHD_INLINE void fc32_to_item32_bswap(
- const fc32_t *input, item32_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = uhd::byteswap(fc32_to_item32(input[i]));
- }
-}
-
-#endif
-
-/***********************************************************************
- * Convert items32 buffer to complex float
- **********************************************************************/
-static const float floats_per_short = float(1.0/shorts_per_float);
-
-static UHD_INLINE fc32_t item32_to_fc32(item32_t item){
- return fc32_t(
- float(boost::int16_t(item >> 16)*floats_per_short),
- float(boost::int16_t(item >> 0)*floats_per_short)
- );
-}
-
-////////////////////////////////////
-// none-swap
-////////////////////////////////////
-#if defined(USE_EMMINTRIN_H)
-static UHD_INLINE void item32_to_fc32_nswap(
- const item32_t *input, fc32_t *output, size_t nsamps
-){
- __m128 scalar = _mm_set_ps1(floats_per_short/(1 << 16));
- __m128i zeroi = _mm_setzero_si128();
-
- //convert blocks of samples with intrinsics
- size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
- //load from input
- __m128i tmpi = _mm_loadu_si128(reinterpret_cast<const __m128i *>(input+i));
-
- //unpack + swap 16-bit pairs
- tmpi = _mm_shufflelo_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
- tmpi = _mm_shufflehi_epi16(tmpi, _MM_SHUFFLE(2, 3, 0, 1));
- __m128i tmpilo = _mm_unpacklo_epi16(zeroi, tmpi); //value in upper 16 bits
- __m128i tmpihi = _mm_unpackhi_epi16(zeroi, tmpi);
-
- //convert and scale
- __m128 tmplo = _mm_mul_ps(_mm_cvtepi32_ps(tmpilo), scalar);
- __m128 tmphi = _mm_mul_ps(_mm_cvtepi32_ps(tmpihi), scalar);
-
- //store to output
- _mm_storeu_ps(reinterpret_cast<float *>(output+i+0), tmplo);
- _mm_storeu_ps(reinterpret_cast<float *>(output+i+2), tmphi);
- }
-
- //convert remainder
- for (; i < nsamps; i++){
- output[i] = item32_to_fc32(input[i]);
- }
-}
-
-#elif defined(USE_ARM_NEON_H)
-static UHD_INLINE void item32_to_fc32_nswap(
- const item32_t *input, fc32_t *output, size_t nsamps)
-{
- size_t i;
-
- float32x4_t Q1 = vdupq_n_f32(floats_per_short);
- for (i=0; i < (nsamps & ~0x03); i+=2) {
- int16x4_t D0 = vld1_s16(reinterpret_cast<const int16_t *>(&input[i]));
- int16x4_t D1 = vrev32_s16(D0);
- int32x4_t Q2 = vmovl_s16(D1);
- float32x4_t Q3 = vcvtq_f32_s32(Q2);
- float32x4_t Q4 = vmulq_f32(Q3, Q1);
- vst1q_f32((reinterpret_cast<float *>(&output[i])), Q4);
- }
-
- for (; i < nsamps; i++)
- output[i] = item32_to_fc32(input[i]);
-}
-
-#else
-static UHD_INLINE void item32_to_fc32_nswap(
- const item32_t *input, fc32_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = item32_to_fc32(input[i]);
- }
-}
-#endif
-
-////////////////////////////////////
-// byte-swap
-////////////////////////////////////
-#if defined(USE_EMMINTRIN_H)
-static UHD_INLINE void item32_to_fc32_bswap(
- const item32_t *input, fc32_t *output, size_t nsamps
-){
- __m128 scalar = _mm_set_ps1(floats_per_short/(1 << 16));
- __m128i zeroi = _mm_setzero_si128();
-
- //convert blocks of samples with intrinsics
- size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){
- //load from input
- __m128i tmpi = _mm_loadu_si128(reinterpret_cast<const __m128i *>(input+i));
-
- //byteswap + unpack -> byteswap 16 bit words
- tmpi = _mm_or_si128(_mm_srli_epi16(tmpi, 8), _mm_slli_epi16(tmpi, 8));
- __m128i tmpilo = _mm_unpacklo_epi16(zeroi, tmpi); //value in upper 16 bits
- __m128i tmpihi = _mm_unpackhi_epi16(zeroi, tmpi);
-
- //convert and scale
- __m128 tmplo = _mm_mul_ps(_mm_cvtepi32_ps(tmpilo), scalar);
- __m128 tmphi = _mm_mul_ps(_mm_cvtepi32_ps(tmpihi), scalar);
-
- //store to output
- _mm_storeu_ps(reinterpret_cast<float *>(output+i+0), tmplo);
- _mm_storeu_ps(reinterpret_cast<float *>(output+i+2), tmphi);
- }
-
- //convert remainder
- for (; i < nsamps; i++){
- output[i] = item32_to_fc32(uhd::byteswap(input[i]));
- }
-}
-
-#else
-static UHD_INLINE void item32_to_fc32_bswap(
- const item32_t *input, fc32_t *output, size_t nsamps
-){
- for (size_t i = 0; i < nsamps; i++){
- output[i] = item32_to_fc32(uhd::byteswap(input[i]));
- }
-}
-
-#endif
-
-#endif /* INCLUDED_LIBUHD_TRANSPORT_CONVERT_TYPES_IMPL_HPP */
diff --git a/host/lib/transport/gen_convert_types.py b/host/lib/transport/gen_convert_types.py
deleted file mode 100755
index f9509c81d..000000000
--- a/host/lib/transport/gen_convert_types.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2010 Ettus Research LLC
-#
-# 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/>.
-#
-
-TMPL_TEXT = """
-#import time
-/***********************************************************************
- * This file was generated by $file on $time.strftime("%c")
- **********************************************************************/
-
-\#include <uhd/config.hpp>
-\#include <uhd/transport/convert_types.hpp>
-\#include <boost/cstdint.hpp>
-\#include <boost/detail/endian.hpp>
-\#include <stdexcept>
-\#include "convert_types_impl.hpp"
-
-using namespace uhd;
-
-/***********************************************************************
- * Generate predicate for jump table
- **********************************************************************/
-UHD_INLINE boost::uint8_t get_pred(
- const io_type_t &io_type,
- const otw_type_t &otw_type,
- size_t num_chans
-){
- boost::uint8_t pred = 0;
-
- switch(otw_type.byteorder){
- \#ifdef BOOST_BIG_ENDIAN
- case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.nswap_p; break;
- case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.bswap_p; break;
- \#else
- case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.bswap_p; break;
- case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.nswap_p; break;
- \#endif
- case otw_type_t::BO_NATIVE: pred |= $ph.nswap_p; break;
- default: throw std::runtime_error("unhandled otw byteorder type");
- }
-
- switch(otw_type.get_sample_size()){
- case sizeof(boost::uint32_t): pred |= $ph.item32_p; break;
- default: throw std::runtime_error("unhandled otw sample size");
- }
-
- switch(io_type.tid){
- case io_type_t::COMPLEX_FLOAT32: pred |= $ph.fc32_p; break;
- case io_type_t::COMPLEX_INT16: pred |= $ph.sc16_p; break;
- default: throw std::runtime_error("unhandled io type id");
- }
-
- switch(num_chans){
- case 1: pred |= $ph.chan1_p; break;
- case 2: pred |= $ph.chan2_p; break;
- case 3: pred |= $ph.chan3_p; break;
- case 4: pred |= $ph.chan4_p; break;
- default: throw std::runtime_error("unhandled number of channels");
- }
-
- return pred;
-}
-
-/***********************************************************************
- * Convert host type to device type
- **********************************************************************/
-void transport::convert_io_type_to_otw_type(
- const std::vector<const void *> &io_buffs,
- const io_type_t &io_type,
- void *otw_buff,
- const otw_type_t &otw_type,
- size_t nsamps_per_io_buff
-){
- switch(get_pred(io_type, otw_type, io_buffs.size())){
- #for $pred in range(2**$ph.nbits)
- case $pred:
- #set $out_type = $ph.get_dev_type($pred)
- #set $in_type = $ph.get_host_type($pred)
- #set $num_chans = $ph.get_num_chans($pred)
- #set $converter = '_'.join([$in_type, 'to', $out_type])
- #if $num_chans == 1
- $(converter)_$ph.get_swap_type($pred)(
- reinterpret_cast<const $(in_type)_t *>(io_buffs.front()),
- reinterpret_cast<$(out_type)_t *>(otw_buff),
- nsamps_per_io_buff
- );
- #else
- for (size_t i = 0, j = 0; i < nsamps_per_io_buff; i++){
- #for $j in range($num_chans)
- reinterpret_cast<$(out_type)_t *>(otw_buff)[j++] =
- #if $ph.get_swap_type($pred) == 'bswap'
- uhd::byteswap($(converter)(reinterpret_cast<const $(in_type)_t *>(io_buffs[$j])[i]));
- #else
- $(converter)(reinterpret_cast<const $(in_type)_t *>(io_buffs[$j])[i]);
- #end if
- #end for
- }
- #end if
- break;
- #end for
- }
-}
-
-/***********************************************************************
- * Convert device type to host type
- **********************************************************************/
-void transport::convert_otw_type_to_io_type(
- const void *otw_buff,
- const otw_type_t &otw_type,
- std::vector<void *> &io_buffs,
- const io_type_t &io_type,
- size_t nsamps_per_io_buff
-){
- switch(get_pred(io_type, otw_type, io_buffs.size())){
- #for $pred in range(2**$ph.nbits)
- case $pred:
- #set $out_type = $ph.get_host_type($pred)
- #set $in_type = $ph.get_dev_type($pred)
- #set $num_chans = $ph.get_num_chans($pred)
- #set $converter = '_'.join([$in_type, 'to', $out_type])
- #if $num_chans == 1
- $(converter)_$ph.get_swap_type($pred)(
- reinterpret_cast<const $(in_type)_t *>(otw_buff),
- reinterpret_cast<$(out_type)_t *>(io_buffs.front()),
- nsamps_per_io_buff
- );
- #else
- for (size_t i = 0, j = 0; i < nsamps_per_io_buff; i++){
- #for $j in range($num_chans)
- reinterpret_cast<$(out_type)_t *>(io_buffs[$j])[i] =
- #if $ph.get_swap_type($pred) == 'bswap'
- $(converter)(uhd::byteswap(reinterpret_cast<const $(in_type)_t *>(otw_buff)[j++]));
- #else
- $(converter)(reinterpret_cast<const $(in_type)_t *>(otw_buff)[j++]);
- #end if
- #end for
- }
- #end if
- break;
- #end for
- }
-}
-
-"""
-
-def parse_tmpl(_tmpl_text, **kwargs):
- from Cheetah.Template import Template
- return str(Template(_tmpl_text, kwargs))
-
-class ph:
- bswap_p = 0b00001
- nswap_p = 0b00000
- item32_p = 0b00000
- sc16_p = 0b00010
- fc32_p = 0b00000
- chan1_p = 0b00000
- chan2_p = 0b00100
- chan3_p = 0b01000
- chan4_p = 0b01100
-
- nbits = 4 #see above
-
- @staticmethod
- def has(pred, mask, flag): return (pred & mask) == flag
-
- @staticmethod
- def get_swap_type(pred):
- mask = 0b1
- if ph.has(pred, mask, ph.bswap_p): return 'bswap'
- if ph.has(pred, mask, ph.nswap_p): return 'nswap'
- raise NotImplementedError
-
- @staticmethod
- def get_dev_type(pred):
- mask = 0b0
- if ph.has(pred, mask, ph.item32_p): return 'item32'
- raise NotImplementedError
-
- @staticmethod
- def get_host_type(pred):
- mask = 0b10
- if ph.has(pred, mask, ph.sc16_p): return 'sc16'
- if ph.has(pred, mask, ph.fc32_p): return 'fc32'
- raise NotImplementedError
-
- @staticmethod
- def get_num_chans(pred):
- mask = 0b1100
- if ph.has(pred, mask, ph.chan1_p): return 1
- if ph.has(pred, mask, ph.chan2_p): return 2
- if ph.has(pred, mask, ph.chan3_p): return 3
- if ph.has(pred, mask, ph.chan4_p): return 4
- raise NotImplementedError
-
-if __name__ == '__main__':
- import sys
- open(sys.argv[1], 'w').write(parse_tmpl(TMPL_TEXT, file=__file__, ph=ph))
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp
index f589d7c77..adc590284 100644
--- a/host/lib/transport/libusb1_zero_copy.cpp
+++ b/host/lib/transport/libusb1_zero_copy.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -18,9 +18,9 @@
#include "libusb1_base.hpp"
#include <uhd/transport/usb_zero_copy.hpp>
#include <uhd/transport/bounded_buffer.hpp>
+#include <uhd/transport/buffer_pool.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/assert.hpp>
-#include <boost/shared_array.hpp>
#include <boost/foreach.hpp>
#include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp>
@@ -105,8 +105,8 @@ private:
//! a list of all transfer structs we allocated
std::vector<libusb_transfer *> _all_luts;
- //! a block of memory for the transfer buffers
- boost::shared_array<char> _buffer;
+ //! memory allocated for the transfer buffers
+ buffer_pool::sptr _buffer_pool;
// Calls for processing asynchronous I/O
libusb_transfer *allocate_transfer(void *mem, size_t len);
@@ -134,7 +134,6 @@ static void callback(libusb_transfer *lut){
* \param pointer to libusb_transfer
*/
void usb_endpoint::callback_handle_transfer(libusb_transfer *lut){
- boost::this_thread::disable_interruption di; //disable because the wait can throw
_completed_list->push_with_wait(lut);
}
@@ -157,9 +156,9 @@ usb_endpoint::usb_endpoint(
_input(input)
{
_completed_list = lut_buff_type::make(num_transfers);
- _buffer = boost::shared_array<char>(new char[num_transfers*transfer_size]);
+ _buffer_pool = buffer_pool::make(num_transfers, transfer_size);
for (size_t i = 0; i < num_transfers; i++){
- _all_luts.push_back(allocate_transfer(_buffer.get() + i*transfer_size, transfer_size));
+ _all_luts.push_back(allocate_transfer(_buffer_pool->at(i), transfer_size));
//input luts are immediately submitted to be filled
//output luts go into the completed list as free buffers
@@ -272,7 +271,6 @@ void usb_endpoint::print_transfer_status(libusb_transfer *lut){
}
libusb_transfer *usb_endpoint::get_lut_with_wait(double timeout){
- boost::this_thread::disable_interruption di; //disable because the wait can throw
libusb_transfer *lut;
if (_completed_list->pop_with_timed_wait(lut, timeout)) return lut;
return NULL;
@@ -293,6 +291,7 @@ public:
~libusb_zero_copy_impl(void){
_threads_running = false;
+ _thread_group.interrupt_all();
_thread_group.join_all();
}
@@ -333,12 +332,14 @@ private:
set_thread_priority_safe();
libusb::session::sptr session = libusb::session::get_global_session();
_threads_running = true;
- while(_threads_running){
- timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 100000; //100ms
- libusb_handle_events_timeout(session->get_context(), &tv);
- }
+ try{
+ while(_threads_running){
+ timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000; //100ms
+ libusb_handle_events_timeout(session->get_context(), &tv);
+ }
+ } catch(const boost::thread_interrupted &){}
}
};
diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp
index c758fa894..5c049cfad 100644
--- a/host/lib/transport/udp_zero_copy_asio.cpp
+++ b/host/lib/transport/udp_zero_copy_asio.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -18,10 +18,10 @@
#include <uhd/transport/udp_zero_copy.hpp>
#include <uhd/transport/udp_simple.hpp> //mtu
#include <uhd/transport/bounded_buffer.hpp>
+#include <uhd/transport/buffer_pool.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/warning.hpp>
-#include <boost/shared_array.hpp>
#include <boost/asio.hpp>
#include <boost/format.hpp>
#include <boost/thread.hpp>
@@ -37,14 +37,15 @@ namespace asio = boost::asio;
**********************************************************************/
//Define this to the the boost async io calls to perform receive.
//Otherwise, get_recv_buff uses a blocking receive with timeout.
-//#define USE_ASIO_ASYNC_RECV
+#define USE_ASIO_ASYNC_RECV
//Define this to the the boost async io calls to perform send.
//Otherwise, the commit callback uses a blocking send.
//#define USE_ASIO_ASYNC_SEND
-//enough buffering for half a second of samples at full rate on usrp2
-static const size_t MIN_RECV_SOCK_BUFF_SIZE = size_t(4 * 25e6 * 0.5);
+//By default, this buffer is sized insufficiently small.
+//For peformance, this buffer should be 10s of megabytes.
+static const size_t MIN_RECV_SOCK_BUFF_SIZE = size_t(10e3);
//Large buffers cause more underflow at high rates.
//Perhaps this is due to the kernel scheduling,
@@ -123,16 +124,16 @@ public:
void init(void){
//allocate all recv frames and release them to begin xfers
_pending_recv_buffs = pending_buffs_type::make(_num_recv_frames);
- _recv_buffer = boost::shared_array<char>(new char[_num_recv_frames*_recv_frame_size]);
+ _recv_buffer_pool = buffer_pool::make(_num_recv_frames, _recv_frame_size);
for (size_t i = 0; i < _num_recv_frames; i++){
- release(_recv_buffer.get() + i*_recv_frame_size);
+ release(_recv_buffer_pool->at(i));
}
//allocate all send frames and push them into the fifo
_pending_send_buffs = pending_buffs_type::make(_num_send_frames);
- _send_buffer = boost::shared_array<char>(new char[_num_send_frames*_send_frame_size]);
+ _send_buffer_pool = buffer_pool::make(_num_send_frames, _send_frame_size);
for (size_t i = 0; i < _num_send_frames; i++){
- handle_send(_send_buffer.get() + i*_send_frame_size);
+ handle_send(_send_buffer_pool->at(i));
}
//spawn the service threads that will run the io service
@@ -302,7 +303,7 @@ public:
private:
//memory management -> buffers and fifos
boost::thread_group _thread_group;
- boost::shared_array<char> _send_buffer, _recv_buffer;
+ buffer_pool::sptr _send_buffer_pool, _recv_buffer_pool;
typedef bounded_buffer<asio::mutable_buffer> pending_buffs_type;
pending_buffs_type::sptr _pending_recv_buffs, _pending_send_buffs;
const size_t _recv_frame_size, _num_recv_frames;
@@ -321,12 +322,13 @@ private:
**********************************************************************/
template<typename Opt> static void resize_buff_helper(
udp_zero_copy_asio_impl::sptr udp_trans,
- size_t target_size,
+ const size_t target_size,
const std::string &name
){
size_t min_sock_buff_size = 0;
if (name == "recv") min_sock_buff_size = MIN_RECV_SOCK_BUFF_SIZE;
if (name == "send") min_sock_buff_size = MIN_SEND_SOCK_BUFF_SIZE;
+ min_sock_buff_size = std::max(min_sock_buff_size, target_size);
std::string help_message;
#if defined(UHD_PLATFORM_LINUX)
@@ -347,7 +349,7 @@ template<typename Opt> static void resize_buff_helper(
) % name % actual_size << std::endl;
if (actual_size < target_size) uhd::warning::post(str(boost::format(
"The %s buffer is smaller than the requested size.\n"
- "The minimum recommended buffer size is %d bytes.\n"
+ "The minimum requested buffer size is %d bytes.\n"
"See the transport application notes on buffer resizing.\n%s"
) % name % min_sock_buff_size % help_message));
}
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp
index 278bcfeaa..c535edd04 100644
--- a/host/lib/transport/vrt_packet_handler.hpp
+++ b/host/lib/transport/vrt_packet_handler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -26,7 +26,7 @@
#include <uhd/types/otw_type.hpp>
#include <uhd/types/metadata.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
-#include <uhd/transport/convert_types.hpp>
+#include <uhd/convert.hpp>
#include <uhd/transport/zero_copy.hpp>
#include <boost/function.hpp>
#include <stdexcept>
@@ -35,6 +35,9 @@
namespace vrt_packet_handler{
+//this may change in the future but its a constant for now
+static const size_t OTW_BYTES_PER_SAMP = sizeof(boost::uint32_t);
+
template <typename T> UHD_INLINE T get_context_code(
const boost::uint32_t *vrt_hdr,
const uhd::transport::vrt::if_packet_info_t &if_packet_info
@@ -91,6 +94,7 @@ template <typename T> UHD_INLINE T get_context_code(
//vrt unpack each managed buffer
uhd::transport::vrt::if_packet_info_t if_packet_info;
for (size_t i = 0; i < state.width; i++){
+ if (state.managed_buffs[i].get() == NULL) continue; //better have a message packet coming up...
//extract packet words and check thats its enough to move on
size_t num_packet_words32 = state.managed_buffs[i]->size()/sizeof(boost::uint32_t);
@@ -144,8 +148,7 @@ template <typename T> UHD_INLINE T get_context_code(
size_t offset_bytes,
size_t total_samps,
uhd::rx_metadata_t &metadata,
- const uhd::io_type_t &io_type,
- const uhd::otw_type_t &otw_type,
+ uhd::convert::function_type &converter,
double tick_rate,
const vrt_unpacker_t &vrt_unpacker,
const get_recv_buffs_t &get_recv_buffs,
@@ -183,7 +186,7 @@ template <typename T> UHD_INLINE T get_context_code(
}
//extract the number of samples available to copy
- size_t bytes_per_item = otw_type.get_sample_size();
+ size_t bytes_per_item = OTW_BYTES_PER_SAMP;
size_t nsamps_available = state.size_of_copy_buffs/bytes_per_item;
size_t nsamps_to_copy = std::min(total_samps*chans_per_otw_buff, nsamps_available);
size_t bytes_to_copy = nsamps_to_copy*bytes_per_item;
@@ -198,9 +201,8 @@ template <typename T> UHD_INLINE T get_context_code(
}
//copy-convert the samples from the recv buffer
- uhd::transport::convert_otw_type_to_io_type(
- state.copy_buffs[i], otw_type, io_buffs, io_type, nsamps_to_copy_per_io_buff
- );
+ uhd::convert::input_type otw_buffs(1, state.copy_buffs[i]);
+ converter(otw_buffs, io_buffs, nsamps_to_copy_per_io_buff);
//update the rx copy buffer to reflect the bytes copied
state.copy_buffs[i] += bytes_to_copy;
@@ -234,6 +236,11 @@ template <typename T> UHD_INLINE T get_context_code(
size_t vrt_header_offset_words32 = 0,
size_t chans_per_otw_buff = 1
){
+ uhd::convert::function_type converter(
+ uhd::convert::get_converter_otw_to_cpu(
+ io_type, otw_type, 1, chans_per_otw_buff
+ ));
+
switch(recv_mode){
////////////////////////////////////////////////////////////////
@@ -244,7 +251,7 @@ template <typename T> UHD_INLINE T get_context_code(
buffs, 0,
total_num_samps,
metadata,
- io_type, otw_type,
+ converter,
tick_rate,
vrt_unpacker,
get_recv_buffs,
@@ -265,7 +272,7 @@ template <typename T> UHD_INLINE T get_context_code(
buffs, accum_num_samps*io_type.size,
total_num_samps - accum_num_samps,
(accum_num_samps == 0)? metadata : tmp_md, //only the first metadata gets kept
- io_type, otw_type,
+ converter,
tick_rate,
vrt_unpacker,
get_recv_buffs,
@@ -309,15 +316,14 @@ template <typename T> UHD_INLINE T get_context_code(
const size_t offset_bytes,
const size_t num_samps,
uhd::transport::vrt::if_packet_info_t &if_packet_info,
- const uhd::io_type_t &io_type,
- const uhd::otw_type_t &otw_type,
+ uhd::convert::function_type &converter,
const vrt_packer_t &vrt_packer,
const get_send_buffs_t &get_send_buffs,
const size_t vrt_header_offset_words32,
const size_t chans_per_otw_buff
){
//load the rest of the if_packet_info in here
- if_packet_info.num_payload_words32 = (num_samps*chans_per_otw_buff*otw_type.get_sample_size())/sizeof(boost::uint32_t);
+ if_packet_info.num_payload_words32 = (num_samps*chans_per_otw_buff*OTW_BYTES_PER_SAMP)/sizeof(boost::uint32_t);
if_packet_info.packet_count = state.next_packet_seq;
//get send buffers for each channel
@@ -337,9 +343,8 @@ template <typename T> UHD_INLINE T get_context_code(
otw_mem += if_packet_info.num_header_words32;
//copy-convert the samples into the send buffer
- uhd::transport::convert_io_type_to_otw_type(
- io_buffs, io_type, otw_mem, otw_type, num_samps
- );
+ uhd::convert::output_type otw_buffs(1, otw_mem);
+ converter(io_buffs, otw_buffs, num_samps);
//commit the samples to the zero-copy interface
size_t num_bytes_total = (vrt_header_offset_words32+if_packet_info.num_packet_words32)*sizeof(boost::uint32_t);
@@ -367,6 +372,11 @@ template <typename T> UHD_INLINE T get_context_code(
size_t vrt_header_offset_words32 = 0,
size_t chans_per_otw_buff = 1
){
+ uhd::convert::function_type converter(
+ uhd::convert::get_converter_cpu_to_otw(
+ io_type, otw_type, chans_per_otw_buff, 1
+ ));
+
//translate the metadata to vrt if packet info
uhd::transport::vrt::if_packet_info_t if_packet_info;
if_packet_info.has_sid = false;
@@ -402,7 +412,7 @@ template <typename T> UHD_INLINE T get_context_code(
buffs_, 0,
std::min(total_num_samps_, max_samples_per_packet),
if_packet_info,
- io_type, otw_type,
+ converter,
vrt_packer,
get_send_buffs,
vrt_header_offset_words32,
@@ -435,7 +445,7 @@ template <typename T> UHD_INLINE T get_context_code(
buffs, total_num_samps_sent*io_type.size,
std::min(total_num_samps_unsent, max_samples_per_packet),
if_packet_info,
- io_type, otw_type,
+ converter,
vrt_packer,
get_send_buffs,
vrt_header_offset_words32,
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
deleted file mode 100644
index bea20a4aa..000000000
--- a/host/lib/types.cpp
+++ /dev/null
@@ -1,350 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#include <uhd/utils/assert.hpp>
-#include <uhd/types/tune_request.hpp>
-#include <uhd/types/tune_result.hpp>
-#include <uhd/types/clock_config.hpp>
-#include <uhd/types/stream_cmd.hpp>
-#include <uhd/types/metadata.hpp>
-#include <uhd/types/ranges.hpp>
-#include <uhd/types/time_spec.hpp>
-#include <uhd/types/device_addr.hpp>
-#include <uhd/types/mac_addr.hpp>
-#include <uhd/types/otw_type.hpp>
-#include <uhd/types/io_type.hpp>
-#include <uhd/types/serial.hpp>
-#include <boost/math/special_functions/round.hpp>
-#include <boost/foreach.hpp>
-#include <boost/format.hpp>
-#include <boost/cstdint.hpp>
-#include <boost/assign/list_of.hpp>
-#include <boost/thread.hpp>
-#include <stdexcept>
-#include <complex>
-#include <sstream>
-
-using namespace uhd;
-
-/***********************************************************************
- * ranges template instantiation
- **********************************************************************/
-template struct uhd::meta_range_t<float>;
-template struct uhd::meta_range_t<double>;
-
-/***********************************************************************
- * tune request
- **********************************************************************/
-tune_request_t::tune_request_t(double target_freq):
- target_freq(target_freq),
- inter_freq_policy(POLICY_AUTO),
- dsp_freq_policy(POLICY_AUTO)
-{
- /* NOP */
-}
-
-tune_request_t::tune_request_t(double target_freq, double lo_off):
- target_freq(target_freq),
- inter_freq_policy(POLICY_MANUAL),
- inter_freq(target_freq + lo_off),
- dsp_freq_policy(POLICY_AUTO)
-{
- /* NOP */
-}
-
-/***********************************************************************
- * tune result
- **********************************************************************/
-std::string tune_result_t::to_pp_string(void) const{
- return str(boost::format(
- "Tune Result:\n"
- " Target Intermediate Freq: %f (MHz)\n"
- " Actual Intermediate Freq: %f (MHz)\n"
- " Target DSP Freq Shift: %f (MHz)\n"
- " Actual DSP Freq Shift: %f (MHz)\n"
- )
- % (target_inter_freq/1e6) % (actual_inter_freq/1e6)
- % (target_dsp_freq/1e6) % (actual_dsp_freq/1e6)
- );
-}
-
-/***********************************************************************
- * clock config
- **********************************************************************/
-clock_config_t::clock_config_t(void):
- ref_source(REF_INT),
- pps_source(PPS_INT),
- pps_polarity(PPS_NEG)
-{
- /* NOP */
-}
-
-/***********************************************************************
- * stream command
- **********************************************************************/
-stream_cmd_t::stream_cmd_t(const stream_mode_t &stream_mode):
- stream_mode(stream_mode),
- num_samps(0),
- stream_now(true)
-{
- /* NOP */
-}
-
-/***********************************************************************
- * metadata
- **********************************************************************/
-tx_metadata_t::tx_metadata_t(void):
- has_time_spec(false),
- time_spec(time_spec_t()),
- start_of_burst(false),
- end_of_burst(false)
-{
- /* NOP */
-}
-
-/***********************************************************************
- * time spec
- **********************************************************************/
-time_spec_t::time_spec_t(double secs):
- _full_secs(0),
- _frac_secs(secs)
-{
- /* NOP */
-}
-
-time_spec_t::time_spec_t(time_t full_secs, double frac_secs):
- _full_secs(full_secs),
- _frac_secs(frac_secs)
-{
- /* NOP */
-}
-
-time_spec_t::time_spec_t(time_t full_secs, long tick_count, double tick_rate):
- _full_secs(full_secs),
- _frac_secs(double(tick_count)/tick_rate)
-{
- /* NOP */
-}
-
-long time_spec_t::get_tick_count(double tick_rate) const{
- return boost::math::iround(this->get_frac_secs()*tick_rate);
-}
-
-double time_spec_t::get_real_secs(void) const{
- return this->_full_secs + this->_frac_secs;
-}
-
-time_t time_spec_t::get_full_secs(void) const{
- double intpart;
- std::modf(this->_frac_secs, &intpart);
- return this->_full_secs + time_t(intpart);
-}
-
-double time_spec_t::get_frac_secs(void) const{
- return std::fmod(this->_frac_secs, 1.0);
-}
-
-time_spec_t &time_spec_t::operator+=(const time_spec_t &rhs){
- this->_full_secs += rhs.get_full_secs();
- this->_frac_secs += rhs.get_frac_secs();
- return *this;
-}
-
-time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){
- this->_full_secs -= rhs.get_full_secs();
- this->_frac_secs -= rhs.get_frac_secs();
- return *this;
-}
-
-bool uhd::operator==(const time_spec_t &lhs, const time_spec_t &rhs){
- return
- lhs.get_full_secs() == rhs.get_full_secs() and
- lhs.get_frac_secs() == rhs.get_frac_secs()
- ;
-}
-
-bool uhd::operator<(const time_spec_t &lhs, const time_spec_t &rhs){
- return (
- (lhs.get_full_secs() < rhs.get_full_secs()) or (
- (lhs.get_full_secs() == rhs.get_full_secs()) and
- (lhs.get_frac_secs() < rhs.get_frac_secs())
- ));
-}
-
-/***********************************************************************
- * device addr
- **********************************************************************/
-static const std::string arg_delim = ",";
-static const std::string pair_delim = "=";
-
-static std::string trim(const std::string &in){
- return boost::algorithm::trim_copy(in);
-}
-
-device_addr_t::device_addr_t(const std::string &args){
- BOOST_FOREACH(const std::string &pair, std::split_string(args, arg_delim)){
- if (trim(pair) == "") continue;
-
- std::vector<std::string> key_val = std::split_string(pair, pair_delim);
- if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args);
- (*this)[trim(key_val.front())] = trim(key_val.back());
- }
-}
-
-std::string device_addr_t::to_pp_string(void) const{
- if (this->size() == 0) return "Empty Device Address";
-
- std::stringstream ss;
- ss << "Device Address:" << std::endl;
- BOOST_FOREACH(std::string key, this->keys()){
- ss << boost::format(" %s: %s") % key % (*this)[key] << std::endl;
- }
- return ss.str();
-}
-
-std::string device_addr_t::to_string(void) const{
- std::string args_str;
- size_t count = 0;
- BOOST_FOREACH(const std::string &key, this->keys()){
- args_str += ((count++)? arg_delim : "") + key + pair_delim + (*this)[key];
- }
- return args_str;
-}
-
-/***********************************************************************
- * mac addr
- **********************************************************************/
-mac_addr_t::mac_addr_t(const byte_vector_t &bytes) : _bytes(bytes){
- UHD_ASSERT_THROW(_bytes.size() == 6);
-}
-
-mac_addr_t mac_addr_t::from_bytes(const byte_vector_t &bytes){
- return mac_addr_t(bytes);
-}
-
-mac_addr_t mac_addr_t::from_string(const std::string &mac_addr_str){
-
- byte_vector_t bytes;
-
- try{
- if (mac_addr_str.size() != 17){
- throw std::runtime_error("expected exactly 17 characters");
- }
-
- //split the mac addr hex string at the colons
- BOOST_FOREACH(const std::string &hex_str, std::split_string(mac_addr_str, ":")){
- int hex_num;
- std::istringstream iss(hex_str);
- iss >> std::hex >> hex_num;
- bytes.push_back(boost::uint8_t(hex_num));
- }
-
- }
- catch(std::exception const& e){
- throw std::runtime_error(str(
- boost::format("Invalid mac address: %s\n\t%s") % mac_addr_str % e.what()
- ));
- }
-
- return mac_addr_t::from_bytes(bytes);
-}
-
-byte_vector_t mac_addr_t::to_bytes(void) const{
- return _bytes;
-}
-
-std::string mac_addr_t::to_string(void) const{
- std::string addr = "";
- BOOST_FOREACH(boost::uint8_t byte, this->to_bytes()){
- addr += str(boost::format("%s%02x") % ((addr == "")?"":":") % int(byte));
- }
- return addr;
-}
-
-/***********************************************************************
- * otw type
- **********************************************************************/
-size_t otw_type_t::get_sample_size(void) const{
- return (this->width * 2) / 8;
-}
-
-otw_type_t::otw_type_t(void):
- width(0),
- shift(0),
- byteorder(BO_NATIVE)
-{
- /* NOP */
-}
-
-/***********************************************************************
- * io type
- **********************************************************************/
-static size_t tid_to_size(io_type_t::tid_t tid){
- switch(tid){
- case io_type_t::COMPLEX_FLOAT32: return sizeof(std::complex<float>);
- case io_type_t::COMPLEX_INT16: return sizeof(std::complex<boost::int16_t>);
- case io_type_t::COMPLEX_INT8: return sizeof(std::complex<boost::int8_t>);
- default: throw std::runtime_error("unknown io type tid");
- }
-}
-
-io_type_t::io_type_t(tid_t tid)
-: size(tid_to_size(tid)), tid(tid){
- /* NOP */
-}
-
-io_type_t::io_type_t(size_t size)
-: size(size), tid(CUSTOM_TYPE){
- /* NOP */
-}
-
-/***********************************************************************
- * serial
- **********************************************************************/
-spi_config_t::spi_config_t(edge_t edge):
- mosi_edge(edge),
- miso_edge(edge)
-{
- /* NOP */
-}
-
-void i2c_iface::write_eeprom(
- boost::uint8_t addr,
- boost::uint8_t offset,
- const byte_vector_t &bytes
-){
- for (size_t i = 0; i < bytes.size(); i++){
- //write a byte at a time, its easy that way
- byte_vector_t cmd = boost::assign::list_of(offset+i)(bytes[i]);
- this->write_i2c(addr, cmd);
- boost::this_thread::sleep(boost::posix_time::milliseconds(10)); //worst case write
- }
-}
-
-byte_vector_t i2c_iface::read_eeprom(
- boost::uint8_t addr,
- boost::uint8_t offset,
- size_t num_bytes
-){
- byte_vector_t bytes;
- for (size_t i = 0; i < num_bytes; i++){
- //do a zero byte write to start read cycle
- this->write_i2c(addr, byte_vector_t(1, offset+i));
- bytes.push_back(this->read_i2c(addr, 1).at(0));
- }
- return bytes;
-}
diff --git a/firmware/microblaze/usrp2/Makefile.am b/host/lib/types/CMakeLists.txt
index 7a58e7253..dfb7cf903 100644
--- a/firmware/microblaze/usrp2/Makefile.am
+++ b/host/lib/types/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2011 Ettus Research LLC
#
# 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
@@ -15,33 +15,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-include $(top_srcdir)/Makefile.common
-
-AM_CFLAGS = \
- $(COMMON_CFLAGS)
-
-AM_LDFLAGS = \
- $(COMMON_LFLAGS) \
- -Wl,-defsym -Wl,_TEXT_START_ADDR=0x0050 \
- -Wl,-defsym -Wl,_STACK_SIZE=3072
-
-LDADD = libusrp2.a
-
-LDADD = libusrp2.a
-
########################################################################
-# USRP2 specific library and programs
+# This file included, use CMake directory variables
########################################################################
-noinst_LIBRARIES = libusrp2.a
-
-libusrp2_a_SOURCES = \
- $(COMMON_SRCS) \
- sd.c \
- ethernet.c \
- udp_fw_update.c
-
-noinst_PROGRAMS = \
- usrp2_txrx_uhd.elf
-
-usrp2_txrx_uhd_elf_SOURCES = \
- $(top_srcdir)/apps/txrx_uhd.c
+LIBUHD_APPEND_SOURCES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/clock_config.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/device_addr.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac_addr.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ranges.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/sensors.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/serial.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/time_spec.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/tune.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/types.cpp
+)
diff --git a/host/lib/types/clock_config.cpp b/host/lib/types/clock_config.cpp
new file mode 100644
index 000000000..c150c5cc3
--- /dev/null
+++ b/host/lib/types/clock_config.cpp
@@ -0,0 +1,44 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/clock_config.hpp>
+
+using namespace uhd;
+
+clock_config_t clock_config_t::external(void){
+ clock_config_t clock_config;
+ clock_config.ref_source = clock_config_t::REF_SMA;
+ clock_config.pps_source = clock_config_t::PPS_SMA;
+ clock_config.pps_polarity = clock_config_t::PPS_POS;
+ return clock_config;
+}
+
+clock_config_t clock_config_t::internal(void){
+ clock_config_t clock_config;
+ clock_config.ref_source = clock_config_t::REF_INT;
+ clock_config.pps_source = clock_config_t::PPS_SMA;
+ clock_config.pps_polarity = clock_config_t::PPS_POS;
+ return clock_config;
+}
+
+clock_config_t::clock_config_t(void):
+ ref_source(REF_INT),
+ pps_source(PPS_SMA),
+ pps_polarity(PPS_POS)
+{
+ /* NOP */
+}
diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp
new file mode 100644
index 000000000..14afaa24b
--- /dev/null
+++ b/host/lib/types/device_addr.cpp
@@ -0,0 +1,73 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/device_addr.hpp>
+#include <boost/algorithm/string.hpp> //for trim
+#include <boost/tokenizer.hpp>
+#include <boost/foreach.hpp>
+#include <boost/format.hpp>
+#include <stdexcept>
+#include <sstream>
+
+using namespace uhd;
+
+static const std::string arg_delim = ",";
+static const std::string pair_delim = "=";
+
+static std::string trim(const std::string &in){
+ return boost::algorithm::trim_copy(in);
+}
+
+#define tokenizer(inp, sep) \
+ boost::tokenizer<boost::char_separator<char> > \
+ (inp, boost::char_separator<char>(sep.c_str()))
+
+device_addr_t::device_addr_t(const std::string &args){
+ BOOST_FOREACH(const std::string &pair, tokenizer(args, arg_delim)){
+ if (trim(pair) == "") continue;
+ std::string key;
+ BOOST_FOREACH(const std::string &tok, tokenizer(pair, pair_delim)){
+ if (key.empty()) key = tok;
+ else{
+ this->set(trim(key), trim(tok));
+ goto continue_next_arg;
+ }
+ }
+ throw std::runtime_error("invalid args string: "+args);
+ continue_next_arg: continue;
+ }
+}
+
+std::string device_addr_t::to_pp_string(void) const{
+ if (this->size() == 0) return "Empty Device Address";
+
+ std::stringstream ss;
+ ss << "Device Address:" << std::endl;
+ BOOST_FOREACH(std::string key, this->keys()){
+ ss << boost::format(" %s: %s") % key % this->get(key) << std::endl;
+ }
+ return ss.str();
+}
+
+std::string device_addr_t::to_string(void) const{
+ std::string args_str;
+ size_t count = 0;
+ BOOST_FOREACH(const std::string &key, this->keys()){
+ args_str += ((count++)? arg_delim : "") + key + pair_delim + this->get(key);
+ }
+ return args_str;
+}
diff --git a/host/lib/types/mac_addr.cpp b/host/lib/types/mac_addr.cpp
new file mode 100644
index 000000000..cf3c3fa97
--- /dev/null
+++ b/host/lib/types/mac_addr.cpp
@@ -0,0 +1,76 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/mac_addr.hpp>
+#include <uhd/utils/assert.hpp>
+#include <boost/tokenizer.hpp>
+#include <boost/foreach.hpp>
+#include <boost/format.hpp>
+#include <boost/cstdint.hpp>
+#include <stdexcept>
+#include <sstream>
+
+using namespace uhd;
+
+mac_addr_t::mac_addr_t(const byte_vector_t &bytes) : _bytes(bytes){
+ UHD_ASSERT_THROW(_bytes.size() == 6);
+}
+
+mac_addr_t mac_addr_t::from_bytes(const byte_vector_t &bytes){
+ return mac_addr_t(bytes);
+}
+
+mac_addr_t mac_addr_t::from_string(const std::string &mac_addr_str){
+
+ byte_vector_t bytes;
+
+ try{
+ if (mac_addr_str.size() != 17){
+ throw std::runtime_error("expected exactly 17 characters");
+ }
+
+ //split the mac addr hex string at the colons
+ boost::tokenizer<boost::char_separator<char> > hex_num_toks(
+ mac_addr_str, boost::char_separator<char>(":"));
+ BOOST_FOREACH(const std::string &hex_str, hex_num_toks){
+ int hex_num;
+ std::istringstream iss(hex_str);
+ iss >> std::hex >> hex_num;
+ bytes.push_back(boost::uint8_t(hex_num));
+ }
+
+ }
+ catch(std::exception const& e){
+ throw std::runtime_error(str(
+ boost::format("Invalid mac address: %s\n\t%s") % mac_addr_str % e.what()
+ ));
+ }
+
+ return mac_addr_t::from_bytes(bytes);
+}
+
+byte_vector_t mac_addr_t::to_bytes(void) const{
+ return _bytes;
+}
+
+std::string mac_addr_t::to_string(void) const{
+ std::string addr = "";
+ BOOST_FOREACH(boost::uint8_t byte, this->to_bytes()){
+ addr += str(boost::format("%s%02x") % ((addr == "")?"":":") % int(byte));
+ }
+ return addr;
+}
diff --git a/host/lib/types/ranges.cpp b/host/lib/types/ranges.cpp
new file mode 100644
index 000000000..4a0d05d80
--- /dev/null
+++ b/host/lib/types/ranges.cpp
@@ -0,0 +1,163 @@
+//
+// Copyright 2011-2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/ranges.hpp>
+#include <boost/math/special_functions/round.hpp>
+#include <boost/foreach.hpp>
+#include <algorithm>
+#include <stdexcept>
+#include <sstream>
+
+using namespace uhd;
+
+/***********************************************************************
+ * range_t implementation code
+ **********************************************************************/
+struct range_t::impl{
+ impl(double start, double stop, double step):
+ start(start), stop(stop), step(step)
+ {
+ /* NOP */
+ }
+ double start, stop, step;
+};
+
+range_t::range_t(double value):
+ _impl(UHD_PIMPL_MAKE(impl, (value, value, 0)))
+{
+ /* NOP */
+}
+
+range_t::range_t(
+ double start, double stop, double step
+):
+ _impl(UHD_PIMPL_MAKE(impl, (start, stop, step)))
+{
+ if (stop < start){
+ throw std::invalid_argument("cannot make range where stop < start");
+ }
+}
+
+double range_t::start(void) const{
+ return _impl->start;
+}
+
+double range_t::stop(void) const{
+ return _impl->stop;
+}
+
+double range_t::step(void) const{
+ return _impl->step;
+}
+
+const std::string range_t::to_pp_string(void) const{
+ std::stringstream ss;
+ ss << "(" << this->start();
+ if (this->start() != this->stop()) ss << ", " << this->stop();
+ if (this->step() != 0) ss << ", " << this->step();
+ ss << ")";
+ return ss.str();
+}
+
+/***********************************************************************
+ * meta_range_t implementation code
+ **********************************************************************/
+void check_meta_range_monotonic(const meta_range_t &mr){
+ if (mr.empty()){
+ throw std::runtime_error("meta-range cannot be empty");
+ }
+ for (size_t i = 1; i < mr.size(); i++){
+ if (mr.at(i).start() < mr.at(i-1).stop()){
+ throw std::runtime_error("meta-range is not monotonic");
+ }
+ }
+}
+
+meta_range_t::meta_range_t(void){
+ /* NOP */
+}
+
+meta_range_t::meta_range_t(
+ double start, double stop, double step
+):
+ std::vector<range_t > (1, range_t(start, stop, step))
+{
+ /* NOP */
+}
+
+double meta_range_t::start(void) const{
+ check_meta_range_monotonic(*this);
+ double min_start = this->front().start();
+ BOOST_FOREACH(const range_t &r, (*this)){
+ min_start = std::min(min_start, r.start());
+ }
+ return min_start;
+}
+
+double meta_range_t::stop(void) const{
+ check_meta_range_monotonic(*this);
+ double max_stop = this->front().stop();
+ BOOST_FOREACH(const range_t &r, (*this)){
+ max_stop = std::max(max_stop, r.stop());
+ }
+ return max_stop;
+}
+
+double meta_range_t::step(void) const{
+ check_meta_range_monotonic(*this);
+ std::vector<double> non_zero_steps;
+ range_t last = this->front();
+ BOOST_FOREACH(const range_t &r, (*this)){
+ //steps at each range
+ if (r.step() > 0) non_zero_steps.push_back(r.step());
+ //and steps in-between ranges
+ double ibtw_step = r.start() - last.stop();
+ if (ibtw_step > 0) non_zero_steps.push_back(ibtw_step);
+ //store ref to last
+ last = r;
+ }
+ if (non_zero_steps.empty()) return 0; //all zero steps, its zero...
+ return *std::min_element(non_zero_steps.begin(), non_zero_steps.end());
+}
+
+double meta_range_t::clip(double value, bool clip_step) const{
+ check_meta_range_monotonic(*this);
+ double last_stop = this->front().stop();
+ BOOST_FOREACH(const range_t &r, (*this)){
+ //in-between ranges, clip to nearest
+ if (value < r.start()){
+ return (std::abs(value - r.start()) < std::abs(value - last_stop))?
+ r.start() : last_stop;
+ }
+ //in this range, clip here
+ if (value <= r.stop()){
+ if (not clip_step or r.step() == 0) return value;
+ return boost::math::round((value - r.start())/r.step())*r.step() + r.start();
+ }
+ //continue on to the next range
+ last_stop = r.stop();
+ }
+ return last_stop;
+}
+
+const std::string meta_range_t::to_pp_string(void) const{
+ std::stringstream ss;
+ BOOST_FOREACH(const range_t &r, (*this)){
+ ss << r.to_pp_string() << std::endl;
+ }
+ return ss.str();
+}
diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp
new file mode 100644
index 000000000..2bff136a4
--- /dev/null
+++ b/host/lib/types/sensors.cpp
@@ -0,0 +1,81 @@
+//
+// Copyright 2011-2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/sensors.hpp>
+#include <uhd/utils/exception.hpp>
+#include <boost/format.hpp>
+
+using namespace uhd;
+
+sensor_value_t::sensor_value_t(
+ const std::string &name,
+ bool value,
+ const std::string &ufalse,
+ const std::string &utrue
+):
+ name(name), value(value?"true":"false"),
+ unit(value?utrue:ufalse), type(BOOLEAN)
+{
+ /* NOP */
+}
+
+sensor_value_t::sensor_value_t(
+ const std::string &name,
+ int_type value,
+ const std::string &unit,
+ const std::string &formatter
+):
+ name(name), value(str(boost::format(formatter) % value)),
+ unit(unit), type(INTEGER)
+{
+ /* NOP */
+}
+
+sensor_value_t::sensor_value_t(
+ const std::string &name,
+ real_type value,
+ const std::string &unit,
+ const std::string &formatter
+):
+ name(name), value(str(boost::format(formatter) % value)),
+ unit(unit), type(REALNUM)
+{
+ /* NOP */
+}
+
+sensor_value_t::sensor_value_t(
+ const std::string &name,
+ const std::string &value,
+ const std::string &unit
+):
+ name(name), value(value),
+ unit(unit), type(STRING)
+{
+ /* NOP */
+}
+
+std::string sensor_value_t::to_pp_string(void) const{
+ switch(type){
+ case BOOLEAN:
+ return str(boost::format("%s: %s") % name % unit);
+ case INTEGER:
+ case REALNUM:
+ case STRING:
+ return str(boost::format("%s: %s %s") % name % value % unit);
+ }
+ UHD_THROW_INVALID_CODE_PATH();
+}
diff --git a/host/lib/types/serial.cpp b/host/lib/types/serial.cpp
new file mode 100644
index 000000000..9acf7156a
--- /dev/null
+++ b/host/lib/types/serial.cpp
@@ -0,0 +1,56 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/serial.hpp>
+#include <boost/thread.hpp> //for sleeping
+#include <boost/assign/list_of.hpp>
+
+using namespace uhd;
+
+spi_config_t::spi_config_t(edge_t edge):
+ mosi_edge(edge),
+ miso_edge(edge)
+{
+ /* NOP */
+}
+
+void i2c_iface::write_eeprom(
+ boost::uint8_t addr,
+ boost::uint8_t offset,
+ const byte_vector_t &bytes
+){
+ for (size_t i = 0; i < bytes.size(); i++){
+ //write a byte at a time, its easy that way
+ byte_vector_t cmd = boost::assign::list_of(offset+i)(bytes[i]);
+ this->write_i2c(addr, cmd);
+ boost::this_thread::sleep(boost::posix_time::milliseconds(10)); //worst case write
+ }
+}
+
+byte_vector_t i2c_iface::read_eeprom(
+ boost::uint8_t addr,
+ boost::uint8_t offset,
+ size_t num_bytes
+){
+ byte_vector_t bytes;
+ for (size_t i = 0; i < num_bytes; i++){
+ //do a zero byte write to start read cycle
+ this->write_i2c(addr, byte_vector_t(1, offset+i));
+ bytes.push_back(this->read_i2c(addr, 1).at(0));
+ }
+ return bytes;
+}
diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp
new file mode 100644
index 000000000..f39625a11
--- /dev/null
+++ b/host/lib/types/time_spec.cpp
@@ -0,0 +1,86 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/time_spec.hpp>
+#include <boost/math/special_functions/round.hpp>
+
+using namespace uhd;
+time_spec_t::time_spec_t(double secs):
+ _full_secs(0),
+ _frac_secs(secs)
+{
+ /* NOP */
+}
+
+time_spec_t::time_spec_t(time_t full_secs, double frac_secs):
+ _full_secs(full_secs),
+ _frac_secs(frac_secs)
+{
+ /* NOP */
+}
+
+time_spec_t::time_spec_t(time_t full_secs, long tick_count, double tick_rate):
+ _full_secs(full_secs),
+ _frac_secs(double(tick_count)/tick_rate)
+{
+ /* NOP */
+}
+
+long time_spec_t::get_tick_count(double tick_rate) const{
+ return boost::math::iround(this->get_frac_secs()*tick_rate);
+}
+
+double time_spec_t::get_real_secs(void) const{
+ return this->_full_secs + this->_frac_secs;
+}
+
+time_t time_spec_t::get_full_secs(void) const{
+ double intpart;
+ std::modf(this->_frac_secs, &intpart);
+ return this->_full_secs + time_t(intpart);
+}
+
+double time_spec_t::get_frac_secs(void) const{
+ return std::fmod(this->_frac_secs, 1.0);
+}
+
+time_spec_t &time_spec_t::operator+=(const time_spec_t &rhs){
+ this->_full_secs += rhs.get_full_secs();
+ this->_frac_secs += rhs.get_frac_secs();
+ return *this;
+}
+
+time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){
+ this->_full_secs -= rhs.get_full_secs();
+ this->_frac_secs -= rhs.get_frac_secs();
+ return *this;
+}
+
+bool uhd::operator==(const time_spec_t &lhs, const time_spec_t &rhs){
+ return
+ lhs.get_full_secs() == rhs.get_full_secs() and
+ lhs.get_frac_secs() == rhs.get_frac_secs()
+ ;
+}
+
+bool uhd::operator<(const time_spec_t &lhs, const time_spec_t &rhs){
+ return (
+ (lhs.get_full_secs() < rhs.get_full_secs()) or (
+ (lhs.get_full_secs() == rhs.get_full_secs()) and
+ (lhs.get_frac_secs() < rhs.get_frac_secs())
+ ));
+}
diff --git a/host/lib/types/tune.cpp b/host/lib/types/tune.cpp
new file mode 100644
index 000000000..601bc20e8
--- /dev/null
+++ b/host/lib/types/tune.cpp
@@ -0,0 +1,52 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/tune_request.hpp>
+#include <uhd/types/tune_result.hpp>
+#include <boost/format.hpp>
+
+using namespace uhd;
+
+tune_request_t::tune_request_t(double target_freq):
+ target_freq(target_freq),
+ inter_freq_policy(POLICY_AUTO),
+ dsp_freq_policy(POLICY_AUTO)
+{
+ /* NOP */
+}
+
+tune_request_t::tune_request_t(double target_freq, double lo_off):
+ target_freq(target_freq),
+ inter_freq_policy(POLICY_MANUAL),
+ inter_freq(target_freq + lo_off),
+ dsp_freq_policy(POLICY_AUTO)
+{
+ /* NOP */
+}
+
+std::string tune_result_t::to_pp_string(void) const{
+ return str(boost::format(
+ "Tune Result:\n"
+ " Target Intermediate Freq: %f (MHz)\n"
+ " Actual Intermediate Freq: %f (MHz)\n"
+ " Target DSP Freq Shift: %f (MHz)\n"
+ " Actual DSP Freq Shift: %f (MHz)\n"
+ )
+ % (target_inter_freq/1e6) % (actual_inter_freq/1e6)
+ % (target_dsp_freq/1e6) % (actual_dsp_freq/1e6)
+ );
+}
diff --git a/host/lib/types/types.cpp b/host/lib/types/types.cpp
new file mode 100644
index 000000000..34d5947eb
--- /dev/null
+++ b/host/lib/types/types.cpp
@@ -0,0 +1,86 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/types/stream_cmd.hpp>
+#include <uhd/types/metadata.hpp>
+#include <uhd/types/otw_type.hpp>
+#include <uhd/types/io_type.hpp>
+#include <boost/cstdint.hpp>
+#include <stdexcept>
+#include <complex>
+
+using namespace uhd;
+
+/***********************************************************************
+ * stream command
+ **********************************************************************/
+stream_cmd_t::stream_cmd_t(const stream_mode_t &stream_mode):
+ stream_mode(stream_mode),
+ num_samps(0),
+ stream_now(true)
+{
+ /* NOP */
+}
+
+/***********************************************************************
+ * metadata
+ **********************************************************************/
+tx_metadata_t::tx_metadata_t(void):
+ has_time_spec(false),
+ time_spec(time_spec_t()),
+ start_of_burst(false),
+ end_of_burst(false)
+{
+ /* NOP */
+}
+
+/***********************************************************************
+ * otw type
+ **********************************************************************/
+size_t otw_type_t::get_sample_size(void) const{
+ return (this->width * 2) / 8;
+}
+
+otw_type_t::otw_type_t(void):
+ width(0),
+ shift(0),
+ byteorder(BO_NATIVE)
+{
+ /* NOP */
+}
+
+/***********************************************************************
+ * io type
+ **********************************************************************/
+static size_t tid_to_size(io_type_t::tid_t tid){
+ switch(tid){
+ case io_type_t::COMPLEX_FLOAT32: return sizeof(std::complex<float>);
+ case io_type_t::COMPLEX_INT16: return sizeof(std::complex<boost::int16_t>);
+ case io_type_t::COMPLEX_INT8: return sizeof(std::complex<boost::int8_t>);
+ default: throw std::runtime_error("unknown io type tid");
+ }
+}
+
+io_type_t::io_type_t(tid_t tid)
+: size(tid_to_size(tid)), tid(tid){
+ /* NOP */
+}
+
+io_type_t::io_type_t(size_t size)
+: size(size), tid(CUSTOM_TYPE){
+ /* NOP */
+}
diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt
index 9dc74a5fe..bd25aec2b 100644
--- a/host/lib/usrp/CMakeLists.txt
+++ b/host/lib/usrp/CMakeLists.txt
@@ -25,6 +25,7 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dboard_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dsp_utils.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mboard_eeprom.cpp
${CMAKE_CURRENT_SOURCE_DIR}/misc_utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/multi_usrp.cpp
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp
index f771595b6..b311576d2 100644
--- a/host/lib/usrp/dboard/db_basic_and_lf.cpp
+++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -134,7 +134,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- val = float(0);
+ val = double(0);
return;
case SUBDEV_PROP_GAIN_RANGE:
@@ -192,7 +192,7 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){
switch(key.as<subdev_prop_t>()){
case SUBDEV_PROP_GAIN:
- UHD_ASSERT_THROW(val.as<float>() == float(0));
+ UHD_ASSERT_THROW(val.as<double>() == double(0));
return;
case SUBDEV_PROP_ANTENNA:
@@ -245,7 +245,7 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- val = float(0);
+ val = double(0);
return;
case SUBDEV_PROP_GAIN_RANGE:
@@ -303,7 +303,7 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){
switch(key.as<subdev_prop_t>()){
case SUBDEV_PROP_GAIN:
- UHD_ASSERT_THROW(val.as<float>() == float(0));
+ UHD_ASSERT_THROW(val.as<double>() == double(0));
return;
case SUBDEV_PROP_ANTENNA:
diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp
index 7250136f5..3ea9cea80 100644
--- a/host/lib/usrp/dboard/db_dbsrx.cpp
+++ b/host/lib/usrp/dboard/db_dbsrx.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -70,7 +70,7 @@ public:
private:
double _lo_freq;
double _bandwidth;
- uhd::dict<std::string, float> _gains;
+ uhd::dict<std::string, double> _gains;
max2118_write_regs_t _max2118_write_regs;
max2118_read_regs_t _max2118_read_regs;
boost::uint8_t _max2118_addr(void){
@@ -78,7 +78,7 @@ private:
};
void set_lo_freq(double target_freq);
- void set_gain(float gain, const std::string &name);
+ void set_gain(double gain, const std::string &name);
void set_bandwidth(double bandwidth);
void send_reg(boost::uint8_t start_reg, boost::uint8_t stop_reg){
@@ -418,17 +418,17 @@ void dbsrx::set_lo_freq(double target_freq){
* \param gain the requested gain in dB
* \return 5 bit the register value
*/
-static int gain_to_gc2_vga_reg(float &gain){
+static int gain_to_gc2_vga_reg(double &gain){
int reg = 0;
gain = dbsrx_gain_ranges["GC2"].clip(gain);
// Half dB steps from 0-5dB, 1dB steps from 5-24dB
if (gain < 5) {
reg = boost::math::iround(31.0 - gain/0.5);
- gain = float(boost::math::iround(gain) * 0.5);
+ gain = double(boost::math::iround(gain) * 0.5);
} else {
reg = boost::math::iround(22.0 - (gain - 4.0));
- gain = float(boost::math::iround(gain));
+ gain = double(boost::math::iround(gain));
}
if (dbsrx_debug) std::cerr << boost::format(
@@ -444,16 +444,16 @@ static int gain_to_gc2_vga_reg(float &gain){
* \param gain the requested gain in dB
* \return dac voltage value
*/
-static float gain_to_gc1_rfvga_dac(float &gain){
+static double gain_to_gc1_rfvga_dac(double &gain){
//clip the input
gain = dbsrx_gain_ranges["GC1"].clip(gain);
//voltage level constants
- static const float max_volts = float(1.2), min_volts = float(2.7);
- static const float slope = (max_volts-min_volts)/dbsrx_gain_ranges["GC1"].stop();
+ static const double max_volts = 1.2, min_volts = 2.7;
+ static const double slope = (max_volts-min_volts)/dbsrx_gain_ranges["GC1"].stop();
//calculate the voltage for the aux dac
- float dac_volts = gain*slope + min_volts;
+ double dac_volts = gain*slope + min_volts;
if (dbsrx_debug) std::cerr << boost::format(
"DBSRX GC1 Gain: %f dB, dac_volts: %f V"
@@ -465,7 +465,7 @@ static float gain_to_gc1_rfvga_dac(float &gain){
return dac_volts;
}
-void dbsrx::set_gain(float gain, const std::string &name){
+void dbsrx::set_gain(double gain, const std::string &name){
assert_has(dbsrx_gain_ranges.keys(), name, "dbsrx gain name");
if (name == "GC2"){
_max2118_write_regs.gc2 = gain_to_gc2_vga_reg(gain);
@@ -584,7 +584,7 @@ void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_gain(val.as<float>(), key.name);
+ this->set_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_ENABLED:
diff --git a/host/lib/usrp/dboard/db_dbsrx2.cpp b/host/lib/usrp/dboard/db_dbsrx2.cpp
index cdafd6a78..defb70ff5 100644
--- a/host/lib/usrp/dboard/db_dbsrx2.cpp
+++ b/host/lib/usrp/dboard/db_dbsrx2.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -48,7 +48,7 @@ static const int dbsrx2_ref_divider = 4; // Hitachi HMC426 divider (U7)
static const prop_names_t dbsrx2_antennas = list_of("J3");
static const uhd::dict<std::string, gain_range_t> dbsrx2_gain_ranges = map_list_of
- ("GC1", gain_range_t(0, 73, float(0.05)))
+ ("GC1", gain_range_t(0, 73, 0.05))
("BBG", gain_range_t(0, 15, 1))
;
@@ -66,7 +66,7 @@ public:
private:
double _lo_freq;
double _bandwidth;
- uhd::dict<std::string, float> _gains;
+ uhd::dict<std::string, double> _gains;
max2112_write_regs_t _max2112_write_regs;
max2112_read_regs_t _max2112_read_regs;
boost::uint8_t _max2112_addr(){ //0x60 or 0x61 depending on which side
@@ -74,7 +74,7 @@ private:
}
void set_lo_freq(double target_freq);
- void set_gain(float gain, const std::string &name);
+ void set_gain(double gain, const std::string &name);
void set_bandwidth(double bandwidth);
void send_reg(boost::uint8_t start_reg, boost::uint8_t stop_reg){
@@ -269,10 +269,10 @@ void dbsrx2::set_lo_freq(double target_freq){
* \param gain the requested gain in dB
* \return 4 bit the register value
*/
-static int gain_to_bbg_vga_reg(float &gain){
+static int gain_to_bbg_vga_reg(double &gain){
int reg = boost::math::iround(dbsrx2_gain_ranges["BBG"].clip(gain));
- gain = float(reg);
+ gain = double(reg);
if (dbsrx2_debug) std::cerr
<< boost::format("DBSRX2 BBG Gain:\n")
@@ -288,16 +288,16 @@ static int gain_to_bbg_vga_reg(float &gain){
* \param gain the requested gain in dB
* \return dac voltage value
*/
-static float gain_to_gc1_rfvga_dac(float &gain){
+static double gain_to_gc1_rfvga_dac(double &gain){
//clip the input
gain = dbsrx2_gain_ranges["GC1"].clip(gain);
//voltage level constants
- static const float max_volts = float(0.5), min_volts = float(2.7);
- static const float slope = (max_volts-min_volts)/dbsrx2_gain_ranges["GC1"].stop();
+ static const double max_volts = 0.5, min_volts = 2.7;
+ static const double slope = (max_volts-min_volts)/dbsrx2_gain_ranges["GC1"].stop();
//calculate the voltage for the aux dac
- float dac_volts = gain*slope + min_volts;
+ double dac_volts = gain*slope + min_volts;
if (dbsrx2_debug) std::cerr
<< boost::format("DBSRX2 GC1 Gain:\n")
@@ -310,7 +310,7 @@ static float gain_to_gc1_rfvga_dac(float &gain){
return dac_volts;
}
-void dbsrx2::set_gain(float gain, const std::string &name){
+void dbsrx2::set_gain(double gain, const std::string &name){
assert_has(dbsrx2_gain_ranges.keys(), name, "dbsrx2 gain name");
if (name == "BBG"){
_max2112_write_regs.bbg = gain_to_bbg_vga_reg(gain);
@@ -423,7 +423,7 @@ void dbsrx2::rx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_gain(val.as<float>(), key.name);
+ this->set_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_ENABLED:
diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp
index 74a9fb37b..cd25ee9b7 100644
--- a/host/lib/usrp/dboard/db_rfx.cpp
+++ b/host/lib/usrp/dboard/db_rfx.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -67,11 +67,11 @@ static const prop_names_t rfx_rx_antennas = list_of("TX/RX")("RX2");
static const uhd::dict<std::string, gain_range_t> rfx_tx_gain_ranges; //empty
static const uhd::dict<std::string, gain_range_t> rfx_rx_gain_ranges = map_list_of
- ("PGA0", gain_range_t(0, 70, float(0.022)))
+ ("PGA0", gain_range_t(0, 70, 0.022))
;
static const uhd::dict<std::string, gain_range_t> rfx400_rx_gain_ranges = map_list_of
- ("PGA0", gain_range_t(0, 45, float(0.022)))
+ ("PGA0", gain_range_t(0, 45, 0.022))
;
/***********************************************************************
@@ -98,14 +98,14 @@ private:
const uhd::dict<dboard_iface::unit_t, bool> _div2;
double _rx_lo_freq, _tx_lo_freq;
std::string _rx_ant;
- uhd::dict<std::string, float> _rx_gains;
+ uhd::dict<std::string, double> _rx_gains;
void set_rx_lo_freq(double freq);
void set_tx_lo_freq(double freq);
void set_rx_ant(const std::string &ant);
void set_tx_ant(const std::string &ant);
- void set_rx_gain(float gain, const std::string &name);
- void set_tx_gain(float gain, const std::string &name);
+ void set_rx_gain(double gain, const std::string &name);
+ void set_tx_gain(double gain, const std::string &name);
/*!
* Set the LO frequency for the particular dboard unit.
@@ -240,13 +240,13 @@ void rfx_xcvr::set_tx_ant(const std::string &ant){
/***********************************************************************
* Gain Handling
**********************************************************************/
-static float rx_pga0_gain_to_dac_volts(float &gain, float range){
+static double rx_pga0_gain_to_dac_volts(double &gain, double range){
//voltage level constants (negative slope)
- static const float max_volts = float(.2), min_volts = float(1.2);
- static const float slope = (max_volts-min_volts)/(range);
+ static const double max_volts = .2, min_volts = 1.2;
+ static const double slope = (max_volts-min_volts)/(range);
//calculate the voltage for the aux dac
- float dac_volts = std::clip<float>(gain*slope + min_volts, max_volts, min_volts);
+ double dac_volts = std::clip<double>(gain*slope + min_volts, max_volts, min_volts);
//the actual gain setting
gain = (dac_volts - min_volts)/slope;
@@ -254,15 +254,15 @@ static float rx_pga0_gain_to_dac_volts(float &gain, float range){
return dac_volts;
}
-void rfx_xcvr::set_tx_gain(float, const std::string &name){
+void rfx_xcvr::set_tx_gain(double, const std::string &name){
assert_has(rfx_tx_gain_ranges.keys(), name, "rfx tx gain name");
UHD_THROW_INVALID_CODE_PATH(); //no gains to set
}
-void rfx_xcvr::set_rx_gain(float gain, const std::string &name){
+void rfx_xcvr::set_rx_gain(double gain, const std::string &name){
assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name");
if(name == "PGA0"){
- float dac_volts = rx_pga0_gain_to_dac_volts(gain,
+ double dac_volts = rx_pga0_gain_to_dac_volts(gain,
(_rx_gain_ranges["PGA0"].stop() - _rx_gain_ranges["PGA0"].start()));
_rx_gains[name] = gain;
@@ -474,7 +474,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_rx_gain(val.as<float>(), key.name);
+ this->set_rx_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_ANTENNA:
@@ -571,7 +571,7 @@ void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_tx_gain(val.as<float>(), key.name);
+ this->set_tx_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_ANTENNA:
diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp
index 2508555d0..4eb29c3e8 100644
--- a/host/lib/usrp/dboard/db_tvrx.cpp
+++ b/host/lib/usrp/dboard/db_tvrx.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -119,8 +119,8 @@ static uhd::dict<std::string, gain_range_t> get_tvrx_gain_ranges(void) {
double ifmax = tvrx_if_gains_db.back();
return map_list_of
- ("RF", gain_range_t(float(rfmin), float(rfmax), float((rfmax-rfmin)/4096.0)))
- ("IF", gain_range_t(float(ifmin), float(ifmax), float((ifmax-ifmin)/4096.0)))
+ ("RF", gain_range_t(rfmin, rfmax, (rfmax-rfmin)/4096.0))
+ ("IF", gain_range_t(ifmin, ifmax, (ifmax-ifmin)/4096.0))
;
}
@@ -141,14 +141,14 @@ public:
void rx_set(const wax::obj &key, const wax::obj &val);
private:
- uhd::dict<std::string, float> _gains;
+ uhd::dict<std::string, double> _gains;
double _lo_freq;
tuner_4937di5_regs_t _tuner_4937di5_regs;
boost::uint8_t _tuner_4937di5_addr(void){
return (this->get_iface()->get_special_props().mangle_i2c_addrs)? 0x61 : 0x60; //ok really? we could rename that call
};
- void set_gain(float gain, const std::string &name);
+ void set_gain(double gain, const std::string &name);
void set_freq(double freq);
void update_regs(void){
@@ -275,7 +275,7 @@ static double gain_interp(double gain, boost::array<double, 17> db_vector, boost
* \return dac voltage value
*/
-static float rf_gain_to_voltage(float gain, double lo_freq){
+static double rf_gain_to_voltage(double gain, double lo_freq){
//clip the input
gain = get_tvrx_gain_ranges()["RF"].clip(gain);
@@ -293,7 +293,7 @@ static float rf_gain_to_voltage(float gain, double lo_freq){
"tvrx RF AGC gain: %f dB, dac_volts: %f V"
) % gain % dac_volts << std::endl;
- return float(dac_volts);
+ return dac_volts;
}
/*!
@@ -303,7 +303,7 @@ static float rf_gain_to_voltage(float gain, double lo_freq){
* \return dac voltage value
*/
-static float if_gain_to_voltage(float gain){
+static double if_gain_to_voltage(double gain){
//clip the input
gain = get_tvrx_gain_ranges()["IF"].clip(gain);
@@ -316,10 +316,10 @@ static float if_gain_to_voltage(float gain){
"tvrx IF AGC gain: %f dB, dac_volts: %f V"
) % gain % dac_volts << std::endl;
- return float(dac_volts);
+ return dac_volts;
}
-void tvrx::set_gain(float gain, const std::string &name){
+void tvrx::set_gain(double gain, const std::string &name){
assert_has(get_tvrx_gain_ranges().keys(), name, "tvrx gain name");
if (name == "RF"){
this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, dboard_iface::AUX_DAC_B, rf_gain_to_voltage(gain, _lo_freq));
@@ -473,7 +473,7 @@ void tvrx::rx_set(const wax::obj &key_, const wax::obj &val){
//handle the get request conditioned on the key
switch(key.as<subdev_prop_t>()){
case SUBDEV_PROP_GAIN:
- this->set_gain(val.as<float>(), key.name);
+ this->set_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_FREQ:
diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp
index 168e1971c..d91d58409 100644
--- a/host/lib/usrp/dboard/db_unknown.cpp
+++ b/host/lib/usrp/dboard/db_unknown.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -115,7 +115,7 @@ void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- val = float(0);
+ val = double(0);
return;
case SUBDEV_PROP_GAIN_RANGE:
@@ -173,7 +173,7 @@ void unknown_rx::rx_set(const wax::obj &key_, const wax::obj &val){
switch(key.as<subdev_prop_t>()){
case SUBDEV_PROP_GAIN:
- UHD_ASSERT_THROW(val.as<float>() == float(0));
+ UHD_ASSERT_THROW(val.as<double>() == double(0));
return;
case SUBDEV_PROP_ANTENNA:
@@ -217,7 +217,7 @@ void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- val = float(0);
+ val = double(0);
return;
case SUBDEV_PROP_GAIN_RANGE:
@@ -275,7 +275,7 @@ void unknown_tx::tx_set(const wax::obj &key_, const wax::obj &val){
switch(key.as<subdev_prop_t>()){
case SUBDEV_PROP_GAIN:
- UHD_ASSERT_THROW(val.as<float>() == float(0));
+ UHD_ASSERT_THROW(val.as<double>() == double(0));
return;
case SUBDEV_PROP_ANTENNA:
diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp
index dd5bd600b..135997789 100644
--- a/host/lib/usrp/dboard/db_wbx.cpp
+++ b/host/lib/usrp/dboard/db_wbx.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -94,11 +94,11 @@ static const prop_names_t wbx_tx_antennas = list_of("TX/RX");
static const prop_names_t wbx_rx_antennas = list_of("TX/RX")("RX2");
static const uhd::dict<std::string, gain_range_t> wbx_tx_gain_ranges = map_list_of
- ("PGA0", gain_range_t(0, 25, float(0.05)))
+ ("PGA0", gain_range_t(0, 25, 0.05))
;
static const uhd::dict<std::string, gain_range_t> wbx_rx_gain_ranges = map_list_of
- ("PGA0", gain_range_t(0, 31.5, float(0.5)))
+ ("PGA0", gain_range_t(0, 31.5, 0.5))
;
/***********************************************************************
@@ -116,7 +116,7 @@ public:
void tx_set(const wax::obj &key, const wax::obj &val);
private:
- uhd::dict<std::string, float> _tx_gains, _rx_gains;
+ uhd::dict<std::string, double> _tx_gains, _rx_gains;
double _rx_lo_freq, _tx_lo_freq;
std::string _tx_ant, _rx_ant;
@@ -124,8 +124,8 @@ private:
void set_tx_lo_freq(double freq);
void set_rx_ant(const std::string &ant);
void set_tx_ant(const std::string &ant);
- void set_rx_gain(float gain, const std::string &name);
- void set_tx_gain(float gain, const std::string &name);
+ void set_rx_gain(double gain, const std::string &name);
+ void set_tx_gain(double gain, const std::string &name);
void update_atr(void);
@@ -196,12 +196,12 @@ wbx_xcvr::~wbx_xcvr(void){
/***********************************************************************
* Gain Handling
**********************************************************************/
-static int rx_pga0_gain_to_iobits(float &gain){
+static int rx_pga0_gain_to_iobits(double &gain){
//clip the input
gain = wbx_rx_gain_ranges["PGA0"].clip(gain);
//convert to attenuation and update iobits for atr
- float attn = wbx_rx_gain_ranges["PGA0"].stop() - gain;
+ double attn = wbx_rx_gain_ranges["PGA0"].stop() - gain;
//calculate the attenuation
int attn_code = boost::math::iround(attn*2);
@@ -212,21 +212,21 @@ static int rx_pga0_gain_to_iobits(float &gain){
) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK << std::endl;
//the actual gain setting
- gain = wbx_rx_gain_ranges["PGA0"].stop() - float(attn_code)/2;
+ gain = wbx_rx_gain_ranges["PGA0"].stop() - double(attn_code)/2;
return iobits;
}
-static float tx_pga0_gain_to_dac_volts(float &gain){
+static double tx_pga0_gain_to_dac_volts(double &gain){
//clip the input
gain = wbx_tx_gain_ranges["PGA0"].clip(gain);
//voltage level constants
- static const float max_volts = float(0.5), min_volts = float(1.4);
- static const float slope = (max_volts-min_volts)/wbx_tx_gain_ranges["PGA0"].stop();
+ static const double max_volts = 0.5, min_volts = 1.4;
+ static const double slope = (max_volts-min_volts)/wbx_tx_gain_ranges["PGA0"].stop();
//calculate the voltage for the aux dac
- float dac_volts = gain*slope + min_volts;
+ double dac_volts = gain*slope + min_volts;
if (wbx_debug) std::cerr << boost::format(
"WBX TX Gain: %f dB, dac_volts: %f V"
@@ -238,10 +238,10 @@ static float tx_pga0_gain_to_dac_volts(float &gain){
return dac_volts;
}
-void wbx_xcvr::set_tx_gain(float gain, const std::string &name){
+void wbx_xcvr::set_tx_gain(double gain, const std::string &name){
assert_has(wbx_tx_gain_ranges.keys(), name, "wbx tx gain name");
if(name == "PGA0"){
- float dac_volts = tx_pga0_gain_to_dac_volts(gain);
+ double dac_volts = tx_pga0_gain_to_dac_volts(gain);
_tx_gains[name] = gain;
//write the new voltage to the aux dac
@@ -250,7 +250,7 @@ void wbx_xcvr::set_tx_gain(float gain, const std::string &name){
else UHD_THROW_INVALID_CODE_PATH();
}
-void wbx_xcvr::set_rx_gain(float gain, const std::string &name){
+void wbx_xcvr::set_rx_gain(double gain, const std::string &name){
assert_has(wbx_rx_gain_ranges.keys(), name, "wbx rx gain name");
if(name == "PGA0"){
rx_pga0_gain_to_iobits(gain);
@@ -544,7 +544,7 @@ void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_rx_gain(val.as<float>(), key.name);
+ this->set_rx_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_ANTENNA:
@@ -645,7 +645,7 @@ void wbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_tx_gain(val.as<float>(), key.name);
+ this->set_tx_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_ANTENNA:
diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp
index e76727bec..6fb5a26a8 100644
--- a/host/lib/usrp/dboard/db_xcvr2450.cpp
+++ b/host/lib/usrp/dboard/db_xcvr2450.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -73,8 +73,8 @@ using namespace boost::assign;
static const bool xcvr2450_debug = false;
static const freq_range_t xcvr_freq_range = list_of
- (range_t<double>(2.4e9, 2.5e9))
- (range_t<double>(4.9e9, 6.0e9))
+ (range_t(2.4e9, 2.5e9))
+ (range_t(4.9e9, 6.0e9))
;
static const prop_names_t xcvr_antennas = list_of("J1")("J2");
@@ -85,9 +85,9 @@ static const uhd::dict<std::string, gain_range_t> xcvr_tx_gain_ranges = map_list
;
static const uhd::dict<std::string, gain_range_t> xcvr_rx_gain_ranges = map_list_of
("LNA", gain_range_t(list_of
- (range_t<float>(0))
- (range_t<float>(15))
- (range_t<float>(30.5))
+ (range_t(0))
+ (range_t(15))
+ (range_t(30.5))
))
("VGA", gain_range_t(0, 62, 2.0))
;
@@ -109,7 +109,7 @@ public:
private:
double _lo_freq;
double _rx_bandwidth, _tx_bandwidth;
- uhd::dict<std::string, float> _tx_gains, _rx_gains;
+ uhd::dict<std::string, double> _tx_gains, _rx_gains;
std::string _tx_ant, _rx_ant;
int _ad9515div;
max2829_regs_t _max2829_regs;
@@ -117,8 +117,8 @@ private:
void set_lo_freq(double target_freq);
void set_tx_ant(const std::string &ant);
void set_rx_ant(const std::string &ant);
- void set_tx_gain(float gain, const std::string &name);
- void set_rx_gain(float gain, const std::string &name);
+ void set_tx_gain(double gain, const std::string &name);
+ void set_rx_gain(double gain, const std::string &name);
void set_rx_bandwidth(double bandwidth);
void set_tx_bandwidth(double bandwidth);
@@ -150,12 +150,12 @@ private:
* Read the RSSI from the aux adc
* \return the rssi in dB
*/
- float get_rssi(void){
+ double get_rssi(void){
//constants for the rssi calculation
- static const float min_v = float(0.5), max_v = float(2.5);
- static const float rssi_dyn_range = 60;
+ static const double min_v = 0.5, max_v = 2.5;
+ static const double rssi_dyn_range = 60;
//calculate the rssi from the voltage
- float voltage = this->get_iface()->read_aux_adc(dboard_iface::UNIT_RX, dboard_iface::AUX_ADC_B);
+ double voltage = this->get_iface()->read_aux_adc(dboard_iface::UNIT_RX, dboard_iface::AUX_ADC_B);
return rssi_dyn_range*(voltage - min_v)/(max_v - min_v);
}
};
@@ -355,14 +355,14 @@ void xcvr2450::set_rx_ant(const std::string &ant){
* \param gain the requested gain in dB
* \return 6 bit the register value
*/
-static int gain_to_tx_vga_reg(float &gain){
+static int gain_to_tx_vga_reg(double &gain){
//calculate the register value
int reg = std::clip(boost::math::iround(gain*60/30.0) + 3, 0, 63);
//calculate the actual gain value
if (reg < 4) gain = 0;
- else if (reg < 48) gain = float(reg/2 - 1);
- else gain = float(reg/2.0 - 1.5);
+ else if (reg < 48) gain = double(reg/2 - 1);
+ else gain = double(reg/2.0 - 1.5);
//return register value
return reg;
@@ -374,7 +374,7 @@ static int gain_to_tx_vga_reg(float &gain){
* \param gain the requested gain in dB
* \return gain enum value
*/
-static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(float &gain){
+static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(double &gain){
int reg = std::clip(boost::math::iround(gain*3/5.0), 0, 3);
switch(reg){
case 0:
@@ -399,9 +399,9 @@ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(float &gain){
* \param gain the requested gain in dB
* \return 5 bit the register value
*/
-static int gain_to_rx_vga_reg(float &gain){
+static int gain_to_rx_vga_reg(double &gain){
int reg = std::clip(boost::math::iround(gain/2.0), 0, 31);
- gain = float(reg*2);
+ gain = double(reg*2);
return reg;
}
@@ -411,7 +411,7 @@ static int gain_to_rx_vga_reg(float &gain){
* \param gain the requested gain in dB
* \return 2 bit the register value
*/
-static int gain_to_rx_lna_reg(float &gain){
+static int gain_to_rx_lna_reg(double &gain){
int reg = std::clip(boost::math::iround(gain*2/30.5) + 1, 0, 3);
switch(reg){
case 0:
@@ -422,7 +422,7 @@ static int gain_to_rx_lna_reg(float &gain){
return reg;
}
-void xcvr2450::set_tx_gain(float gain, const std::string &name){
+void xcvr2450::set_tx_gain(double gain, const std::string &name){
assert_has(xcvr_tx_gain_ranges.keys(), name, "xcvr tx gain name");
if (name == "VGA"){
_max2829_regs.tx_vga_gain = gain_to_tx_vga_reg(gain);
@@ -436,7 +436,7 @@ void xcvr2450::set_tx_gain(float gain, const std::string &name){
_tx_gains[name] = gain;
}
-void xcvr2450::set_rx_gain(float gain, const std::string &name){
+void xcvr2450::set_rx_gain(double gain, const std::string &name){
assert_has(xcvr_rx_gain_ranges.keys(), name, "xcvr rx gain name");
if (name == "VGA"){
_max2829_regs.rx_vga_gain = gain_to_rx_vga_reg(gain);
@@ -643,7 +643,7 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_rx_gain(val.as<float>(), key.name);
+ this->set_rx_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_ANTENNA:
@@ -742,7 +742,7 @@ void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){
return;
case SUBDEV_PROP_GAIN:
- this->set_tx_gain(val.as<float>(), key.name);
+ this->set_tx_gain(val.as<double>(), key.name);
return;
case SUBDEV_PROP_BANDWIDTH:
diff --git a/host/lib/usrp/usrp2/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp
index 2273b2cd9..3c7c00134 100644
--- a/host/lib/usrp/usrp2/gps_ctrl.cpp
+++ b/host/lib/usrp/gps_ctrl.cpp
@@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include "gps_ctrl.hpp"
+#include <uhd/usrp/gps_ctrl.hpp>
#include <uhd/utils/assert.hpp>
#include <boost/cstdint.hpp>
#include <string>
@@ -30,14 +30,15 @@ using namespace boost::posix_time;
using namespace boost::algorithm;
/*!
- * A usrp2 GPS control for Jackson Labs devices
+ * A GPS control for Jackson Labs devices (and other NMEA compatible GPS's)
*/
//TODO: multiple baud rate support (requires mboard_impl changes for poking UART registers)
-class usrp2_gps_ctrl_impl : public usrp2_gps_ctrl{
+class gps_ctrl_impl : public gps_ctrl{
public:
- usrp2_gps_ctrl_impl(usrp2_iface::sptr iface){
- _iface = iface;
+ gps_ctrl_impl(gps_send_fn_t send, gps_recv_fn_t recv){
+ _send = send;
+ _recv = recv;
std::string reply;
bool i_heard_some_nmea = false, i_heard_something_weird = false;
@@ -47,8 +48,8 @@ public:
// set_uart_baud_rate(GPS_UART, 115200);
//first we look for a Jackson Labs Firefly (since that's what we sell with the USRP2+...)
- _iface->read_uart(GPS_UART); //get whatever junk is in the rx buffer right now, and throw it away
- _iface->write_uart(GPS_UART, "HAAAY GUYYYYS\n"); //to elicit a response from the Firefly
+ _recv(); //get whatever junk is in the rx buffer right now, and throw it away
+ _send("HAAAY GUYYYYS\n"); //to elicit a response from the Firefly
//then we loop until we either timeout, or until we get a response that indicates we're a JL device
int timeout = GPS_TIMEOUT_TRIES;
@@ -60,13 +61,14 @@ public:
}
else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response
else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate
+ boost::this_thread::sleep(boost::posix_time::milliseconds(200));
}
if((i_heard_some_nmea) && (gps_type != GPS_TYPE_JACKSON_LABS)) gps_type = GPS_TYPE_GENERIC_NMEA;
//otherwise, we can try some other common baud rates looking to see if a GPS is connected (todo, later)
if((gps_type == GPS_TYPE_NONE) && i_heard_something_weird) {
- std::cout << "Invalid reply, possible incorrect baud rate" << std::endl;
+ std::cout << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl;
}
bool found_gprmc = false;
@@ -78,15 +80,15 @@ public:
//none of these should issue replies so we don't bother looking for them
//we have to sleep between commands because the JL device, despite not acking, takes considerable time to process each command.
boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS));
- _iface->write_uart(GPS_UART, "SYST:COMM:SER:ECHO OFF\n");
+ _send("SYST:COMM:SER:ECHO OFF\n");
boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS));
- _iface->write_uart(GPS_UART, "SYST:COMM:SER:PRO OFF\n");
+ _send("SYST:COMM:SER:PRO OFF\n");
boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS));
- _iface->write_uart(GPS_UART, "GPS:GPGGA 0\n");
+ _send("GPS:GPGGA 0\n");
boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS));
- _iface->write_uart(GPS_UART, "GPS:GGAST 0\n");
+ _send("GPS:GGAST 0\n");
boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS));
- _iface->write_uart(GPS_UART, "GPS:GPRMC 1\n");
+ _send("GPS:GPRMC 1\n");
boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS));
// break;
@@ -119,15 +121,15 @@ public:
}
- ~usrp2_gps_ctrl_impl(void){
+ ~gps_ctrl_impl(void){
}
+//TODO: this isn't generalizeable to non-USRP2 USRPs.
std::string safe_gps_read() {
std::string reply;
try {
- reply = _iface->read_uart(GPS_UART);
- //std::cerr << "Got reply from GPS: " << reply.c_str() << " with length = " << reply.length() << std::endl;
+ reply = _recv();
} catch (std::runtime_error err) {
if(err.what() != std::string("usrp2 no control response")) throw; //sorry can't cope with that
else { //we don't actually have a GPS installed
@@ -185,7 +187,8 @@ public:
}
private:
- usrp2_iface::sptr _iface;
+ gps_send_fn_t _send;
+ gps_recv_fn_t _recv;
enum {
GPS_TYPE_JACKSON_LABS,
@@ -193,8 +196,8 @@ private:
GPS_TYPE_NONE
} gps_type;
- static const int GPS_UART = 2; //TODO: this should be plucked from fw_common.h or memory_map.h or somewhere in common with the firmware
static const int GPS_TIMEOUT_TRIES = 5;
+ static const int GPS_TIMEOUT_DELAY_MS = 200;
static const int FIREFLY_STUPID_DELAY_MS = 200;
};
@@ -202,6 +205,6 @@ private:
/***********************************************************************
* Public make function for the GPS control
**********************************************************************/
-usrp2_gps_ctrl::sptr usrp2_gps_ctrl::make(usrp2_iface::sptr iface){
- return sptr(new usrp2_gps_ctrl_impl(iface));
+gps_ctrl::sptr gps_ctrl::make(gps_send_fn_t send, gps_recv_fn_t recv){
+ return sptr(new gps_ctrl_impl(send, recv));
}
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index 863a80191..f7f4b2c68 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -97,8 +97,14 @@ static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
N100_EEPROM_ADDR, USRP_N100_OFFSETS["name"], NAME_MAX_LEN
));
- //empty serial correction: use the mac address
- if (mb_eeprom["serial"].empty()) mb_eeprom["serial"] = mb_eeprom["mac-addr"];
+ //Empty serial correction: use the mac address to determine serial.
+ //Older usrp2 models don't have a serial burned into EEPROM.
+ //The lower mac address bits will function as the serial number.
+ if (mb_eeprom["serial"].empty()){
+ byte_vector_t mac_addr_bytes = mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes();
+ unsigned serial = mac_addr_bytes.at(5) | (unsigned(mac_addr_bytes.at(4) & 0x0f) << 8);
+ mb_eeprom["serial"] = boost::lexical_cast<std::string>(serial);
+ }
}
static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp
index 5856d706f..02f4b216d 100644
--- a/host/lib/usrp/misc_utils.cpp
+++ b/host/lib/usrp/misc_utils.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -39,24 +39,24 @@ static gain_range_t get_codec_gain_range(wax::obj codec, const std::string &name
return codec[named_prop_t(CODEC_PROP_GAIN_RANGE, name)].as<gain_range_t>();
}
-static float get_codec_gain_i(wax::obj codec, const std::string &name){
- return codec[named_prop_t(CODEC_PROP_GAIN_I, name)].as<float>();
+static double get_codec_gain_i(wax::obj codec, const std::string &name){
+ return codec[named_prop_t(CODEC_PROP_GAIN_I, name)].as<double>();
}
-static float get_codec_gain_q(wax::obj codec, const std::string &name){
- return codec[named_prop_t(CODEC_PROP_GAIN_Q, name)].as<float>();
+static double get_codec_gain_q(wax::obj codec, const std::string &name){
+ return codec[named_prop_t(CODEC_PROP_GAIN_Q, name)].as<double>();
}
-static void set_codec_gain_both(wax::obj codec, const std::string &name, float gain){
+static void set_codec_gain_both(wax::obj codec, const std::string &name, double gain){
codec[named_prop_t(CODEC_PROP_GAIN_I, name)] = gain;
codec[named_prop_t(CODEC_PROP_GAIN_Q, name)] = gain;
}
-static void set_codec_gain_i(wax::obj codec, const std::string &name, float gain){
+static void set_codec_gain_i(wax::obj codec, const std::string &name, double gain){
codec[named_prop_t(CODEC_PROP_GAIN_I, name)] = gain;
}
-static void set_codec_gain_q(wax::obj codec, const std::string &name, float gain){
+static void set_codec_gain_q(wax::obj codec, const std::string &name, double gain){
codec[named_prop_t(CODEC_PROP_GAIN_Q, name)] = gain;
}
@@ -64,15 +64,15 @@ static void set_codec_gain_q(wax::obj codec, const std::string &name, float gain
* subdev gain group helper functions:
* do this so we dont have to bind a templated function
**********************************************************************/
-static float get_subdev_gain(wax::obj subdev, const std::string &name){
- return subdev[named_prop_t(SUBDEV_PROP_GAIN, name)].as<float>();
+static double get_subdev_gain(wax::obj subdev, const std::string &name){
+ return subdev[named_prop_t(SUBDEV_PROP_GAIN, name)].as<double>();
}
static gain_range_t get_subdev_gain_range(wax::obj subdev, const std::string &name){
return subdev[named_prop_t(SUBDEV_PROP_GAIN_RANGE, name)].as<gain_range_t>();
}
-static void set_subdev_gain(wax::obj subdev, const std::string &name, float gain){
+static void set_subdev_gain(wax::obj subdev, const std::string &name, double gain){
subdev[named_prop_t(SUBDEV_PROP_GAIN, name)] = gain;
}
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 876f1a3fc..48eec28c1 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -117,26 +117,32 @@ public:
return _mboard(0)[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
}
+ time_spec_t get_time_last_pps(void){
+ return _mboard(0)[MBOARD_PROP_TIME_PPS].as<time_spec_t>();
+ }
+
void set_time_next_pps(const time_spec_t &time_spec){
for (size_t m = 0; m < get_num_mboards(); m++){
- _mboard(m)[MBOARD_PROP_TIME_NEXT_PPS] = time_spec;
+ _mboard(m)[MBOARD_PROP_TIME_PPS] = time_spec;
}
}
void set_time_unknown_pps(const time_spec_t &time_spec){
- std::cout << "Set time with unknown pps edge:" << std::endl;
- std::cout << " 1) set times next pps (race condition)" << std::endl;
- set_time_next_pps(time_spec);
- boost::this_thread::sleep(boost::posix_time::seconds(1));
-
- std::cout << " 2) catch seconds rollover at pps edge" << std::endl;
- time_t last_secs = 0, curr_secs = 0;
- while(curr_secs == last_secs){
- last_secs = curr_secs;
- curr_secs = get_time_now().get_full_secs();
+ std::cout << " 1) catch time transition at pps edge" << std::endl;
+ time_spec_t time_start = get_time_now();
+ time_spec_t time_start_last_pps = get_time_last_pps();
+ while(true){
+ if (get_time_last_pps() != time_start_last_pps) break;
+ if ((get_time_now() - time_start) > time_spec_t(1.1)){
+ throw std::runtime_error(
+ "Board 0 may not be getting a PPS signal!\n"
+ "No PPS detected within the time interval.\n"
+ "See the application notes for your device.\n"
+ );
+ }
}
- std::cout << " 3) set times next pps (synchronously)" << std::endl;
+ std::cout << " 2) set times next pps (synchronously)" << std::endl;
set_time_next_pps(time_spec);
boost::this_thread::sleep(boost::posix_time::seconds(1));
@@ -233,11 +239,11 @@ public:
return add_dsp_shift(_rx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp(chan/rx_cpm()));
}
- void set_rx_gain(float gain, const std::string &name, size_t chan){
+ void set_rx_gain(double gain, const std::string &name, size_t chan){
return _rx_gain_group(chan)->set_value(gain, name);
}
- float get_rx_gain(const std::string &name, size_t chan){
+ double get_rx_gain(const std::string &name, size_t chan){
return _rx_gain_group(chan)->get_value(name);
}
@@ -273,8 +279,8 @@ public:
return _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH].as<double>();
}
- float read_rssi(size_t chan){
- return _rx_subdev(chan)[SUBDEV_PROP_RSSI].as<float>();
+ double read_rssi(size_t chan){
+ return _rx_subdev(chan)[SUBDEV_PROP_RSSI].as<double>();
}
dboard_iface::sptr get_rx_dboard_iface(size_t chan){
@@ -331,11 +337,11 @@ public:
return add_dsp_shift(_tx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp(chan/tx_cpm()));
}
- void set_tx_gain(float gain, const std::string &name, size_t chan){
+ void set_tx_gain(double gain, const std::string &name, size_t chan){
return _tx_gain_group(chan)->set_value(gain, name);
}
- float get_tx_gain(const std::string &name, size_t chan){
+ double get_tx_gain(const std::string &name, size_t chan){
return _tx_gain_group(chan)->get_value(name);
}
diff --git a/host/lib/usrp/single_usrp.cpp b/host/lib/usrp/single_usrp.cpp
index a0456d1f0..c37449c5f 100644
--- a/host/lib/usrp/single_usrp.cpp
+++ b/host/lib/usrp/single_usrp.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -106,12 +106,16 @@ public:
return _mboard()[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
}
+ time_spec_t get_time_last_pps(void){
+ return _mboard()[MBOARD_PROP_TIME_PPS].as<time_spec_t>();
+ }
+
void set_time_now(const time_spec_t &time_spec){
_mboard()[MBOARD_PROP_TIME_NOW] = time_spec;
}
void set_time_next_pps(const time_spec_t &time_spec){
- _mboard()[MBOARD_PROP_TIME_NEXT_PPS] = time_spec;
+ _mboard()[MBOARD_PROP_TIME_PPS] = time_spec;
}
void issue_stream_cmd(const stream_cmd_t &stream_cmd){
@@ -160,11 +164,11 @@ public:
return add_dsp_shift(_rx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp());
}
- void set_rx_gain(float gain, const std::string &name, size_t chan){
+ void set_rx_gain(double gain, const std::string &name, size_t chan){
return _rx_gain_group(chan)->set_value(gain, name);
}
- float get_rx_gain(const std::string &name, size_t chan){
+ double get_rx_gain(const std::string &name, size_t chan){
return _rx_gain_group(chan)->get_value(name);
}
@@ -200,8 +204,8 @@ public:
return _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH].as<double>();
}
- float read_rssi(size_t chan){
- return _rx_subdev(chan)[SUBDEV_PROP_RSSI].as<float>();
+ double read_rssi(size_t chan){
+ return _rx_subdev(chan)[SUBDEV_PROP_RSSI].as<double>();
}
dboard_iface::sptr get_rx_dboard_iface(size_t chan){
@@ -246,11 +250,11 @@ public:
return add_dsp_shift(_tx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp());
}
- void set_tx_gain(float gain, const std::string &name, size_t chan){
+ void set_tx_gain(double gain, const std::string &name, size_t chan){
return _tx_gain_group(chan)->set_value(gain, name);
}
- float get_tx_gain(const std::string &name, size_t chan){
+ double get_tx_gain(const std::string &name, size_t chan){
return _tx_gain_group(chan)->get_value(name);
}
diff --git a/host/lib/usrp/subdev_spec.cpp b/host/lib/usrp/subdev_spec.cpp
index 95d2cbb12..51c88bda3 100644
--- a/host/lib/usrp/subdev_spec.cpp
+++ b/host/lib/usrp/subdev_spec.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -16,15 +16,21 @@
//
#include <uhd/usrp/subdev_spec.hpp>
-#include <uhd/utils/algorithm.hpp>
+#include <boost/algorithm/string.hpp> //for split
+#include <boost/tokenizer.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
#include <stdexcept>
#include <sstream>
+#include <vector>
using namespace uhd;
using namespace uhd::usrp;
+#define pair_tokenizer(inp) \
+ boost::tokenizer<boost::char_separator<char> > \
+ (inp, boost::char_separator<char>(" "))
+
subdev_spec_pair_t::subdev_spec_pair_t(
const std::string &db_name, const std::string &sd_name
):
@@ -39,9 +45,9 @@ bool usrp::operator==(const subdev_spec_pair_t &lhs, const subdev_spec_pair_t &r
}
subdev_spec_t::subdev_spec_t(const std::string &markup){
- BOOST_FOREACH(const std::string &pair, std::split_string(markup)){
+ BOOST_FOREACH(const std::string &pair, pair_tokenizer(markup)){
if (pair == "") continue;
- std::vector<std::string> db_sd = std::split_string(pair, ":");
+ std::vector<std::string> db_sd; boost::split(db_sd, pair, boost::is_any_of(":"));
switch(db_sd.size()){
case 1: this->push_back(subdev_spec_pair_t("", db_sd.front())); break;
case 2: this->push_back(subdev_spec_pair_t(db_sd.front(), db_sd.back())); break;
diff --git a/host/lib/usrp/usrp1/CMakeLists.txt b/host/lib/usrp/usrp1/CMakeLists.txt
index 519e17bfa..9e50f5728 100644
--- a/host/lib/usrp/usrp1/CMakeLists.txt
+++ b/host/lib/usrp/usrp1/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -38,6 +38,7 @@ IF(ENABLE_USRP1)
${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/soft_time_ctrl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/usrp1_iface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/usrp1_iface.hpp
${CMAKE_CURRENT_SOURCE_DIR}/usrp1_impl.cpp
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index 18f794632..f3816b377 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -35,7 +35,7 @@ using namespace uhd;
static const bool codec_debug = false;
-const gain_range_t usrp1_codec_ctrl::tx_pga_gain_range(-20, 0, float(0.1));
+const gain_range_t usrp1_codec_ctrl::tx_pga_gain_range(-20, 0, double(0.1));
const gain_range_t usrp1_codec_ctrl::rx_pga_gain_range(0, 20, 1);
/***********************************************************************
@@ -50,17 +50,18 @@ public:
~usrp1_codec_ctrl_impl(void);
//aux adc and dac control
- float read_aux_adc(aux_adc_t which);
- void write_aux_dac(aux_dac_t which, float volts);
+ double read_aux_adc(aux_adc_t which);
+ void write_aux_dac(aux_dac_t which, double volts);
//duc control
void set_duc_freq(double freq);
+ void enable_tx_digital(bool enb);
//pga gain control
- void set_tx_pga_gain(float);
- float get_tx_pga_gain(void);
- void set_rx_pga_gain(float, char);
- float get_rx_pga_gain(char);
+ void set_tx_pga_gain(double);
+ double get_tx_pga_gain(void);
+ void set_rx_pga_gain(double, char);
+ double get_rx_pga_gain(char);
//rx adc buffer control
void bypass_adc_buffers(bool bypass);
@@ -159,19 +160,19 @@ usrp1_codec_ctrl_impl::~usrp1_codec_ctrl_impl(void)
**********************************************************************/
static const int mtpgw = 255; //maximum tx pga gain word
-void usrp1_codec_ctrl_impl::set_tx_pga_gain(float gain){
+void usrp1_codec_ctrl_impl::set_tx_pga_gain(double gain){
int gain_word = int(mtpgw*(gain - tx_pga_gain_range.start())/(tx_pga_gain_range.stop() - tx_pga_gain_range.start()));
_ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, mtpgw);
this->send_reg(16);
}
-float usrp1_codec_ctrl_impl::get_tx_pga_gain(void){
+double usrp1_codec_ctrl_impl::get_tx_pga_gain(void){
return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.stop() - tx_pga_gain_range.start())/mtpgw) + tx_pga_gain_range.start();
}
static const int mrpgw = 0x14; //maximum rx pga gain word
-void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which){
+void usrp1_codec_ctrl_impl::set_rx_pga_gain(double gain, char which){
int gain_word = int(mrpgw*(gain - rx_pga_gain_range.start())/(rx_pga_gain_range.stop() - rx_pga_gain_range.start()));
gain_word = std::clip(gain_word, 0, mrpgw);
switch(which){
@@ -187,7 +188,7 @@ void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which){
}
}
-float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which){
+double usrp1_codec_ctrl_impl::get_rx_pga_gain(char which){
int gain_word;
switch(which){
case 'A': gain_word = _ad9862_regs.rx_pga_a; break;
@@ -200,12 +201,12 @@ float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which){
/***********************************************************************
* Codec Control AUX ADC Methods
**********************************************************************/
-static float aux_adc_to_volts(boost::uint8_t high, boost::uint8_t low)
+static double aux_adc_to_volts(boost::uint8_t high, boost::uint8_t low)
{
- return float(((boost::uint16_t(high) << 2) | low)*3.3)/0x3ff;
+ return double(((boost::uint16_t(high) << 2) | low)*3.3)/0x3ff;
}
-float usrp1_codec_ctrl_impl::read_aux_adc(aux_adc_t which)
+double usrp1_codec_ctrl_impl::read_aux_adc(aux_adc_t which)
{
//check to see if the switch needs to be set
bool write_switch = false;
@@ -259,7 +260,7 @@ float usrp1_codec_ctrl_impl::read_aux_adc(aux_adc_t which)
/***********************************************************************
* Codec Control AUX DAC Methods
**********************************************************************/
-void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, float volts)
+void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)
{
//special case for aux dac d (aka sigma delta word)
if (which == AUX_DAC_D) {
@@ -421,6 +422,11 @@ void usrp1_codec_ctrl_impl::set_duc_freq(double freq)
this->send_reg(23);
}
+void usrp1_codec_ctrl_impl::enable_tx_digital(bool enb){
+ _ad9862_regs.tx_digital_pd = (enb)? 0 : 1;
+ this->send_reg(8);
+}
+
/***********************************************************************
* Codec Control ADC buffer bypass
* Disable this for AC-coupled daughterboards (TVRX)
diff --git a/host/lib/usrp/usrp1/codec_ctrl.hpp b/host/lib/usrp/usrp1/codec_ctrl.hpp
index e2e8a010d..20e4015c5 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.hpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -61,7 +61,7 @@ public:
* \param which which of the 4 adcs
* \return a value in volts
*/
- virtual float read_aux_adc(aux_adc_t which) = 0;
+ virtual double read_aux_adc(aux_adc_t which) = 0;
//! aux dac identifier constants
enum aux_dac_t{
@@ -76,23 +76,26 @@ public:
* \param which which of the 4 dacs
* \param volts the level in in volts
*/
- virtual void write_aux_dac(aux_dac_t which, float volts) = 0;
+ virtual void write_aux_dac(aux_dac_t which, double volts) = 0;
//! Set the TX PGA gain
- virtual void set_tx_pga_gain(float gain) = 0;
+ virtual void set_tx_pga_gain(double gain) = 0;
//! Get the TX PGA gain
- virtual float get_tx_pga_gain(void) = 0;
+ virtual double get_tx_pga_gain(void) = 0;
//! Set the RX PGA gain ('A' or 'B')
- virtual void set_rx_pga_gain(float gain, char which) = 0;
+ virtual void set_rx_pga_gain(double gain, char which) = 0;
//! Get the RX PGA gain ('A' or 'B')
- virtual float get_rx_pga_gain(char which) = 0;
+ virtual double get_rx_pga_gain(char which) = 0;
//! Set the TX modulator frequency
virtual void set_duc_freq(double freq) = 0;
-
+
+ //! Enable or disable the digital part of the DAC
+ virtual void enable_tx_digital(bool enb) = 0;
+
//! Enable or disable ADC buffer bypass
virtual void bypass_adc_buffers(bool bypass) = 0;
};
diff --git a/host/lib/usrp/usrp1/codec_impl.cpp b/host/lib/usrp/usrp1/codec_impl.cpp
index db53be53e..14ecd2d2e 100644
--- a/host/lib/usrp/usrp1/codec_impl.cpp
+++ b/host/lib/usrp/usrp1/codec_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -92,12 +92,12 @@ void usrp1_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val, dboard_
switch(key.as<codec_prop_t>()) {
case CODEC_PROP_GAIN_I:
UHD_ASSERT_THROW(key.name == adc_pga_gain_name);
- _codec_ctrls[dboard_slot]->set_rx_pga_gain(val.as<float>(), 'A');
+ _codec_ctrls[dboard_slot]->set_rx_pga_gain(val.as<double>(), 'A');
return;
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == adc_pga_gain_name);
- _codec_ctrls[dboard_slot]->set_rx_pga_gain(val.as<float>(), 'B');
+ _codec_ctrls[dboard_slot]->set_rx_pga_gain(val.as<double>(), 'B');
return;
default: UHD_THROW_PROP_SET_ERROR();
@@ -151,7 +151,7 @@ void usrp1_impl::tx_codec_set(const wax::obj &key_, const wax::obj &val, dboard_
case CODEC_PROP_GAIN_I: //only one gain for I and Q
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == dac_pga_gain_name);
- _codec_ctrls[dboard_slot]->set_tx_pga_gain(val.as<float>());
+ _codec_ctrls[dboard_slot]->set_tx_pga_gain(val.as<double>());
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp
index 4e47d6bf6..eec4a52db 100644
--- a/host/lib/usrp/usrp1/dboard_iface.cpp
+++ b/host/lib/usrp/usrp1/dboard_iface.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -72,8 +72,8 @@ public:
return props;
}
- void write_aux_dac(unit_t, aux_dac_t, float);
- float read_aux_adc(unit_t, aux_adc_t);
+ void write_aux_dac(unit_t, aux_dac_t, double);
+ double read_aux_adc(unit_t, aux_adc_t);
void _set_pin_ctrl(unit_t, boost::uint16_t);
void _set_atr_reg(unit_t, atr_reg_t, boost::uint16_t);
@@ -369,7 +369,7 @@ byte_vector_t usrp1_dboard_iface::read_i2c(boost::uint8_t addr,
* Aux DAX/ADC
**********************************************************************/
void usrp1_dboard_iface::write_aux_dac(dboard_iface::unit_t,
- aux_dac_t which, float value)
+ aux_dac_t which, double value)
{
//same aux dacs for each unit
static const uhd::dict<aux_dac_t, usrp1_codec_ctrl::aux_dac_t>
@@ -382,7 +382,7 @@ void usrp1_dboard_iface::write_aux_dac(dboard_iface::unit_t,
_codec->write_aux_dac(which_to_aux_dac[which], value);
}
-float usrp1_dboard_iface::read_aux_adc(dboard_iface::unit_t unit,
+double usrp1_dboard_iface::read_aux_adc(dboard_iface::unit_t unit,
aux_adc_t which)
{
static const
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp
index 6728d9b15..9fa1b4f72 100644
--- a/host/lib/usrp/usrp1/io_impl.cpp
+++ b/host/lib/usrp/usrp1/io_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -19,7 +19,6 @@
#include "usrp_commands.h"
#include "usrp1_impl.hpp"
#include <uhd/utils/thread_priority.hpp>
-#include <uhd/transport/convert_types.hpp>
#include <uhd/transport/bounded_buffer.hpp>
#include <boost/bind.hpp>
#include <boost/format.hpp>
@@ -92,6 +91,7 @@ struct usrp1_impl::io_impl{
void commit_send_buff(offset_send_buffer::sptr, offset_send_buffer::sptr, size_t);
void flush_send_buff(void);
bool get_send_buffs(vrt_packet_handler::managed_send_buffs_t &, double);
+ bool transmitting_enb;
};
/*!
@@ -184,6 +184,28 @@ void usrp1_impl::io_init(void){
_tx_otw_type.byteorder = otw_type_t::BO_LITTLE_ENDIAN;
_io_impl = UHD_PIMPL_MAKE(io_impl, (_data_transport));
+
+ _soft_time_ctrl = soft_time_ctrl::make(
+ boost::bind(&usrp1_impl::rx_stream_on_off, this, _1)
+ );
+
+ rx_stream_on_off(false);
+ tx_stream_on_off(false);
+}
+
+void usrp1_impl::rx_stream_on_off(bool enb){
+ return _iface->write_firmware_cmd(VRQ_FPGA_SET_RX_ENABLE, enb, 0, 0, 0);
+ //drain any junk in the receive transport after stop streaming command
+ while(not enb and _data_transport->get_recv_buff().get() != NULL){
+ /* NOP */
+ }
+}
+
+void usrp1_impl::tx_stream_on_off(bool enb){
+ if (not enb) _io_impl->flush_send_buff();
+ _codec_ctrls[DBOARD_SLOT_A]->enable_tx_digital(enb);
+ _codec_ctrls[DBOARD_SLOT_B]->enable_tx_digital(enb);
+ _io_impl->transmitting_enb = enb;
}
/***********************************************************************
@@ -209,6 +231,9 @@ size_t usrp1_impl::send(
const tx_metadata_t &metadata, const io_type_t &io_type,
send_mode_t send_mode, double timeout
){
+ if (_soft_time_ctrl->send_pre(metadata, timeout)) return num_samps;
+ if (not _io_impl->transmitting_enb) tx_stream_on_off(true);
+
size_t num_samps_sent = vrt_packet_handler::send(
_io_impl->packet_handler_send_state, //last state of the send handler
buffs, num_samps, //buffer to fill
@@ -222,9 +247,11 @@ size_t usrp1_impl::send(
_tx_subdev_spec.size() //num channels
);
- //Don't honor sob because it is normal to be always bursting...
- //handle eob flag (commit the buffer)
- if (metadata.end_of_burst) _io_impl->flush_send_buff();
+ //handle eob flag (commit the buffer, disable the DACs)
+ //check num samps sent to avoid flush on incomplete/timeout
+ if (metadata.end_of_burst and num_samps_sent == num_samps){
+ this->tx_stream_on_off(false);
+ }
//handle the polling for underflow conditions
_io_impl->underflow_poll_samp_count += num_samps_sent;
@@ -296,6 +323,8 @@ size_t usrp1_impl::recv(
_rx_subdev_spec.size() //num channels
);
+ _soft_time_ctrl->recv_post(metadata, num_samps_recvd);
+
//handle the polling for overflow conditions
_io_impl->overflow_poll_samp_count += num_samps_recvd;
if (_io_impl->overflow_poll_samp_count >= _rx_samps_per_poll_interval){
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index 4df5ada0a..23c8f03c4 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -240,19 +240,6 @@ void usrp1_impl::mboard_init(void)
}
}
-void usrp1_impl::issue_stream_cmd(const stream_cmd_t &stream_cmd)
-{
- switch(stream_cmd.stream_mode){
- case stream_cmd_t::STREAM_MODE_START_CONTINUOUS:
- return _iface->write_firmware_cmd(VRQ_FPGA_SET_RX_ENABLE, true, 0, 0, 0);
-
- case stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS:
- return _iface->write_firmware_cmd(VRQ_FPGA_SET_RX_ENABLE, false, 0, 0, 0);
-
- default: throw std::runtime_error("unsupported stream command type for USRP1");
- }
-}
-
/***********************************************************************
* Mboard Get
**********************************************************************/
@@ -326,6 +313,10 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
val = _iface->mb_eeprom;
return;
+ case MBOARD_PROP_TIME_NOW:
+ val = _soft_time_ctrl->get_time();
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -348,7 +339,7 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
switch(key.as<mboard_prop_t>()){
case MBOARD_PROP_STREAM_CMD:
- issue_stream_cmd(val.as<stream_cmd_t>());
+ _soft_time_ctrl->issue_stream_cmd(val.as<stream_cmd_t>());
return;
case MBOARD_PROP_RX_SUBDEV_SPEC:
@@ -384,6 +375,10 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
_iface->mb_eeprom = mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_B000);
return;
+ case MBOARD_PROP_TIME_NOW:
+ _soft_time_ctrl->set_time(val.as<time_spec_t>());
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/usrp1/soft_time_ctrl.cpp b/host/lib/usrp/usrp1/soft_time_ctrl.cpp
new file mode 100644
index 000000000..4d6abe218
--- /dev/null
+++ b/host/lib/usrp/usrp1/soft_time_ctrl.cpp
@@ -0,0 +1,224 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include "soft_time_ctrl.hpp"
+#include <uhd/transport/bounded_buffer.hpp>
+#include <boost/any.hpp>
+#include <boost/thread.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/local_time/local_time.hpp>
+#include <iostream>
+
+using namespace uhd;
+using namespace uhd::usrp;
+using namespace uhd::transport;
+namespace pt = boost::posix_time;
+namespace lt = boost::local_time;
+
+static const time_spec_t TWIDDLE(0.0015);
+
+/***********************************************************************
+ * Utility helper functions
+ **********************************************************************/
+
+//TODO put these in time_spec_t (maybe useful)
+
+static const double time_dur_tps = double(pt::time_duration::ticks_per_second());
+
+time_spec_t time_dur_to_time_spec(const pt::time_duration &time_dur){
+ return time_spec_t(
+ time_dur.total_seconds(),
+ long(time_dur.fractional_seconds()),
+ time_dur_tps
+ );
+}
+
+pt::time_duration time_spec_to_time_dur(const time_spec_t &time_spec){
+ return pt::time_duration(
+ 0, 0, long(time_spec.get_full_secs()),
+ time_spec.get_tick_count(time_dur_tps)
+ );
+}
+
+/***********************************************************************
+ * Soft time control implementation
+ **********************************************************************/
+class soft_time_ctrl_impl : public soft_time_ctrl{
+public:
+
+ soft_time_ctrl_impl(const cb_fcn_type &stream_on_off):
+ _nsamps_remaining(0),
+ _stream_mode(stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS),
+ _cmd_queue(bounded_buffer<boost::any>::make(2)),
+ _stream_on_off(stream_on_off)
+ {
+ //synchronously spawn a new thread
+ _update_mutex.lock(); //lock mutex before spawned
+ _thread_group.create_thread(boost::bind(&soft_time_ctrl_impl::recv_cmd_dispatcher, this));
+ _update_mutex.lock(); //lock blocks until spawned
+ _update_mutex.unlock(); //unlock mutex before done
+ }
+
+ ~soft_time_ctrl_impl(void){
+ _thread_group.interrupt_all();
+ _thread_group.join_all();
+ }
+
+ /*******************************************************************
+ * Time control
+ ******************************************************************/
+ void set_time(const time_spec_t &time){
+ boost::mutex::scoped_lock lock(_update_mutex);
+ _time_offset = boost::get_system_time() - time_spec_to_time_dur(time);
+ }
+
+ time_spec_t get_time(void){
+ boost::mutex::scoped_lock lock(_update_mutex);
+ return time_now();
+ }
+
+ UHD_INLINE time_spec_t time_now(void){
+ //internal get time without scoped lock
+ return time_dur_to_time_spec(boost::get_system_time() - _time_offset);
+ }
+
+ UHD_INLINE void sleep_until_time(
+ boost::mutex::scoped_lock &lock, const time_spec_t &time
+ ){
+ boost::condition_variable cond;
+ //use a condition variable to unlock, sleep, lock
+ cond.timed_wait(lock, _time_offset + time_spec_to_time_dur(time));
+ }
+
+ /*******************************************************************
+ * Receive control
+ ******************************************************************/
+ void recv_post(rx_metadata_t &md, size_t &nsamps){
+ boost::mutex::scoped_lock lock(_update_mutex);
+
+ //load the metadata with the expected time
+ md.has_time_spec = true;
+ md.time_spec = time_now();
+
+ //none of the stuff below matters in continuous streaming mode
+ if (_stream_mode == stream_cmd_t::STREAM_MODE_START_CONTINUOUS) return;
+
+ //When to stop streaming:
+ //The samples have been received and the stream mode is non-continuous.
+ //Rewrite the sample count to clip to the requested number of samples.
+ if (_nsamps_remaining <= nsamps){
+ nsamps = _nsamps_remaining; //set nsamps, then stop
+ md.end_of_burst = true;
+ stream_on_off(false);
+ return;
+ }
+
+ //update the consumed samples
+ _nsamps_remaining -= nsamps;
+ }
+
+ void issue_stream_cmd(const stream_cmd_t &cmd){
+ _cmd_queue->push_with_wait(cmd);
+ }
+
+ void stream_on_off(bool enb){
+ _stream_on_off(enb);
+ _nsamps_remaining = 0;
+ }
+
+ /*******************************************************************
+ * Transmit control
+ ******************************************************************/
+ bool send_pre(const tx_metadata_t &md, double &timeout){
+ if (not md.has_time_spec) return false;
+
+ boost::mutex::scoped_lock lock(_update_mutex);
+
+ time_spec_t time_at(md.time_spec - TWIDDLE);
+
+ //handle late packets
+ if (time_at < time_now()){
+ //TODO post async message
+ return true;
+ }
+
+ timeout -= (time_at - time_now()).get_real_secs();
+ sleep_until_time(lock, time_at);
+ return false;
+ }
+
+ /*******************************************************************
+ * Thread control
+ ******************************************************************/
+ void recv_cmd_handle_cmd(const stream_cmd_t &cmd){
+ boost::mutex::scoped_lock lock(_update_mutex);
+
+ //handle the stream at time by sleeping
+ if (not cmd.stream_now){
+ time_spec_t time_at(cmd.time_spec - TWIDDLE);
+ if (time_at < time_now()){
+ //TODO inject late cmd inline error
+ }
+ else{
+ sleep_until_time(lock, time_at);
+ }
+ }
+
+ //When to stop streaming:
+ //Stop streaming when the command is a stop and streaming.
+ if (cmd.stream_mode == stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS
+ and _stream_mode != stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS
+ ) stream_on_off(false);
+
+ //When to start streaming:
+ //Start streaming when the command is not a stop and not streaming.
+ if (cmd.stream_mode != stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS
+ and _stream_mode == stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS
+ ) stream_on_off(true);
+
+ //update the state
+ _nsamps_remaining += cmd.num_samps;
+ _stream_mode = cmd.stream_mode;
+ }
+
+ void recv_cmd_dispatcher(void){
+ _update_mutex.unlock();
+ try{
+ boost::any cmd;
+ while (true){
+ _cmd_queue->pop_with_wait(cmd);
+ recv_cmd_handle_cmd(boost::any_cast<stream_cmd_t>(cmd));
+ }
+ } catch(const boost::thread_interrupted &){}
+ }
+
+private:
+ boost::mutex _update_mutex;
+ size_t _nsamps_remaining;
+ stream_cmd_t::stream_mode_t _stream_mode;
+ pt::ptime _time_offset;
+ bounded_buffer<boost::any>::sptr _cmd_queue;
+ const cb_fcn_type _stream_on_off;
+ boost::thread_group _thread_group;
+};
+
+/***********************************************************************
+ * Soft time control factor
+ **********************************************************************/
+soft_time_ctrl::sptr soft_time_ctrl::make(const cb_fcn_type &stream_on_off){
+ return sptr(new soft_time_ctrl_impl(stream_on_off));
+}
diff --git a/host/lib/usrp/usrp1/soft_time_ctrl.hpp b/host/lib/usrp/usrp1/soft_time_ctrl.hpp
new file mode 100644
index 000000000..7fdac7fc8
--- /dev/null
+++ b/host/lib/usrp/usrp1/soft_time_ctrl.hpp
@@ -0,0 +1,69 @@
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#ifndef INCLUDED_LIBUHD_USRP_USRP1_SOFT_TIME_CTRL_HPP
+#define INCLUDED_LIBUHD_USRP_USRP1_SOFT_TIME_CTRL_HPP
+
+#include <uhd/types/stream_cmd.hpp>
+#include <uhd/types/time_spec.hpp>
+#include <uhd/types/metadata.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
+
+namespace uhd{ namespace usrp{
+
+/*!
+ * The soft time control emulates some of the
+ * advanced streaming capabilities of the later USRP models.
+ * Soft time control uses the system time to emulate
+ * timed transmits, timed receive commands, device time,
+ * and inline and async error messages.
+ */
+class soft_time_ctrl : boost::noncopyable{
+public:
+ typedef boost::shared_ptr<soft_time_ctrl> sptr;
+ typedef boost::function<void(bool)> cb_fcn_type;
+
+ /*!
+ * Make a new soft time control.
+ * \param stream_on_off a function to enable/disable rx
+ * \return a new soft time control object
+ */
+ static sptr make(const cb_fcn_type &stream_on_off);
+ //TODO pass in the error queue for async msgs
+ //TODO pass in the queue for inline msgs
+
+ //! Set the current time
+ virtual void set_time(const time_spec_t &time) = 0;
+
+ //! Get the current time
+ virtual time_spec_t get_time(void) = 0;
+
+ //! Call after the internal recv function
+ virtual void recv_post(rx_metadata_t &md, size_t &nsamps) = 0;
+
+ //! Call before the internal send function
+ virtual bool send_pre(const tx_metadata_t &md, double &timeout) = 0;
+
+ //! Issue a stream command to receive
+ virtual void issue_stream_cmd(const stream_cmd_t &cmd) = 0;
+};
+
+}} //namespace
+
+#endif /* INCLUDED_LIBUHD_USRP_USRP1_SOFT_TIME_CTRL_HPP */
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.cpp b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
index 5043aed7d..09f854813 100644
--- a/host/lib/usrp/usrp1/usrp1_ctrl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
@@ -139,13 +139,6 @@ public:
_ctrl_transport = ctrl_transport;
}
-
- ~usrp_ctrl_impl(void)
- {
- /* NOP */
- }
-
-
int usrp_load_firmware(std::string filestring, bool force)
{
const char *filename = filestring.c_str();
@@ -233,6 +226,20 @@ public:
return -1;
}
+ void usrp_init(void){
+ /* not calling because this causes junk to come at init
+ * and it does not seem to be necessary to call anyway
+ usrp_rx_enable(false);
+ usrp_rx_reset(true);
+ usrp_rx_reset(false);
+ usrp_rx_enable(true);
+ */
+
+ usrp_tx_enable(false);
+ usrp_tx_reset(true);
+ usrp_tx_reset(false);
+ usrp_tx_enable(true);
+ }
int usrp_load_fpga(std::string filestring)
{
@@ -288,7 +295,7 @@ public:
usrp_set_fpga_hash(hash);
file.close();
if (load_img_msg) std::cout << " done" << std::endl;
- return 0;
+ return 0;
}
int usrp_load_eeprom(std::string filestring)
@@ -393,6 +400,12 @@ public:
}
+ int usrp_rx_reset(bool on)
+ {
+ return usrp_control_write_cmd(VRQ_FPGA_SET_RX_RESET, on, 0);
+ }
+
+
int usrp_control_write(boost::uint8_t request,
boost::uint16_t value,
boost::uint16_t index,
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.hpp b/host/lib/usrp/usrp1/usrp1_ctrl.hpp
index a02d9f96c..8ccfacab7 100644
--- a/host/lib/usrp/usrp1/usrp1_ctrl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_ctrl.hpp
@@ -33,6 +33,9 @@ public:
*/
static sptr make(uhd::transport::usb_control::sptr ctrl_transport);
+ //! Call init after the fpga is loaded
+ virtual void usrp_init(void) = 0;
+
/*!
* Load firmware in Intel HEX Format onto device
* \param filename name of firmware file
@@ -93,20 +96,6 @@ public:
virtual int usrp_set_fpga_hash(size_t hash) = 0;
/*!
- * Set rx enable or disable
- * \param on enable or disable value
- * \return 0 on success, error code otherwise
- */
- virtual int usrp_rx_enable(bool on) = 0;
-
- /*!
- * Set rx enable or disable
- * \param on enable or disable value
- * \return 0 on success, error code otherwise
- */
- virtual int usrp_tx_enable(bool on) = 0;
-
- /*!
* Submit an IN transfer
* \param request device specific request
* \param value device specific field
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 6016b0979..c395db0b9 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -139,6 +139,7 @@ static device::sptr usrp1_make(const device_addr_t &device_addr){
usb_control::sptr ctrl_transport = usb_control::make(handle);
usrp_ctrl::sptr usrp_ctrl = usrp_ctrl::make(ctrl_transport);
usrp_ctrl->usrp_load_fpga(usrp1_fpga_image);
+ usrp_ctrl->usrp_init();
usb_zero_copy::sptr data_transport = usb_zero_copy::make(
handle, // identifier
6, // IN endpoint
@@ -192,9 +193,6 @@ usrp1_impl::usrp1_impl(uhd::transport::usb_zero_copy::sptr data_transport,
//initialize the send/recv
io_init();
- //turn on the transmitter
- _ctrl_transport->usrp_tx_enable(true);
-
//init the subdev specs
this->mboard_set(MBOARD_PROP_RX_SUBDEV_SPEC, subdev_spec_t());
this->mboard_set(MBOARD_PROP_TX_SUBDEV_SPEC, subdev_spec_t());
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index ff4d40762..057725394 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -19,6 +19,7 @@
#include "usrp1_ctrl.hpp"
#include "clock_ctrl.hpp"
#include "codec_ctrl.hpp"
+#include "soft_time_ctrl.hpp"
#include <uhd/device.hpp>
#include <uhd/utils/pimpl.hpp>
#include <uhd/types/dict.hpp>
@@ -114,13 +115,17 @@ private:
const uhd::usrp::dboard_id_t &rx_dboard_id
);
+ //soft time control emulation
+ uhd::usrp::soft_time_ctrl::sptr _soft_time_ctrl;
+
//interface to ioctls and file descriptor
usrp1_iface::sptr _iface;
//handle io stuff
UHD_PIMPL_DECL(io_impl) _io_impl;
void io_init(void);
- void issue_stream_cmd(const uhd::stream_cmd_t &stream_cmd);
+ void rx_stream_on_off(bool);
+ void tx_stream_on_off(bool);
void handle_overrun(size_t);
//underrun and overrun poll intervals
diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt
index 527669852..e8811a8fb 100644
--- a/host/lib/usrp/usrp2/CMakeLists.txt
+++ b/host/lib/usrp/usrp2/CMakeLists.txt
@@ -34,12 +34,8 @@ IF(ENABLE_USRP2)
${CMAKE_CURRENT_SOURCE_DIR}/dboard_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/serdes_ctrl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/serdes_ctrl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/usrp2_iface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/usrp2_iface.hpp
${CMAKE_CURRENT_SOURCE_DIR}/usrp2_impl.cpp
diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp
index 428d5539b..27ccefb2b 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.cpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.cpp
@@ -22,10 +22,13 @@
#include <uhd/utils/assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/math/special_functions/round.hpp>
#include <iostream>
using namespace uhd;
+static const bool enb_test_clk = false;
+
/*!
* A usrp2 clock control specific to the ad9510 ic.
*/
@@ -66,13 +69,12 @@ public:
this->enable_external_ref(false);
this->enable_rx_dboard_clock(false);
this->enable_tx_dboard_clock(false);
+ this->enable_mimo_clock_out(false);
/* private clock enables, must be set here */
this->enable_dac_clock(true);
this->enable_adc_clock(true);
-
- /* always driving the mimo reference */
- this->enable_mimo_clock_out(true);
+ this->enable_test_clock(enb_test_clk);
}
~usrp2_clock_ctrl_impl(void){
@@ -83,6 +85,7 @@ public:
this->enable_dac_clock(false);
this->enable_adc_clock(false);
this->enable_mimo_clock_out(false);
+ this->enable_test_clock(false);
}
void enable_mimo_clock_out(bool enb){
@@ -246,6 +249,54 @@ public:
double get_master_clock_rate(void){
return 100e6;
}
+
+ void set_mimo_clock_delay(double delay) {
+ //delay_val is a 5-bit value (0-31) for fine control
+ //the equations below determine delay for a given ramp current, # of caps and fine delay register
+ //delay range:
+ //range_ns = 200*((caps+3)/i_ramp_ua)*1.3286
+ //offset (zero delay):
+ //offset_ns = 0.34 + (1600 - i_ramp_ua)*1e-4 + ((caps-1)/ramp)*6
+ //delay_ns = offset_ns + range_ns * delay / 31
+
+ int delay_val = boost::math::iround(delay/9.744e-9*31);
+
+ if(delay_val == 0) {
+ switch(clk_regs.exp) {
+ case 5:
+ _ad9510_regs.delay_control_out5 = 1;
+ break;
+ case 6:
+ _ad9510_regs.delay_control_out6 = 1;
+ break;
+ default:
+ break; //delay not supported on U2 rev 3
+ }
+ } else {
+ switch(clk_regs.exp) {
+ case 5:
+ _ad9510_regs.delay_control_out5 = 0;
+ _ad9510_regs.ramp_current_out5 = ad9510_regs_t::RAMP_CURRENT_OUT5_200UA;
+ _ad9510_regs.ramp_capacitor_out5 = ad9510_regs_t::RAMP_CAPACITOR_OUT5_4CAPS;
+ _ad9510_regs.delay_fine_adjust_out5 = delay_val;
+ this->write_reg(0x34);
+ this->write_reg(0x35);
+ this->write_reg(0x36);
+ break;
+ case 6:
+ _ad9510_regs.delay_control_out6 = 0;
+ _ad9510_regs.ramp_current_out6 = ad9510_regs_t::RAMP_CURRENT_OUT6_200UA;
+ _ad9510_regs.ramp_capacitor_out6 = ad9510_regs_t::RAMP_CAPACITOR_OUT6_4CAPS;
+ _ad9510_regs.delay_fine_adjust_out6 = delay_val;
+ this->write_reg(0x38);
+ this->write_reg(0x39);
+ this->write_reg(0x3A);
+ break;
+ default:
+ break;
+ }
+ }
+ }
private:
/*!
diff --git a/host/lib/usrp/usrp2/clock_ctrl.hpp b/host/lib/usrp/usrp2/clock_ctrl.hpp
index db6c52c83..9ccbc959e 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.hpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.hpp
@@ -91,8 +91,18 @@ public:
virtual void enable_test_clock(bool enb) = 0;
/*!
- * TODO other clock control api here....
+ * Enable/disable the ref clock output over the serdes cable.
+ * \param enb true to enable
+ */
+ virtual void enable_mimo_clock_out(bool enb) = 0;
+
+ /*!
+ * Set the output delay of the mimo clock
+ * Used to synchronise daisy-chained USRPs over the MIMO cable
+ * Can also be used to adjust delay for uneven reference cable lengths
+ * \param delay the clock delay in seconds
*/
+ virtual void set_mimo_clock_delay(double delay) = 0;
};
diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp
index 3a34afe11..890969b5a 100644
--- a/host/lib/usrp/usrp2/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp2/codec_ctrl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -124,7 +124,7 @@ public:
this->send_ad9777_reg(0x01); //set the register
}
- void set_rx_digital_gain(float gain) { //fine digital gain
+ void set_rx_digital_gain(double gain) { //fine digital gain
switch(_iface->get_rev()){
case usrp2_iface::USRP_N200:
case usrp2_iface::USRP_N210:
@@ -136,7 +136,7 @@ public:
}
}
- void set_rx_digital_fine_gain(float gain) { //gain correction
+ void set_rx_digital_fine_gain(double gain) { //gain correction
switch(_iface->get_rev()){
case usrp2_iface::USRP_N200:
case usrp2_iface::USRP_N210:
@@ -148,7 +148,7 @@ public:
}
}
- void set_rx_analog_gain(bool gain) { //turns on/off analog 3.5dB preamp
+ void set_rx_analog_gain(bool /*gain*/) { //turns on/off analog 3.5dB preamp
switch(_iface->get_rev()){
case usrp2_iface::USRP_N200:
case usrp2_iface::USRP_N210:
diff --git a/host/lib/usrp/usrp2/codec_ctrl.hpp b/host/lib/usrp/usrp2/codec_ctrl.hpp
index c8d977a1f..ca300e2b1 100644
--- a/host/lib/usrp/usrp2/codec_ctrl.hpp
+++ b/host/lib/usrp/usrp2/codec_ctrl.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -54,14 +54,14 @@ public:
* \param gain from 0-6dB
*/
- virtual void set_rx_digital_gain(float gain) = 0;
+ virtual void set_rx_digital_gain(double gain) = 0;
/*!
* Set the digital gain correction on the USRP2+ ADC (ADS62P44).
* \param gain from 0-0.5dB
*/
- virtual void set_rx_digital_fine_gain(float gain) = 0;
+ virtual void set_rx_digital_fine_gain(double gain) = 0;
};
diff --git a/host/lib/usrp/usrp2/codec_impl.cpp b/host/lib/usrp/usrp2/codec_impl.cpp
index 8299ce0a6..d7078d985 100644
--- a/host/lib/usrp/usrp2/codec_impl.cpp
+++ b/host/lib/usrp/usrp2/codec_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -28,10 +28,10 @@ using namespace uhd;
using namespace uhd::usrp;
using namespace boost::assign;
-//this only applies to USRP2P
+//this only applies to N2XX
static const uhd::dict<std::string, gain_range_t> codec_rx_gain_ranges = map_list_of
- ("digital", gain_range_t(0, float(6.0), float(0.5)))
- ("digital-fine", gain_range_t(0, float(0.5), float(0.05)));
+ ("digital", gain_range_t(0, 6.0, 0.5))
+ ("digital-fine", gain_range_t(0, 0.5, 0.05));
/***********************************************************************
@@ -111,7 +111,7 @@ void usrp2_mboard_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val){
switch(key.as<codec_prop_t>()) {
case CODEC_PROP_GAIN_I:
case CODEC_PROP_GAIN_Q:
- this->rx_codec_set_gain(val.as<float>(), key.name);
+ this->rx_codec_set_gain(val.as<double>(), key.name);
return;
default: UHD_THROW_PROP_SET_ERROR();
@@ -122,7 +122,7 @@ void usrp2_mboard_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val){
* Helper function to set RX codec gain
***********************************************************************/
-void usrp2_mboard_impl::rx_codec_set_gain(float gain, const std::string &name){
+void usrp2_mboard_impl::rx_codec_set_gain(double gain, const std::string &name){
assert_has(codec_rx_gain_ranges.keys(), name, "codec rx gain name");
_codec_rx_gains[name] = gain;
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index 54c1c735c..c539b0058 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -44,8 +44,8 @@ public:
return props;
}
- void write_aux_dac(unit_t, aux_dac_t, float);
- float read_aux_adc(unit_t, aux_adc_t);
+ void write_aux_dac(unit_t, aux_dac_t, double);
+ double read_aux_adc(unit_t, aux_adc_t);
void _set_pin_ctrl(unit_t, boost::uint16_t);
void _set_atr_reg(unit_t, atr_reg_t, boost::uint16_t);
@@ -294,7 +294,7 @@ void usrp2_dboard_iface::_write_aux_dac(unit_t unit){
);
}
-void usrp2_dboard_iface::write_aux_dac(unit_t unit, aux_dac_t which, float value){
+void usrp2_dboard_iface::write_aux_dac(unit_t unit, aux_dac_t which, double value){
_dac_regs[unit].data = boost::math::iround(4095*value/3.3);
_dac_regs[unit].cmd = ad5623_regs_t::CMD_WR_UP_DAC_CHAN_N;
@@ -317,7 +317,7 @@ void usrp2_dboard_iface::write_aux_dac(unit_t unit, aux_dac_t which, float value
this->_write_aux_dac(unit);
}
-float usrp2_dboard_iface::read_aux_adc(unit_t unit, aux_adc_t which){
+double usrp2_dboard_iface::read_aux_adc(unit_t unit, aux_adc_t which){
static const uhd::dict<unit_t, int> unit_to_spi_adc = map_list_of
(UNIT_RX, SPI_SS_RX_ADC)
(UNIT_TX, SPI_SS_TX_ADC)
@@ -346,5 +346,5 @@ float usrp2_dboard_iface::read_aux_adc(unit_t unit, aux_adc_t which){
)));
//convert to voltage and return
- return float(3.3*ad7922_regs.result/4095);
+ return 3.3*ad7922_regs.result/4095;
}
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index a9c39e650..a22f805e1 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -18,23 +18,20 @@
#ifndef INCLUDED_USRP2_FW_COMMON_H
#define INCLUDED_USRP2_FW_COMMON_H
+#include <stdint.h>
+
/*!
* Structs and constants for usrp2 communication.
* This header is shared by the firmware and host code.
* Therefore, this header may only contain valid C code.
*/
#ifdef __cplusplus
- #include <boost/cstdint.hpp>
- #define __stdint(type) boost::type
extern "C" {
-#else
- #include <stdint.h>
- #define __stdint(type) type
#endif
//fpga and firmware compatibility numbers
-#define USRP2_FPGA_COMPAT_NUM 3
-#define USRP2_FW_COMPAT_NUM 7
+#define USRP2_FPGA_COMPAT_NUM 4
+#define USRP2_FW_COMPAT_NUM 8
//used to differentiate control packets over data port
#define USRP2_INVALID_VRT_HEADER 0
@@ -42,7 +39,9 @@ extern "C" {
// udp ports for the usrp2 communication
// Dynamic and/or private ports: 49152-65535
#define USRP2_UDP_CTRL_PORT 49152
-#define USRP2_UDP_DATA_PORT 49153
+//#define USRP2_UDP_UPDATE_PORT 49154
+#define USRP2_UDP_DATA_PORT 49156
+#define USRP2_UDP_ERR0_PORT 49157
////////////////////////////////////////////////////////////////////////
// I2C addresses
@@ -104,40 +103,38 @@ typedef enum{
} usrp2_clk_edge_t;
typedef struct{
- __stdint(uint32_t) proto_ver;
- __stdint(uint32_t) id;
- __stdint(uint32_t) seq;
+ uint32_t proto_ver;
+ uint32_t id;
+ uint32_t seq;
union{
- __stdint(uint32_t) ip_addr;
+ uint32_t ip_addr;
struct {
- __stdint(uint32_t) dev;
- __stdint(uint32_t) data;
- __stdint(uint8_t) miso_edge;
- __stdint(uint8_t) mosi_edge;
- __stdint(uint8_t) num_bits;
- __stdint(uint8_t) readback;
+ uint32_t dev;
+ uint32_t data;
+ uint8_t miso_edge;
+ uint8_t mosi_edge;
+ uint8_t num_bits;
+ uint8_t readback;
} spi_args;
struct {
- __stdint(uint8_t) addr;
- __stdint(uint8_t) bytes;
- __stdint(uint8_t) data[20];
+ uint8_t addr;
+ uint8_t bytes;
+ uint8_t data[20];
} i2c_args;
struct {
- __stdint(uint32_t) addr;
- __stdint(uint32_t) data;
- __stdint(uint32_t) addrhi;
- __stdint(uint32_t) datahi;
- __stdint(uint8_t) num_bytes; //1, 2, 4, 8
+ uint32_t addr;
+ uint32_t data;
+ uint32_t _pad[2];
+ uint8_t num_bytes; //1, 2, 4
} poke_args;
struct {
- __stdint(uint8_t) dev;
- __stdint(uint8_t) bytes;
- __stdint(uint8_t) data[20];
+ uint8_t dev;
+ uint8_t bytes;
+ uint8_t data[20];
} uart_args;
} data;
} usrp2_ctrl_data_t;
-#undef __stdint
#ifdef __cplusplus
}
#endif
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index cbc0a0817..30eaecae2 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -20,12 +20,13 @@
#include "usrp2_regs.hpp"
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/thread_priority.hpp>
-#include <uhd/transport/convert_types.hpp>
-#include <uhd/transport/alignment_buffer.hpp>
+#include <uhd/transport/bounded_buffer.hpp>
#include <boost/format.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <iostream>
+#include <list>
using namespace uhd;
using namespace uhd::usrp;
@@ -108,16 +109,24 @@ private:
* - vrt packet handler states
**********************************************************************/
struct usrp2_impl::io_impl{
- typedef alignment_buffer<managed_recv_buffer::sptr, time_spec_t> alignment_buffer_type;
- io_impl(size_t num_recv_frames, size_t send_frame_size, size_t width):
+ io_impl(size_t send_frame_size, size_t width):
packet_handler_recv_state(width),
- recv_pirate_booty(alignment_buffer_type::make(num_recv_frames-3, width)),
async_msg_fifo(bounded_buffer<async_metadata_t>::make(100/*messages deep*/))
{
- for (size_t i = 0; i < width; i++) fc_mons.push_back(
- flow_control_monitor::sptr(new flow_control_monitor(usrp2_impl::sram_bytes/send_frame_size))
- );
+ for (size_t i = 0; i < width; i++){
+ fc_mons.push_back(flow_control_monitor::sptr(
+ new flow_control_monitor(usrp2_impl::sram_bytes/send_frame_size)
+ ));
+ //init empty packet infos
+ vrt::if_packet_info_t packet_info;
+ packet_info.packet_count = 0xf;
+ packet_info.has_tsi = true;
+ packet_info.tsi = 0;
+ packet_info.has_tsf = true;
+ packet_info.tsf = 0;
+ prev_infos.push_back(packet_info);
+ }
}
~io_impl(void){
@@ -126,11 +135,6 @@ struct usrp2_impl::io_impl{
recv_pirate_crew.join_all();
}
- bool get_recv_buffs(vrt_packet_handler::managed_recv_buffs_t &buffs, double timeout){
- boost::this_thread::disable_interruption di; //disable because the wait can throw
- return recv_pirate_booty->pop_elems_with_timed_wait(buffs, timeout);
- }
-
bool get_send_buffs(
const std::vector<zero_copy_if::sptr> &trans,
vrt_packet_handler::managed_send_buffs_t &buffs,
@@ -151,6 +155,15 @@ struct usrp2_impl::io_impl{
return true;
}
+ bool get_recv_buffs(
+ const std::vector<zero_copy_if::sptr> &xports,
+ vrt_packet_handler::managed_recv_buffs_t &buffs,
+ double timeout
+ );
+
+ //previous state for each buffer
+ std::vector<vrt::if_packet_info_t> prev_infos;
+
//flow control monitors
std::vector<flow_control_monitor::sptr> fc_mons;
@@ -162,29 +175,28 @@ struct usrp2_impl::io_impl{
void recv_pirate_loop(zero_copy_if::sptr, usrp2_mboard_impl::sptr, size_t);
boost::thread_group recv_pirate_crew;
bool recv_pirate_crew_raiding;
- alignment_buffer_type::sptr recv_pirate_booty;
bounded_buffer<async_metadata_t>::sptr async_msg_fifo;
boost::mutex spawn_mutex;
};
/***********************************************************************
* Receive Pirate Loop
- * - while raiding, loot for recv buffers
- * - put booty into the alignment buffer
+ * - while raiding, loot for message packet
+ * - update flow control condition count
+ * - put async message packets into queue
**********************************************************************/
void usrp2_impl::io_impl::recv_pirate_loop(
- zero_copy_if::sptr zc_if,
+ zero_copy_if::sptr zc_if_err0,
usrp2_mboard_impl::sptr mboard,
size_t index
){
set_thread_priority_safe();
recv_pirate_crew_raiding = true;
- size_t next_packet_seq = 0;
spawn_mutex.unlock();
while(recv_pirate_crew_raiding){
- managed_recv_buffer::sptr buff = zc_if->get_recv_buff();
+ managed_recv_buffer::sptr buff = zc_if_err0->get_recv_buff();
if (not buff.get()) continue; //ignore timeout/error buffers
try{
@@ -194,26 +206,6 @@ void usrp2_impl::io_impl::recv_pirate_loop(
const boost::uint32_t *vrt_hdr = buff->cast<const boost::uint32_t *>();
vrt::if_hdr_unpack_be(vrt_hdr, if_packet_info);
- //handle the rx data stream
- if (if_packet_info.sid == usrp2_impl::RECV_SID){
- //handle the packet count / sequence number
- if (if_packet_info.packet_count != next_packet_seq){
- //std::cerr << "S" << (if_packet_info.packet_count - next_packet_seq)%16;
- std::cerr << "O" << std::flush; //report overflow (drops in the kernel)
- }
- next_packet_seq = (if_packet_info.packet_count+1)%16;
-
- //extract the timespec and round to the nearest packet
- UHD_ASSERT_THROW(if_packet_info.has_tsi and if_packet_info.has_tsf);
- time_spec_t time(
- time_t(if_packet_info.tsi), size_t(if_packet_info.tsf), mboard->get_master_clock_freq()
- );
-
- //push the packet into the buffer with the new time
- recv_pirate_booty->push_with_pop_on_full(buff, time, index);
- continue;
- }
-
//handle a tx async report message
if (if_packet_info.sid == usrp2_impl::ASYNC_SID and if_packet_info.packet_type != vrt::if_packet_info_t::PACKET_TYPE_DATA){
@@ -253,21 +245,10 @@ void usrp2_impl::io_impl::recv_pirate_loop(
void usrp2_impl::io_init(void){
//the assumption is that all data transports should be identical
- const size_t num_recv_frames = _data_transports.front()->get_num_recv_frames();
const size_t send_frame_size = _data_transports.front()->get_send_frame_size();
//create new io impl
- _io_impl = UHD_PIMPL_MAKE(io_impl, (num_recv_frames, send_frame_size, _data_transports.size()));
-
- //TODO temporary fix for weird power up state, remove when FPGA fixed
- {
- //send an initial packet to all transports
- tx_metadata_t md; md.end_of_burst = true;
- this->send(
- std::vector<const void *>(_data_transports.size(), NULL), 0, md,
- io_type_t::COMPLEX_FLOAT32, device::SEND_MODE_ONE_PACKET, 0
- );
- }
+ _io_impl = UHD_PIMPL_MAKE(io_impl, (send_frame_size, _data_transports.size()));
//create a new pirate thread for each zc if (yarr!!)
for (size_t i = 0; i < _data_transports.size(); i++){
@@ -276,7 +257,7 @@ void usrp2_impl::io_init(void){
//spawn a new pirate to plunder the recv booty
_io_impl->recv_pirate_crew.create_thread(boost::bind(
&usrp2_impl::io_impl::recv_pirate_loop,
- _io_impl.get(), _data_transports.at(i),
+ _io_impl.get(), _err0_transports.at(i),
_mboards.at(i), i
));
//block here until the spawned thread unlocks
@@ -328,6 +309,133 @@ size_t usrp2_impl::send(
}
/***********************************************************************
+ * Alignment logic on receive
+ **********************************************************************/
+static UHD_INLINE boost::posix_time::time_duration to_time_dur(double timeout){
+ return boost::posix_time::microseconds(long(timeout*1e6));
+}
+
+static UHD_INLINE double from_time_dur(const boost::posix_time::time_duration &time_dur){
+ return 1e-6*time_dur.total_microseconds();
+}
+
+static UHD_INLINE time_spec_t extract_time_spec(
+ const vrt::if_packet_info_t &packet_info
+){
+ return time_spec_t( //assumes has_tsi and has_tsf are true
+ time_t(packet_info.tsi), size_t(packet_info.tsf),
+ 100e6 //tick rate does not have to be correct for comparison purposes
+ );
+}
+
+static UHD_INLINE void extract_packet_info(
+ managed_recv_buffer::sptr &buff,
+ vrt::if_packet_info_t &prev_info,
+ time_spec_t &time, bool &clear, bool &msg
+){
+ //extract packet info
+ vrt::if_packet_info_t next_info;
+ next_info.num_packet_words32 = buff->size()/sizeof(boost::uint32_t);
+ vrt::if_hdr_unpack_be(buff->cast<const boost::uint32_t *>(), next_info);
+
+ //handle the packet count / sequence number
+ if ((prev_info.packet_count+1)%16 != next_info.packet_count){
+ std::cerr << "O" << std::flush; //report overflow (drops in the kernel)
+ }
+
+ time = extract_time_spec(next_info);
+ clear = extract_time_spec(prev_info) > time;
+ msg = next_info.packet_type != vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ prev_info = next_info;
+}
+
+static UHD_INLINE bool handle_msg_packet(
+ vrt_packet_handler::managed_recv_buffs_t &buffs, size_t index
+){
+ for (size_t i = 0; i < buffs.size(); i++){
+ if (i == index) continue;
+ buffs[i].reset(); //set NULL
+ }
+ return true;
+}
+
+UHD_INLINE bool usrp2_impl::io_impl::get_recv_buffs(
+ const std::vector<zero_copy_if::sptr> &xports,
+ vrt_packet_handler::managed_recv_buffs_t &buffs,
+ double timeout
+){
+ if (buffs.size() == 1){
+ buffs[0] = xports[0]->get_recv_buff(timeout);
+ if (buffs[0].get() == NULL) return false;
+ bool clear, msg; time_spec_t time; //unused variables
+ //call extract_packet_info to handle printing the overflows
+ extract_packet_info(buffs[0], this->prev_infos[0], time, clear, msg);
+ return true;
+ }
+ //-------------------- begin alignment logic ---------------------//
+ boost::system_time exit_time = boost::get_system_time() + to_time_dur(timeout);
+ managed_recv_buffer::sptr buff_tmp;
+ std::list<size_t> _all_indexes, indexes_to_do;
+ for (size_t i = 0; i < buffs.size(); i++) _all_indexes.push_back(i);
+ bool clear, msg;
+ time_spec_t expected_time;
+
+ //respond to a clear by starting from scratch
+ got_clear:
+ indexes_to_do = _all_indexes;
+ clear = false;
+
+ //do an initial pop to load an initial sequence id
+ size_t index = indexes_to_do.front();
+ buff_tmp = xports[index]->get_recv_buff(from_time_dur(exit_time - boost::get_system_time()));
+ if (buff_tmp.get() == NULL) return false;
+ extract_packet_info(buff_tmp, this->prev_infos[index], expected_time, clear, msg);
+ if (clear) goto got_clear;
+ buffs[index] = buff_tmp;
+ if (msg) return handle_msg_packet(buffs, index);
+ indexes_to_do.pop_front();
+
+ //get an aligned set of elements from the buffers:
+ while(indexes_to_do.size() != 0){
+
+ //pop an element off for this index
+ index = indexes_to_do.front();
+ buff_tmp = xports[index]->get_recv_buff(from_time_dur(exit_time - boost::get_system_time()));
+ if (buff_tmp.get() == NULL) return false;
+ time_spec_t this_time;
+ extract_packet_info(buff_tmp, this->prev_infos[index], this_time, clear, msg);
+ if (clear) goto got_clear;
+ buffs[index] = buff_tmp;
+ if (msg) return handle_msg_packet(buffs, index);
+
+ //if the sequence id matches:
+ // remove this index from the list and continue
+ if (this_time == expected_time){
+ indexes_to_do.pop_front();
+ continue;
+ }
+
+ //if the sequence id is older:
+ // continue with the same index to try again
+ else if (this_time < expected_time){
+ continue;
+ }
+
+ //if the sequence id is newer:
+ // use the new expected time for comparison
+ // add all other indexes back into the list
+ else{
+ expected_time = this_time;
+ indexes_to_do = _all_indexes;
+ indexes_to_do.remove(index);
+ continue;
+ }
+ }
+ return true;
+ //-------------------- end alignment logic -----------------------//
+}
+
+/***********************************************************************
* Receive Data
**********************************************************************/
size_t usrp2_impl::get_max_recv_samps_per_packet(void) const{
@@ -357,7 +465,7 @@ size_t usrp2_impl::recv(
io_type, _rx_otw_type, //input and output types to convert
_mboards.front()->get_master_clock_freq(), //master clock tick rate
uhd::transport::vrt::if_hdr_unpack_be,
- boost::bind(&usrp2_impl::io_impl::get_recv_buffs, _io_impl.get(), _1, timeout),
+ boost::bind(&usrp2_impl::io_impl::get_recv_buffs, _io_impl.get(), _data_transports, _1, timeout),
boost::bind(&handle_overflow, _mboards, _1)
);
}
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 766ea993c..95f7013e7 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -17,6 +17,7 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
+#include <uhd/usrp/gps_ctrl.hpp>
#include <uhd/usrp/misc_utils.hpp>
#include <uhd/usrp/dsp_utils.hpp>
#include <uhd/usrp/mboard_props.hpp>
@@ -25,11 +26,13 @@
#include <uhd/utils/algorithm.hpp>
#include <boost/bind.hpp>
#include <iostream>
-#include <boost/date_time/posix_time/posix_time.hpp>
+
+static const double mimo_clock_delay_usrp2_rev4 = 4.18e-9;
+static const double mimo_clock_delay_usrp_n2xx = 3.55e-9;
+static const size_t mimo_clock_sync_delay_cycles = 137;
using namespace uhd;
using namespace uhd::usrp;
-using namespace boost::posix_time;
/***********************************************************************
* Structors
@@ -38,8 +41,9 @@ usrp2_mboard_impl::usrp2_mboard_impl(
size_t index,
transport::udp_simple::sptr ctrl_transport,
transport::zero_copy_if::sptr data_transport,
- size_t recv_samps_per_packet,
- const device_addr_t &flow_control_hints
+ transport::zero_copy_if::sptr err0_transport,
+ const device_addr_t &device_args,
+ size_t recv_samps_per_packet
):
_index(index),
_iface(usrp2_iface::make(ctrl_transport))
@@ -47,19 +51,24 @@ usrp2_mboard_impl::usrp2_mboard_impl(
//Send a small data packet so the usrp2 knows the udp source port.
//This setup must happen before further initialization occurs
//or the async update packets will cause ICMP destination unreachable.
- transport::managed_send_buffer::sptr send_buff = data_transport->get_send_buff();
+ transport::managed_send_buffer::sptr send_buff;
static const boost::uint32_t data[2] = {
uhd::htonx(boost::uint32_t(0 /* don't care seq num */)),
uhd::htonx(boost::uint32_t(USRP2_INVALID_VRT_HEADER))
};
+ send_buff = data_transport->get_send_buff();
+ std::memcpy(send_buff->cast<void*>(), &data, sizeof(data));
+ send_buff->commit(sizeof(data));
+ send_buff = err0_transport->get_send_buff();
std::memcpy(send_buff->cast<void*>(), &data, sizeof(data));
send_buff->commit(sizeof(data));
//contruct the interfaces to mboard perifs
_clock_ctrl = usrp2_clock_ctrl::make(_iface);
_codec_ctrl = usrp2_codec_ctrl::make(_iface);
- _serdes_ctrl = usrp2_serdes_ctrl::make(_iface);
- //_gps_ctrl = usrp2_gps_ctrl::make(_iface);
+ //_gps_ctrl = gps_ctrl::make(
+ // _iface->get_gps_write_fn(),
+ // _iface->get_gps_read_fn());
//if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl;
@@ -98,14 +107,14 @@ usrp2_mboard_impl::usrp2_mboard_impl(
_iface->poke32(_iface->regs.tx_ctrl_policy, U2_FLAG_TX_CTRL_POLICY_NEXT_PACKET);
//setting the cycles per update (disabled by default)
- const double ups_per_sec = flow_control_hints.cast<double>("ups_per_sec", 0.0);
+ const double ups_per_sec = device_args.cast<double>("ups_per_sec", 0.0);
if (ups_per_sec > 0.0){
const size_t cycles_per_up = size_t(_clock_ctrl->get_master_clock_rate()/ups_per_sec);
_iface->poke32(_iface->regs.tx_ctrl_cycles_per_up, U2_FLAG_TX_CTRL_UP_ENB | cycles_per_up);
}
//setting the packets per update (enabled by default)
- const double ups_per_fifo = flow_control_hints.cast<double>("ups_per_fifo", 8.0);
+ const double ups_per_fifo = device_args.cast<double>("ups_per_fifo", 8.0);
if (ups_per_fifo > 0.0){
const size_t packets_per_up = size_t(usrp2_impl::sram_bytes/ups_per_fifo/data_transport->get_send_frame_size());
_iface->poke32(_iface->regs.tx_ctrl_packets_per_up, U2_FLAG_TX_CTRL_UP_ENB | packets_per_up);
@@ -118,7 +127,26 @@ usrp2_mboard_impl::usrp2_mboard_impl(
init_duc_config();
//initialize the clock configuration
- init_clock_config();
+ if (device_args.has_key("mimo_mode")){
+ if (device_args["mimo_mode"] == "master"){
+ _mimo_clocking_mode_is_master = true;
+ }
+ else if (device_args["mimo_mode"] == "slave"){
+ _mimo_clocking_mode_is_master = false;
+ }
+ else throw std::runtime_error(
+ "mimo_mode must be set to master or slave"
+ );
+ }
+ else {
+ _mimo_clocking_mode_is_master = (_iface->peek32(_iface->regs.status) & (1 << 8)) != 0;
+ }
+ std::cout << boost::format("mboard%d MIMO %s") % _index %
+ (_mimo_clocking_mode_is_master?"master":"slave") << std::endl;
+
+ //init the clock config
+ _clock_config = clock_config_t::internal();
+ update_clock_config();
//init the codec before the dboard
codec_init();
@@ -139,23 +167,12 @@ usrp2_mboard_impl::~usrp2_mboard_impl(void){
/***********************************************************************
* Helper Methods
**********************************************************************/
-void usrp2_mboard_impl::init_clock_config(void){
- //setup the clock configuration settings
- _clock_config.ref_source = clock_config_t::REF_INT;
- _clock_config.pps_source = clock_config_t::PPS_SMA;
- _clock_config.pps_polarity = clock_config_t::PPS_NEG;
-
- //update the clock config (sends a control packet)
- update_clock_config();
-}
-
void usrp2_mboard_impl::update_clock_config(void){
boost::uint32_t pps_flags = 0;
//translate pps source enums
switch(_clock_config.pps_source){
case clock_config_t::PPS_SMA: pps_flags |= U2_FLAG_TIME64_PPS_SMA; break;
- case clock_config_t::PPS_MIMO: pps_flags |= U2_FLAG_TIME64_PPS_MIMO; break;
default: throw std::runtime_error("unhandled clock configuration pps source");
}
@@ -176,7 +193,6 @@ void usrp2_mboard_impl::update_clock_config(void){
switch(_clock_config.ref_source){
case clock_config_t::REF_INT : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x12); break;
case clock_config_t::REF_SMA : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x1C); break;
- case clock_config_t::REF_MIMO: _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); break;
default: throw std::runtime_error("unhandled clock configuration reference source");
}
_clock_ctrl->enable_external_ref(true); //USRP2P has an internal 10MHz TCXO
@@ -187,7 +203,6 @@ void usrp2_mboard_impl::update_clock_config(void){
switch(_clock_config.ref_source){
case clock_config_t::REF_INT : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x10); break;
case clock_config_t::REF_SMA : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x1C); break;
- case clock_config_t::REF_MIMO: _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); break;
default: throw std::runtime_error("unhandled clock configuration reference source");
}
_clock_ctrl->enable_external_ref(_clock_config.ref_source != clock_config_t::REF_INT);
@@ -195,6 +210,36 @@ void usrp2_mboard_impl::update_clock_config(void){
case usrp2_iface::USRP_NXXX: break;
}
+
+ //Handle the serdes clocking based on master/slave mode:
+ // - Masters always drive the clock over serdes.
+ // - Slaves always lock to this serdes clock.
+ // - Slaves lock their time over the serdes.
+ if (_mimo_clocking_mode_is_master){
+ _clock_ctrl->enable_mimo_clock_out(true);
+ switch(_iface->get_rev()){
+ case usrp2_iface::USRP_N200:
+ case usrp2_iface::USRP_N210:
+ _clock_ctrl->set_mimo_clock_delay(mimo_clock_delay_usrp_n2xx);
+ break;
+
+ case usrp2_iface::USRP2_REV4:
+ _clock_ctrl->set_mimo_clock_delay(mimo_clock_delay_usrp2_rev4);
+ break;
+
+ default: break; //not handled
+ }
+ _iface->poke32(_iface->regs.time64_mimo_sync, 0);
+ }
+ else{
+ _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15);
+ _clock_ctrl->enable_external_ref(true);
+ _clock_ctrl->enable_mimo_clock_out(false);
+ _iface->poke32(_iface->regs.time64_mimo_sync,
+ (1 << 8) | (mimo_clock_sync_delay_cycles & 0xff)
+ );
+ }
+
}
void usrp2_mboard_impl::set_time_spec(const time_spec_t &time_spec, bool now){
@@ -279,15 +324,21 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
val = _clock_config;
return;
- case MBOARD_PROP_TIME_NOW:{
- usrp2_iface::pair64 time64(
- _iface->peek64(_iface->regs.time64_secs_rb, _iface->regs.time64_ticks_rb)
- );
- val = time_spec_t(
- time64.first, time64.second, get_master_clock_freq()
- );
- }
+ case MBOARD_PROP_TIME_NOW: while(true){
+ uint32_t secs = _iface->peek32(_iface->regs.time64_secs_rb_imm);
+ uint32_t ticks = _iface->peek32(_iface->regs.time64_ticks_rb_imm);
+ if (secs != _iface->peek32(_iface->regs.time64_secs_rb_imm)) continue;
+ val = time_spec_t(secs, ticks, get_master_clock_freq());
return;
+ }
+
+ case MBOARD_PROP_TIME_PPS: while(true){
+ uint32_t secs = _iface->peek32(_iface->regs.time64_secs_rb_pps);
+ uint32_t ticks = _iface->peek32(_iface->regs.time64_ticks_rb_pps);
+ if (secs != _iface->peek32(_iface->regs.time64_secs_rb_pps)) continue;
+ val = time_spec_t(secs, ticks, get_master_clock_freq());
+ return;
+ }
case MBOARD_PROP_RX_SUBDEV_SPEC:
val = _rx_subdev_spec;
@@ -321,7 +372,7 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
set_time_spec(val.as<time_spec_t>(), true);
return;
- case MBOARD_PROP_TIME_NEXT_PPS:
+ case MBOARD_PROP_TIME_PPS:
set_time_spec(val.as<time_spec_t>(), false);
return;
diff --git a/host/lib/usrp/usrp2/serdes_ctrl.cpp b/host/lib/usrp/usrp2/serdes_ctrl.cpp
deleted file mode 100644
index 1cda22f45..000000000
--- a/host/lib/usrp/usrp2/serdes_ctrl.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#include "serdes_ctrl.hpp"
-#include "usrp2_regs.hpp"
-
-using namespace uhd;
-
-/*!
- * A usrp2 serdes control implementation
- */
-class usrp2_serdes_ctrl_impl : public usrp2_serdes_ctrl{
-public:
- usrp2_serdes_ctrl_impl(usrp2_iface::sptr iface){
- _iface = iface;
- _iface->poke32(_iface->regs.misc_ctrl_serdes, U2_FLAG_MISC_CTRL_SERDES_ENABLE | U2_FLAG_MISC_CTRL_SERDES_RXEN);
- }
-
- ~usrp2_serdes_ctrl_impl(void){
- _iface->poke32(_iface->regs.misc_ctrl_serdes, 0); //power-down
- }
-
-private:
- usrp2_iface::sptr _iface;
-};
-
-/***********************************************************************
- * Public make function for the usrp2 serdes control
- **********************************************************************/
-usrp2_serdes_ctrl::sptr usrp2_serdes_ctrl::make(usrp2_iface::sptr iface){
- return sptr(new usrp2_serdes_ctrl_impl(iface));
-}
diff --git a/host/lib/usrp/usrp2/serdes_ctrl.hpp b/host/lib/usrp/usrp2/serdes_ctrl.hpp
deleted file mode 100644
index 3c909c531..000000000
--- a/host/lib/usrp/usrp2/serdes_ctrl.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_SERDES_CTRL_HPP
-#define INCLUDED_SERDES_CTRL_HPP
-
-#include "usrp2_iface.hpp"
-#include <boost/shared_ptr.hpp>
-#include <boost/utility.hpp>
-
-class usrp2_serdes_ctrl : boost::noncopyable{
-public:
- typedef boost::shared_ptr<usrp2_serdes_ctrl> sptr;
-
- /*!
- * Make a serdes control object for the usrp2 serdes port.
- * \param _iface a pointer to the usrp2 interface object
- * \return a new serdes control object
- */
- static sptr make(usrp2_iface::sptr iface);
-
- //TODO fill me in with virtual methods
-
-};
-
-#endif /* INCLUDED_SERDES_CTRL_HPP */
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index ffbe8eedb..149c5011f 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -93,20 +93,6 @@ public:
return this->peek<boost::uint16_t>(addr);
}
- pair64 peek64(boost::uint32_t addrlo, boost::uint32_t addrhi){
- //setup the out data
- usrp2_ctrl_data_t out_data;
- out_data.id = htonl(USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO);
- out_data.data.poke_args.addr = htonl(addrlo);
- out_data.data.poke_args.addrhi = htonl(addrhi);
- out_data.data.poke_args.num_bytes = sizeof(boost::uint64_t);
-
- //send and recv
- usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data);
- UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE);
- return pair64(ntohl(in_data.data.poke_args.data), ntohl(in_data.data.poke_args.datahi));
- }
-
/***********************************************************************
* SPI
**********************************************************************/
@@ -232,6 +218,14 @@ public:
}
return result;
}
+
+ gps_send_fn_t get_gps_write_fn(void) {
+ return boost::bind(&usrp2_iface_impl::write_uart, this, 2, _1); //2 is the GPS UART port on USRP2
+ }
+
+ gps_recv_fn_t get_gps_read_fn(void) {
+ return boost::bind(&usrp2_iface_impl::read_uart, this, 2); //2 is the GPS UART port on USRP2
+ }
/***********************************************************************
* Send/Recv over control
diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp
index af3ed6c9f..49cb0e6dc 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.hpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.hpp
@@ -24,11 +24,17 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/cstdint.hpp>
+#include <boost/function.hpp>
#include <utility>
#include <string>
#include "fw_common.h"
#include "usrp2_regs.hpp"
+
+//TODO: kill this crap when you have the top level GPS include file
+typedef boost::function<void(std::string)> gps_send_fn_t;
+typedef boost::function<std::string(void)> gps_recv_fn_t;
+
/*!
* The usrp2 interface class:
* Provides a set of functions to implementation layer.
@@ -37,7 +43,6 @@
class usrp2_iface : public uhd::i2c_iface, boost::noncopyable{
public:
typedef boost::shared_ptr<usrp2_iface> sptr;
- typedef std::pair<boost::uint32_t, boost::uint32_t> pair64;
/*!
* Make a new usrp2 interface with the control transport.
@@ -54,14 +59,6 @@ public:
virtual usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &data) = 0;
/*!
- * Read a dual register (64 bits)
- * \param addrlo the address for the low-32 bits
- * \param addrhi the address for the high-32 bits
- * \return a pair of 32 bit integers lo, hi
- */
- virtual pair64 peek64(boost::uint32_t addrlo, boost::uint32_t addrhi) = 0;
-
- /*!
* Write a register (32 bits)
* \param addr the address
* \param data the 32bit data
@@ -109,6 +106,9 @@ public:
virtual void write_uart(boost::uint8_t dev, const std::string &buf) = 0;
virtual std::string read_uart(boost::uint8_t dev) = 0;
+
+ virtual gps_recv_fn_t get_gps_read_fn(void) = 0;
+ virtual gps_send_fn_t get_gps_write_fn(void) = 0;
//! The list of possible revision types
enum rev_type {
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index c3bbe4d65..059ddf65f 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -22,7 +22,7 @@
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
#include <uhd/utils/warning.hpp>
-#include <uhd/utils/algorithm.hpp>
+#include <boost/algorithm/string.hpp> //for split
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
@@ -31,6 +31,7 @@
#include <boost/bind.hpp>
#include <boost/asio.hpp> //htonl and ntohl
#include <iostream>
+#include <vector>
using namespace uhd;
using namespace uhd::usrp;
@@ -47,8 +48,8 @@ template <class T> std::string num2str(T num){
//! separate indexed device addresses into a vector of device addresses
device_addrs_t sep_indexed_dev_addrs(const device_addr_t &dev_addr){
//------------ support old deprecated way and print warning --------
- if (dev_addr.has_key("addr")){
- std::vector<std::string> addrs = std::split_string(dev_addr["addr"]);
+ if (dev_addr.has_key("addr") and not dev_addr["addr"].empty()){
+ std::vector<std::string> addrs; boost::split(addrs, dev_addr["addr"], boost::is_any_of(" "));
if (addrs.size() > 1){
device_addr_t fixed_dev_addr = dev_addr;
fixed_dev_addr.pop("addr");
@@ -197,24 +198,36 @@ static device_addrs_t usrp2_find(const device_addr_t &hint_){
* Make
**********************************************************************/
static device::sptr usrp2_make(const device_addr_t &device_addr){
-sep_indexed_dev_addrs(device_addr);
+
+ //setup the dsp transport hints (default to a large recv buff)
+ device_addr_t dsp_xport_hints = device_addr;
+ if (not dsp_xport_hints.has_key("recv_buff_size")){
+ //set to half-a-second of buffering at max rate
+ dsp_xport_hints["recv_buff_size"] = "50e6";
+ }
+
//create a ctrl and data transport for each address
std::vector<udp_simple::sptr> ctrl_transports;
std::vector<zero_copy_if::sptr> data_transports;
+ std::vector<zero_copy_if::sptr> err0_transports;
+ const device_addrs_t device_addrs = sep_indexed_dev_addrs(device_addr);
- BOOST_FOREACH(const device_addr_t &dev_addr_i, sep_indexed_dev_addrs(device_addr)){
+ BOOST_FOREACH(const device_addr_t &dev_addr_i, device_addrs){
ctrl_transports.push_back(udp_simple::make_connected(
dev_addr_i["addr"], num2str(USRP2_UDP_CTRL_PORT)
));
data_transports.push_back(udp_zero_copy::make(
- dev_addr_i["addr"], num2str(USRP2_UDP_DATA_PORT), device_addr
+ dev_addr_i["addr"], num2str(USRP2_UDP_DATA_PORT), dsp_xport_hints
+ ));
+ err0_transports.push_back(udp_zero_copy::make(
+ dev_addr_i["addr"], num2str(USRP2_UDP_ERR0_PORT), device_addr_t()
));
}
//create the usrp2 implementation guts
- return device::sptr(
- new usrp2_impl(ctrl_transports, data_transports, device_addr)
- );
+ return device::sptr(new usrp2_impl(
+ ctrl_transports, data_transports, err0_transports, device_addrs
+ ));
}
UHD_STATIC_BLOCK(register_usrp2_device){
@@ -227,9 +240,11 @@ UHD_STATIC_BLOCK(register_usrp2_device){
usrp2_impl::usrp2_impl(
std::vector<udp_simple::sptr> ctrl_transports,
std::vector<zero_copy_if::sptr> data_transports,
- const device_addr_t &flow_control_hints
+ std::vector<zero_copy_if::sptr> err0_transports,
+ const device_addrs_t &device_args
):
- _data_transports(data_transports)
+ _data_transports(data_transports),
+ _err0_transports(err0_transports)
{
//setup rx otw type
_rx_otw_type.width = 16;
@@ -244,11 +259,11 @@ usrp2_impl::usrp2_impl(
//!!!!! set the otw type here before continuing, its used below
//create a new mboard handler for each control transport
- for(size_t i = 0; i < ctrl_transports.size(); i++){
+ for(size_t i = 0; i < device_args.size(); i++){
_mboards.push_back(usrp2_mboard_impl::sptr(new usrp2_mboard_impl(
i, ctrl_transports[i], data_transports[i],
- this->get_max_recv_samps_per_packet(),
- flow_control_hints
+ err0_transports[i], device_args[i],
+ this->get_max_recv_samps_per_packet()
)));
//use an empty name when there is only one mboard
std::string name = (ctrl_transports.size() > 1)? boost::lexical_cast<std::string>(i) : "";
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index aa8eb0155..ad95b2a4a 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -21,8 +21,7 @@
#include "usrp2_iface.hpp"
#include "clock_ctrl.hpp"
#include "codec_ctrl.hpp"
-#include "gps_ctrl.hpp"
-#include "serdes_ctrl.hpp"
+#include <uhd/usrp/gps_ctrl.hpp>
#include <uhd/device.hpp>
#include <uhd/utils/pimpl.hpp>
#include <uhd/types/dict.hpp>
@@ -86,8 +85,9 @@ public:
size_t index,
uhd::transport::udp_simple::sptr,
uhd::transport::zero_copy_if::sptr,
- size_t recv_samps_per_packet,
- const uhd::device_addr_t &flow_control_hints
+ uhd::transport::zero_copy_if::sptr,
+ const uhd::device_addr_t &device_args,
+ size_t recv_samps_per_packet
);
~usrp2_mboard_impl(void);
@@ -100,13 +100,13 @@ public:
private:
size_t _index;
bool _continuous_streaming;
+ bool _mimo_clocking_mode_is_master;
//interfaces
usrp2_iface::sptr _iface;
usrp2_clock_ctrl::sptr _clock_ctrl;
usrp2_codec_ctrl::sptr _codec_ctrl;
- usrp2_serdes_ctrl::sptr _serdes_ctrl;
- usrp2_gps_ctrl::sptr _gps_ctrl;
+ gps_ctrl::sptr _gps_ctrl;
//properties for this mboard
void get(const wax::obj &, wax::obj &);
@@ -120,7 +120,6 @@ private:
//methods and shadows for clock configuration
uhd::clock_config_t _clock_config;
- void init_clock_config(void);
void update_clock_config(void);
void set_time_spec(const uhd::time_spec_t &time_spec, bool now);
@@ -133,8 +132,8 @@ private:
wax_obj_proxy::sptr _rx_codec_proxy;
wax_obj_proxy::sptr _tx_codec_proxy;
- void rx_codec_set_gain(float, const std::string &);
- uhd::dict<std::string, float> _codec_rx_gains;
+ void rx_codec_set_gain(double, const std::string &);
+ uhd::dict<std::string, double> _codec_rx_gains;
//properties interface for rx dboard
void rx_dboard_get(const wax::obj &, wax::obj &);
@@ -187,12 +186,14 @@ public:
* Create a new usrp2 impl base.
* \param ctrl_transports the udp transports for control
* \param data_transports the udp transports for data
- * \param flow_control_hints optional flow control params
+ * \param err0_transports the udp transports for error
+ * \param device_args optional misc device parameters
*/
usrp2_impl(
std::vector<uhd::transport::udp_simple::sptr> ctrl_transports,
std::vector<uhd::transport::zero_copy_if::sptr> data_transports,
- const uhd::device_addr_t &flow_control_hints
+ std::vector<uhd::transport::zero_copy_if::sptr> err0_transports,
+ const uhd::device_addrs_t &device_args
);
~usrp2_impl(void);
@@ -223,6 +224,7 @@ private:
//io impl methods and members
std::vector<uhd::transport::zero_copy_if::sptr> _data_transports;
+ std::vector<uhd::transport::zero_copy_if::sptr> _err0_transports;
uhd::otw_type_t _rx_otw_type, _tx_otw_type;
UHD_PIMPL_DECL(io_impl) _io_impl;
void io_init(void);
diff --git a/host/lib/usrp/usrp2/usrp2_regs.cpp b/host/lib/usrp/usrp2/usrp2_regs.cpp
index dd0433816..84907c32e 100644
--- a/host/lib/usrp/usrp2/usrp2_regs.cpp
+++ b/host/lib/usrp/usrp2/usrp2_regs.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -57,9 +57,13 @@ usrp2_regs_t usrp2_get_regs(bool use_n2xx_map) {
x.time64_flags = sr_addr(misc_output_base, x.sr_time64 + 2);
x.time64_imm = sr_addr(misc_output_base, x.sr_time64 + 3);
x.time64_tps = sr_addr(misc_output_base, x.sr_time64 + 4);
- x.time64_secs_rb = bp_base + 4*10;
- x.time64_ticks_rb = bp_base + 4*11;
+ x.time64_mimo_sync = sr_addr(misc_output_base, x.sr_time64 + 5);
+ x.status = bp_base + 4*8;
+ x.time64_secs_rb_imm = bp_base + 4*10;
+ x.time64_ticks_rb_imm = bp_base + 4*11;
x.compat_num_rb = bp_base + 4*12;
+ x.time64_secs_rb_pps = bp_base + 4*14;
+ x.time64_ticks_rb_pps = bp_base + 4*15;
x.dsp_tx_freq = sr_addr(misc_output_base, x.sr_tx_dsp + 0);
x.dsp_tx_scale_iq = sr_addr(misc_output_base, x.sr_tx_dsp + 1);
x.dsp_tx_interp_rate = sr_addr(misc_output_base, x.sr_tx_dsp + 2);
diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp
index 9936d634a..977b342cb 100644
--- a/host/lib/usrp/usrp2/usrp2_regs.hpp
+++ b/host/lib/usrp/usrp2/usrp2_regs.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -25,10 +25,10 @@
#define USRP2_ATR_BASE 0xE400
#define USRP2_BP_STATUS_BASE 0xCC00
-#define USRP2P_MISC_OUTPUT_BASE 0x2000
-#define USRP2P_GPIO_BASE 0x3200
-#define USRP2P_ATR_BASE 0x3800
-#define USRP2P_BP_STATUS_BASE 0x3300
+#define USRP2P_MISC_OUTPUT_BASE 0x5000
+#define USRP2P_GPIO_BASE 0x6200
+#define USRP2P_ATR_BASE 0x6800
+#define USRP2P_BP_STATUS_BASE 0x6300
typedef struct {
int sr_misc;
@@ -57,8 +57,12 @@ typedef struct {
int time64_flags; // flags -- see chart below
int time64_imm; // set immediate (0=latch on next pps, 1=latch immediate, default=0)
int time64_tps; // ticks per second rollover count
- int time64_secs_rb;
- int time64_ticks_rb;
+ int time64_mimo_sync;
+ int status;
+ int time64_secs_rb_imm;
+ int time64_ticks_rb_imm;
+ int time64_secs_rb_pps;
+ int time64_ticks_rb_pps;
int compat_num_rb;
int dsp_tx_freq;
int dsp_tx_scale_iq;
diff --git a/host/lib/usrp/usrp_e100/codec_ctrl.cpp b/host/lib/usrp/usrp_e100/codec_ctrl.cpp
index 18d9daca0..b33c8ae65 100644
--- a/host/lib/usrp/usrp_e100/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp_e100/codec_ctrl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -31,7 +31,7 @@ using namespace uhd;
static const bool codec_debug = false;
-const gain_range_t usrp_e100_codec_ctrl::tx_pga_gain_range(-20, 0, float(0.1));
+const gain_range_t usrp_e100_codec_ctrl::tx_pga_gain_range(-20, 0, double(0.1));
const gain_range_t usrp_e100_codec_ctrl::rx_pga_gain_range(0, 20, 1);
/***********************************************************************
@@ -44,14 +44,14 @@ public:
~usrp_e100_codec_ctrl_impl(void);
//aux adc and dac control
- float read_aux_adc(aux_adc_t which);
- void write_aux_dac(aux_dac_t which, float volts);
+ double read_aux_adc(aux_adc_t which);
+ void write_aux_dac(aux_dac_t which, double volts);
//pga gain control
- void set_tx_pga_gain(float);
- float get_tx_pga_gain(void);
- void set_rx_pga_gain(float, char);
- float get_rx_pga_gain(char);
+ void set_tx_pga_gain(double);
+ double get_tx_pga_gain(void);
+ void set_rx_pga_gain(double, char);
+ double get_rx_pga_gain(char);
private:
usrp_e100_iface::sptr _iface;
@@ -135,19 +135,19 @@ usrp_e100_codec_ctrl_impl::~usrp_e100_codec_ctrl_impl(void){
**********************************************************************/
static const int mtpgw = 255; //maximum tx pga gain word
-void usrp_e100_codec_ctrl_impl::set_tx_pga_gain(float gain){
+void usrp_e100_codec_ctrl_impl::set_tx_pga_gain(double gain){
int gain_word = int(mtpgw*(gain - tx_pga_gain_range.start())/(tx_pga_gain_range.stop() - tx_pga_gain_range.start()));
_ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, mtpgw);
this->send_reg(16);
}
-float usrp_e100_codec_ctrl_impl::get_tx_pga_gain(void){
+double usrp_e100_codec_ctrl_impl::get_tx_pga_gain(void){
return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.stop() - tx_pga_gain_range.start())/mtpgw) + tx_pga_gain_range.start();
}
static const int mrpgw = 0x14; //maximum rx pga gain word
-void usrp_e100_codec_ctrl_impl::set_rx_pga_gain(float gain, char which){
+void usrp_e100_codec_ctrl_impl::set_rx_pga_gain(double gain, char which){
int gain_word = int(mrpgw*(gain - rx_pga_gain_range.start())/(rx_pga_gain_range.stop() - rx_pga_gain_range.start()));
gain_word = std::clip(gain_word, 0, mrpgw);
switch(which){
@@ -163,7 +163,7 @@ void usrp_e100_codec_ctrl_impl::set_rx_pga_gain(float gain, char which){
}
}
-float usrp_e100_codec_ctrl_impl::get_rx_pga_gain(char which){
+double usrp_e100_codec_ctrl_impl::get_rx_pga_gain(char which){
int gain_word;
switch(which){
case 'A': gain_word = _ad9862_regs.rx_pga_a; break;
@@ -176,11 +176,11 @@ float usrp_e100_codec_ctrl_impl::get_rx_pga_gain(char which){
/***********************************************************************
* Codec Control AUX ADC Methods
**********************************************************************/
-static float aux_adc_to_volts(boost::uint8_t high, boost::uint8_t low){
- return float((boost::uint16_t(high) << 2) | low)*3.3/0x3ff;
+static double aux_adc_to_volts(boost::uint8_t high, boost::uint8_t low){
+ return double((boost::uint16_t(high) << 2) | low)*3.3/0x3ff;
}
-float usrp_e100_codec_ctrl_impl::read_aux_adc(aux_adc_t which){
+double usrp_e100_codec_ctrl_impl::read_aux_adc(aux_adc_t which){
//check to see if the switch needs to be set
bool write_switch = false;
switch(which){
@@ -233,7 +233,7 @@ float usrp_e100_codec_ctrl_impl::read_aux_adc(aux_adc_t which){
/***********************************************************************
* Codec Control AUX DAC Methods
**********************************************************************/
-void usrp_e100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, float volts){
+void usrp_e100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){
//special case for aux dac d (aka sigma delta word)
if (which == AUX_DAC_D){
boost::uint16_t dac_word = std::clip(boost::math::iround(volts*0xfff/3.3), 0, 0xfff);
diff --git a/host/lib/usrp/usrp_e100/codec_ctrl.hpp b/host/lib/usrp/usrp_e100/codec_ctrl.hpp
index 74ce9bd9a..05d7aab38 100644
--- a/host/lib/usrp/usrp_e100/codec_ctrl.hpp
+++ b/host/lib/usrp/usrp_e100/codec_ctrl.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -57,7 +57,7 @@ public:
* \param which which of the 4 adcs
* \return a value in volts
*/
- virtual float read_aux_adc(aux_adc_t which) = 0;
+ virtual double read_aux_adc(aux_adc_t which) = 0;
//! aux dac identifier constants
enum aux_dac_t{
@@ -72,19 +72,19 @@ public:
* \param which which of the 4 dacs
* \param volts the level in in volts
*/
- virtual void write_aux_dac(aux_dac_t which, float volts) = 0;
+ virtual void write_aux_dac(aux_dac_t which, double volts) = 0;
//! Set the TX PGA gain
- virtual void set_tx_pga_gain(float gain) = 0;
+ virtual void set_tx_pga_gain(double gain) = 0;
//! Get the TX PGA gain
- virtual float get_tx_pga_gain(void) = 0;
+ virtual double get_tx_pga_gain(void) = 0;
//! Set the RX PGA gain ('A' or 'B')
- virtual void set_rx_pga_gain(float gain, char which) = 0;
+ virtual void set_rx_pga_gain(double gain, char which) = 0;
//! Get the RX PGA gain ('A' or 'B')
- virtual float get_rx_pga_gain(char which) = 0;
+ virtual double get_rx_pga_gain(char which) = 0;
};
#endif /* INCLUDED_USRP_E100_CODEC_CTRL_HPP */
diff --git a/host/lib/usrp/usrp_e100/codec_impl.cpp b/host/lib/usrp/usrp_e100/codec_impl.cpp
index 6fd44bad3..0d91fb42c 100644
--- a/host/lib/usrp/usrp_e100/codec_impl.cpp
+++ b/host/lib/usrp/usrp_e100/codec_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -86,12 +86,12 @@ void usrp_e100_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val){
switch(key.as<codec_prop_t>()){
case CODEC_PROP_GAIN_I:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- _codec_ctrl->set_rx_pga_gain(val.as<float>(), 'A');
+ _codec_ctrl->set_rx_pga_gain(val.as<double>(), 'A');
return;
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- _codec_ctrl->set_rx_pga_gain(val.as<float>(), 'B');
+ _codec_ctrl->set_rx_pga_gain(val.as<double>(), 'B');
return;
default: UHD_THROW_PROP_SET_ERROR();
@@ -141,7 +141,7 @@ void usrp_e100_impl::tx_codec_set(const wax::obj &key_, const wax::obj &val){
case CODEC_PROP_GAIN_I: //only one gain for I and Q
case CODEC_PROP_GAIN_Q:
UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
- _codec_ctrl->set_tx_pga_gain(val.as<float>());
+ _codec_ctrl->set_tx_pga_gain(val.as<double>());
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp_e100/dboard_iface.cpp b/host/lib/usrp/usrp_e100/dboard_iface.cpp
index a5032f86f..e4c3856c9 100644
--- a/host/lib/usrp/usrp_e100/dboard_iface.cpp
+++ b/host/lib/usrp/usrp_e100/dboard_iface.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -60,8 +60,8 @@ public:
return props;
}
- void write_aux_dac(unit_t, aux_dac_t, float);
- float read_aux_adc(unit_t, aux_adc_t);
+ void write_aux_dac(unit_t, aux_dac_t, double);
+ double read_aux_adc(unit_t, aux_adc_t);
void _set_pin_ctrl(unit_t, boost::uint16_t);
void _set_atr_reg(unit_t, atr_reg_t, boost::uint16_t);
@@ -270,7 +270,7 @@ byte_vector_t usrp_e100_dboard_iface::read_i2c(boost::uint8_t addr, size_t num_b
/***********************************************************************
* Aux DAX/ADC
**********************************************************************/
-void usrp_e100_dboard_iface::write_aux_dac(dboard_iface::unit_t, aux_dac_t which, float value){
+void usrp_e100_dboard_iface::write_aux_dac(dboard_iface::unit_t, aux_dac_t which, double value){
//same aux dacs for each unit
static const uhd::dict<aux_dac_t, usrp_e100_codec_ctrl::aux_dac_t> which_to_aux_dac = map_list_of
(AUX_DAC_A, usrp_e100_codec_ctrl::AUX_DAC_A)
@@ -281,7 +281,7 @@ void usrp_e100_dboard_iface::write_aux_dac(dboard_iface::unit_t, aux_dac_t which
_codec->write_aux_dac(which_to_aux_dac[which], value);
}
-float usrp_e100_dboard_iface::read_aux_adc(dboard_iface::unit_t unit, aux_adc_t which){
+double usrp_e100_dboard_iface::read_aux_adc(dboard_iface::unit_t unit, aux_adc_t which){
static const uhd::dict<
unit_t, uhd::dict<aux_adc_t, usrp_e100_codec_ctrl::aux_adc_t>
> unit_to_which_to_aux_adc = map_list_of
diff --git a/host/lib/usrp/usrp_e100/dsp_impl.cpp b/host/lib/usrp/usrp_e100/dsp_impl.cpp
index 43a3bd3be..7d358a607 100644
--- a/host/lib/usrp/usrp_e100/dsp_impl.cpp
+++ b/host/lib/usrp/usrp_e100/dsp_impl.cpp
@@ -38,7 +38,7 @@ void usrp_e100_impl::rx_ddc_init(void){
//initial config and update
rx_ddc_set(DSP_PROP_FREQ_SHIFT, double(0));
- rx_ddc_set(DSP_PROP_HOST_RATE, double(64e6/10));
+ rx_ddc_set(DSP_PROP_HOST_RATE, double(16e6));
}
/***********************************************************************
@@ -121,7 +121,7 @@ void usrp_e100_impl::tx_duc_init(void){
//initial config and update
tx_duc_set(DSP_PROP_FREQ_SHIFT, double(0));
- tx_duc_set(DSP_PROP_HOST_RATE, double(64e6/10));
+ tx_duc_set(DSP_PROP_HOST_RATE, double(16e6));
}
/***********************************************************************
diff --git a/host/lib/usrp/usrp_e100/mboard_impl.cpp b/host/lib/usrp/usrp_e100/mboard_impl.cpp
index fe26cd63d..f52d2e6fb 100644
--- a/host/lib/usrp/usrp_e100/mboard_impl.cpp
+++ b/host/lib/usrp/usrp_e100/mboard_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -36,11 +36,13 @@ void usrp_e100_impl::mboard_init(void){
boost::bind(&usrp_e100_impl::mboard_set, this, _1, _2)
);
- //init the clock config
- _clock_config.ref_source = clock_config_t::REF_AUTO;
- _clock_config.pps_source = clock_config_t::PPS_SMA;
- _clock_config.pps_polarity = clock_config_t::PPS_NEG;
+ //set the ticks per seconds into the vita time control
+ _iface->poke32(UE_REG_TIME64_TPS,
+ boost::uint32_t(_clock_ctrl->get_fpga_clock_rate())
+ );
+ //init the clock config
+ _clock_config = clock_config_t::internal();
update_clock_config();
}
@@ -134,6 +136,22 @@ void usrp_e100_impl::mboard_get(const wax::obj &key_, wax::obj &val){
val = _iface->mb_eeprom;
return;
+ case MBOARD_PROP_TIME_NOW: while(true){
+ uint32_t secs = _iface->peek32(UE_REG_RB_TIME_NOW_SECS);
+ uint32_t ticks = _iface->peek32(UE_REG_RB_TIME_NOW_TICKS);
+ if (secs != _iface->peek32(UE_REG_RB_TIME_NOW_SECS)) continue;
+ val = time_spec_t(secs, ticks, _clock_ctrl->get_fpga_clock_rate());
+ return;
+ }
+
+ case MBOARD_PROP_TIME_PPS: while(true){
+ uint32_t secs = _iface->peek32(UE_REG_RB_TIME_PPS_SECS);
+ uint32_t ticks = _iface->peek32(UE_REG_RB_TIME_PPS_TICKS);
+ if (secs != _iface->peek32(UE_REG_RB_TIME_PPS_SECS)) continue;
+ val = time_spec_t(secs, ticks, _clock_ctrl->get_fpga_clock_rate());
+ return;
+ }
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -150,7 +168,7 @@ void usrp_e100_impl::mboard_set(const wax::obj &key, const wax::obj &val){
return;
case MBOARD_PROP_TIME_NOW:
- case MBOARD_PROP_TIME_NEXT_PPS:{
+ case MBOARD_PROP_TIME_PPS:{
time_spec_t time_spec = val.as<time_spec_t>();
_iface->poke32(UE_REG_TIME64_TICKS, time_spec.get_tick_count(_clock_ctrl->get_fpga_clock_rate()));
boost::uint32_t imm_flags = (key.as<mboard_prop_t>() == MBOARD_PROP_TIME_NOW)? 1 : 0;
diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp
index de158ea5e..864e82099 100644
--- a/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp
+++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp
@@ -30,7 +30,7 @@
#ifndef INCLUDED_USRP_E100_IMPL_HPP
#define INCLUDED_USRP_E100_IMPL_HPP
-static const boost::uint16_t USRP_E_COMPAT_NUM = 0x02;
+static const boost::uint16_t USRP_E_COMPAT_NUM = 0x03;
//! load an fpga image from a bin file into the usrp-e fpga
extern void usrp_e100_load_fpga(const std::string &bin_file);
diff --git a/host/lib/usrp/usrp_e100/usrp_e100_regs.hpp b/host/lib/usrp/usrp_e100/usrp_e100_regs.hpp
index 625fb2c35..a57fe5171 100644
--- a/host/lib/usrp/usrp_e100/usrp_e100_regs.hpp
+++ b/host/lib/usrp/usrp_e100/usrp_e100_regs.hpp
@@ -114,6 +114,16 @@
#define UE_REG_ATR_FULL_RXSIDE UE_REG_ATR_BASE + 12
#define UE_REG_ATR_FULL_TXSIDE UE_REG_ATR_BASE + 14
+///////////////////////////////////////////////////
+// Slave 7 -- Readback Mux 32
+
+#define UE_REG_RB_MUX_32_BASE UE_REG_SLAVE(7)
+
+#define UE_REG_RB_TIME_NOW_SECS UE_REG_RB_MUX_32_BASE + 0
+#define UE_REG_RB_TIME_NOW_TICKS UE_REG_RB_MUX_32_BASE + 4
+#define UE_REG_RB_TIME_PPS_SECS UE_REG_RB_MUX_32_BASE + 8
+#define UE_REG_RB_TIME_PPS_TICKS UE_REG_RB_MUX_32_BASE + 12
+
/////////////////////////////////////////////////
// DSP RX Regs
////////////////////////////////////////////////
diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt
index 60df24eef..5fa5b4d6d 100644
--- a/host/lib/utils/CMakeLists.txt
+++ b/host/lib/utils/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -87,6 +87,7 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/load_modules.cpp
${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp
${CMAKE_CURRENT_SOURCE_DIR}/props.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/static.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_priority.cpp
${CMAKE_CURRENT_SOURCE_DIR}/warning.cpp
)
diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp
index 11bbb8c0a..07aa21115 100644
--- a/host/lib/utils/gain_group.cpp
+++ b/host/lib/utils/gain_group.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -39,7 +39,7 @@ static bool compare_by_step_size(
* Get a multiple of step with the following relation:
* result = step*floor(num/step)
*
- * Due to small floating-point inaccuracies:
+ * Due to small doubleing-point inaccuracies:
* num = n*step + e, where e is a small inaccuracy.
* When e is negative, floor would yeild (n-1)*step,
* despite that n*step is really the desired result.
@@ -66,7 +66,7 @@ public:
gain_range_t get_range(const std::string &name){
if (not name.empty()) return _name_to_fcns[name].get_range();
- float overall_min = 0, overall_max = 0, overall_step = 0;
+ double overall_min = 0, overall_max = 0, overall_step = 0;
BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
const gain_range_t range = fcns.get_range();
overall_min += range.start();
@@ -78,33 +78,33 @@ public:
return gain_range_t(overall_min, overall_max, overall_step);
}
- float get_value(const std::string &name){
+ double get_value(const std::string &name){
if (not name.empty()) return _name_to_fcns[name].get_value();
- float overall_gain = 0;
+ double overall_gain = 0;
BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
overall_gain += fcns.get_value();
}
return overall_gain;
}
- void set_value(float gain, const std::string &name){
+ void set_value(double gain, const std::string &name){
if (not name.empty()) return _name_to_fcns[name].set_value(gain);
std::vector<gain_fcns_t> all_fcns = get_all_fcns();
if (all_fcns.size() == 0) return; //nothing to set!
//get the max step size among the gains
- float max_step = 0;
+ double max_step = 0;
BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
max_step = std::max(max_step, fcns.get_range().step());
}
//create gain bucket to distribute power
- std::vector<float> gain_bucket;
+ std::vector<double> gain_bucket;
//distribute power according to priority (round to max step)
- float gain_left_to_distribute = gain;
+ double gain_left_to_distribute = gain;
BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
const gain_range_t range = fcns.get_range();
gain_bucket.push_back(floor_step(std::clip(
@@ -131,7 +131,7 @@ public:
//fill in the largest step sizes first that are less than the remainder
BOOST_FOREACH(size_t i, indexes_step_size_dec){
const gain_range_t range = all_fcns.at(i).get_range();
- float additional_gain = floor_step(std::clip(
+ double additional_gain = floor_step(std::clip(
gain_bucket.at(i) + gain_left_to_distribute, range.start(), range.stop()
), range.step()) - gain_bucket.at(i);
gain_bucket.at(i) += additional_gain;
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index 9e9525caf..93d15d290 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -17,7 +17,7 @@
#include "constants.hpp"
#include <uhd/config.hpp>
-#include <uhd/utils/algorithm.hpp>
+#include <boost/tokenizer.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
@@ -38,6 +38,10 @@ namespace fs = boost::filesystem;
static const std::string env_path_sep = ":";
#endif /*UHD_PLATFORM_WIN32*/
+#define path_tokenizer(inp) \
+ boost::tokenizer<boost::char_separator<char> > \
+ (inp, boost::char_separator<char>(env_path_sep.c_str()))
+
/***********************************************************************
* Get a list of paths for an environment variable
**********************************************************************/
@@ -60,7 +64,7 @@ static std::vector<fs::path> get_env_paths(const std::string &var_name){
//convert to filesystem path, filter blank paths
std::vector<fs::path> paths;
- BOOST_FOREACH(const std::string &path_string, std::split_string(var_value, env_path_sep)){
+ BOOST_FOREACH(const std::string &path_string, path_tokenizer(var_value)){
if (path_string.empty()) continue;
paths.push_back(fs::system_complete(path_string));
}
diff --git a/host/lib/transport/msvc/stdint.h b/host/lib/utils/static.cpp
index b3eb61aae..a0dea3372 100644
--- a/host/lib/transport/msvc/stdint.h
+++ b/host/lib/utils/static.cpp
@@ -1,35 +1,32 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// 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/>.
-//
-
-#ifndef INCLUDED_LIBUHD_TRANSPORT_STDINT_H
-#define INCLUDED_LIBUHD_TRANSPORT_STDINT_H
-
-#include <boost/cstdint.hpp>
-
-//provide a stdint implementation for libusb
-
-typedef boost::uint64_t uint64_t;
-typedef boost::uint32_t uint32_t;
-typedef boost::uint16_t uint16_t;
-typedef boost::uint8_t uint8_t;
-
-typedef boost::int64_t int64_t;
-typedef boost::int32_t int32_t;
-typedef boost::int16_t int16_t;
-typedef boost::int8_t int8_t;
-
-#endif /* INCLUDED_LIBUHD_TRANSPORT_STDINT_H */
+//
+// Copyright 2011 Ettus Research LLC
+//
+// 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/>.
+//
+
+#include <uhd/utils/static.hpp>
+#include <stdexcept>
+#include <iostream>
+_uhd_static_fixture::_uhd_static_fixture(void (*fcn)(void), const char *name){
+ try{
+ fcn();
+ }
+ catch(const std::exception &e){
+ std::cerr << "Exception in static block " << name << std::endl;
+ std::cerr << " " << e.what() << std::endl;
+ }
+ catch(...){
+ std::cerr << "Exception in static block " << name << std::endl;
+ }
+}
diff --git a/host/lib/utils/warning.cpp b/host/lib/utils/warning.cpp
index 05be7ae4d..bc4c79b6e 100644
--- a/host/lib/utils/warning.cpp
+++ b/host/lib/utils/warning.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -16,7 +16,7 @@
//
#include <uhd/utils/warning.hpp>
-#include <uhd/utils/algorithm.hpp>
+#include <boost/tokenizer.hpp>
#include <uhd/utils/static.hpp>
#include <uhd/types/dict.hpp>
#include <boost/foreach.hpp>
@@ -27,6 +27,10 @@
using namespace uhd;
+#define tokenizer(inp, sep) \
+ boost::tokenizer<boost::char_separator<char> > \
+ (inp, boost::char_separator<char>(sep))
+
/***********************************************************************
* Registry implementation
**********************************************************************/
@@ -52,7 +56,7 @@ void warning::post(const std::string &msg){
//format the warning message
ss << std::endl << "Warning:" << std::endl;
- BOOST_FOREACH(const std::string &line, std::split_string(msg, "\n")){
+ BOOST_FOREACH(const std::string &line, tokenizer(msg, "\n")){
ss << " " << line << std::endl;
}
diff --git a/host/msvc/inttypes.h b/host/msvc/inttypes.h
new file mode 100644
index 000000000..1c2baa82e
--- /dev/null
+++ b/host/msvc/inttypes.h
@@ -0,0 +1,301 @@
+// ISO C9x compliant inttypes.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_INTTYPES_H_ // [
+#define _MSC_INTTYPES_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <stdint.h>
+
+// 7.8 Format conversion of integer types
+
+typedef struct {
+ intmax_t quot;
+ intmax_t rem;
+} imaxdiv_t;
+
+// 7.8.1 Macros for format specifiers
+
+// The fprintf macros for signed integers are:
+#define PRId8 "d"
+#define PRIi8 "i"
+#define PRIdLEAST8 "d"
+#define PRIiLEAST8 "i"
+#define PRIdFAST8 "d"
+#define PRIiFAST8 "i"
+
+#define PRId16 "hd"
+#define PRIi16 "hi"
+#define PRIdLEAST16 "hd"
+#define PRIiLEAST16 "hi"
+#define PRIdFAST16 "hd"
+#define PRIiFAST16 "hi"
+
+#define PRId32 "I32d"
+#define PRIi32 "I32i"
+#define PRIdLEAST32 "I32d"
+#define PRIiLEAST32 "I32i"
+#define PRIdFAST32 "I32d"
+#define PRIiFAST32 "I32i"
+
+#define PRId64 "I64d"
+#define PRIi64 "I64i"
+#define PRIdLEAST64 "I64d"
+#define PRIiLEAST64 "I64i"
+#define PRIdFAST64 "I64d"
+#define PRIiFAST64 "I64i"
+
+#define PRIdMAX "I64d"
+#define PRIiMAX "I64i"
+
+#define PRIdPTR "Id"
+#define PRIiPTR "Ii"
+
+// The fprintf macros for unsigned integers are:
+#define PRIo8 "o"
+#define PRIu8 "u"
+#define PRIx8 "x"
+#define PRIX8 "X"
+#define PRIoLEAST8 "o"
+#define PRIuLEAST8 "u"
+#define PRIxLEAST8 "x"
+#define PRIXLEAST8 "X"
+#define PRIoFAST8 "o"
+#define PRIuFAST8 "u"
+#define PRIxFAST8 "x"
+#define PRIXFAST8 "X"
+
+#define PRIo16 "ho"
+#define PRIu16 "hu"
+#define PRIx16 "hx"
+#define PRIX16 "hX"
+#define PRIoLEAST16 "ho"
+#define PRIuLEAST16 "hu"
+#define PRIxLEAST16 "hx"
+#define PRIXLEAST16 "hX"
+#define PRIoFAST16 "ho"
+#define PRIuFAST16 "hu"
+#define PRIxFAST16 "hx"
+#define PRIXFAST16 "hX"
+
+#define PRIo32 "I32o"
+#define PRIu32 "I32u"
+#define PRIx32 "I32x"
+#define PRIX32 "I32X"
+#define PRIoLEAST32 "I32o"
+#define PRIuLEAST32 "I32u"
+#define PRIxLEAST32 "I32x"
+#define PRIXLEAST32 "I32X"
+#define PRIoFAST32 "I32o"
+#define PRIuFAST32 "I32u"
+#define PRIxFAST32 "I32x"
+#define PRIXFAST32 "I32X"
+
+#define PRIo64 "I64o"
+#define PRIu64 "I64u"
+#define PRIx64 "I64x"
+#define PRIX64 "I64X"
+#define PRIoLEAST64 "I64o"
+#define PRIuLEAST64 "I64u"
+#define PRIxLEAST64 "I64x"
+#define PRIXLEAST64 "I64X"
+#define PRIoFAST64 "I64o"
+#define PRIuFAST64 "I64u"
+#define PRIxFAST64 "I64x"
+#define PRIXFAST64 "I64X"
+
+#define PRIoMAX "I64o"
+#define PRIuMAX "I64u"
+#define PRIxMAX "I64x"
+#define PRIXMAX "I64X"
+
+#define PRIoPTR "Io"
+#define PRIuPTR "Iu"
+#define PRIxPTR "Ix"
+#define PRIXPTR "IX"
+
+// The fscanf macros for signed integers are:
+#define SCNd8 "d"
+#define SCNi8 "i"
+#define SCNdLEAST8 "d"
+#define SCNiLEAST8 "i"
+#define SCNdFAST8 "d"
+#define SCNiFAST8 "i"
+
+#define SCNd16 "hd"
+#define SCNi16 "hi"
+#define SCNdLEAST16 "hd"
+#define SCNiLEAST16 "hi"
+#define SCNdFAST16 "hd"
+#define SCNiFAST16 "hi"
+
+#define SCNd32 "ld"
+#define SCNi32 "li"
+#define SCNdLEAST32 "ld"
+#define SCNiLEAST32 "li"
+#define SCNdFAST32 "ld"
+#define SCNiFAST32 "li"
+
+#define SCNd64 "I64d"
+#define SCNi64 "I64i"
+#define SCNdLEAST64 "I64d"
+#define SCNiLEAST64 "I64i"
+#define SCNdFAST64 "I64d"
+#define SCNiFAST64 "I64i"
+
+#define SCNdMAX "I64d"
+#define SCNiMAX "I64i"
+
+#ifdef _WIN64 // [
+# define SCNdPTR "I64d"
+# define SCNiPTR "I64i"
+#else // _WIN64 ][
+# define SCNdPTR "ld"
+# define SCNiPTR "li"
+#endif // _WIN64 ]
+
+// The fscanf macros for unsigned integers are:
+#define SCNo8 "o"
+#define SCNu8 "u"
+#define SCNx8 "x"
+#define SCNX8 "X"
+#define SCNoLEAST8 "o"
+#define SCNuLEAST8 "u"
+#define SCNxLEAST8 "x"
+#define SCNXLEAST8 "X"
+#define SCNoFAST8 "o"
+#define SCNuFAST8 "u"
+#define SCNxFAST8 "x"
+#define SCNXFAST8 "X"
+
+#define SCNo16 "ho"
+#define SCNu16 "hu"
+#define SCNx16 "hx"
+#define SCNX16 "hX"
+#define SCNoLEAST16 "ho"
+#define SCNuLEAST16 "hu"
+#define SCNxLEAST16 "hx"
+#define SCNXLEAST16 "hX"
+#define SCNoFAST16 "ho"
+#define SCNuFAST16 "hu"
+#define SCNxFAST16 "hx"
+#define SCNXFAST16 "hX"
+
+#define SCNo32 "lo"
+#define SCNu32 "lu"
+#define SCNx32 "lx"
+#define SCNX32 "lX"
+#define SCNoLEAST32 "lo"
+#define SCNuLEAST32 "lu"
+#define SCNxLEAST32 "lx"
+#define SCNXLEAST32 "lX"
+#define SCNoFAST32 "lo"
+#define SCNuFAST32 "lu"
+#define SCNxFAST32 "lx"
+#define SCNXFAST32 "lX"
+
+#define SCNo64 "I64o"
+#define SCNu64 "I64u"
+#define SCNx64 "I64x"
+#define SCNX64 "I64X"
+#define SCNoLEAST64 "I64o"
+#define SCNuLEAST64 "I64u"
+#define SCNxLEAST64 "I64x"
+#define SCNXLEAST64 "I64X"
+#define SCNoFAST64 "I64o"
+#define SCNuFAST64 "I64u"
+#define SCNxFAST64 "I64x"
+#define SCNXFAST64 "I64X"
+
+#define SCNoMAX "I64o"
+#define SCNuMAX "I64u"
+#define SCNxMAX "I64x"
+#define SCNXMAX "I64X"
+
+#ifdef _WIN64 // [
+# define SCNoPTR "I64o"
+# define SCNuPTR "I64u"
+# define SCNxPTR "I64x"
+# define SCNXPTR "I64X"
+#else // _WIN64 ][
+# define SCNoPTR "lo"
+# define SCNuPTR "lu"
+# define SCNxPTR "lx"
+# define SCNXPTR "lX"
+#endif // _WIN64 ]
+
+// 7.8.2 Functions for greatest-width integer types
+
+// 7.8.2.1 The imaxabs function
+#define imaxabs _abs64
+
+// 7.8.2.2 The imaxdiv function
+
+// This is modified version of div() function from Microsoft's div.c found
+// in %MSVC.NET%\crt\src\div.c
+#ifdef STATIC_IMAXDIV // [
+static
+#else // STATIC_IMAXDIV ][
+_inline
+#endif // STATIC_IMAXDIV ]
+imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
+{
+ imaxdiv_t result;
+
+ result.quot = numer / denom;
+ result.rem = numer % denom;
+
+ if (numer < 0 && result.rem > 0) {
+ // did division wrong; must fix up
+ ++result.quot;
+ result.rem -= denom;
+ }
+
+ return result;
+}
+
+// 7.8.2.3 The strtoimax and strtoumax functions
+#define strtoimax _strtoi64
+#define strtoumax _strtoui64
+
+// 7.8.2.4 The wcstoimax and wcstoumax functions
+#define wcstoimax _wcstoi64
+#define wcstoumax _wcstoui64
+
+
+#endif // _MSC_INTTYPES_H_ ]
diff --git a/host/msvc/stdint.h b/host/msvc/stdint.h
new file mode 100644
index 000000000..15333b467
--- /dev/null
+++ b/host/msvc/stdint.h
@@ -0,0 +1,226 @@
+// ISO C9x compliant stdint.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_STDINT_H_ // [
+#define _MSC_STDINT_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <limits.h>
+
+// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
+// or compiler give many errors like this:
+// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
+#if (_MSC_VER < 1300) && defined(__cplusplus)
+ extern "C++" {
+#endif
+# include <wchar.h>
+#if (_MSC_VER < 1300) && defined(__cplusplus)
+ }
+#endif
+
+// 7.18.1 Integer types
+
+// 7.18.1.1 Exact-width integer types
+typedef __int8 int8_t;
+typedef __int16 int16_t;
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+
+// 7.18.1.2 Minimum-width integer types
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+// 7.18.1.3 Fastest minimum-width integer types
+typedef int8_t int_fast8_t;
+typedef int16_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef int64_t int_fast64_t;
+typedef uint8_t uint_fast8_t;
+typedef uint16_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+typedef uint64_t uint_fast64_t;
+
+// 7.18.1.4 Integer types capable of holding object pointers
+#ifdef _WIN64 // [
+ typedef __int64 intptr_t;
+ typedef unsigned __int64 uintptr_t;
+#else // _WIN64 ][
+ typedef int intptr_t;
+ typedef unsigned int uintptr_t;
+#endif // _WIN64 ]
+
+// 7.18.1.5 Greatest-width integer types
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+
+
+// 7.18.2 Limits of specified-width integer types
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
+
+// 7.18.2.1 Limits of exact-width integer types
+#define INT8_MIN ((int8_t)_I8_MIN)
+#define INT8_MAX _I8_MAX
+#define INT16_MIN ((int16_t)_I16_MIN)
+#define INT16_MAX _I16_MAX
+#define INT32_MIN ((int32_t)_I32_MIN)
+#define INT32_MAX _I32_MAX
+#define INT64_MIN ((int64_t)_I64_MIN)
+#define INT64_MAX _I64_MAX
+#define UINT8_MAX _UI8_MAX
+#define UINT16_MAX _UI16_MAX
+#define UINT32_MAX _UI32_MAX
+#define UINT64_MAX _UI64_MAX
+
+// 7.18.2.2 Limits of minimum-width integer types
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+// 7.18.2.3 Limits of fastest minimum-width integer types
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+// 7.18.2.4 Limits of integer types capable of holding object pointers
+#ifdef _WIN64 // [
+# define INTPTR_MIN INT64_MIN
+# define INTPTR_MAX INT64_MAX
+# define UINTPTR_MAX UINT64_MAX
+#else // _WIN64 ][
+# define INTPTR_MIN INT32_MIN
+# define INTPTR_MAX INT32_MAX
+# define UINTPTR_MAX UINT32_MAX
+#endif // _WIN64 ]
+
+// 7.18.2.5 Limits of greatest-width integer types
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+// 7.18.3 Limits of other integer types
+
+#ifdef _WIN64 // [
+# define PTRDIFF_MIN _I64_MIN
+# define PTRDIFF_MAX _I64_MAX
+#else // _WIN64 ][
+# define PTRDIFF_MIN _I32_MIN
+# define PTRDIFF_MAX _I32_MAX
+#endif // _WIN64 ]
+
+#define SIG_ATOMIC_MIN INT_MIN
+#define SIG_ATOMIC_MAX INT_MAX
+
+#ifndef SIZE_MAX // [
+# ifdef _WIN64 // [
+# define SIZE_MAX _UI64_MAX
+# else // _WIN64 ][
+# define SIZE_MAX _UI32_MAX
+# endif // _WIN64 ]
+#endif // SIZE_MAX ]
+
+// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
+#ifndef WCHAR_MIN // [
+# define WCHAR_MIN 0
+#endif // WCHAR_MIN ]
+#ifndef WCHAR_MAX // [
+# define WCHAR_MAX _UI16_MAX
+#endif // WCHAR_MAX ]
+
+#define WINT_MIN 0
+#define WINT_MAX _UI16_MAX
+
+#endif // __STDC_LIMIT_MACROS ]
+
+
+// 7.18.4 Limits of other integer types
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
+
+// 7.18.4.1 Macros for minimum-width integer constants
+
+#define INT8_C(val) val##i8
+#define INT16_C(val) val##i16
+#define INT32_C(val) val##i32
+#define INT64_C(val) val##i64
+
+#define UINT8_C(val) val##ui8
+#define UINT16_C(val) val##ui16
+#define UINT32_C(val) val##ui32
+#define UINT64_C(val) val##ui64
+
+// 7.18.4.2 Macros for greatest-width integer constants
+#ifndef INTMAX_C
+#define INTMAX_C INT64_C
+#endif
+#ifndef UINTMAX_C
+#define UINTMAX_C UINT64_C
+#endif
+
+#endif // __STDC_CONSTANT_MACROS ]
+
+
+#endif // _MSC_STDINT_H_ ]
diff --git a/host/test/CMakeLists.txt b/host/tests/CMakeLists.txt
index bdbde4b2c..79b20cd47 100644
--- a/host/test/CMakeLists.txt
+++ b/host/tests/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 Ettus Research LLC
#
# 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
@@ -22,7 +22,7 @@ SET(test_sources
addr_test.cpp
buffer_test.cpp
byteswap_test.cpp
- convert_types_test.cpp
+ convert_test.cpp
dict_test.cpp
error_test.cpp
gain_group_test.cpp
@@ -51,6 +51,7 @@ ENDFOREACH(test_source)
# demo of a loadable module
########################################################################
ADD_LIBRARY(module_test MODULE module_test.cpp)
+TARGET_LINK_LIBRARIES(module_test uhd)
INSTALL(TARGETS
RUNTIME DESTINATION ${PKG_DATA_DIR}/tests
diff --git a/host/test/addr_test.cpp b/host/tests/addr_test.cpp
index d4b45aa1a..d4b45aa1a 100644
--- a/host/test/addr_test.cpp
+++ b/host/tests/addr_test.cpp
diff --git a/host/test/buffer_test.cpp b/host/tests/buffer_test.cpp
index 8445412e7..e7bc88699 100644
--- a/host/test/buffer_test.cpp
+++ b/host/tests/buffer_test.cpp
@@ -17,7 +17,6 @@
#include <boost/test/unit_test.hpp>
#include <uhd/transport/bounded_buffer.hpp>
-#include <uhd/transport/alignment_buffer.hpp>
#include <boost/assign/list_of.hpp>
using namespace boost::assign;
@@ -63,53 +62,3 @@ BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_pop_on_full){
BOOST_CHECK(bb->pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 3);
}
-
-BOOST_AUTO_TEST_CASE(test_alignment_buffer){
- alignment_buffer<int, size_t>::sptr ab(alignment_buffer<int, size_t>::make(7, 3));
- //load index 0 with all good seq numbers
- BOOST_CHECK(ab->push_with_pop_on_full(0, 0, 0));
- BOOST_CHECK(ab->push_with_pop_on_full(1, 1, 0));
- BOOST_CHECK(ab->push_with_pop_on_full(2, 2, 0));
- BOOST_CHECK(ab->push_with_pop_on_full(3, 3, 0));
- BOOST_CHECK(ab->push_with_pop_on_full(4, 4, 0));
-
- //load index 1 with some skipped seq numbers
- BOOST_CHECK(ab->push_with_pop_on_full(10, 0, 1));
- BOOST_CHECK(ab->push_with_pop_on_full(11, 1, 1));
- BOOST_CHECK(ab->push_with_pop_on_full(14, 4, 1));
- BOOST_CHECK(ab->push_with_pop_on_full(15, 5, 1));
- BOOST_CHECK(ab->push_with_pop_on_full(16, 6, 1));
-
- //load index 2 with all good seq numbers
- BOOST_CHECK(ab->push_with_pop_on_full(20, 0, 2));
- BOOST_CHECK(ab->push_with_pop_on_full(21, 1, 2));
- BOOST_CHECK(ab->push_with_pop_on_full(22, 2, 2));
- BOOST_CHECK(ab->push_with_pop_on_full(23, 3, 2));
- BOOST_CHECK(ab->push_with_pop_on_full(24, 4, 2));
-
- //readback aligned values
- std::vector<int> aligned_elems(3);
-
- static const std::vector<int> expected_elems0 = list_of(0)(10)(20);
- BOOST_CHECK(ab->pop_elems_with_timed_wait(aligned_elems, timeout));
- BOOST_CHECK_EQUAL_COLLECTIONS(
- aligned_elems.begin(), aligned_elems.end(),
- expected_elems0.begin(), expected_elems0.end()
- );
-
- static const std::vector<int> expected_elems1 = list_of(1)(11)(21);
- BOOST_CHECK(ab->pop_elems_with_timed_wait(aligned_elems, timeout));
- BOOST_CHECK_EQUAL_COLLECTIONS(
- aligned_elems.begin(), aligned_elems.end(),
- expected_elems1.begin(), expected_elems1.end()
- );
-
- //there was a skip now find 4
-
- static const std::vector<int> expected_elems4 = list_of(4)(14)(24);
- BOOST_CHECK(ab->pop_elems_with_timed_wait(aligned_elems, timeout));
- BOOST_CHECK_EQUAL_COLLECTIONS(
- aligned_elems.begin(), aligned_elems.end(),
- expected_elems4.begin(), expected_elems4.end()
- );
-}
diff --git a/host/test/byteswap_test.cpp b/host/tests/byteswap_test.cpp
index 3d50c9bfa..3d50c9bfa 100644
--- a/host/test/byteswap_test.cpp
+++ b/host/tests/byteswap_test.cpp
diff --git a/host/test/convert_types_test.cpp b/host/tests/convert_test.cpp
index 378e184de..5f2aaf3d1 100644
--- a/host/test/convert_types_test.cpp
+++ b/host/tests/convert_test.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2011-2011 Ettus Research LLC
//
// 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
@@ -15,14 +15,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include <uhd/transport/convert_types.hpp>
+#include <uhd/convert.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp>
#include <boost/cstdint.hpp>
-#include <boost/asio/buffer.hpp>
#include <complex>
#include <vector>
#include <cstdlib>
+#include <iostream>
using namespace uhd;
@@ -30,14 +30,6 @@ using namespace uhd;
typedef std::complex<boost::int16_t> sc16_t;
typedef std::complex<float> fc32_t;
-//extract pointer to POD since using &vector.front() throws in MSVC
-template <typename T> void * pod2ptr(T &pod){
- return boost::asio::buffer_cast<void *>(boost::asio::buffer(pod));
-}
-template <typename T> const void * pod2ptr(const T &pod){
- return boost::asio::buffer_cast<const void *>(boost::asio::buffer(pod));
-}
-
#define MY_CHECK_CLOSE(a, b, f) if ((std::abs(a) > (f) and std::abs(b) > (f))) \
BOOST_CHECK_CLOSE_FRACTION(a, b, f)
@@ -54,21 +46,20 @@ template <typename Range> static void loopback(
Range &output
){
//item32 is largest device type
- std::vector<boost::uint32_t> dev(nsamps);
+ std::vector<boost::uint32_t> interm(nsamps);
- //convert to dev type
- transport::convert_io_type_to_otw_type(
- pod2ptr(input), io_type,
- pod2ptr(dev), otw_type,
- nsamps
- );
+ convert::input_type input0(1, &input[0]), input1(1, &interm[0]);
+ convert::output_type output0(1, &interm[0]), output1(1, &output[0]);
+
+ //convert to intermediate type
+ convert::get_converter_cpu_to_otw(
+ io_type, otw_type, input0.size(), output0.size()
+ )(input0, output0, nsamps);
//convert back to host type
- transport::convert_otw_type_to_io_type(
- pod2ptr(dev), otw_type,
- pod2ptr(output), io_type,
- nsamps
- );
+ convert::get_converter_otw_to_cpu(
+ io_type, otw_type, input1.size(), output1.size()
+ )(input1, output1, nsamps);
}
/***********************************************************************
@@ -98,7 +89,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_sc16(nsamps, io_type, otw_type);
}
}
@@ -110,7 +101,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_sc16(nsamps, io_type, otw_type);
}
}
@@ -145,7 +136,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_fc32(nsamps, io_type, otw_type);
}
}
@@ -157,7 +148,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_fc32(nsamps, io_type, otw_type);
}
}
@@ -179,22 +170,21 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){
(std::rand()/float(RAND_MAX/2)) - 1,
(std::rand()/float(RAND_MAX/2)) - 1
);
+ std::vector<boost::uint32_t> interm(nsamps);
+ std::vector<sc16_t> output(nsamps);
- //convert float to dev
- std::vector<boost::uint32_t> tmp(nsamps);
- transport::convert_io_type_to_otw_type(
- pod2ptr(input), io_type_in,
- pod2ptr(tmp), otw_type,
- nsamps
- );
+ convert::input_type input0(1, &input[0]), input1(1, &interm[0]);
+ convert::output_type output0(1, &interm[0]), output1(1, &output[0]);
- //convert dev to short
- std::vector<sc16_t> output(nsamps);
- transport::convert_otw_type_to_io_type(
- pod2ptr(tmp), otw_type,
- pod2ptr(output), io_type_out,
- nsamps
- );
+ //convert float to intermediate
+ convert::get_converter_cpu_to_otw(
+ io_type_in, otw_type, input0.size(), output0.size()
+ )(input0, output0, nsamps);
+
+ //convert intermediate to short
+ convert::get_converter_otw_to_cpu(
+ io_type_out, otw_type, input1.size(), output1.size()
+ )(input1, output1, nsamps);
//test that the inputs and outputs match
for (size_t i = 0; i < nsamps; i++){
@@ -220,22 +210,21 @@ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){
std::rand()-(RAND_MAX/2),
std::rand()-(RAND_MAX/2)
);
+ std::vector<boost::uint32_t> interm(nsamps);
+ std::vector<fc32_t> output(nsamps);
- //convert short to dev
- std::vector<boost::uint32_t> tmp(nsamps);
- transport::convert_io_type_to_otw_type(
- pod2ptr(input), io_type_in,
- pod2ptr(tmp), otw_type,
- nsamps
- );
+ convert::input_type input0(1, &input[0]), input1(1, &interm[0]);
+ convert::output_type output0(1, &interm[0]), output1(1, &output[0]);
- //convert dev to float
- std::vector<fc32_t> output(nsamps);
- transport::convert_otw_type_to_io_type(
- pod2ptr(tmp), otw_type,
- pod2ptr(output), io_type_out,
- nsamps
- );
+ //convert short to intermediate
+ convert::get_converter_cpu_to_otw(
+ io_type_in, otw_type, input0.size(), output0.size()
+ )(input0, output0, nsamps);
+
+ //convert intermediate to float
+ convert::get_converter_otw_to_cpu(
+ io_type_out, otw_type, input1.size(), output1.size()
+ )(input1, output1, nsamps);
//test that the inputs and outputs match
for (size_t i = 0; i < nsamps; i++){
diff --git a/host/test/dict_test.cpp b/host/tests/dict_test.cpp
index 0501a7878..0501a7878 100644
--- a/host/test/dict_test.cpp
+++ b/host/tests/dict_test.cpp
diff --git a/host/test/error_test.cpp b/host/tests/error_test.cpp
index c76a15ab7..c76a15ab7 100644
--- a/host/test/error_test.cpp
+++ b/host/tests/error_test.cpp
diff --git a/host/test/gain_group_test.cpp b/host/tests/gain_group_test.cpp
index dbb585987..53142ef21 100644
--- a/host/test/gain_group_test.cpp
+++ b/host/tests/gain_group_test.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -35,37 +35,37 @@ public:
return gain_range_t(0, 90, 1);
}
- float get_value(void){
+ double get_value(void){
return _gain;
}
- void set_value(float gain){
- float step = get_range().step();
+ void set_value(double gain){
+ double step = get_range().step();
_gain = step*rint(gain/step);
}
private:
- float _gain;
+ double _gain;
};
class gain_element2{
public:
gain_range_t get_range(void){
- return gain_range_t(-20, 10, float(0.1));
+ return gain_range_t(-20, 10, 0.1);
}
- float get_value(void){
+ double get_value(void){
return _gain;
}
- void set_value(float gain){
- float step = get_range().step();
+ void set_value(double gain){
+ double step = get_range().step();
_gain = step*rint(gain/step);
}
private:
- float _gain;
+ double _gain;
};
//create static instances of gain elements to be shared by the tests
@@ -94,17 +94,17 @@ static gain_group::sptr get_gain_group(size_t pri1 = 0, size_t pri2 = 0){
/***********************************************************************
* Test cases
**********************************************************************/
-static const float tolerance = float(0.001);
+static const double tolerance = 0.001;
BOOST_AUTO_TEST_CASE(test_gain_group_overall){
gain_group::sptr gg = get_gain_group();
//test the overall stuff
gg->set_value(80);
- BOOST_CHECK_CLOSE(gg->get_value(), float(80), tolerance);
- BOOST_CHECK_CLOSE(gg->get_range().start(), float(-20), tolerance);
- BOOST_CHECK_CLOSE(gg->get_range().stop(), float(100), tolerance);
- BOOST_CHECK_CLOSE(gg->get_range().step(), float(0.1), tolerance);
+ BOOST_CHECK_CLOSE(gg->get_value(), 80, tolerance);
+ BOOST_CHECK_CLOSE(gg->get_range().start(), -20, tolerance);
+ BOOST_CHECK_CLOSE(gg->get_range().stop(), 100, tolerance);
+ BOOST_CHECK_CLOSE(gg->get_range().step(), 0.1, tolerance);
}
BOOST_AUTO_TEST_CASE(test_gain_group_priority){
@@ -112,10 +112,10 @@ BOOST_AUTO_TEST_CASE(test_gain_group_priority){
//test the overall stuff
gg->set_value(80);
- BOOST_CHECK_CLOSE(gg->get_value(), float(80), tolerance);
- BOOST_CHECK_CLOSE(gg->get_range().start(), float(-20), tolerance);
- BOOST_CHECK_CLOSE(gg->get_range().stop(), float(100), tolerance);
- BOOST_CHECK_CLOSE(gg->get_range().step(), float(0.1), tolerance);
+ BOOST_CHECK_CLOSE(gg->get_value(), 80, tolerance);
+ BOOST_CHECK_CLOSE(gg->get_range().start(), -20, tolerance);
+ BOOST_CHECK_CLOSE(gg->get_range().stop(), 100, tolerance);
+ BOOST_CHECK_CLOSE(gg->get_range().step(), 0.1, tolerance);
//test the the higher priority gain got filled first (gain 2)
BOOST_CHECK_CLOSE(g2.get_value(), g2.get_range().stop(), tolerance);
diff --git a/host/test/module_test.cpp b/host/tests/module_test.cpp
index 47a0e1af9..47a0e1af9 100644
--- a/host/test/module_test.cpp
+++ b/host/tests/module_test.cpp
diff --git a/host/test/ranges_test.cpp b/host/tests/ranges_test.cpp
index ad61867e1..5f6de4645 100644
--- a/host/test/ranges_test.cpp
+++ b/host/tests/ranges_test.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -24,18 +24,18 @@ using namespace uhd;
static const double tolerance = 0.001;
BOOST_AUTO_TEST_CASE(test_ranges_bounds){
- meta_range_t<double> mr;
- mr.push_back(range_t<double>(-1.0, +1.0, 0.1));
+ meta_range_t mr;
+ mr.push_back(range_t(-1.0, +1.0, 0.1));
BOOST_CHECK_CLOSE(mr.start(), -1.0, tolerance);
BOOST_CHECK_CLOSE(mr.stop(), +1.0, tolerance);
BOOST_CHECK_CLOSE(mr.step(), 0.1, tolerance);
- mr.push_back(range_t<double>(40.0, 60.0, 1.0));
+ mr.push_back(range_t(40.0, 60.0, 1.0));
BOOST_CHECK_CLOSE(mr.start(), -1.0, tolerance);
BOOST_CHECK_CLOSE(mr.stop(), 60.0, tolerance);
BOOST_CHECK_CLOSE(mr.step(), 0.1, tolerance);
- BOOST_CHECK_EQUAL(mr.size(), 2);
+ BOOST_CHECK_EQUAL(mr.size(), unsigned(2));
BOOST_CHECK_CLOSE(mr[0].start(), -1.0, tolerance);
BOOST_CHECK_CLOSE(mr[0].stop(), +1.0, tolerance);
@@ -43,9 +43,9 @@ BOOST_AUTO_TEST_CASE(test_ranges_bounds){
}
BOOST_AUTO_TEST_CASE(test_ranges_clip){
- meta_range_t<double> mr;
- mr.push_back(range_t<double>(-1.0, +1.0, 0.1));
- mr.push_back(range_t<double>(40.0, 60.0, 1.0));
+ meta_range_t mr;
+ mr.push_back(range_t(-1.0, +1.0, 0.1));
+ mr.push_back(range_t(40.0, 60.0, 1.0));
BOOST_CHECK_CLOSE(mr.clip(-30.0), -1.0, tolerance);
BOOST_CHECK_CLOSE(mr.clip(70.0), 60.0, tolerance);
diff --git a/host/test/subdev_spec_test.cpp b/host/tests/subdev_spec_test.cpp
index 8817d5eee..8817d5eee 100644
--- a/host/test/subdev_spec_test.cpp
+++ b/host/tests/subdev_spec_test.cpp
diff --git a/host/test/time_spec_test.cpp b/host/tests/time_spec_test.cpp
index 5ad782160..5ad782160 100644
--- a/host/test/time_spec_test.cpp
+++ b/host/tests/time_spec_test.cpp
diff --git a/host/test/tune_helper_test.cpp b/host/tests/tune_helper_test.cpp
index 735e7e948..735e7e948 100644
--- a/host/test/tune_helper_test.cpp
+++ b/host/tests/tune_helper_test.cpp
diff --git a/host/test/vrt_test.cpp b/host/tests/vrt_test.cpp
index 9e131a10b..9e131a10b 100644
--- a/host/test/vrt_test.cpp
+++ b/host/tests/vrt_test.cpp
diff --git a/host/test/warning_test.cpp b/host/tests/warning_test.cpp
index db19955de..db19955de 100644
--- a/host/test/warning_test.cpp
+++ b/host/tests/warning_test.cpp
diff --git a/host/test/wax_test.cpp b/host/tests/wax_test.cpp
index 731f470ed..731f470ed 100644
--- a/host/test/wax_test.cpp
+++ b/host/tests/wax_test.cpp
diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt
index a8e50f72b..2df1c3529 100644
--- a/host/utils/CMakeLists.txt
+++ b/host/utils/CMakeLists.txt
@@ -47,6 +47,7 @@ ENDIF(ENABLE_USRP1)
IF(ENABLE_USRP_E100)
ENABLE_LANGUAGE(C)
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/include)
LIST(APPEND util_share_sources
fpga-downloader.cpp
diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp
index 5cba7c362..b32131b2a 100644
--- a/host/utils/uhd_usrp_probe.cpp
+++ b/host/utils/uhd_usrp_probe.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// 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
@@ -18,7 +18,7 @@
#include <uhd/utils/safe_main.hpp>
#include <uhd/device.hpp>
#include <uhd/types/ranges.hpp>
-#include <uhd/utils/algorithm.hpp>
+#include <boost/algorithm/string.hpp> //for split
#include <uhd/usrp/device_props.hpp>
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
@@ -32,6 +32,7 @@
#include <boost/foreach.hpp>
#include <iostream>
#include <sstream>
+#include <vector>
namespace po = boost::program_options;
using namespace uhd;
@@ -44,7 +45,7 @@ static std::string make_border(const std::string &text){
std::stringstream ss;
ss << boost::format(" _____________________________________________________") << std::endl;
ss << boost::format(" /") << std::endl;
- std::vector<std::string> lines = std::split_string(text, "\n");
+ std::vector<std::string> lines; boost::split(lines, text, boost::is_any_of("\n"));
while (lines.back() == "") lines.pop_back(); //strip trailing newlines
if (lines.size()) lines[0] = " " + lines[0]; //indent the title line
BOOST_FOREACH(const std::string &line, lines){
diff --git a/host/utils/usrp-e-debug-pins.c b/host/utils/usrp-e-debug-pins.c
index 1ed2c8983..94f898b67 100644
--- a/host/utils/usrp-e-debug-pins.c
+++ b/host/utils/usrp-e-debug-pins.c
@@ -7,7 +7,7 @@
#include <sys/ioctl.h>
#include <linux/usrp_e.h>
-#include "usrp_e_regs.hpp"
+#include "usrp_e100_regs.hpp"
// Usage: usrp_e_gpio <string>
@@ -42,6 +42,7 @@ int main(int argc, char *argv[])
test = 0;
if (argc < 2) {
printf("%s 0|1|off\n", argv[0]);
+ return -1;
}
fp = open("/dev/usrp_e0", O_RDWR);
diff --git a/host/utils/usrp_e_regs.hpp b/host/utils/usrp_e_regs.hpp
deleted file mode 100644
index a4f42093e..000000000
--- a/host/utils/usrp_e_regs.hpp
+++ /dev/null
@@ -1,196 +0,0 @@
-
-
-////////////////////////////////////////////////////////////////
-//
-// Memory map for embedded wishbone bus
-//
-////////////////////////////////////////////////////////////////
-
-// All addresses are byte addresses. All accesses are word (16-bit) accesses.
-// This means that address bit 0 is usually 0.
-// There are 11 bits of address for the control.
-
-#ifndef __USRP_E_REGS_H
-#define __USRP_E_REGS_H
-
-/////////////////////////////////////////////////////
-// Slave pointers
-
-#define UE_REG_SLAVE(n) ((n)<<7)
-#define UE_REG_SR_ADDR(n) ((UE_REG_SLAVE(5)) + (4*(n)))
-
-/////////////////////////////////////////////////////
-// Slave 0 -- Misc Regs
-
-#define UE_REG_MISC_BASE UE_REG_SLAVE(0)
-
-#define UE_REG_MISC_LED UE_REG_MISC_BASE + 0
-#define UE_REG_MISC_SW UE_REG_MISC_BASE + 2
-#define UE_REG_MISC_CGEN_CTRL UE_REG_MISC_BASE + 4
-#define UE_REG_MISC_CGEN_ST UE_REG_MISC_BASE + 6
-#define UE_REG_MISC_TEST UE_REG_MISC_BASE + 8
-#define UE_REG_MISC_RX_LEN UE_REG_MISC_BASE + 10
-#define UE_REG_MISC_TX_LEN UE_REG_MISC_BASE + 12
-
-/////////////////////////////////////////////////////
-// Slave 1 -- UART
-// CLKDIV is 16 bits, others are only 8
-
-#define UE_REG_UART_BASE UE_REG_SLAVE(1)
-
-#define UE_REG_UART_CLKDIV UE_REG_UART_BASE + 0
-#define UE_REG_UART_TXLEVEL UE_REG_UART_BASE + 2
-#define UE_REG_UART_RXLEVEL UE_REG_UART_BASE + 4
-#define UE_REG_UART_TXCHAR UE_REG_UART_BASE + 6
-#define UE_REG_UART_RXCHAR UE_REG_UART_BASE + 8
-
-/////////////////////////////////////////////////////
-// Slave 2 -- SPI Core
-// This should be accessed through the IOCTL
-// Users should not touch directly
-
-#define UE_REG_SPI_BASE UE_REG_SLAVE(2)
-
-//spi slave constants
-#define UE_SPI_SS_AD9522 (1 << 3)
-#define UE_SPI_SS_AD9862 (1 << 2)
-#define UE_SPI_SS_TX_DB (1 << 1)
-#define UE_SPI_SS_RX_DB (1 << 0)
-
-////////////////////////////////////////////////
-// Slave 3 -- I2C Core
-// This should be accessed through the IOCTL
-// Users should not touch directly
-
-#define UE_REG_I2C_BASE UE_REG_SLAVE(3)
-
-
-////////////////////////////////////////////////
-// Slave 4 -- GPIO
-
-#define UE_REG_GPIO_BASE UE_REG_SLAVE(4)
-
-#define UE_REG_GPIO_RX_IO UE_REG_GPIO_BASE + 0
-#define UE_REG_GPIO_TX_IO UE_REG_GPIO_BASE + 2
-#define UE_REG_GPIO_RX_DDR UE_REG_GPIO_BASE + 4
-#define UE_REG_GPIO_TX_DDR UE_REG_GPIO_BASE + 6
-#define UE_REG_GPIO_RX_SEL UE_REG_GPIO_BASE + 8
-#define UE_REG_GPIO_TX_SEL UE_REG_GPIO_BASE + 10
-#define UE_REG_GPIO_RX_DBG UE_REG_GPIO_BASE + 12
-#define UE_REG_GPIO_TX_DBG UE_REG_GPIO_BASE + 14
-
-//possible bit values for sel when dbg is 0:
-#define GPIO_SEL_SW 0 // if pin is an output, set by software in the io reg
-#define GPIO_SEL_ATR 1 // if pin is an output, set by ATR logic
-
-//possible bit values for sel when dbg is 1:
-#define GPIO_SEL_DEBUG_0 0 // if pin is an output, debug lines from FPGA fabric
-#define GPIO_SEL_DEBUG_1 1 // if pin is an output, debug lines from FPGA fabric
-
-
-////////////////////////////////////////////////////
-// Slave 5 -- Settings Bus
-//
-// Output-only, no readback, 32 registers total
-// Each register must be written 32 bits at a time
-// First the address xxx_xx00 and then xxx_xx10
-
-#define UE_REG_SETTINGS_BASE UE_REG_SLAVE(5)
-
-///////////////////////////////////////////////////
-// Slave 6 -- ATR Controller
-// 16 regs
-
-#define UE_REG_ATR_BASE UE_REG_SLAVE(6)
-
-#define UE_REG_ATR_IDLE_RXSIDE UE_REG_ATR_BASE + 0
-#define UE_REG_ATR_IDLE_TXSIDE UE_REG_ATR_BASE + 2
-#define UE_REG_ATR_INTX_RXSIDE UE_REG_ATR_BASE + 4
-#define UE_REG_ATR_INTX_TXSIDE UE_REG_ATR_BASE + 6
-#define UE_REG_ATR_INRX_RXSIDE UE_REG_ATR_BASE + 8
-#define UE_REG_ATR_INRX_TXSIDE UE_REG_ATR_BASE + 10
-#define UE_REG_ATR_FULL_RXSIDE UE_REG_ATR_BASE + 12
-#define UE_REG_ATR_FULL_TXSIDE UE_REG_ATR_BASE + 14
-
-/////////////////////////////////////////////////
-// DSP RX Regs
-////////////////////////////////////////////////
-#define UE_REG_DSP_RX_FREQ UE_REG_SR_ADDR(0)
-#define UE_REG_DSP_RX_SCALE_IQ UE_REG_SR_ADDR(1) // {scale_i,scale_q}
-#define UE_REG_DSP_RX_DECIM_RATE UE_REG_SR_ADDR(2) // hb and decim rate
-#define UE_REG_DSP_RX_DCOFFSET_I UE_REG_SR_ADDR(3) // Bit 31 high sets fixed offset mode, using lower 14 bits, // otherwise it is automatic
-#define UE_REG_DSP_RX_DCOFFSET_Q UE_REG_SR_ADDR(4) // Bit 31 high sets fixed offset mode, using lower 14 bits
-#define UE_REG_DSP_RX_MUX UE_REG_SR_ADDR(5)
-
-///////////////////////////////////////////////////
-// VITA RX CTRL regs
-///////////////////////////////////////////////////
-// The following 3 are logically a single command register.
-// They are clocked into the underlying fifo when time_ticks is written.
-#define UE_REG_CTRL_RX_STREAM_CMD UE_REG_SR_ADDR(8) // {now, chain, num_samples(30)
-#define UE_REG_CTRL_RX_TIME_SECS UE_REG_SR_ADDR(9)
-#define UE_REG_CTRL_RX_TIME_TICKS UE_REG_SR_ADDR(10)
-#define UE_REG_CTRL_RX_CLEAR_OVERRUN UE_REG_SR_ADDR(11) // write anything to clear overrun
-#define UE_REG_CTRL_RX_VRT_HEADER UE_REG_SR_ADDR(12) // word 0 of packet. FPGA fills in packet counter
-#define UE_REG_CTRL_RX_VRT_STREAM_ID UE_REG_SR_ADDR(13) // word 1 of packet.
-#define UE_REG_CTRL_RX_VRT_TRAILER UE_REG_SR_ADDR(14)
-#define UE_REG_CTRL_RX_NSAMPS_PER_PKT UE_REG_SR_ADDR(15)
-#define UE_REG_CTRL_RX_NCHANNELS UE_REG_SR_ADDR(16) // 1 in basic case, up to 4 for vector sources
-
-/////////////////////////////////////////////////
-// DSP TX Regs
-////////////////////////////////////////////////
-#define UE_REG_DSP_TX_FREQ UE_REG_SR_ADDR(17)
-#define UE_REG_DSP_TX_SCALE_IQ UE_REG_SR_ADDR(18) // {scale_i,scale_q}
-#define UE_REG_DSP_TX_INTERP_RATE UE_REG_SR_ADDR(19)
-#define UE_REG_DSP_TX_UNUSED UE_REG_SR_ADDR(20)
-#define UE_REG_DSP_TX_MUX UE_REG_SR_ADDR(21)
-
-/////////////////////////////////////////////////
-// VITA TX CTRL regs
-////////////////////////////////////////////////
-#define UE_REG_CTRL_TX_NCHANNELS UE_REG_SR_ADDR(24)
-#define UE_REG_CTRL_TX_CLEAR_UNDERRUN UE_REG_SR_ADDR(25)
-#define UE_REG_CTRL_TX_REPORT_SID UE_REG_SR_ADDR(26)
-#define UE_REG_CTRL_TX_POLICY UE_REG_SR_ADDR(27)
-
-#define UE_FLAG_CTRL_TX_POLICY_WAIT (0x1 << 0)
-#define UE_FLAG_CTRL_TX_POLICY_NEXT_PACKET (0x1 << 1)
-#define UE_FLAG_CTRL_TX_POLICY_NEXT_BURST (0x1 << 2)
-
-/////////////////////////////////////////////////
-// VITA49 64 bit time (write only)
-////////////////////////////////////////////////
- /*!
- * \brief Time 64 flags
- *
- * <pre>
- *
- * 3 2 1
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +-----------------------------------------------------------+-+-+
- * | |S|P|
- * +-----------------------------------------------------------+-+-+
- *
- * P - PPS edge selection (0=negedge, 1=posedge, default=0)
- * S - Source (0=sma, 1=mimo, 0=default)
- *
- * </pre>
- */
-#define UE_REG_TIME64_SECS UE_REG_SR_ADDR(28) // value to set absolute secs to on next PPS
-#define UE_REG_TIME64_TICKS UE_REG_SR_ADDR(29) // value to set absolute ticks to on next PPS
-#define UE_REG_TIME64_FLAGS UE_REG_SR_ADDR(30) // flags - see chart above
-#define UE_REG_TIME64_IMM UE_REG_SR_ADDR(31) // set immediate (0=latch on next pps, 1=latch immediate, default=0)
-#define UE_REG_TIME64_TPS UE_REG_SR_ADDR(31) // clock ticks per second (counter rollover)
-
-//pps flags (see above)
-#define UE_FLAG_TIME64_PPS_NEGEDGE (0 << 0)
-#define UE_FLAG_TIME64_PPS_POSEDGE (1 << 0)
-#define UE_FLAG_TIME64_PPS_SMA (0 << 1)
-#define UE_FLAG_TIME64_PPS_MIMO (1 << 1)
-
-#define UE_FLAG_TIME64_LATCH_NOW 1
-#define UE_FLAG_TIME64_LATCH_NEXT_PPS 0
-
-#endif
-
diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt
index ee8146f3a..705153baf 100644
--- a/images/CMakeLists.txt
+++ b/images/CMakeLists.txt
@@ -32,6 +32,7 @@ SET(CPACK_PACKAGE_CONTACT "support@ettus.com")
SET(CPACK_PACKAGE_VERSION_MAJOR ${UHD_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${UHD_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${UHD_VERSION_PATCH})
+SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")
INCLUDE(CPack) #include after setting vars
MESSAGE(STATUS "Version: ${CPACK_PACKAGE_VERSION}")
diff --git a/images/Makefile b/images/Makefile
index 27390427d..34c18cdc2 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -30,6 +30,12 @@ CMAKE_BUILD_DIR = $(TOP_DIR)/build
##filled in below
IMAGES_LIST =
+##little rule to make the images directory
+$(BUILT_IMAGES_DIR):
+ mkdir $@
+
+GLOBAL_DEPS = $(BUILT_IMAGES_DIR)
+
########################################################################
# Utility Checks
########################################################################
@@ -37,8 +43,8 @@ ifeq ($(shell sdcc --help > /dev/null 2>&1 && echo $$?),0)
HAS_SDCC=1
endif
-ifeq ($(shell mb-gcc --help > /dev/null 2>&1 && echo $$?),0)
- HAS_MB_GCC=1
+ifeq ($(shell zpu-elf-gcc --help > /dev/null 2>&1 && echo $$?),0)
+ HAS_ZPU_GCC=1
endif
ifeq ($(shell xtclsh -h > /dev/null 2>&1 && echo $$?),0)
@@ -54,7 +60,7 @@ _usrp1_fw_dir = $(TOP_FW_DIR)/fx2
_usrp1_fw_ihx = $(BUILT_IMAGES_DIR)/usrp1_fw.ihx
IMAGES_LIST += $(_usrp1_fw_ihx)
-$(_usrp1_fw_ihx):
+$(_usrp1_fw_ihx): $(GLOBAL_DEPS)
cd $(_usrp1_fw_dir) && rm -rf build
cd $(_usrp1_fw_dir) && mkdir build
cd $(_usrp1_fw_dir)/build && cmake ../
@@ -71,29 +77,29 @@ _usrp1_fpga_rbf = $(BUILT_IMAGES_DIR)/usrp1_fpga.rbf
_usrp1_fpga_4rx_rbf = $(BUILT_IMAGES_DIR)/usrp1_fpga_4rx.rbf
IMAGES_LIST += $(_usrp1_fpga_rbf) $(_usrp1_fpga_4rx_rbf)
-$(_usrp1_fpga_rbf):
+$(_usrp1_fpga_rbf): $(GLOBAL_DEPS)
cp $(_usrp1_fpga_dir)/std_2rxhb_2tx.rbf $@
-$(_usrp1_fpga_4rx_rbf):
+$(_usrp1_fpga_4rx_rbf): $(GLOBAL_DEPS)
cp $(_usrp1_fpga_dir)/std_4rx_0tx.rbf $@
########################################################################
-# USRP2 and USRP-N2XX firmware
+# USRP2 and N Series firmware
########################################################################
-ifdef HAS_MB_GCC
+ifdef HAS_ZPU_GCC
-_usrp2_fw_dir = $(TOP_FW_DIR)/microblaze
+_usrp2_fw_dir = $(TOP_FW_DIR)/zpu
_usrp2_fw_bin = $(BUILT_IMAGES_DIR)/usrp2_fw.bin
_usrp_n2xx_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n2xx_fw.bin
IMAGES_LIST += $(_usrp2_fw_bin)
-$(_usrp2_fw_bin) $(_usrp_n2xx_fw_bin):
- cd $(_usrp2_fw_dir) && ./bootstrap
- cd $(_usrp2_fw_dir) && ./configure --host=mb
- make -C $(_usrp2_fw_dir) clean
- make -C $(_usrp2_fw_dir) all
- cp $(_usrp2_fw_dir)/usrp2/usrp2_txrx_uhd.bin $(_usrp2_fw_bin)
- cp $(_usrp2_fw_dir)/usrp2p/usrp2p_txrx_uhd.bin $(_usrp_n2xx_fw_bin)
+$(_usrp2_fw_bin) $(_usrp_n2xx_fw_bin): $(GLOBAL_DEPS)
+ cd $(_usrp2_fw_dir) && rm -rf build
+ cd $(_usrp2_fw_dir) && mkdir build
+ cd $(_usrp2_fw_dir)/build && cmake ../
+ cd $(_usrp2_fw_dir)/build && make
+ cp $(_usrp2_fw_dir)/build/usrp2/usrp2_txrx_uhd.bin $(_usrp2_fw_bin)
+ cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $(_usrp_n2xx_fw_bin)
endif
@@ -106,7 +112,7 @@ _usrp2_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/u2_rev3
_usrp2_fpga_bin = $(BUILT_IMAGES_DIR)/usrp2_fpga.bin
IMAGES_LIST += $(_usrp2_fpga_bin)
-$(_usrp2_fpga_bin):
+$(_usrp2_fpga_bin): $(GLOBAL_DEPS)
cd $(_usrp2_fpga_dir) && make clean
cd $(_usrp2_fpga_dir) && make bin
cp $(_usrp2_fpga_dir)/build/u2_rev3.bin $@
@@ -122,7 +128,7 @@ _usrp_n210_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/u2plus
_usrp_n210_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n210_fpga.bin
IMAGES_LIST += $(_usrp_n210_fpga_bin)
-$(_usrp_n210_fpga_bin):
+$(_usrp_n210_fpga_bin): $(GLOBAL_DEPS)
cd $(_usrp_n210_fpga_dir) && make clean
cd $(_usrp_n210_fpga_dir) && make bin
cp $(_usrp_n210_fpga_dir)/build/u2plus.bin $@
@@ -138,7 +144,7 @@ _usrp_e100_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/u1e
_usrp_e100_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_e100_fpga.bin
IMAGES_LIST += $(_usrp_e100_fpga_bin)
-$(_usrp_e100_fpga_bin):
+$(_usrp_e100_fpga_bin): $(GLOBAL_DEPS)
cd $(_usrp_e100_fpga_dir) && make clean
cd $(_usrp_e100_fpga_dir) && make bin
cp $(_usrp_e100_fpga_dir)/build/u1e.bin $@
@@ -148,11 +154,7 @@ endif
########################################################################
# Build rules
########################################################################
-##little rule to make the images directory
-$(BUILT_IMAGES_DIR):
- mkdir $@
-
-images: $(BUILT_IMAGES_DIR) $(IMAGES_LIST)
+images: $(IMAGES_LIST)
chmod -x $(BUILT_IMAGES_DIR)/*
clean: