Skip to content
Snippets Groups Projects
Commit 42aa247b authored by paulrr2's avatar paulrr2
Browse files

Update Babel Test.ipynb

parent 5ef5ed7a
Branches master
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
from pynq import Overlay
from pynq import DefaultHierarchy
import pynq.lib.dma
from pynq import allocate
import numpy as np
from kamene.all import *
```
%% Cell type:code id: tags:
``` python
overlay=BabelOverlay('babel_overlay_test.bit')
overlay=Overlay('babel_overlay_test.bit')
```
%% Cell type:code id: tags:
``` python
overlay.ip_dict.keys()
```
%% Output
dict_keys(['UDP/udp_meta', 'UDP/udp_data', 'network_stack/ethernet_dma', 'axi_dma_0', 'UDP/udp_stack/ipv4_0', 'UDP/udp_stack/udp_0', 'network_stack/arp_server_subnet_0', 'network_stack/ip_handler_0', 'network_stack/mac_ip_encode_0', 'processing_system7_0'])
%% Cell type:code id: tags:
``` python
overlay.download()
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
udp_meta = overlay.UDP.udp_meta
udp_data = overlay.UDP.udp_data
ethernet = overlay.network_stack.ethernet_dma
overlay.UDP.udp_stack.ipv4_0.local_ipv4_address_V = 0xDEADBEEF
overlay.UDP.udp_stack.protocol_V = 0x11
overlay.UDP.udp_stack.udp_0.reg_ip_address_V_1 = 0xDEADBEEF
overlay.UDP.udp_stack.udp_0.reg_ip_address_V_2 = 0xDEADBEEF
overlay.UDP.udp_stack.udp_0.reg_ip_address_V_3 = 0xDEADBEEF
overlay.UDP.udp_stack.udp_0.reg_ip_address_V_4 = 0xDEADBEEF
overlay.UDP.udp_stack.udp_0.reg_listen_port_V = 54001
overlay.network_stack.arp_server_subnet_0.myMacAddress_V_1 = 0xEEEEEEEE
overlay.network_stack.arp_server_subnet_0.myMacAddress_V_2 = 0xEEEEEEEE
overlay.network_stack.arp_server_subnet_0.myIpAddress_V = 0xDEADBEEF
overlay.network_stack.ip_handler_0.myIpAddress_V = 0xDEADBEEF
overlay.network_stack.mac_ip_encode_0.myMacAddress_V_1 = 0xEEEEEEEE
overlay.network_stack.mac_ip_encode_0.myMacAddress_V_2 = 0xEEEEEEEE
overlay.network_stack.mac_ip_encode_0.regSubNetMask_V= 0x00FFFFFF
overlay.network_stack.mac_ip_encode_0.regDefaultGateway_V= 0xDEADBEEF
```
%% Cell type:code id: tags:
``` python
udp_data_buffer_out = allocate(shape=(1), dtype=np.uint64)
udp_metadata_buffer_out = allocate(shape=(32), dtype=np.uint8)
udp_data_buffer_in = allocate(shape=(1), dtype=np.uint64)
udp_metadata_buffer_in = allocate(shape=(4), dtype=np.uint64)
raw_packet_in = allocate(shape=(128), dtype=np.uint8)
raw_packet_out = allocate(shape=(128), dtype=np.uint8)
```
%% Cell type:code id: tags:
``` python
udp_data_buffer_out[0] = 0xDEADBEEFDEADBEEF
for i in range(32):
udp_metadata_buffer_out[i] = 0xac
```
%% Cell type:code id: tags:
``` python
udp_meta.recvchannel.start()
udp_meta.sendchannel.start()
udp_data.recvchannel.start()
udp_data.sendchannel.start()
ethernet.recvchannel.start()
ethernet.sendchannel.start()
```
%% Cell type:code id: tags:
``` python
udp_meta.sendchannel.transfer(udp_metadata_buffer_out)
udp_data.sendchannel.transfer(udp_data_buffer_out)
udp_meta.sendchannel.wait()
udp_data.sendchannel.wait()
```
%% Cell type:code id: tags:
``` python
ethernet.recvchannel.transfer(raw_packet_in)
ethernet.recvchannel.wait()
```
%% Cell type:code id: tags:
``` python
for item in raw_packet_in:
print('{:02x}'.format(item), end=" ")
```
%% Output
ff ff ff ff ff ff 00 00 00 00 00 00 08 06 00 01 08 00 06 04 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
%% Cell type:code id: tags:
``` python
packet = Ether(dst='ee:ee:ee:ee:ee:ee')/IP(dst="222.173.190.239")/UDP(dport=54001)
i = 0
for b in bytes(packet):
raw_packet_out[i] = b
i+=1
for item in raw_packet_out:
print('{:02x}'.format(item), end=" ")
ethernet.sendchannel.transfer(raw_packet_out)
udp_meta.recvchannel.transfer(udp_metadata_buffer_in)
udp_data.recvchannel.transfer(udp_data_buffer_in)
ethernet.sendchannel.wait()
udp_meta.recvchannel.wait()
udp_data.recvchannel.wait()
```
%% Output
ee ee ee ee ee ee 00 05 6b 01 1a cb 08 00 45 00 00 1c 00 01 00 00 40 11 1b c2 c0 a8 00 c9 de ad be ef 00 35 d2 f1 00 08 cd a8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-97-2db318aa1f6d> in <module>()
10 udp_data.recvchannel.transfer(udp_data_buffer_in)
11 ethernet.sendchannel.wait()
---> 12 udp_meta.recvchannel.wait()
13 udp_data.recvchannel.wait()
/usr/local/lib/python3.6/dist-packages/pynq/lib/dma.py in wait(self)
206 while True:
207 error = self._mmio.read(self._offset + 4)
--> 208 if self.error:
209 if error & 0x10:
210 raise RuntimeError(
/usr/local/lib/python3.6/dist-packages/pynq/lib/dma.py in error(self)
115 """True if DMA engine is in an error state
116 """
--> 117 return self._mmio.read(self._offset + 4) & 0x70 != 0x0
118
119 def start(self):
/usr/local/lib/python3.6/dist-packages/pynq/mmio.py in read(self, offset, length, word_order)
146
147 # Read data out
--> 148 lsb = int(self.array[idx])
149 if length == 8:
150 if word_order == 'little':
KeyboardInterrupt:
%% Cell type:code id: tags:
``` python
for item in udp_data_buffer_in:
print('{:x}'.format(item), end=" ")
for item in udp_metadata_buffer_in:
print('{:x}'.format(item), end=" ")
```
%% Output
0 0 0 0 0
%% Cell type:code id: tags:
``` python
udp_meta.recvchannel.stop()
udp_meta.sendchannel.stop()
udp_data.recvchannel.stop()
udp_data.sendchannel.stop()
ethernet.recvchannel.stop()
ethernet.sendchannel.stop()
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment