diff --git a/hw/README.md b/hw/README.md new file mode 100644 index 0000000..31b1115 --- /dev/null +++ b/hw/README.md @@ -0,0 +1,5 @@ +# X-HEEP hardware reference + +https://github.com/esl-epfl/x-heep-femu + +d7b7341d2be860289760541477f1009ade953a49 diff --git a/hw/x_heep.bit b/hw/x_heep.bit old mode 100755 new mode 100644 index a619f32..31552a3 Binary files a/hw/x_heep.bit and b/hw/x_heep.bit differ diff --git a/hw/x_heep.hwh b/hw/x_heep.hwh old mode 100755 new mode 100644 index 674bbb4..49f4ec7 --- a/hw/x_heep.hwh +++ b/hw/x_heep.hwh @@ -1,5 +1,5 @@  - + @@ -109,16 +109,6 @@ - - - - - - - - - - @@ -1014,14 +1004,34 @@ - + + + + + + + + + + + - + + + + + + - + - + + + + + + @@ -1071,12 +1081,6 @@ - - - - - - @@ -1103,7 +1107,7 @@ - + @@ -1189,7 +1193,7 @@ - + @@ -1275,7 +1279,7 @@ - + @@ -1361,7 +1365,7 @@ - + @@ -1415,7 +1419,7 @@ - + @@ -1469,7 +1473,7 @@ - + @@ -1500,7 +1504,7 @@ - + @@ -2136,7 +2140,7 @@ - + @@ -2469,44 +2473,44 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2519,14 +2523,14 @@ - + - + - + - + @@ -2559,14 +2563,14 @@ - + - + - + - + @@ -4777,7 +4781,7 @@ - + @@ -4993,12 +4997,6 @@ - - - - - - @@ -5955,12 +5953,12 @@ - + - + - + @@ -6761,21 +6759,14 @@ - - - - - - - - - - - - + - + + + + + @@ -6941,7 +6932,7 @@ - + @@ -7312,17 +7303,10 @@ - - - - - - - - - + + diff --git a/sw/arm/apps/virtual_obi_read/virtual_obi_read.py b/sw/arm/apps/virtual_obi_read/virtual_obi_read.py index f0b9bbb..8f8b294 100644 --- a/sw/arm/apps/virtual_obi_read/virtual_obi_read.py +++ b/sw/arm/apps/virtual_obi_read/virtual_obi_read.py @@ -13,20 +13,17 @@ # Compile the application x_heep.compile_app("virtual_obi_read") -# Init the OBI -obi = x_heep.init_obi() +# Init the OBI memory +obi = x_heep.init_obi_mem() -# Reset the OBI Memory -x_heep.reset_obi(obi) +# Reset the OBI memory +x_heep.reset_obi_mem(obi) -#Write the OBI Memory +# Write to the OBI memory write_list = list() for i in range(1024): write_list.append(i ** 2) -x_heep.write_obi_memory(write_list, obi) - -#Check if OBI memory is as desired -obi_read = x_heep.read_obi(obi) +x_heep.write_obi_mem(write_list, obi) # Run the application x_heep.run_app() diff --git a/sw/arm/apps/virtual_obi_write/virtual_obi_write.py b/sw/arm/apps/virtual_obi_write/virtual_obi_write.py index 0b03b12..861dbf6 100644 --- a/sw/arm/apps/virtual_obi_write/virtual_obi_write.py +++ b/sw/arm/apps/virtual_obi_write/virtual_obi_write.py @@ -13,26 +13,22 @@ # Compile the application x_heep.compile_app("virtual_obi_write") -# Init the OBI -obi = x_heep.init_obi() +# Init the OBI memory +obi = x_heep.init_obi_mem() -# Reset the OBI Memory -x_heep.reset_obi(obi) - -#Check if OBI memory is resetted -obi_read = x_heep.read_obi(obi) +# Reset the OBI memory +x_heep.reset_obi_mem(obi) # Run the application x_heep.run_app() -#Compare application output -obi_read = x_heep.read_obi(obi) +# 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) -#print(target_read) if target_read == obi_read: - print("Arrays matching! Write from RISCV Successful.") + print("Write operation successful.") # Delete OBI del obi diff --git a/sw/arm/jupyter_notebooks/hello_world.ipynb b/sw/arm/jupyter_notebooks/hello_world.ipynb index 5ee85e4..f4861de 100755 --- a/sw/arm/jupyter_notebooks/hello_world.ipynb +++ b/sw/arm/jupyter_notebooks/hello_world.ipynb @@ -43,14 +43,6 @@ "# Run the application\n", "x_heep.run_app()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1fefd8b2", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/sw/arm/jupyter_notebooks/virtual_flash_read.ipynb b/sw/arm/jupyter_notebooks/virtual_flash_read.ipynb index 8c11618..cb87ff8 100755 --- a/sw/arm/jupyter_notebooks/virtual_flash_read.ipynb +++ b/sw/arm/jupyter_notebooks/virtual_flash_read.ipynb @@ -99,14 +99,6 @@ "# Delete flash\n", "del flash" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dcdc39b0", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/sw/arm/jupyter_notebooks/virtual_flash_write.ipynb b/sw/arm/jupyter_notebooks/virtual_flash_write.ipynb index 792ae2b..107b626 100755 --- a/sw/arm/jupyter_notebooks/virtual_flash_write.ipynb +++ b/sw/arm/jupyter_notebooks/virtual_flash_write.ipynb @@ -101,14 +101,6 @@ "# Delete flash\n", "del flash" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5d639370", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/sw/arm/jupyter_notebooks/virtual_obi_read.ipynb b/sw/arm/jupyter_notebooks/virtual_obi_read.ipynb index a99b21d..887ef45 100755 --- a/sw/arm/jupyter_notebooks/virtual_obi_read.ipynb +++ b/sw/arm/jupyter_notebooks/virtual_obi_read.ipynb @@ -40,8 +40,8 @@ "metadata": {}, "outputs": [], "source": [ - "#Initialize the OBI\n", - "obi = x_heep.init_obi()" + "# Init the OBI memory\n", + "obi = x_heep.init_obi_mem()" ] }, { @@ -51,8 +51,8 @@ "metadata": {}, "outputs": [], "source": [ - "#Reset the OBI\n", - "x_heep.reset_obi(obi)" + "# Reset the OBI memory\n", + "x_heep.reset_obi_mem(obi)" ] }, { @@ -62,28 +62,17 @@ "metadata": {}, "outputs": [], "source": [ - "#Write to OBI Memory a custom array\n", + "# 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_memory(write_list, obi)" + "x_heep.write_obi_mem(write_list, obi)" ] }, { "cell_type": "code", "execution_count": null, - "id": "2f6a9c40", - "metadata": {}, - "outputs": [], - "source": [ - "#Check if the memory values are correct\n", - "obi_read = x_heep.read_obi(obi)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fd8e74c7", + "id": "b4b82dd7", "metadata": {}, "outputs": [], "source": [ @@ -101,14 +90,6 @@ "# Delete OBI\n", "del obi" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "19eca63d", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/sw/arm/jupyter_notebooks/virtual_obi_write.ipynb b/sw/arm/jupyter_notebooks/virtual_obi_write.ipynb index 3573fcd..ab527d6 100755 --- a/sw/arm/jupyter_notebooks/virtual_obi_write.ipynb +++ b/sw/arm/jupyter_notebooks/virtual_obi_write.ipynb @@ -40,8 +40,8 @@ "metadata": {}, "outputs": [], "source": [ - "#Initialize the OBI\n", - "obi = x_heep.init_obi()" + "# Init the OBI memory\n", + "obi = x_heep.init_obi_mem()" ] }, { @@ -51,19 +51,8 @@ "metadata": {}, "outputs": [], "source": [ - "#Reset the OBI\n", - "x_heep.reset_obi(obi)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2f6a9c40", - "metadata": {}, - "outputs": [], - "source": [ - "#Check if the memory is resetted to zeros\n", - "obi_read = x_heep.read_obi(obi)" + "# Reset the OBI memory\n", + "x_heep.reset_obi_mem(obi)" ] }, { @@ -84,14 +73,13 @@ "metadata": {}, "outputs": [], "source": [ - "#Read the memory and compare with what is expected\n", - "obi_read = x_heep.read_obi(obi)\n", + "# 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", - "#print(target_read)\n", "if target_read == obi_read:\n", - " print(\"Arrays matching! Write from RISCV Successful.\")" + " print(\"Write operation successful.\")" ] }, { @@ -104,14 +92,6 @@ "# Delete OBI\n", "del obi" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c514a7ec", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/sw/arm/sdk/x_heep_api.py b/sw/arm/sdk/x_heep_api.py index 95ece91..068728b 100755 --- a/sw/arm/sdk/x_heep_api.py +++ b/sw/arm/sdk/x_heep_api.py @@ -12,23 +12,16 @@ import csv ADC_OFFSET = 0x40000000 -FLASH_AXI_ADDRESS_ADDER_OFFSET = 0x43c00000 -#PERFORMANCE_COUNTERS_OFFSET = 0x43C10000 -OBI_AXI_ADDRESS_ADDER_OFFSET = 0x43c10000 -PERFORMANCE_COUNTERS_OFFSET = 0x43c20000 +FLASH_AXI_ADDRESS_ADDER_OFFSET = 0x43C00000 +OBI_AXI_ADDRESS_ADDER_OFFSET = 0x43C10000 +PERFORMANCE_COUNTERS_OFFSET = 0x43C20000 class x_heep(Overlay): def __init__(self, ILA_debug = False, **kwargs): # Load bitstream - if not ILA_debug: - super().__init__("/home/xilinx/x-heep-femu-sdk/hw/x_heep.bit", **kwargs) - else: - """ - When debugging with ILA, you first need to program the FPGA with base.bit, then program it again from the Vivado with the desired bitstream file. For this, set ILA_debug = True when debugging and initializing the x_heep class in Python. - """ - super().__init__("base.bit", **kwargs) + super().__init__("/home/xilinx/x-heep-femu-sdk/hw/x_heep.bit", **kwargs) def load_bitstream(self): @@ -70,24 +63,6 @@ def init_flash(self): flash[:] = 0 return flash - - def init_obi(self): - - # Allocate OBI Memory - obi = allocate(shape=(1024,)) #32768 -> old value - - # Write Flash base address to AXI address adder - axi_address_adder = MMIO(OBI_AXI_ADDRESS_ADDER_OFFSET, 0x4) - axi_address_adder.write(0x0, obi.physical_address) - - #Test: Check if the value written and read from the register is the same or not. - #result = axi_address_adder.read(0x0) - #print(obi.physical_address == result) - - # Reset Flash - obi[:] = 0 - - return obi def reset_flash(self, flash): @@ -95,11 +70,6 @@ def reset_flash(self, flash): # Reset Flash flash[:] = 0 - def reset_obi(self, obi): - - # Reset OBI - obi[:] = 0 - def write_flash(self, flash): @@ -110,11 +80,6 @@ def write_flash(self, flash): flash[i] = (file_byte[i*4+3] << 24) | (file_byte[i*4+2] << 16) | (file_byte[i*4+1] << 8) | file_byte[i*4]; file.close() - def write_obi_memory(self, write_list, obi): - - #Write to the memory space allocated for OBI applications a test case - obi[:] = write_list - def read_flash(self, flash): @@ -123,11 +88,6 @@ def read_flash(self, flash): byte_array = bytearray(flash) file.write(byte_array) file.close() - - def read_obi(self, obi): - - print(obi) - return list(obi) def init_adc_mem(self): @@ -168,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 diff --git a/sw/riscv/apps/virtual_obi_read/virtual_obi_read.c b/sw/riscv/apps/virtual_obi_read/virtual_obi_read.c index d61bce4..cc67235 100644 --- a/sw/riscv/apps/virtual_obi_read/virtual_obi_read.c +++ b/sw/riscv/apps/virtual_obi_read/virtual_obi_read.c @@ -12,21 +12,20 @@ int main(int argc, char *argv[]) { - printf("Started!\n\r"); - unsigned int* pointer = (unsigned int*)EXT_SLAVE_START_ADDRESS; unsigned int value = *pointer; - + for (int i=0; i < 1024; i++){ value = *pointer; if (value != i * i){ printf("An element does not match!"); - printf("Not Matching!: %d -- %d", value, i*i); - return 1; + printf("Not matching: %d -- %d", value, i*i); + return EXIT_FAILURE; } - pointer++; + pointer++; } - - printf("Read operation successful!"); + + printf("Read operation successful."); + return EXIT_SUCCESS; } diff --git a/sw/riscv/apps/virtual_obi_write/virtual_obi_write.c b/sw/riscv/apps/virtual_obi_write/virtual_obi_write.c index 9b8b1cc..405e0df 100644 --- a/sw/riscv/apps/virtual_obi_write/virtual_obi_write.c +++ b/sw/riscv/apps/virtual_obi_write/virtual_obi_write.c @@ -13,13 +13,13 @@ int main(int argc, char *argv[]) { unsigned int* pointer = (unsigned int*)EXT_SLAVE_START_ADDRESS; - - int i; - - for (i=0; i < 1024; i++){ - *pointer = i*i; //write the squared index to the DDR memory on PS side - pointer++; + + for (int i=0; i < 1024; i++){ + *pointer = i*i; + pointer++; } - + + printf("Done.\n\r"); + return EXIT_SUCCESS; }