Skip to content

Commit

Permalink
Merge pull request #2 from denizkasap/OBI_virtualization
Browse files Browse the repository at this point in the history
OBI Virtualization.
  • Loading branch information
simone-machetti authored Jan 9, 2024
2 parents b50b6a1 + 7c256d3 commit 9fba7d2
Show file tree
Hide file tree
Showing 11 changed files with 2,669 additions and 395 deletions.
5 changes: 5 additions & 0 deletions hw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# X-HEEP hardware reference

https://github.com/esl-epfl/x-heep-femu

d7b7341d2be860289760541477f1009ade953a49
Binary file modified hw/x_heep.bit
100755 → 100644
Binary file not shown.
2,633 changes: 2,240 additions & 393 deletions hw/x_heep.hwh
100755 → 100644

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions sw/arm/apps/virtual_obi_read/virtual_obi_read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 EPFL
# Solderpad Hardware License, Version 2.1, see LICENSE.md for details.
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
#
# Author: Simone Machetti - [email protected]

# Import the X-HEEP Python class
from pynq import x_heep

# Load the X-HEEP bitstream
x_heep = x_heep()

# Compile the application
x_heep.compile_app("virtual_obi_read")

# Init the OBI memory
obi = x_heep.init_obi_mem()

# Reset the OBI memory
x_heep.reset_obi_mem(obi)

# Write to the OBI memory
write_list = list()
for i in range(1024):
write_list.append(i ** 2)
x_heep.write_obi_mem(write_list, obi)

# Run the application
x_heep.run_app()

# Delete OBI
del obi
34 changes: 34 additions & 0 deletions sw/arm/apps/virtual_obi_write/virtual_obi_write.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 EPFL
# Solderpad Hardware License, Version 2.1, see LICENSE.md for details.
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
#
# Author: Simone Machetti - [email protected]

# Import the X-HEEP Python class
from pynq import x_heep

# Load the X-HEEP bitstream
x_heep = x_heep()

# Compile the application
x_heep.compile_app("virtual_obi_write")

# Init the OBI memory
obi = x_heep.init_obi_mem()

# Reset the OBI memory
x_heep.reset_obi_mem(obi)

# Run the application
x_heep.run_app()

# Read the OBI memory
obi_read = x_heep.read_obi_mem(obi)
target_read = list()
for i in range(1024):
target_read.append(i ** 2)
if target_read == obi_read:
print("Write operation successful.")

# Delete OBI
del obi
116 changes: 116 additions & 0 deletions sw/arm/jupyter_notebooks/virtual_obi_read.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "63f1eaa7",
"metadata": {},
"outputs": [],
"source": [
"# Import the X-HEEP Python class\n",
"from pynq import x_heep"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2d224b64",
"metadata": {},
"outputs": [],
"source": [
"# Load the X-HEEP bitstream\n",
"x_heep = x_heep()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d6af7d95",
"metadata": {},
"outputs": [],
"source": [
"# Compile the application\n",
"x_heep.compile_app(\"virtual_obi_read\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "75a905c1",
"metadata": {},
"outputs": [],
"source": [
"# Init the OBI memory\n",
"obi = x_heep.init_obi_mem()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "00c60248",
"metadata": {},
"outputs": [],
"source": [
"# Reset the OBI memory\n",
"x_heep.reset_obi_mem(obi)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "35615647",
"metadata": {},
"outputs": [],
"source": [
"# Write to the OBI memory\n",
"write_list = list()\n",
"for i in range(1024):\n",
" write_list.append(i ** 2)\n",
"x_heep.write_obi_mem(write_list, obi)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4b82dd7",
"metadata": {},
"outputs": [],
"source": [
"# Run the application\n",
"x_heep.run_app()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "84f8d8c9",
"metadata": {},
"outputs": [],
"source": [
"# Delete OBI\n",
"del obi"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
118 changes: 118 additions & 0 deletions sw/arm/jupyter_notebooks/virtual_obi_write.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "63f1eaa7",
"metadata": {},
"outputs": [],
"source": [
"# Import the X-HEEP Python class\n",
"from pynq import x_heep"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2d224b64",
"metadata": {},
"outputs": [],
"source": [
"# Load the X-HEEP bitstream\n",
"x_heep = x_heep()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d6af7d95",
"metadata": {},
"outputs": [],
"source": [
"# Compile the application\n",
"x_heep.compile_app(\"virtual_obi_write\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "75a905c1",
"metadata": {},
"outputs": [],
"source": [
"# Init the OBI memory\n",
"obi = x_heep.init_obi_mem()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "35615647",
"metadata": {},
"outputs": [],
"source": [
"# Reset the OBI memory\n",
"x_heep.reset_obi_mem(obi)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fd8e74c7",
"metadata": {},
"outputs": [],
"source": [
"# Run the application\n",
"x_heep.run_app()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b9065ea6",
"metadata": {},
"outputs": [],
"source": [
"# Read the OBI memory\n",
"obi_read = x_heep.read_obi_mem(obi)\n",
"target_read = list()\n",
"for i in range(1024):\n",
" target_read.append(i ** 2)\n",
"if target_read == obi_read:\n",
" print(\"Write operation successful.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e507c63",
"metadata": {},
"outputs": [],
"source": [
"# Delete OBI\n",
"del obi"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
38 changes: 36 additions & 2 deletions sw/arm/sdk/x_heep_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

ADC_OFFSET = 0x40000000
FLASH_AXI_ADDRESS_ADDER_OFFSET = 0x43C00000
PERFORMANCE_COUNTERS_OFFSET = 0x43C10000
OBI_AXI_ADDRESS_ADDER_OFFSET = 0x43C10000
PERFORMANCE_COUNTERS_OFFSET = 0x43C20000

class x_heep(Overlay):

def __init__(self, **kwargs):
def __init__(self, ILA_debug = False, **kwargs):

# Load bitstream
super().__init__("/home/xilinx/x-heep-femu-sdk/hw/x_heep.bit", **kwargs)
Expand Down Expand Up @@ -127,6 +128,39 @@ def read_adc_mem(self, adc_mem):
file.close()


def init_obi_mem(self):

# Allocate OBI memory
obi = allocate(shape=(1024,))

# Write OBI memory base address to AXI address adder
axi_address_adder = MMIO(OBI_AXI_ADDRESS_ADDER_OFFSET, 0x4)
axi_address_adder.write(0x0, obi.physical_address)

# Reset OBI memory
obi[:] = 0

return obi


def reset_obi_mem(self, obi):

# Reset OBI memory
obi[:] = 0


def write_obi_mem(self, write_list, obi):

# Write OBI memory
obi[:] = write_list


def read_obi_mem(self, obi):

# Read OBI memory
return list(obi)


def init_perf_cnt(self):

# Map performance counters
Expand Down
Loading

0 comments on commit 9fba7d2

Please sign in to comment.