From 2dab7b9096ef58b456cb7f5fca373d8f42407fae Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 18 Aug 2017 14:02:02 -0300 Subject: [PATCH 01/54] Cleaned up my fork --- hemps8.5/README.txt => README.txt | 0 .../applications => applications}/MPEG4/ADSP_0.c | 0 .../applications => applications}/MPEG4/AU_0.c | 0 .../applications => applications}/MPEG4/BAB_0.c | 0 .../applications => applications}/MPEG4/IDCT_0.c | 0 .../applications => applications}/MPEG4/MCPU_0.c | 0 .../applications => applications}/MPEG4/MPEG4.cfg | 0 .../applications => applications}/MPEG4/RAST_0.c | 0 .../applications => applications}/MPEG4/RISC_0.c | 0 .../applications => applications}/MPEG4/SDRAM_0.c | 0 .../applications => applications}/MPEG4/SRAM1_0.c | 0 .../applications => applications}/MPEG4/SRAM2_0.c | 0 .../applications => applications}/MPEG4/UPSAMP_0.c | 0 .../applications => applications}/MPEG4/VU_0.c | 0 {hemps8.5/applications => applications}/MWD/BLEND.c | 0 {hemps8.5/applications => applications}/MWD/HS.c | 0 {hemps8.5/applications => applications}/MWD/HVS.c | 0 {hemps8.5/applications => applications}/MWD/IN.c | 0 {hemps8.5/applications => applications}/MWD/JUG1.c | 0 {hemps8.5/applications => applications}/MWD/JUG2.c | 0 {hemps8.5/applications => applications}/MWD/MEM1.c | 0 {hemps8.5/applications => applications}/MWD/MEM2.c | 0 {hemps8.5/applications => applications}/MWD/MEM3.c | 0 {hemps8.5/applications => applications}/MWD/MWD.cfg | 0 {hemps8.5/applications => applications}/MWD/NR.c | 0 {hemps8.5/applications => applications}/MWD/SE.c | 0 {hemps8.5/applications => applications}/MWD/VS.c | 0 .../applications => applications}/VOPD/ACDC_0.c | 0 .../applications => applications}/VOPD/ARM_0.c | 0 .../applications => applications}/VOPD/IDCT2_0.c | 0 .../applications => applications}/VOPD/IQUANT_0.c | 0 .../applications => applications}/VOPD/ISCAN_0.c | 0 .../applications => applications}/VOPD/PAD_0.c | 0 .../applications => applications}/VOPD/RUN_0.c | 0 .../applications => applications}/VOPD/STRIPEM_0.c | 0 .../applications => applications}/VOPD/UPSAMP_0.c | 0 .../applications => applications}/VOPD/VLD_0.c | 0 .../applications => applications}/VOPD/VOPD.cfg | 0 .../applications => applications}/VOPD/VOPME_0.c | 0 .../applications => applications}/VOPD/VOPREC_0.c | 0 {hemps8.5/applications => applications}/aes/aes.cfg | 0 {hemps8.5/applications => applications}/aes/aes.h | 0 .../aes/aes_generator/Aplicacao_AES_para_HeMPS.pdf | Bin .../aes/aes_generator/README.txt | 0 .../aes/aes_generator/aes.cfg | 0 .../aes/aes_generator/aes.h | 0 .../aes/aes_generator/aes.hmp | 0 .../aes/aes_generator/aes_generator.sh | 0 .../aes/aes_generator/aes_master.c | 0 .../aes/aes_generator/aes_master.h | 0 .../aes/aes_generator/aes_sl.c | 0 .../applications => applications}/aes/aes_master.c | 0 .../applications => applications}/aes/aes_master.h | 0 .../applications => applications}/aes/aes_slave1.c | 0 .../applications => applications}/aes/aes_slave2.c | 0 .../applications => applications}/aes/aes_slave3.c | 0 .../applications => applications}/aes/aes_slave4.c | 0 .../applications => applications}/aes/aes_slave5.c | 0 .../applications => applications}/aes/aes_slave6.c | 0 .../applications => applications}/aes/aes_slave7.c | 0 .../applications => applications}/aes/aes_slave8.c | 0 .../applications => applications}/audio_video/FIR.c | 0 .../audio_video/adpcm_dec.c | 0 .../audio_video/audio_video_def.h | 0 .../audio_video/idct.c | 0 .../audio_video/iquant.c | 0 .../audio_video/ivlc.c | 0 .../audio_video/join.c | 0 .../audio_video/split.c | 0 .../audio_video/tcg.yaml | 0 .../dijkstra/dijkstra.cfg | 0 .../dijkstra/dijkstra_0.c | 0 .../dijkstra/dijkstra_1.c | 0 .../dijkstra/dijkstra_2.c | 0 .../dijkstra/dijkstra_3.c | 0 .../dijkstra/dijkstra_4.c | 0 .../dijkstra/divider.c | 0 .../applications => applications}/dijkstra/print.c | 0 {hemps8.5/applications => applications}/dtw/bank.c | 0 {hemps8.5/applications => applications}/dtw/dtw.cfg | 0 {hemps8.5/applications => applications}/dtw/dtw.h | 0 {hemps8.5/applications => applications}/dtw/p1.c | 0 {hemps8.5/applications => applications}/dtw/p2.c | 0 {hemps8.5/applications => applications}/dtw/p3.c | 0 {hemps8.5/applications => applications}/dtw/p4.c | 0 .../applications => applications}/dtw/recognizer.c | 0 .../fixe_base_test_16/DLAB.c | 0 .../fixe_base_test_16/DRGB.c | 0 .../fixe_base_test_16/DXYZ.c | 0 .../fixe_base_test_16/GFC.c | 0 .../fixe_base_test_16/LAB1.c | 0 .../fixe_base_test_16/LAB2.c | 0 .../fixe_base_test_16/P1.c | 0 .../fixe_base_test_16/P2.c | 0 .../fixe_base_test_16/RGB1.c | 0 .../fixe_base_test_16/RGB2.c | 0 .../fixe_base_test_16/RMS.c | 0 .../fixe_base_test_16/WRMS.c | 0 .../fixe_base_test_16/XYZ1.c | 0 .../fixe_base_test_16/XYZ2.c | 0 .../fixe_base_test_16/fixe_base_test_16.cfg | 0 {hemps8.5/applications => applications}/mpeg/idct.c | 0 .../applications => applications}/mpeg/iquant.c | 0 {hemps8.5/applications => applications}/mpeg/ivlc.c | 0 .../applications => applications}/mpeg/mpeg.cfg | 0 .../applications => applications}/mpeg/mpeg_std.h | 0 .../applications => applications}/mpeg/print.c | 0 .../applications => applications}/mpeg/start.c | 0 .../applications => applications}/prod_cons/cons.c | 0 .../applications => applications}/prod_cons/prod.c | 0 .../prod_cons/prod_cons.cfg | 0 .../prod_cons/prod_cons_std.h | 0 .../synthetic/syn_std.h | 0 .../synthetic/synthetic.cfg | 0 .../applications => applications}/synthetic/taskA.c | 0 .../applications => applications}/synthetic/taskB.c | 0 .../applications => applications}/synthetic/taskC.c | 0 .../applications => applications}/synthetic/taskD.c | 0 .../applications => applications}/synthetic/taskE.c | 0 .../applications => applications}/synthetic/taskF.c | 0 .../build_env => build_env}/HeMPS_Debugger.jar | Bin .../build_env => build_env}/bin/hemps-debugger | 0 {hemps8.5/build_env => build_env}/bin/hemps-gen | 0 {hemps8.5/build_env => build_env}/bin/hemps-run | 0 .../build_env => build_env}/bin/hemps-sortdebug | 0 .../build_env => build_env}/bin/hemps-wave_gen | 0 {hemps8.5/build_env => build_env}/bin/ram_generator | Bin .../build_env => build_env}/bin/ram_generator.c | 0 {hemps8.5/build_env => build_env}/deloream_env.py | 0 .../build_env => build_env}/makes/make_all_apps | 0 {hemps8.5/build_env => build_env}/makes/make_app | 0 {hemps8.5/build_env => build_env}/makes/make_kernel | 0 .../build_env => build_env}/makes/make_systemc | 0 .../build_env => build_env}/makes/make_systemc_mod | 0 .../build_env => build_env}/makes/make_testcase | 0 {hemps8.5/build_env => build_env}/makes/make_vhdl | 0 {hemps8.5/build_env => build_env}/makes/sim.do | 0 .../build_env => build_env}/scripts/app_builder.py | 0 {hemps8.5/build_env => build_env}/scripts/banner.py | 0 .../build_env => build_env}/scripts/build_utils.py | 0 .../build_env => build_env}/scripts/hw_builder.py | 0 .../scripts/kernel_builder.py | 0 .../build_env => build_env}/scripts/yaml_intf.py | 0 .../build_env => build_env}/testcase_builder.py | 0 {hemps8.5/docs => docs}/hemps_doxy.conf | 0 {hemps8.5/hardware => hardware}/sc/hemps.cpp | 0 {hemps8.5/hardware => hardware}/sc/hemps.h | 0 {hemps8.5/hardware => hardware}/sc/pe/dmni/dmni.cpp | 0 {hemps8.5/hardware => hardware}/sc/pe/dmni/dmni.h | 0 .../hardware => hardware}/sc/pe/memory/ram.cpp | 0 {hemps8.5/hardware => hardware}/sc/pe/memory/ram.h | 0 {hemps8.5/hardware => hardware}/sc/pe/pe.cpp | 0 {hemps8.5/hardware => hardware}/sc/pe/pe.h | 0 .../sc/pe/processor/plasma/mlite_cpu.cpp | 0 .../sc/pe/processor/plasma/mlite_cpu.h | 0 .../hardware => hardware}/sc/pe/router/queue.cpp | 0 .../hardware => hardware}/sc/pe/router/queue.h | 0 .../sc/pe/router/router_cc.cpp | 0 .../hardware => hardware}/sc/pe/router/router_cc.h | 0 .../sc/pe/router/switchcontrol.cpp | 0 .../sc/pe/router/switchcontrol.h | 0 {hemps8.5/hardware => hardware}/sc/standards.h | 0 {hemps8.5/hardware => hardware}/sc/test_bench.cpp | 0 {hemps8.5/hardware => hardware}/sc/test_bench.h | 0 {hemps8.5/hardware => hardware}/vhdl/hemps.vhd | 0 .../hardware => hardware}/vhdl/pe/dmni/dmni.vhd | 0 .../hardware => hardware}/vhdl/pe/memory/ram.vhd | 0 {hemps8.5/hardware => hardware}/vhdl/pe/pe.vhd | 0 .../vhdl/pe/processor/plasma/UartFile.vhd | 0 .../vhdl/pe/processor/plasma/alu.vhd | 0 .../vhdl/pe/processor/plasma/bus_mux.vhd | 0 .../vhdl/pe/processor/plasma/control.vhd | 0 .../vhdl/pe/processor/plasma/mem_ctrl.vhd | 0 .../vhdl/pe/processor/plasma/mlite_cpu.vhd | 0 .../vhdl/pe/processor/plasma/mlite_pack.vhd | 0 .../vhdl/pe/processor/plasma/mult.vhd | 0 .../vhdl/pe/processor/plasma/pc_next.vhd | 0 .../vhdl/pe/processor/plasma/pipeline.vhd | 0 .../vhdl/pe/processor/plasma/reg_bank.vhd | 0 .../vhdl/pe/processor/plasma/shifter.vhd | 0 .../vhdl/pe/router/Hermes_buffer.vhd | 0 .../vhdl/pe/router/Hermes_crossbar.vhd | 0 .../vhdl/pe/router/Hermes_switchcontrol.vhd | 0 .../vhdl/pe/router/RouterCC.vhd | 0 {hemps8.5/hardware => hardware}/vhdl/standards.vhd | 0 {hemps8.5/hardware => hardware}/vhdl/test_bench.vhd | 0 .../software => software}/boot_task/boot_task.asm | 0 {hemps8.5/software => software}/include/api.h | 0 {hemps8.5/software => software}/include/plasma.h | 0 {hemps8.5/software => software}/include/services.h | 0 {hemps8.5/software => software}/include/stdlib.h | 0 .../software => software}/kernel/master/boot.S | 0 .../kernel/master/kernel_master.c | 0 .../kernel/master/kernel_master.h | 0 {hemps8.5/software => software}/kernel/slave/boot.S | 0 .../kernel/slave/kernel_slave.c | 0 .../kernel/slave/kernel_slave.h | 0 .../software => software}/modules/applications.c | 0 .../software => software}/modules/applications.h | 0 .../software => software}/modules/communication.c | 0 .../software => software}/modules/communication.h | 0 {hemps8.5/software => software}/modules/new_task.c | 0 {hemps8.5/software => software}/modules/new_task.h | 0 {hemps8.5/software => software}/modules/packet.c | 0 {hemps8.5/software => software}/modules/packet.h | 0 .../software => software}/modules/pending_service.c | 0 .../software => software}/modules/pending_service.h | 0 .../software => software}/modules/processors.c | 0 .../software => software}/modules/processors.h | 0 .../software => software}/modules/reclustering.c | 0 .../software => software}/modules/reclustering.h | 0 .../modules/resource_manager.c | 0 .../modules/resource_manager.h | 0 .../software => software}/modules/task_control.c | 0 .../software => software}/modules/task_control.h | 0 .../software => software}/modules/task_location.c | 0 .../software => software}/modules/task_location.h | 0 .../software => software}/modules/task_migration.c | 0 .../software => software}/modules/task_migration.h | 0 .../software => software}/modules/task_scheduler.c | 0 .../software => software}/modules/task_scheduler.h | 0 {hemps8.5/software => software}/modules/utils.c | 0 {hemps8.5/software => software}/modules/utils.h | 0 {hemps8.5/testcases => testcases}/example.yaml | 0 .../regression/12x12_4x4_2t.yaml | 0 .../regression/16x16_4x4_2t.yaml | 0 .../regression/3x3_3x3_2t.yaml | 0 .../regression/6x6_3x3_2t.yaml | 0 .../regression/8x8_4x4_2t.yaml | 0 .../regression/8x8_4x4_3t.yaml | 0 .../regression/8x8_4x4_4t.yaml | 0 .../regression/9x9_3x3_2t.yaml | 0 .../regression/9x9_3x3_3t.yaml | 0 .../regression/9x9_3x3_4t.yaml | 0 234 files changed, 0 insertions(+), 0 deletions(-) rename hemps8.5/README.txt => README.txt (100%) rename {hemps8.5/applications => applications}/MPEG4/ADSP_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/AU_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/BAB_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/IDCT_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/MCPU_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/MPEG4.cfg (100%) rename {hemps8.5/applications => applications}/MPEG4/RAST_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/RISC_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/SDRAM_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/SRAM1_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/SRAM2_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/UPSAMP_0.c (100%) rename {hemps8.5/applications => applications}/MPEG4/VU_0.c (100%) rename {hemps8.5/applications => applications}/MWD/BLEND.c (100%) rename {hemps8.5/applications => applications}/MWD/HS.c (100%) rename {hemps8.5/applications => applications}/MWD/HVS.c (100%) rename {hemps8.5/applications => applications}/MWD/IN.c (100%) rename {hemps8.5/applications => applications}/MWD/JUG1.c (100%) rename {hemps8.5/applications => applications}/MWD/JUG2.c (100%) rename {hemps8.5/applications => applications}/MWD/MEM1.c (100%) rename {hemps8.5/applications => applications}/MWD/MEM2.c (100%) rename {hemps8.5/applications => applications}/MWD/MEM3.c (100%) rename {hemps8.5/applications => applications}/MWD/MWD.cfg (100%) rename {hemps8.5/applications => applications}/MWD/NR.c (100%) rename {hemps8.5/applications => applications}/MWD/SE.c (100%) rename {hemps8.5/applications => applications}/MWD/VS.c (100%) rename {hemps8.5/applications => applications}/VOPD/ACDC_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/ARM_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/IDCT2_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/IQUANT_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/ISCAN_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/PAD_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/RUN_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/STRIPEM_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/UPSAMP_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/VLD_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/VOPD.cfg (100%) rename {hemps8.5/applications => applications}/VOPD/VOPME_0.c (100%) rename {hemps8.5/applications => applications}/VOPD/VOPREC_0.c (100%) rename {hemps8.5/applications => applications}/aes/aes.cfg (100%) rename {hemps8.5/applications => applications}/aes/aes.h (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/Aplicacao_AES_para_HeMPS.pdf (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/README.txt (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/aes.cfg (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/aes.h (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/aes.hmp (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/aes_generator.sh (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/aes_master.c (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/aes_master.h (100%) rename {hemps8.5/applications => applications}/aes/aes_generator/aes_sl.c (100%) rename {hemps8.5/applications => applications}/aes/aes_master.c (100%) rename {hemps8.5/applications => applications}/aes/aes_master.h (100%) rename {hemps8.5/applications => applications}/aes/aes_slave1.c (100%) rename {hemps8.5/applications => applications}/aes/aes_slave2.c (100%) rename {hemps8.5/applications => applications}/aes/aes_slave3.c (100%) rename {hemps8.5/applications => applications}/aes/aes_slave4.c (100%) rename {hemps8.5/applications => applications}/aes/aes_slave5.c (100%) rename {hemps8.5/applications => applications}/aes/aes_slave6.c (100%) rename {hemps8.5/applications => applications}/aes/aes_slave7.c (100%) rename {hemps8.5/applications => applications}/aes/aes_slave8.c (100%) rename {hemps8.5/applications => applications}/audio_video/FIR.c (100%) rename {hemps8.5/applications => applications}/audio_video/adpcm_dec.c (100%) rename {hemps8.5/applications => applications}/audio_video/audio_video_def.h (100%) rename {hemps8.5/applications => applications}/audio_video/idct.c (100%) rename {hemps8.5/applications => applications}/audio_video/iquant.c (100%) rename {hemps8.5/applications => applications}/audio_video/ivlc.c (100%) rename {hemps8.5/applications => applications}/audio_video/join.c (100%) rename {hemps8.5/applications => applications}/audio_video/split.c (100%) rename {hemps8.5/applications => applications}/audio_video/tcg.yaml (100%) rename {hemps8.5/applications => applications}/dijkstra/dijkstra.cfg (100%) rename {hemps8.5/applications => applications}/dijkstra/dijkstra_0.c (100%) rename {hemps8.5/applications => applications}/dijkstra/dijkstra_1.c (100%) rename {hemps8.5/applications => applications}/dijkstra/dijkstra_2.c (100%) rename {hemps8.5/applications => applications}/dijkstra/dijkstra_3.c (100%) rename {hemps8.5/applications => applications}/dijkstra/dijkstra_4.c (100%) rename {hemps8.5/applications => applications}/dijkstra/divider.c (100%) rename {hemps8.5/applications => applications}/dijkstra/print.c (100%) rename {hemps8.5/applications => applications}/dtw/bank.c (100%) rename {hemps8.5/applications => applications}/dtw/dtw.cfg (100%) rename {hemps8.5/applications => applications}/dtw/dtw.h (100%) rename {hemps8.5/applications => applications}/dtw/p1.c (100%) rename {hemps8.5/applications => applications}/dtw/p2.c (100%) rename {hemps8.5/applications => applications}/dtw/p3.c (100%) rename {hemps8.5/applications => applications}/dtw/p4.c (100%) rename {hemps8.5/applications => applications}/dtw/recognizer.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/DLAB.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/DRGB.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/DXYZ.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/GFC.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/LAB1.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/LAB2.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/P1.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/P2.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/RGB1.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/RGB2.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/RMS.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/WRMS.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/XYZ1.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/XYZ2.c (100%) rename {hemps8.5/applications => applications}/fixe_base_test_16/fixe_base_test_16.cfg (100%) rename {hemps8.5/applications => applications}/mpeg/idct.c (100%) rename {hemps8.5/applications => applications}/mpeg/iquant.c (100%) rename {hemps8.5/applications => applications}/mpeg/ivlc.c (100%) rename {hemps8.5/applications => applications}/mpeg/mpeg.cfg (100%) rename {hemps8.5/applications => applications}/mpeg/mpeg_std.h (100%) rename {hemps8.5/applications => applications}/mpeg/print.c (100%) rename {hemps8.5/applications => applications}/mpeg/start.c (100%) rename {hemps8.5/applications => applications}/prod_cons/cons.c (100%) rename {hemps8.5/applications => applications}/prod_cons/prod.c (100%) rename {hemps8.5/applications => applications}/prod_cons/prod_cons.cfg (100%) rename {hemps8.5/applications => applications}/prod_cons/prod_cons_std.h (100%) rename {hemps8.5/applications => applications}/synthetic/syn_std.h (100%) rename {hemps8.5/applications => applications}/synthetic/synthetic.cfg (100%) rename {hemps8.5/applications => applications}/synthetic/taskA.c (100%) rename {hemps8.5/applications => applications}/synthetic/taskB.c (100%) rename {hemps8.5/applications => applications}/synthetic/taskC.c (100%) rename {hemps8.5/applications => applications}/synthetic/taskD.c (100%) rename {hemps8.5/applications => applications}/synthetic/taskE.c (100%) rename {hemps8.5/applications => applications}/synthetic/taskF.c (100%) rename {hemps8.5/build_env => build_env}/HeMPS_Debugger.jar (100%) rename {hemps8.5/build_env => build_env}/bin/hemps-debugger (100%) rename {hemps8.5/build_env => build_env}/bin/hemps-gen (100%) rename {hemps8.5/build_env => build_env}/bin/hemps-run (100%) rename {hemps8.5/build_env => build_env}/bin/hemps-sortdebug (100%) rename {hemps8.5/build_env => build_env}/bin/hemps-wave_gen (100%) rename {hemps8.5/build_env => build_env}/bin/ram_generator (100%) rename {hemps8.5/build_env => build_env}/bin/ram_generator.c (100%) rename {hemps8.5/build_env => build_env}/deloream_env.py (100%) rename {hemps8.5/build_env => build_env}/makes/make_all_apps (100%) rename {hemps8.5/build_env => build_env}/makes/make_app (100%) rename {hemps8.5/build_env => build_env}/makes/make_kernel (100%) rename {hemps8.5/build_env => build_env}/makes/make_systemc (100%) rename {hemps8.5/build_env => build_env}/makes/make_systemc_mod (100%) rename {hemps8.5/build_env => build_env}/makes/make_testcase (100%) rename {hemps8.5/build_env => build_env}/makes/make_vhdl (100%) rename {hemps8.5/build_env => build_env}/makes/sim.do (100%) rename {hemps8.5/build_env => build_env}/scripts/app_builder.py (100%) rename {hemps8.5/build_env => build_env}/scripts/banner.py (100%) rename {hemps8.5/build_env => build_env}/scripts/build_utils.py (100%) rename {hemps8.5/build_env => build_env}/scripts/hw_builder.py (100%) rename {hemps8.5/build_env => build_env}/scripts/kernel_builder.py (100%) rename {hemps8.5/build_env => build_env}/scripts/yaml_intf.py (100%) rename {hemps8.5/build_env => build_env}/testcase_builder.py (100%) rename {hemps8.5/docs => docs}/hemps_doxy.conf (100%) rename {hemps8.5/hardware => hardware}/sc/hemps.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/hemps.h (100%) rename {hemps8.5/hardware => hardware}/sc/pe/dmni/dmni.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/pe/dmni/dmni.h (100%) rename {hemps8.5/hardware => hardware}/sc/pe/memory/ram.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/pe/memory/ram.h (100%) rename {hemps8.5/hardware => hardware}/sc/pe/pe.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/pe/pe.h (100%) rename {hemps8.5/hardware => hardware}/sc/pe/processor/plasma/mlite_cpu.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/pe/processor/plasma/mlite_cpu.h (100%) rename {hemps8.5/hardware => hardware}/sc/pe/router/queue.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/pe/router/queue.h (100%) rename {hemps8.5/hardware => hardware}/sc/pe/router/router_cc.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/pe/router/router_cc.h (100%) rename {hemps8.5/hardware => hardware}/sc/pe/router/switchcontrol.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/pe/router/switchcontrol.h (100%) rename {hemps8.5/hardware => hardware}/sc/standards.h (100%) rename {hemps8.5/hardware => hardware}/sc/test_bench.cpp (100%) rename {hemps8.5/hardware => hardware}/sc/test_bench.h (100%) rename {hemps8.5/hardware => hardware}/vhdl/hemps.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/dmni/dmni.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/memory/ram.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/pe.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/UartFile.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/alu.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/bus_mux.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/control.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/mem_ctrl.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/mlite_cpu.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/mlite_pack.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/mult.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/pc_next.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/pipeline.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/reg_bank.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/processor/plasma/shifter.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/router/Hermes_buffer.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/router/Hermes_crossbar.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/router/Hermes_switchcontrol.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/pe/router/RouterCC.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/standards.vhd (100%) rename {hemps8.5/hardware => hardware}/vhdl/test_bench.vhd (100%) rename {hemps8.5/software => software}/boot_task/boot_task.asm (100%) rename {hemps8.5/software => software}/include/api.h (100%) rename {hemps8.5/software => software}/include/plasma.h (100%) rename {hemps8.5/software => software}/include/services.h (100%) rename {hemps8.5/software => software}/include/stdlib.h (100%) rename {hemps8.5/software => software}/kernel/master/boot.S (100%) rename {hemps8.5/software => software}/kernel/master/kernel_master.c (100%) rename {hemps8.5/software => software}/kernel/master/kernel_master.h (100%) rename {hemps8.5/software => software}/kernel/slave/boot.S (100%) rename {hemps8.5/software => software}/kernel/slave/kernel_slave.c (100%) rename {hemps8.5/software => software}/kernel/slave/kernel_slave.h (100%) rename {hemps8.5/software => software}/modules/applications.c (100%) rename {hemps8.5/software => software}/modules/applications.h (100%) rename {hemps8.5/software => software}/modules/communication.c (100%) rename {hemps8.5/software => software}/modules/communication.h (100%) rename {hemps8.5/software => software}/modules/new_task.c (100%) rename {hemps8.5/software => software}/modules/new_task.h (100%) rename {hemps8.5/software => software}/modules/packet.c (100%) rename {hemps8.5/software => software}/modules/packet.h (100%) rename {hemps8.5/software => software}/modules/pending_service.c (100%) rename {hemps8.5/software => software}/modules/pending_service.h (100%) rename {hemps8.5/software => software}/modules/processors.c (100%) rename {hemps8.5/software => software}/modules/processors.h (100%) rename {hemps8.5/software => software}/modules/reclustering.c (100%) rename {hemps8.5/software => software}/modules/reclustering.h (100%) rename {hemps8.5/software => software}/modules/resource_manager.c (100%) rename {hemps8.5/software => software}/modules/resource_manager.h (100%) rename {hemps8.5/software => software}/modules/task_control.c (100%) rename {hemps8.5/software => software}/modules/task_control.h (100%) rename {hemps8.5/software => software}/modules/task_location.c (100%) rename {hemps8.5/software => software}/modules/task_location.h (100%) rename {hemps8.5/software => software}/modules/task_migration.c (100%) rename {hemps8.5/software => software}/modules/task_migration.h (100%) rename {hemps8.5/software => software}/modules/task_scheduler.c (100%) rename {hemps8.5/software => software}/modules/task_scheduler.h (100%) rename {hemps8.5/software => software}/modules/utils.c (100%) rename {hemps8.5/software => software}/modules/utils.h (100%) rename {hemps8.5/testcases => testcases}/example.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/12x12_4x4_2t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/16x16_4x4_2t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/3x3_3x3_2t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/6x6_3x3_2t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/8x8_4x4_2t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/8x8_4x4_3t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/8x8_4x4_4t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/9x9_3x3_2t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/9x9_3x3_3t.yaml (100%) rename {hemps8.5/testcases => testcases}/regression/9x9_3x3_4t.yaml (100%) diff --git a/hemps8.5/README.txt b/README.txt similarity index 100% rename from hemps8.5/README.txt rename to README.txt diff --git a/hemps8.5/applications/MPEG4/ADSP_0.c b/applications/MPEG4/ADSP_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/ADSP_0.c rename to applications/MPEG4/ADSP_0.c diff --git a/hemps8.5/applications/MPEG4/AU_0.c b/applications/MPEG4/AU_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/AU_0.c rename to applications/MPEG4/AU_0.c diff --git a/hemps8.5/applications/MPEG4/BAB_0.c b/applications/MPEG4/BAB_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/BAB_0.c rename to applications/MPEG4/BAB_0.c diff --git a/hemps8.5/applications/MPEG4/IDCT_0.c b/applications/MPEG4/IDCT_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/IDCT_0.c rename to applications/MPEG4/IDCT_0.c diff --git a/hemps8.5/applications/MPEG4/MCPU_0.c b/applications/MPEG4/MCPU_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/MCPU_0.c rename to applications/MPEG4/MCPU_0.c diff --git a/hemps8.5/applications/MPEG4/MPEG4.cfg b/applications/MPEG4/MPEG4.cfg similarity index 100% rename from hemps8.5/applications/MPEG4/MPEG4.cfg rename to applications/MPEG4/MPEG4.cfg diff --git a/hemps8.5/applications/MPEG4/RAST_0.c b/applications/MPEG4/RAST_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/RAST_0.c rename to applications/MPEG4/RAST_0.c diff --git a/hemps8.5/applications/MPEG4/RISC_0.c b/applications/MPEG4/RISC_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/RISC_0.c rename to applications/MPEG4/RISC_0.c diff --git a/hemps8.5/applications/MPEG4/SDRAM_0.c b/applications/MPEG4/SDRAM_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/SDRAM_0.c rename to applications/MPEG4/SDRAM_0.c diff --git a/hemps8.5/applications/MPEG4/SRAM1_0.c b/applications/MPEG4/SRAM1_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/SRAM1_0.c rename to applications/MPEG4/SRAM1_0.c diff --git a/hemps8.5/applications/MPEG4/SRAM2_0.c b/applications/MPEG4/SRAM2_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/SRAM2_0.c rename to applications/MPEG4/SRAM2_0.c diff --git a/hemps8.5/applications/MPEG4/UPSAMP_0.c b/applications/MPEG4/UPSAMP_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/UPSAMP_0.c rename to applications/MPEG4/UPSAMP_0.c diff --git a/hemps8.5/applications/MPEG4/VU_0.c b/applications/MPEG4/VU_0.c similarity index 100% rename from hemps8.5/applications/MPEG4/VU_0.c rename to applications/MPEG4/VU_0.c diff --git a/hemps8.5/applications/MWD/BLEND.c b/applications/MWD/BLEND.c similarity index 100% rename from hemps8.5/applications/MWD/BLEND.c rename to applications/MWD/BLEND.c diff --git a/hemps8.5/applications/MWD/HS.c b/applications/MWD/HS.c similarity index 100% rename from hemps8.5/applications/MWD/HS.c rename to applications/MWD/HS.c diff --git a/hemps8.5/applications/MWD/HVS.c b/applications/MWD/HVS.c similarity index 100% rename from hemps8.5/applications/MWD/HVS.c rename to applications/MWD/HVS.c diff --git a/hemps8.5/applications/MWD/IN.c b/applications/MWD/IN.c similarity index 100% rename from hemps8.5/applications/MWD/IN.c rename to applications/MWD/IN.c diff --git a/hemps8.5/applications/MWD/JUG1.c b/applications/MWD/JUG1.c similarity index 100% rename from hemps8.5/applications/MWD/JUG1.c rename to applications/MWD/JUG1.c diff --git a/hemps8.5/applications/MWD/JUG2.c b/applications/MWD/JUG2.c similarity index 100% rename from hemps8.5/applications/MWD/JUG2.c rename to applications/MWD/JUG2.c diff --git a/hemps8.5/applications/MWD/MEM1.c b/applications/MWD/MEM1.c similarity index 100% rename from hemps8.5/applications/MWD/MEM1.c rename to applications/MWD/MEM1.c diff --git a/hemps8.5/applications/MWD/MEM2.c b/applications/MWD/MEM2.c similarity index 100% rename from hemps8.5/applications/MWD/MEM2.c rename to applications/MWD/MEM2.c diff --git a/hemps8.5/applications/MWD/MEM3.c b/applications/MWD/MEM3.c similarity index 100% rename from hemps8.5/applications/MWD/MEM3.c rename to applications/MWD/MEM3.c diff --git a/hemps8.5/applications/MWD/MWD.cfg b/applications/MWD/MWD.cfg similarity index 100% rename from hemps8.5/applications/MWD/MWD.cfg rename to applications/MWD/MWD.cfg diff --git a/hemps8.5/applications/MWD/NR.c b/applications/MWD/NR.c similarity index 100% rename from hemps8.5/applications/MWD/NR.c rename to applications/MWD/NR.c diff --git a/hemps8.5/applications/MWD/SE.c b/applications/MWD/SE.c similarity index 100% rename from hemps8.5/applications/MWD/SE.c rename to applications/MWD/SE.c diff --git a/hemps8.5/applications/MWD/VS.c b/applications/MWD/VS.c similarity index 100% rename from hemps8.5/applications/MWD/VS.c rename to applications/MWD/VS.c diff --git a/hemps8.5/applications/VOPD/ACDC_0.c b/applications/VOPD/ACDC_0.c similarity index 100% rename from hemps8.5/applications/VOPD/ACDC_0.c rename to applications/VOPD/ACDC_0.c diff --git a/hemps8.5/applications/VOPD/ARM_0.c b/applications/VOPD/ARM_0.c similarity index 100% rename from hemps8.5/applications/VOPD/ARM_0.c rename to applications/VOPD/ARM_0.c diff --git a/hemps8.5/applications/VOPD/IDCT2_0.c b/applications/VOPD/IDCT2_0.c similarity index 100% rename from hemps8.5/applications/VOPD/IDCT2_0.c rename to applications/VOPD/IDCT2_0.c diff --git a/hemps8.5/applications/VOPD/IQUANT_0.c b/applications/VOPD/IQUANT_0.c similarity index 100% rename from hemps8.5/applications/VOPD/IQUANT_0.c rename to applications/VOPD/IQUANT_0.c diff --git a/hemps8.5/applications/VOPD/ISCAN_0.c b/applications/VOPD/ISCAN_0.c similarity index 100% rename from hemps8.5/applications/VOPD/ISCAN_0.c rename to applications/VOPD/ISCAN_0.c diff --git a/hemps8.5/applications/VOPD/PAD_0.c b/applications/VOPD/PAD_0.c similarity index 100% rename from hemps8.5/applications/VOPD/PAD_0.c rename to applications/VOPD/PAD_0.c diff --git a/hemps8.5/applications/VOPD/RUN_0.c b/applications/VOPD/RUN_0.c similarity index 100% rename from hemps8.5/applications/VOPD/RUN_0.c rename to applications/VOPD/RUN_0.c diff --git a/hemps8.5/applications/VOPD/STRIPEM_0.c b/applications/VOPD/STRIPEM_0.c similarity index 100% rename from hemps8.5/applications/VOPD/STRIPEM_0.c rename to applications/VOPD/STRIPEM_0.c diff --git a/hemps8.5/applications/VOPD/UPSAMP_0.c b/applications/VOPD/UPSAMP_0.c similarity index 100% rename from hemps8.5/applications/VOPD/UPSAMP_0.c rename to applications/VOPD/UPSAMP_0.c diff --git a/hemps8.5/applications/VOPD/VLD_0.c b/applications/VOPD/VLD_0.c similarity index 100% rename from hemps8.5/applications/VOPD/VLD_0.c rename to applications/VOPD/VLD_0.c diff --git a/hemps8.5/applications/VOPD/VOPD.cfg b/applications/VOPD/VOPD.cfg similarity index 100% rename from hemps8.5/applications/VOPD/VOPD.cfg rename to applications/VOPD/VOPD.cfg diff --git a/hemps8.5/applications/VOPD/VOPME_0.c b/applications/VOPD/VOPME_0.c similarity index 100% rename from hemps8.5/applications/VOPD/VOPME_0.c rename to applications/VOPD/VOPME_0.c diff --git a/hemps8.5/applications/VOPD/VOPREC_0.c b/applications/VOPD/VOPREC_0.c similarity index 100% rename from hemps8.5/applications/VOPD/VOPREC_0.c rename to applications/VOPD/VOPREC_0.c diff --git a/hemps8.5/applications/aes/aes.cfg b/applications/aes/aes.cfg similarity index 100% rename from hemps8.5/applications/aes/aes.cfg rename to applications/aes/aes.cfg diff --git a/hemps8.5/applications/aes/aes.h b/applications/aes/aes.h similarity index 100% rename from hemps8.5/applications/aes/aes.h rename to applications/aes/aes.h diff --git a/hemps8.5/applications/aes/aes_generator/Aplicacao_AES_para_HeMPS.pdf b/applications/aes/aes_generator/Aplicacao_AES_para_HeMPS.pdf similarity index 100% rename from hemps8.5/applications/aes/aes_generator/Aplicacao_AES_para_HeMPS.pdf rename to applications/aes/aes_generator/Aplicacao_AES_para_HeMPS.pdf diff --git a/hemps8.5/applications/aes/aes_generator/README.txt b/applications/aes/aes_generator/README.txt similarity index 100% rename from hemps8.5/applications/aes/aes_generator/README.txt rename to applications/aes/aes_generator/README.txt diff --git a/hemps8.5/applications/aes/aes_generator/aes.cfg b/applications/aes/aes_generator/aes.cfg similarity index 100% rename from hemps8.5/applications/aes/aes_generator/aes.cfg rename to applications/aes/aes_generator/aes.cfg diff --git a/hemps8.5/applications/aes/aes_generator/aes.h b/applications/aes/aes_generator/aes.h similarity index 100% rename from hemps8.5/applications/aes/aes_generator/aes.h rename to applications/aes/aes_generator/aes.h diff --git a/hemps8.5/applications/aes/aes_generator/aes.hmp b/applications/aes/aes_generator/aes.hmp similarity index 100% rename from hemps8.5/applications/aes/aes_generator/aes.hmp rename to applications/aes/aes_generator/aes.hmp diff --git a/hemps8.5/applications/aes/aes_generator/aes_generator.sh b/applications/aes/aes_generator/aes_generator.sh similarity index 100% rename from hemps8.5/applications/aes/aes_generator/aes_generator.sh rename to applications/aes/aes_generator/aes_generator.sh diff --git a/hemps8.5/applications/aes/aes_generator/aes_master.c b/applications/aes/aes_generator/aes_master.c similarity index 100% rename from hemps8.5/applications/aes/aes_generator/aes_master.c rename to applications/aes/aes_generator/aes_master.c diff --git a/hemps8.5/applications/aes/aes_generator/aes_master.h b/applications/aes/aes_generator/aes_master.h similarity index 100% rename from hemps8.5/applications/aes/aes_generator/aes_master.h rename to applications/aes/aes_generator/aes_master.h diff --git a/hemps8.5/applications/aes/aes_generator/aes_sl.c b/applications/aes/aes_generator/aes_sl.c similarity index 100% rename from hemps8.5/applications/aes/aes_generator/aes_sl.c rename to applications/aes/aes_generator/aes_sl.c diff --git a/hemps8.5/applications/aes/aes_master.c b/applications/aes/aes_master.c similarity index 100% rename from hemps8.5/applications/aes/aes_master.c rename to applications/aes/aes_master.c diff --git a/hemps8.5/applications/aes/aes_master.h b/applications/aes/aes_master.h similarity index 100% rename from hemps8.5/applications/aes/aes_master.h rename to applications/aes/aes_master.h diff --git a/hemps8.5/applications/aes/aes_slave1.c b/applications/aes/aes_slave1.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave1.c rename to applications/aes/aes_slave1.c diff --git a/hemps8.5/applications/aes/aes_slave2.c b/applications/aes/aes_slave2.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave2.c rename to applications/aes/aes_slave2.c diff --git a/hemps8.5/applications/aes/aes_slave3.c b/applications/aes/aes_slave3.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave3.c rename to applications/aes/aes_slave3.c diff --git a/hemps8.5/applications/aes/aes_slave4.c b/applications/aes/aes_slave4.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave4.c rename to applications/aes/aes_slave4.c diff --git a/hemps8.5/applications/aes/aes_slave5.c b/applications/aes/aes_slave5.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave5.c rename to applications/aes/aes_slave5.c diff --git a/hemps8.5/applications/aes/aes_slave6.c b/applications/aes/aes_slave6.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave6.c rename to applications/aes/aes_slave6.c diff --git a/hemps8.5/applications/aes/aes_slave7.c b/applications/aes/aes_slave7.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave7.c rename to applications/aes/aes_slave7.c diff --git a/hemps8.5/applications/aes/aes_slave8.c b/applications/aes/aes_slave8.c similarity index 100% rename from hemps8.5/applications/aes/aes_slave8.c rename to applications/aes/aes_slave8.c diff --git a/hemps8.5/applications/audio_video/FIR.c b/applications/audio_video/FIR.c similarity index 100% rename from hemps8.5/applications/audio_video/FIR.c rename to applications/audio_video/FIR.c diff --git a/hemps8.5/applications/audio_video/adpcm_dec.c b/applications/audio_video/adpcm_dec.c similarity index 100% rename from hemps8.5/applications/audio_video/adpcm_dec.c rename to applications/audio_video/adpcm_dec.c diff --git a/hemps8.5/applications/audio_video/audio_video_def.h b/applications/audio_video/audio_video_def.h similarity index 100% rename from hemps8.5/applications/audio_video/audio_video_def.h rename to applications/audio_video/audio_video_def.h diff --git a/hemps8.5/applications/audio_video/idct.c b/applications/audio_video/idct.c similarity index 100% rename from hemps8.5/applications/audio_video/idct.c rename to applications/audio_video/idct.c diff --git a/hemps8.5/applications/audio_video/iquant.c b/applications/audio_video/iquant.c similarity index 100% rename from hemps8.5/applications/audio_video/iquant.c rename to applications/audio_video/iquant.c diff --git a/hemps8.5/applications/audio_video/ivlc.c b/applications/audio_video/ivlc.c similarity index 100% rename from hemps8.5/applications/audio_video/ivlc.c rename to applications/audio_video/ivlc.c diff --git a/hemps8.5/applications/audio_video/join.c b/applications/audio_video/join.c similarity index 100% rename from hemps8.5/applications/audio_video/join.c rename to applications/audio_video/join.c diff --git a/hemps8.5/applications/audio_video/split.c b/applications/audio_video/split.c similarity index 100% rename from hemps8.5/applications/audio_video/split.c rename to applications/audio_video/split.c diff --git a/hemps8.5/applications/audio_video/tcg.yaml b/applications/audio_video/tcg.yaml similarity index 100% rename from hemps8.5/applications/audio_video/tcg.yaml rename to applications/audio_video/tcg.yaml diff --git a/hemps8.5/applications/dijkstra/dijkstra.cfg b/applications/dijkstra/dijkstra.cfg similarity index 100% rename from hemps8.5/applications/dijkstra/dijkstra.cfg rename to applications/dijkstra/dijkstra.cfg diff --git a/hemps8.5/applications/dijkstra/dijkstra_0.c b/applications/dijkstra/dijkstra_0.c similarity index 100% rename from hemps8.5/applications/dijkstra/dijkstra_0.c rename to applications/dijkstra/dijkstra_0.c diff --git a/hemps8.5/applications/dijkstra/dijkstra_1.c b/applications/dijkstra/dijkstra_1.c similarity index 100% rename from hemps8.5/applications/dijkstra/dijkstra_1.c rename to applications/dijkstra/dijkstra_1.c diff --git a/hemps8.5/applications/dijkstra/dijkstra_2.c b/applications/dijkstra/dijkstra_2.c similarity index 100% rename from hemps8.5/applications/dijkstra/dijkstra_2.c rename to applications/dijkstra/dijkstra_2.c diff --git a/hemps8.5/applications/dijkstra/dijkstra_3.c b/applications/dijkstra/dijkstra_3.c similarity index 100% rename from hemps8.5/applications/dijkstra/dijkstra_3.c rename to applications/dijkstra/dijkstra_3.c diff --git a/hemps8.5/applications/dijkstra/dijkstra_4.c b/applications/dijkstra/dijkstra_4.c similarity index 100% rename from hemps8.5/applications/dijkstra/dijkstra_4.c rename to applications/dijkstra/dijkstra_4.c diff --git a/hemps8.5/applications/dijkstra/divider.c b/applications/dijkstra/divider.c similarity index 100% rename from hemps8.5/applications/dijkstra/divider.c rename to applications/dijkstra/divider.c diff --git a/hemps8.5/applications/dijkstra/print.c b/applications/dijkstra/print.c similarity index 100% rename from hemps8.5/applications/dijkstra/print.c rename to applications/dijkstra/print.c diff --git a/hemps8.5/applications/dtw/bank.c b/applications/dtw/bank.c similarity index 100% rename from hemps8.5/applications/dtw/bank.c rename to applications/dtw/bank.c diff --git a/hemps8.5/applications/dtw/dtw.cfg b/applications/dtw/dtw.cfg similarity index 100% rename from hemps8.5/applications/dtw/dtw.cfg rename to applications/dtw/dtw.cfg diff --git a/hemps8.5/applications/dtw/dtw.h b/applications/dtw/dtw.h similarity index 100% rename from hemps8.5/applications/dtw/dtw.h rename to applications/dtw/dtw.h diff --git a/hemps8.5/applications/dtw/p1.c b/applications/dtw/p1.c similarity index 100% rename from hemps8.5/applications/dtw/p1.c rename to applications/dtw/p1.c diff --git a/hemps8.5/applications/dtw/p2.c b/applications/dtw/p2.c similarity index 100% rename from hemps8.5/applications/dtw/p2.c rename to applications/dtw/p2.c diff --git a/hemps8.5/applications/dtw/p3.c b/applications/dtw/p3.c similarity index 100% rename from hemps8.5/applications/dtw/p3.c rename to applications/dtw/p3.c diff --git a/hemps8.5/applications/dtw/p4.c b/applications/dtw/p4.c similarity index 100% rename from hemps8.5/applications/dtw/p4.c rename to applications/dtw/p4.c diff --git a/hemps8.5/applications/dtw/recognizer.c b/applications/dtw/recognizer.c similarity index 100% rename from hemps8.5/applications/dtw/recognizer.c rename to applications/dtw/recognizer.c diff --git a/hemps8.5/applications/fixe_base_test_16/DLAB.c b/applications/fixe_base_test_16/DLAB.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/DLAB.c rename to applications/fixe_base_test_16/DLAB.c diff --git a/hemps8.5/applications/fixe_base_test_16/DRGB.c b/applications/fixe_base_test_16/DRGB.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/DRGB.c rename to applications/fixe_base_test_16/DRGB.c diff --git a/hemps8.5/applications/fixe_base_test_16/DXYZ.c b/applications/fixe_base_test_16/DXYZ.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/DXYZ.c rename to applications/fixe_base_test_16/DXYZ.c diff --git a/hemps8.5/applications/fixe_base_test_16/GFC.c b/applications/fixe_base_test_16/GFC.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/GFC.c rename to applications/fixe_base_test_16/GFC.c diff --git a/hemps8.5/applications/fixe_base_test_16/LAB1.c b/applications/fixe_base_test_16/LAB1.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/LAB1.c rename to applications/fixe_base_test_16/LAB1.c diff --git a/hemps8.5/applications/fixe_base_test_16/LAB2.c b/applications/fixe_base_test_16/LAB2.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/LAB2.c rename to applications/fixe_base_test_16/LAB2.c diff --git a/hemps8.5/applications/fixe_base_test_16/P1.c b/applications/fixe_base_test_16/P1.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/P1.c rename to applications/fixe_base_test_16/P1.c diff --git a/hemps8.5/applications/fixe_base_test_16/P2.c b/applications/fixe_base_test_16/P2.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/P2.c rename to applications/fixe_base_test_16/P2.c diff --git a/hemps8.5/applications/fixe_base_test_16/RGB1.c b/applications/fixe_base_test_16/RGB1.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/RGB1.c rename to applications/fixe_base_test_16/RGB1.c diff --git a/hemps8.5/applications/fixe_base_test_16/RGB2.c b/applications/fixe_base_test_16/RGB2.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/RGB2.c rename to applications/fixe_base_test_16/RGB2.c diff --git a/hemps8.5/applications/fixe_base_test_16/RMS.c b/applications/fixe_base_test_16/RMS.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/RMS.c rename to applications/fixe_base_test_16/RMS.c diff --git a/hemps8.5/applications/fixe_base_test_16/WRMS.c b/applications/fixe_base_test_16/WRMS.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/WRMS.c rename to applications/fixe_base_test_16/WRMS.c diff --git a/hemps8.5/applications/fixe_base_test_16/XYZ1.c b/applications/fixe_base_test_16/XYZ1.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/XYZ1.c rename to applications/fixe_base_test_16/XYZ1.c diff --git a/hemps8.5/applications/fixe_base_test_16/XYZ2.c b/applications/fixe_base_test_16/XYZ2.c similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/XYZ2.c rename to applications/fixe_base_test_16/XYZ2.c diff --git a/hemps8.5/applications/fixe_base_test_16/fixe_base_test_16.cfg b/applications/fixe_base_test_16/fixe_base_test_16.cfg similarity index 100% rename from hemps8.5/applications/fixe_base_test_16/fixe_base_test_16.cfg rename to applications/fixe_base_test_16/fixe_base_test_16.cfg diff --git a/hemps8.5/applications/mpeg/idct.c b/applications/mpeg/idct.c similarity index 100% rename from hemps8.5/applications/mpeg/idct.c rename to applications/mpeg/idct.c diff --git a/hemps8.5/applications/mpeg/iquant.c b/applications/mpeg/iquant.c similarity index 100% rename from hemps8.5/applications/mpeg/iquant.c rename to applications/mpeg/iquant.c diff --git a/hemps8.5/applications/mpeg/ivlc.c b/applications/mpeg/ivlc.c similarity index 100% rename from hemps8.5/applications/mpeg/ivlc.c rename to applications/mpeg/ivlc.c diff --git a/hemps8.5/applications/mpeg/mpeg.cfg b/applications/mpeg/mpeg.cfg similarity index 100% rename from hemps8.5/applications/mpeg/mpeg.cfg rename to applications/mpeg/mpeg.cfg diff --git a/hemps8.5/applications/mpeg/mpeg_std.h b/applications/mpeg/mpeg_std.h similarity index 100% rename from hemps8.5/applications/mpeg/mpeg_std.h rename to applications/mpeg/mpeg_std.h diff --git a/hemps8.5/applications/mpeg/print.c b/applications/mpeg/print.c similarity index 100% rename from hemps8.5/applications/mpeg/print.c rename to applications/mpeg/print.c diff --git a/hemps8.5/applications/mpeg/start.c b/applications/mpeg/start.c similarity index 100% rename from hemps8.5/applications/mpeg/start.c rename to applications/mpeg/start.c diff --git a/hemps8.5/applications/prod_cons/cons.c b/applications/prod_cons/cons.c similarity index 100% rename from hemps8.5/applications/prod_cons/cons.c rename to applications/prod_cons/cons.c diff --git a/hemps8.5/applications/prod_cons/prod.c b/applications/prod_cons/prod.c similarity index 100% rename from hemps8.5/applications/prod_cons/prod.c rename to applications/prod_cons/prod.c diff --git a/hemps8.5/applications/prod_cons/prod_cons.cfg b/applications/prod_cons/prod_cons.cfg similarity index 100% rename from hemps8.5/applications/prod_cons/prod_cons.cfg rename to applications/prod_cons/prod_cons.cfg diff --git a/hemps8.5/applications/prod_cons/prod_cons_std.h b/applications/prod_cons/prod_cons_std.h similarity index 100% rename from hemps8.5/applications/prod_cons/prod_cons_std.h rename to applications/prod_cons/prod_cons_std.h diff --git a/hemps8.5/applications/synthetic/syn_std.h b/applications/synthetic/syn_std.h similarity index 100% rename from hemps8.5/applications/synthetic/syn_std.h rename to applications/synthetic/syn_std.h diff --git a/hemps8.5/applications/synthetic/synthetic.cfg b/applications/synthetic/synthetic.cfg similarity index 100% rename from hemps8.5/applications/synthetic/synthetic.cfg rename to applications/synthetic/synthetic.cfg diff --git a/hemps8.5/applications/synthetic/taskA.c b/applications/synthetic/taskA.c similarity index 100% rename from hemps8.5/applications/synthetic/taskA.c rename to applications/synthetic/taskA.c diff --git a/hemps8.5/applications/synthetic/taskB.c b/applications/synthetic/taskB.c similarity index 100% rename from hemps8.5/applications/synthetic/taskB.c rename to applications/synthetic/taskB.c diff --git a/hemps8.5/applications/synthetic/taskC.c b/applications/synthetic/taskC.c similarity index 100% rename from hemps8.5/applications/synthetic/taskC.c rename to applications/synthetic/taskC.c diff --git a/hemps8.5/applications/synthetic/taskD.c b/applications/synthetic/taskD.c similarity index 100% rename from hemps8.5/applications/synthetic/taskD.c rename to applications/synthetic/taskD.c diff --git a/hemps8.5/applications/synthetic/taskE.c b/applications/synthetic/taskE.c similarity index 100% rename from hemps8.5/applications/synthetic/taskE.c rename to applications/synthetic/taskE.c diff --git a/hemps8.5/applications/synthetic/taskF.c b/applications/synthetic/taskF.c similarity index 100% rename from hemps8.5/applications/synthetic/taskF.c rename to applications/synthetic/taskF.c diff --git a/hemps8.5/build_env/HeMPS_Debugger.jar b/build_env/HeMPS_Debugger.jar similarity index 100% rename from hemps8.5/build_env/HeMPS_Debugger.jar rename to build_env/HeMPS_Debugger.jar diff --git a/hemps8.5/build_env/bin/hemps-debugger b/build_env/bin/hemps-debugger similarity index 100% rename from hemps8.5/build_env/bin/hemps-debugger rename to build_env/bin/hemps-debugger diff --git a/hemps8.5/build_env/bin/hemps-gen b/build_env/bin/hemps-gen similarity index 100% rename from hemps8.5/build_env/bin/hemps-gen rename to build_env/bin/hemps-gen diff --git a/hemps8.5/build_env/bin/hemps-run b/build_env/bin/hemps-run similarity index 100% rename from hemps8.5/build_env/bin/hemps-run rename to build_env/bin/hemps-run diff --git a/hemps8.5/build_env/bin/hemps-sortdebug b/build_env/bin/hemps-sortdebug similarity index 100% rename from hemps8.5/build_env/bin/hemps-sortdebug rename to build_env/bin/hemps-sortdebug diff --git a/hemps8.5/build_env/bin/hemps-wave_gen b/build_env/bin/hemps-wave_gen similarity index 100% rename from hemps8.5/build_env/bin/hemps-wave_gen rename to build_env/bin/hemps-wave_gen diff --git a/hemps8.5/build_env/bin/ram_generator b/build_env/bin/ram_generator similarity index 100% rename from hemps8.5/build_env/bin/ram_generator rename to build_env/bin/ram_generator diff --git a/hemps8.5/build_env/bin/ram_generator.c b/build_env/bin/ram_generator.c similarity index 100% rename from hemps8.5/build_env/bin/ram_generator.c rename to build_env/bin/ram_generator.c diff --git a/hemps8.5/build_env/deloream_env.py b/build_env/deloream_env.py similarity index 100% rename from hemps8.5/build_env/deloream_env.py rename to build_env/deloream_env.py diff --git a/hemps8.5/build_env/makes/make_all_apps b/build_env/makes/make_all_apps similarity index 100% rename from hemps8.5/build_env/makes/make_all_apps rename to build_env/makes/make_all_apps diff --git a/hemps8.5/build_env/makes/make_app b/build_env/makes/make_app similarity index 100% rename from hemps8.5/build_env/makes/make_app rename to build_env/makes/make_app diff --git a/hemps8.5/build_env/makes/make_kernel b/build_env/makes/make_kernel similarity index 100% rename from hemps8.5/build_env/makes/make_kernel rename to build_env/makes/make_kernel diff --git a/hemps8.5/build_env/makes/make_systemc b/build_env/makes/make_systemc similarity index 100% rename from hemps8.5/build_env/makes/make_systemc rename to build_env/makes/make_systemc diff --git a/hemps8.5/build_env/makes/make_systemc_mod b/build_env/makes/make_systemc_mod similarity index 100% rename from hemps8.5/build_env/makes/make_systemc_mod rename to build_env/makes/make_systemc_mod diff --git a/hemps8.5/build_env/makes/make_testcase b/build_env/makes/make_testcase similarity index 100% rename from hemps8.5/build_env/makes/make_testcase rename to build_env/makes/make_testcase diff --git a/hemps8.5/build_env/makes/make_vhdl b/build_env/makes/make_vhdl similarity index 100% rename from hemps8.5/build_env/makes/make_vhdl rename to build_env/makes/make_vhdl diff --git a/hemps8.5/build_env/makes/sim.do b/build_env/makes/sim.do similarity index 100% rename from hemps8.5/build_env/makes/sim.do rename to build_env/makes/sim.do diff --git a/hemps8.5/build_env/scripts/app_builder.py b/build_env/scripts/app_builder.py similarity index 100% rename from hemps8.5/build_env/scripts/app_builder.py rename to build_env/scripts/app_builder.py diff --git a/hemps8.5/build_env/scripts/banner.py b/build_env/scripts/banner.py similarity index 100% rename from hemps8.5/build_env/scripts/banner.py rename to build_env/scripts/banner.py diff --git a/hemps8.5/build_env/scripts/build_utils.py b/build_env/scripts/build_utils.py similarity index 100% rename from hemps8.5/build_env/scripts/build_utils.py rename to build_env/scripts/build_utils.py diff --git a/hemps8.5/build_env/scripts/hw_builder.py b/build_env/scripts/hw_builder.py similarity index 100% rename from hemps8.5/build_env/scripts/hw_builder.py rename to build_env/scripts/hw_builder.py diff --git a/hemps8.5/build_env/scripts/kernel_builder.py b/build_env/scripts/kernel_builder.py similarity index 100% rename from hemps8.5/build_env/scripts/kernel_builder.py rename to build_env/scripts/kernel_builder.py diff --git a/hemps8.5/build_env/scripts/yaml_intf.py b/build_env/scripts/yaml_intf.py similarity index 100% rename from hemps8.5/build_env/scripts/yaml_intf.py rename to build_env/scripts/yaml_intf.py diff --git a/hemps8.5/build_env/testcase_builder.py b/build_env/testcase_builder.py similarity index 100% rename from hemps8.5/build_env/testcase_builder.py rename to build_env/testcase_builder.py diff --git a/hemps8.5/docs/hemps_doxy.conf b/docs/hemps_doxy.conf similarity index 100% rename from hemps8.5/docs/hemps_doxy.conf rename to docs/hemps_doxy.conf diff --git a/hemps8.5/hardware/sc/hemps.cpp b/hardware/sc/hemps.cpp similarity index 100% rename from hemps8.5/hardware/sc/hemps.cpp rename to hardware/sc/hemps.cpp diff --git a/hemps8.5/hardware/sc/hemps.h b/hardware/sc/hemps.h similarity index 100% rename from hemps8.5/hardware/sc/hemps.h rename to hardware/sc/hemps.h diff --git a/hemps8.5/hardware/sc/pe/dmni/dmni.cpp b/hardware/sc/pe/dmni/dmni.cpp similarity index 100% rename from hemps8.5/hardware/sc/pe/dmni/dmni.cpp rename to hardware/sc/pe/dmni/dmni.cpp diff --git a/hemps8.5/hardware/sc/pe/dmni/dmni.h b/hardware/sc/pe/dmni/dmni.h similarity index 100% rename from hemps8.5/hardware/sc/pe/dmni/dmni.h rename to hardware/sc/pe/dmni/dmni.h diff --git a/hemps8.5/hardware/sc/pe/memory/ram.cpp b/hardware/sc/pe/memory/ram.cpp similarity index 100% rename from hemps8.5/hardware/sc/pe/memory/ram.cpp rename to hardware/sc/pe/memory/ram.cpp diff --git a/hemps8.5/hardware/sc/pe/memory/ram.h b/hardware/sc/pe/memory/ram.h similarity index 100% rename from hemps8.5/hardware/sc/pe/memory/ram.h rename to hardware/sc/pe/memory/ram.h diff --git a/hemps8.5/hardware/sc/pe/pe.cpp b/hardware/sc/pe/pe.cpp similarity index 100% rename from hemps8.5/hardware/sc/pe/pe.cpp rename to hardware/sc/pe/pe.cpp diff --git a/hemps8.5/hardware/sc/pe/pe.h b/hardware/sc/pe/pe.h similarity index 100% rename from hemps8.5/hardware/sc/pe/pe.h rename to hardware/sc/pe/pe.h diff --git a/hemps8.5/hardware/sc/pe/processor/plasma/mlite_cpu.cpp b/hardware/sc/pe/processor/plasma/mlite_cpu.cpp similarity index 100% rename from hemps8.5/hardware/sc/pe/processor/plasma/mlite_cpu.cpp rename to hardware/sc/pe/processor/plasma/mlite_cpu.cpp diff --git a/hemps8.5/hardware/sc/pe/processor/plasma/mlite_cpu.h b/hardware/sc/pe/processor/plasma/mlite_cpu.h similarity index 100% rename from hemps8.5/hardware/sc/pe/processor/plasma/mlite_cpu.h rename to hardware/sc/pe/processor/plasma/mlite_cpu.h diff --git a/hemps8.5/hardware/sc/pe/router/queue.cpp b/hardware/sc/pe/router/queue.cpp similarity index 100% rename from hemps8.5/hardware/sc/pe/router/queue.cpp rename to hardware/sc/pe/router/queue.cpp diff --git a/hemps8.5/hardware/sc/pe/router/queue.h b/hardware/sc/pe/router/queue.h similarity index 100% rename from hemps8.5/hardware/sc/pe/router/queue.h rename to hardware/sc/pe/router/queue.h diff --git a/hemps8.5/hardware/sc/pe/router/router_cc.cpp b/hardware/sc/pe/router/router_cc.cpp similarity index 100% rename from hemps8.5/hardware/sc/pe/router/router_cc.cpp rename to hardware/sc/pe/router/router_cc.cpp diff --git a/hemps8.5/hardware/sc/pe/router/router_cc.h b/hardware/sc/pe/router/router_cc.h similarity index 100% rename from hemps8.5/hardware/sc/pe/router/router_cc.h rename to hardware/sc/pe/router/router_cc.h diff --git a/hemps8.5/hardware/sc/pe/router/switchcontrol.cpp b/hardware/sc/pe/router/switchcontrol.cpp similarity index 100% rename from hemps8.5/hardware/sc/pe/router/switchcontrol.cpp rename to hardware/sc/pe/router/switchcontrol.cpp diff --git a/hemps8.5/hardware/sc/pe/router/switchcontrol.h b/hardware/sc/pe/router/switchcontrol.h similarity index 100% rename from hemps8.5/hardware/sc/pe/router/switchcontrol.h rename to hardware/sc/pe/router/switchcontrol.h diff --git a/hemps8.5/hardware/sc/standards.h b/hardware/sc/standards.h similarity index 100% rename from hemps8.5/hardware/sc/standards.h rename to hardware/sc/standards.h diff --git a/hemps8.5/hardware/sc/test_bench.cpp b/hardware/sc/test_bench.cpp similarity index 100% rename from hemps8.5/hardware/sc/test_bench.cpp rename to hardware/sc/test_bench.cpp diff --git a/hemps8.5/hardware/sc/test_bench.h b/hardware/sc/test_bench.h similarity index 100% rename from hemps8.5/hardware/sc/test_bench.h rename to hardware/sc/test_bench.h diff --git a/hemps8.5/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/hemps.vhd rename to hardware/vhdl/hemps.vhd diff --git a/hemps8.5/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/dmni/dmni.vhd rename to hardware/vhdl/pe/dmni/dmni.vhd diff --git a/hemps8.5/hardware/vhdl/pe/memory/ram.vhd b/hardware/vhdl/pe/memory/ram.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/memory/ram.vhd rename to hardware/vhdl/pe/memory/ram.vhd diff --git a/hemps8.5/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/pe.vhd rename to hardware/vhdl/pe/pe.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/UartFile.vhd b/hardware/vhdl/pe/processor/plasma/UartFile.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/UartFile.vhd rename to hardware/vhdl/pe/processor/plasma/UartFile.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/alu.vhd b/hardware/vhdl/pe/processor/plasma/alu.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/alu.vhd rename to hardware/vhdl/pe/processor/plasma/alu.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/bus_mux.vhd b/hardware/vhdl/pe/processor/plasma/bus_mux.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/bus_mux.vhd rename to hardware/vhdl/pe/processor/plasma/bus_mux.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/control.vhd b/hardware/vhdl/pe/processor/plasma/control.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/control.vhd rename to hardware/vhdl/pe/processor/plasma/control.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/mem_ctrl.vhd b/hardware/vhdl/pe/processor/plasma/mem_ctrl.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/mem_ctrl.vhd rename to hardware/vhdl/pe/processor/plasma/mem_ctrl.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/mlite_cpu.vhd b/hardware/vhdl/pe/processor/plasma/mlite_cpu.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/mlite_cpu.vhd rename to hardware/vhdl/pe/processor/plasma/mlite_cpu.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/mlite_pack.vhd b/hardware/vhdl/pe/processor/plasma/mlite_pack.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/mlite_pack.vhd rename to hardware/vhdl/pe/processor/plasma/mlite_pack.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/mult.vhd b/hardware/vhdl/pe/processor/plasma/mult.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/mult.vhd rename to hardware/vhdl/pe/processor/plasma/mult.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/pc_next.vhd b/hardware/vhdl/pe/processor/plasma/pc_next.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/pc_next.vhd rename to hardware/vhdl/pe/processor/plasma/pc_next.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/pipeline.vhd b/hardware/vhdl/pe/processor/plasma/pipeline.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/pipeline.vhd rename to hardware/vhdl/pe/processor/plasma/pipeline.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/reg_bank.vhd b/hardware/vhdl/pe/processor/plasma/reg_bank.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/reg_bank.vhd rename to hardware/vhdl/pe/processor/plasma/reg_bank.vhd diff --git a/hemps8.5/hardware/vhdl/pe/processor/plasma/shifter.vhd b/hardware/vhdl/pe/processor/plasma/shifter.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/processor/plasma/shifter.vhd rename to hardware/vhdl/pe/processor/plasma/shifter.vhd diff --git a/hemps8.5/hardware/vhdl/pe/router/Hermes_buffer.vhd b/hardware/vhdl/pe/router/Hermes_buffer.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/router/Hermes_buffer.vhd rename to hardware/vhdl/pe/router/Hermes_buffer.vhd diff --git a/hemps8.5/hardware/vhdl/pe/router/Hermes_crossbar.vhd b/hardware/vhdl/pe/router/Hermes_crossbar.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/router/Hermes_crossbar.vhd rename to hardware/vhdl/pe/router/Hermes_crossbar.vhd diff --git a/hemps8.5/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd rename to hardware/vhdl/pe/router/Hermes_switchcontrol.vhd diff --git a/hemps8.5/hardware/vhdl/pe/router/RouterCC.vhd b/hardware/vhdl/pe/router/RouterCC.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/pe/router/RouterCC.vhd rename to hardware/vhdl/pe/router/RouterCC.vhd diff --git a/hemps8.5/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/standards.vhd rename to hardware/vhdl/standards.vhd diff --git a/hemps8.5/hardware/vhdl/test_bench.vhd b/hardware/vhdl/test_bench.vhd similarity index 100% rename from hemps8.5/hardware/vhdl/test_bench.vhd rename to hardware/vhdl/test_bench.vhd diff --git a/hemps8.5/software/boot_task/boot_task.asm b/software/boot_task/boot_task.asm similarity index 100% rename from hemps8.5/software/boot_task/boot_task.asm rename to software/boot_task/boot_task.asm diff --git a/hemps8.5/software/include/api.h b/software/include/api.h similarity index 100% rename from hemps8.5/software/include/api.h rename to software/include/api.h diff --git a/hemps8.5/software/include/plasma.h b/software/include/plasma.h similarity index 100% rename from hemps8.5/software/include/plasma.h rename to software/include/plasma.h diff --git a/hemps8.5/software/include/services.h b/software/include/services.h similarity index 100% rename from hemps8.5/software/include/services.h rename to software/include/services.h diff --git a/hemps8.5/software/include/stdlib.h b/software/include/stdlib.h similarity index 100% rename from hemps8.5/software/include/stdlib.h rename to software/include/stdlib.h diff --git a/hemps8.5/software/kernel/master/boot.S b/software/kernel/master/boot.S similarity index 100% rename from hemps8.5/software/kernel/master/boot.S rename to software/kernel/master/boot.S diff --git a/hemps8.5/software/kernel/master/kernel_master.c b/software/kernel/master/kernel_master.c similarity index 100% rename from hemps8.5/software/kernel/master/kernel_master.c rename to software/kernel/master/kernel_master.c diff --git a/hemps8.5/software/kernel/master/kernel_master.h b/software/kernel/master/kernel_master.h similarity index 100% rename from hemps8.5/software/kernel/master/kernel_master.h rename to software/kernel/master/kernel_master.h diff --git a/hemps8.5/software/kernel/slave/boot.S b/software/kernel/slave/boot.S similarity index 100% rename from hemps8.5/software/kernel/slave/boot.S rename to software/kernel/slave/boot.S diff --git a/hemps8.5/software/kernel/slave/kernel_slave.c b/software/kernel/slave/kernel_slave.c similarity index 100% rename from hemps8.5/software/kernel/slave/kernel_slave.c rename to software/kernel/slave/kernel_slave.c diff --git a/hemps8.5/software/kernel/slave/kernel_slave.h b/software/kernel/slave/kernel_slave.h similarity index 100% rename from hemps8.5/software/kernel/slave/kernel_slave.h rename to software/kernel/slave/kernel_slave.h diff --git a/hemps8.5/software/modules/applications.c b/software/modules/applications.c similarity index 100% rename from hemps8.5/software/modules/applications.c rename to software/modules/applications.c diff --git a/hemps8.5/software/modules/applications.h b/software/modules/applications.h similarity index 100% rename from hemps8.5/software/modules/applications.h rename to software/modules/applications.h diff --git a/hemps8.5/software/modules/communication.c b/software/modules/communication.c similarity index 100% rename from hemps8.5/software/modules/communication.c rename to software/modules/communication.c diff --git a/hemps8.5/software/modules/communication.h b/software/modules/communication.h similarity index 100% rename from hemps8.5/software/modules/communication.h rename to software/modules/communication.h diff --git a/hemps8.5/software/modules/new_task.c b/software/modules/new_task.c similarity index 100% rename from hemps8.5/software/modules/new_task.c rename to software/modules/new_task.c diff --git a/hemps8.5/software/modules/new_task.h b/software/modules/new_task.h similarity index 100% rename from hemps8.5/software/modules/new_task.h rename to software/modules/new_task.h diff --git a/hemps8.5/software/modules/packet.c b/software/modules/packet.c similarity index 100% rename from hemps8.5/software/modules/packet.c rename to software/modules/packet.c diff --git a/hemps8.5/software/modules/packet.h b/software/modules/packet.h similarity index 100% rename from hemps8.5/software/modules/packet.h rename to software/modules/packet.h diff --git a/hemps8.5/software/modules/pending_service.c b/software/modules/pending_service.c similarity index 100% rename from hemps8.5/software/modules/pending_service.c rename to software/modules/pending_service.c diff --git a/hemps8.5/software/modules/pending_service.h b/software/modules/pending_service.h similarity index 100% rename from hemps8.5/software/modules/pending_service.h rename to software/modules/pending_service.h diff --git a/hemps8.5/software/modules/processors.c b/software/modules/processors.c similarity index 100% rename from hemps8.5/software/modules/processors.c rename to software/modules/processors.c diff --git a/hemps8.5/software/modules/processors.h b/software/modules/processors.h similarity index 100% rename from hemps8.5/software/modules/processors.h rename to software/modules/processors.h diff --git a/hemps8.5/software/modules/reclustering.c b/software/modules/reclustering.c similarity index 100% rename from hemps8.5/software/modules/reclustering.c rename to software/modules/reclustering.c diff --git a/hemps8.5/software/modules/reclustering.h b/software/modules/reclustering.h similarity index 100% rename from hemps8.5/software/modules/reclustering.h rename to software/modules/reclustering.h diff --git a/hemps8.5/software/modules/resource_manager.c b/software/modules/resource_manager.c similarity index 100% rename from hemps8.5/software/modules/resource_manager.c rename to software/modules/resource_manager.c diff --git a/hemps8.5/software/modules/resource_manager.h b/software/modules/resource_manager.h similarity index 100% rename from hemps8.5/software/modules/resource_manager.h rename to software/modules/resource_manager.h diff --git a/hemps8.5/software/modules/task_control.c b/software/modules/task_control.c similarity index 100% rename from hemps8.5/software/modules/task_control.c rename to software/modules/task_control.c diff --git a/hemps8.5/software/modules/task_control.h b/software/modules/task_control.h similarity index 100% rename from hemps8.5/software/modules/task_control.h rename to software/modules/task_control.h diff --git a/hemps8.5/software/modules/task_location.c b/software/modules/task_location.c similarity index 100% rename from hemps8.5/software/modules/task_location.c rename to software/modules/task_location.c diff --git a/hemps8.5/software/modules/task_location.h b/software/modules/task_location.h similarity index 100% rename from hemps8.5/software/modules/task_location.h rename to software/modules/task_location.h diff --git a/hemps8.5/software/modules/task_migration.c b/software/modules/task_migration.c similarity index 100% rename from hemps8.5/software/modules/task_migration.c rename to software/modules/task_migration.c diff --git a/hemps8.5/software/modules/task_migration.h b/software/modules/task_migration.h similarity index 100% rename from hemps8.5/software/modules/task_migration.h rename to software/modules/task_migration.h diff --git a/hemps8.5/software/modules/task_scheduler.c b/software/modules/task_scheduler.c similarity index 100% rename from hemps8.5/software/modules/task_scheduler.c rename to software/modules/task_scheduler.c diff --git a/hemps8.5/software/modules/task_scheduler.h b/software/modules/task_scheduler.h similarity index 100% rename from hemps8.5/software/modules/task_scheduler.h rename to software/modules/task_scheduler.h diff --git a/hemps8.5/software/modules/utils.c b/software/modules/utils.c similarity index 100% rename from hemps8.5/software/modules/utils.c rename to software/modules/utils.c diff --git a/hemps8.5/software/modules/utils.h b/software/modules/utils.h similarity index 100% rename from hemps8.5/software/modules/utils.h rename to software/modules/utils.h diff --git a/hemps8.5/testcases/example.yaml b/testcases/example.yaml similarity index 100% rename from hemps8.5/testcases/example.yaml rename to testcases/example.yaml diff --git a/hemps8.5/testcases/regression/12x12_4x4_2t.yaml b/testcases/regression/12x12_4x4_2t.yaml similarity index 100% rename from hemps8.5/testcases/regression/12x12_4x4_2t.yaml rename to testcases/regression/12x12_4x4_2t.yaml diff --git a/hemps8.5/testcases/regression/16x16_4x4_2t.yaml b/testcases/regression/16x16_4x4_2t.yaml similarity index 100% rename from hemps8.5/testcases/regression/16x16_4x4_2t.yaml rename to testcases/regression/16x16_4x4_2t.yaml diff --git a/hemps8.5/testcases/regression/3x3_3x3_2t.yaml b/testcases/regression/3x3_3x3_2t.yaml similarity index 100% rename from hemps8.5/testcases/regression/3x3_3x3_2t.yaml rename to testcases/regression/3x3_3x3_2t.yaml diff --git a/hemps8.5/testcases/regression/6x6_3x3_2t.yaml b/testcases/regression/6x6_3x3_2t.yaml similarity index 100% rename from hemps8.5/testcases/regression/6x6_3x3_2t.yaml rename to testcases/regression/6x6_3x3_2t.yaml diff --git a/hemps8.5/testcases/regression/8x8_4x4_2t.yaml b/testcases/regression/8x8_4x4_2t.yaml similarity index 100% rename from hemps8.5/testcases/regression/8x8_4x4_2t.yaml rename to testcases/regression/8x8_4x4_2t.yaml diff --git a/hemps8.5/testcases/regression/8x8_4x4_3t.yaml b/testcases/regression/8x8_4x4_3t.yaml similarity index 100% rename from hemps8.5/testcases/regression/8x8_4x4_3t.yaml rename to testcases/regression/8x8_4x4_3t.yaml diff --git a/hemps8.5/testcases/regression/8x8_4x4_4t.yaml b/testcases/regression/8x8_4x4_4t.yaml similarity index 100% rename from hemps8.5/testcases/regression/8x8_4x4_4t.yaml rename to testcases/regression/8x8_4x4_4t.yaml diff --git a/hemps8.5/testcases/regression/9x9_3x3_2t.yaml b/testcases/regression/9x9_3x3_2t.yaml similarity index 100% rename from hemps8.5/testcases/regression/9x9_3x3_2t.yaml rename to testcases/regression/9x9_3x3_2t.yaml diff --git a/hemps8.5/testcases/regression/9x9_3x3_3t.yaml b/testcases/regression/9x9_3x3_3t.yaml similarity index 100% rename from hemps8.5/testcases/regression/9x9_3x3_3t.yaml rename to testcases/regression/9x9_3x3_3t.yaml diff --git a/hemps8.5/testcases/regression/9x9_3x3_4t.yaml b/testcases/regression/9x9_3x3_4t.yaml similarity index 100% rename from hemps8.5/testcases/regression/9x9_3x3_4t.yaml rename to testcases/regression/9x9_3x3_4t.yaml From d132027cf44bf8fa1eb0c1bf152928be845a2827 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Sun, 27 Aug 2017 14:28:13 -0300 Subject: [PATCH 02/54] Routers modified to allow manual border routing, noc top generator modified to allow authorize manual routing only on border routers --- hardware/vhdl/hemps.vhd | 9 +- hardware/vhdl/pe/pe.vhd | 89 ++++++++++--------- .../vhdl/pe/router/Hermes_switchcontrol.vhd | 86 ++++++++++++++---- hardware/vhdl/pe/router/RouterCC.vhd | 75 +++++++++------- hardware/vhdl/standards.vhd | 47 +++++++++- 5 files changed, 213 insertions(+), 93 deletions(-) diff --git a/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd index f1d896d..5f3017f 100644 --- a/hardware/vhdl/hemps.vhd +++ b/hardware/vhdl/hemps.vhd @@ -80,8 +80,11 @@ architecture HeMPS of HeMPS is generic map ( router_address => RouterAddress(i), kernel_type => pe_type(i), - log_file => log_filename(i) - ) + log_file => log_filename(i), + manual_EAST => manualEASTByPos(i), + manual_WEST => manualWESTByPos(i), + manual_NORTH => manualNORTHByPos(i), + manual_SOUTH => manualSOUTHByPos(i)) port map( clock => clock, reset => reset, @@ -192,4 +195,4 @@ architecture HeMPS of HeMPS is end generate; end generate proc; -end architecture; \ No newline at end of file +end architecture; diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 5818de4..b4bee3c 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -17,35 +17,40 @@ library unisim; use unisim.vcomponents.all; entity pe is - generic + generic ( - log_file : string := "output.txt"; - router_address : regmetadeflit:= (others=>'0'); - kernel_type : kernel_str - ); - port - ( - clock : in std_logic; - reset : in std_logic; - -- NoC - clock_rx : in std_logic_vector(3 downto 0); - rx : in std_logic_vector(3 downto 0); - data_in : in arrayNPORT_1_regflit; - credit_o : out std_logic_vector(3 downto 0); - clock_tx : out std_logic_vector(3 downto 0); - tx : out std_logic_vector(3 downto 0); - data_out : out arrayNPORT_1_regflit; - credit_i : in std_logic_vector(3 downto 0); - -- External Memory - repo_address : out std_logic_vector(29 downto 0); - repo_data_read : in std_logic_vector(31 downto 0); - ack_app : out std_logic; - req_app : in std_logic_vector(31 downto 0) - -- External Debug interface + log_file : string := "output.txt"; + router_address : regmetadeflit := (others => '0'); + kernel_type : kernel_str + manual_NORTH : boolean := false; + manual_SOUTH : boolean := false; + manual_LOCAL : boolean := false; + manual_EAST : boolean := false; + manual_WEST : boolean := false; + ); + port + ( + clock : in std_logic; + reset : in std_logic; + -- NoC + clock_rx : in std_logic_vector(3 downto 0); + rx : in std_logic_vector(3 downto 0); + data_in : in arrayNPORT_1_regflit; + credit_o : out std_logic_vector(3 downto 0); + clock_tx : out std_logic_vector(3 downto 0); + tx : out std_logic_vector(3 downto 0); + data_out : out arrayNPORT_1_regflit; + credit_i : in std_logic_vector(3 downto 0); + -- External Memory + repo_address : out std_logic_vector(29 downto 0); + repo_data_read : in std_logic_vector(31 downto 0); + ack_app : out std_logic; + req_app : in std_logic_vector(31 downto 0) + -- External Debug interface -- write_enable_debug : out std_logic; -- data_out_debug : out std_logic_vector(31 downto 0); -- busy_debug : in std_logic - ); + ); end entity pe; architecture structural of pe is @@ -167,20 +172,24 @@ slave: if kernel_type = "sla" generate ); end generate; - router : Entity work.RouterCC - generic map(address => router_address) - port map( - clock => clock, - reset => reset, - clock_rx => clock_rx_router, - rx => rx_router, - data_in => data_in_router, - credit_o => credit_o_router, - clock_tx => clock_tx_router, - tx => tx_router, - data_out => data_out_router, - credit_i => credit_i_router - ); + router : entity work.RouterCC + generic map(address => router_address, + manual_NORTH => manual_NORTH, + manual_SOUTH => manual_SOUTH, + manual_EAST => manual_EAST, + manual_WEST => manual_WEST) + port map( + clock => clock, + reset => reset, + clock_rx => clock_rx_router, + rx => rx_router, + data_in => data_in_router, + credit_o => credit_o_router, + clock_tx => clock_tx_router, + tx => tx_router, + data_out => data_out_router, + credit_i => credit_i_router + ); dmni : entity work.dmni @@ -418,4 +427,4 @@ end generate; end architecture structural; - \ No newline at end of file + diff --git a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd index 2f8ab2b..b74ad38 100644 --- a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd +++ b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd @@ -18,6 +18,12 @@ use IEEE.STD_LOGIC_unsigned.all; use work.standards.all; entity SwitchControl is +generic ( + manual_NORTH : boolean := false; + manual_SOUTH : boolean := false; + manual_EAST: boolean := false; + manual_WEST: boolean := false; + ); port( clock : in std_logic; reset : in std_logic; @@ -49,6 +55,10 @@ signal auxfree: regNport := (others=> '0'); signal source: arrayNport_reg3 := (others=> (others=> '0')); signal sender_ant: regNport := (others=> '0'); +signal manual_routing_flag : std_logic; +signal manual_routing_sel : integer range 0 to (NPORT-1) := 0; +signal manual_routing_en : boolean; + begin ask <= '1' when h(LOCAL)='1' or h(EAST)='1' or h(WEST)='1' or h(NORTH)='1' or h(SOUTH)='1' else '0'; @@ -98,8 +108,11 @@ begin tx <= header((METADEFLIT - 1) downto QUARTOFLIT); ty <= header((QUARTOFLIT - 1) downto 0); - dirx <= WEST when lx > tx else EAST; - diry <= NORTH when ly < ty else SOUTH; + manual_routing_flag <= header(TAM_FLIT-1); + manual_routing_sel <= header(TAM_FLIT-2 downto TAM_FLIT-3); + + dirx <= WEST when lx > tx or (manual_WEST and manual_routing_sel=WEST) else EAST; + diry <= NORTH when ly < ty or (manual_NORTH and manual_routing_sel=NORTH) else SOUTH; process(reset,clock) begin @@ -137,21 +150,62 @@ begin -- S7 -> O estado S7 � necess�rio para que a porta selecionada para roteamento baixe o sinal -- h. -- - process(ES,ask,h,lx,ly,tx,ty,auxfree,dirx,diry) + + process(manual_routing_flag, manual_routing_sel) begin - case ES is - when S0 => PES <= S1; - when S1 => if ask='1' then PES <= S2; else PES <= S1; end if; - when S2 => PES <= S3; - when S3 => if lx = tx and ly = ty and auxfree(LOCAL)='1' then PES<=S4; - elsif lx /= tx and auxfree(dirx)='1' then PES<=S5; - elsif lx = tx and ly /= ty and auxfree(diry)='1' then PES<=S6; - else PES<=S1; end if; - when S4 => PES<=S7; - when S5 => PES<=S7; - when S6 => PES<=S7; - when S7 => PES<=S1; - end case; + if manual_routing_flag = '1' then + case manual_routing_sel is + when WEST => manual_routing_en <= manual_WEST; + when EAST => manual_routing_en <= manual_EAST; + when NORTH => manual_routing_en <= manual_NORTH; + when SOUTH => manual_routing_en <= manual_SOUTH; + when others => manual_routing_en <= false; + end case; + else + manual_routing_en <= false; + end if; + end process; + + process(ES, ask, h, lx, ly, tx, ty, auxfree, dirx, diry) + begin + case ES is + when S0 => PES <= S1; + when S1 => + if ask = '1' then PES <= S2; else PES <= S1; end if; + when S2 => PES <= S3; + when S3 => + if lx = tx and ly = ty then + if (not manual_routing_en) and auxfree(LOCAL) = '1' then PES <= S4; + elsif manual_routing_en then + case manual_routing_sel is + when EAST|WEST => + if auxfree(dirx) = '1' then + PES <= S5; + else + PES <= S1; + end if; + when NORTH|SOUTH => + if auxfree(diry) = '1' then + PES <= S6; + else + PES <= S1; + end if; + when others => + if auxfree(LOCAL) = '1' then + PES <= S4; + else + PES <= S1; + end if; + end case; + end if; + elsif lx /= tx and auxfree(dirx) = '1' then PES <= S5; + elsif lx = tx and ly /= ty and auxfree(diry) = '1' then PES <= S6; + else PES <= S1; end if; + when S4 => PES <= S7; + when S5 => PES <= S7; + when S6 => PES <= S7; + when S7 => PES <= S1; + end case; end process; ------------------------------------------------------------------------------------------------------ diff --git a/hardware/vhdl/pe/router/RouterCC.vhd b/hardware/vhdl/pe/router/RouterCC.vhd index 9108fd1..9ad2692 100644 --- a/hardware/vhdl/pe/router/RouterCC.vhd +++ b/hardware/vhdl/pe/router/RouterCC.vhd @@ -25,14 +25,14 @@ use std.textio.all; use IEEE.NUMERIC_STD.all; entity traffic_monitor is - generic( ID : integer ); -port( - clock : in std_logic; - reset : in std_logic; - data_in : in regflit; - address : in regmetadeflit; - rx : in std_logic; - credit_o : in std_logic ); + generic(ID : integer); + port( + clock : in std_logic; + reset : in std_logic; + data_in : in regflit; + address : in regmetadeflit; + rx : in std_logic; + credit_o : in std_logic); end traffic_monitor; architecture arq_traffic of traffic_monitor is @@ -269,18 +269,22 @@ use std.textio.all; use IEEE.NUMERIC_STD.all; entity RouterCC is -generic( address: regmetadeflit); -port( - clock: in std_logic; - reset: in std_logic; - clock_rx: in regNport; - rx: in regNport; - data_in: in arrayNport_regflit; - credit_o: out regNport; - clock_tx: out regNport; - tx: out regNport; - data_out: out arrayNport_regflit; - credit_i: in regNport); + generic(address : regmetadeflit; + manual_NORTH : boolean := false; + manual_SOUTH : boolean := false; + manual_EAST : boolean := false; + manual_WEST : boolean := false); + port( + clock : in std_logic; + reset : in std_logic; + clock_rx : in regNport; + rx : in regNport; + data_in : in arrayNport_regflit; + credit_o : out regNport; + clock_tx : out regNport; + tx : out regNport; + data_out : out arrayNport_regflit; + credit_i : in regNport); end RouterCC; architecture RouterCC of RouterCC is @@ -307,7 +311,7 @@ begin credit_o <= credit_o_sig; traffic_router: for i in 0 to (NPORT-1) generate traffic_monit : entity work.traffic_monitor - generic map( ID => i ) + generic map( ID => i ) port map( clock => clock, reset => reset, @@ -393,18 +397,23 @@ begin data_ack => data_ack(4), credit_o => credit_o_sig(4)); - SwitchControl : Entity work.SwitchControl(XY) - port map( - clock => clock, - reset => reset, - h => h, - ack_h => ack_h, - address => address, - data => data, - sender => sender, - free => free, - mux_in => mux_in, - mux_out => mux_out); + SwitchControl : Entity work.SwitchControl(XY) + generic map( + manual_NORTH => manual_NORTH, + manual_SOUTH => manual_SOUTH, + manual_EAST => manual_EAST, + manual_WEST => manual_WEST) + port map( + clock => clock, + reset => reset, + h => h, + ack_h => ack_h, + address => address, + data => data, + sender => sender, + free => free, + mux_in => mux_in, + mux_out => mux_out); CrossBar : Entity work.Hermes_crossbar port map( diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index 8f0b1b7..8916d5f 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -334,7 +334,52 @@ package body standards is return pos; - end RouterPosition; + end RouterPosition; + + function ManualEASTbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = TL) or (pos = CL) or (pos = BL) then + return true; + else + return false; + end if; + end ManualEASTbyPos; + + function ManualWESTbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = TR) or (pos = CRX) or (pos = BR) then + return true; + else + return false; + end if; + end ManualWESTbyPos; + + function ManualNORTHbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = TL) or (pos = TC) or (pos = TR) then + return true; + else + return false; + end if; + end ManualNORTHbyPos; + + function ManualSOUTHbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = BR) or (pos = BC) or (pos = BR) then + return true; + else + return false; + end if; + end ManualSOUTHbyPos; + function RouterAddress(router: integer) return std_logic_vector is variable pos_x, pos_y : regquartoflit; From cc7111c8a3cf746c203b7876a4032fd9f51e7ff1 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Sun, 27 Aug 2017 14:28:13 -0300 Subject: [PATCH 03/54] Routers modified to allow manual border routing, noc top generator modified to allow authorize manual routing only on border routers --- hardware/vhdl/hemps.vhd | 9 +- hardware/vhdl/pe/pe.vhd | 88 ++++++++++--------- .../vhdl/pe/router/Hermes_switchcontrol.vhd | 86 ++++++++++++++---- hardware/vhdl/pe/router/RouterCC.vhd | 75 +++++++++------- hardware/vhdl/standards.vhd | 47 +++++++++- 5 files changed, 212 insertions(+), 93 deletions(-) diff --git a/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd index f1d896d..5f3017f 100644 --- a/hardware/vhdl/hemps.vhd +++ b/hardware/vhdl/hemps.vhd @@ -80,8 +80,11 @@ architecture HeMPS of HeMPS is generic map ( router_address => RouterAddress(i), kernel_type => pe_type(i), - log_file => log_filename(i) - ) + log_file => log_filename(i), + manual_EAST => manualEASTByPos(i), + manual_WEST => manualWESTByPos(i), + manual_NORTH => manualNORTHByPos(i), + manual_SOUTH => manualSOUTHByPos(i)) port map( clock => clock, reset => reset, @@ -192,4 +195,4 @@ architecture HeMPS of HeMPS is end generate; end generate proc; -end architecture; \ No newline at end of file +end architecture; diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 5818de4..ef227c8 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -17,35 +17,39 @@ library unisim; use unisim.vcomponents.all; entity pe is - generic + generic ( - log_file : string := "output.txt"; - router_address : regmetadeflit:= (others=>'0'); - kernel_type : kernel_str - ); - port - ( - clock : in std_logic; - reset : in std_logic; - -- NoC - clock_rx : in std_logic_vector(3 downto 0); - rx : in std_logic_vector(3 downto 0); - data_in : in arrayNPORT_1_regflit; - credit_o : out std_logic_vector(3 downto 0); - clock_tx : out std_logic_vector(3 downto 0); - tx : out std_logic_vector(3 downto 0); - data_out : out arrayNPORT_1_regflit; - credit_i : in std_logic_vector(3 downto 0); - -- External Memory - repo_address : out std_logic_vector(29 downto 0); - repo_data_read : in std_logic_vector(31 downto 0); - ack_app : out std_logic; - req_app : in std_logic_vector(31 downto 0) - -- External Debug interface + log_file : string := "output.txt"; + router_address : regmetadeflit := (others => '0'); + kernel_type : kernel_str + manual_NORTH : boolean := false; + manual_SOUTH : boolean := false; + manual_EAST : boolean := false; + manual_WEST : boolean := false; + ); + port + ( + clock : in std_logic; + reset : in std_logic; + -- NoC + clock_rx : in std_logic_vector(3 downto 0); + rx : in std_logic_vector(3 downto 0); + data_in : in arrayNPORT_1_regflit; + credit_o : out std_logic_vector(3 downto 0); + clock_tx : out std_logic_vector(3 downto 0); + tx : out std_logic_vector(3 downto 0); + data_out : out arrayNPORT_1_regflit; + credit_i : in std_logic_vector(3 downto 0); + -- External Memory + repo_address : out std_logic_vector(29 downto 0); + repo_data_read : in std_logic_vector(31 downto 0); + ack_app : out std_logic; + req_app : in std_logic_vector(31 downto 0) + -- External Debug interface -- write_enable_debug : out std_logic; -- data_out_debug : out std_logic_vector(31 downto 0); -- busy_debug : in std_logic - ); + ); end entity pe; architecture structural of pe is @@ -167,20 +171,24 @@ slave: if kernel_type = "sla" generate ); end generate; - router : Entity work.RouterCC - generic map(address => router_address) - port map( - clock => clock, - reset => reset, - clock_rx => clock_rx_router, - rx => rx_router, - data_in => data_in_router, - credit_o => credit_o_router, - clock_tx => clock_tx_router, - tx => tx_router, - data_out => data_out_router, - credit_i => credit_i_router - ); + router : entity work.RouterCC + generic map(address => router_address, + manual_NORTH => manual_NORTH, + manual_SOUTH => manual_SOUTH, + manual_EAST => manual_EAST, + manual_WEST => manual_WEST) + port map( + clock => clock, + reset => reset, + clock_rx => clock_rx_router, + rx => rx_router, + data_in => data_in_router, + credit_o => credit_o_router, + clock_tx => clock_tx_router, + tx => tx_router, + data_out => data_out_router, + credit_i => credit_i_router + ); dmni : entity work.dmni @@ -418,4 +426,4 @@ end generate; end architecture structural; - \ No newline at end of file + diff --git a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd index 2f8ab2b..b74ad38 100644 --- a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd +++ b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd @@ -18,6 +18,12 @@ use IEEE.STD_LOGIC_unsigned.all; use work.standards.all; entity SwitchControl is +generic ( + manual_NORTH : boolean := false; + manual_SOUTH : boolean := false; + manual_EAST: boolean := false; + manual_WEST: boolean := false; + ); port( clock : in std_logic; reset : in std_logic; @@ -49,6 +55,10 @@ signal auxfree: regNport := (others=> '0'); signal source: arrayNport_reg3 := (others=> (others=> '0')); signal sender_ant: regNport := (others=> '0'); +signal manual_routing_flag : std_logic; +signal manual_routing_sel : integer range 0 to (NPORT-1) := 0; +signal manual_routing_en : boolean; + begin ask <= '1' when h(LOCAL)='1' or h(EAST)='1' or h(WEST)='1' or h(NORTH)='1' or h(SOUTH)='1' else '0'; @@ -98,8 +108,11 @@ begin tx <= header((METADEFLIT - 1) downto QUARTOFLIT); ty <= header((QUARTOFLIT - 1) downto 0); - dirx <= WEST when lx > tx else EAST; - diry <= NORTH when ly < ty else SOUTH; + manual_routing_flag <= header(TAM_FLIT-1); + manual_routing_sel <= header(TAM_FLIT-2 downto TAM_FLIT-3); + + dirx <= WEST when lx > tx or (manual_WEST and manual_routing_sel=WEST) else EAST; + diry <= NORTH when ly < ty or (manual_NORTH and manual_routing_sel=NORTH) else SOUTH; process(reset,clock) begin @@ -137,21 +150,62 @@ begin -- S7 -> O estado S7 � necess�rio para que a porta selecionada para roteamento baixe o sinal -- h. -- - process(ES,ask,h,lx,ly,tx,ty,auxfree,dirx,diry) + + process(manual_routing_flag, manual_routing_sel) begin - case ES is - when S0 => PES <= S1; - when S1 => if ask='1' then PES <= S2; else PES <= S1; end if; - when S2 => PES <= S3; - when S3 => if lx = tx and ly = ty and auxfree(LOCAL)='1' then PES<=S4; - elsif lx /= tx and auxfree(dirx)='1' then PES<=S5; - elsif lx = tx and ly /= ty and auxfree(diry)='1' then PES<=S6; - else PES<=S1; end if; - when S4 => PES<=S7; - when S5 => PES<=S7; - when S6 => PES<=S7; - when S7 => PES<=S1; - end case; + if manual_routing_flag = '1' then + case manual_routing_sel is + when WEST => manual_routing_en <= manual_WEST; + when EAST => manual_routing_en <= manual_EAST; + when NORTH => manual_routing_en <= manual_NORTH; + when SOUTH => manual_routing_en <= manual_SOUTH; + when others => manual_routing_en <= false; + end case; + else + manual_routing_en <= false; + end if; + end process; + + process(ES, ask, h, lx, ly, tx, ty, auxfree, dirx, diry) + begin + case ES is + when S0 => PES <= S1; + when S1 => + if ask = '1' then PES <= S2; else PES <= S1; end if; + when S2 => PES <= S3; + when S3 => + if lx = tx and ly = ty then + if (not manual_routing_en) and auxfree(LOCAL) = '1' then PES <= S4; + elsif manual_routing_en then + case manual_routing_sel is + when EAST|WEST => + if auxfree(dirx) = '1' then + PES <= S5; + else + PES <= S1; + end if; + when NORTH|SOUTH => + if auxfree(diry) = '1' then + PES <= S6; + else + PES <= S1; + end if; + when others => + if auxfree(LOCAL) = '1' then + PES <= S4; + else + PES <= S1; + end if; + end case; + end if; + elsif lx /= tx and auxfree(dirx) = '1' then PES <= S5; + elsif lx = tx and ly /= ty and auxfree(diry) = '1' then PES <= S6; + else PES <= S1; end if; + when S4 => PES <= S7; + when S5 => PES <= S7; + when S6 => PES <= S7; + when S7 => PES <= S1; + end case; end process; ------------------------------------------------------------------------------------------------------ diff --git a/hardware/vhdl/pe/router/RouterCC.vhd b/hardware/vhdl/pe/router/RouterCC.vhd index 9108fd1..9ad2692 100644 --- a/hardware/vhdl/pe/router/RouterCC.vhd +++ b/hardware/vhdl/pe/router/RouterCC.vhd @@ -25,14 +25,14 @@ use std.textio.all; use IEEE.NUMERIC_STD.all; entity traffic_monitor is - generic( ID : integer ); -port( - clock : in std_logic; - reset : in std_logic; - data_in : in regflit; - address : in regmetadeflit; - rx : in std_logic; - credit_o : in std_logic ); + generic(ID : integer); + port( + clock : in std_logic; + reset : in std_logic; + data_in : in regflit; + address : in regmetadeflit; + rx : in std_logic; + credit_o : in std_logic); end traffic_monitor; architecture arq_traffic of traffic_monitor is @@ -269,18 +269,22 @@ use std.textio.all; use IEEE.NUMERIC_STD.all; entity RouterCC is -generic( address: regmetadeflit); -port( - clock: in std_logic; - reset: in std_logic; - clock_rx: in regNport; - rx: in regNport; - data_in: in arrayNport_regflit; - credit_o: out regNport; - clock_tx: out regNport; - tx: out regNport; - data_out: out arrayNport_regflit; - credit_i: in regNport); + generic(address : regmetadeflit; + manual_NORTH : boolean := false; + manual_SOUTH : boolean := false; + manual_EAST : boolean := false; + manual_WEST : boolean := false); + port( + clock : in std_logic; + reset : in std_logic; + clock_rx : in regNport; + rx : in regNport; + data_in : in arrayNport_regflit; + credit_o : out regNport; + clock_tx : out regNport; + tx : out regNport; + data_out : out arrayNport_regflit; + credit_i : in regNport); end RouterCC; architecture RouterCC of RouterCC is @@ -307,7 +311,7 @@ begin credit_o <= credit_o_sig; traffic_router: for i in 0 to (NPORT-1) generate traffic_monit : entity work.traffic_monitor - generic map( ID => i ) + generic map( ID => i ) port map( clock => clock, reset => reset, @@ -393,18 +397,23 @@ begin data_ack => data_ack(4), credit_o => credit_o_sig(4)); - SwitchControl : Entity work.SwitchControl(XY) - port map( - clock => clock, - reset => reset, - h => h, - ack_h => ack_h, - address => address, - data => data, - sender => sender, - free => free, - mux_in => mux_in, - mux_out => mux_out); + SwitchControl : Entity work.SwitchControl(XY) + generic map( + manual_NORTH => manual_NORTH, + manual_SOUTH => manual_SOUTH, + manual_EAST => manual_EAST, + manual_WEST => manual_WEST) + port map( + clock => clock, + reset => reset, + h => h, + ack_h => ack_h, + address => address, + data => data, + sender => sender, + free => free, + mux_in => mux_in, + mux_out => mux_out); CrossBar : Entity work.Hermes_crossbar port map( diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index 8f0b1b7..8916d5f 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -334,7 +334,52 @@ package body standards is return pos; - end RouterPosition; + end RouterPosition; + + function ManualEASTbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = TL) or (pos = CL) or (pos = BL) then + return true; + else + return false; + end if; + end ManualEASTbyPos; + + function ManualWESTbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = TR) or (pos = CRX) or (pos = BR) then + return true; + else + return false; + end if; + end ManualWESTbyPos; + + function ManualNORTHbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = TL) or (pos = TC) or (pos = TR) then + return true; + else + return false; + end if; + end ManualNORTHbyPos; + + function ManualSOUTHbyPos(router : integer) return boolean is + variable pos : integer; + begin + pos := RouterPosition(router); + if (pos = BR) or (pos = BC) or (pos = BR) then + return true; + else + return false; + end if; + end ManualSOUTHbyPos; + function RouterAddress(router: integer) return std_logic_vector is variable pos_x, pos_y : regquartoflit; From cc1d97e5d6ea719d3b20acccb64c09813ba0580b Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Sun, 27 Aug 2017 16:11:47 -0300 Subject: [PATCH 04/54] VHDL syntetic corrections --- hardware/vhdl/hemps.vhd | 8 +- hardware/vhdl/pe/pe.vhd | 5 +- .../vhdl/pe/router/Hermes_switchcontrol.vhd | 7 +- hardware/vhdl/standards.vhd | 682 +++++++++--------- 4 files changed, 353 insertions(+), 349 deletions(-) diff --git a/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd index 5f3017f..573c377 100644 --- a/hardware/vhdl/hemps.vhd +++ b/hardware/vhdl/hemps.vhd @@ -81,10 +81,10 @@ architecture HeMPS of HeMPS is router_address => RouterAddress(i), kernel_type => pe_type(i), log_file => log_filename(i), - manual_EAST => manualEASTByPos(i), - manual_WEST => manualWESTByPos(i), - manual_NORTH => manualNORTHByPos(i), - manual_SOUTH => manualSOUTHByPos(i)) + manual_EAST => ManualEASTByPos(i), + manual_WEST => ManualWESTByPos(i), + manual_NORTH => ManualNORTHByPos(i), + manual_SOUTH => ManualSOUTHByPos(i)) port map( clock => clock, reset => reset, diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 2724cab..8363cc1 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -21,12 +21,11 @@ entity pe is ( log_file : string := "output.txt"; router_address : regmetadeflit := (others => '0'); - kernel_type : kernel_str + kernel_type : kernel_str; manual_NORTH : boolean := false; manual_SOUTH : boolean := false; manual_EAST : boolean := false; - manual_WEST : boolean := false; - ); + manual_WEST : boolean := false); port ( clock : in std_logic; diff --git a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd index b74ad38..35b59fb 100644 --- a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd +++ b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd @@ -22,8 +22,7 @@ generic ( manual_NORTH : boolean := false; manual_SOUTH : boolean := false; manual_EAST: boolean := false; - manual_WEST: boolean := false; - ); + manual_WEST: boolean := false); port( clock : in std_logic; reset : in std_logic; @@ -56,7 +55,7 @@ signal source: arrayNport_reg3 := (others=> (others=> '0')); signal sender_ant: regNport := (others=> '0'); signal manual_routing_flag : std_logic; -signal manual_routing_sel : integer range 0 to (NPORT-1) := 0; +signal manual_routing_sel : integer range 0 to (NPORT-1); signal manual_routing_en : boolean; begin @@ -109,7 +108,7 @@ begin ty <= header((QUARTOFLIT - 1) downto 0); manual_routing_flag <= header(TAM_FLIT-1); - manual_routing_sel <= header(TAM_FLIT-2 downto TAM_FLIT-3); + manual_routing_sel <= conv_integer(header(TAM_FLIT-2 downto TAM_FLIT-3)); dirx <= WEST when lx > tx or (manual_WEST and manual_routing_sel=WEST) else EAST; diry <= NORTH when ly < ty or (manual_NORTH and manual_routing_sel=NORTH) else SOUTH; diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index 8916d5f..6cf3da0 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -24,385 +24,391 @@ package standards is -- CONSTANTS -------------------------------------------------------- -- Memory map constants. - constant DEBUG : std_logic_vector(31 downto 0) := x"20000000"; - constant IRQ_MASK : std_logic_vector(31 downto 0) := x"20000010"; - constant IRQ_STATUS_ADDR : std_logic_vector(31 downto 0) := x"20000020"; - constant TIME_SLICE_ADDR : std_logic_vector(31 downto 0) := x"20000060"; - constant FIFO_AVAIL : std_logic_vector(31 downto 0) := x"20000040"; - constant END_SIM : std_logic_vector(31 downto 0) := x"20000080"; - constant CLOCK_HOLD : std_logic_vector(31 downto 0) := x"20000090"; - constant NET_ADDRESS : std_logic_vector(31 downto 0) := x"20000140"; - - -- Network interface mapping. - constant NI_STATUS_READ : std_logic_vector(31 downto 0) := x"20000100"; - constant NI_STATUS_SEND : std_logic_vector(31 downto 0) := x"20000110"; - constant NI_READ : std_logic_vector(31 downto 0) := x"20000120"; - constant NI_WRITE : std_logic_vector(31 downto 0) := x"20000130"; - constant NI_CONFIGURATION : std_logic_vector(31 downto 0) := x"20000140"; - constant NI_ACK : std_logic_vector(31 downto 0) := x"20000150"; - constant NI_NACK : std_logic_vector(31 downto 0) := x"20000160"; - constant NI_END : std_logic_vector(31 downto 0) := x"20000170"; - - -- DMNI mapping. - constant DMNI_SIZE : std_logic_vector(31 downto 0) := x"20000200"; - constant DMNI_ADDR : std_logic_vector(31 downto 0) := x"20000210"; - constant DMNI_SIZE_2 : std_logic_vector(31 downto 0) := x"20000204"; - constant DMNI_ADDR_2 : std_logic_vector(31 downto 0) := x"20000214"; - constant DMNI_OP : std_logic_vector(31 downto 0) := x"20000220"; - constant START_DMNI : std_logic_vector(31 downto 0) := x"20000230"; - constant DMNI_ACK : std_logic_vector(31 downto 0) := x"20000240"; - - constant DMNI_SEND_ACTIVE : std_logic_vector(31 downto 0) := x"20000250"; - constant DMNI_RECEIVE_ACTIVE : std_logic_vector(31 downto 0) := x"20000260"; - - constant SCHEDULING_REPORT : std_logic_vector(31 downto 0) := x"20000270"; - - constant TICK_COUNTER_ADDR : std_logic_vector(31 downto 0) := x"20000300"; - constant REQ_APP_REG : std_logic_vector(31 downto 0) := x"20000350"; - constant ACK_APP_REG : std_logic_vector(31 downto 0) := x"20000360"; - - constant PENDING_SERVICE_INTR : std_logic_vector(31 downto 0) := x"20000400"; - - - constant SLACK_TIME_MONITOR : std_logic_vector(31 downto 0) := x"20000370"; - constant SLACK_MONITOR_WINDOW : integer := 50000; + constant DEBUG : std_logic_vector(31 downto 0) := x"20000000"; + constant IRQ_MASK : std_logic_vector(31 downto 0) := x"20000010"; + constant IRQ_STATUS_ADDR : std_logic_vector(31 downto 0) := x"20000020"; + constant TIME_SLICE_ADDR : std_logic_vector(31 downto 0) := x"20000060"; + constant FIFO_AVAIL : std_logic_vector(31 downto 0) := x"20000040"; + constant END_SIM : std_logic_vector(31 downto 0) := x"20000080"; + constant CLOCK_HOLD : std_logic_vector(31 downto 0) := x"20000090"; + constant NET_ADDRESS : std_logic_vector(31 downto 0) := x"20000140"; + + -- Network interface mapping. + constant NI_STATUS_READ : std_logic_vector(31 downto 0) := x"20000100"; + constant NI_STATUS_SEND : std_logic_vector(31 downto 0) := x"20000110"; + constant NI_READ : std_logic_vector(31 downto 0) := x"20000120"; + constant NI_WRITE : std_logic_vector(31 downto 0) := x"20000130"; + constant NI_CONFIGURATION : std_logic_vector(31 downto 0) := x"20000140"; + constant NI_ACK : std_logic_vector(31 downto 0) := x"20000150"; + constant NI_NACK : std_logic_vector(31 downto 0) := x"20000160"; + constant NI_END : std_logic_vector(31 downto 0) := x"20000170"; + + -- DMNI mapping. + constant DMNI_SIZE : std_logic_vector(31 downto 0) := x"20000200"; + constant DMNI_ADDR : std_logic_vector(31 downto 0) := x"20000210"; + constant DMNI_SIZE_2 : std_logic_vector(31 downto 0) := x"20000204"; + constant DMNI_ADDR_2 : std_logic_vector(31 downto 0) := x"20000214"; + constant DMNI_OP : std_logic_vector(31 downto 0) := x"20000220"; + constant START_DMNI : std_logic_vector(31 downto 0) := x"20000230"; + constant DMNI_ACK : std_logic_vector(31 downto 0) := x"20000240"; + + constant DMNI_SEND_ACTIVE : std_logic_vector(31 downto 0) := x"20000250"; + constant DMNI_RECEIVE_ACTIVE : std_logic_vector(31 downto 0) := x"20000260"; + + constant SCHEDULING_REPORT : std_logic_vector(31 downto 0) := x"20000270"; + + constant TICK_COUNTER_ADDR : std_logic_vector(31 downto 0) := x"20000300"; + constant REQ_APP_REG : std_logic_vector(31 downto 0) := x"20000350"; + constant ACK_APP_REG : std_logic_vector(31 downto 0) := x"20000360"; + + constant PENDING_SERVICE_INTR : std_logic_vector(31 downto 0) := x"20000400"; + + + constant SLACK_TIME_MONITOR : std_logic_vector(31 downto 0) := x"20000370"; + constant SLACK_MONITOR_WINDOW : integer := 50000; -------------------------------------------------------------------------------- -- Router position constants - FIXED - it is not a function of the NoC size -------------------------------------------------------------------------------- - constant BL: integer := 0; - constant BC: integer := 1; - constant BR: integer := 2; - constant CL: integer := 3; - constant CC: integer := 4; - constant CRX: integer := 5; - constant TL: integer := 6; - constant TC: integer := 7; - constant TR: integer := 8; + constant BL : integer := 0; + constant BC : integer := 1; + constant BR : integer := 2; + constant CL : integer := 3; + constant CC : integer := 4; + constant CRX : integer := 5; + constant TL : integer := 6; + constant TC : integer := 7; + constant TR : integer := 8; --------------------------------------------------------- -- CONSTANTS INDEPENDENTES --------------------------------------------------------- - constant NPORT: integer := 5; + constant NPORT : integer := 5; - constant EAST: integer := 0; - constant WEST: integer := 1; - constant NORTH : integer := 2; - constant SOUTH : integer := 3; - constant LOCAL : integer := 4; + constant EAST : integer := 0; + constant WEST : integer := 1; + constant NORTH : integer := 2; + constant SOUTH : integer := 3; + constant LOCAL : integer := 4; --------------------------------------------------------- -- CONSTANT DEPENDENTE DA LARGURA DE BANDA DA REDE - FIXED FOR HEMPS --------------------------------------------------------- - constant TAM_FLIT : integer range 1 to 64 := 32; - constant METADEFLIT : integer range 1 to 32 := (TAM_FLIT/2); - constant QUARTOFLIT : integer range 1 to 16 := (TAM_FLIT/4); + constant TAM_FLIT : integer range 1 to 64 := 32; + constant METADEFLIT : integer range 1 to 32 := (TAM_FLIT/2); + constant QUARTOFLIT : integer range 1 to 16 := (TAM_FLIT/4); --------------------------------------------------------- -- CONSTANTS DEPENDENTES DA PROFUNDIDADE DA FILA --------------------------------------------------------- - constant TAM_BUFFER: integer := 16; - constant TAM_BUFFER_DMNI: integer := 16; - constant TAM_POINTER : integer range 1 to 32 := 4; + constant TAM_BUFFER : integer := 16; + constant TAM_BUFFER_DMNI : integer := 16; + constant TAM_POINTER : integer range 1 to 32 := 4; --------------------------------------------------------- -- CONSTANTS DEPENDENTES DO NUMERO DE ROTEADORES --------------------------------------------------------- - constant NROT: integer := NUMBER_PROCESSORS; + constant NROT : integer := NUMBER_PROCESSORS; - constant MIN_X : integer := 0; - constant MIN_Y : integer := 0; - constant MAX_X : integer := NUMBER_PROCESSORS_X-1; - constant MAX_Y : integer := NUMBER_PROCESSORS_Y-1; + constant MIN_X : integer := 0; + constant MIN_Y : integer := 0; + constant MAX_X : integer := NUMBER_PROCESSORS_X-1; + constant MAX_Y : integer := NUMBER_PROCESSORS_Y-1; --------------------------------------------------------- -- CONSTANT TB --------------------------------------------------------- - constant TAM_LINHA : integer := 2; --4; + constant TAM_LINHA : integer := 2; --4; --------------------------------------------------------- -- SUBTIPOS, TIPOS E FUNCOES --------------------------------------------------------- - subtype reg3 is std_logic_vector(2 downto 0); - subtype reg8 is std_logic_vector(7 downto 0); - subtype reg30 is std_logic_vector(29 downto 0); - subtype reg32 is std_logic_vector(31 downto 0); - subtype regNrot is std_logic_vector((NROT-1) downto 0); - subtype regNport is std_logic_vector((NPORT-1) downto 0); - subtype regflit is std_logic_vector((TAM_FLIT-1) downto 0); - subtype regmetadeflit is std_logic_vector((METADEFLIT-1) downto 0); - subtype regquartoflit is std_logic_vector((QUARTOFLIT-1) downto 0); - subtype pointer is std_logic_vector((TAM_POINTER-1) downto 0); - subtype regNPe is std_logic_vector((NUMBER_PROCESSORS - 1) downto 0); - - type buff is array(0 to TAM_BUFFER-1) of regflit; - type buff_dmni is array(0 to TAM_BUFFER_DMNI-1) of regflit; - - - type arrayNport_reg3 is array((NPORT-1) downto 0) of reg3; - type arrayNport_reg8 is array((NPORT-1) downto 0) of reg8; - type arrayNport_regflit is array((NPORT-1) downto 0) of regflit; - type arrayNrot_reg3 is array((NROT-1) downto 0) of reg3; - type arrayNrot_regflit is array((NROT-1) downto 0) of regflit; - type arrayNrot_regmetadeflit is array((NROT-1) downto 0) of regmetadeflit; - type arrayNPe_reg32 is array((NUMBER_PROCESSORS -1) downto 0) of reg32; - type arrayNPe_reg30 is array((NUMBER_PROCESSORS -1) downto 0) of reg30; - - -- number of ports of the processing_element - 4 - north/south/west/east - type arrayNPORT_1_regflit is array(3 downto 0) of regflit; + subtype reg3 is std_logic_vector(2 downto 0); + subtype reg8 is std_logic_vector(7 downto 0); + subtype reg30 is std_logic_vector(29 downto 0); + subtype reg32 is std_logic_vector(31 downto 0); + subtype regNrot is std_logic_vector((NROT-1) downto 0); + subtype regNport is std_logic_vector((NPORT-1) downto 0); + subtype regflit is std_logic_vector((TAM_FLIT-1) downto 0); + subtype regmetadeflit is std_logic_vector((METADEFLIT-1) downto 0); + subtype regquartoflit is std_logic_vector((QUARTOFLIT-1) downto 0); + subtype pointer is std_logic_vector((TAM_POINTER-1) downto 0); + subtype regNPe is std_logic_vector((NUMBER_PROCESSORS - 1) downto 0); + + type buff is array(0 to TAM_BUFFER-1) of regflit; + type buff_dmni is array(0 to TAM_BUFFER_DMNI-1) of regflit; + + + type arrayNport_reg3 is array((NPORT-1) downto 0) of reg3; + type arrayNport_reg8 is array((NPORT-1) downto 0) of reg8; + type arrayNport_regflit is array((NPORT-1) downto 0) of regflit; + type arrayNrot_reg3 is array((NROT-1) downto 0) of reg3; + type arrayNrot_regflit is array((NROT-1) downto 0) of regflit; + type arrayNrot_regmetadeflit is array((NROT-1) downto 0) of regmetadeflit; + type arrayNPe_reg32 is array((NUMBER_PROCESSORS -1) downto 0) of reg32; + type arrayNPe_reg30 is array((NUMBER_PROCESSORS -1) downto 0) of reg30; + + -- number of ports of the processing_element - 4 - north/south/west/east + type arrayNPORT_1_regflit is array(3 downto 0) of regflit; --------------------------------------------------------- -- HERMES FUCTIONS --------------------------------------------------------- - Function CONV_VECTOR( int: integer ) return std_logic_vector; - function CONV_VECTOR( letra : string(1 to TAM_LINHA); pos: integer ) return std_logic_vector; - function CONV_HEX( int : integer ) return string; - function CONV_STRING_4BITS( dado : std_logic_vector(3 downto 0)) return string; - function CONV_STRING_8BITS( dado : std_logic_vector(7 downto 0)) return string; - function CONV_STRING_16BITS( dado : std_logic_vector(15 downto 0)) return string; - function CONV_STRING_32BITS( dado : std_logic_vector(31 downto 0)) return string; + function CONV_VECTOR(int : integer) return std_logic_vector; + function CONV_VECTOR(letra : string(1 to TAM_LINHA); pos : integer) return std_logic_vector; + function CONV_HEX(int : integer) return string; + function CONV_STRING_4BITS(dado : std_logic_vector(3 downto 0)) return string; + function CONV_STRING_8BITS(dado : std_logic_vector(7 downto 0)) return string; + function CONV_STRING_16BITS(dado : std_logic_vector(15 downto 0)) return string; + function CONV_STRING_32BITS(dado : std_logic_vector(31 downto 0)) return string; --------------------------------------------------------- -- HEMPS FUCTIONS --------------------------------------------------------- - function RouterPosition(router: integer) return integer; - function RouterAddress(router: integer) return std_logic_vector; - function log_filename(i: integer) return string; + function RouterPosition(router : integer) return integer; + function RouterAddress(router : integer) return std_logic_vector; + + function ManualEASTByPos(router : integer) return boolean; + function ManualWESTByPos(router : integer) return boolean; + function ManualNORTHByPos(router : integer) return boolean; + function ManualSOUTHByPos(router : integer) return boolean; + + function log_filename(i : integer) return string; end standards; -package body standards is - -- - -- converte um inteiro em um std_logic_vector(2 downto 0) - -- - function CONV_VECTOR( int: integer ) return std_logic_vector is - variable bin: reg3; - begin - case(int) is - when 0 => bin := "000"; - when 1 => bin := "001"; - when 2 => bin := "010"; - when 3 => bin := "011"; - when 4 => bin := "100"; - when 5 => bin := "101"; - when 6 => bin := "110"; - when 7 => bin := "111"; - when others => bin := "000"; - end case; - return bin; - end CONV_VECTOR; - --------------------------------------------------------- - -- FUNCOES TB - --------------------------------------------------------- - -- - -- converte um caracter de uma dada linha em um std_logic_vector - -- - function CONV_VECTOR( letra:string(1 to TAM_LINHA);pos: integer ) return std_logic_vector is - variable bin: std_logic_vector(3 downto 0); - begin - case (letra(pos)) is - when '0' => bin := "0000"; - when '1' => bin := "0001"; - when '2' => bin := "0010"; - when '3' => bin := "0011"; - when '4' => bin := "0100"; - when '5' => bin := "0101"; - when '6' => bin := "0110"; - when '7' => bin := "0111"; - when '8' => bin := "1000"; - when '9' => bin := "1001"; - when 'A' => bin := "1010"; - when 'B' => bin := "1011"; - when 'C' => bin := "1100"; - when 'D' => bin := "1101"; - when 'E' => bin := "1110"; - when 'F' => bin := "1111"; - when others =>bin := "0000"; - end case; - return bin; - end CONV_VECTOR; +package body standards is + -- + -- converte um inteiro em um std_logic_vector(2 downto 0) + -- + function CONV_VECTOR(int : integer) return std_logic_vector is + variable bin : reg3; + begin + case(int) is + when 0 => bin := "000"; + when 1 => bin := "001"; + when 2 => bin := "010"; + when 3 => bin := "011"; + when 4 => bin := "100"; + when 5 => bin := "101"; + when 6 => bin := "110"; + when 7 => bin := "111"; + when others => bin := "000"; + end case; + return bin; +end CONV_VECTOR; +--------------------------------------------------------- +-- FUNCOES TB +--------------------------------------------------------- +-- +-- converte um caracter de uma dada linha em um std_logic_vector +-- +function CONV_VECTOR(letra : string(1 to TAM_LINHA); pos : integer) return std_logic_vector is + variable bin : std_logic_vector(3 downto 0); +begin + case (letra(pos)) is + when '0' => bin := "0000"; + when '1' => bin := "0001"; + when '2' => bin := "0010"; + when '3' => bin := "0011"; + when '4' => bin := "0100"; + when '5' => bin := "0101"; + when '6' => bin := "0110"; + when '7' => bin := "0111"; + when '8' => bin := "1000"; + when '9' => bin := "1001"; + when 'A' => bin := "1010"; + when 'B' => bin := "1011"; + when 'C' => bin := "1100"; + when 'D' => bin := "1101"; + when 'E' => bin := "1110"; + when 'F' => bin := "1111"; + when others => bin := "0000"; + end case; + return bin; +end CONV_VECTOR; -- converte um inteiro em um string - function CONV_HEX( int: integer ) return string is - variable str: string(1 to 1); - begin - case(int) is - when 0 => str := "0"; - when 1 => str := "1"; - when 2 => str := "2"; - when 3 => str := "3"; - when 4 => str := "4"; - when 5 => str := "5"; - when 6 => str := "6"; - when 7 => str := "7"; - when 8 => str := "8"; - when 9 => str := "9"; - when 10 => str := "A"; - when 11 => str := "B"; - when 12 => str := "C"; - when 13 => str := "D"; - when 14 => str := "E"; - when 15 => str := "F"; - when others =>str := "U"; - end case; - return str; - end CONV_HEX; - - function CONV_STRING_4BITS(dado : std_logic_vector(3 downto 0)) return string is - variable str: string(1 to 1); - begin - str := CONV_HEX(CONV_INTEGER(dado)); - return str; - end CONV_STRING_4BITS; - - function CONV_STRING_8BITS(dado : std_logic_vector(7 downto 0)) return string is - variable str1,str2: string(1 to 1); - variable str: string(1 to 2); - begin - str1 := CONV_STRING_4BITS(dado(7 downto 4)); - str2 := CONV_STRING_4BITS(dado(3 downto 0)); - str := str1 & str2; - return str; - end CONV_STRING_8BITS; - - function CONV_STRING_16BITS(dado : std_logic_vector(15 downto 0)) return string is - variable str1,str2: string(1 to 2); - variable str: string(1 to 4); - begin - str1 := CONV_STRING_8BITS(dado(15 downto 8)); - str2 := CONV_STRING_8BITS(dado(7 downto 0)); - str := str1 & str2; - return str; - end CONV_STRING_16BITS; - - function CONV_STRING_32BITS(dado : std_logic_vector(31 downto 0)) return string is - variable str1,str2: string(1 to 4); - variable str: string(1 to 8); - begin - str1 := CONV_STRING_16BITS(dado(31 downto 16)); - str2 := CONV_STRING_16BITS(dado(15 downto 0)); - str := str1 & str2; - return str; - end CONV_STRING_32BITS; - - -- Returns the router position in the mesh - -- BR: Botton Right - -- BL: Botton Left - -- TR: Top Right - -- TL: Top Left - -- CRX: Center Right - -- CL: Center Left - -- CC: Center - -- 4x4 positions exemple - -- TL TC TC TR - -- CL CC CC CRX - -- CL CC CC CRX - -- BL BC BC BR - function RouterPosition(router: integer) return integer is - variable pos: integer range 0 to TR; - variable line, column: integer; - begin - - --line := router/NUMBER_PROCESSORS_Y; - column := router mod NUMBER_PROCESSORS_X; - - if router >= NUMBER_PROCESSORS-NUMBER_PROCESSORS_X then --TOP - if column = NUMBER_PROCESSORS_X-1 then --RIGHT - pos := TR; - elsif column = 0 then--LEFT - pos := TL; - else--CENTER_X - pos := TC; - end if; - elsif router < NUMBER_PROCESSORS_X then --BOTTOM - if column = NUMBER_PROCESSORS_X-1 then --RIGHT - pos := BR; - elsif column = 0 then--LEFT - pos := BL; - else--CENTER_X - pos := BC; - end if; - else --CENTER_Y - if column = NUMBER_PROCESSORS_X-1 then --RIGHT - pos := CRX; - elsif column = 0 then--LEFT - pos := CL; - else--CENTER_X - pos := CC; - end if; - end if; - - return pos; - - end RouterPosition; - - function ManualEASTbyPos(router : integer) return boolean is - variable pos : integer; - begin - pos := RouterPosition(router); - if (pos = TL) or (pos = CL) or (pos = BL) then - return true; - else - return false; - end if; - end ManualEASTbyPos; - - function ManualWESTbyPos(router : integer) return boolean is - variable pos : integer; - begin - pos := RouterPosition(router); - if (pos = TR) or (pos = CRX) or (pos = BR) then - return true; - else - return false; - end if; - end ManualWESTbyPos; - - function ManualNORTHbyPos(router : integer) return boolean is - variable pos : integer; - begin - pos := RouterPosition(router); - if (pos = TL) or (pos = TC) or (pos = TR) then - return true; - else - return false; - end if; - end ManualNORTHbyPos; - - function ManualSOUTHbyPos(router : integer) return boolean is - variable pos : integer; - begin - pos := RouterPosition(router); - if (pos = BR) or (pos = BC) or (pos = BR) then - return true; - else - return false; - end if; - end ManualSOUTHbyPos; - - - function RouterAddress(router: integer) return std_logic_vector is - variable pos_x, pos_y : regquartoflit; - variable addr : regmetadeflit; - variable aux : integer; - begin - aux := (router/NUMBER_PROCESSORS_X); - pos_x := conv_std_logic_vector((router mod NUMBER_PROCESSORS_X),QUARTOFLIT); - pos_y := conv_std_logic_vector(aux,QUARTOFLIT); - - addr := pos_x & pos_y; - return addr; - end RouterAddress; - - function log_filename(i: integer) return string is - variable filename : string(1 to 14); - variable aux_x : integer; - variable aux_y : integer; - begin - aux_x := (i mod NUMBER_PROCESSORS_X); - aux_y := (i/NUMBER_PROCESSORS_X); - filename := "log/log" & CONV_HEX(aux_x) & "x" & CONV_HEX(aux_y) & ".txt"; - return filename; - end log_filename; - +function CONV_HEX(int : integer) return string is + variable str : string(1 to 1); +begin + case(int) is + when 0 => str := "0"; + when 1 => str := "1"; + when 2 => str := "2"; + when 3 => str := "3"; + when 4 => str := "4"; + when 5 => str := "5"; + when 6 => str := "6"; + when 7 => str := "7"; + when 8 => str := "8"; + when 9 => str := "9"; + when 10 => str := "A"; + when 11 => str := "B"; + when 12 => str := "C"; + when 13 => str := "D"; + when 14 => str := "E"; + when 15 => str := "F"; + when others => str := "U"; +end case; +return str; +end CONV_HEX; + +function CONV_STRING_4BITS(dado : std_logic_vector(3 downto 0)) return string is + variable str : string(1 to 1); +begin + str := CONV_HEX(CONV_INTEGER(dado)); + return str; +end CONV_STRING_4BITS; + +function CONV_STRING_8BITS(dado : std_logic_vector(7 downto 0)) return string is + variable str1, str2 : string(1 to 1); + variable str : string(1 to 2); +begin + str1 := CONV_STRING_4BITS(dado(7 downto 4)); + str2 := CONV_STRING_4BITS(dado(3 downto 0)); + str := str1 & str2; + return str; +end CONV_STRING_8BITS; + +function CONV_STRING_16BITS(dado : std_logic_vector(15 downto 0)) return string is + variable str1, str2 : string(1 to 2); + variable str : string(1 to 4); +begin + str1 := CONV_STRING_8BITS(dado(15 downto 8)); + str2 := CONV_STRING_8BITS(dado(7 downto 0)); + str := str1 & str2; + return str; +end CONV_STRING_16BITS; + +function CONV_STRING_32BITS(dado : std_logic_vector(31 downto 0)) return string is + variable str1, str2 : string(1 to 4); + variable str : string(1 to 8); +begin + str1 := CONV_STRING_16BITS(dado(31 downto 16)); + str2 := CONV_STRING_16BITS(dado(15 downto 0)); + str := str1 & str2; + return str; +end CONV_STRING_32BITS; + +-- Returns the router position in the mesh +-- BR: Botton Right +-- BL: Botton Left +-- TR: Top Right +-- TL: Top Left +-- CRX: Center Right +-- CL: Center Left +-- CC: Center +-- 4x4 positions exemple +-- TL TC TC TR +-- CL CC CC CRX +-- CL CC CC CRX +-- BL BC BC BR +function RouterPosition(router : integer) return integer is + variable pos : integer range 0 to TR; + variable line, column : integer; +begin + + --line := router/NUMBER_PROCESSORS_Y; + column := router mod NUMBER_PROCESSORS_X; + + if router >= NUMBER_PROCESSORS-NUMBER_PROCESSORS_X then --TOP + if column = NUMBER_PROCESSORS_X-1 then --RIGHT + pos := TR; + elsif column = 0 then --LEFT + pos := TL; + else --CENTER_X + pos := TC; + end if; + elsif router < NUMBER_PROCESSORS_X then --BOTTOM + if column = NUMBER_PROCESSORS_X-1 then --RIGHT + pos := BR; + elsif column = 0 then --LEFT + pos := BL; + else --CENTER_X + pos := BC; + end if; + else --CENTER_Y + if column = NUMBER_PROCESSORS_X-1 then --RIGHT + pos := CRX; + elsif column = 0 then --LEFT + pos := CL; + else --CENTER_X + pos := CC; + end if; + end if; + + return pos; + +end RouterPosition; + +function ManualEASTbyPos(router : integer) return boolean is + variable pos : integer; +begin + pos := RouterPosition(router); + if (pos = TL) or (pos = CL) or (pos = BL) then + return true; + else + return false; + end if; +end ManualEASTbyPos; + +function ManualWESTbyPos(router : integer) return boolean is + variable pos : integer; +begin + pos := RouterPosition(router); + if (pos = TR) or (pos = CRX) or (pos = BR) then + return true; + else + return false; + end if; +end ManualWESTbyPos; + +function ManualNORTHbyPos(router : integer) return boolean is + variable pos : integer; +begin + pos := RouterPosition(router); + if (pos = TL) or (pos = TC) or (pos = TR) then + return true; + else + return false; + end if; +end ManualNORTHbyPos; + +function ManualSOUTHbyPos(router : integer) return boolean is + variable pos : integer; +begin + pos := RouterPosition(router); + if (pos = BR) or (pos = BC) or (pos = BR) then + return true; + else + return false; + end if; +end ManualSOUTHbyPos; + + +function RouterAddress(router : integer) return std_logic_vector is + variable pos_x, pos_y : regquartoflit; + variable addr : regmetadeflit; + variable aux : integer; +begin + aux := (router/NUMBER_PROCESSORS_X); + pos_x := conv_std_logic_vector((router mod NUMBER_PROCESSORS_X), QUARTOFLIT); + pos_y := conv_std_logic_vector(aux, QUARTOFLIT); + + addr := pos_x & pos_y; + return addr; +end RouterAddress; + +function log_filename(i : integer) return string is + variable filename : string(1 to 14); + variable aux_x : integer; + variable aux_y : integer; +begin + aux_x := (i mod NUMBER_PROCESSORS_X); + aux_y := (i/NUMBER_PROCESSORS_X); + filename := "log/log" & CONV_HEX(aux_x) & "x" & CONV_HEX(aux_y) & ".txt"; + return filename; +end log_filename; + end standards; From 887c7e0f77d48642ba6becae2da8fc716ded8450 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 8 Sep 2017 10:22:17 -0300 Subject: [PATCH 05/54] gitignore added --- .gitignore | 3 +++ load_env | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 .gitignore create mode 100644 load_env diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf26e47 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +*.pyc +\#*\# diff --git a/load_env b/load_env new file mode 100644 index 0000000..d59263a --- /dev/null +++ b/load_env @@ -0,0 +1,4 @@ +module load systemc mips-elf/4.1.1-hemps questa + +export HEMPS_PATH=$(pwd) +export PATH=${PATH}:${HEMPS_PATH}/build_env/bin From 56416254380d72196ad8e31e9c8fcdf72421ae4e Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 8 Sep 2017 16:27:15 -0300 Subject: [PATCH 06/54] integrated dummy border peripherals --- build_env/makes/make_vhdl | 4 +- hardware/vhdl/hemps.vhd | 456 +++++++++++++++------------ hardware/vhdl/inject_data.vhd | 149 +++++++++ hardware/vhdl/pe/router/RouterCC.vhd | 4 +- hardware/vhdl/receive_data.vhd | 56 ++++ 5 files changed, 467 insertions(+), 202 deletions(-) create mode 100644 hardware/vhdl/inject_data.vhd create mode 100644 hardware/vhdl/receive_data.vhd diff --git a/build_env/makes/make_vhdl b/build_env/makes/make_vhdl index 6b3e7a9..d14a6e4 100644 --- a/build_env/makes/make_vhdl +++ b/build_env/makes/make_vhdl @@ -8,7 +8,7 @@ COMP =vcom -work $(LIB) #VHDL files HEMPS_PKG =hemps_pkg STAND =standards -TOP =hemps test_bench +TOP =receive_data inject_data hemps test_bench PE =pe DMNI =dmni MEMORY =ram_master ram_slave @@ -71,4 +71,4 @@ clean: @rm -f repository* @rm -f ../modelsim.ini @rm -rf ../work - @rm -rf ../transcript \ No newline at end of file + @rm -rf ../transcript diff --git a/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd index 573c377..4ba960a 100644 --- a/hardware/vhdl/hemps.vhd +++ b/hardware/vhdl/hemps.vhd @@ -1,198 +1,258 @@ ------------------------------------------------------------------------------------------------- --- --- DISTRIBUTED HEMPS - version 5.0 --- --- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br --- --- Distribution: September 2013 --- --- Source name: HeMPS.vhd --- --- Brief description: NoC generation --- ------------------------------------------------------------------------------------------------- - -library IEEE; -use ieee.std_logic_1164.all; -use ieee.std_logic_arith.all; -use ieee.std_logic_unsigned.all; -use work.standards.all; -use work.hemps_pkg.all; - -entity HeMPS is - port( - clock : in std_logic; - reset : in std_logic; - - -- Tasks repository interface - repo_address : out std_logic_vector(29 downto 0); - repo_data : in std_logic_vector(31 downto 0); - ack_app : out std_logic; - req_app : in std_logic_vector(31 downto 0) - - -- External Debug interface --- write_enable_debug : out std_logic; --- data_out_debug : out std_logic_vector(31 downto 0); --- busy_debug : in std_logic; - - ); -end; - -architecture HeMPS of HeMPS is - - -- Interconnection signals - type txNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); - signal tx : txNPORT; - type rxNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); - signal rx : rxNPORT; - type clock_rxNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); - signal clock_rx : clock_rxNPORT; - type clock_txNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); - signal clock_tx : clock_txNPORT; - type credit_iNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); - signal credit_i : credit_iNPORT; - type credit_oNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); - signal credit_o : credit_oNPORT; - type data_inNport is array (NUMBER_PROCESSORS - 1 downto 0) of arrayNPORT_1_regflit; - signal data_in : data_inNPORT; - type data_outNport is array (NUMBER_PROCESSORS - 1 downto 0) of arrayNPORT_1_regflit; - signal data_out : data_outNPORT; - signal address_router : std_logic_vector(7 downto 0); - type router_position is array (NUMBER_PROCESSORS - 1 downto 0) of integer range 0 to TR; - signal position : router_position; - - type repo_address_t is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(29 downto 0); - signal repo_address_sig : repo_address_t; - signal repo_data_sig : arrayNPe_reg32; - signal ack_app_sig : regNPe; - signal req_app_sig : arrayNPe_reg32; - - begin - - core_type_gen: for i in 0 to NUMBER_PROCESSORS-1 generate - position(i) <= RouterPosition(i); - end generate core_type_gen; - - - proc: for i in 0 to NUMBER_PROCESSORS-1 generate - - PE: entity work.pe - generic map ( - router_address => RouterAddress(i), - kernel_type => pe_type(i), - log_file => log_filename(i), - manual_EAST => ManualEASTByPos(i), - manual_WEST => ManualWESTByPos(i), - manual_NORTH => ManualNORTHByPos(i), - manual_SOUTH => ManualSOUTHByPos(i)) - port map( - clock => clock, - reset => reset, - -- NoC - clock_tx => clock_tx(i), - tx => tx(i), - data_out => data_out(i), - credit_i => credit_i(i), - clock_rx => clock_rx(i), - rx => rx(i), - data_in => data_in(i), - credit_o => credit_o(i), - -- External Memory - repo_address => repo_address_sig(i), - repo_data_read => repo_data_sig(i), - ack_app => ack_app_sig(i), - req_app => req_app_sig(i) - -- External Debug interface --- write_enable_debug => write_enable_debug_sig(i), --- data_out_debug => data_out_debug_sig(i), --- busy_debug => busy_debug_sig(i) - - ); - - ------------------------------------------------------------------------------ - --- REPOSITORY CONNECTIONS ---------------------------------------------------- - ------------------------------------------------------------------------------ - repo_mas: if pe_type(i) = "mas" generate - repo_address <= repo_address_sig(i); - repo_data_sig(i) <= repo_data; - ack_app <= ack_app_sig(i); - req_app_sig(i) <= req_app; - end generate; - - ground_repo: if pe_type(i) /= "mas" generate - repo_address_sig(i) <= (others => '0'); - repo_data_sig(i) <= (others => '0'); - ack_app_sig(i) <= '0'; - req_app_sig(i) <= (others => '0'); - end generate; - - ------------------------------------------------------------------------------ - --- EAST PORT CONNECTIONS ---------------------------------------------------- - ------------------------------------------------------------------------------ - east_grounding: if RouterPosition(i) = BR or RouterPosition(i) = CRX or RouterPosition(i) = TR generate - rx(i)(EAST) <= '0'; - clock_rx(i)(EAST) <= '0'; - credit_i(i)(EAST) <= '0'; - data_in(i)(EAST) <= (others => '0'); - end generate; - - east_connection: if RouterPosition(i) = BL or RouterPosition(i) = CL or RouterPosition(i) = TL or RouterPosition(i) = BC or RouterPosition(i) = TC or RouterPosition(i) = CC generate - rx(i)(EAST) <= tx(i+1)(WEST); - clock_rx(i)(EAST) <= clock_tx(i+1)(WEST); - credit_i(i)(EAST) <= credit_o(i+1)(WEST); - data_in(i)(EAST) <= data_out(i+1)(WEST); - end generate; - - ------------------------------------------------------------------------------ - --- WEST PORT CONNECTIONS ---------------------------------------------------- - ------------------------------------------------------------------------------ - west_grounding: if RouterPosition(i) = BL or RouterPosition(i) = CL or RouterPosition(i) = TL generate - rx(i)(WEST) <= '0'; - clock_rx(i)(WEST) <= '0'; - credit_i(i)(WEST) <= '0'; - data_in(i)(WEST) <= (others => '0'); - end generate; - - west_connection: if (RouterPosition(i) = BR or RouterPosition(i) = CRX or RouterPosition(i) = TR or RouterPosition(i) = BC or RouterPosition(i) = TC or RouterPosition(i) = CC) generate - rx(i)(WEST) <= tx(i-1)(EAST); - clock_rx(i)(WEST) <= clock_tx(i-1)(EAST); - credit_i(i)(WEST) <= credit_o(i-1)(EAST); - data_in(i)(WEST) <= data_out(i-1)(EAST); - end generate; - - ------------------------------------------------------------------------------- - --- NORTH PORT CONNECTIONS ---------------------------------------------------- - ------------------------------------------------------------------------------- - north_grounding: if RouterPosition(i) = TL or RouterPosition(i) = TC or RouterPosition(i) = TR generate - rx(i)(NORTH) <= '0'; - clock_rx(i)(NORTH) <= '0'; - credit_i(i)(NORTH) <= '0'; - data_in(i)(NORTH) <= (others => '0'); - end generate; - - north_connection: if RouterPosition(i) = BL or RouterPosition(i) = BC or RouterPosition(i) = BR or RouterPosition(i) = CL or RouterPosition(i) = CRX or RouterPosition(i) = CC generate - rx(i)(NORTH) <= tx(i+NUMBER_PROCESSORS_X)(SOUTH); - clock_rx(i)(NORTH) <= clock_tx(i+NUMBER_PROCESSORS_X)(SOUTH); - credit_i(i)(NORTH) <= credit_o(i+NUMBER_PROCESSORS_X)(SOUTH); - data_in(i)(NORTH) <= data_out(i+NUMBER_PROCESSORS_X)(SOUTH); - end generate; - - -------------------------------------------------------------------------------- - --- SOUTH PORT CONNECTIONS ----------------------------------------------------- - --------------------------------------------------------------------------- - south_grounding: if RouterPosition(i) = BL or RouterPosition(i) = BC or RouterPosition(i) = BR generate - rx(i)(SOUTH) <= '0'; - clock_rx(i)(SOUTH) <= '0'; - credit_i(i)(SOUTH) <= '0'; - data_in(i)(SOUTH) <= (others => '0'); - end generate; - - south_connection: if RouterPosition(i) = TL or RouterPosition(i) = TC or RouterPosition(i) = TR or RouterPosition(i) = CL or RouterPosition(i) = CRX or RouterPosition(i) = CC generate - rx(i)(SOUTH) <= tx(i-NUMBER_PROCESSORS_X)(NORTH); - clock_rx(i)(SOUTH) <= clock_tx(i-NUMBER_PROCESSORS_X)(NORTH); - credit_i(i)(SOUTH) <= credit_o(i-NUMBER_PROCESSORS_X)(NORTH); - data_in(i)(SOUTH) <= data_out(i-NUMBER_PROCESSORS_X)(NORTH); - end generate; - end generate proc; - -end architecture; +------------------------------------------------------------------------------------------------ +-- +-- DISTRIBUTED HEMPS - version 5.0 +-- +-- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br +-- +-- Distribution: September 2013 +-- +-- Source name: HeMPS.vhd +-- +-- Brief description: NoC generation +-- +------------------------------------------------------------------------------------------------ + +library IEEE; +use ieee.std_logic_1164.all; +use ieee.std_logic_arith.all; +use ieee.std_logic_unsigned.all; +use work.standards.all; +use work.hemps_pkg.all; + +entity HeMPS is + port( + clock : in std_logic; + reset : in std_logic; + + -- Tasks repository interface + repo_address : out std_logic_vector(29 downto 0); + repo_data : in std_logic_vector(31 downto 0); + ack_app : out std_logic; + req_app : in std_logic_vector(31 downto 0) + + -- External Debug interface +-- write_enable_debug : out std_logic; +-- data_out_debug : out std_logic_vector(31 downto 0); +-- busy_debug : in std_logic; + + ); +end; + +architecture HeMPS of HeMPS is + + -- Interconnection signals + type txNport is array (NUMBER_PROCESSORS-1 downto 0) of std_logic_vector(3 downto 0); + signal tx : txNPORT; + type rxNport is array (NUMBER_PROCESSORS-1 downto 0) of std_logic_vector(3 downto 0); + signal rx : rxNPORT; + type clock_rxNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); + signal clock_rx : clock_rxNPORT; + type clock_txNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); + signal clock_tx : clock_txNPORT; + type credit_iNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); + signal credit_i : credit_iNPORT; + type credit_oNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); + signal credit_o : credit_oNPORT; + type data_inNport is array (NUMBER_PROCESSORS - 1 downto 0) of arrayNPORT_1_regflit; + signal data_in : data_inNPORT; + type data_outNport is array (NUMBER_PROCESSORS - 1 downto 0) of arrayNPORT_1_regflit; + signal data_out : data_outNPORT; + signal address_router : std_logic_vector(7 downto 0); + type router_position is array (NUMBER_PROCESSORS - 1 downto 0) of integer range 0 to TR; + signal position : router_position; + + type repo_address_t is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(29 downto 0); + signal repo_address_sig : repo_address_t; + signal repo_data_sig : arrayNPe_reg32; + signal ack_app_sig : regNPe; + signal req_app_sig : arrayNPe_reg32; + +begin + + core_type_gen : for i in 0 to NUMBER_PROCESSORS-1 generate + position(i) <= RouterPosition(i); + end generate core_type_gen; + + + proc : for i in 0 to NUMBER_PROCESSORS-1 generate + + PE : entity work.pe + generic map ( + router_address => RouterAddress(i), + kernel_type => pe_type(i), + log_file => log_filename(i), + manual_EAST => ManualEASTByPos(i), + manual_WEST => ManualWESTByPos(i), + manual_NORTH => ManualNORTHByPos(i), + manual_SOUTH => ManualSOUTHByPos(i)) + port map( + clock => clock, + reset => reset, + -- NoC + clock_tx => clock_tx(i), + tx => tx(i), + data_out => data_out(i), + credit_i => credit_i(i), + clock_rx => clock_rx(i), + rx => rx(i), + data_in => data_in(i), + credit_o => credit_o(i), + -- External Memory + repo_address => repo_address_sig(i), + repo_data_read => repo_data_sig(i), + ack_app => ack_app_sig(i), + req_app => req_app_sig(i) + -- External Debug interface +-- write_enable_debug => write_enable_debug_sig(i), +-- data_out_debug => data_out_debug_sig(i), +-- busy_debug => busy_debug_sig(i) + + ); + + ------------------------------------------------------------------------------ + --- REPOSITORY CONNECTIONS ---------------------------------------------------- + ------------------------------------------------------------------------------ + repo_mas : if pe_type(i) = "mas" generate + repo_address <= repo_address_sig(i); + repo_data_sig(i) <= repo_data; + ack_app <= ack_app_sig(i); + req_app_sig(i) <= req_app; + end generate; + + ground_repo : if pe_type(i) /= "mas" generate + repo_address_sig(i) <= (others => '0'); + repo_data_sig(i) <= (others => '0'); + ack_app_sig(i) <= '0'; + req_app_sig(i) <= (others => '0'); + end generate; + + ------------------------------------------------------------------------------ + --- EAST PORT CONNECTIONS ---------------------------------------------------- + ------------------------------------------------------------------------------ + east_border : if RouterPosition(i) = BR or RouterPosition(i) = CRX or RouterPosition(i) = TR generate + data_injector : entity work.inject_data + generic map(router_nb => i, + port_name => "EAST") + port map (clock => clock, + reset => reset, + clock_rx => clock_rx(i)(EAST), + rx => rx(i)(EAST), + data_in => data_in(i)(EAST), + credit_o => credit_o(i)(EAST)); + + data_consumer : entity work.receive_data + generic map(router_nb => i, + port_name => "EAST") + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(EAST), + tx => tx(i)(EAST), + data_out => data_out(i)(EAST), + credit_i => credit_i(i)(EAST)); + end generate; + + east_connection : if RouterPosition(i) = BL or RouterPosition(i) = CL or RouterPosition(i) = TL or RouterPosition(i) = BC or RouterPosition(i) = TC or RouterPosition(i) = CC generate + rx(i)(EAST) <= tx(i+1)(WEST); + clock_rx(i)(EAST) <= clock_tx(i+1)(WEST); + credit_i(i)(EAST) <= credit_o(i+1)(WEST); + data_in(i)(EAST) <= data_out(i+1)(WEST); + end generate; + + ------------------------------------------------------------------------------ + --- WEST PORT CONNECTIONS ---------------------------------------------------- + ------------------------------------------------------------------------------ + west_border : if RouterPosition(i) = BL or RouterPosition(i) = CL or RouterPosition(i) = TL generate + data_injector : entity work.inject_data + generic map(router_nb => i, + port_name => "WEST") + port map (clock => clock, + reset => reset, + clock_rx => clock_rx(i)(WEST), + rx => rx(i)(WEST), + data_in => data_in(i)(WEST), + credit_o => credit_o(i)(WEST)); + + data_consumer : entity work.receive_data + generic map(router_nb => i, + port_name => "WEST") + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(WEST), + tx => tx(i)(WEST), + data_out => data_out(i)(WEST), + credit_i => credit_i(i)(WEST)); + end generate; + + west_connection : if (RouterPosition(i) = BR or RouterPosition(i) = CRX or RouterPosition(i) = TR or RouterPosition(i) = BC or RouterPosition(i) = TC or RouterPosition(i) = CC) generate + rx(i)(WEST) <= tx(i-1)(EAST); + clock_rx(i)(WEST) <= clock_tx(i-1)(EAST); + credit_i(i)(WEST) <= credit_o(i-1)(EAST); + data_in(i)(WEST) <= data_out(i-1)(EAST); + end generate; + + ------------------------------------------------------------------------------- + --- NORTH PORT CONNECTIONS ---------------------------------------------------- + ------------------------------------------------------------------------------- + north_border : if RouterPosition(i) = TL or RouterPosition(i) = TC or RouterPosition(i) = TR generate + data_injector : entity work.inject_data + generic map(router_nb => i, + port_name => "NORTH") + port map (clock => clock, + reset => reset, + clock_rx => clock_rx(i)(NORTH), + rx => rx(i)(NORTH), + data_in => data_in(i)(NORTH), + credit_o => credit_o(i)(NORTH)); + + data_consumer : entity work.receive_data + generic map(router_nb => i, + port_name => "NORTH") + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(NORTH), + tx => tx(i)(NORTH), + data_out => data_out(i)(NORTH), + credit_i => credit_i(i)(NORTH)); + end generate; + + north_connection : if RouterPosition(i) = BL or RouterPosition(i) = BC or RouterPosition(i) = BR or RouterPosition(i) = CL or RouterPosition(i) = CRX or RouterPosition(i) = CC generate + rx(i)(NORTH) <= tx(i+NUMBER_PROCESSORS_X)(SOUTH); + clock_rx(i)(NORTH) <= clock_tx(i+NUMBER_PROCESSORS_X)(SOUTH); + credit_i(i)(NORTH) <= credit_o(i+NUMBER_PROCESSORS_X)(SOUTH); + data_in(i)(NORTH) <= data_out(i+NUMBER_PROCESSORS_X)(SOUTH); + end generate; + + -------------------------------------------------------------------------------- + --- SOUTH PORT CONNECTIONS ----------------------------------------------------- + --------------------------------------------------------------------------- + south_border : if RouterPosition(i) = BL or RouterPosition(i) = BC or RouterPosition(i) = BR generate + data_injector : entity work.inject_data + generic map(router_nb => i, + port_name => "SOUTH") + port map (clock => clock, + reset => reset, + clock_rx => clock_rx(i)(SOUTH), + rx => rx(i)(SOUTH), + data_in => data_in(i)(SOUTH), + credit_o => credit_o(i)(SOUTH)); + + data_consumer : entity work.receive_data + generic map(router_nb => i, + port_name => "SOUTH") + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(SOUTH), + tx => tx(i)(SOUTH), + data_out => data_out(i)(SOUTH), + credit_i => credit_i(i)(SOUTH)); + end generate; + + south_connection : if RouterPosition(i) = TL or RouterPosition(i) = TC or RouterPosition(i) = TR or RouterPosition(i) = CL or RouterPosition(i) = CRX or RouterPosition(i) = CC generate + rx(i)(SOUTH) <= tx(i-NUMBER_PROCESSORS_X)(NORTH); + clock_rx(i)(SOUTH) <= clock_tx(i-NUMBER_PROCESSORS_X)(NORTH); + credit_i(i)(SOUTH) <= credit_o(i-NUMBER_PROCESSORS_X)(NORTH); + data_in(i)(SOUTH) <= data_out(i-NUMBER_PROCESSORS_X)(NORTH); + end generate; + end generate proc; + +end architecture; diff --git a/hardware/vhdl/inject_data.vhd b/hardware/vhdl/inject_data.vhd new file mode 100644 index 0000000..ef920ed --- /dev/null +++ b/hardware/vhdl/inject_data.vhd @@ -0,0 +1,149 @@ +library STD; +use STD.TEXTIO.all; +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.std_logic_unsigned.all; +use IEEE.std_logic_textio.all; +library work; +use work.hemps_pkg.all; +use work.standards.all; + +------------------------------------------------------------------------------- +-- Ports are labelled from the router's perspective +------------------------------------------------------------------------------- +entity inject_data is + generic(router_nb : integer; + port_name : string); + port( + clock : in std_logic; + reset : in std_logic; + + clock_rx : out std_logic; + rx : out std_logic; + data_in : out regflit; + credit_o : in std_logic); +end inject_data; + + +architecture inject_data of inject_data is + + ---arquivos com os pacotes - pacotes de até 256 flits, e max 100 pacotes por arquivo + + type packet is array (0 to 256) of std_logic_vector(31 downto 0); + + type packet_array is array(0 to 100) of packet; + + signal packets : packet_array; --- packet read from a file + + signal packet_number : integer := 0; + --signal dta_out : string(1 to 8); + + +begin + + clock_rx <= clock; -- enable the router to inject data + + --------------------------------------------------------------------------------------------- + -- inject traffic + --------------------------------------------------------------------------------------------- + process + variable i, ix : integer; + variable ARQ_LINE : line; + variable line_arq : string(1 to 2000); + variable count_flit : integer := 0; + variable position : integer := 1; + file file_out : text; + variable fstatus : file_open_status; + variable dta_out : string(1 to 8); + begin + + rx <= '0'; -- if the file is empty, there is no injection + ix := 0; + + wait for 200 ns; -- condition to start injecting the packets (in fact 200 ns is the time required to read the file and restart the injection) + + -- loop to inject all packets described in the input file + if packet_number > 0 then + + loop + i := 0; + while i < CONV_INTEGER(packets(ix)(1) + 2) loop -- header + packet size + + if credit_o = '1' then -- flow control + file_open(fstatus, file_out, "inj" & integer'image(router_nb) & port_name & ".txt", write_mode); + dta_out := CONV_STRING_32BITS(packets(ix)(i)); + write(ARQ_LINE, dta_out & " " & "," & " " & time'image(NOW)); + writeline(file_out, ARQ_LINE); + rx <= '1'; + data_in <= packets(ix)(i); + wait for 10 ns; + rx <= '0'; + wait for 10 ns; + i := i + 1; + else + wait for 10 ns; + rx <= '0'; + end if; + + end loop; + + wait for 10 ns; -- time between packets - MUDEI MORAES - 07/JULHO + + ix := ix + 1; -- next packet + + exit when ix = packet_number; + + end loop; + end if; + end process; + + --------------------------------------------------------------------------------------------- + -- read the file + --------------------------------------------------------------------------------------------- + process + variable ARQ_LINE : line; + variable line_arq : string(1 to 2000); + variable count_flit : integer := 0; + variable position : integer := 1; + file file_in : text; + variable fstatus : file_open_status; + begin + + wait until reset = '1'; -- start reading the file + + file_open(fstatus, file_in, "in" & integer'image(router_nb) & port_name & ".txt", read_mode); + + if fstatus = open_ok then + while not (endfile(file_in)) loop -- one packet per line ----- + + readline(file_in, ARQ_LINE); + read(ARQ_LINE, line_arq(1 to ARQ_LINE'length)); ---- read the line + + report "The line is " & line_arq; + + position := 1; + count_flit := 0; -- flit number + loop + for w in 0 to 7 loop + packets(packet_number)(count_flit)((31-w*4) downto (32-(w+1)*4)) <= CONV_VECTOR(line_arq(position+w to position+w+1), 1); + end loop; + + position := position + 9; + count_flit := count_flit + 1; + + wait for 2 ps; -- tempo para avançar o processo (tricki!) + + exit when count_flit > 2 and count_flit = (CONV_INTEGER(packets(packet_number)(1)) + 2); -- second flit is the packet size + + end loop; + + packet_number <= packet_number + 1; --- number of lines of the traffic file + + wait for 2 ps; --required, to wait the next line :-) + + end loop; -- end loop da linha + end if; + + end process; + +end inject_data; diff --git a/hardware/vhdl/pe/router/RouterCC.vhd b/hardware/vhdl/pe/router/RouterCC.vhd index 9ad2692..367d02b 100644 --- a/hardware/vhdl/pe/router/RouterCC.vhd +++ b/hardware/vhdl/pe/router/RouterCC.vhd @@ -39,7 +39,7 @@ architecture arq_traffic of traffic_monitor is type type_state is (Hheader, Ppayload, Sservice, task_allocation, task_menssage, cont_payload); signal SM_traffic_monitor : type_state; - signal tick_counter : reg32; + signal tick_counter : reg32; signal target_router : regflit; signal header_time : integer; signal bandwidth_allocation : integer; @@ -308,7 +308,7 @@ begin -- Remova esse generate caso queira fazer uma synthesis. -- Esse generate é usado para o traffic_monitor das portas de entrada do router. --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - credit_o <= credit_o_sig; + credit_o <= credit_o_sig; traffic_router: for i in 0 to (NPORT-1) generate traffic_monit : entity work.traffic_monitor generic map( ID => i ) diff --git a/hardware/vhdl/receive_data.vhd b/hardware/vhdl/receive_data.vhd new file mode 100644 index 0000000..6081b7b --- /dev/null +++ b/hardware/vhdl/receive_data.vhd @@ -0,0 +1,56 @@ +library STD; +use STD.TEXTIO.all; +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.std_logic_unsigned.all; +use IEEE.std_logic_textio.all; +library work; +use work.hemps_pkg.all; +use work.standards.all; + +entity receive_data is + generic(router_nb : integer; + port_name : string); + port( + clock : in std_logic; + reset : in std_logic; + + clock_tx : in std_logic; + tx : in std_logic; + data_out : in regflit; + credit_i : out std_logic); +end receive_data; + +architecture receive_data of receive_data is +begin + + +--------------------------------------------------------------------------------------------- +-- receive traffic +--------------------------------------------------------------------------------------------- + + process(clock_tx) + variable ARQ_LINE : line; + variable line_arq : string(1 to 2000); + variable count_flit : integer := 0; + variable position : integer := 1; + file file_out : text; + variable fstatus : file_open_status; + variable dta_out : string(1 to 8); + + begin + credit_i <= '1'; -- can receive data + + if clock_tx'event and clock_tx = '1' and tx = '1' then + file_open(fstatus, file_out, "out" & integer'image(router_nb) & port_name & ".txt", write_mode); + -- report "The output file " & filename & "is open."; + dta_out := CONV_STRING_32BITS(data_out); +-- report "Data Out is:" & dta_out; + write(ARQ_LINE, dta_out & " " & "," & " " & time'image(NOW)); + writeline(file_out, ARQ_LINE); + --write(line_arq, time'image(now)); + --writeline(file_out, line_arq); + end if; + end process; + +end receive_data; From 7829a5dbe72012209caac88437d237ec94e6df00 Mon Sep 17 00:00:00 2001 From: b-scherer Date: Tue, 12 Sep 2017 08:17:31 -0300 Subject: [PATCH 07/54] Added SW Made the function board_routing --- software/include/services.h | 1 + software/modules/boarder_route.c | 41 ++++++++++++++++++++++++++++++++ software/modules/boarder_route.h | 32 +++++++++++++++++++++++++ software/modules/packet.h | 4 ++++ 4 files changed, 78 insertions(+) create mode 100644 software/modules/boarder_route.c create mode 100644 software/modules/boarder_route.h diff --git a/software/include/services.h b/software/include/services.h index 1f25376..4f5e565 100644 --- a/software/include/services.h +++ b/software/include/services.h @@ -44,5 +44,6 @@ #define SLACK_TIME_REPORT 0x00000260 #define DEADLINE_MISS_REPORT 0x00000270 #define REAL_TIME_CHANGE 0x00000280 +#define BORDER_ROUTE 0x00000290 #endif diff --git a/software/modules/boarder_route.c b/software/modules/boarder_route.c new file mode 100644 index 0000000..86a7892 --- /dev/null +++ b/software/modules/boarder_route.c @@ -0,0 +1,41 @@ +/*!\file task_location.h + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Created by: Bruno Oliveira - contact: bruno.scherer@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief + * This module defines function relative to boarder routing. + * \detailed + * + */ + +#include "boarder_route.h" +#include "../../include/kernel_pkg.h" +#include "utils.h" + +/** + * \brief This structure stores the location (slave process address) of the other task + */ + +int boarder_route(unsigned int f1, unsigned int f2, unsigned int f3){ + if (f1 == 1){ + if (f2 == 1 and f3 == 1){ + return 57344; + } + else if (f2 == 1 and f3 == 0) { + return 49152; + } + else if (f2 == 0 and f3 == 1){ + return 40960; + } + else if (f2 == 0 and f3 == 0){ + return 32768; + } + } +} + +#endif /* BORDER_ROUTE_H_ */ diff --git a/software/modules/boarder_route.h b/software/modules/boarder_route.h new file mode 100644 index 0000000..f0d4c16 --- /dev/null +++ b/software/modules/boarder_route.h @@ -0,0 +1,32 @@ +/*!\file task_location.h + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Created by: Bruno Oliveira - contact: bruno.scherer@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief + * This module defines function relative to boarder routing. + * \detailed + * + */ + +#ifndef BORDER_ROUTE +#define BORDER_ROUTE_H_ + +#include "../../include/kernel_pkg.h" +#include "boarder_route.h" +/** + * \brief This structure stores the location (slave process address) of the other task + */ +struct packed_struct { + unsigned int f1:1; + unsigned int f2:1; + unsigned int f3:1; +} + +int boarder_route(unsigned int f1, unsigned int f2, unsigned int f3); + +#endif /* BORDER_ROUTE_H_ */ diff --git a/software/modules/packet.h b/software/modules/packet.h index d24e616..59d9e92 100644 --- a/software/modules/packet.h +++ b/software/modules/packet.h @@ -33,6 +33,10 @@ typedef struct { unsigned int app_ID; }; + union { //! Date: Thu, 14 Sep 2017 23:25:07 -0300 Subject: [PATCH 08/54] TRANSIT Syscall Added the Transit Syscall --- api.h | 62 ++++ kernel_slave.c | 933 +++++++++++++++++++++++++++++++++++++++++++++++++ kernel_slave.h | 44 +++ services.h | 52 +++ 4 files changed, 1091 insertions(+) create mode 100644 api.h create mode 100644 kernel_slave.c create mode 100644 kernel_slave.h create mode 100644 services.h diff --git a/api.h b/api.h new file mode 100644 index 0000000..43c9225 --- /dev/null +++ b/api.h @@ -0,0 +1,62 @@ +/*!\file api.h + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief + * Implements the API for the user's task and defines the structure Message, + * used by tasks to exchange messages + */ + +#ifndef __TASK_H__ +#define __TASK_H__ + +/* Syscalls*/ +#define EXIT 0 +#define WRITEPIPE 1 +#define READPIPE 2 +#define GETTICK 3 +#define ECHO 4 +#define REALTIME 5 +#define TRANSIT 6 + +#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) +#define TRUE 1 +#define FALSE 0 + +extern int SystemCall(); + +#define Send(msg, target) while(!SystemCall(WRITEPIPE, (unsigned int*)msg, target,0)) +#define Receive(msg, source) while(!SystemCall(READPIPE, (unsigned int*)msg, source,0)) +#define GetTick() SystemCall(GETTICK,0,0,0) +#define Echo(str) SystemCall(ECHO, (char*)str,0,0) +#define exit() while(!SystemCall(EXIT, 0, 0, 0)) + +// Bruno's modification 14/09 - The change reflects the need of a transit message to send packets outside the NoC. +// The call is Target (Border Router, out_target (00 - South, 01 - West, 10 - East, 11 - North), message (payload)) +#define Transit(target, out_target, msg) while (!SystemCall(TRANSIT, target, out_target, (unsigned int*)msg)) + +//Real-Time API - time represented in microseconds +#define RealTime(period, deadline, execution_time) while(!SystemCall(REALTIME, period, deadline, execution_time)) + +/*-------------------------------------------------------------------- + * struct Message + * + * DESCRIPTION: + * Used to handle messages inside the task. + * This is not the same structure used in the kernels. + * + *--------------------------------------------------------------------*/ +#define MSG_SIZE 128 + +typedef struct { + int length; + int msg[MSG_SIZE]; +} Message; + +#endif /*__TASK_H__*/ + diff --git a/kernel_slave.c b/kernel_slave.c new file mode 100644 index 0000000..b1537b9 --- /dev/null +++ b/kernel_slave.c @@ -0,0 +1,933 @@ +/*!\file kernel_slave.c + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief + * Kernel slave is the system slave used to execute user's tasks. + * + * \detailed + * kernel_slave is the core of the OS running into the slave processors. + * Its job is to runs the user's task. It communicates whit the kernel_master to receive new tasks + * and also notifying its finish. + * The kernel_slave file uses several modules that implement specific functions + */ + +#include "kernel_slave.h" + +#include "../../../include/kernel_pkg.h" +#include "../../include/api.h" +#include "../../include/plasma.h" +#include "../../include/services.h" +#include "../../modules/task_location.h" +#include "../../modules/packet.h" +#include "../../modules/communication.h" +#include "../../modules/pending_service.h" +#include "../../modules/task_scheduler.h" +#include "../../modules/utils.h" +#if MIGRATION_ENABLED +#include "../../modules/task_migration.h" +#endif + +//Globals +unsigned int net_address; //!< Store the current XY address +unsigned int schedule_after_syscall; //!< Signals the syscall function (assembly implemented) to call the scheduler after the syscall +unsigned int cluster_master_address; //!< Store the cluster master XY address +unsigned int last_idle_time; //!< Store the last idle time duration +unsigned int total_slack_time; //!< Store the total of the processor idle time +TCB idle_tcb; //!< TCB pointer used to run idle task +TCB * current; //!< TCB pointer used to store the current task executing into processor +Message msg_write_pipe; //!< Message variable which is used to copy a message and send it by the NoC + + +/** Assembles and sends a TASK_TERMINATED packet to the master kernel + * \param terminated_task Terminated task TCB pointer + */ +void send_task_terminated(TCB * terminated_task){ + + ServiceHeader *p = get_service_header_slot(); + + p->header = terminated_task->master_address; + + p->service = TASK_TERMINATED; + + p->task_ID = terminated_task->id; + + p->master_ID = cluster_master_address; + + send_packet(p, 0, 0); + + if (terminated_task->master_address != cluster_master_address){ + + p = get_service_header_slot(); + + p->header = cluster_master_address; + + p->service = TASK_TERMINATED_OTHER_CLUSTER; + + p->task_ID = terminated_task->id; + + p->master_ID = terminated_task->master_address; + + send_packet(p, 0, 0); + } + +} + +/** Assembles and sends a TASK_ALLOCATED packet to the master kernel + * \param allocated_task Allocated task TCB pointer + */ +void send_task_allocated(TCB * allocated_task){ + + ServiceHeader *p = get_service_header_slot(); + + p->header = allocated_task->master_address; + + p->service = TASK_ALLOCATED; + + p->task_ID = allocated_task->id; + + p->master_ID = cluster_master_address; + + send_packet(p, 0, 0); +} + +/** Assembles and sends a MESSAGE_DELIVERY packet to a consumer task located into a slave processor + * \param producer_task ID of the task that produce the message (Send()) + * \param consumer_task ID of the task that consume the message (Receive()) + * \param msg_ptr Message pointer + */ +void send_message_delivery(int producer_task, int consumer_task, int consumer_PE, Message * msg_ptr){ + + ServiceHeader *p = get_service_header_slot(); + + p->header = consumer_PE; + + p->service = MESSAGE_DELIVERY; + + p->producer_task = producer_task; + + p->consumer_task = consumer_task; + + p->msg_lenght = msg_ptr->length; + + send_packet(p, (unsigned int)msg_ptr->msg, msg_ptr->length); + +} + +/** Assembles and sends a REAL_TIME_CHANGE packet to the master kernel + * \param tcb_ptr TCB pointer of the task that change its real-time parameters + */ +void send_task_real_time_change(TCB * tcb_ptr){ + + ServiceHeader * p = get_service_header_slot(); + + p = get_service_header_slot(); + + p->header = cluster_master_address; + + p->service = REAL_TIME_CHANGE; + + p->task_ID = tcb_ptr->id; + + p->utilization = tcb_ptr->scheduling_ptr->utilization; + + putsv("Send real time change, utilization: ", p->utilization); + + send_packet(p, 0, 0); +} + +/** Assembles and sends a SLACK_TIME_REPORT packet to the master kernel + */ +void send_slack_time_report(){ + + ServiceHeader * p = get_service_header_slot(); + + p->header = cluster_master_address; + + p->service = SLACK_TIME_REPORT; + + p->cpu_slack_time = ( (total_slack_time*100) / SLACK_TIME_WINDOW); + + send_packet(p, 0, 0); +} + +/** Assembles and sends a UPDATE_TASK_LOCATION packet to a slave processor. Useful because task migration + * \param target_proc Target slave processor which the packet will be sent + * \param task_id Task ID that have its location updated + * \param new_task_location New location (slave processor address) of the task + */ +void send_update_task_location(unsigned int target_proc, unsigned int task_id, unsigned int new_task_location){ + + ServiceHeader *p = get_service_header_slot(); + + if (target_proc != net_address){ + + p->header = target_proc; + + p->service = UPDATE_TASK_LOCATION; + + p->task_ID = task_id; + + p->allocated_processor = new_task_location; + + send_packet(p, 0, 0); + } + + if (target_proc != new_task_location){ + + p = get_service_header_slot(); + + p->header = new_task_location; + + p->service = UPDATE_TASK_LOCATION; + + p->task_ID = task_id; + + p->allocated_processor = new_task_location; + + send_packet(p, 0, 0); + } +} + +/** Assembles and sends a MESSAGE_REQUEST packet to producer task into a slave processor + * \param producer_task Producer task ID (Send()) + * \param consumer_task Consumer task ID (Receive()) + * \param targetPE Processor address of the producer task + * \param requestingPE Processor address of the consumer task + * \param insert_pipe_flag Tells to the producer PE that the message not need to be by passed again + */ +void send_message_request(int producer_task, int consumer_task, unsigned int targetPE, unsigned int requestingPE, int insert_pipe_flag){ + + + ServiceHeader *p = get_service_header_slot(); + + p->header = targetPE; + + p->service = MESSAGE_REQUEST; + + p->requesting_processor = requestingPE; + + p->producer_task = producer_task; + + p->consumer_task = consumer_task; + + p->insert_request = insert_pipe_flag; + + send_packet(p, 0, 0); +} + +//Bruno's Change - Added function to send the injection +void generateInjection(int producer_task, int consumer_task, unsigned int targetPE, unsigned int requestingPE, int insert_pipe_flag) + ServiceHeader *p = get_service_header_slot(); + p->header = targetPE; + p->service = BORDER_ROUTE; + p-> requesting_processor = requestingPE; + p-> producer_task = producer_task; + p->consumer_task = consumer_task; + p-> insert_request = insert_pipe_flag; + send_packet(p,0,0) + +/** Useful function to writes a message into the task page space + * \param task_tcb_ptr TCB pointer of the task + * \param msg_lenght Lenght of the message to be copied + * \param msg_data Message data + */ +void write_local_msg_to_task(TCB * task_tcb_ptr, int msg_lenght, int * msg_data){ + + Message * msg_ptr; + + msg_ptr = (Message*)((task_tcb_ptr->offset) | ((unsigned int)task_tcb_ptr->reg[3])); //reg[3] = address message + + msg_ptr->length = msg_lenght; + + for (int i=0; ilength; i++) + msg_ptr->msg[i] = msg_data[i]; + + //Unlock the blocked task + task_tcb_ptr->reg[0] = TRUE; + + //Release task to execute + task_tcb_ptr->scheduling_ptr->waiting_msg = 0; +} + +/** Syscall handler. It is called when a task calls a function defined into the api.h file + * \param service Service of the syscall + * \param arg0 Generic argument + * \param arg1 Generic argument + * \param arg2 Generic argument + */ +int Syscall(unsigned int service, unsigned int arg0, unsigned int arg1, unsigned int arg2) { + + Message *msg_read; + Message *msg_write; + PipeSlot *pipe_ptr; + MessageRequest * msg_req_ptr; + int consumer_task; + int producer_task; + int producer_PE; + int consumer_PE; + int appID; + int ret; + + schedule_after_syscall = 0; + + switch (service) { + + case EXIT: + + schedule_after_syscall = 1; + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + //Also, due task migration sincronization messages, the producer task cannot finish it execution while have messages in PIPE + if (MemoryRead(DMNI_SEND_ACTIVE) || search_PIPE_producer(current->id)){ + return 0; + } + + puts("Task id: "); puts(itoa(current->id)); putsv(" terminated at ", MemoryRead(TICK_COUNTER)); + + send_task_terminated(current); + + clear_scheduling(current->scheduling_ptr); + + appID = current->id >> 8; + + if ( !is_another_task_running(appID) ){ + + clear_app_tasks_locations(appID); + } + + return 1; + + case WRITEPIPE: + + producer_task = current->id; + consumer_task = (int) arg1; + + appID = producer_task >> 8; + consumer_task = (appID << 8) | consumer_task; + + //puts("WRITEPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); + + consumer_PE = get_task_location(consumer_task); + + //Test if the consumer task is not allocated + if (consumer_PE == -1){ + //Task is blocked until its a TASK_RELEASE packet + current->scheduling_ptr->status = BLOCKED; + return 0; + } + + /*Points the message in the task page. Address composition: offset + msg address*/ + msg_read = (Message *)((current->offset) | arg0); + + //Searches if there is a message request to the produced message + msg_req_ptr = remove_message_request(producer_task, consumer_task); + + if (msg_req_ptr){ + + if (msg_req_ptr->requester_proc == net_address){ //Test if the consumer is local or remote + + //Writes to the consumer page address (local consumer) + TCB * requesterTCB = searchTCB(consumer_task); + + write_local_msg_to_task(requesterTCB, msg_read->length, msg_read->msg); + +#if MIGRATION_ENABLED + if (requesterTCB->proc_to_migrate != -1){ + + migrate_dynamic_memory(requesterTCB); + + schedule_after_syscall = 1; + } +#endif + + } else { //Send a mesage delivery (remote consumer) + + //Deadlock avoidance: voids to send a packet when the DMNI is busy in send process + if ( MemoryRead(DMNI_SEND_ACTIVE) ){ + //Restore the message request + msg_req_ptr->requested = producer_task; + msg_req_ptr->requester = consumer_task; + return 0; + } + + msg_write_pipe.length = msg_read->length; + + //Avoids message overwriting by the producer task + for (int i=0; i < msg_read->length; i++) + msg_write_pipe.msg[i] = msg_read->msg[i]; + + send_message_delivery(producer_task, consumer_task, msg_req_ptr->requester_proc, &msg_write_pipe); + + } + } else { //message not requested yet, stores into PIPE + + //########################### ADD PIPE ################################# + ret = add_PIPE(producer_task, consumer_task, msg_read); + //########################### ADD PIPE ################################# + + if (ret == 0){ + schedule_after_syscall = 1; + return 0; + } + } + + return 1; + + case READPIPE: + + consumer_task = current->id; + producer_task = (int) arg1; + + appID = consumer_task >> 8; + producer_task = (appID << 8) | producer_task; + + //puts("READPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); + + producer_PE = get_task_location(producer_task); + + //Test if the producer task is not allocated + if (producer_PE == -1){ + //Task is blocked until its a TASK_RELEASE packet + current->scheduling_ptr->status = BLOCKED; + return 0; + } + + if (producer_PE == net_address){ //Local producer + + //Searches if the message is in PIPE (local producer) + pipe_ptr = remove_PIPE(producer_task, consumer_task); + + if (pipe_ptr == 0){ + + //Stores the request into the message request table (local producer) + insert_message_request(producer_task, consumer_task, net_address); + + } else { + + //Message was found in pipe, writes to the consumer page address (local producer) + + msg_write = (Message*) arg0; + + msg_write = (Message*)((current->offset) | ((unsigned int)msg_write)); + + msg_write->length = pipe_ptr->message.length; + + for (int i = 0; ilength; i++) { + msg_write->msg[i] = pipe_ptr->message.msg[i]; + } + + return 1; + } + + } else { //Remote producer : Sends the message request (remote producer) + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + if ( MemoryRead(DMNI_SEND_ACTIVE) ) + return 0; + + send_message_request(producer_task, consumer_task, producer_PE, net_address, 0); + + } + + //Sets task as waiting blocking its execution, it will execute again when the message is produced by a WRITEPIPE or incoming MSG_DELIVERY + current->scheduling_ptr->waiting_msg = 1; + + schedule_after_syscall = 1; + + return 0; + + case GETTICK: + + return MemoryRead(TICK_COUNTER); + + break; + + case ECHO: + + puts("$$$_"); + puts(itoa(net_address>>8));puts("x");puts(itoa(net_address&0xFF)); puts("_"); + puts(itoa(current->id >> 8)); puts("_"); + puts(itoa(current->id & 0xFF)); puts("_"); + puts((char *)((current->offset) | (unsigned int) arg0)); + puts("\n"); + + break; + + case REALTIME: + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + if (MemoryRead(DMNI_SEND_ACTIVE)){ + return 0; + } + + //putsv("\nReal-time to task: ", current->id); + + real_time_task(current->scheduling_ptr, arg0, arg1, arg2); + + //send_task_real_time_change(current); + + schedule_after_syscall = 1; + + return 1; + + //Bruno Modification's 15/09 + //These changes were made in order to be able to send data out of the NoC. + //Concept is based on sending the first bit high will enable the function and the 2 others decide where to send it (in the switchcontrol). + case TRANSIT: + + consumer_task = current->id; + producer_task = (int) arg0; + + appID = consumer_task >> 8; + producer_task = (arg1 << 8) | producer_task; + + //puts("READPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); + + producer_PE = get_task_location(producer_task); + + //Test if the producer task is not allocated + if (producer_PE == -1){ + //Task is blocked until its a TASK_RELEASE packet + current->scheduling_ptr->status = BLOCKED; + return 0; + } + + if (producer_PE == net_address){ //Local producer + + //Searches if the message is in PIPE (local producer) + pipe_ptr = remove_PIPE(producer_task, consumer_task); + + if (pipe_ptr == 0){ + + //Stores the request into the message request table (local producer) + insert_message_request(producer_task, consumer_task, net_address); + + } else { + + //Message was found in pipe, writes to the consumer page address (local producer) + + msg_write = (Message*) arg2; + + msg_write = (Message*)((current->offset) | ((unsigned int)msg_write)); + + msg_write->length = pipe_ptr->message.length; + + for (int i = 0; ilength; i++) { + msg_write->msg[i] = pipe_ptr->message.msg[i]; + } + + return 1; + } + + } else { //Remote producer : Sends the message request (remote producer) + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + if ( MemoryRead(DMNI_SEND_ACTIVE) ) + return 0; + + generateInjection(producer_task, consumer_task, producer_PE, net_address, 0); + + return 0; + + break; + } + + return 0; +} + +/** Handles a new packet from NoC + */ +int handle_packet(volatile ServiceHeader * p) { + + int need_scheduling, code_lenght, app_ID, task_loc; + unsigned int app_tasks_location[MAX_TASKS_APP]; + PipeSlot * slot_ptr; + Message * msg_ptr; + TCB * tcb_ptr = 0; + + need_scheduling = 0; + + switch (p->service) { + + case MESSAGE_REQUEST: //This case is the most complicated of the HeMPS if you understand it, so you understand all task communication protocol + //This case sincronizes the communication messages also in case of task migration, the migration allows several scenarios, that are handled inside this case + + //Gets the location of the producer task + task_loc = get_task_location(p->producer_task); + + //Test if the task was migrated to this processor but have message produced in the old processor + //In this case is necessary to forward the message request to the old processor + if (searchTCB(p->producer_task) && task_loc != net_address){ + if (p->insert_request) + insert_message_request(p->producer_task, p->consumer_task, p->requesting_processor); + else + //MESSAGE_REQUEST by pass + send_message_request(p->producer_task, p->consumer_task, task_loc, p->requesting_processor, 0); + + break; + } + + //Remove msg from PIPE, if there is no message, them slot_ptr will be 0 + //Note that this line, is below to the by pass above, becase we need to avoid that the a message be removed if still there are other messages in pipe of the old proc + slot_ptr = remove_PIPE(p->producer_task, p->consumer_task); + + //Test if there is no message in PIPE + if (slot_ptr == 0){ + + //Test if the producer task is running at this processor, this conditions work togheter to the first by pass condition (above). + if (task_loc == net_address){ + + insert_message_request(p->producer_task, p->consumer_task, p->requesting_processor); + + } else { //If not, the task was migrated and the requester message_request need to be forwarded to the correct producer proc + + //If there is no more messages in the pipe of the producer, update the location of the migrated task at the remote proc + if ( search_PIPE_producer(p->producer_task) == 0) + send_update_task_location(p->requesting_processor, p->producer_task, task_loc); + + //MESSAGE_REQUEST by pass with flag insert in pipe enabled (there is no more message for the requesting task in this processor) + send_message_request(p->producer_task, p->consumer_task, task_loc, p->requesting_processor, 1); + } + + //message found, send it!! + } else if (p->requesting_processor != net_address){ + + send_message_delivery(p->producer_task, p->consumer_task, p->requesting_processor, &slot_ptr->message); + + //This else is executed when this slave received a own MESSAGE_REQUEST due a task migration by pass + } else { + + tcb_ptr = searchTCB(p->consumer_task); + + write_local_msg_to_task(tcb_ptr, slot_ptr->message.length, slot_ptr->message.msg); + } + + break; + + case MESSAGE_DELIVERY: + + tcb_ptr = searchTCB(p->consumer_task); + + msg_ptr = (Message *)(tcb_ptr->offset | tcb_ptr->reg[3]); + + msg_ptr->length = p->msg_lenght; + + DMNI_read_data((unsigned int)msg_ptr->msg, msg_ptr->length); + + tcb_ptr->reg[0] = 1; + + //Release task to execute + tcb_ptr->scheduling_ptr->waiting_msg = 0; + +#if MIGRATION_ENABLED + if (tcb_ptr->proc_to_migrate != -1){ + + migrate_dynamic_memory(tcb_ptr); + + need_scheduling = 1; + + } else +#endif + + if (current == &idle_tcb){ + need_scheduling = 1; + } + + break; + + case TASK_ALLOCATION: + + tcb_ptr = search_free_TCB(); + + tcb_ptr->pc = 0; + + tcb_ptr->id = p->task_ID; + + puts("Task id: "); puts(itoa(tcb_ptr->id)); putsv(" allocated at ", MemoryRead(TICK_COUNTER)); + + code_lenght = p->code_size; + + tcb_ptr->text_lenght = code_lenght; + + tcb_ptr->master_address = p->master_ID; + + tcb_ptr->proc_to_migrate = -1; + + tcb_ptr->scheduling_ptr->remaining_exec_time = MAX_TIME_SLICE; + + DMNI_read_data(tcb_ptr->offset, code_lenght); + + tcb_ptr->scheduling_ptr->status = BLOCKED; + + send_task_allocated(tcb_ptr); + + if (current == &idle_tcb){ + need_scheduling = 1; + } + + break; + + case TASK_RELEASE: + + tcb_ptr = searchTCB(p->task_ID); + + app_ID = p->task_ID >> 8; + + //putsv("-> TASK RELEASE received to task ", p->task_ID); + + tcb_ptr->data_lenght = p->data_size; + + tcb_ptr->bss_lenght = p->bss_size; + + tcb_ptr->text_lenght = tcb_ptr->text_lenght - tcb_ptr->data_lenght; + + if (tcb_ptr->scheduling_ptr->status == BLOCKED) + tcb_ptr->scheduling_ptr->status = READY; + + DMNI_read_data( (unsigned int) app_tasks_location, p->app_task_number); + + if (get_task_location(tcb_ptr->id) == -1){ + for (int i = 0; i < p->app_task_number; i++){ + add_task_location(app_ID << 8 | i, app_tasks_location[i]); + } + } + + if (current == &idle_tcb){ + need_scheduling = 1; + } + + break; + + case UPDATE_TASK_LOCATION: + + if (is_another_task_running(p->task_ID >> 8) ){ + + remove_task_location(p->task_ID); + + add_task_location(p->task_ID, p->allocated_processor); + + } + + break; + + case INITIALIZE_SLAVE: + + cluster_master_address = p->source_PE; + + putsv("Slave initialized by cluster address: ", cluster_master_address); + + break; + +#if MIGRATION_ENABLED + case TASK_MIGRATION: + case MIGRATION_CODE: + case MIGRATION_TCB: + case MIGRATION_TASK_LOCATION: + case MIGRATION_MSG_REQUEST: + case MIGRATION_STACK: + case MIGRATION_DATA_BSS: + + need_scheduling = handle_migration(p, cluster_master_address); + + break; +#endif + + default: + putsv("ERROR: service unknown: ", MemoryRead(TICK_COUNTER)); + break; + } + + return need_scheduling; +} + +/** Generic task scheduler call + */ +void Scheduler() { + + Scheduling * scheduled; + unsigned int scheduler_call_time; + + scheduler_call_time = MemoryRead(TICK_COUNTER); + + MemoryWrite(SCHEDULING_REPORT, SCHEDULER); + + #if MIGRATION_ENABLED + if (current->proc_to_migrate != -1 && current->scheduling_ptr->status == RUNNING && current->scheduling_ptr->waiting_msg == 0) + migrate_dynamic_memory(current); + #endif + + scheduled = LST(scheduler_call_time); + + if (scheduled){ + + //This cast is an approach to reduce the scheduler call overhead + current = (TCB *) scheduled->tcb_ptr; + + MemoryWrite(SCHEDULING_REPORT, current->id); + + } else { + + current = &idle_tcb; // schedules the idle task + + last_idle_time = MemoryRead(TICK_COUNTER); + + MemoryWrite(SCHEDULING_REPORT, IDLE); + } + + MemoryWrite(TIME_SLICE, get_time_slice() ); + + OS_InterruptMaskSet(IRQ_SCHEDULER); + +} + +/** Function called by assembly (into interruption handler). Implements the routine to handle interruption in HeMPS + * This function must implement a important rule: it cannot send a packet when the DMNI is already send a packet. + * The interruption triggers according to the DMNI status, and the if-else statements inside this function ensure this + * behavior. + * \param status Status of the interruption. Signal the interruption type + */ +void OS_InterruptServiceRoutine(unsigned int status) { + + MemoryWrite(SCHEDULING_REPORT, INTERRUPTION); + + volatile ServiceHeader p; + ServiceHeader * next_service; + unsigned call_scheduler; + + + if (current == &idle_tcb){ + total_slack_time += MemoryRead(TICK_COUNTER) - last_idle_time; + } + + call_scheduler = 0; + + //***** Check if interruption comes from NoC + if ( status & IRQ_NOC ){ + + read_packet((ServiceHeader *)&p); + + if (MemoryRead(DMNI_SEND_ACTIVE) && (p.service == MESSAGE_REQUEST || p.service == TASK_MIGRATION) ){ + + add_pending_service((ServiceHeader *)&p); + + } else { + + call_scheduler = handle_packet(&p); + } + + //**** Handles remaining packets + } else if (status & IRQ_PENDING_SERVICE) { + + next_service = get_next_pending_service(); + if (next_service){ + call_scheduler = handle_packet(next_service); + } + //***** Send the monitoring packet + } else if (status & IRQ_SLACK_TIME){ + send_slack_time_report(); + total_slack_time = 0; + MemoryWrite(SLACK_TIME_MONITOR, 0); + } + + + if ( status & IRQ_SCHEDULER ){ + + call_scheduler = 1; + } + + + if (call_scheduler){ + + Scheduler(); + + } else if (current == &idle_tcb){ + + last_idle_time = MemoryRead(TICK_COUNTER); + + MemoryWrite(SCHEDULING_REPORT, IDLE); + + } else { + MemoryWrite(SCHEDULING_REPORT, current->id); + } + + /*runs the scheduled task*/ + ASM_RunScheduledTask(current); +} + +/** Clear a interruption mask + * \param Mask Interruption mask clear + */ +unsigned int OS_InterruptMaskClear(unsigned int Mask) { + + unsigned int mask; + + mask = MemoryRead(IRQ_MASK) & ~Mask; + MemoryWrite(IRQ_MASK, mask); + + return mask; +} + +/** Set a interruption mask + * \param Mask Interruption mask set + */ +unsigned int OS_InterruptMaskSet(unsigned int Mask) { + + unsigned int mask; + + mask = MemoryRead(IRQ_MASK) | Mask; + MemoryWrite(IRQ_MASK, mask); + + return mask; +} + +/** Idle function + */ +void OS_Idle() { + for (;;){ + MemoryWrite(CLOCK_HOLD, 1); + } +} + +int main(){ + + ASM_SetInterruptEnable(FALSE); + + idle_tcb.pc = (unsigned int) &OS_Idle; + idle_tcb.id = 0; + idle_tcb.offset = 0; + + total_slack_time = 0; + + last_idle_time = MemoryRead(TICK_COUNTER); + + current = &idle_tcb; + + net_address = MemoryRead(NI_CONFIG); + + puts("Initializing PE: "); puts(itoh(net_address)); puts("\n"); + + init_communication(); + + init_service_header_slots(); + + init_task_location(); + + init_TCBs(); + + /*disable interrupts*/ + OS_InterruptMaskClear(0xffffffff); + + /*enables timeslice counter and wrapper interrupts*/ + OS_InterruptMaskSet(IRQ_SCHEDULER | IRQ_NOC | IRQ_PENDING_SERVICE | IRQ_SLACK_TIME); + + /*runs the scheduled task*/ + ASM_RunScheduledTask(current); + + return 0; +} diff --git a/kernel_slave.h b/kernel_slave.h new file mode 100644 index 0000000..28cf1b9 --- /dev/null +++ b/kernel_slave.h @@ -0,0 +1,44 @@ +/*!\file kernel_slave.h + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief + * kernel_slave is the core of the OS running into the slave processors + * + * \detailed + * Its job is to runs the user's task. It communicates whit the kernel_master to receive new tasks + * and also notifying its finish. + * The kernel_slave file uses several modules that implement specific functions + */ + +#ifndef __KERNEL_SLAVE_H__ +#define __KERNEL_SLAVE_H__ + +#include "../../modules/task_control.h" + +/* + * ENABLE MODULES + */ +#define MIGRATION_ENABLED 1 //!< Enable or disable the migration module + + +extern unsigned int ASM_SetInterruptEnable(unsigned int); +extern void ASM_SaveRemainingContext(TCB*); +extern void ASM_RunScheduledTask(TCB*); +void OS_InterruptServiceRoutine(unsigned int); + +// ISR +unsigned int OS_InterruptMaskSet(unsigned int); +unsigned int OS_InterruptMaskClear(unsigned int); + +void OS_Init(); +void OS_Idle(); + +void Scheduler(); + +#endif diff --git a/services.h b/services.h new file mode 100644 index 0000000..5a2d0e5 --- /dev/null +++ b/services.h @@ -0,0 +1,52 @@ +/*!\file services.h + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief Kernel services definitions. This services are used to + * identifies a packet. + */ + +#ifndef __SERVICES_H__ +#define __SERVICES_H__ + +#define MESSAGE_REQUEST 0x00000010 +#define MESSAGE_DELIVERY 0x00000020 +#define TASK_ALLOCATION 0x00000040 +#define TASK_ALLOCATED 0x00000050 +#define TASK_REQUEST 0x00000060 +#define TASK_TERMINATED 0x00000070 +#define LOAN_PROCESSOR_RELEASE 0x00000090 +#define DEBUG_MESSAGE 0x00000100 +#define NEW_TASK 0x00000130 +#define APP_TERMINATED 0x00000140 +#define NEW_APP 0x00000150 +#define INITIALIZE_CLUSTER 0x00000160 +#define INITIALIZE_SLAVE 0x00000170 +#define TASK_TERMINATED_OTHER_CLUSTER 0x00000180 +#define LOAN_PROCESSOR_REQUEST 0x00000190 +#define LOAN_PROCESSOR_DELIVERY 0x00000200 +#define TASK_MIGRATION 0x00000210 +#define MIGRATION_CODE 0x00000220 +#define MIGRATION_TCB 0x00000221 +#define MIGRATION_TASK_LOCATION 0x00000222 +#define MIGRATION_MSG_REQUEST 0x00000223 +#define MIGRATION_STACK 0x00000224 +#define MIGRATION_DATA_BSS 0x00000225 +#define UPDATE_TASK_LOCATION 0x00000230 +#define TASK_MIGRATED 0x00000235 +#define APP_ALLOCATION_REQUEST 0x00000240 +#define TASK_RELEASE 0x00000250 +#define SLACK_TIME_REPORT 0x00000260 +#define DEADLINE_MISS_REPORT 0x00000270 +#define REAL_TIME_CHANGE 0x00000280 +#define BORDER_ROUTE 0x00000380 + + + + +#endif From a24a842038d14b78b9913ad50e29bdb274c37a39 Mon Sep 17 00:00:00 2001 From: b-scherer Date: Wed, 20 Sep 2017 17:17:06 -0300 Subject: [PATCH 09/54] Add files via upload SW for Border Route --- software/include/api.h | 9 +- software/include/services.h | 2 +- software/kernel/slave/kernel_slave.c | 68 +- software/kernel/slave/kernel_slave_old.c | 864 +++++++++++++++++++++++ software/modules/packet.h | 4 - 5 files changed, 937 insertions(+), 10 deletions(-) create mode 100644 software/kernel/slave/kernel_slave_old.c diff --git a/software/include/api.h b/software/include/api.h index 7965084..43c9225 100644 --- a/software/include/api.h +++ b/software/include/api.h @@ -21,8 +21,9 @@ #define READPIPE 2 #define GETTICK 3 #define ECHO 4 -#define REALTIME 5 - +#define REALTIME 5 +#define TRANSIT 6 + #define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) #define TRUE 1 #define FALSE 0 @@ -35,6 +36,10 @@ extern int SystemCall(); #define Echo(str) SystemCall(ECHO, (char*)str,0,0) #define exit() while(!SystemCall(EXIT, 0, 0, 0)) +// Bruno's modification 14/09 - The change reflects the need of a transit message to send packets outside the NoC. +// The call is Target (Border Router, out_target (00 - South, 01 - West, 10 - East, 11 - North), message (payload)) +#define Transit(target, out_target, msg) while (!SystemCall(TRANSIT, target, out_target, (unsigned int*)msg)) + //Real-Time API - time represented in microseconds #define RealTime(period, deadline, execution_time) while(!SystemCall(REALTIME, period, deadline, execution_time)) diff --git a/software/include/services.h b/software/include/services.h index 4f5e565..bcc4059 100644 --- a/software/include/services.h +++ b/software/include/services.h @@ -44,6 +44,6 @@ #define SLACK_TIME_REPORT 0x00000260 #define DEADLINE_MISS_REPORT 0x00000270 #define REAL_TIME_CHANGE 0x00000280 -#define BORDER_ROUTE 0x00000290 +#define BORDER_ROUTE 0x00000310 #endif diff --git a/software/kernel/slave/kernel_slave.c b/software/kernel/slave/kernel_slave.c index a141da0..1041e1a 100644 --- a/software/kernel/slave/kernel_slave.c +++ b/software/kernel/slave/kernel_slave.c @@ -221,7 +221,6 @@ void send_message_request(int producer_task, int consumer_task, unsigned int tar send_packet(p, 0, 0); } - /** Useful function to writes a message into the task page space * \param task_tcb_ptr TCB pointer of the task * \param msg_lenght Lenght of the message to be copied @@ -466,12 +465,75 @@ int Syscall(unsigned int service, unsigned int arg0, unsigned int arg1, unsigned return 1; + //Bruno Modification's 15/09 + //These changes were made in order to be able to send data out of the NoC. + //Concept is based on sending the first bit high will enable the function and the 2 others decide where to send it (in the switchcontrol). + break; - } + case TRANSIT: + consumer_task = current->id; + producer_task = (int) arg0; + + appID = consumer_task >> 8; + // Here we shift the arg1 + producer_task = (arg1 << 8) | producer_task; + + puts("TRANSIT - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); + + producer_PE = get_task_location(producer_task); + + //Test if the producer task is not allocated + if (producer_PE == -1){ + //Task is blocked until its a TASK_RELEASE packet + current->scheduling_ptr->status = BLOCKED; + return 0; + } + if (producer_PE == net_address){ //Local producer + //Searches if the message is in PIPE (local producer) + pipe_ptr = remove_PIPE(producer_task, consumer_task); + + if (pipe_ptr == 0){ + + //Stores the request into the message request table (local producer) + insert_message_request(producer_task, consumer_task, net_address); + + } else { + //Message was found in pipe, writes to the consumer page address (local producer) + msg_write = (Message*) arg2; + msg_write = (Message*)((current->offset) | ((unsigned int)msg_write)); + msg_write->length = pipe_ptr->message.length; + for (int i = 0; ilength; i++) { + msg_write->msg[i] = pipe_ptr->message.msg[i]; + } + return 1; + } + } else + { //Remote producer : Sends the message request (remote producer) + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + // Revisar para fazer um pooling ao invés de um if aqui (vai ficar bloqueante). + while( MemoryRead(DMNI_SEND_ACTIVE) ) + return 0; + // Mover o generateinjection aqui para dentro e usar o send packet na propria syscall + ServiceHeader *p = get_service_header_slot(); + p-> header = producer_task; + p-> service = BORDER_ROUTE; + p-> requesting_processor = net_address; + p-> producer_task = producer_task; + p-> consumer_task = consumer_task; + //p-> msg_lenght=3333; + //p-> tasks_of_same_app=4444; + //p-> code_size=5555; + //p-> bss_size=6666; + //p-> initial_address=7777; + send_packet(p, (unsigned int)msg_write->msg, msg_write->length); + + } + break; return 0; + } } - /** Handles a new packet from NoC */ int handle_packet(volatile ServiceHeader * p) { diff --git a/software/kernel/slave/kernel_slave_old.c b/software/kernel/slave/kernel_slave_old.c new file mode 100644 index 0000000..a141da0 --- /dev/null +++ b/software/kernel/slave/kernel_slave_old.c @@ -0,0 +1,864 @@ +/*!\file kernel_slave.c + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief + * Kernel slave is the system slave used to execute user's tasks. + * + * \detailed + * kernel_slave is the core of the OS running into the slave processors. + * Its job is to runs the user's task. It communicates whit the kernel_master to receive new tasks + * and also notifying its finish. + * The kernel_slave file uses several modules that implement specific functions + */ + +#include "kernel_slave.h" + +#include "../../../include/kernel_pkg.h" +#include "../../include/api.h" +#include "../../include/plasma.h" +#include "../../include/services.h" +#include "../../modules/task_location.h" +#include "../../modules/packet.h" +#include "../../modules/communication.h" +#include "../../modules/pending_service.h" +#include "../../modules/task_scheduler.h" +#include "../../modules/utils.h" +#if MIGRATION_ENABLED +#include "../../modules/task_migration.h" +#endif + +//Globals +unsigned int net_address; //!< Store the current XY address +unsigned int schedule_after_syscall; //!< Signals the syscall function (assembly implemented) to call the scheduler after the syscall +unsigned int cluster_master_address; //!< Store the cluster master XY address +unsigned int last_idle_time; //!< Store the last idle time duration +unsigned int total_slack_time; //!< Store the total of the processor idle time +TCB idle_tcb; //!< TCB pointer used to run idle task +TCB * current; //!< TCB pointer used to store the current task executing into processor +Message msg_write_pipe; //!< Message variable which is used to copy a message and send it by the NoC + + +/** Assembles and sends a TASK_TERMINATED packet to the master kernel + * \param terminated_task Terminated task TCB pointer + */ +void send_task_terminated(TCB * terminated_task){ + + ServiceHeader *p = get_service_header_slot(); + + p->header = terminated_task->master_address; + + p->service = TASK_TERMINATED; + + p->task_ID = terminated_task->id; + + p->master_ID = cluster_master_address; + + send_packet(p, 0, 0); + + if (terminated_task->master_address != cluster_master_address){ + + p = get_service_header_slot(); + + p->header = cluster_master_address; + + p->service = TASK_TERMINATED_OTHER_CLUSTER; + + p->task_ID = terminated_task->id; + + p->master_ID = terminated_task->master_address; + + send_packet(p, 0, 0); + } + +} + +/** Assembles and sends a TASK_ALLOCATED packet to the master kernel + * \param allocated_task Allocated task TCB pointer + */ +void send_task_allocated(TCB * allocated_task){ + + ServiceHeader *p = get_service_header_slot(); + + p->header = allocated_task->master_address; + + p->service = TASK_ALLOCATED; + + p->task_ID = allocated_task->id; + + p->master_ID = cluster_master_address; + + send_packet(p, 0, 0); +} + +/** Assembles and sends a MESSAGE_DELIVERY packet to a consumer task located into a slave processor + * \param producer_task ID of the task that produce the message (Send()) + * \param consumer_task ID of the task that consume the message (Receive()) + * \param msg_ptr Message pointer + */ +void send_message_delivery(int producer_task, int consumer_task, int consumer_PE, Message * msg_ptr){ + + ServiceHeader *p = get_service_header_slot(); + + p->header = consumer_PE; + + p->service = MESSAGE_DELIVERY; + + p->producer_task = producer_task; + + p->consumer_task = consumer_task; + + p->msg_lenght = msg_ptr->length; + + send_packet(p, (unsigned int)msg_ptr->msg, msg_ptr->length); + +} + +/** Assembles and sends a REAL_TIME_CHANGE packet to the master kernel + * \param tcb_ptr TCB pointer of the task that change its real-time parameters + */ +void send_task_real_time_change(TCB * tcb_ptr){ + + ServiceHeader * p = get_service_header_slot(); + + p = get_service_header_slot(); + + p->header = cluster_master_address; + + p->service = REAL_TIME_CHANGE; + + p->task_ID = tcb_ptr->id; + + p->utilization = tcb_ptr->scheduling_ptr->utilization; + + putsv("Send real time change, utilization: ", p->utilization); + + send_packet(p, 0, 0); +} + +/** Assembles and sends a SLACK_TIME_REPORT packet to the master kernel + */ +void send_slack_time_report(){ + + ServiceHeader * p = get_service_header_slot(); + + p->header = cluster_master_address; + + p->service = SLACK_TIME_REPORT; + + p->cpu_slack_time = ( (total_slack_time*100) / SLACK_TIME_WINDOW); + + send_packet(p, 0, 0); +} + +/** Assembles and sends a UPDATE_TASK_LOCATION packet to a slave processor. Useful because task migration + * \param target_proc Target slave processor which the packet will be sent + * \param task_id Task ID that have its location updated + * \param new_task_location New location (slave processor address) of the task + */ +void send_update_task_location(unsigned int target_proc, unsigned int task_id, unsigned int new_task_location){ + + ServiceHeader *p = get_service_header_slot(); + + if (target_proc != net_address){ + + p->header = target_proc; + + p->service = UPDATE_TASK_LOCATION; + + p->task_ID = task_id; + + p->allocated_processor = new_task_location; + + send_packet(p, 0, 0); + } + + if (target_proc != new_task_location){ + + p = get_service_header_slot(); + + p->header = new_task_location; + + p->service = UPDATE_TASK_LOCATION; + + p->task_ID = task_id; + + p->allocated_processor = new_task_location; + + send_packet(p, 0, 0); + } +} + +/** Assembles and sends a MESSAGE_REQUEST packet to producer task into a slave processor + * \param producer_task Producer task ID (Send()) + * \param consumer_task Consumer task ID (Receive()) + * \param targetPE Processor address of the producer task + * \param requestingPE Processor address of the consumer task + * \param insert_pipe_flag Tells to the producer PE that the message not need to be by passed again + */ +void send_message_request(int producer_task, int consumer_task, unsigned int targetPE, unsigned int requestingPE, int insert_pipe_flag){ + + + ServiceHeader *p = get_service_header_slot(); + + p->header = targetPE; + + p->service = MESSAGE_REQUEST; + + p->requesting_processor = requestingPE; + + p->producer_task = producer_task; + + p->consumer_task = consumer_task; + + p->insert_request = insert_pipe_flag; + + send_packet(p, 0, 0); +} + + +/** Useful function to writes a message into the task page space + * \param task_tcb_ptr TCB pointer of the task + * \param msg_lenght Lenght of the message to be copied + * \param msg_data Message data + */ +void write_local_msg_to_task(TCB * task_tcb_ptr, int msg_lenght, int * msg_data){ + + Message * msg_ptr; + + msg_ptr = (Message*)((task_tcb_ptr->offset) | ((unsigned int)task_tcb_ptr->reg[3])); //reg[3] = address message + + msg_ptr->length = msg_lenght; + + for (int i=0; ilength; i++) + msg_ptr->msg[i] = msg_data[i]; + + //Unlock the blocked task + task_tcb_ptr->reg[0] = TRUE; + + //Release task to execute + task_tcb_ptr->scheduling_ptr->waiting_msg = 0; +} + +/** Syscall handler. It is called when a task calls a function defined into the api.h file + * \param service Service of the syscall + * \param arg0 Generic argument + * \param arg1 Generic argument + * \param arg2 Generic argument + */ +int Syscall(unsigned int service, unsigned int arg0, unsigned int arg1, unsigned int arg2) { + + Message *msg_read; + Message *msg_write; + PipeSlot *pipe_ptr; + MessageRequest * msg_req_ptr; + int consumer_task; + int producer_task; + int producer_PE; + int consumer_PE; + int appID; + int ret; + + schedule_after_syscall = 0; + + switch (service) { + + case EXIT: + + schedule_after_syscall = 1; + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + //Also, due task migration sincronization messages, the producer task cannot finish it execution while have messages in PIPE + if (MemoryRead(DMNI_SEND_ACTIVE) || search_PIPE_producer(current->id)){ + return 0; + } + + puts("Task id: "); puts(itoa(current->id)); putsv(" terminated at ", MemoryRead(TICK_COUNTER)); + + send_task_terminated(current); + + clear_scheduling(current->scheduling_ptr); + + appID = current->id >> 8; + + if ( !is_another_task_running(appID) ){ + + clear_app_tasks_locations(appID); + } + + return 1; + + case WRITEPIPE: + + producer_task = current->id; + consumer_task = (int) arg1; + + appID = producer_task >> 8; + consumer_task = (appID << 8) | consumer_task; + + //puts("WRITEPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); + + consumer_PE = get_task_location(consumer_task); + + //Test if the consumer task is not allocated + if (consumer_PE == -1){ + //Task is blocked until its a TASK_RELEASE packet + current->scheduling_ptr->status = BLOCKED; + return 0; + } + + /*Points the message in the task page. Address composition: offset + msg address*/ + msg_read = (Message *)((current->offset) | arg0); + + //Searches if there is a message request to the produced message + msg_req_ptr = remove_message_request(producer_task, consumer_task); + + if (msg_req_ptr){ + + if (msg_req_ptr->requester_proc == net_address){ //Test if the consumer is local or remote + + //Writes to the consumer page address (local consumer) + TCB * requesterTCB = searchTCB(consumer_task); + + write_local_msg_to_task(requesterTCB, msg_read->length, msg_read->msg); + +#if MIGRATION_ENABLED + if (requesterTCB->proc_to_migrate != -1){ + + migrate_dynamic_memory(requesterTCB); + + schedule_after_syscall = 1; + } +#endif + + } else { //Send a mesage delivery (remote consumer) + + //Deadlock avoidance: voids to send a packet when the DMNI is busy in send process + if ( MemoryRead(DMNI_SEND_ACTIVE) ){ + //Restore the message request + msg_req_ptr->requested = producer_task; + msg_req_ptr->requester = consumer_task; + return 0; + } + + msg_write_pipe.length = msg_read->length; + + //Avoids message overwriting by the producer task + for (int i=0; i < msg_read->length; i++) + msg_write_pipe.msg[i] = msg_read->msg[i]; + + send_message_delivery(producer_task, consumer_task, msg_req_ptr->requester_proc, &msg_write_pipe); + + } + } else { //message not requested yet, stores into PIPE + + //########################### ADD PIPE ################################# + ret = add_PIPE(producer_task, consumer_task, msg_read); + //########################### ADD PIPE ################################# + + if (ret == 0){ + schedule_after_syscall = 1; + return 0; + } + } + + return 1; + + case READPIPE: + + consumer_task = current->id; + producer_task = (int) arg1; + + appID = consumer_task >> 8; + producer_task = (appID << 8) | producer_task; + + //puts("READPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); + + producer_PE = get_task_location(producer_task); + + //Test if the producer task is not allocated + if (producer_PE == -1){ + //Task is blocked until its a TASK_RELEASE packet + current->scheduling_ptr->status = BLOCKED; + return 0; + } + + if (producer_PE == net_address){ //Local producer + + //Searches if the message is in PIPE (local producer) + pipe_ptr = remove_PIPE(producer_task, consumer_task); + + if (pipe_ptr == 0){ + + //Stores the request into the message request table (local producer) + insert_message_request(producer_task, consumer_task, net_address); + + } else { + + //Message was found in pipe, writes to the consumer page address (local producer) + + msg_write = (Message*) arg0; + + msg_write = (Message*)((current->offset) | ((unsigned int)msg_write)); + + msg_write->length = pipe_ptr->message.length; + + for (int i = 0; ilength; i++) { + msg_write->msg[i] = pipe_ptr->message.msg[i]; + } + + return 1; + } + + } else { //Remote producer : Sends the message request (remote producer) + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + if ( MemoryRead(DMNI_SEND_ACTIVE) ) + return 0; + + send_message_request(producer_task, consumer_task, producer_PE, net_address, 0); + + } + + //Sets task as waiting blocking its execution, it will execute again when the message is produced by a WRITEPIPE or incoming MSG_DELIVERY + current->scheduling_ptr->waiting_msg = 1; + + schedule_after_syscall = 1; + + return 0; + + case GETTICK: + + return MemoryRead(TICK_COUNTER); + + break; + + case ECHO: + + puts("$$$_"); + puts(itoa(net_address>>8));puts("x");puts(itoa(net_address&0xFF)); puts("_"); + puts(itoa(current->id >> 8)); puts("_"); + puts(itoa(current->id & 0xFF)); puts("_"); + puts((char *)((current->offset) | (unsigned int) arg0)); + puts("\n"); + + break; + + case REALTIME: + + //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process + if (MemoryRead(DMNI_SEND_ACTIVE)){ + return 0; + } + + //putsv("\nReal-time to task: ", current->id); + + real_time_task(current->scheduling_ptr, arg0, arg1, arg2); + + //send_task_real_time_change(current); + + schedule_after_syscall = 1; + + return 1; + + break; + } + + return 0; +} + +/** Handles a new packet from NoC + */ +int handle_packet(volatile ServiceHeader * p) { + + int need_scheduling, code_lenght, app_ID, task_loc; + unsigned int app_tasks_location[MAX_TASKS_APP]; + PipeSlot * slot_ptr; + Message * msg_ptr; + TCB * tcb_ptr = 0; + + need_scheduling = 0; + + switch (p->service) { + + case MESSAGE_REQUEST: //This case is the most complicated of the HeMPS if you understand it, so you understand all task communication protocol + //This case sincronizes the communication messages also in case of task migration, the migration allows several scenarios, that are handled inside this case + + //Gets the location of the producer task + task_loc = get_task_location(p->producer_task); + + //Test if the task was migrated to this processor but have message produced in the old processor + //In this case is necessary to forward the message request to the old processor + if (searchTCB(p->producer_task) && task_loc != net_address){ + if (p->insert_request) + insert_message_request(p->producer_task, p->consumer_task, p->requesting_processor); + else + //MESSAGE_REQUEST by pass + send_message_request(p->producer_task, p->consumer_task, task_loc, p->requesting_processor, 0); + + break; + } + + //Remove msg from PIPE, if there is no message, them slot_ptr will be 0 + //Note that this line, is below to the by pass above, becase we need to avoid that the a message be removed if still there are other messages in pipe of the old proc + slot_ptr = remove_PIPE(p->producer_task, p->consumer_task); + + //Test if there is no message in PIPE + if (slot_ptr == 0){ + + //Test if the producer task is running at this processor, this conditions work togheter to the first by pass condition (above). + if (task_loc == net_address){ + + insert_message_request(p->producer_task, p->consumer_task, p->requesting_processor); + + } else { //If not, the task was migrated and the requester message_request need to be forwarded to the correct producer proc + + //If there is no more messages in the pipe of the producer, update the location of the migrated task at the remote proc + if ( search_PIPE_producer(p->producer_task) == 0) + send_update_task_location(p->requesting_processor, p->producer_task, task_loc); + + //MESSAGE_REQUEST by pass with flag insert in pipe enabled (there is no more message for the requesting task in this processor) + send_message_request(p->producer_task, p->consumer_task, task_loc, p->requesting_processor, 1); + } + + //message found, send it!! + } else if (p->requesting_processor != net_address){ + + send_message_delivery(p->producer_task, p->consumer_task, p->requesting_processor, &slot_ptr->message); + + //This else is executed when this slave received a own MESSAGE_REQUEST due a task migration by pass + } else { + + tcb_ptr = searchTCB(p->consumer_task); + + write_local_msg_to_task(tcb_ptr, slot_ptr->message.length, slot_ptr->message.msg); + } + + break; + + case MESSAGE_DELIVERY: + + tcb_ptr = searchTCB(p->consumer_task); + + msg_ptr = (Message *)(tcb_ptr->offset | tcb_ptr->reg[3]); + + msg_ptr->length = p->msg_lenght; + + DMNI_read_data((unsigned int)msg_ptr->msg, msg_ptr->length); + + tcb_ptr->reg[0] = 1; + + //Release task to execute + tcb_ptr->scheduling_ptr->waiting_msg = 0; + +#if MIGRATION_ENABLED + if (tcb_ptr->proc_to_migrate != -1){ + + migrate_dynamic_memory(tcb_ptr); + + need_scheduling = 1; + + } else +#endif + + if (current == &idle_tcb){ + need_scheduling = 1; + } + + break; + + case TASK_ALLOCATION: + + tcb_ptr = search_free_TCB(); + + tcb_ptr->pc = 0; + + tcb_ptr->id = p->task_ID; + + puts("Task id: "); puts(itoa(tcb_ptr->id)); putsv(" allocated at ", MemoryRead(TICK_COUNTER)); + + code_lenght = p->code_size; + + tcb_ptr->text_lenght = code_lenght; + + tcb_ptr->master_address = p->master_ID; + + tcb_ptr->proc_to_migrate = -1; + + tcb_ptr->scheduling_ptr->remaining_exec_time = MAX_TIME_SLICE; + + DMNI_read_data(tcb_ptr->offset, code_lenght); + + tcb_ptr->scheduling_ptr->status = BLOCKED; + + send_task_allocated(tcb_ptr); + + if (current == &idle_tcb){ + need_scheduling = 1; + } + + break; + + case TASK_RELEASE: + + tcb_ptr = searchTCB(p->task_ID); + + app_ID = p->task_ID >> 8; + + //putsv("-> TASK RELEASE received to task ", p->task_ID); + + tcb_ptr->data_lenght = p->data_size; + + tcb_ptr->bss_lenght = p->bss_size; + + tcb_ptr->text_lenght = tcb_ptr->text_lenght - tcb_ptr->data_lenght; + + if (tcb_ptr->scheduling_ptr->status == BLOCKED) + tcb_ptr->scheduling_ptr->status = READY; + + DMNI_read_data( (unsigned int) app_tasks_location, p->app_task_number); + + if (get_task_location(tcb_ptr->id) == -1){ + for (int i = 0; i < p->app_task_number; i++){ + add_task_location(app_ID << 8 | i, app_tasks_location[i]); + } + } + + if (current == &idle_tcb){ + need_scheduling = 1; + } + + break; + + case UPDATE_TASK_LOCATION: + + if (is_another_task_running(p->task_ID >> 8) ){ + + remove_task_location(p->task_ID); + + add_task_location(p->task_ID, p->allocated_processor); + + } + + break; + + case INITIALIZE_SLAVE: + + cluster_master_address = p->source_PE; + + putsv("Slave initialized by cluster address: ", cluster_master_address); + + break; + +#if MIGRATION_ENABLED + case TASK_MIGRATION: + case MIGRATION_CODE: + case MIGRATION_TCB: + case MIGRATION_TASK_LOCATION: + case MIGRATION_MSG_REQUEST: + case MIGRATION_STACK: + case MIGRATION_DATA_BSS: + + need_scheduling = handle_migration(p, cluster_master_address); + + break; +#endif + + default: + putsv("ERROR: service unknown: ", MemoryRead(TICK_COUNTER)); + break; + } + + return need_scheduling; +} + +/** Generic task scheduler call + */ +void Scheduler() { + + Scheduling * scheduled; + unsigned int scheduler_call_time; + + scheduler_call_time = MemoryRead(TICK_COUNTER); + + MemoryWrite(SCHEDULING_REPORT, SCHEDULER); + + #if MIGRATION_ENABLED + if (current->proc_to_migrate != -1 && current->scheduling_ptr->status == RUNNING && current->scheduling_ptr->waiting_msg == 0) + migrate_dynamic_memory(current); + #endif + + scheduled = LST(scheduler_call_time); + + if (scheduled){ + + //This cast is an approach to reduce the scheduler call overhead + current = (TCB *) scheduled->tcb_ptr; + + MemoryWrite(SCHEDULING_REPORT, current->id); + + } else { + + current = &idle_tcb; // schedules the idle task + + last_idle_time = MemoryRead(TICK_COUNTER); + + MemoryWrite(SCHEDULING_REPORT, IDLE); + } + + MemoryWrite(TIME_SLICE, get_time_slice() ); + + OS_InterruptMaskSet(IRQ_SCHEDULER); + +} + +/** Function called by assembly (into interruption handler). Implements the routine to handle interruption in HeMPS + * This function must implement a important rule: it cannot send a packet when the DMNI is already send a packet. + * The interruption triggers according to the DMNI status, and the if-else statements inside this function ensure this + * behavior. + * \param status Status of the interruption. Signal the interruption type + */ +void OS_InterruptServiceRoutine(unsigned int status) { + + MemoryWrite(SCHEDULING_REPORT, INTERRUPTION); + + volatile ServiceHeader p; + ServiceHeader * next_service; + unsigned call_scheduler; + + + if (current == &idle_tcb){ + total_slack_time += MemoryRead(TICK_COUNTER) - last_idle_time; + } + + call_scheduler = 0; + + //***** Check if interruption comes from NoC + if ( status & IRQ_NOC ){ + + read_packet((ServiceHeader *)&p); + + if (MemoryRead(DMNI_SEND_ACTIVE) && (p.service == MESSAGE_REQUEST || p.service == TASK_MIGRATION) ){ + + add_pending_service((ServiceHeader *)&p); + + } else { + + call_scheduler = handle_packet(&p); + } + + //**** Handles remaining packets + } else if (status & IRQ_PENDING_SERVICE) { + + next_service = get_next_pending_service(); + if (next_service){ + call_scheduler = handle_packet(next_service); + } + //***** Send the monitoring packet + } else if (status & IRQ_SLACK_TIME){ + send_slack_time_report(); + total_slack_time = 0; + MemoryWrite(SLACK_TIME_MONITOR, 0); + } + + + if ( status & IRQ_SCHEDULER ){ + + call_scheduler = 1; + } + + + if (call_scheduler){ + + Scheduler(); + + } else if (current == &idle_tcb){ + + last_idle_time = MemoryRead(TICK_COUNTER); + + MemoryWrite(SCHEDULING_REPORT, IDLE); + + } else { + MemoryWrite(SCHEDULING_REPORT, current->id); + } + + /*runs the scheduled task*/ + ASM_RunScheduledTask(current); +} + +/** Clear a interruption mask + * \param Mask Interruption mask clear + */ +unsigned int OS_InterruptMaskClear(unsigned int Mask) { + + unsigned int mask; + + mask = MemoryRead(IRQ_MASK) & ~Mask; + MemoryWrite(IRQ_MASK, mask); + + return mask; +} + +/** Set a interruption mask + * \param Mask Interruption mask set + */ +unsigned int OS_InterruptMaskSet(unsigned int Mask) { + + unsigned int mask; + + mask = MemoryRead(IRQ_MASK) | Mask; + MemoryWrite(IRQ_MASK, mask); + + return mask; +} + +/** Idle function + */ +void OS_Idle() { + for (;;){ + MemoryWrite(CLOCK_HOLD, 1); + } +} + +int main(){ + + ASM_SetInterruptEnable(FALSE); + + idle_tcb.pc = (unsigned int) &OS_Idle; + idle_tcb.id = 0; + idle_tcb.offset = 0; + + total_slack_time = 0; + + last_idle_time = MemoryRead(TICK_COUNTER); + + current = &idle_tcb; + + net_address = MemoryRead(NI_CONFIG); + + puts("Initializing PE: "); puts(itoh(net_address)); puts("\n"); + + init_communication(); + + init_service_header_slots(); + + init_task_location(); + + init_TCBs(); + + /*disable interrupts*/ + OS_InterruptMaskClear(0xffffffff); + + /*enables timeslice counter and wrapper interrupts*/ + OS_InterruptMaskSet(IRQ_SCHEDULER | IRQ_NOC | IRQ_PENDING_SERVICE | IRQ_SLACK_TIME); + + /*runs the scheduled task*/ + ASM_RunScheduledTask(current); + + return 0; +} diff --git a/software/modules/packet.h b/software/modules/packet.h index 59d9e92..d24e616 100644 --- a/software/modules/packet.h +++ b/software/modules/packet.h @@ -33,10 +33,6 @@ typedef struct { unsigned int app_ID; }; - union { //! Date: Wed, 20 Sep 2017 17:17:48 -0300 Subject: [PATCH 10/54] Add files via upload --- example.yaml | 28 ++++++++++++++++++++++++++++ pc1/prod.c~ | 38 ++++++++++++++++++++++++++++++++++++++ pc1/taskA.c | 14 ++++++++++++++ pc1/taskA.c~ | 14 ++++++++++++++ pc1/taskB.c | 14 ++++++++++++++ pc1/taskB.c~ | 14 ++++++++++++++ pc2/prod.c~ | 38 ++++++++++++++++++++++++++++++++++++++ pc2/taskA.c | 14 ++++++++++++++ pc2/taskA.c~ | 15 +++++++++++++++ pc2/taskB.c | 14 ++++++++++++++ pc2/taskB.c~ | 14 ++++++++++++++ 11 files changed, 217 insertions(+) create mode 100644 example.yaml create mode 100644 pc1/prod.c~ create mode 100644 pc1/taskA.c create mode 100644 pc1/taskA.c~ create mode 100644 pc1/taskB.c create mode 100644 pc1/taskB.c~ create mode 100644 pc2/prod.c~ create mode 100644 pc2/taskA.c create mode 100644 pc2/taskA.c~ create mode 100644 pc2/taskB.c create mode 100644 pc2/taskB.c~ diff --git a/example.yaml b/example.yaml new file mode 100644 index 0000000..e56c770 --- /dev/null +++ b/example.yaml @@ -0,0 +1,28 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 3 + repository_size_MB: 1 + model_description: sc # sc (gcc) | scmod (questa) | vhdl + noc_buffer_size: 8 # must be power of 2 + mpsoc_dimension: [4,4] # for while, must be a square shape + cluster_dimension: [2,2] # for while, must be a square shape + master_location: LB # LB +sw: + mapping_algorithm: WithLoad # WithLoad + task_scheduler: round_robin # round_robing | lst + +#--------- Application definitions ----------- +#Example of an application defining static mapping for two tasks +#- name: mpeg +# start_time_ms: 0 #any unsigned integer number +# static_mapping: +# print: [1,1] # Task print from app mpeg will be mapped as static at address X=1, Y=1 +# start: [0,1] # Task start from app mpeg will be mapped as static at address X=1, Y=1 +# +# Attention: When using static mapping all application must be manually sorted by start time +apps: + - name: pc2 + start_time_ms: 1 #any unsigned integer number + - name: pc1 + start_time_ms: 5 + diff --git a/pc1/prod.c~ b/pc1/prod.c~ new file mode 100644 index 0000000..7473dad --- /dev/null +++ b/pc1/prod.c~ @@ -0,0 +1,38 @@ +/* + * prod.c + * + * Created on: 07/03/2013 + * Author: mruaro + */ + +#include +#include +#include "prod_cons_std.h" + +Message msg; + +int main() +{ + + int i; + volatile int t; + + + Echo("Inicio da aplicacao prod"); + + for(i=0;i +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Transit(taskB, 254, &msg); + } + Echo(itoa(GetTick())); + Echo("task A finished."); + exit(); +} diff --git a/pc1/taskA.c~ b/pc1/taskA.c~ new file mode 100644 index 0000000..6268dce --- /dev/null +++ b/pc1/taskA.c~ @@ -0,0 +1,14 @@ +gedit taskB.c +#include +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Send(&msg,taskB); + } + Echo(itoa(GetTick())); + Echo("task A finished."); + exit(); diff --git a/pc1/taskB.c b/pc1/taskB.c new file mode 100644 index 0000000..d4c929a --- /dev/null +++ b/pc1/taskB.c @@ -0,0 +1,14 @@ +#include +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Receive(&msg,taskA); + } + Echo(itoa(GetTick())); + Echo("task B finished."); + exit(); +} diff --git a/pc1/taskB.c~ b/pc1/taskB.c~ new file mode 100644 index 0000000..05f57fa --- /dev/null +++ b/pc1/taskB.c~ @@ -0,0 +1,14 @@ +#include +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Send(1,254,&msg); + } + Echo(itoa(GetTick())); + Echo("task B finished."); + exit(); +} diff --git a/pc2/prod.c~ b/pc2/prod.c~ new file mode 100644 index 0000000..7473dad --- /dev/null +++ b/pc2/prod.c~ @@ -0,0 +1,38 @@ +/* + * prod.c + * + * Created on: 07/03/2013 + * Author: mruaro + */ + +#include +#include +#include "prod_cons_std.h" + +Message msg; + +int main() +{ + + int i; + volatile int t; + + + Echo("Inicio da aplicacao prod"); + + for(i=0;i +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Send(&msg,taskB); + } + Echo(itoa(GetTick())); + Echo("task A finished."); + exit(); +} diff --git a/pc2/taskA.c~ b/pc2/taskA.c~ new file mode 100644 index 0000000..f1f89f3 --- /dev/null +++ b/pc2/taskA.c~ @@ -0,0 +1,15 @@ + +#include +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Send(&msg,taskB); + } + Echo(itoa(GetTick())); + Echo("task A finished."); + exit(); +} diff --git a/pc2/taskB.c b/pc2/taskB.c new file mode 100644 index 0000000..d4c929a --- /dev/null +++ b/pc2/taskB.c @@ -0,0 +1,14 @@ +#include +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Receive(&msg,taskA); + } + Echo(itoa(GetTick())); + Echo("task B finished."); + exit(); +} diff --git a/pc2/taskB.c~ b/pc2/taskB.c~ new file mode 100644 index 0000000..05f57fa --- /dev/null +++ b/pc2/taskB.c~ @@ -0,0 +1,14 @@ +#include +#include +Message msg; +int main(){ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Send(1,254,&msg); + } + Echo(itoa(GetTick())); + Echo("task B finished."); + exit(); +} From 9074f58186fd29b2fd04ba003e522a58c9d05b4f Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 22 Sep 2017 10:30:04 -0300 Subject: [PATCH 11/54] reorganized border_router_test into repo --- {pc1 => applications/pc1}/taskA.c | 0 {pc1 => applications/pc1}/taskB.c | 0 {pc2 => applications/pc2}/taskA.c | 0 {pc2 => applications/pc2}/taskB.c | 0 pc1/prod.c~ | 38 ------------------- pc1/taskA.c~ | 14 ------- pc1/taskB.c~ | 14 ------- pc2/prod.c~ | 38 ------------------- pc2/taskA.c~ | 15 -------- pc2/taskB.c~ | 14 ------- .../border_router_test.yaml | 2 +- 11 files changed, 1 insertion(+), 134 deletions(-) rename {pc1 => applications/pc1}/taskA.c (100%) rename {pc1 => applications/pc1}/taskB.c (100%) rename {pc2 => applications/pc2}/taskA.c (100%) rename {pc2 => applications/pc2}/taskB.c (100%) delete mode 100644 pc1/prod.c~ delete mode 100644 pc1/taskA.c~ delete mode 100644 pc1/taskB.c~ delete mode 100644 pc2/prod.c~ delete mode 100644 pc2/taskA.c~ delete mode 100644 pc2/taskB.c~ rename example.yaml => testcases/border_router_test.yaml (93%) diff --git a/pc1/taskA.c b/applications/pc1/taskA.c similarity index 100% rename from pc1/taskA.c rename to applications/pc1/taskA.c diff --git a/pc1/taskB.c b/applications/pc1/taskB.c similarity index 100% rename from pc1/taskB.c rename to applications/pc1/taskB.c diff --git a/pc2/taskA.c b/applications/pc2/taskA.c similarity index 100% rename from pc2/taskA.c rename to applications/pc2/taskA.c diff --git a/pc2/taskB.c b/applications/pc2/taskB.c similarity index 100% rename from pc2/taskB.c rename to applications/pc2/taskB.c diff --git a/pc1/prod.c~ b/pc1/prod.c~ deleted file mode 100644 index 7473dad..0000000 --- a/pc1/prod.c~ +++ /dev/null @@ -1,38 +0,0 @@ -/* - * prod.c - * - * Created on: 07/03/2013 - * Author: mruaro - */ - -#include -#include -#include "prod_cons_std.h" - -Message msg; - -int main() -{ - - int i; - volatile int t; - - - Echo("Inicio da aplicacao prod"); - - for(i=0;i -#include -Message msg; -int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Send(&msg,taskB); - } - Echo(itoa(GetTick())); - Echo("task A finished."); - exit(); diff --git a/pc1/taskB.c~ b/pc1/taskB.c~ deleted file mode 100644 index 05f57fa..0000000 --- a/pc1/taskB.c~ +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -Message msg; -int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Send(1,254,&msg); - } - Echo(itoa(GetTick())); - Echo("task B finished."); - exit(); -} diff --git a/pc2/prod.c~ b/pc2/prod.c~ deleted file mode 100644 index 7473dad..0000000 --- a/pc2/prod.c~ +++ /dev/null @@ -1,38 +0,0 @@ -/* - * prod.c - * - * Created on: 07/03/2013 - * Author: mruaro - */ - -#include -#include -#include "prod_cons_std.h" - -Message msg; - -int main() -{ - - int i; - volatile int t; - - - Echo("Inicio da aplicacao prod"); - - for(i=0;i -#include -Message msg; -int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Send(&msg,taskB); - } - Echo(itoa(GetTick())); - Echo("task A finished."); - exit(); -} diff --git a/pc2/taskB.c~ b/pc2/taskB.c~ deleted file mode 100644 index 05f57fa..0000000 --- a/pc2/taskB.c~ +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -Message msg; -int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Send(1,254,&msg); - } - Echo(itoa(GetTick())); - Echo("task B finished."); - exit(); -} diff --git a/example.yaml b/testcases/border_router_test.yaml similarity index 93% rename from example.yaml rename to testcases/border_router_test.yaml index e56c770..4d11ce5 100644 --- a/example.yaml +++ b/testcases/border_router_test.yaml @@ -2,7 +2,7 @@ hw: page_size_KB: 32 tasks_per_PE: 3 repository_size_MB: 1 - model_description: sc # sc (gcc) | scmod (questa) | vhdl + model_description: vhdl # sc (gcc) | scmod (questa) | vhdl noc_buffer_size: 8 # must be power of 2 mpsoc_dimension: [4,4] # for while, must be a square shape cluster_dimension: [2,2] # for while, must be a square shape From 2a8daaa81a8dcdbe8212baa642fa662b1aa60980 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 22 Sep 2017 17:25:37 -0300 Subject: [PATCH 12/54] rewrote transmit syscall --- applications/pc1/taskA.c | 23 +++++---- applications/pc1/taskB.c | 14 ------ applications/pc2/taskA.c | 18 +++---- applications/pc2/taskB.c | 18 +++---- software/include/api.h | 14 ++++-- software/kernel/slave/kernel_slave.c | 75 ++++------------------------ software/modules/boarder_route.c | 14 +++--- software/modules/boarder_route.h | 6 +-- software/modules/packet.c | 2 - testcases/border_router_test.yaml | 9 ++-- 10 files changed, 66 insertions(+), 127 deletions(-) delete mode 100644 applications/pc1/taskB.c diff --git a/applications/pc1/taskA.c b/applications/pc1/taskA.c index d65ed52..fc43a77 100644 --- a/applications/pc1/taskA.c +++ b/applications/pc1/taskA.c @@ -1,14 +1,17 @@ #include #include -Message msg; + +char message[] = "Hello World\n"; + int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Transit(taskB, 254, &msg); - } - Echo(itoa(GetTick())); - Echo("task A finished."); - exit(); + int i; + + Echo("task A started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Transmit(ROUTER_ADDR(0, 0)|MANUAL_NORTH, message, 3); + } + Echo(itoa(GetTick())); + Echo("task A finished."); + exit(); } diff --git a/applications/pc1/taskB.c b/applications/pc1/taskB.c deleted file mode 100644 index d4c929a..0000000 --- a/applications/pc1/taskB.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -Message msg; -int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Receive(&msg,taskA); - } - Echo(itoa(GetTick())); - Echo("task B finished."); - exit(); -} diff --git a/applications/pc2/taskA.c b/applications/pc2/taskA.c index 1d915bf..4c8fd70 100644 --- a/applications/pc2/taskA.c +++ b/applications/pc2/taskA.c @@ -2,13 +2,13 @@ #include Message msg; int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Send(&msg,taskB); - } - Echo(itoa(GetTick())); - Echo("task A finished."); - exit(); + int i; + Echo("task A started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Send(&msg,taskB); + } + Echo(itoa(GetTick())); + Echo("task A finished."); + exit(); } diff --git a/applications/pc2/taskB.c b/applications/pc2/taskB.c index d4c929a..0d50dac 100644 --- a/applications/pc2/taskB.c +++ b/applications/pc2/taskB.c @@ -2,13 +2,13 @@ #include Message msg; int main(){ - int i; - Echo("task B started."); - Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Receive(&msg,taskA); - } - Echo(itoa(GetTick())); - Echo("task B finished."); - exit(); + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<500;i++){ + Receive(&msg,taskA); + } + Echo(itoa(GetTick())); + Echo("task B finished."); + exit(); } diff --git a/software/include/api.h b/software/include/api.h index 43c9225..1acb2eb 100644 --- a/software/include/api.h +++ b/software/include/api.h @@ -22,12 +22,20 @@ #define GETTICK 3 #define ECHO 4 #define REALTIME 5 -#define TRANSIT 6 +#define TRANSMIT 6 #define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) #define TRUE 1 #define FALSE 0 +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) + extern int SystemCall(); #define Send(msg, target) while(!SystemCall(WRITEPIPE, (unsigned int*)msg, target,0)) @@ -37,8 +45,8 @@ extern int SystemCall(); #define exit() while(!SystemCall(EXIT, 0, 0, 0)) // Bruno's modification 14/09 - The change reflects the need of a transit message to send packets outside the NoC. -// The call is Target (Border Router, out_target (00 - South, 01 - West, 10 - East, 11 - North), message (payload)) -#define Transit(target, out_target, msg) while (!SystemCall(TRANSIT, target, out_target, (unsigned int*)msg)) +// The call is Target (ROUTER_ADDR(x,y)|MANUAL_PORT) , message (payload), payload len in flits) +#define Transmit(target, msg, len) while (!SystemCall(TRANSMIT, target, (unsigned int*)msg, len)) //Real-Time API - time represented in microseconds #define RealTime(period, deadline, execution_time) while(!SystemCall(REALTIME, period, deadline, execution_time)) diff --git a/software/kernel/slave/kernel_slave.c b/software/kernel/slave/kernel_slave.c index 1041e1a..f432b12 100644 --- a/software/kernel/slave/kernel_slave.c +++ b/software/kernel/slave/kernel_slave.c @@ -252,6 +252,7 @@ void write_local_msg_to_task(TCB * task_tcb_ptr, int msg_lenght, int * msg_data) */ int Syscall(unsigned int service, unsigned int arg0, unsigned int arg1, unsigned int arg2) { + ServiceHeader *p; Message *msg_read; Message *msg_write; PipeSlot *pipe_ptr; @@ -464,75 +465,21 @@ int Syscall(unsigned int service, unsigned int arg0, unsigned int arg1, unsigned schedule_after_syscall = 1; return 1; + break; - //Bruno Modification's 15/09 - //These changes were made in order to be able to send data out of the NoC. - //Concept is based on sending the first bit high will enable the function and the 2 others decide where to send it (in the switchcontrol). - - break; - - case TRANSIT: - consumer_task = current->id; - producer_task = (int) arg0; - - appID = consumer_task >> 8; - // Here we shift the arg1 - producer_task = (arg1 << 8) | producer_task; - - puts("TRANSIT - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); - - producer_PE = get_task_location(producer_task); - - //Test if the producer task is not allocated - if (producer_PE == -1){ - //Task is blocked until its a TASK_RELEASE packet - current->scheduling_ptr->status = BLOCKED; - return 0; - } - if (producer_PE == net_address){ //Local producer - //Searches if the message is in PIPE (local producer) - pipe_ptr = remove_PIPE(producer_task, consumer_task); - - if (pipe_ptr == 0){ - - //Stores the request into the message request table (local producer) - insert_message_request(producer_task, consumer_task, net_address); + case TRANSMIT: + p = get_service_header_slot(); + p->header = arg0; + p->service = BORDER_ROUTE; + p->task_ID = current->id; - } else { - //Message was found in pipe, writes to the consumer page address (local producer) - msg_write = (Message*) arg2; - msg_write = (Message*)((current->offset) | ((unsigned int)msg_write)); - msg_write->length = pipe_ptr->message.length; - for (int i = 0; ilength; i++) { - msg_write->msg[i] = pipe_ptr->message.msg[i]; - } - return 1; - } - } else - { //Remote producer : Sends the message request (remote producer) + send_packet(p, arg1, arg2); - //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process - // Revisar para fazer um pooling ao invés de um if aqui (vai ficar bloqueante). - while( MemoryRead(DMNI_SEND_ACTIVE) ) - return 0; - // Mover o generateinjection aqui para dentro e usar o send packet na propria syscall - ServiceHeader *p = get_service_header_slot(); - p-> header = producer_task; - p-> service = BORDER_ROUTE; - p-> requesting_processor = net_address; - p-> producer_task = producer_task; - p-> consumer_task = consumer_task; - //p-> msg_lenght=3333; - //p-> tasks_of_same_app=4444; - //p-> code_size=5555; - //p-> bss_size=6666; - //p-> initial_address=7777; - send_packet(p, (unsigned int)msg_write->msg, msg_write->length); - - } + return 1; break; - return 0; } + + return 0; } /** Handles a new packet from NoC */ diff --git a/software/modules/boarder_route.c b/software/modules/boarder_route.c index 86a7892..51a240d 100644 --- a/software/modules/boarder_route.c +++ b/software/modules/boarder_route.c @@ -8,12 +8,12 @@ * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br * * \brief - * This module defines function relative to boarder routing. + * This module defines function relative to border routing. * \detailed * */ -#include "boarder_route.h" +#include "border_route.h" #include "../../include/kernel_pkg.h" #include "utils.h" @@ -21,18 +21,18 @@ * \brief This structure stores the location (slave process address) of the other task */ -int boarder_route(unsigned int f1, unsigned int f2, unsigned int f3){ +int border_route(unsigned int f1, unsigned int f2, unsigned int f3){ if (f1 == 1){ - if (f2 == 1 and f3 == 1){ + if (f2 == 1 && f3 == 1){ return 57344; } - else if (f2 == 1 and f3 == 0) { + else if (f2 == 1 && f3 == 0) { return 49152; } - else if (f2 == 0 and f3 == 1){ + else if (f2 == 0 && f3 == 1){ return 40960; } - else if (f2 == 0 and f3 == 0){ + else if (f2 == 0 && f3 == 0){ return 32768; } } diff --git a/software/modules/boarder_route.h b/software/modules/boarder_route.h index f0d4c16..1cb492f 100644 --- a/software/modules/boarder_route.h +++ b/software/modules/boarder_route.h @@ -8,7 +8,7 @@ * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br * * \brief - * This module defines function relative to boarder routing. + * This module defines function relative to border routing. * \detailed * */ @@ -17,7 +17,7 @@ #define BORDER_ROUTE_H_ #include "../../include/kernel_pkg.h" -#include "boarder_route.h" +#include "border_route.h" /** * \brief This structure stores the location (slave process address) of the other task */ @@ -27,6 +27,6 @@ struct packed_struct { unsigned int f3:1; } -int boarder_route(unsigned int f1, unsigned int f2, unsigned int f3); +int border_route(unsigned int f1, unsigned int f2, unsigned int f3); #endif /* BORDER_ROUTE_H_ */ diff --git a/software/modules/packet.c b/software/modules/packet.c index 7cc4fcf..c559524 100644 --- a/software/modules/packet.c +++ b/software/modules/packet.c @@ -99,14 +99,12 @@ void send_packet(ServiceHeader *p, unsigned int initial_address, unsigned int dm MemoryWrite(DMNI_ADDRESS, (unsigned int) p); if (dmni_msg_size > 0){ - MemoryWrite(DMNI_SIZE_2, dmni_msg_size); MemoryWrite(DMNI_ADDRESS_2, initial_address); } MemoryWrite(DMNI_OP, READ); MemoryWrite(DMNI_START, 1); - } /**Function that abstracts the process to read a generic packet from NoC by programming the DMNI diff --git a/testcases/border_router_test.yaml b/testcases/border_router_test.yaml index 4d11ce5..12606a2 100644 --- a/testcases/border_router_test.yaml +++ b/testcases/border_router_test.yaml @@ -4,12 +4,9 @@ hw: repository_size_MB: 1 model_description: vhdl # sc (gcc) | scmod (questa) | vhdl noc_buffer_size: 8 # must be power of 2 - mpsoc_dimension: [4,4] # for while, must be a square shape + mpsoc_dimension: [2,2] # for while, must be a square shape cluster_dimension: [2,2] # for while, must be a square shape master_location: LB # LB -sw: - mapping_algorithm: WithLoad # WithLoad - task_scheduler: round_robin # round_robing | lst #--------- Application definitions ----------- #Example of an application defining static mapping for two tasks @@ -21,8 +18,8 @@ sw: # # Attention: When using static mapping all application must be manually sorted by start time apps: - - name: pc2 + - name: prod_cons start_time_ms: 1 #any unsigned integer number - name: pc1 - start_time_ms: 5 + start_time_ms: 2 From 967c8498b0a0bef59dc1ef00e100ed3e3eeace75 Mon Sep 17 00:00:00 2001 From: Bruno Scherer Oliveira Date: Sat, 23 Sep 2017 14:50:02 -0300 Subject: [PATCH 13/54] Added the manual packet. --- hardware/vhdl/in8.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 hardware/vhdl/in8.txt diff --git a/hardware/vhdl/in8.txt b/hardware/vhdl/in8.txt new file mode 100644 index 0000000..a1ca00d --- /dev/null +++ b/hardware/vhdl/in8.txt @@ -0,0 +1,5 @@ +A0000000 00000010 00001001 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F 12345678 +A0000000 00000010 00001111 00002222 00003333 00004444 00005555 00006666 00007777 00008088 00009999 0000AAAA 0000BBBB 0000CCCC 0000DDDD 0000EEEE 0000FFFF 89ABCDEF +A0000000 00000010 AAAAAAAA 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F AAAAAAAA +A0000000 00000010 BBBBBBBB 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F BBBBBBBB +A0000000 00000010 CCCCCCCC 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F CCCCCCCC From 88e1fa7ca5419c8c568555dbc9ef86c62a720bff Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Sat, 23 Sep 2017 17:20:59 -0300 Subject: [PATCH 14/54] Border routing working --- applications/pc1/taskA.c | 2 +- build_env/makes/sim.do | 2 +- hardware/vhdl/in8.txt | 5 -- hardware/vhdl/pe/pe.vhd | 32 ++++--- hardware/vhdl/pe/router/Hermes_crossbar.vhd | 88 +++++++++++-------- .../vhdl/pe/router/Hermes_switchcontrol.vhd | 6 +- hardware/vhdl/standards.vhd | 10 +-- testcases/border_router_test.yaml | 2 +- 8 files changed, 79 insertions(+), 68 deletions(-) delete mode 100644 hardware/vhdl/in8.txt diff --git a/applications/pc1/taskA.c b/applications/pc1/taskA.c index fc43a77..7ff1a36 100644 --- a/applications/pc1/taskA.c +++ b/applications/pc1/taskA.c @@ -9,7 +9,7 @@ int main(){ Echo("task A started."); Echo(itoa(GetTick())); for(i=0;i<500;i++){ - Transmit(ROUTER_ADDR(0, 0)|MANUAL_NORTH, message, 3); + Transmit(ROUTER_ADDR(0, 0)|MANUAL_WEST, message, 3); } Echo(itoa(GetTick())); Echo("task A finished."); diff --git a/build_env/makes/sim.do b/build_env/makes/sim.do index 1764d56..ce51019 100644 --- a/build_env/makes/sim.do +++ b/build_env/makes/sim.do @@ -1,4 +1,4 @@ -vsim -novopt -t ps +notimingchecks hardware/work.test_bench +vsim -voptargs=+acc=lprn -t ps +notimingchecks hardware/work.test_bench do wave.do onerror {resume} diff --git a/hardware/vhdl/in8.txt b/hardware/vhdl/in8.txt deleted file mode 100644 index a1ca00d..0000000 --- a/hardware/vhdl/in8.txt +++ /dev/null @@ -1,5 +0,0 @@ -A0000000 00000010 00001001 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F 12345678 -A0000000 00000010 00001111 00002222 00003333 00004444 00005555 00006666 00007777 00008088 00009999 0000AAAA 0000BBBB 0000CCCC 0000DDDD 0000EEEE 0000FFFF 89ABCDEF -A0000000 00000010 AAAAAAAA 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F AAAAAAAA -A0000000 00000010 BBBBBBBB 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F BBBBBBBB -A0000000 00000010 CCCCCCCC 00002002 00003003 00004004 00005005 00006006 00007007 00008008 00009009 0000A00A 0000B00B 0000C00C 0000D00D 0000E00E 0000F00F CCCCCCCC diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 8363cc1..4306fb8 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -170,20 +170,24 @@ slave: if kernel_type = "sla" generate ); end generate; - router : Entity work.RouterCC - generic map(address => router_address) - port map( - clock => clock, - reset => reset, - clock_rx => clock_rx_router, - rx => rx_router, - data_in => data_in_router, - credit_o => credit_o_router, - clock_tx => clock_tx_router, - tx => tx_router, - data_out => data_out_router, - credit_i => credit_i_router - ); + router : entity work.RouterCC + generic map(address => router_address, + manual_NORTH => manual_NORTH, + manual_SOUTH => manual_SOUTH, + manual_EAST => manual_EAST, + manual_WEST => manual_WEST) + port map( + clock => clock, + reset => reset, + clock_rx => clock_rx_router, + rx => rx_router, + data_in => data_in_router, + credit_o => credit_o_router, + clock_tx => clock_tx_router, + tx => tx_router, + data_out => data_out_router, + credit_i => credit_i_router + ); dmni : entity work.dmni diff --git a/hardware/vhdl/pe/router/Hermes_crossbar.vhd b/hardware/vhdl/pe/router/Hermes_crossbar.vhd index ded33de..a8c5390 100644 --- a/hardware/vhdl/pe/router/Hermes_crossbar.vhd +++ b/hardware/vhdl/pe/router/Hermes_crossbar.vhd @@ -50,16 +50,16 @@ begin -- PORTA LOCAL ---------------------------------------------------------------------------------- tx(LOCAL) <= data_av(EAST) when tab_out(LOCAL)="000" and free(LOCAL)='0' else - data_av(WEST) when tab_out(LOCAL)="001" and free(LOCAL)='0' else - data_av(NORTH) when tab_out(LOCAL)="010" and free(LOCAL)='0' else - data_av(SOUTH) when tab_out(LOCAL)="011" and free(LOCAL)='0' else - '0'; + data_av(WEST) when tab_out(LOCAL)="001" and free(LOCAL)='0' else + data_av(NORTH) when tab_out(LOCAL)="010" and free(LOCAL)='0' else + data_av(SOUTH) when tab_out(LOCAL)="011" and free(LOCAL)='0' else + '0'; data_out(LOCAL) <= data_in(EAST) when tab_out(LOCAL)="000" and free(LOCAL)='0' else - data_in(WEST) when tab_out(LOCAL)="001" and free(LOCAL)='0' else - data_in(NORTH) when tab_out(LOCAL)="010" and free(LOCAL)='0' else - data_in(SOUTH) when tab_out(LOCAL)="011" and free(LOCAL)='0' else - (others=>'0'); + data_in(WEST) when tab_out(LOCAL)="001" and free(LOCAL)='0' else + data_in(NORTH) when tab_out(LOCAL)="010" and free(LOCAL)='0' else + data_in(SOUTH) when tab_out(LOCAL)="011" and free(LOCAL)='0' else + (others=>'0'); data_ack(LOCAL) <= credit_i(EAST) when tab_in(LOCAL)="000" and data_av(LOCAL)='1' else credit_i(WEST) when tab_in(LOCAL)="001" and data_av(LOCAL)='1' else @@ -70,52 +70,62 @@ begin -- PORTA EAST ---------------------------------------------------------------------------------- tx(EAST) <= data_av(WEST) when tab_out(EAST)="001" and free(EAST)='0' else - data_av(LOCAL) when tab_out(EAST)="100" and free(EAST)='0' else - '0'; + data_av(NORTH) when tab_out(EAST)="010" and free(EAST)='0' else + data_av(SOUTH) when tab_out(EAST)="011" and free(EAST)='0' else + data_av(LOCAL) when tab_out(EAST)="100" and free(EAST)='0' else + '0'; data_out(EAST) <= data_in(WEST) when tab_out(EAST)="001" and free(EAST)='0' else - data_in(LOCAL) when tab_out(EAST)="100" and free(EAST)='0' else - (others=>'0'); + data_in(NORTH) when tab_out(EAST)="010" and free(EAST)='0' else + data_in(SOUTH) when tab_out(EAST)="011" and free(EAST)='0' else + data_in(LOCAL) when tab_out(EAST)="100" and free(EAST)='0' else + (others=>'0'); data_ack(EAST) <= credit_i(WEST) when tab_in(EAST)="001" and data_av(EAST)='1' else - credit_i(NORTH) when tab_in(EAST)="010" and data_av(EAST)='1' else - credit_i(SOUTH) when tab_in(EAST)="011" and data_av(EAST)='1' else - credit_i(LOCAL) when tab_in(EAST)="100" and data_av(EAST)='1' else - '0'; + credit_i(NORTH) when tab_in(EAST)="010" and data_av(EAST)='1' else + credit_i(SOUTH) when tab_in(EAST)="011" and data_av(EAST)='1' else + credit_i(LOCAL) when tab_in(EAST)="100" and data_av(EAST)='1' else + '0'; ---------------------------------------------------------------------------------- -- PORTA WEST ---------------------------------------------------------------------------------- tx(WEST) <= data_av(EAST) when tab_out(WEST)="000" and free(WEST)='0' else - data_av(LOCAL) when tab_out(WEST)="100" and free(WEST)='0' else - '0'; + data_av(NORTH) when tab_out(WEST)="010" and free(WEST)='0' else + data_av(SOUTH) when tab_out(WEST)="011" and free(WEST)='0' else + data_av(LOCAL) when tab_out(WEST)="100" and free(WEST)='0' else + '0'; data_out(WEST) <= data_in(EAST) when tab_out(WEST)="000" and free(WEST)='0' else - data_in(LOCAL) when tab_out(WEST)="100" and free(WEST)='0' else - (others=>'0'); + data_in(NORTH) when tab_out(WEST)="010" and free(WEST)='0' else + data_in(SOUTH) when tab_out(WEST)="011" and free(WEST)='0' else + data_in(LOCAL) when tab_out(WEST)="100" and free(WEST)='0' else + (others=>'0'); data_ack(WEST) <= credit_i(EAST) when tab_in(WEST)="000" and data_av(WEST)='1' else - credit_i(NORTH) when tab_in(WEST)="010" and data_av(WEST)='1' else - credit_i(SOUTH) when tab_in(WEST)="011" and data_av(WEST)='1' else - credit_i(LOCAL) when tab_in(WEST)="100" and data_av(WEST)='1' else - '0'; + credit_i(NORTH) when tab_in(WEST)="010" and data_av(WEST)='1' else + credit_i(SOUTH) when tab_in(WEST)="011" and data_av(WEST)='1' else + credit_i(LOCAL) when tab_in(WEST)="100" and data_av(WEST)='1' else + '0'; ---------------------------------------------------------------------------------- -- PORTA NORTH ---------------------------------------------------------------------------------- tx(NORTH) <= data_av(EAST) when tab_out(NORTH)="000" and free(NORTH)='0' else - data_av(WEST) when tab_out(NORTH)="001" and free(NORTH)='0' else - data_av(SOUTH) when tab_out(NORTH)="011" and free(NORTH)='0' else - data_av(LOCAL) when tab_out(NORTH)="100" and free(NORTH)='0' else - '0'; + data_av(WEST) when tab_out(NORTH)="001" and free(NORTH)='0' else + data_av(SOUTH) when tab_out(NORTH)="011" and free(NORTH)='0' else + data_av(LOCAL) when tab_out(NORTH)="100" and free(NORTH)='0' else + '0'; data_out(NORTH) <= data_in(EAST) when tab_out(NORTH)="000" and free(NORTH)='0' else - data_in(WEST) when tab_out(NORTH)="001" and free(NORTH)='0' else - data_in(SOUTH) when tab_out(NORTH)="011" and free(NORTH)='0' else - data_in(LOCAL) when tab_out(NORTH)="100" and free(NORTH)='0' else - (others=>'0'); - - data_ack(NORTH) <= credit_i(SOUTH) when tab_in(NORTH)="011" and data_av(NORTH)='1' else - credit_i(LOCAL) when tab_in(NORTH)="100" and data_av(NORTH)='1' else - '0'; + data_in(WEST) when tab_out(NORTH)="001" and free(NORTH)='0' else + data_in(SOUTH) when tab_out(NORTH)="011" and free(NORTH)='0' else + data_in(LOCAL) when tab_out(NORTH)="100" and free(NORTH)='0' else + (others=>'0'); + + data_ack(NORTH) <= credit_i(EAST) when tab_in(NORTH)="000" and data_av(NORTH)='1' else + credit_i(WEST) when tab_in(NORTH)="001" and data_av(NORTH)='1' else + credit_i(SOUTH) when tab_in(NORTH)="011" and data_av(NORTH)='1' else + credit_i(LOCAL) when tab_in(NORTH)="100" and data_av(NORTH)='1' else + '0'; ---------------------------------------------------------------------------------- -- PORTA SOUTH ---------------------------------------------------------------------------------- @@ -131,8 +141,10 @@ begin data_in(LOCAL) when tab_out(SOUTH)="100" and free(SOUTH)='0' else (others=>'0'); - data_ack(SOUTH) <= credit_i(NORTH) when tab_in(SOUTH)="010" and data_av(SOUTH)='1' else - credit_i(LOCAL) when tab_in(SOUTH)="100" and data_av(SOUTH)='1' else + data_ack(SOUTH) <= credit_i(EAST) when tab_in(SOUTH)="000" and data_av(SOUTH)='1' else + credit_i(WEST) when tab_in(SOUTH)="001" and data_av(SOUTH)='1' else + credit_i(NORTH) when tab_in(SOUTH)="010" and data_av(SOUTH)='1' else + credit_i(LOCAL) when tab_in(SOUTH)="100" and data_av(SOUTH)='1' else '0'; end Hermes_crossbar; diff --git a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd index 35b59fb..fce5d3d 100644 --- a/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd +++ b/hardware/vhdl/pe/router/Hermes_switchcontrol.vhd @@ -110,8 +110,8 @@ begin manual_routing_flag <= header(TAM_FLIT-1); manual_routing_sel <= conv_integer(header(TAM_FLIT-2 downto TAM_FLIT-3)); - dirx <= WEST when lx > tx or (manual_WEST and manual_routing_sel=WEST) else EAST; - diry <= NORTH when ly < ty or (manual_NORTH and manual_routing_sel=NORTH) else SOUTH; + dirx <= WEST when lx > tx or (manual_routing_en and manual_routing_sel=WEST) else EAST; + diry <= NORTH when ly < ty or (manual_routing_en and manual_routing_sel=NORTH) else SOUTH; process(reset,clock) begin @@ -165,7 +165,7 @@ begin end if; end process; - process(ES, ask, h, lx, ly, tx, ty, auxfree, dirx, diry) + process(ES, ask, auxfree, dirx, diry, lx, ly, manual_routing_en, manual_routing_sel, tx, ty) begin case ES is when S0 => PES <= S1; diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index 6cf3da0..e4ddc2e 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -342,7 +342,7 @@ begin end RouterPosition; -function ManualEASTbyPos(router : integer) return boolean is +function ManualWESTbyPos(router : integer) return boolean is variable pos : integer; begin pos := RouterPosition(router); @@ -351,9 +351,9 @@ begin else return false; end if; -end ManualEASTbyPos; +end ManualWESTbyPos; -function ManualWESTbyPos(router : integer) return boolean is +function ManualEASTbyPos(router : integer) return boolean is variable pos : integer; begin pos := RouterPosition(router); @@ -362,7 +362,7 @@ begin else return false; end if; -end ManualWESTbyPos; +end ManualEASTbyPos; function ManualNORTHbyPos(router : integer) return boolean is variable pos : integer; @@ -379,7 +379,7 @@ function ManualSOUTHbyPos(router : integer) return boolean is variable pos : integer; begin pos := RouterPosition(router); - if (pos = BR) or (pos = BC) or (pos = BR) then + if (pos = BL) or (pos = BC) or (pos = BR) then return true; else return false; diff --git a/testcases/border_router_test.yaml b/testcases/border_router_test.yaml index 12606a2..2de8ac4 100644 --- a/testcases/border_router_test.yaml +++ b/testcases/border_router_test.yaml @@ -21,5 +21,5 @@ apps: - name: prod_cons start_time_ms: 1 #any unsigned integer number - name: pc1 - start_time_ms: 2 + start_time_ms: 0 From 9225a901bf32f7a89534cf4d6cc51c2a174c7f59 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Sun, 15 Oct 2017 12:44:24 -0200 Subject: [PATCH 15/54] integrated andersons changes into tree --- .gitignore | 2 + api.h | 62 -- applications/pc1/taskA.c | 15 +- applications/pc1/taskB.c | 17 + applications/pc2/taskA.c | 8 +- applications/pc2/taskB.c | 7 +- applications/receive/receive.c | 206 ++++++ applications/transmit/transmit.c | 207 ++++++ hardware/vhdl/hemps.vhd | 74 +- hardware/vhdl/pe/dmni/dmni.vhd | 88 ++- hardware/vhdl/pe/pe.vhd | 731 +++++++++---------- hardware/vhdl/standards.vhd | 2 +- kernel_slave.c | 933 ------------------------- kernel_slave.h | 44 -- services.h | 52 -- software/include/services.h | 100 +-- software/kernel/master/kernel_master.c | 582 +++++++++++++++ testcases/test.txt | 72 ++ testcases/teste.yaml | 16 + testcases/teste_2x2_vhdl.yaml | 16 + testcases/teste_2x2_vhdl_ativ2.yaml | 15 + testcases/teste_2x2_vhdl_ativ4.yaml | 15 + testcases/teste_vhdl.yaml | 16 + 23 files changed, 1732 insertions(+), 1548 deletions(-) delete mode 100644 api.h create mode 100644 applications/pc1/taskB.c create mode 100644 applications/receive/receive.c create mode 100644 applications/transmit/transmit.c delete mode 100644 kernel_slave.c delete mode 100644 kernel_slave.h delete mode 100644 services.h create mode 100644 testcases/test.txt create mode 100644 testcases/teste.yaml create mode 100644 testcases/teste_2x2_vhdl.yaml create mode 100644 testcases/teste_2x2_vhdl_ativ2.yaml create mode 100644 testcases/teste_2x2_vhdl_ativ4.yaml create mode 100644 testcases/teste_vhdl.yaml diff --git a/.gitignore b/.gitignore index bf26e47..38487ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *~ *.pyc \#*\# +*.o +*.vlw diff --git a/api.h b/api.h deleted file mode 100644 index 43c9225..0000000 --- a/api.h +++ /dev/null @@ -1,62 +0,0 @@ -/*!\file api.h - * HEMPS VERSION - 8.0 - support for RT applications - * - * Distribution: June 2016 - * - * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br - * - * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br - * - * \brief - * Implements the API for the user's task and defines the structure Message, - * used by tasks to exchange messages - */ - -#ifndef __TASK_H__ -#define __TASK_H__ - -/* Syscalls*/ -#define EXIT 0 -#define WRITEPIPE 1 -#define READPIPE 2 -#define GETTICK 3 -#define ECHO 4 -#define REALTIME 5 -#define TRANSIT 6 - -#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) -#define TRUE 1 -#define FALSE 0 - -extern int SystemCall(); - -#define Send(msg, target) while(!SystemCall(WRITEPIPE, (unsigned int*)msg, target,0)) -#define Receive(msg, source) while(!SystemCall(READPIPE, (unsigned int*)msg, source,0)) -#define GetTick() SystemCall(GETTICK,0,0,0) -#define Echo(str) SystemCall(ECHO, (char*)str,0,0) -#define exit() while(!SystemCall(EXIT, 0, 0, 0)) - -// Bruno's modification 14/09 - The change reflects the need of a transit message to send packets outside the NoC. -// The call is Target (Border Router, out_target (00 - South, 01 - West, 10 - East, 11 - North), message (payload)) -#define Transit(target, out_target, msg) while (!SystemCall(TRANSIT, target, out_target, (unsigned int*)msg)) - -//Real-Time API - time represented in microseconds -#define RealTime(period, deadline, execution_time) while(!SystemCall(REALTIME, period, deadline, execution_time)) - -/*-------------------------------------------------------------------- - * struct Message - * - * DESCRIPTION: - * Used to handle messages inside the task. - * This is not the same structure used in the kernels. - * - *--------------------------------------------------------------------*/ -#define MSG_SIZE 128 - -typedef struct { - int length; - int msg[MSG_SIZE]; -} Message; - -#endif /*__TASK_H__*/ - diff --git a/applications/pc1/taskA.c b/applications/pc1/taskA.c index 7ff1a36..e70c60b 100644 --- a/applications/pc1/taskA.c +++ b/applications/pc1/taskA.c @@ -1,16 +1,17 @@ #include #include - -char message[] = "Hello World\n"; - +Message msg; int main(){ - int i; - + int i, j,t; Echo("task A started."); Echo(itoa(GetTick())); - for(i=0;i<500;i++){ - Transmit(ROUTER_ADDR(0, 0)|MANUAL_WEST, message, 3); + for(i=0;i<1;i++) + { + msg.length = 30; + for(j=0;j<30;j++) msg.msg[j]=i; + Send(&msg,taskB); } + Echo(itoa(GetTick())); Echo("task A finished."); exit(); diff --git a/applications/pc1/taskB.c b/applications/pc1/taskB.c new file mode 100644 index 0000000..2349ed7 --- /dev/null +++ b/applications/pc1/taskB.c @@ -0,0 +1,17 @@ +#include +#include +Message msg; +int main() +{ + int i; + Echo("task B started."); + Echo(itoa(GetTick())); + for(i=0;i<1;i++) + { + Receive(&msg,taskA); + } + + Echo(itoa(GetTick())); + Echo("task B finished."); + exit(); +} diff --git a/applications/pc2/taskA.c b/applications/pc2/taskA.c index 4c8fd70..2a6fdbc 100644 --- a/applications/pc2/taskA.c +++ b/applications/pc2/taskA.c @@ -2,12 +2,16 @@ #include Message msg; int main(){ - int i; + int i, j,t; Echo("task A started."); Echo(itoa(GetTick())); - for(i=0;i<500;i++){ + for(i=0;i<30;i++) + { + msg.length = 30; + for(j=0;j<30;j++) msg.msg[j]=i; Send(&msg,taskB); } + Echo(itoa(GetTick())); Echo("task A finished."); exit(); diff --git a/applications/pc2/taskB.c b/applications/pc2/taskB.c index 0d50dac..40d5f16 100644 --- a/applications/pc2/taskB.c +++ b/applications/pc2/taskB.c @@ -1,13 +1,16 @@ #include #include Message msg; -int main(){ +int main() +{ int i; Echo("task B started."); Echo(itoa(GetTick())); - for(i=0;i<500;i++){ + for(i=0;i<30;i++) + { Receive(&msg,taskA); } + Echo(itoa(GetTick())); Echo("task B finished."); exit(); diff --git a/applications/receive/receive.c b/applications/receive/receive.c new file mode 100644 index 0000000..9d58b22 --- /dev/null +++ b/applications/receive/receive.c @@ -0,0 +1,206 @@ + + +#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) +#define MemoryRead(A) (*(volatile unsigned int*)(A)) + +/* DMNI operations */ +#define READ 0 +#define WRITE 1 + + +#define NI_CONFIG 0x20000140 + +/* DMNI*/ +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 + +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) + + +#define UART_WRITE 0x20000000 +#define TESTE 0x20000008 + +typedef struct { + unsigned int header; + unsigned int payload_size; + unsigned int service; + unsigned int source; + unsigned int target; + unsigned int pkt_size; +} ServiceHeader; + + + + + + +int puts(char *string) { + + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + for( + str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); + + !( ( (char*)str_part )[0] == 0 || ( (char*)str_part )[1] == 0 || ( (char*)str_part )[2] == 0 || ( (char*)str_part )[3] == 0); + + *str_part++,MemoryWrite(UART_WRITE, *str_part) + ); + return 0; +} + +/**Converts a integer number to its decimal representation in a array of char + * \param num Integer number to be converted + * \return Array of chars + */ +char *itoa(unsigned int num) +{ + static char buf[12]; + static char buf2[12]; + int i,j; + + if (num==0) + { + buf[0] = '0'; + buf[1] = '\0'; + return &buf[0]; + } + + for(i=0;i<11 && num!=0;i++) + { + buf[i]=(char)((num%10)+'0'); + num/=10; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; +} + + + +char *itoh(unsigned int num) +{ + static char buf[11]; + int i; + buf[10]=0; + + buf[0] = '0'; + buf[1] = 'x'; + + if (num==0) + { + buf[2] = '0'; + buf[3] = '0'; + buf[4] = '0'; + buf[5] = '0'; + buf[6] = '0'; + buf[7] = '0'; + buf[8] = '0'; + buf[9] = '0'; + return buf; + } + + for(i=9;i>=2;--i) + { + if ((num%16) < 10) + buf[i]=(char)((num%16)+'0'); + else + buf[i]=(char)((num%16)+'W'); + + num/=16; + } + + return buf; +} + + + + + + +void read_packet(ServiceHeader *p){ + + MemoryWrite(DMNI_SIZE, 6); + MemoryWrite(DMNI_OP, WRITE); + MemoryWrite(DMNI_ADDRESS, (unsigned int) p); + MemoryWrite(DMNI_START, 1); + //Waits the DMNI copy all data to memory before release the software to access it + while (MemoryRead(DMNI_RECEIVE_ACTIVE)); + +} + + + + + +int main() +{ + + int anderson[2]; + anderson[0] = 14; + anderson[1] = 20; + + volatile ServiceHeader p; + + read_packet((ServiceHeader *)&p); + puts("$$$ "); + puts(itoa((unsigned int)p.header)); + puts("\n"); + puts(itoh((unsigned int)p.service)); + puts("\n"); + + transmite(0x00000001 ,0x00000290, anderson ,2); + + + //transmite(0x00000100 ,0x00000290, data_dma_code ,102); + //transmite(0x00000000 ,0x00000290, data_dma_code ,102); + //transmite(0x00000101 ,0x00000290, data_dma_code,102); + // + + while(1) + { + int i; + + for(i=0; i<100; i++) + { + MemoryWrite(TESTE, i); //Grava o valor de no endereco da memoria (definida como teste) + *(volatile unsigned int *)(TESTE) = i; + + puts("$$$ "); + puts(itoa(i)); + puts(itoa(&i)); + puts("\n"); + } + + + + } + + + +} + +/* + +USO: +int message[30] +transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) +*/ \ No newline at end of file diff --git a/applications/transmit/transmit.c b/applications/transmit/transmit.c new file mode 100644 index 0000000..0d3c606 --- /dev/null +++ b/applications/transmit/transmit.c @@ -0,0 +1,207 @@ + + +#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) +#define MemoryRead(A) (*(volatile unsigned int*)(A)) + +/* DMNI operations */ +#define READ 0 +#define WRITE 1 + + +#define NI_CONFIG 0x20000140 + +/* DMNI*/ +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 + +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) + + +typedef struct { + unsigned int header; + unsigned int payload_size; + unsigned int service; + unsigned int source; + unsigned int target; + unsigned int pkt_size; +} ServiceHeader; + + +void transmite(int target, int service, int *msg, int lenght){ + + + ServiceHeader *p; + p -> header = target; + p -> payload_size = 6 + lenght; // 6 devido ao service header + p -> service = service; + p -> source = MemoryRead(NI_CONFIG); + p -> target = target; + p -> pkt_size = lenght; + + + //Waits the DMNI send process be released + while (MemoryRead(DMNI_SEND_ACTIVE)); + + MemoryWrite(DMNI_SIZE, 6); + MemoryWrite(DMNI_ADDRESS, (unsigned int)p ); //grava na memoria as informacoes do header + + if( lenght > 0 ) { + + MemoryWrite(DMNI_SIZE_2, lenght); + MemoryWrite(DMNI_ADDRESS_2, msg); + + } + + MemoryWrite(DMNI_OP, READ); + MemoryWrite(DMNI_START, 1); +} + + +int main() +{ + ServiceHeader *p; + p -> header = 1; + p -> payload_size = 2; // 6 devido ao service header + p -> service = 3; + p -> source = 4; + p -> target = 5; + p -> pkt_size = 6; + MemoryWrite(DMNI_SIZE, 6); + MemoryWrite(DMNI_ADDRESS, (unsigned int)p ); //grava na memoria as informacoes do header + + + unsigned int data_dma_code[102]; + data_dma_code[0]= 0x241d7fff; + data_dma_code[1]= 0x0c00002c; + data_dma_code[2]= 0x00000000; + data_dma_code[3]= 0x00002021; + data_dma_code[4]= 0x0000000c; + data_dma_code[5]= 0x00000000; + data_dma_code[6]= 0x08000006; + data_dma_code[7]= 0x00000000; + data_dma_code[8]= 0x0000000c; + data_dma_code[9]= 0x00000000; + data_dma_code[10]= 0x03e00008; + data_dma_code[11]= 0x00000000; + data_dma_code[12]= 0x24e20006; + data_dma_code[13]= 0xac450008; + data_dma_code[14]= 0xac440000; + data_dma_code[15]= 0xac420004; + data_dma_code[16]= 0x3c022000; + data_dma_code[17]= 0x34420140; + data_dma_code[18]= 0x8c430000; + data_dma_code[19]= 0x3c052000; + data_dma_code[20]= 0xac43000c; + data_dma_code[21]= 0xac440010; + data_dma_code[22]= 0xac470014; + data_dma_code[23]= 0x34a30250; + data_dma_code[24]= 0x8c620000; + data_dma_code[25]= 0x00000000; + data_dma_code[26]= 0x1440fffd; + data_dma_code[27]= 0x34a20200; + data_dma_code[28]= 0x34a40210; + data_dma_code[29]= 0x24030006; + data_dma_code[30]= 0xac430000; + data_dma_code[31]= 0xac820000; + data_dma_code[32]= 0x18e00004; + data_dma_code[33]= 0x34a20205; + data_dma_code[34]= 0x34a30215; + data_dma_code[35]= 0xac470000; + data_dma_code[36]= 0xac660000; + data_dma_code[37]= 0x34a20230; + data_dma_code[38]= 0x34a30220; + data_dma_code[39]= 0x24040001; + data_dma_code[40]= 0xac600000; + data_dma_code[41]= 0xac440000; + data_dma_code[42]= 0x03e00008; + data_dma_code[43]= 0x00000000; + data_dma_code[44]= 0x27bdffa8; + data_dma_code[45]= 0x24020001; + data_dma_code[46]= 0x24030002; + data_dma_code[47]= 0xafa20010; + data_dma_code[48]= 0xafa30014; + data_dma_code[49]= 0x24020003; + data_dma_code[50]= 0x24030004; + data_dma_code[51]= 0xafa20018; + data_dma_code[52]= 0xafa3001c; + data_dma_code[53]= 0x24020005; + data_dma_code[54]= 0x24030006; + data_dma_code[55]= 0xafa20020; + data_dma_code[56]= 0xafa30024; + data_dma_code[57]= 0x24020007; + data_dma_code[58]= 0x24030008; + data_dma_code[59]= 0xafa20028; + data_dma_code[60]= 0xafa3002c; + data_dma_code[61]= 0x24020009; + data_dma_code[62]= 0x2403000a; + data_dma_code[63]= 0xafa20030; + data_dma_code[64]= 0xafa30034; + data_dma_code[65]= 0x2402000b; + data_dma_code[66]= 0x2403000c; + data_dma_code[67]= 0xafb00050; + data_dma_code[68]= 0xafa20038; + data_dma_code[69]= 0x27b00010; + data_dma_code[70]= 0xafa3003c; + data_dma_code[71]= 0x2402000d; + data_dma_code[72]= 0x2403000e; + data_dma_code[73]= 0x24040001; + data_dma_code[74]= 0x24050290; + data_dma_code[75]= 0x02003021; + data_dma_code[76]= 0x24070010; + data_dma_code[77]= 0xafa20040; + data_dma_code[78]= 0xafa30044; + data_dma_code[79]= 0x2402000f; + data_dma_code[80]= 0x24030010; + data_dma_code[81]= 0xafbf0054; + data_dma_code[82]= 0xafa20048; + data_dma_code[83]= 0x0c00000c; + data_dma_code[84]= 0xafa3004c; + data_dma_code[85]= 0x24040100; + data_dma_code[86]= 0x24050290; + data_dma_code[87]= 0x02003021; + data_dma_code[88]= 0x0c00000c; + data_dma_code[89]= 0x24070010; + data_dma_code[90]= 0x00002021; + data_dma_code[91]= 0x24050290; + data_dma_code[92]= 0x02003021; + data_dma_code[93]= 0x0c00000c; + data_dma_code[94]= 0x24070010; + data_dma_code[95]= 0x02003021; + data_dma_code[96]= 0x24040101; + data_dma_code[97]= 0x24050290; + data_dma_code[98]= 0x0c00000c; + data_dma_code[99]= 0x24070010; + data_dma_code[100]= 0x08000064; + data_dma_code[101]= 0x00000000; + + transmite(0x00000001 ,0x00000290, data_dma_code ,102); + transmite(0x00000100 ,0x00000290, data_dma_code ,102); + transmite(0x00000000 ,0x00000290, data_dma_code ,102); + transmite(0x00000101 ,0x00000290, data_dma_code,102); + + + while(1); + + + +} + +/* + +USO: +int message[30] +transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) +*/ \ No newline at end of file diff --git a/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd index 4ba960a..ba6ea65 100644 --- a/hardware/vhdl/hemps.vhd +++ b/hardware/vhdl/hemps.vhd @@ -19,7 +19,7 @@ use ieee.std_logic_unsigned.all; use work.standards.all; use work.hemps_pkg.all; -entity HeMPS is +entity HeMPS is -- Interface com o ambiente exterior port( clock : in std_logic; reset : in std_logic; @@ -38,12 +38,12 @@ entity HeMPS is ); end; -architecture HeMPS of HeMPS is +architecture HeMPS of HeMPS is --Relacao entre as portas -- Interconnection signals - type txNport is array (NUMBER_PROCESSORS-1 downto 0) of std_logic_vector(3 downto 0); + type txNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); signal tx : txNPORT; - type rxNport is array (NUMBER_PROCESSORS-1 downto 0) of std_logic_vector(3 downto 0); + type rxNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); signal rx : rxNPORT; type clock_rxNport is array (NUMBER_PROCESSORS - 1 downto 0) of std_logic_vector(3 downto 0); signal clock_rx : clock_rxNPORT; @@ -74,7 +74,7 @@ begin end generate core_type_gen; - proc : for i in 0 to NUMBER_PROCESSORS-1 generate + proc : for i in 0 to NUMBER_PROCESSORS-1 generate --Gera uma matriz de processadores homeogenios PE : entity work.pe generic map ( @@ -112,20 +112,40 @@ begin ------------------------------------------------------------------------------ --- REPOSITORY CONNECTIONS ---------------------------------------------------- ------------------------------------------------------------------------------ - repo_mas : if pe_type(i) = "mas" generate + repo_mas : if pe_type(i) = "mas" generate -- Caso o PE for mestre repo_address <= repo_address_sig(i); repo_data_sig(i) <= repo_data; ack_app <= ack_app_sig(i); req_app_sig(i) <= req_app; end generate; - ground_repo : if pe_type(i) /= "mas" generate + ground_repo : if pe_type(i) /= "mas" generate --Caso o PE nao for mestre repo_address_sig(i) <= (others => '0'); repo_data_sig(i) <= (others => '0'); ack_app_sig(i) <= '0'; req_app_sig(i) <= (others => '0'); end generate; + + + + + -- Returns the router position in the mesh + -- BR: Botton Right + -- BL: Botton Left + -- TR: Top Right + -- TL: Top Left + -- CRX: Center Right + -- CL: Center Left + -- CC: Center + -- 4x4 positions exemple + -- TL TC TC TR + -- CL CC CC CRX + -- CL CC CC CRX + -- BL BC BC BR + + + ------------------------------------------------------------------------------ --- EAST PORT CONNECTIONS ---------------------------------------------------- ------------------------------------------------------------------------------ @@ -143,11 +163,11 @@ begin data_consumer : entity work.receive_data generic map(router_nb => i, port_name => "EAST") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(EAST), - tx => tx(i)(EAST), - data_out => data_out(i)(EAST), + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(EAST), + tx => tx(i)(EAST), + data_out => data_out(i)(EAST), credit_i => credit_i(i)(EAST)); end generate; @@ -175,11 +195,11 @@ begin data_consumer : entity work.receive_data generic map(router_nb => i, port_name => "WEST") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(WEST), - tx => tx(i)(WEST), - data_out => data_out(i)(WEST), + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(WEST), + tx => tx(i)(WEST), + data_out => data_out(i)(WEST), credit_i => credit_i(i)(WEST)); end generate; @@ -207,11 +227,11 @@ begin data_consumer : entity work.receive_data generic map(router_nb => i, port_name => "NORTH") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(NORTH), - tx => tx(i)(NORTH), - data_out => data_out(i)(NORTH), + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(NORTH), + tx => tx(i)(NORTH), + data_out => data_out(i)(NORTH), credit_i => credit_i(i)(NORTH)); end generate; @@ -239,11 +259,11 @@ begin data_consumer : entity work.receive_data generic map(router_nb => i, port_name => "SOUTH") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(SOUTH), - tx => tx(i)(SOUTH), - data_out => data_out(i)(SOUTH), + port map(clock => clock, + reset => reset, + clock_tx => clock_tx(i)(SOUTH), + tx => tx(i)(SOUTH), + data_out => data_out(i)(SOUTH), credit_i => credit_i(i)(SOUTH)); end generate; diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 473a5c1..f1c53b5 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -40,6 +40,7 @@ entity dmni is intr : out std_logic; send_active : out std_logic; receive_active : out std_logic; + reset_dmni : out std_logic; -- Memory interface mem_address : out std_logic_vector(31 downto 0); mem_data_write : out std_logic_vector(31 downto 0); @@ -62,7 +63,7 @@ architecture dmni of dmni is constant DMNI_TIMER: std_logic_vector(4 downto 0):="10000"; constant WORD_SIZE: std_logic_vector(4 downto 0):="00100"; - type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, FINISH); + type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, FINISH); signal DMNI_Send: dmni_state; signal DMNI_Receive: dmni_state; @@ -103,6 +104,12 @@ architecture dmni of dmni is signal send_active_2 : std_logic; signal receive_active_2 : std_logic; signal intr_counter_temp : std_logic_vector(3 downto 0); + + signal reset_dmni_s : std_logic; + signal payload_fix : regflit; + signal sizedata_fix : regflit; + signal novo_pacote : std_logic; + signal is_dmma : std_logic; begin --config proc_config: process(clock) @@ -144,7 +151,7 @@ begin case ARB is when ROUND => if prio = '0' then - if DMNI_Receive = COPY_TO_MEM then + if (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then ARB <= RECEIVE; read_enable <= '1'; elsif send_active_2 = '1' then @@ -155,7 +162,7 @@ begin if send_active_2 = '1' then ARB <= SEND; write_enable <= '1'; - elsif DMNI_Receive = COPY_TO_MEM then + elsif (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then ARB <= RECEIVE; read_enable <= '1'; end if; @@ -187,6 +194,12 @@ begin proc_receive : process (clock, reset) begin if (reset = '1') then + reset_dmni_s <= '1'; + payload_fix <= (others=>'0'); + sizedata_fix <= (others=>'0'); + novo_pacote <= '0'; + is_dmma <= '0'; + first <= (others=> '0'); last <= (others=> '0'); payload_size <= (others=> '0'); @@ -205,7 +218,6 @@ begin bufferr(CONV_INTEGER(last)) <= data_in; add_buffer <= '1'; last <= last + 1; - --Read from NoC case( SR ) is when HEADER => @@ -218,44 +230,91 @@ begin when PAYLOAD => is_header(CONV_INTEGER(last)) <= '0'; payload_size <= data_in - 1; + payload_fix <= data_in - 1; + sizedata_fix <= data_in - 12; SR <= DATA; when DATA => + novo_pacote <= '1'; is_header(CONV_INTEGER(last)) <= '0'; if(payload_size = 0) then SR <= HEADER; - else + novo_pacote <= '0'; + is_dmma <= '0'; + else payload_size <= payload_size - 1; + + if (payload_size = payload_fix) then + if (data_in = x"00000300") then --Service 300 start_cpu + reset_dmni_s <= '0'; + end if; + end if; + if (payload_size = payload_fix) then + if (data_in = x"00000290") then --Service 290 dmni_operation + is_dmma <= '1'; + end if; + end if; end if; end case ; - end if; --(rx ='1' and slot_available = '1') + end if; --(rx ='1' and slot_available = '1') --Write to memory case( DMNI_Receive ) is when WAIT_state => - if (start = '1' and operation = '1') then - recv_address <= address - WORD_SIZE; - recv_size <= size - 1; + if ((start = '1' and operation = '1') or novo_pacote = '1' ) then + --recv_address <= address - WORD_SIZE; + --recv_size <= size - 1; + recv_address <= (others=> '0'); + recv_size <= payload_fix + 2; if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then intr_counter_temp <= intr_counter_temp -1; end if; receive_active_2 <= '1'; - DMNI_Receive <= COPY_TO_MEM; + if(is_dmma = '1') then + DMNI_Receive <= COPY_TO_MEM_DMA; + else + DMNI_Receive <= COPY_TO_MEM; + end if; end if; when COPY_TO_MEM => if (read_enable = '1' and read_av = '1') then - mem_byte_we <= "1111"; - mem_data_write <= bufferr(CONV_INTEGER(first)); + --mem_byte_we <= "1111"; + --mem_data_write <= bufferr(CONV_INTEGER(first)); + --recv_address <= recv_address + WORD_SIZE; + recv_address <= (others=> '0'); + mem_byte_we <= "0000"; + mem_data_write <= (others=> '0'); first <= first + 1; add_buffer <= '0'; - recv_address <= recv_address + WORD_SIZE; recv_size <= recv_size -1; if (recv_size = 0) then DMNI_Receive <= FINISH; - end if ; + end if ; else mem_byte_we <= "0000"; end if; + + when COPY_TO_MEM_DMA => + if (read_enable = '1' and read_av = '1') then + if (recv_size <= sizedata_fix) then + mem_byte_we <= "1111"; + mem_data_write <= bufferr(CONV_INTEGER(first)); + recv_address <= recv_address + WORD_SIZE; + else + mem_byte_we <= "0000"; + mem_data_write <= (others=> '0'); + recv_address <= (others=> '0'); + end if; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if ; + else + mem_byte_we <= "0000"; + end if; + when FINISH => receive_active_2 <= '0'; @@ -270,6 +329,7 @@ begin intr_count <= intr_counter_temp; intr <= '1' when intr_counter_temp > 0 else '0'; + reset_dmni <= reset_dmni_s; proc_send : process (clock, reset) begin diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 4306fb8..e224e4c 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -2,7 +2,7 @@ -- HeMPS Processing Element ------------------------------------------------------------------------------------------------ library ieee; -use work.mlite_pack.all; +use work.mlite_pack.all; use work.standards.all; use work.hemps_pkg.all; use ieee.std_logic_1164.all; @@ -17,7 +17,7 @@ library unisim; use unisim.vcomponents.all; entity pe is - generic + generic ( log_file : string := "output.txt"; router_address : regmetadeflit := (others => '0'); @@ -48,381 +48,402 @@ entity pe is -- write_enable_debug : out std_logic; -- data_out_debug : out std_logic_vector(31 downto 0); -- busy_debug : in std_logic - ); + ); end entity pe; architecture structural of pe is - - type repo_state is (WAIT_state, COPY_FROM_REP); - signal repo_FSM : repo_state; - - signal cpu_mem_address_reg : std_logic_vector(31 downto 0); - signal cpu_mem_data_write_reg : std_logic_vector(31 downto 0); - signal cpu_mem_write_byte_enable_reg : std_logic_vector(3 downto 0); - signal irq_mask_reg : std_logic_vector(7 downto 0); - signal irq_status : std_logic_vector(7 downto 0); - signal irq : std_logic; - signal time_slice : std_logic_vector(31 downto 0); - signal write_enable : std_logic; - signal tick_counter_local : std_logic_vector(31 downto 0); - signal tick_counter : std_logic_vector(31 downto 0); - signal current_page : std_logic_vector(7 downto 0); - signal cpu_mem_address : std_logic_vector(31 downto 0); - signal cpu_mem_data_write : std_logic_vector(31 downto 0); - signal cpu_mem_data_read : std_logic_vector(31 downto 0); - signal cpu_mem_write_byte_enable : std_logic_vector(3 downto 0); - signal cpu_mem_pause : std_logic; - signal cpu_enable_ram : std_logic; - signal cpu_set_size : std_logic; - signal cpu_set_address : std_logic; - signal cpu_set_size_2 : std_logic; - signal cpu_set_address_2 : std_logic; - signal cpu_set_op : std_logic; - signal cpu_start : std_logic; - signal clock_aux : std_logic; - signal clock_hold_s : std_logic; - signal pending_service : std_logic; - - --Router - signal clock_rx_router : regNport; - signal rx_router : regNport; - signal data_in_router : arrayNport_regflit; - signal credit_o_router : regNport; - signal clock_tx_router : regNport; - signal tx_router : regNport; - signal data_out_router : arrayNport_regflit; - signal credit_i_router : regNport; - - signal data_read_ram : std_logic_vector(31 downto 0); - signal mem_data_read : std_logic_vector(31 downto 0); - --signal debug_busy : std_logic; - --signal debug_write_data : std_logic; - --signal debug_write_busy : std_logic; - --signal debug_data_avail : std_logic; - signal ni_intr : std_logic; - signal dmni_mem_address : std_logic_vector(31 downto 0); - signal dmni_mem_write_byte_enable : std_logic_vector(3 downto 0); - signal dmni_mem_data_write : std_logic_vector(31 downto 0); - signal dmni_mem_data_read : std_logic_vector(31 downto 0); - signal dmni_data_read : std_logic_vector(31 downto 0); - signal dmni_enable_internal_ram : std_logic; - signal dmni_send_active_sig : std_logic; - signal dmni_receive_active_sig : std_logic; - signal addr_a : std_logic_vector(31 downto 2); - signal addr_b : std_logic_vector(31 downto 2); - signal cpu_repo_access : std_logic := '0'; - signal data_av : std_logic; - signal end_sim_reg : std_logic_vector(31 downto 0); - signal uart_write_data : std_logic; - - signal slack_update_timer : std_logic_vector(31 downto 0); - + + type repo_state is (WAIT_state, COPY_FROM_REP); + signal repo_FSM : repo_state; + + signal cpu_mem_address_reg : std_logic_vector(31 downto 0); + signal cpu_mem_data_write_reg : std_logic_vector(31 downto 0); + signal cpu_mem_write_byte_enable_reg : std_logic_vector(3 downto 0); + signal irq_mask_reg : std_logic_vector(7 downto 0); + signal irq_status : std_logic_vector(7 downto 0); + signal irq : std_logic; + signal time_slice : std_logic_vector(31 downto 0); + signal write_enable : std_logic; + signal tick_counter_local : std_logic_vector(31 downto 0); + signal tick_counter : std_logic_vector(31 downto 0); + signal current_page : std_logic_vector(7 downto 0); + signal cpu_mem_address : std_logic_vector(31 downto 0); + signal cpu_mem_data_write : std_logic_vector(31 downto 0); + signal cpu_mem_data_read : std_logic_vector(31 downto 0); + signal cpu_mem_write_byte_enable : std_logic_vector(3 downto 0); + signal cpu_mem_pause : std_logic; + signal cpu_enable_ram : std_logic; + signal cpu_set_size : std_logic; + signal cpu_set_address : std_logic; + signal cpu_set_size_2 : std_logic; + signal cpu_set_address_2 : std_logic; + signal cpu_set_op : std_logic; + signal cpu_start : std_logic; + signal clock_aux : std_logic; + signal clock_hold_s : std_logic; + signal pending_service : std_logic; + + --Router + signal clock_rx_router : regNport; + signal rx_router : regNport; + signal data_in_router : arrayNport_regflit; + signal credit_o_router : regNport; + signal clock_tx_router : regNport; + signal tx_router : regNport; + signal data_out_router : arrayNport_regflit; + signal credit_i_router : regNport; + + signal data_read_ram : std_logic_vector(31 downto 0); + signal mem_data_read : std_logic_vector(31 downto 0); + --signal debug_busy : std_logic; + --signal debug_write_data : std_logic; + --signal debug_write_busy : std_logic; + --signal debug_data_avail : std_logic; + signal ni_intr : std_logic; + signal dmni_mem_address : std_logic_vector(31 downto 0); + signal dmni_mem_write_byte_enable : std_logic_vector(3 downto 0); + signal dmni_mem_data_write : std_logic_vector(31 downto 0); + signal dmni_mem_data_read : std_logic_vector(31 downto 0); + signal dmni_data_read : std_logic_vector(31 downto 0); + signal dmni_enable_internal_ram : std_logic; + signal dmni_send_active_sig : std_logic; + signal dmni_receive_active_sig : std_logic; + signal addr_a : std_logic_vector(31 downto 2); + signal addr_b : std_logic_vector(31 downto 2); + signal cpu_repo_access : std_logic := '0'; + signal data_av : std_logic; + signal end_sim_reg : std_logic_vector(31 downto 0); + signal uart_write_data : std_logic; + + signal slack_update_timer : std_logic_vector(31 downto 0); + + signal reset_dmni : std_logic; + begin - + ----------------------------------------------------------------------------------- -- PE COMPONENTS INSTANTIATION ----------------------------------------------------------------------------------- - cpu : entity work.mlite_cpu - port map( - clk => clock_hold_s, - reset_in => reset, - intr_in => irq, - mem_address => cpu_mem_address, - mem_data_w => cpu_mem_data_write, - mem_data_r => cpu_mem_data_read, - mem_byte_we => cpu_mem_write_byte_enable, - mem_pause => cpu_mem_pause, - current_page => current_page - ); - - -master: if kernel_type = "mas" generate - mem : entity work.ram_master - port map( - clk => clock, - enable_a => cpu_enable_ram, - wbe_a => cpu_mem_write_byte_enable, - address_a => addr_a, - data_write_a => cpu_mem_data_write, - data_read_a => data_read_ram, - enable_b => dmni_enable_internal_ram, - wbe_b => dmni_mem_write_byte_enable, - address_b => addr_b, - data_write_b => dmni_mem_data_write, - data_read_b => mem_data_read - ); -end generate; - -slave: if kernel_type = "sla" generate - mem : entity work.ram_slave - port map( - clk => clock, - enable_a => cpu_enable_ram, - wbe_a => cpu_mem_write_byte_enable, - address_a => addr_a, - data_write_a => cpu_mem_data_write, - data_read_a => data_read_ram, - enable_b => dmni_enable_internal_ram, - wbe_b => dmni_mem_write_byte_enable, - address_b => addr_b, - data_write_b => dmni_mem_data_write, - data_read_b => mem_data_read - ); -end generate; - - router : entity work.RouterCC - generic map(address => router_address, - manual_NORTH => manual_NORTH, - manual_SOUTH => manual_SOUTH, - manual_EAST => manual_EAST, - manual_WEST => manual_WEST) - port map( - clock => clock, - reset => reset, - clock_rx => clock_rx_router, - rx => rx_router, - data_in => data_in_router, - credit_o => credit_o_router, - clock_tx => clock_tx_router, - tx => tx_router, - data_out => data_out_router, - credit_i => credit_i_router - ); - - - dmni : entity work.dmni - generic map( - address_router => router_address - ) - port map( - clock => clock, - reset => reset, - --Configuration interface - set_address => cpu_set_address, - set_address_2 => cpu_set_address_2, - set_size => cpu_set_size, - set_size_2 => cpu_set_size_2, - set_op => cpu_set_op, - start => cpu_start, - config_data => dmni_data_read, - - -- Status outputs - intr => ni_intr, - send_active => dmni_send_active_sig, - receive_active => dmni_receive_active_sig, - - -- Memory interface - mem_address => dmni_mem_address, - mem_data_write => dmni_mem_data_write, - mem_data_read => dmni_mem_data_read, - mem_byte_we => dmni_mem_write_byte_enable, - - --NoC Interface (Local port) - tx => rx_router(LOCAL), - data_out => data_in_router(LOCAL), - credit_i => credit_o_router(LOCAL), - clock_tx => clock_rx_router(LOCAL), - rx => tx_router(LOCAL), - data_in => data_out_router(LOCAL), - credit_o => credit_i_router(LOCAL), - clock_rx => clock_tx_router(LOCAL) - ); - - uart : entity work.UartFile - generic map( - log_file => log_file - ) - port map( - reset => reset, - data_av => uart_write_data, - data_in => cpu_mem_data_write_reg - ); - + mastercpu : if kernel_type = "mas" generate --Distincao da CPU para Mestre + cpu : entity work.mlite_cpu + port map( + clk => clock_hold_s, + reset_in => reset, + intr_in => irq, + mem_address => cpu_mem_address, + mem_data_w => cpu_mem_data_write, + mem_data_r => cpu_mem_data_read, + mem_byte_we => cpu_mem_write_byte_enable, + mem_pause => cpu_mem_pause, + current_page => current_page + ); + end generate; + + + slavecpu : if kernel_type = "sla" generate --Distincao da CPU para Escravo + cpu : entity work.mlite_cpu + port map( + clk => clock_hold_s, + reset_in => reset_dmni, + intr_in => irq, + mem_address => cpu_mem_address, + mem_data_w => cpu_mem_data_write, + mem_data_r => cpu_mem_data_read, + mem_byte_we => cpu_mem_write_byte_enable, + mem_pause => cpu_mem_pause, + current_page => current_page + ); + end generate; + + + master : if kernel_type = "mas" generate + mem : entity work.ram_master + port map( + clk => clock, + enable_a => cpu_enable_ram, + wbe_a => cpu_mem_write_byte_enable, + address_a => addr_a, + data_write_a => cpu_mem_data_write, + data_read_a => data_read_ram, + enable_b => dmni_enable_internal_ram, + wbe_b => dmni_mem_write_byte_enable, + address_b => addr_b, + data_write_b => dmni_mem_data_write, + data_read_b => mem_data_read + ); + end generate; + + slave : if kernel_type = "sla" generate + mem : entity work.ram_slave + port map( + clk => clock, + enable_a => cpu_enable_ram, + wbe_a => cpu_mem_write_byte_enable, + address_a => addr_a, + data_write_a => cpu_mem_data_write, + data_read_a => data_read_ram, + enable_b => dmni_enable_internal_ram, + wbe_b => dmni_mem_write_byte_enable, + address_b => addr_b, + data_write_b => dmni_mem_data_write, + data_read_b => mem_data_read + ); + end generate; + + router : entity work.RouterCC + generic map(address => router_address, + manual_NORTH => manual_NORTH, + manual_SOUTH => manual_SOUTH, + manual_EAST => manual_EAST, + manual_WEST => manual_WEST) + port map( + clock => clock, + reset => reset, + clock_rx => clock_rx_router, + rx => rx_router, + data_in => data_in_router, + credit_o => credit_o_router, + clock_tx => clock_tx_router, + tx => tx_router, + data_out => data_out_router, + credit_i => credit_i_router + ); + + + dmni : entity work.dmni + generic map( + address_router => router_address + ) + port map( + clock => clock, + reset => reset, + --Configuration interface + set_address => cpu_set_address, + set_address_2 => cpu_set_address_2, + set_size => cpu_set_size, + set_size_2 => cpu_set_size_2, + set_op => cpu_set_op, + start => cpu_start, + config_data => dmni_data_read, + + -- Status outputs + intr => ni_intr, + send_active => dmni_send_active_sig, + receive_active => dmni_receive_active_sig, + reset_dmni => reset_dmni, + + -- Memory interface + mem_address => dmni_mem_address, + mem_data_write => dmni_mem_data_write, + mem_data_read => dmni_mem_data_read, + mem_byte_we => dmni_mem_write_byte_enable, + + --NoC Interface (Local port) + tx => rx_router(LOCAL), + data_out => data_in_router(LOCAL), + credit_i => credit_o_router(LOCAL), + clock_tx => clock_rx_router(LOCAL), + rx => tx_router(LOCAL), + data_in => data_out_router(LOCAL), + credit_o => credit_i_router(LOCAL), + clock_rx => clock_tx_router(LOCAL) + ); + + uart : entity work.UartFile + generic map( + log_file => log_file + ) + port map( + reset => reset, + data_av => uart_write_data, + data_in => cpu_mem_data_write_reg + ); + ----------------------------------------------------------------------------------- -- COMBINATIONAL LOGIC AND WIRING ----------------------------------------------------------------------------------- - --Router external wiring - clock_rx_router (3 downto 0) <= clock_rx; - rx_router (3 downto 0) <= rx; - credit_i_router (3 downto 0) <= credit_i; - data_in_router (EAST) <= data_in(EAST); - data_in_router (WEST) <= data_in(WEST); - data_in_router (NORTH) <= data_in(NORTH); - data_in_router (SOUTH) <= data_in(SOUTH); - - clock_tx <= clock_tx_router (3 downto 0); - tx <= tx_router (3 downto 0); - credit_o <= credit_o_router (3 downto 0); - data_out(EAST) <= data_out_router (EAST); - data_out(WEST) <= data_out_router (WEST); - data_out(NORTH) <= data_out_router (NORTH); - data_out(SOUTH) <= data_out_router (SOUTH); - - -- UART - uart_write_data <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' else '0'; - --debug_busy <= '0'; - --debug_write_busy <= '0'; - --debug_data_avail <= '0'; - - -- CPU data read mux - MUX_CPU : cpu_mem_data_read <= repo_data_read when cpu_mem_address_reg(30 downto 28) = "001" else -- External RAM - ZERO(31 downto 8) & irq_mask_reg when cpu_mem_address_reg = IRQ_MASK else - ZERO(31 downto 8) & irq_status when cpu_mem_address_reg = IRQ_STATUS_ADDR else - time_slice when cpu_mem_address_reg = TIME_SLICE_ADDR else - ZERO(31 downto 16) & router_address when cpu_mem_address_reg = NET_ADDRESS else - tick_counter when cpu_mem_address_reg = TICK_COUNTER_ADDR else - req_app when cpu_mem_address_reg = REQ_APP_REG else - ZERO(31 downto 1) & dmni_send_active_sig when cpu_mem_address_reg = DMNI_SEND_ACTIVE else - ZERO(31 downto 1) & dmni_receive_active_sig when cpu_mem_address_reg = DMNI_RECEIVE_ACTIVE else - data_read_ram; - - --Comb assignments - addr_a(31 downto 28) <= cpu_mem_address(31 downto 28); - addr_a(27 downto PAGE_SIZE_H_INDEX + 1) <= ZERO(27 downto PAGE_SIZE_H_INDEX + 9) & current_page when current_page /= "00000000" and cpu_mem_address(31 downto PAGE_SIZE_H_INDEX + 1) /= ZERO(31 downto PAGE_SIZE_H_INDEX + 1) - else cpu_mem_address(27 downto PAGE_SIZE_H_INDEX + 1); - addr_a(PAGE_SIZE_H_INDEX downto 2) <= cpu_mem_address(PAGE_SIZE_H_INDEX downto 2); - - addr_b <= dmni_mem_address(31 downto 2); - data_av <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' else '0'; - --write_enable_debug <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' else '0'; - --data_out_debug <= cpu_mem_data_write_reg; - --debug_write_busy <= busy_debug; - --debug_busy <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' and busy_debug = '1' else '0'; - --cpu_mem_pause <= cpu_repo_access or debug_busy; - cpu_mem_pause <= cpu_repo_access; - irq <= '1' when (irq_status /= x"00" and irq_mask_reg /= x"00") else '0'; - dmni_data_read <= cpu_mem_data_write_reg; - dmni_mem_data_read <= mem_data_read when dmni_enable_internal_ram = '1' else repo_data_read; - cpu_enable_ram <= '1' when cpu_mem_address(30 downto 28) = "000" else '0'; - dmni_enable_internal_ram <= '1' when dmni_mem_address(30 downto 28) = "000" else '0'; - end_sim_reg <= x"00000000" when cpu_mem_address_reg = END_SIM and write_enable = '1' else x"00000001"; - irq_status(7 downto 4) <= "00" & ni_intr & '0'; - irq_status(3) <= '1' when time_slice = x"00000001" else '0'; - irq_status(2) <= '0'; - irq_status(1) <= '1' when dmni_send_active_sig = '0' and slack_update_timer = SLACK_MONITOR_WINDOW else '0'; - irq_status(0) <= (not dmni_send_active_sig and pending_service); - - cpu_set_size <= '1' when cpu_mem_address_reg = DMNI_SIZE and write_enable = '1' else '0'; - cpu_set_address <= '1' when cpu_mem_address_reg = DMNI_ADDR and write_enable = '1' else '0'; - cpu_set_size_2 <= '1' when cpu_mem_address_reg = DMNI_SIZE_2 and write_enable = '1' else '0'; - cpu_set_address_2 <= '1' when cpu_mem_address_reg = DMNI_ADDR_2 and write_enable = '1' else '0'; - cpu_set_op <= '1' when (cpu_mem_address_reg = DMNI_OP and write_enable = '1') else '0'; - cpu_start <= '1' when (cpu_mem_address_reg = START_DMNI and write_enable = '1') else '0'; - - write_enable <= '1' when cpu_mem_write_byte_enable_reg /= "0000" else '0'; + --Router external wiring + clock_rx_router (3 downto 0) <= clock_rx; + rx_router (3 downto 0) <= rx; + credit_i_router (3 downto 0) <= credit_i; + data_in_router (EAST) <= data_in(EAST); + data_in_router (WEST) <= data_in(WEST); + data_in_router (NORTH) <= data_in(NORTH); + data_in_router (SOUTH) <= data_in(SOUTH); + + clock_tx <= clock_tx_router (3 downto 0); + tx <= tx_router (3 downto 0); + credit_o <= credit_o_router (3 downto 0); + data_out(EAST) <= data_out_router (EAST); + data_out(WEST) <= data_out_router (WEST); + data_out(NORTH) <= data_out_router (NORTH); + data_out(SOUTH) <= data_out_router (SOUTH); + + -- UART + uart_write_data <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' else '0'; + --debug_busy <= '0'; + --debug_write_busy <= '0'; + --debug_data_avail <= '0'; + + -- CPU data read mux + MUX_CPU : cpu_mem_data_read <= repo_data_read when cpu_mem_address_reg(30 downto 28) = "001" else -- External RAM + ZERO(31 downto 8) & irq_mask_reg when cpu_mem_address_reg = IRQ_MASK else + ZERO(31 downto 8) & irq_status when cpu_mem_address_reg = IRQ_STATUS_ADDR else + time_slice when cpu_mem_address_reg = TIME_SLICE_ADDR else + ZERO(31 downto 16) & router_address when cpu_mem_address_reg = NET_ADDRESS else + tick_counter when cpu_mem_address_reg = TICK_COUNTER_ADDR else + req_app when cpu_mem_address_reg = REQ_APP_REG else + ZERO(31 downto 1) & dmni_send_active_sig when cpu_mem_address_reg = DMNI_SEND_ACTIVE else + ZERO(31 downto 1) & dmni_receive_active_sig when cpu_mem_address_reg = DMNI_RECEIVE_ACTIVE else + data_read_ram; + + --Comb assignments + addr_a(31 downto 28) <= cpu_mem_address(31 downto 28); + addr_a(27 downto PAGE_SIZE_H_INDEX + 1) <= ZERO(27 downto PAGE_SIZE_H_INDEX + 9) & current_page when current_page /= "00000000" and cpu_mem_address(31 downto PAGE_SIZE_H_INDEX + 1) /= ZERO(31 downto PAGE_SIZE_H_INDEX + 1) + else cpu_mem_address(27 downto PAGE_SIZE_H_INDEX + 1); + addr_a(PAGE_SIZE_H_INDEX downto 2) <= cpu_mem_address(PAGE_SIZE_H_INDEX downto 2); + + addr_b <= dmni_mem_address(31 downto 2); + data_av <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' else '0'; + --write_enable_debug <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' else '0'; + --data_out_debug <= cpu_mem_data_write_reg; + --debug_write_busy <= busy_debug; + --debug_busy <= '1' when cpu_mem_address_reg = DEBUG and write_enable = '1' and busy_debug = '1' else '0'; + --cpu_mem_pause <= cpu_repo_access or debug_busy; + cpu_mem_pause <= cpu_repo_access; + irq <= '1' when (irq_status /= x"00" and irq_mask_reg /= x"00") else '0'; + dmni_data_read <= cpu_mem_data_write_reg; + dmni_mem_data_read <= mem_data_read when dmni_enable_internal_ram = '1' else repo_data_read; + cpu_enable_ram <= '1' when cpu_mem_address(30 downto 28) = "000" else '0'; + dmni_enable_internal_ram <= '1' when dmni_mem_address(30 downto 28) = "000" else '0'; + end_sim_reg <= x"00000000" when cpu_mem_address_reg = END_SIM and write_enable = '1' else x"00000001"; + irq_status(7 downto 4) <= "00" & ni_intr & '0'; + irq_status(3) <= '1' when time_slice = x"00000001" else '0'; + irq_status(2) <= '0'; + irq_status(1) <= '1' when dmni_send_active_sig = '0' and slack_update_timer = SLACK_MONITOR_WINDOW else '0'; + irq_status(0) <= (not dmni_send_active_sig and pending_service); + + cpu_set_size <= '1' when cpu_mem_address_reg = DMNI_SIZE and write_enable = '1' else '0'; + cpu_set_address <= '1' when cpu_mem_address_reg = DMNI_ADDR and write_enable = '1' else '0'; + cpu_set_size_2 <= '1' when cpu_mem_address_reg = DMNI_SIZE_2 and write_enable = '1' else '0'; + cpu_set_address_2 <= '1' when cpu_mem_address_reg = DMNI_ADDR_2 and write_enable = '1' else '0'; + cpu_set_op <= '1' when (cpu_mem_address_reg = DMNI_OP and write_enable = '1') else '0'; + cpu_start <= '1' when (cpu_mem_address_reg = START_DMNI and write_enable = '1') else '0'; + + write_enable <= '1' when cpu_mem_write_byte_enable_reg /= "0000" else '0'; ----------------------------------------------------------------------------------- -- SYNCHRONOUS PROCESSES ----------------------------------------------------------------------------------- - repo_to_mem_access: process(clock,reset) - begin - if reset = '1' then - repo_FSM <= WAIT_state; - cpu_repo_access <= '0'; - elsif rising_edge(clock) then - case( repo_FSM ) is - when WAIT_state => - if(cpu_mem_address(30 downto 28) = "001") then - cpu_repo_access <= '1'; - repo_FSM <= COPY_FROM_REP; - end if; - when COPY_FROM_REP => - repo_FSM <= WAIT_state; - cpu_repo_access <= '0'; - end case ; - end if; - end process repo_to_mem_access; + repo_to_mem_access : process(clock, reset) + begin + if reset = '1' then + repo_FSM <= WAIT_state; + cpu_repo_access <= '0'; + elsif rising_edge(clock) then + case(repo_FSM) is + when WAIT_state => + if(cpu_mem_address(30 downto 28) = "001") then + cpu_repo_access <= '1'; + repo_FSM <= COPY_FROM_REP; + end if; + when COPY_FROM_REP => + repo_FSM <= WAIT_state; + cpu_repo_access <= '0'; + end case; + end if; + end process repo_to_mem_access; + + + process(cpu_repo_access, dmni_mem_address) + begin + if(cpu_repo_access = '1') then + repo_address <= cpu_mem_address(29 downto 0); + elsif dmni_mem_address(30 downto 28) = "001" then + repo_address <= dmni_mem_address(29 downto 0); + end if; + end process; + sequential_attr : process(clock, reset) + begin + if reset = '1' then + cpu_mem_address_reg <= ZERO; + cpu_mem_data_write_reg <= ZERO; + cpu_mem_write_byte_enable_reg <= ZERO(3 downto 0); + irq_mask_reg <= ZERO(7 downto 0); + time_slice <= ZERO; + tick_counter <= ZERO; + pending_service <= '0'; + ack_app <= '0'; + slack_update_timer <= ZERO; + elsif (clock'event and clock = '1') then + if cpu_mem_pause = '0' then + cpu_mem_address_reg <= cpu_mem_address; + cpu_mem_data_write_reg <= cpu_mem_data_write; + cpu_mem_write_byte_enable_reg <= cpu_mem_write_byte_enable; - process(cpu_repo_access, dmni_mem_address) - begin - if(cpu_repo_access = '1') then - repo_address <= cpu_mem_address(29 downto 0) ; - elsif dmni_mem_address(30 downto 28) = "001" then - repo_address <= dmni_mem_address(29 downto 0); + if cpu_mem_address_reg = IRQ_MASK and write_enable = '1' then + irq_mask_reg <= cpu_mem_data_write_reg(7 downto 0); end if; - end process; - - sequential_attr: process(clock, reset) - begin - if reset = '1' then - cpu_mem_address_reg <= ZERO; - cpu_mem_data_write_reg <= ZERO; - cpu_mem_write_byte_enable_reg <= ZERO(3 downto 0); - irq_mask_reg <= ZERO(7 downto 0); - time_slice <= ZERO; - tick_counter <= ZERO; - pending_service <= '0'; - ack_app <= '0'; - slack_update_timer <= ZERO; - elsif (clock'event and clock = '1') then - if cpu_mem_pause = '0' then - cpu_mem_address_reg <= cpu_mem_address; - cpu_mem_data_write_reg <= cpu_mem_data_write; - cpu_mem_write_byte_enable_reg <= cpu_mem_write_byte_enable; - - if cpu_mem_address_reg = IRQ_MASK and write_enable = '1' then - irq_mask_reg <= cpu_mem_data_write_reg(7 downto 0); - end if; - -- Decrements the time slice when executing a task (current_page /= x"00") or handling a syscall (syscall = '1') - if time_slice > 1 then - time_slice <= time_slice - 1; - end if; - - if(cpu_mem_address_reg = PENDING_SERVICE_INTR and write_enable = '1') then - if cpu_mem_data_write_reg = ZERO then - pending_service <= '0'; - else - pending_service <= '1'; - end if; - end if; - end if; - - if cpu_mem_address_reg = SLACK_TIME_MONITOR and write_enable = '1' then - slack_update_timer <= cpu_mem_data_write_reg; - elsif slack_update_timer < SLACK_MONITOR_WINDOW then - slack_update_timer <= slack_update_timer + 1; - end if; - - if cpu_mem_address_reg = TIME_SLICE_ADDR and write_enable = '1' then - time_slice <= cpu_mem_data_write_reg; - end if; - - if cpu_mem_address_reg = ACK_APP_REG then - ack_app <= '1'; - elsif req_app(31) = '0' then - ack_app <= '0'; - end if; - - tick_counter <= tick_counter + 1; + -- Decrements the time slice when executing a task (current_page /= x"00") or handling a syscall (syscall = '1') + if time_slice > 1 then + time_slice <= time_slice - 1; end if; - end process sequential_attr; - - clock_stop: process(reset,clock) - begin - if(reset = '1') then - tick_counter_local <= (others=> '0'); - clock_aux <= '1'; - else - if cpu_mem_address_reg = CLOCK_HOLD and write_enable = '1' then - clock_aux <= '0'; - --elsif tx_router(LOCAL) = '1' or ni_intr = '1' or time_slice = x"00000001" then - elsif ni_intr = '1' or time_slice = x"00000001" or irq_status(1) = '1' then - clock_aux <= '1'; - end if; - - if(clock_aux ='1' and clock ='1') then - clock_hold_s <= '1'; - tick_counter_local <= tick_counter_local + 1; - else - clock_hold_s <= '0'; - end if; + + if(cpu_mem_address_reg = PENDING_SERVICE_INTR and write_enable = '1') then + if cpu_mem_data_write_reg = ZERO then + pending_service <= '0'; + else + pending_service <= '1'; + end if; end if; - end process clock_stop; + end if; + + if cpu_mem_address_reg = SLACK_TIME_MONITOR and write_enable = '1' then + slack_update_timer <= cpu_mem_data_write_reg; + elsif slack_update_timer < SLACK_MONITOR_WINDOW then + slack_update_timer <= slack_update_timer + 1; + end if; + + if cpu_mem_address_reg = TIME_SLICE_ADDR and write_enable = '1' then + time_slice <= cpu_mem_data_write_reg; + end if; + + if cpu_mem_address_reg = ACK_APP_REG then + ack_app <= '1'; + elsif req_app(31) = '0' then + ack_app <= '0'; + end if; + + tick_counter <= tick_counter + 1; + end if; + end process sequential_attr; + + clock_stop : process(reset, clock) + begin + if(reset = '1') then + tick_counter_local <= (others => '0'); + clock_aux <= '1'; + else + if cpu_mem_address_reg = CLOCK_HOLD and write_enable = '1' then + clock_aux <= '0'; + --elsif tx_router(LOCAL) = '1' or ni_intr = '1' or time_slice = x"00000001" then + elsif ni_intr = '1' or time_slice = x"00000001" or irq_status(1) = '1' then + clock_aux <= '1'; + end if; + + if(clock_aux = '1' and clock = '1') then + clock_hold_s <= '1'; + tick_counter_local <= tick_counter_local + 1; + else + clock_hold_s <= '0'; + end if; + end if; + end process clock_stop; end architecture structural; - + diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index e4ddc2e..da56b4a 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -93,7 +93,7 @@ package standards is --------------------------------------------------------- -- CONSTANT DEPENDENTE DA LARGURA DE BANDA DA REDE - FIXED FOR HEMPS --------------------------------------------------------- - constant TAM_FLIT : integer range 1 to 64 := 32; + constant TAM_FLIT : integer range 1 to 64 := 32; -- Flit tem faixa de 1 ate 64 e eh atribuido 32 constant METADEFLIT : integer range 1 to 32 := (TAM_FLIT/2); constant QUARTOFLIT : integer range 1 to 16 := (TAM_FLIT/4); diff --git a/kernel_slave.c b/kernel_slave.c deleted file mode 100644 index b1537b9..0000000 --- a/kernel_slave.c +++ /dev/null @@ -1,933 +0,0 @@ -/*!\file kernel_slave.c - * HEMPS VERSION - 8.0 - support for RT applications - * - * Distribution: June 2016 - * - * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br - * - * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br - * - * \brief - * Kernel slave is the system slave used to execute user's tasks. - * - * \detailed - * kernel_slave is the core of the OS running into the slave processors. - * Its job is to runs the user's task. It communicates whit the kernel_master to receive new tasks - * and also notifying its finish. - * The kernel_slave file uses several modules that implement specific functions - */ - -#include "kernel_slave.h" - -#include "../../../include/kernel_pkg.h" -#include "../../include/api.h" -#include "../../include/plasma.h" -#include "../../include/services.h" -#include "../../modules/task_location.h" -#include "../../modules/packet.h" -#include "../../modules/communication.h" -#include "../../modules/pending_service.h" -#include "../../modules/task_scheduler.h" -#include "../../modules/utils.h" -#if MIGRATION_ENABLED -#include "../../modules/task_migration.h" -#endif - -//Globals -unsigned int net_address; //!< Store the current XY address -unsigned int schedule_after_syscall; //!< Signals the syscall function (assembly implemented) to call the scheduler after the syscall -unsigned int cluster_master_address; //!< Store the cluster master XY address -unsigned int last_idle_time; //!< Store the last idle time duration -unsigned int total_slack_time; //!< Store the total of the processor idle time -TCB idle_tcb; //!< TCB pointer used to run idle task -TCB * current; //!< TCB pointer used to store the current task executing into processor -Message msg_write_pipe; //!< Message variable which is used to copy a message and send it by the NoC - - -/** Assembles and sends a TASK_TERMINATED packet to the master kernel - * \param terminated_task Terminated task TCB pointer - */ -void send_task_terminated(TCB * terminated_task){ - - ServiceHeader *p = get_service_header_slot(); - - p->header = terminated_task->master_address; - - p->service = TASK_TERMINATED; - - p->task_ID = terminated_task->id; - - p->master_ID = cluster_master_address; - - send_packet(p, 0, 0); - - if (terminated_task->master_address != cluster_master_address){ - - p = get_service_header_slot(); - - p->header = cluster_master_address; - - p->service = TASK_TERMINATED_OTHER_CLUSTER; - - p->task_ID = terminated_task->id; - - p->master_ID = terminated_task->master_address; - - send_packet(p, 0, 0); - } - -} - -/** Assembles and sends a TASK_ALLOCATED packet to the master kernel - * \param allocated_task Allocated task TCB pointer - */ -void send_task_allocated(TCB * allocated_task){ - - ServiceHeader *p = get_service_header_slot(); - - p->header = allocated_task->master_address; - - p->service = TASK_ALLOCATED; - - p->task_ID = allocated_task->id; - - p->master_ID = cluster_master_address; - - send_packet(p, 0, 0); -} - -/** Assembles and sends a MESSAGE_DELIVERY packet to a consumer task located into a slave processor - * \param producer_task ID of the task that produce the message (Send()) - * \param consumer_task ID of the task that consume the message (Receive()) - * \param msg_ptr Message pointer - */ -void send_message_delivery(int producer_task, int consumer_task, int consumer_PE, Message * msg_ptr){ - - ServiceHeader *p = get_service_header_slot(); - - p->header = consumer_PE; - - p->service = MESSAGE_DELIVERY; - - p->producer_task = producer_task; - - p->consumer_task = consumer_task; - - p->msg_lenght = msg_ptr->length; - - send_packet(p, (unsigned int)msg_ptr->msg, msg_ptr->length); - -} - -/** Assembles and sends a REAL_TIME_CHANGE packet to the master kernel - * \param tcb_ptr TCB pointer of the task that change its real-time parameters - */ -void send_task_real_time_change(TCB * tcb_ptr){ - - ServiceHeader * p = get_service_header_slot(); - - p = get_service_header_slot(); - - p->header = cluster_master_address; - - p->service = REAL_TIME_CHANGE; - - p->task_ID = tcb_ptr->id; - - p->utilization = tcb_ptr->scheduling_ptr->utilization; - - putsv("Send real time change, utilization: ", p->utilization); - - send_packet(p, 0, 0); -} - -/** Assembles and sends a SLACK_TIME_REPORT packet to the master kernel - */ -void send_slack_time_report(){ - - ServiceHeader * p = get_service_header_slot(); - - p->header = cluster_master_address; - - p->service = SLACK_TIME_REPORT; - - p->cpu_slack_time = ( (total_slack_time*100) / SLACK_TIME_WINDOW); - - send_packet(p, 0, 0); -} - -/** Assembles and sends a UPDATE_TASK_LOCATION packet to a slave processor. Useful because task migration - * \param target_proc Target slave processor which the packet will be sent - * \param task_id Task ID that have its location updated - * \param new_task_location New location (slave processor address) of the task - */ -void send_update_task_location(unsigned int target_proc, unsigned int task_id, unsigned int new_task_location){ - - ServiceHeader *p = get_service_header_slot(); - - if (target_proc != net_address){ - - p->header = target_proc; - - p->service = UPDATE_TASK_LOCATION; - - p->task_ID = task_id; - - p->allocated_processor = new_task_location; - - send_packet(p, 0, 0); - } - - if (target_proc != new_task_location){ - - p = get_service_header_slot(); - - p->header = new_task_location; - - p->service = UPDATE_TASK_LOCATION; - - p->task_ID = task_id; - - p->allocated_processor = new_task_location; - - send_packet(p, 0, 0); - } -} - -/** Assembles and sends a MESSAGE_REQUEST packet to producer task into a slave processor - * \param producer_task Producer task ID (Send()) - * \param consumer_task Consumer task ID (Receive()) - * \param targetPE Processor address of the producer task - * \param requestingPE Processor address of the consumer task - * \param insert_pipe_flag Tells to the producer PE that the message not need to be by passed again - */ -void send_message_request(int producer_task, int consumer_task, unsigned int targetPE, unsigned int requestingPE, int insert_pipe_flag){ - - - ServiceHeader *p = get_service_header_slot(); - - p->header = targetPE; - - p->service = MESSAGE_REQUEST; - - p->requesting_processor = requestingPE; - - p->producer_task = producer_task; - - p->consumer_task = consumer_task; - - p->insert_request = insert_pipe_flag; - - send_packet(p, 0, 0); -} - -//Bruno's Change - Added function to send the injection -void generateInjection(int producer_task, int consumer_task, unsigned int targetPE, unsigned int requestingPE, int insert_pipe_flag) - ServiceHeader *p = get_service_header_slot(); - p->header = targetPE; - p->service = BORDER_ROUTE; - p-> requesting_processor = requestingPE; - p-> producer_task = producer_task; - p->consumer_task = consumer_task; - p-> insert_request = insert_pipe_flag; - send_packet(p,0,0) - -/** Useful function to writes a message into the task page space - * \param task_tcb_ptr TCB pointer of the task - * \param msg_lenght Lenght of the message to be copied - * \param msg_data Message data - */ -void write_local_msg_to_task(TCB * task_tcb_ptr, int msg_lenght, int * msg_data){ - - Message * msg_ptr; - - msg_ptr = (Message*)((task_tcb_ptr->offset) | ((unsigned int)task_tcb_ptr->reg[3])); //reg[3] = address message - - msg_ptr->length = msg_lenght; - - for (int i=0; ilength; i++) - msg_ptr->msg[i] = msg_data[i]; - - //Unlock the blocked task - task_tcb_ptr->reg[0] = TRUE; - - //Release task to execute - task_tcb_ptr->scheduling_ptr->waiting_msg = 0; -} - -/** Syscall handler. It is called when a task calls a function defined into the api.h file - * \param service Service of the syscall - * \param arg0 Generic argument - * \param arg1 Generic argument - * \param arg2 Generic argument - */ -int Syscall(unsigned int service, unsigned int arg0, unsigned int arg1, unsigned int arg2) { - - Message *msg_read; - Message *msg_write; - PipeSlot *pipe_ptr; - MessageRequest * msg_req_ptr; - int consumer_task; - int producer_task; - int producer_PE; - int consumer_PE; - int appID; - int ret; - - schedule_after_syscall = 0; - - switch (service) { - - case EXIT: - - schedule_after_syscall = 1; - - //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process - //Also, due task migration sincronization messages, the producer task cannot finish it execution while have messages in PIPE - if (MemoryRead(DMNI_SEND_ACTIVE) || search_PIPE_producer(current->id)){ - return 0; - } - - puts("Task id: "); puts(itoa(current->id)); putsv(" terminated at ", MemoryRead(TICK_COUNTER)); - - send_task_terminated(current); - - clear_scheduling(current->scheduling_ptr); - - appID = current->id >> 8; - - if ( !is_another_task_running(appID) ){ - - clear_app_tasks_locations(appID); - } - - return 1; - - case WRITEPIPE: - - producer_task = current->id; - consumer_task = (int) arg1; - - appID = producer_task >> 8; - consumer_task = (appID << 8) | consumer_task; - - //puts("WRITEPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); - - consumer_PE = get_task_location(consumer_task); - - //Test if the consumer task is not allocated - if (consumer_PE == -1){ - //Task is blocked until its a TASK_RELEASE packet - current->scheduling_ptr->status = BLOCKED; - return 0; - } - - /*Points the message in the task page. Address composition: offset + msg address*/ - msg_read = (Message *)((current->offset) | arg0); - - //Searches if there is a message request to the produced message - msg_req_ptr = remove_message_request(producer_task, consumer_task); - - if (msg_req_ptr){ - - if (msg_req_ptr->requester_proc == net_address){ //Test if the consumer is local or remote - - //Writes to the consumer page address (local consumer) - TCB * requesterTCB = searchTCB(consumer_task); - - write_local_msg_to_task(requesterTCB, msg_read->length, msg_read->msg); - -#if MIGRATION_ENABLED - if (requesterTCB->proc_to_migrate != -1){ - - migrate_dynamic_memory(requesterTCB); - - schedule_after_syscall = 1; - } -#endif - - } else { //Send a mesage delivery (remote consumer) - - //Deadlock avoidance: voids to send a packet when the DMNI is busy in send process - if ( MemoryRead(DMNI_SEND_ACTIVE) ){ - //Restore the message request - msg_req_ptr->requested = producer_task; - msg_req_ptr->requester = consumer_task; - return 0; - } - - msg_write_pipe.length = msg_read->length; - - //Avoids message overwriting by the producer task - for (int i=0; i < msg_read->length; i++) - msg_write_pipe.msg[i] = msg_read->msg[i]; - - send_message_delivery(producer_task, consumer_task, msg_req_ptr->requester_proc, &msg_write_pipe); - - } - } else { //message not requested yet, stores into PIPE - - //########################### ADD PIPE ################################# - ret = add_PIPE(producer_task, consumer_task, msg_read); - //########################### ADD PIPE ################################# - - if (ret == 0){ - schedule_after_syscall = 1; - return 0; - } - } - - return 1; - - case READPIPE: - - consumer_task = current->id; - producer_task = (int) arg1; - - appID = consumer_task >> 8; - producer_task = (appID << 8) | producer_task; - - //puts("READPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); - - producer_PE = get_task_location(producer_task); - - //Test if the producer task is not allocated - if (producer_PE == -1){ - //Task is blocked until its a TASK_RELEASE packet - current->scheduling_ptr->status = BLOCKED; - return 0; - } - - if (producer_PE == net_address){ //Local producer - - //Searches if the message is in PIPE (local producer) - pipe_ptr = remove_PIPE(producer_task, consumer_task); - - if (pipe_ptr == 0){ - - //Stores the request into the message request table (local producer) - insert_message_request(producer_task, consumer_task, net_address); - - } else { - - //Message was found in pipe, writes to the consumer page address (local producer) - - msg_write = (Message*) arg0; - - msg_write = (Message*)((current->offset) | ((unsigned int)msg_write)); - - msg_write->length = pipe_ptr->message.length; - - for (int i = 0; ilength; i++) { - msg_write->msg[i] = pipe_ptr->message.msg[i]; - } - - return 1; - } - - } else { //Remote producer : Sends the message request (remote producer) - - //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process - if ( MemoryRead(DMNI_SEND_ACTIVE) ) - return 0; - - send_message_request(producer_task, consumer_task, producer_PE, net_address, 0); - - } - - //Sets task as waiting blocking its execution, it will execute again when the message is produced by a WRITEPIPE or incoming MSG_DELIVERY - current->scheduling_ptr->waiting_msg = 1; - - schedule_after_syscall = 1; - - return 0; - - case GETTICK: - - return MemoryRead(TICK_COUNTER); - - break; - - case ECHO: - - puts("$$$_"); - puts(itoa(net_address>>8));puts("x");puts(itoa(net_address&0xFF)); puts("_"); - puts(itoa(current->id >> 8)); puts("_"); - puts(itoa(current->id & 0xFF)); puts("_"); - puts((char *)((current->offset) | (unsigned int) arg0)); - puts("\n"); - - break; - - case REALTIME: - - //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process - if (MemoryRead(DMNI_SEND_ACTIVE)){ - return 0; - } - - //putsv("\nReal-time to task: ", current->id); - - real_time_task(current->scheduling_ptr, arg0, arg1, arg2); - - //send_task_real_time_change(current); - - schedule_after_syscall = 1; - - return 1; - - //Bruno Modification's 15/09 - //These changes were made in order to be able to send data out of the NoC. - //Concept is based on sending the first bit high will enable the function and the 2 others decide where to send it (in the switchcontrol). - case TRANSIT: - - consumer_task = current->id; - producer_task = (int) arg0; - - appID = consumer_task >> 8; - producer_task = (arg1 << 8) | producer_task; - - //puts("READPIPE - prod: "); puts(itoa(producer_task)); putsv(" consumer ", consumer_task); - - producer_PE = get_task_location(producer_task); - - //Test if the producer task is not allocated - if (producer_PE == -1){ - //Task is blocked until its a TASK_RELEASE packet - current->scheduling_ptr->status = BLOCKED; - return 0; - } - - if (producer_PE == net_address){ //Local producer - - //Searches if the message is in PIPE (local producer) - pipe_ptr = remove_PIPE(producer_task, consumer_task); - - if (pipe_ptr == 0){ - - //Stores the request into the message request table (local producer) - insert_message_request(producer_task, consumer_task, net_address); - - } else { - - //Message was found in pipe, writes to the consumer page address (local producer) - - msg_write = (Message*) arg2; - - msg_write = (Message*)((current->offset) | ((unsigned int)msg_write)); - - msg_write->length = pipe_ptr->message.length; - - for (int i = 0; ilength; i++) { - msg_write->msg[i] = pipe_ptr->message.msg[i]; - } - - return 1; - } - - } else { //Remote producer : Sends the message request (remote producer) - - //Deadlock avoidance: avoids to send a packet when the DMNI is busy in send process - if ( MemoryRead(DMNI_SEND_ACTIVE) ) - return 0; - - generateInjection(producer_task, consumer_task, producer_PE, net_address, 0); - - return 0; - - break; - } - - return 0; -} - -/** Handles a new packet from NoC - */ -int handle_packet(volatile ServiceHeader * p) { - - int need_scheduling, code_lenght, app_ID, task_loc; - unsigned int app_tasks_location[MAX_TASKS_APP]; - PipeSlot * slot_ptr; - Message * msg_ptr; - TCB * tcb_ptr = 0; - - need_scheduling = 0; - - switch (p->service) { - - case MESSAGE_REQUEST: //This case is the most complicated of the HeMPS if you understand it, so you understand all task communication protocol - //This case sincronizes the communication messages also in case of task migration, the migration allows several scenarios, that are handled inside this case - - //Gets the location of the producer task - task_loc = get_task_location(p->producer_task); - - //Test if the task was migrated to this processor but have message produced in the old processor - //In this case is necessary to forward the message request to the old processor - if (searchTCB(p->producer_task) && task_loc != net_address){ - if (p->insert_request) - insert_message_request(p->producer_task, p->consumer_task, p->requesting_processor); - else - //MESSAGE_REQUEST by pass - send_message_request(p->producer_task, p->consumer_task, task_loc, p->requesting_processor, 0); - - break; - } - - //Remove msg from PIPE, if there is no message, them slot_ptr will be 0 - //Note that this line, is below to the by pass above, becase we need to avoid that the a message be removed if still there are other messages in pipe of the old proc - slot_ptr = remove_PIPE(p->producer_task, p->consumer_task); - - //Test if there is no message in PIPE - if (slot_ptr == 0){ - - //Test if the producer task is running at this processor, this conditions work togheter to the first by pass condition (above). - if (task_loc == net_address){ - - insert_message_request(p->producer_task, p->consumer_task, p->requesting_processor); - - } else { //If not, the task was migrated and the requester message_request need to be forwarded to the correct producer proc - - //If there is no more messages in the pipe of the producer, update the location of the migrated task at the remote proc - if ( search_PIPE_producer(p->producer_task) == 0) - send_update_task_location(p->requesting_processor, p->producer_task, task_loc); - - //MESSAGE_REQUEST by pass with flag insert in pipe enabled (there is no more message for the requesting task in this processor) - send_message_request(p->producer_task, p->consumer_task, task_loc, p->requesting_processor, 1); - } - - //message found, send it!! - } else if (p->requesting_processor != net_address){ - - send_message_delivery(p->producer_task, p->consumer_task, p->requesting_processor, &slot_ptr->message); - - //This else is executed when this slave received a own MESSAGE_REQUEST due a task migration by pass - } else { - - tcb_ptr = searchTCB(p->consumer_task); - - write_local_msg_to_task(tcb_ptr, slot_ptr->message.length, slot_ptr->message.msg); - } - - break; - - case MESSAGE_DELIVERY: - - tcb_ptr = searchTCB(p->consumer_task); - - msg_ptr = (Message *)(tcb_ptr->offset | tcb_ptr->reg[3]); - - msg_ptr->length = p->msg_lenght; - - DMNI_read_data((unsigned int)msg_ptr->msg, msg_ptr->length); - - tcb_ptr->reg[0] = 1; - - //Release task to execute - tcb_ptr->scheduling_ptr->waiting_msg = 0; - -#if MIGRATION_ENABLED - if (tcb_ptr->proc_to_migrate != -1){ - - migrate_dynamic_memory(tcb_ptr); - - need_scheduling = 1; - - } else -#endif - - if (current == &idle_tcb){ - need_scheduling = 1; - } - - break; - - case TASK_ALLOCATION: - - tcb_ptr = search_free_TCB(); - - tcb_ptr->pc = 0; - - tcb_ptr->id = p->task_ID; - - puts("Task id: "); puts(itoa(tcb_ptr->id)); putsv(" allocated at ", MemoryRead(TICK_COUNTER)); - - code_lenght = p->code_size; - - tcb_ptr->text_lenght = code_lenght; - - tcb_ptr->master_address = p->master_ID; - - tcb_ptr->proc_to_migrate = -1; - - tcb_ptr->scheduling_ptr->remaining_exec_time = MAX_TIME_SLICE; - - DMNI_read_data(tcb_ptr->offset, code_lenght); - - tcb_ptr->scheduling_ptr->status = BLOCKED; - - send_task_allocated(tcb_ptr); - - if (current == &idle_tcb){ - need_scheduling = 1; - } - - break; - - case TASK_RELEASE: - - tcb_ptr = searchTCB(p->task_ID); - - app_ID = p->task_ID >> 8; - - //putsv("-> TASK RELEASE received to task ", p->task_ID); - - tcb_ptr->data_lenght = p->data_size; - - tcb_ptr->bss_lenght = p->bss_size; - - tcb_ptr->text_lenght = tcb_ptr->text_lenght - tcb_ptr->data_lenght; - - if (tcb_ptr->scheduling_ptr->status == BLOCKED) - tcb_ptr->scheduling_ptr->status = READY; - - DMNI_read_data( (unsigned int) app_tasks_location, p->app_task_number); - - if (get_task_location(tcb_ptr->id) == -1){ - for (int i = 0; i < p->app_task_number; i++){ - add_task_location(app_ID << 8 | i, app_tasks_location[i]); - } - } - - if (current == &idle_tcb){ - need_scheduling = 1; - } - - break; - - case UPDATE_TASK_LOCATION: - - if (is_another_task_running(p->task_ID >> 8) ){ - - remove_task_location(p->task_ID); - - add_task_location(p->task_ID, p->allocated_processor); - - } - - break; - - case INITIALIZE_SLAVE: - - cluster_master_address = p->source_PE; - - putsv("Slave initialized by cluster address: ", cluster_master_address); - - break; - -#if MIGRATION_ENABLED - case TASK_MIGRATION: - case MIGRATION_CODE: - case MIGRATION_TCB: - case MIGRATION_TASK_LOCATION: - case MIGRATION_MSG_REQUEST: - case MIGRATION_STACK: - case MIGRATION_DATA_BSS: - - need_scheduling = handle_migration(p, cluster_master_address); - - break; -#endif - - default: - putsv("ERROR: service unknown: ", MemoryRead(TICK_COUNTER)); - break; - } - - return need_scheduling; -} - -/** Generic task scheduler call - */ -void Scheduler() { - - Scheduling * scheduled; - unsigned int scheduler_call_time; - - scheduler_call_time = MemoryRead(TICK_COUNTER); - - MemoryWrite(SCHEDULING_REPORT, SCHEDULER); - - #if MIGRATION_ENABLED - if (current->proc_to_migrate != -1 && current->scheduling_ptr->status == RUNNING && current->scheduling_ptr->waiting_msg == 0) - migrate_dynamic_memory(current); - #endif - - scheduled = LST(scheduler_call_time); - - if (scheduled){ - - //This cast is an approach to reduce the scheduler call overhead - current = (TCB *) scheduled->tcb_ptr; - - MemoryWrite(SCHEDULING_REPORT, current->id); - - } else { - - current = &idle_tcb; // schedules the idle task - - last_idle_time = MemoryRead(TICK_COUNTER); - - MemoryWrite(SCHEDULING_REPORT, IDLE); - } - - MemoryWrite(TIME_SLICE, get_time_slice() ); - - OS_InterruptMaskSet(IRQ_SCHEDULER); - -} - -/** Function called by assembly (into interruption handler). Implements the routine to handle interruption in HeMPS - * This function must implement a important rule: it cannot send a packet when the DMNI is already send a packet. - * The interruption triggers according to the DMNI status, and the if-else statements inside this function ensure this - * behavior. - * \param status Status of the interruption. Signal the interruption type - */ -void OS_InterruptServiceRoutine(unsigned int status) { - - MemoryWrite(SCHEDULING_REPORT, INTERRUPTION); - - volatile ServiceHeader p; - ServiceHeader * next_service; - unsigned call_scheduler; - - - if (current == &idle_tcb){ - total_slack_time += MemoryRead(TICK_COUNTER) - last_idle_time; - } - - call_scheduler = 0; - - //***** Check if interruption comes from NoC - if ( status & IRQ_NOC ){ - - read_packet((ServiceHeader *)&p); - - if (MemoryRead(DMNI_SEND_ACTIVE) && (p.service == MESSAGE_REQUEST || p.service == TASK_MIGRATION) ){ - - add_pending_service((ServiceHeader *)&p); - - } else { - - call_scheduler = handle_packet(&p); - } - - //**** Handles remaining packets - } else if (status & IRQ_PENDING_SERVICE) { - - next_service = get_next_pending_service(); - if (next_service){ - call_scheduler = handle_packet(next_service); - } - //***** Send the monitoring packet - } else if (status & IRQ_SLACK_TIME){ - send_slack_time_report(); - total_slack_time = 0; - MemoryWrite(SLACK_TIME_MONITOR, 0); - } - - - if ( status & IRQ_SCHEDULER ){ - - call_scheduler = 1; - } - - - if (call_scheduler){ - - Scheduler(); - - } else if (current == &idle_tcb){ - - last_idle_time = MemoryRead(TICK_COUNTER); - - MemoryWrite(SCHEDULING_REPORT, IDLE); - - } else { - MemoryWrite(SCHEDULING_REPORT, current->id); - } - - /*runs the scheduled task*/ - ASM_RunScheduledTask(current); -} - -/** Clear a interruption mask - * \param Mask Interruption mask clear - */ -unsigned int OS_InterruptMaskClear(unsigned int Mask) { - - unsigned int mask; - - mask = MemoryRead(IRQ_MASK) & ~Mask; - MemoryWrite(IRQ_MASK, mask); - - return mask; -} - -/** Set a interruption mask - * \param Mask Interruption mask set - */ -unsigned int OS_InterruptMaskSet(unsigned int Mask) { - - unsigned int mask; - - mask = MemoryRead(IRQ_MASK) | Mask; - MemoryWrite(IRQ_MASK, mask); - - return mask; -} - -/** Idle function - */ -void OS_Idle() { - for (;;){ - MemoryWrite(CLOCK_HOLD, 1); - } -} - -int main(){ - - ASM_SetInterruptEnable(FALSE); - - idle_tcb.pc = (unsigned int) &OS_Idle; - idle_tcb.id = 0; - idle_tcb.offset = 0; - - total_slack_time = 0; - - last_idle_time = MemoryRead(TICK_COUNTER); - - current = &idle_tcb; - - net_address = MemoryRead(NI_CONFIG); - - puts("Initializing PE: "); puts(itoh(net_address)); puts("\n"); - - init_communication(); - - init_service_header_slots(); - - init_task_location(); - - init_TCBs(); - - /*disable interrupts*/ - OS_InterruptMaskClear(0xffffffff); - - /*enables timeslice counter and wrapper interrupts*/ - OS_InterruptMaskSet(IRQ_SCHEDULER | IRQ_NOC | IRQ_PENDING_SERVICE | IRQ_SLACK_TIME); - - /*runs the scheduled task*/ - ASM_RunScheduledTask(current); - - return 0; -} diff --git a/kernel_slave.h b/kernel_slave.h deleted file mode 100644 index 28cf1b9..0000000 --- a/kernel_slave.h +++ /dev/null @@ -1,44 +0,0 @@ -/*!\file kernel_slave.h - * HEMPS VERSION - 8.0 - support for RT applications - * - * Distribution: June 2016 - * - * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br - * - * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br - * - * \brief - * kernel_slave is the core of the OS running into the slave processors - * - * \detailed - * Its job is to runs the user's task. It communicates whit the kernel_master to receive new tasks - * and also notifying its finish. - * The kernel_slave file uses several modules that implement specific functions - */ - -#ifndef __KERNEL_SLAVE_H__ -#define __KERNEL_SLAVE_H__ - -#include "../../modules/task_control.h" - -/* - * ENABLE MODULES - */ -#define MIGRATION_ENABLED 1 //!< Enable or disable the migration module - - -extern unsigned int ASM_SetInterruptEnable(unsigned int); -extern void ASM_SaveRemainingContext(TCB*); -extern void ASM_RunScheduledTask(TCB*); -void OS_InterruptServiceRoutine(unsigned int); - -// ISR -unsigned int OS_InterruptMaskSet(unsigned int); -unsigned int OS_InterruptMaskClear(unsigned int); - -void OS_Init(); -void OS_Idle(); - -void Scheduler(); - -#endif diff --git a/services.h b/services.h deleted file mode 100644 index 5a2d0e5..0000000 --- a/services.h +++ /dev/null @@ -1,52 +0,0 @@ -/*!\file services.h - * HEMPS VERSION - 8.0 - support for RT applications - * - * Distribution: June 2016 - * - * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br - * - * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br - * - * \brief Kernel services definitions. This services are used to - * identifies a packet. - */ - -#ifndef __SERVICES_H__ -#define __SERVICES_H__ - -#define MESSAGE_REQUEST 0x00000010 -#define MESSAGE_DELIVERY 0x00000020 -#define TASK_ALLOCATION 0x00000040 -#define TASK_ALLOCATED 0x00000050 -#define TASK_REQUEST 0x00000060 -#define TASK_TERMINATED 0x00000070 -#define LOAN_PROCESSOR_RELEASE 0x00000090 -#define DEBUG_MESSAGE 0x00000100 -#define NEW_TASK 0x00000130 -#define APP_TERMINATED 0x00000140 -#define NEW_APP 0x00000150 -#define INITIALIZE_CLUSTER 0x00000160 -#define INITIALIZE_SLAVE 0x00000170 -#define TASK_TERMINATED_OTHER_CLUSTER 0x00000180 -#define LOAN_PROCESSOR_REQUEST 0x00000190 -#define LOAN_PROCESSOR_DELIVERY 0x00000200 -#define TASK_MIGRATION 0x00000210 -#define MIGRATION_CODE 0x00000220 -#define MIGRATION_TCB 0x00000221 -#define MIGRATION_TASK_LOCATION 0x00000222 -#define MIGRATION_MSG_REQUEST 0x00000223 -#define MIGRATION_STACK 0x00000224 -#define MIGRATION_DATA_BSS 0x00000225 -#define UPDATE_TASK_LOCATION 0x00000230 -#define TASK_MIGRATED 0x00000235 -#define APP_ALLOCATION_REQUEST 0x00000240 -#define TASK_RELEASE 0x00000250 -#define SLACK_TIME_REPORT 0x00000260 -#define DEADLINE_MISS_REPORT 0x00000270 -#define REAL_TIME_CHANGE 0x00000280 -#define BORDER_ROUTE 0x00000380 - - - - -#endif diff --git a/software/include/services.h b/software/include/services.h index bcc4059..0bfc8ce 100644 --- a/software/include/services.h +++ b/software/include/services.h @@ -1,49 +1,51 @@ -/*!\file services.h - * HEMPS VERSION - 8.0 - support for RT applications - * - * Distribution: June 2016 - * - * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br - * - * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br - * - * \brief Kernel services definitions. This services are used to - * identifies a packet. - */ - -#ifndef __SERVICES_H__ -#define __SERVICES_H__ - -#define MESSAGE_REQUEST 0x00000010 -#define MESSAGE_DELIVERY 0x00000020 -#define TASK_ALLOCATION 0x00000040 -#define TASK_ALLOCATED 0x00000050 -#define TASK_REQUEST 0x00000060 -#define TASK_TERMINATED 0x00000070 -#define LOAN_PROCESSOR_RELEASE 0x00000090 -#define DEBUG_MESSAGE 0x00000100 -#define NEW_TASK 0x00000130 -#define APP_TERMINATED 0x00000140 -#define NEW_APP 0x00000150 -#define INITIALIZE_CLUSTER 0x00000160 -#define INITIALIZE_SLAVE 0x00000170 -#define TASK_TERMINATED_OTHER_CLUSTER 0x00000180 -#define LOAN_PROCESSOR_REQUEST 0x00000190 -#define LOAN_PROCESSOR_DELIVERY 0x00000200 -#define TASK_MIGRATION 0x00000210 -#define MIGRATION_CODE 0x00000220 -#define MIGRATION_TCB 0x00000221 -#define MIGRATION_TASK_LOCATION 0x00000222 -#define MIGRATION_MSG_REQUEST 0x00000223 -#define MIGRATION_STACK 0x00000224 -#define MIGRATION_DATA_BSS 0x00000225 -#define UPDATE_TASK_LOCATION 0x00000230 -#define TASK_MIGRATED 0x00000235 -#define APP_ALLOCATION_REQUEST 0x00000240 -#define TASK_RELEASE 0x00000250 -#define SLACK_TIME_REPORT 0x00000260 -#define DEADLINE_MISS_REPORT 0x00000270 -#define REAL_TIME_CHANGE 0x00000280 -#define BORDER_ROUTE 0x00000310 - -#endif +/*!\file services.h + * HEMPS VERSION - 8.0 - support for RT applications + * + * Distribution: June 2016 + * + * Edited by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br + * + * Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br + * + * \brief Kernel services definitions. This services are used to + * identifies a packet. + */ + +#ifndef __SERVICES_H__ +#define __SERVICES_H__ + +#define MESSAGE_REQUEST 0x00000010 +#define MESSAGE_DELIVERY 0x00000020 +#define TASK_ALLOCATION 0x00000040 +#define TASK_ALLOCATED 0x00000050 +#define TASK_REQUEST 0x00000060 +#define TASK_TERMINATED 0x00000070 +#define LOAN_PROCESSOR_RELEASE 0x00000090 +#define DEBUG_MESSAGE 0x00000100 +#define NEW_TASK 0x00000130 +#define APP_TERMINATED 0x00000140 +#define NEW_APP 0x00000150 +#define INITIALIZE_CLUSTER 0x00000160 +#define INITIALIZE_SLAVE 0x00000170 +#define TASK_TERMINATED_OTHER_CLUSTER 0x00000180 +#define LOAN_PROCESSOR_REQUEST 0x00000190 +#define LOAN_PROCESSOR_DELIVERY 0x00000200 +#define TASK_MIGRATION 0x00000210 +#define MIGRATION_CODE 0x00000220 +#define MIGRATION_TCB 0x00000221 +#define MIGRATION_TASK_LOCATION 0x00000222 +#define MIGRATION_MSG_REQUEST 0x00000223 +#define MIGRATION_STACK 0x00000224 +#define MIGRATION_DATA_BSS 0x00000225 +#define UPDATE_TASK_LOCATION 0x00000230 +#define TASK_MIGRATED 0x00000235 +#define APP_ALLOCATION_REQUEST 0x00000240 +#define TASK_RELEASE 0x00000250 +#define SLACK_TIME_REPORT 0x00000260 +#define DEADLINE_MISS_REPORT 0x00000270 +#define REAL_TIME_CHANGE 0x00000280 +#define BORDER_ROUTE 0x00000310 +#define DMA_OPERATION 0x00000290 +#define START_CPU 0x00000300 + +#endif diff --git a/software/kernel/master/kernel_master.c b/software/kernel/master/kernel_master.c index 1b01060..e0f6d7f 100644 --- a/software/kernel/master/kernel_master.c +++ b/software/kernel/master/kernel_master.c @@ -742,6 +742,572 @@ void handle_app_request(){ } + +void send_dma_operation(int target){ +/* + int data_dma_operation[6]; + data_dma_operation[0]= 1; + data_dma_operation[1]= 2; + data_dma_operation[2]= 3; + data_dma_operation[3]= 4; + data_dma_operation[4]= 5; + data_dma_operation[5]= 6; +*/ + +if(target == 0x00000101) +{ + +//transmite +unsigned int data_dma_code[271]; +data_dma_code[0]= 0x241d7fff; +data_dma_code[1]= 0x0c0000d4; +data_dma_code[2]= 0x00000000; +data_dma_code[3]= 0x00002021; +data_dma_code[4]= 0x0000000c; +data_dma_code[5]= 0x00000000; +data_dma_code[6]= 0x08000006; +data_dma_code[7]= 0x00000000; +data_dma_code[8]= 0x0000000c; +data_dma_code[9]= 0x00000000; +data_dma_code[10]= 0x03e00008; +data_dma_code[11]= 0x00000000; +data_dma_code[12]= 0x8c820000; +data_dma_code[13]= 0x3c032000; +data_dma_code[14]= 0xac620000; +data_dma_code[15]= 0x00802821; +data_dma_code[16]= 0x80840000; +data_dma_code[17]= 0x00000000; +data_dma_code[18]= 0x10800022; +data_dma_code[19]= 0x00000000; +data_dma_code[20]= 0x80a20001; +data_dma_code[21]= 0x00000000; +data_dma_code[22]= 0x1040001e; +data_dma_code[23]= 0x00000000; +data_dma_code[24]= 0x80a20002; +data_dma_code[25]= 0x00000000; +data_dma_code[26]= 0x1040001a; +data_dma_code[27]= 0x00000000; +data_dma_code[28]= 0x80a20003; +data_dma_code[29]= 0x00000000; +data_dma_code[30]= 0x10400016; +data_dma_code[31]= 0x3c042000; +data_dma_code[32]= 0x0800002e; +data_dma_code[33]= 0x24a50004; +data_dma_code[34]= 0x80a20001; +data_dma_code[35]= 0x00000000; +data_dma_code[36]= 0x10400010; +data_dma_code[37]= 0x00000000; +data_dma_code[38]= 0x80a20002; +data_dma_code[39]= 0x00000000; +data_dma_code[40]= 0x1040000c; +data_dma_code[41]= 0x00000000; +data_dma_code[42]= 0x80a20003; +data_dma_code[43]= 0x00000000; +data_dma_code[44]= 0x10400008; +data_dma_code[45]= 0x24a50004; +data_dma_code[46]= 0x8ca20000; +data_dma_code[47]= 0x00000000; +data_dma_code[48]= 0xac820000; +data_dma_code[49]= 0x80a30000; +data_dma_code[50]= 0x00000000; +data_dma_code[51]= 0x1460ffee; +data_dma_code[52]= 0x00000000; +data_dma_code[53]= 0x03e00008; +data_dma_code[54]= 0x00001021; +data_dma_code[55]= 0x14800009; +data_dma_code[56]= 0x00802821; +data_dma_code[57]= 0x3c020000; +data_dma_code[58]= 0x24440454; +data_dma_code[59]= 0x00802821; +data_dma_code[60]= 0x24030030; +data_dma_code[61]= 0xa0430454; +data_dma_code[62]= 0x00a01021; +data_dma_code[63]= 0x03e00008; +data_dma_code[64]= 0xa0800001; +data_dma_code[65]= 0x3c03cccc; +data_dma_code[66]= 0x3463cccd; +data_dma_code[67]= 0x00830019; +data_dma_code[68]= 0x3c020000; +data_dma_code[69]= 0x24460455; +data_dma_code[70]= 0x3c080000; +data_dma_code[71]= 0x24070001; +data_dma_code[72]= 0x00001810; +data_dma_code[73]= 0x000318c2; +data_dma_code[74]= 0x00031040; +data_dma_code[75]= 0x000320c0; +data_dma_code[76]= 0x00441021; +data_dma_code[77]= 0x00a21023; +data_dma_code[78]= 0x24420030; +data_dma_code[79]= 0x00602821; +data_dma_code[80]= 0x10a00013; +data_dma_code[81]= 0xa1020454; +data_dma_code[82]= 0x3c03cccc; +data_dma_code[83]= 0x3463cccd; +data_dma_code[84]= 0x00a30019; +data_dma_code[85]= 0x24e70001; +data_dma_code[86]= 0x00001810; +data_dma_code[87]= 0x000320c2; +data_dma_code[88]= 0x00041040; +data_dma_code[89]= 0x000418c0; +data_dma_code[90]= 0x00431021; +data_dma_code[91]= 0x00a21023; +data_dma_code[92]= 0x24420030; +data_dma_code[93]= 0xa0c20000; +data_dma_code[94]= 0x2402000b; +data_dma_code[95]= 0x10e2000d; +data_dma_code[96]= 0x24c60001; +data_dma_code[97]= 0x00802821; +data_dma_code[98]= 0x14a0fff0; +data_dma_code[99]= 0x3c03cccc; +data_dma_code[100]= 0x3c040000; +data_dma_code[101]= 0x24820448; +data_dma_code[102]= 0x00e21021; +data_dma_code[103]= 0x24e3ffff; +data_dma_code[104]= 0x04610008; +data_dma_code[105]= 0xa0400000; +data_dma_code[106]= 0x24850448; +data_dma_code[107]= 0x03e00008; +data_dma_code[108]= 0x00a01021; +data_dma_code[109]= 0x3c040000; +data_dma_code[110]= 0x24820448; +data_dma_code[111]= 0x2403000a; +data_dma_code[112]= 0xa040000b; +data_dma_code[113]= 0x24820448; +data_dma_code[114]= 0x00621821; +data_dma_code[115]= 0x3c020000; +data_dma_code[116]= 0x25050454; +data_dma_code[117]= 0x24460447; +data_dma_code[118]= 0x90a20000; +data_dma_code[119]= 0x00000000; +data_dma_code[120]= 0xa0620000; +data_dma_code[121]= 0x2463ffff; +data_dma_code[122]= 0x1466fffb; +data_dma_code[123]= 0x24a50001; +data_dma_code[124]= 0x0800006b; +data_dma_code[125]= 0x24850448; +data_dma_code[126]= 0x3c080000; +data_dma_code[127]= 0x2503043c; +data_dma_code[128]= 0x24050030; +data_dma_code[129]= 0x24020078; +data_dma_code[130]= 0xa0620001; +data_dma_code[131]= 0xa060000a; +data_dma_code[132]= 0x1480000b; +data_dma_code[133]= 0xa105043c; +data_dma_code[134]= 0xa0650009; +data_dma_code[135]= 0xa0650002; +data_dma_code[136]= 0xa0650003; +data_dma_code[137]= 0xa0650004; +data_dma_code[138]= 0xa0650005; +data_dma_code[139]= 0xa0650006; +data_dma_code[140]= 0xa0650007; +data_dma_code[141]= 0xa0650008; +data_dma_code[142]= 0x03e00008; +data_dma_code[143]= 0x2502043c; +data_dma_code[144]= 0x3c020000; +data_dma_code[145]= 0x3c030000; +data_dma_code[146]= 0x24470445; +data_dma_code[147]= 0x08000099; +data_dma_code[148]= 0x2463043d; +data_dma_code[149]= 0xa0e60000; +data_dma_code[150]= 0x24e7ffff; +data_dma_code[151]= 0x10e3fff6; +data_dma_code[152]= 0x00042102; +data_dma_code[153]= 0x3082000f; +data_dma_code[154]= 0x24460030; +data_dma_code[155]= 0x24450057; +data_dma_code[156]= 0x2c42000a; +data_dma_code[157]= 0x1440fff7; +data_dma_code[158]= 0x00000000; +data_dma_code[159]= 0x08000096; +data_dma_code[160]= 0xa0e50000; +data_dma_code[161]= 0x27bdffc8; +data_dma_code[162]= 0xafb1002c; +data_dma_code[163]= 0x00e08821; +data_dma_code[164]= 0x26220004; +data_dma_code[165]= 0xafa20014; +data_dma_code[166]= 0x3c022000; +data_dma_code[167]= 0xafb20030; +data_dma_code[168]= 0xafb00028; +data_dma_code[169]= 0xafa40010; +data_dma_code[170]= 0xafbf0034; +data_dma_code[171]= 0xafa50018; +data_dma_code[172]= 0x34420140; +data_dma_code[173]= 0x8c430000; +data_dma_code[174]= 0x00803821; +data_dma_code[175]= 0x3c040000; +data_dma_code[176]= 0x24840420; +data_dma_code[177]= 0x3c102000; +data_dma_code[178]= 0xafa3001c; +data_dma_code[179]= 0xafa70020; +data_dma_code[180]= 0x00c09021; +data_dma_code[181]= 0x0c00000c; +data_dma_code[182]= 0xafb10024; +data_dma_code[183]= 0x36030250; +data_dma_code[184]= 0x8c620000; +data_dma_code[185]= 0x00000000; +data_dma_code[186]= 0x1440fffd; +data_dma_code[187]= 0x24020006; +data_dma_code[188]= 0x36030200; +data_dma_code[189]= 0x3c040000; +data_dma_code[190]= 0xac620000; +data_dma_code[191]= 0x0c00000c; +data_dma_code[192]= 0x24840424; +data_dma_code[193]= 0x36030210; +data_dma_code[194]= 0x27a20010; +data_dma_code[195]= 0xac620000; +data_dma_code[196]= 0x1a200004; +data_dma_code[197]= 0x36020205; +data_dma_code[198]= 0x36030215; +data_dma_code[199]= 0xac510000; +data_dma_code[200]= 0xac720000; +data_dma_code[201]= 0x36020230; +data_dma_code[202]= 0x36030220; +data_dma_code[203]= 0x24040001; +data_dma_code[204]= 0xac600000; +data_dma_code[205]= 0xac440000; +data_dma_code[206]= 0x8fbf0034; +data_dma_code[207]= 0x8fb20030; +data_dma_code[208]= 0x8fb1002c; +data_dma_code[209]= 0x8fb00028; +data_dma_code[210]= 0x03e00008; +data_dma_code[211]= 0x27bd0038; +data_dma_code[212]= 0x3c040000; +data_dma_code[213]= 0x27bdffc8; +data_dma_code[214]= 0x24840428; +data_dma_code[215]= 0xafbf0030; +data_dma_code[216]= 0xafb3002c; +data_dma_code[217]= 0xafb20028; +data_dma_code[218]= 0xafb10024; +data_dma_code[219]= 0x0c00000c; +data_dma_code[220]= 0xafb00020; +data_dma_code[221]= 0x24030014; +data_dma_code[222]= 0x2402000e; +data_dma_code[223]= 0x24040001; +data_dma_code[224]= 0x24050020; +data_dma_code[225]= 0x27a60014; +data_dma_code[226]= 0x24070002; +data_dma_code[227]= 0xafa30018; +data_dma_code[228]= 0x0c0000a1; +data_dma_code[229]= 0xafa20014; +data_dma_code[230]= 0x3c040000; +data_dma_code[231]= 0x0c00000c; +data_dma_code[232]= 0x2484042c; +data_dma_code[233]= 0x3c022000; +data_dma_code[234]= 0xafa00010; +data_dma_code[235]= 0x34510008; +data_dma_code[236]= 0x27b00010; +data_dma_code[237]= 0x00001821; +data_dma_code[238]= 0x3c120000; +data_dma_code[239]= 0x3c130000; +data_dma_code[240]= 0xae230000; +data_dma_code[241]= 0x26440430; +data_dma_code[242]= 0xae230000; +data_dma_code[243]= 0x0c00000c; +data_dma_code[244]= 0x00000000; +data_dma_code[245]= 0x8fa40010; +data_dma_code[246]= 0x0c000037; +data_dma_code[247]= 0x00000000; +data_dma_code[248]= 0x0c00000c; +data_dma_code[249]= 0x00402021; +data_dma_code[250]= 0x0c000037; +data_dma_code[251]= 0x02002021; +data_dma_code[252]= 0x0c00000c; +data_dma_code[253]= 0x00402021; +data_dma_code[254]= 0x0c00000c; +data_dma_code[255]= 0x26640438; +data_dma_code[256]= 0x8fa30010; +data_dma_code[257]= 0x00000000; +data_dma_code[258]= 0x24630001; +data_dma_code[259]= 0x2c620064; +data_dma_code[260]= 0x1440ffeb; +data_dma_code[261]= 0xafa30010; +data_dma_code[262]= 0x08000106; +data_dma_code[263]= 0x00000000; +data_dma_code[264]= 0x74726d00; +data_dma_code[265]= 0x61706f00; +data_dma_code[266]= 0x24242400; +data_dma_code[267]= 0x61612400; +data_dma_code[268]= 0x24242420; +data_dma_code[269]= 0x00000000; +data_dma_code[270]= 0x0a000000; + + + ServiceHeader *p = get_service_header_slot(); + p->header = 0x00000101; + + p->service = DMA_OPERATION; + send_packet(p, data_dma_code, 271); //send_packet(ServiceHeader *p, Endereco inicial do payload, tamanho do payload) + //Se fosse inteiro era &nome da variavel e tamanho 1 +} +else +//receive +{ + +unsigned int data_dma_code[219]; +data_dma_code[0]= 0x241d7fff; +data_dma_code[1]= 0x0c0000b4; +data_dma_code[2]= 0x00000000; +data_dma_code[3]= 0x00002021; +data_dma_code[4]= 0x0000000c; +data_dma_code[5]= 0x00000000; +data_dma_code[6]= 0x08000006; +data_dma_code[7]= 0x00000000; +data_dma_code[8]= 0x0000000c; +data_dma_code[9]= 0x00000000; +data_dma_code[10]= 0x03e00008; +data_dma_code[11]= 0x00000000; +data_dma_code[12]= 0x8c820000; +data_dma_code[13]= 0x3c032000; +data_dma_code[14]= 0xac620000; +data_dma_code[15]= 0x00802821; +data_dma_code[16]= 0x80840000; +data_dma_code[17]= 0x00000000; +data_dma_code[18]= 0x10800022; +data_dma_code[19]= 0x00000000; +data_dma_code[20]= 0x80a20001; +data_dma_code[21]= 0x00000000; +data_dma_code[22]= 0x1040001e; +data_dma_code[23]= 0x00000000; +data_dma_code[24]= 0x80a20002; +data_dma_code[25]= 0x00000000; +data_dma_code[26]= 0x1040001a; +data_dma_code[27]= 0x00000000; +data_dma_code[28]= 0x80a20003; +data_dma_code[29]= 0x00000000; +data_dma_code[30]= 0x10400016; +data_dma_code[31]= 0x3c042000; +data_dma_code[32]= 0x0800002e; +data_dma_code[33]= 0x24a50004; +data_dma_code[34]= 0x80a20001; +data_dma_code[35]= 0x00000000; +data_dma_code[36]= 0x10400010; +data_dma_code[37]= 0x00000000; +data_dma_code[38]= 0x80a20002; +data_dma_code[39]= 0x00000000; +data_dma_code[40]= 0x1040000c; +data_dma_code[41]= 0x00000000; +data_dma_code[42]= 0x80a20003; +data_dma_code[43]= 0x00000000; +data_dma_code[44]= 0x10400008; +data_dma_code[45]= 0x24a50004; +data_dma_code[46]= 0x8ca20000; +data_dma_code[47]= 0x00000000; +data_dma_code[48]= 0xac820000; +data_dma_code[49]= 0x80a30000; +data_dma_code[50]= 0x00000000; +data_dma_code[51]= 0x1460ffee; +data_dma_code[52]= 0x00000000; +data_dma_code[53]= 0x03e00008; +data_dma_code[54]= 0x00001021; +data_dma_code[55]= 0x14800009; +data_dma_code[56]= 0x00802821; +data_dma_code[57]= 0x3c020000; +data_dma_code[58]= 0x24440384; +data_dma_code[59]= 0x00802821; +data_dma_code[60]= 0x24030030; +data_dma_code[61]= 0xa0430384; +data_dma_code[62]= 0x00a01021; +data_dma_code[63]= 0x03e00008; +data_dma_code[64]= 0xa0800001; +data_dma_code[65]= 0x3c03cccc; +data_dma_code[66]= 0x3463cccd; +data_dma_code[67]= 0x00830019; +data_dma_code[68]= 0x3c020000; +data_dma_code[69]= 0x24460385; +data_dma_code[70]= 0x3c080000; +data_dma_code[71]= 0x24070001; +data_dma_code[72]= 0x00001810; +data_dma_code[73]= 0x000318c2; +data_dma_code[74]= 0x00031040; +data_dma_code[75]= 0x000320c0; +data_dma_code[76]= 0x00441021; +data_dma_code[77]= 0x00a21023; +data_dma_code[78]= 0x24420030; +data_dma_code[79]= 0x00602821; +data_dma_code[80]= 0x10a00013; +data_dma_code[81]= 0xa1020384; +data_dma_code[82]= 0x3c03cccc; +data_dma_code[83]= 0x3463cccd; +data_dma_code[84]= 0x00a30019; +data_dma_code[85]= 0x24e70001; +data_dma_code[86]= 0x00001810; +data_dma_code[87]= 0x000320c2; +data_dma_code[88]= 0x00041040; +data_dma_code[89]= 0x000418c0; +data_dma_code[90]= 0x00431021; +data_dma_code[91]= 0x00a21023; +data_dma_code[92]= 0x24420030; +data_dma_code[93]= 0xa0c20000; +data_dma_code[94]= 0x2402000b; +data_dma_code[95]= 0x10e2000d; +data_dma_code[96]= 0x24c60001; +data_dma_code[97]= 0x00802821; +data_dma_code[98]= 0x14a0fff0; +data_dma_code[99]= 0x3c03cccc; +data_dma_code[100]= 0x3c040000; +data_dma_code[101]= 0x24820378; +data_dma_code[102]= 0x00e21021; +data_dma_code[103]= 0x24e3ffff; +data_dma_code[104]= 0x04610008; +data_dma_code[105]= 0xa0400000; +data_dma_code[106]= 0x24850378; +data_dma_code[107]= 0x03e00008; +data_dma_code[108]= 0x00a01021; +data_dma_code[109]= 0x3c040000; +data_dma_code[110]= 0x24820378; +data_dma_code[111]= 0x2403000a; +data_dma_code[112]= 0xa040000b; +data_dma_code[113]= 0x24820378; +data_dma_code[114]= 0x00621821; +data_dma_code[115]= 0x3c020000; +data_dma_code[116]= 0x25050384; +data_dma_code[117]= 0x24460377; +data_dma_code[118]= 0x90a20000; +data_dma_code[119]= 0x00000000; +data_dma_code[120]= 0xa0620000; +data_dma_code[121]= 0x2463ffff; +data_dma_code[122]= 0x1466fffb; +data_dma_code[123]= 0x24a50001; +data_dma_code[124]= 0x0800006b; +data_dma_code[125]= 0x24850378; +data_dma_code[126]= 0x3c080000; +data_dma_code[127]= 0x2503036c; +data_dma_code[128]= 0x24050030; +data_dma_code[129]= 0x24020078; +data_dma_code[130]= 0xa0620001; +data_dma_code[131]= 0xa060000a; +data_dma_code[132]= 0x1480000b; +data_dma_code[133]= 0xa105036c; +data_dma_code[134]= 0xa0650009; +data_dma_code[135]= 0xa0650002; +data_dma_code[136]= 0xa0650003; +data_dma_code[137]= 0xa0650004; +data_dma_code[138]= 0xa0650005; +data_dma_code[139]= 0xa0650006; +data_dma_code[140]= 0xa0650007; +data_dma_code[141]= 0xa0650008; +data_dma_code[142]= 0x03e00008; +data_dma_code[143]= 0x2502036c; +data_dma_code[144]= 0x3c020000; +data_dma_code[145]= 0x3c030000; +data_dma_code[146]= 0x24470375; +data_dma_code[147]= 0x08000099; +data_dma_code[148]= 0x2463036d; +data_dma_code[149]= 0xa0e60000; +data_dma_code[150]= 0x24e7ffff; +data_dma_code[151]= 0x10e3fff6; +data_dma_code[152]= 0x00042102; +data_dma_code[153]= 0x3082000f; +data_dma_code[154]= 0x24460030; +data_dma_code[155]= 0x24450057; +data_dma_code[156]= 0x2c42000a; +data_dma_code[157]= 0x1440fff7; +data_dma_code[158]= 0x00000000; +data_dma_code[159]= 0x08000096; +data_dma_code[160]= 0xa0e50000; +data_dma_code[161]= 0x3c032000; +data_dma_code[162]= 0x24090001; +data_dma_code[163]= 0x34650200; +data_dma_code[164]= 0x34660220; +data_dma_code[165]= 0x34670210; +data_dma_code[166]= 0x34680230; +data_dma_code[167]= 0x24020006; +data_dma_code[168]= 0xaca20000; +data_dma_code[169]= 0xafa40000; +data_dma_code[170]= 0xacc90000; +data_dma_code[171]= 0x34630260; +data_dma_code[172]= 0xacfd0000; +data_dma_code[173]= 0xad090000; +data_dma_code[174]= 0x8c620000; +data_dma_code[175]= 0x00000000; +data_dma_code[176]= 0x1440fffd; +data_dma_code[177]= 0x00000000; +data_dma_code[178]= 0x03e00008; +data_dma_code[179]= 0x00000000; +data_dma_code[180]= 0x27bdffc8; +data_dma_code[181]= 0xafb1002c; +data_dma_code[182]= 0x3c110000; +data_dma_code[183]= 0x26240368; +data_dma_code[184]= 0xafb00028; +data_dma_code[185]= 0xafbf0030; +data_dma_code[186]= 0x0c00000c; +data_dma_code[187]= 0x27b00010; +data_dma_code[188]= 0x3c022000; +data_dma_code[189]= 0x34420020; +data_dma_code[190]= 0x8c430000; +data_dma_code[191]= 0x00000000; +data_dma_code[192]= 0x30630020; +data_dma_code[193]= 0x1060fffa; +data_dma_code[194]= 0x02002021; +data_dma_code[195]= 0x0c0000a1; +data_dma_code[196]= 0x00000000; +data_dma_code[197]= 0x0c00000c; +data_dma_code[198]= 0x26240368; +data_dma_code[199]= 0x8fa40010; +data_dma_code[200]= 0x0c000037; +data_dma_code[201]= 0x00000000; +data_dma_code[202]= 0x0c00000c; +data_dma_code[203]= 0x00402021; +data_dma_code[204]= 0x8fa40018; +data_dma_code[205]= 0x0c00007e; +data_dma_code[206]= 0x00000000; +data_dma_code[207]= 0x0c00000c; +data_dma_code[208]= 0x00402021; +data_dma_code[209]= 0x3c022000; +data_dma_code[210]= 0x34420020; +data_dma_code[211]= 0x8c430000; +data_dma_code[212]= 0x00000000; +data_dma_code[213]= 0x30630020; +data_dma_code[214]= 0x1060ffe5; +data_dma_code[215]= 0x02002021; +data_dma_code[216]= 0x080000c3; +data_dma_code[217]= 0x00000000; +data_dma_code[218]= 0x61000000; + + + ServiceHeader *p = get_service_header_slot(); + p->header = 0x00000001; + + p->service = DMA_OPERATION; + //p->master_ID = cluster_master_address; + + send_packet(p, data_dma_code, 219); //send_packet(ServiceHeader *p, Endereco inicial do payload, tamanho do payload) + //Se fosse inteiro era &nome da variavel e tamanho 1 +} + + +} + + +void send_start_cpu(unsigned teste){ + +/* int data_start_cpu[6]; + data_start_cpu[0]= 10; + data_start_cpu[1]= 11; + data_start_cpu[2]= 12; + data_start_cpu[3]= 13; + data_start_cpu[4]= 14; + data_start_cpu[5]= 15; +*/ + ServiceHeader *p = get_service_header_slot(); + + p->header = teste; + + p->service = START_CPU; + + p->period = 0x010; + + + + //p->master_ID = cluster_master_address; + + send_packet(p, 0, 0); //send_packet(ServiceHeader *p, unsigned int initial_address, unsigned int dmni_msg_size) + +} + + + + int main() { NewTask * pending_new_task; @@ -774,6 +1340,22 @@ int main() { init_service_header_slots(); + + send_dma_operation(0x00000101);//envio um pacote com servico de acesso direto a DMNI + + send_dma_operation(0x00000001);//envio um pacote com servico de acesso direto a DMNI + + send_start_cpu(0x00000001); + + send_start_cpu(0x00000101); + + + + + + + + puts("Kernel Initialized\n"); diff --git a/testcases/test.txt b/testcases/test.txt new file mode 100644 index 0000000..3039ab8 --- /dev/null +++ b/testcases/test.txt @@ -0,0 +1,72 @@ +make: Entering directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2' + + + _ _ __ __ ____ ____ ___ _____ + | | | | ___| \// | _ \// ___| ( _ ) |___ // + | |_| |// _ \ |\//| | |_) \___ \ // _ \ |_ \ + | _ | __// | | | __// ___) | | (_) | ___) | + |_| |_|\___|_| |_|_| |____// \___(_)____// + + +OBS: + 1. Renaming local_scheduler -> task_scheduler + 1.a - Improvements on LST task scheduler to a better deadline miss monitoring + 2. Renaming cluster_scheduler -> resource_manager + + +make[1]: Entering directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/applications' +make[2]: Entering directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/applications/pc1' +make[2]: Nothing to be done for 'default'. +make[2]: Leaving directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/applications/pc1' +make[2]: Entering directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/applications/pc2' +make[2]: Nothing to be done for 'default'. +make[2]: Leaving directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/applications/pc2' +make[1]: Leaving directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/applications' + +***************** task page size report *********************** +Memory size (32KB) OK for file with size (3.0KB) +Memory size (32KB) OK for file with size (3.0KB) +Memory size (32KB) OK for file with size (3.0KB) +Memory size (32KB) OK for file with size (3.0KB) +***************** end task page size report ********************* + + +***************** repository size report *********************** +Repository size (7.0KB) OK for size informed within yaml file (1024KB) +***************** end repository size report *********************** + +make[1]: Entering directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/software' +Compiling Kernel modules/utils.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/utils.o modules/utils.c +Compiling Kernel modules/packet.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/packet.o modules/packet.c +Compiling Kernel modules/applications.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/applications.o modules/applications.c +Compiling Kernel modules/pending_service.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/pending_service.o modules/pending_service.c +Compiling Kernel modules/reclustering.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/reclustering.o modules/reclustering.c +Compiling Kernel modules/new_task.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/new_task.o modules/new_task.c +Compiling Kernel modules/communication.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/communication.o modules/communication.c +Compiling Kernel modules/processors.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/processors.o modules/processors.c +Compiling Kernel modules/task_control.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/task_control.o modules/task_control.c +Compiling Kernel modules/task_location.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/task_location.o modules/task_location.c +Compiling Kernel modules/task_migration.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/task_migration.o modules/task_migration.c +Compiling Kernel modules/task_scheduler.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/task_scheduler.o modules/task_scheduler.c +Compiling Kernel modules/resource_manager.c ... +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -o modules/resource_manager.o modules/resource_manager.c +Compiling Kernel Master: kernel_master.c ... +mips-elf-as --defsym sp_addr=65535 -o boot_master.o kernel/master/boot.S +mips-elf-gcc -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -DHOP_NUMBER=1 -Dload -o kernel_master.o kernel/master/kernel_master.c -D IS_MASTER +mips-elf-ld -Ttext 0 -eentry -Map kernel_master.map -s -N -o kernel_master.bin boot_master.o kernel_master.o modules/utils.o modules/packet.o modules/applications.o modules/reclustering.o modules/new_task.o modules/communication.o modules/processors.o modules/resource_manager.o ../include/kernel_pkg.o +makefile:51: recipe for target 'kernel_master.txt' failed +make[1]: Leaving directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2/software' +makefile:18: recipe for target 'kernel' failed +make: Leaving directory '/home/anderson/Documents/hemps/hemps8.5/testcases/teste_2x2_vhdl_ativ2' diff --git a/testcases/teste.yaml b/testcases/teste.yaml new file mode 100644 index 0000000..48bee38 --- /dev/null +++ b/testcases/teste.yaml @@ -0,0 +1,16 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: sc # sc (gcc) | scmod (questa) | vhdl + noc_buffer_size: 8 # must be power of 2 + mpsoc_dimension: [4,4] # for while, must be a square shape + cluster_dimension: [2,2] # for while, must be a square shape + master_location: LB # LB + + +apps: + - name: pc1 + start_time_ms: 0 #any unsigned integer number + - name: pc2 + start_time_ms: 1ms #any unsigned integer number diff --git a/testcases/teste_2x2_vhdl.yaml b/testcases/teste_2x2_vhdl.yaml new file mode 100644 index 0000000..2266430 --- /dev/null +++ b/testcases/teste_2x2_vhdl.yaml @@ -0,0 +1,16 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: vhdl # sc (gcc) | scmod (questa) | vhdl + noc_buffer_size: 8 # must be power of 2 + mpsoc_dimension: [2,2] # for while, must be a square shape + cluster_dimension: [2,2] # for while, must be a square shape + master_location: LB # LB + + +apps: + - name: pc1 + start_time_ms: 0 #any unsigned integer number + - name: pc2 + start_time_ms: 1ms #any unsigned integer number diff --git a/testcases/teste_2x2_vhdl_ativ2.yaml b/testcases/teste_2x2_vhdl_ativ2.yaml new file mode 100644 index 0000000..87eb331 --- /dev/null +++ b/testcases/teste_2x2_vhdl_ativ2.yaml @@ -0,0 +1,15 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: vhdl # sc (gcc) | scmod (questa) | vhdl + noc_buffer_size: 8 # must be power of 2 + mpsoc_dimension: [2,2] # for while, must be a square shape + cluster_dimension: [2,2] # for while, must be a square shape + master_location: LB # LB + + +apps: + - name: pc1 + start_time_ms: 0 #any unsigned integer number + diff --git a/testcases/teste_2x2_vhdl_ativ4.yaml b/testcases/teste_2x2_vhdl_ativ4.yaml new file mode 100644 index 0000000..25e569e --- /dev/null +++ b/testcases/teste_2x2_vhdl_ativ4.yaml @@ -0,0 +1,15 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: vhdl # sc (gcc) | scmod (questa) | vhdl + noc_buffer_size: 8 # must be power of 2 + mpsoc_dimension: [2,2] # for while, must be a square shape + cluster_dimension: [2,2] # for while, must be a square shape + master_location: LB # LB + +apps: + - name: transmit + start_time_ms: 0 #any unsigned integer number + + diff --git a/testcases/teste_vhdl.yaml b/testcases/teste_vhdl.yaml new file mode 100644 index 0000000..dd9ef33 --- /dev/null +++ b/testcases/teste_vhdl.yaml @@ -0,0 +1,16 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: vhdl # sc (gcc) | scmod (questa) | vhdl + noc_buffer_size: 8 # must be power of 2 + mpsoc_dimension: [4,4] # for while, must be a square shape + cluster_dimension: [2,2] # for while, must be a square shape + master_location: LB # LB + + +apps: + - name: pc1 + start_time_ms: 0 #any unsigned integer number + - name: pc2 + start_time_ms: 1ms #any unsigned integer number From e8d33b3b0595787aa9b13864ddc3bed27a5faf90 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Tue, 17 Oct 2017 17:29:00 -0200 Subject: [PATCH 16/54] Restored DMNI legacy reception behaviour --- hardware/vhdl/pe/dmni/dmni.vhd | 825 +++++++++++++++++---------------- 1 file changed, 416 insertions(+), 409 deletions(-) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index f1c53b5..5beb6c4 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -1,409 +1,416 @@ ------------------------------------------------------------------------------------------------- --- --- DISTRIBUTED HEMPS - version 7.0 --- --- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br --- --- Distribution: May 2015 --- --- Source name: dmni.vhd --- --- Brief description: Implements a DMNI module. --- --- OPERATIONS: --- 0 - Copy from memory --- 1 - Copy to memory ---------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.std_logic_unsigned.all; -use ieee.std_logic_arith.all; -use work.hemps_pkg.all; -use work.standards.all; - -entity dmni is - generic(address_router: regmetadeflit := (others=>'0')); - port - ( - clock : in std_logic; - reset : in std_logic; - -- Configuration interface - set_address : in std_logic; - set_address_2 : in std_logic; - set_size : in std_logic; - set_size_2 : in std_logic; - set_op : in std_logic; - start : in std_logic; - config_data : in std_logic_vector(31 downto 0); - -- Status outputs - intr : out std_logic; - send_active : out std_logic; - receive_active : out std_logic; - reset_dmni : out std_logic; - -- Memory interface - mem_address : out std_logic_vector(31 downto 0); - mem_data_write : out std_logic_vector(31 downto 0); - mem_data_read : in std_logic_vector(31 downto 0); - mem_byte_we : out std_logic_vector(3 downto 0); - -- Noc Interface (Local port) - tx : out std_logic; - data_out : out regflit; - credit_i : in std_logic; - clock_tx : out std_logic; - rx : in std_logic; - data_in : in regflit; - credit_o : out std_logic; - clock_rx : in std_logic - ); -end; - -architecture dmni of dmni is - - constant DMNI_TIMER: std_logic_vector(4 downto 0):="10000"; - constant WORD_SIZE: std_logic_vector(4 downto 0):="00100"; - - type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, FINISH); - signal DMNI_Send: dmni_state; - signal DMNI_Receive: dmni_state; - - type noc_state is (HEADER, PAYLOAD, DATA); - signal SR: noc_state; - - type arbiter_state is (ROUND, SEND, RECEIVE); - signal ARB: arbiter_state; - - signal bufferr: buff_dmni := (others=>(others=>'0')); - subtype buffsizebool is std_logic_vector(0 to (TAM_BUFFER_DMNI-1)); - signal is_header: buffsizebool := (others=> '0'); - signal intr_count : std_logic_vector(3 downto 0); - - signal first,last: pointer := (others=>'0'); - signal add_buffer : std_logic; - - signal payload_size : regflit; - - signal timer : std_logic_vector(4 downto 0); - signal address : std_logic_vector(31 downto 0); - signal address_2 : std_logic_vector(31 downto 0); - signal size : std_logic_vector(31 downto 0); - signal size_2 : std_logic_vector(31 downto 0); - signal send_address : std_logic_vector(31 downto 0); - signal send_address_2 : std_logic_vector(31 downto 0); - signal send_size : std_logic_vector(31 downto 0); - signal send_size_2 : std_logic_vector(31 downto 0); - signal recv_address : std_logic_vector(31 downto 0); - signal recv_size : std_logic_vector(31 downto 0); - signal prio : std_logic; - signal operation : std_logic; - signal read_av : std_logic; - signal slot_available : std_logic; - signal read_enable : std_logic; - signal write_enable : std_logic; - - signal send_active_2 : std_logic; - signal receive_active_2 : std_logic; - signal intr_counter_temp : std_logic_vector(3 downto 0); - - signal reset_dmni_s : std_logic; - signal payload_fix : regflit; - signal sizedata_fix : regflit; - signal novo_pacote : std_logic; - signal is_dmma : std_logic; -begin - --config - proc_config: process(clock) - begin - if(clock'event and clock = '1') then - if (set_address = '1') then - address <= config_data; - address_2 <= (others => '0'); - elsif (set_address_2 = '1') then - address_2 <= config_data; - elsif (set_size = '1') then - size <= config_data; - size_2 <= (others => '0'); - elsif (set_size_2 = '1') then - size_2 <= config_data; - elsif (set_op = '1') then - operation <= config_data(0); - end if; - end if; - end process proc_config; - - mem_address <= send_address when write_enable = '1' else recv_address; - credit_o <= slot_available; - slot_available <= '0' when (first = last and add_buffer = '1') else '1'; - read_av <= '0' when (first = last and add_buffer = '0') else '1'; - clock_tx <= clock; - send_active <= send_active_2; - receive_active <= receive_active_2; - - arbiter: process (clock,reset) - begin - if reset = '1' then - read_enable <= '0'; - write_enable <= '0'; - timer <= "00000"; - prio <= '0'; - ARB <= ROUND; - elsif (clock'event and clock = '1') then - case ARB is - when ROUND => - if prio = '0' then - if (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then - ARB <= RECEIVE; - read_enable <= '1'; - elsif send_active_2 = '1' then - ARB <= SEND; - write_enable <= '1'; - end if; - else - if send_active_2 = '1' then - ARB <= SEND; - write_enable <= '1'; - elsif (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then - ARB <= RECEIVE; - read_enable <= '1'; - end if; - end if; - - when SEND => - if DMNI_Send = FINISH or (timer = DMNI_TIMER and receive_active_2 = '1') then - timer <= "00000"; - ARB <= ROUND; - write_enable <= '0'; - prio <= not prio; - else - timer <= timer + '1'; - end if; - - when RECEIVE => - if DMNI_Receive = FINISH or (timer = DMNI_TIMER and send_active_2 = '1') then - timer <= "00000"; - ARB <= ROUND; - read_enable <= '0'; - prio <= not prio; - else - timer <= timer + '1'; - end if; - end case; - end if; - end process arbiter; - - proc_receive : process (clock, reset) - begin - if (reset = '1') then - reset_dmni_s <= '1'; - payload_fix <= (others=>'0'); - sizedata_fix <= (others=>'0'); - novo_pacote <= '0'; - is_dmma <= '0'; - - first <= (others=> '0'); - last <= (others=> '0'); - payload_size <= (others=> '0'); - SR <= HEADER; - add_buffer <= '0'; - receive_active_2 <= '0'; - DMNI_Receive <= WAIT_state; - recv_address <= (others=> '0'); - recv_size <= (others=> '0'); - mem_data_write <= (others=> '0'); - is_header <= (others=> '0'); - intr_counter_temp <= (others=> '0'); - mem_byte_we <= (others=> '0'); - elsif (clock'event and clock = '1') then - if (rx ='1' and slot_available = '1') then - bufferr(CONV_INTEGER(last)) <= data_in; - add_buffer <= '1'; - last <= last + 1; - --Read from NoC - case( SR ) is - when HEADER => - intr_counter_temp <= intr_counter_temp + 1; - assert address_router = x"0000" - report "Master receiving msg" - severity note; - is_header(CONV_INTEGER(last)) <= '1'; - SR <= PAYLOAD; - when PAYLOAD => - is_header(CONV_INTEGER(last)) <= '0'; - payload_size <= data_in - 1; - payload_fix <= data_in - 1; - sizedata_fix <= data_in - 12; - SR <= DATA; - when DATA => - novo_pacote <= '1'; - is_header(CONV_INTEGER(last)) <= '0'; - if(payload_size = 0) then - SR <= HEADER; - novo_pacote <= '0'; - is_dmma <= '0'; - else - payload_size <= payload_size - 1; - - if (payload_size = payload_fix) then - if (data_in = x"00000300") then --Service 300 start_cpu - reset_dmni_s <= '0'; - end if; - end if; - if (payload_size = payload_fix) then - if (data_in = x"00000290") then --Service 290 dmni_operation - is_dmma <= '1'; - end if; - end if; - end if; - end case ; - end if; --(rx ='1' and slot_available = '1') - - --Write to memory - case( DMNI_Receive ) is - when WAIT_state => - if ((start = '1' and operation = '1') or novo_pacote = '1' ) then - --recv_address <= address - WORD_SIZE; - --recv_size <= size - 1; - recv_address <= (others=> '0'); - recv_size <= payload_fix + 2; - if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then - intr_counter_temp <= intr_counter_temp -1; - end if; - receive_active_2 <= '1'; - if(is_dmma = '1') then - DMNI_Receive <= COPY_TO_MEM_DMA; - else - DMNI_Receive <= COPY_TO_MEM; - end if; - end if; - - when COPY_TO_MEM => - if (read_enable = '1' and read_av = '1') then - --mem_byte_we <= "1111"; - --mem_data_write <= bufferr(CONV_INTEGER(first)); - --recv_address <= recv_address + WORD_SIZE; - recv_address <= (others=> '0'); - mem_byte_we <= "0000"; - mem_data_write <= (others=> '0'); - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - DMNI_Receive <= FINISH; - end if ; - else - mem_byte_we <= "0000"; - end if; - - when COPY_TO_MEM_DMA => - if (read_enable = '1' and read_av = '1') then - if (recv_size <= sizedata_fix) then - mem_byte_we <= "1111"; - mem_data_write <= bufferr(CONV_INTEGER(first)); - recv_address <= recv_address + WORD_SIZE; - else - mem_byte_we <= "0000"; - mem_data_write <= (others=> '0'); - recv_address <= (others=> '0'); - end if; - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - DMNI_Receive <= FINISH; - end if ; - else - mem_byte_we <= "0000"; - end if; - - - when FINISH => - receive_active_2 <= '0'; - mem_byte_we <= "0000"; - recv_address <= (others=> '0'); - recv_size <= (others=> '0'); - DMNI_Receive <= WAIT_state; - when OTHERS => - end case; - end if; --rising_edge(clock) - end process proc_receive; - - intr_count <= intr_counter_temp; - intr <= '1' when intr_counter_temp > 0 else '0'; - reset_dmni <= reset_dmni_s; - - proc_send : process (clock, reset) - begin - if(reset = '1') then - DMNI_Send <= WAIT_state; - send_active_2 <= '0'; - tx <= '0'; - send_size <= (others=> '0'); - send_size_2 <= (others=> '0'); - send_address <= (others=> '0'); - send_address_2 <= (others=> '0'); - data_out <= (others=> '0'); - elsif (clock'event and clock = '1') then - case( DMNI_Send ) is - when WAIT_state => - if (start = '1' and operation = '0') then - send_address <= address; - send_address_2 <= address_2; - send_size <= size; - send_size_2 <= size_2; - send_active_2 <= '1'; - DMNI_Send <= LOAD; - assert address_router = x"0000" - report "Master sending msg" - severity note; - end if ; - - when LOAD => - if(credit_i = '1' and write_enable = '1') then - send_address <= send_address + WORD_SIZE; - DMNI_Send <= COPY_FROM_MEM; - end if; - - when COPY_FROM_MEM => - if(credit_i = '1' and write_enable = '1') then - if(send_size > 0) then - tx <= '1'; - data_out <= mem_data_read; - send_address <= send_address + WORD_SIZE; - send_size <= send_size -1; - elsif (send_size_2 > 0) then - send_size <= send_size_2; - send_size_2 <= (others=> '0'); - tx <= '0'; - if(send_address_2(30 downto 28) = "000") then - send_address <= send_address_2; - else - send_address <= send_address_2 - WORD_SIZE; - end if; - DMNI_Send <= LOAD; - else - tx <= '0'; - DMNI_Send <= FINISH; - end if; - else - if (credit_i = '0') then - send_size <= send_size + 1; - send_address <= send_address - WORD_SIZE - WORD_SIZE; -- address back 2 positions - else - send_address <= send_address - WORD_SIZE; -- address back 1 position - end if; - tx <= '0'; - DMNI_Send <= LOAD; - end if; - - when FINISH => - send_active_2 <= '0'; - send_address <= (others=> '0'); - send_address_2 <= (others=> '0'); - send_size <= (others=> '0'); - send_size_2 <= (others=> '0'); - DMNI_Send <= WAIT_state; - when OTHERS => - end case ; - end if; --rising_edge(clock) - end process proc_send; -end dmni; +------------------------------------------------------------------------------------------------ +-- +-- DISTRIBUTED HEMPS - version 7.0 +-- +-- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br +-- +-- Distribution: May 2015 +-- +-- Source name: dmni.vhd +-- +-- Brief description: Implements a DMNI module. +-- +-- OPERATIONS: +-- 0 - Copy from memory +-- 1 - Copy to memory +--------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.std_logic_unsigned.all; +use ieee.std_logic_arith.all; +use work.hemps_pkg.all; +use work.standards.all; + +entity dmni is + generic(address_router : regmetadeflit := (others => '0')); + port + ( + clock : in std_logic; + reset : in std_logic; + -- Configuration interface + set_address : in std_logic; + set_address_2 : in std_logic; + set_size : in std_logic; + set_size_2 : in std_logic; + set_op : in std_logic; + start : in std_logic; + config_data : in std_logic_vector(31 downto 0); + -- Status outputs + intr : out std_logic; + send_active : out std_logic; + receive_active : out std_logic; + reset_dmni : out std_logic; + -- Memory interface + mem_address : out std_logic_vector(31 downto 0); + mem_data_write : out std_logic_vector(31 downto 0); + mem_data_read : in std_logic_vector(31 downto 0); + mem_byte_we : out std_logic_vector(3 downto 0); + -- Noc Interface (Local port) + tx : out std_logic; + data_out : out regflit; + credit_i : in std_logic; + clock_tx : out std_logic; + rx : in std_logic; + data_in : in regflit; + credit_o : out std_logic; + clock_rx : in std_logic + ); +end; + +architecture dmni of dmni is + + constant DMNI_TIMER : std_logic_vector(4 downto 0) := "10000"; + constant WORD_SIZE : std_logic_vector(4 downto 0) := "00100"; + + type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, DISCARD, FINISH); + type operation_type is (LEGACY, DMMA, START_CPU); + signal DMNI_Send : dmni_state; + signal DMNI_Receive : dmni_state; + + type noc_state is (HEADER, PAYLOAD, DATA); + signal SR : noc_state; + + type arbiter_state is (ROUND, SEND, RECEIVE); + signal ARB : arbiter_state; + + signal bufferr : buff_dmni := (others => (others => '0')); + subtype buffsizebool is std_logic_vector(0 to (TAM_BUFFER_DMNI-1)); + signal is_header : buffsizebool := (others => '0'); + signal intr_count : std_logic_vector(3 downto 0); + + signal first, last : pointer := (others => '0'); + signal add_buffer : std_logic; + + signal payload_size : regflit; + + signal timer : std_logic_vector(4 downto 0); + signal address : std_logic_vector(31 downto 0); + signal address_2 : std_logic_vector(31 downto 0); + signal size : std_logic_vector(31 downto 0); + signal size_2 : std_logic_vector(31 downto 0); + signal send_address : std_logic_vector(31 downto 0); + signal send_address_2 : std_logic_vector(31 downto 0); + signal send_size : std_logic_vector(31 downto 0); + signal send_size_2 : std_logic_vector(31 downto 0); + signal recv_address : std_logic_vector(31 downto 0); + signal recv_size : std_logic_vector(31 downto 0); + signal prio : std_logic; + signal operation : std_logic; + signal read_av : std_logic; + signal slot_available : std_logic; + signal read_enable : std_logic; + signal write_enable : std_logic; + + signal send_active_2 : std_logic; + signal receive_active_2 : std_logic; + signal intr_counter_temp : std_logic_vector(3 downto 0); + + signal reset_dmni_s : std_logic; + signal payload_fix : regflit; + signal sizedata_fix : regflit; + signal novo_pacote : std_logic; + signal recv_op : operation_type; +begin + --config + proc_config : process(clock) + begin + if(clock'event and clock = '1') then + if (set_address = '1') then + address <= config_data; + address_2 <= (others => '0'); + elsif (set_address_2 = '1') then + address_2 <= config_data; + elsif (set_size = '1') then + size <= config_data; + size_2 <= (others => '0'); + elsif (set_size_2 = '1') then + size_2 <= config_data; + elsif (set_op = '1') then + operation <= config_data(0); + end if; + end if; + end process proc_config; + + mem_address <= send_address when write_enable = '1' else recv_address; + credit_o <= slot_available; + slot_available <= '0' when (first = last and add_buffer = '1') else '1'; + read_av <= '0' when (first = last and add_buffer = '0') else '1'; + clock_tx <= clock; + send_active <= send_active_2; + receive_active <= receive_active_2; + + arbiter : process (clock, reset) + begin + if reset = '1' then + read_enable <= '0'; + write_enable <= '0'; + timer <= "00000"; + prio <= '0'; + ARB <= ROUND; + elsif (clock'event and clock = '1') then + case ARB is + when ROUND => + if prio = '0' then + if (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then + ARB <= RECEIVE; + read_enable <= '1'; + elsif send_active_2 = '1' then + ARB <= SEND; + write_enable <= '1'; + end if; + else + if send_active_2 = '1' then + ARB <= SEND; + write_enable <= '1'; + elsif (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then + ARB <= RECEIVE; + read_enable <= '1'; + end if; + end if; + + when SEND => + if DMNI_Send = FINISH or (timer = DMNI_TIMER and receive_active_2 = '1') then + timer <= "00000"; + ARB <= ROUND; + write_enable <= '0'; + prio <= not prio; + else + timer <= timer + '1'; + end if; + + when RECEIVE => + if DMNI_Receive = FINISH or (timer = DMNI_TIMER and send_active_2 = '1') then + timer <= "00000"; + ARB <= ROUND; + read_enable <= '0'; + prio <= not prio; + else + timer <= timer + '1'; + end if; + end case; + end if; + end process arbiter; + + proc_receive : process (clock, reset) + begin + if (reset = '1') then + reset_dmni_s <= '1'; + payload_fix <= (others => '0'); + sizedata_fix <= (others => '0'); + novo_pacote <= '0'; + recv_op <= LEGACY; + + first <= (others => '0'); + last <= (others => '0'); + payload_size <= (others => '0'); + SR <= HEADER; + add_buffer <= '0'; + receive_active_2 <= '0'; + DMNI_Receive <= WAIT_state; + recv_address <= (others => '0'); + recv_size <= (others => '0'); + mem_data_write <= (others => '0'); + is_header <= (others => '0'); + intr_counter_temp <= (others => '0'); + mem_byte_we <= (others => '0'); + elsif (clock'event and clock = '1') then + if (rx = '1' and slot_available = '1') then + bufferr(CONV_INTEGER(last)) <= data_in; + add_buffer <= '1'; + last <= last + 1; + --Read from NoC + case SR is + when HEADER => + intr_counter_temp <= intr_counter_temp + 1; + assert address_router = x"0000" + report "Master receiving msg" + severity note; + is_header(CONV_INTEGER(last)) <= '1'; + SR <= PAYLOAD; + when PAYLOAD => + is_header(CONV_INTEGER(last)) <= '0'; + payload_size <= data_in - 1; + payload_fix <= data_in - 1; + sizedata_fix <= data_in - 12; + SR <= DATA; + when DATA => + novo_pacote <= '1'; + is_header(CONV_INTEGER(last)) <= '0'; + if(payload_size = 0) then + SR <= HEADER; + novo_pacote <= '0'; + recv_op <= LEGACY; + else + payload_size <= payload_size - 1; + + if (payload_size = payload_fix) then + if (data_in = x"00000300") then --Service 300 start_cpu + reset_dmni_s <= '0'; + recv_op <= START_CPU; + end if; + end if; + if (payload_size = payload_fix) then + if (data_in = x"00000290") then --Service 290 dmni_operation + recv_op <= DMMA; + end if; + end if; + end if; + end case; + end if; --(rx ='1' and slot_available = '1') + + --Write to memory + case DMNI_Receive is + when WAIT_state => + if ((start = '1' and operation = '1') or novo_pacote = '1') then + recv_address <= address - WORD_SIZE; + recv_size <= size - 1; + if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then + intr_counter_temp <= intr_counter_temp -1; + end if; + receive_active_2 <= '1'; + case recv_op is + when LEGACY => DMNI_Receive <= COPY_TO_MEM; + when DMMA => DMNI_Receive <= COPY_TO_MEM_DMA; + when START_CPU => DMNI_Receive <= DISCARD; + end case; + end if; + + when COPY_TO_MEM => + if (read_enable = '1' and read_av = '1') then + mem_byte_we <= "1111"; + mem_data_write <= bufferr(CONV_INTEGER(first)); + recv_address <= recv_address + WORD_SIZE; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + else + mem_byte_we <= "0000"; + end if; + + when DISCARD => + recv_address <= (others => '0'); + mem_byte_we <= "0000"; + mem_data_write <= (others => '0'); + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + + when COPY_TO_MEM_DMA => + if (read_enable = '1' and read_av = '1') then + if (recv_size <= sizedata_fix) then + mem_byte_we <= "1111"; + mem_data_write <= bufferr(CONV_INTEGER(first)); + recv_address <= recv_address + WORD_SIZE; + else + mem_byte_we <= "0000"; + mem_data_write <= (others => '0'); + recv_address <= (others => '0'); + end if; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + else + mem_byte_we <= "0000"; + end if; + + when FINISH => + receive_active_2 <= '0'; + mem_byte_we <= "0000"; + recv_address <= (others => '0'); + recv_size <= (others => '0'); + DMNI_Receive <= WAIT_state; + when others => + end case; + end if; --rising_edge(clock) + end process proc_receive; + + intr_count <= intr_counter_temp; + intr <= '1' when intr_counter_temp > 0 else '0'; + reset_dmni <= reset_dmni_s; + + proc_send : process (clock, reset) + begin + if(reset = '1') then + DMNI_Send <= WAIT_state; + send_active_2 <= '0'; + tx <= '0'; + send_size <= (others => '0'); + send_size_2 <= (others => '0'); + send_address <= (others => '0'); + send_address_2 <= (others => '0'); + data_out <= (others => '0'); + elsif (clock'event and clock = '1') then + case DMNI_Send is + when WAIT_state => + if (start = '1' and operation = '0') then + send_address <= address; + send_address_2 <= address_2; + send_size <= size; + send_size_2 <= size_2; + send_active_2 <= '1'; + DMNI_Send <= LOAD; + assert address_router = x"0000" + report "Master sending msg" + severity note; + end if; + + when LOAD => + if(credit_i = '1' and write_enable = '1') then + send_address <= send_address + WORD_SIZE; + DMNI_Send <= COPY_FROM_MEM; + end if; + + when COPY_FROM_MEM => + if(credit_i = '1' and write_enable = '1') then + if(send_size > 0) then + tx <= '1'; + data_out <= mem_data_read; + send_address <= send_address + WORD_SIZE; + send_size <= send_size -1; + elsif (send_size_2 > 0) then + send_size <= send_size_2; + send_size_2 <= (others => '0'); + tx <= '0'; + if(send_address_2(30 downto 28) = "000") then + send_address <= send_address_2; + else + send_address <= send_address_2 - WORD_SIZE; + end if; + DMNI_Send <= LOAD; + else + tx <= '0'; + DMNI_Send <= FINISH; + end if; + else + if (credit_i = '0') then + send_size <= send_size + 1; + send_address <= send_address - WORD_SIZE - WORD_SIZE; -- address back 2 positions + else + send_address <= send_address - WORD_SIZE; -- address back 1 position + end if; + tx <= '0'; + DMNI_Send <= LOAD; + end if; + + when FINISH => + send_active_2 <= '0'; + send_address <= (others => '0'); + send_address_2 <= (others => '0'); + send_size <= (others => '0'); + send_size_2 <= (others => '0'); + DMNI_Send <= WAIT_state; + when others => + end case; + end if; --rising_edge(clock) + end process proc_send; +end dmni; From 2a95738af2938fbd36660b05c1569300770f735d Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Tue, 17 Oct 2017 18:45:51 -0200 Subject: [PATCH 17/54] Attempt at fixing DMNI reception --- hardware/vhdl/pe/dmni/dmni.vhd | 67 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 5beb6c4..236d555 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -24,38 +24,36 @@ use work.standards.all; entity dmni is generic(address_router : regmetadeflit := (others => '0')); - port - ( - clock : in std_logic; - reset : in std_logic; - -- Configuration interface - set_address : in std_logic; - set_address_2 : in std_logic; - set_size : in std_logic; - set_size_2 : in std_logic; - set_op : in std_logic; - start : in std_logic; - config_data : in std_logic_vector(31 downto 0); - -- Status outputs - intr : out std_logic; - send_active : out std_logic; - receive_active : out std_logic; - reset_dmni : out std_logic; - -- Memory interface - mem_address : out std_logic_vector(31 downto 0); - mem_data_write : out std_logic_vector(31 downto 0); - mem_data_read : in std_logic_vector(31 downto 0); - mem_byte_we : out std_logic_vector(3 downto 0); - -- Noc Interface (Local port) - tx : out std_logic; - data_out : out regflit; - credit_i : in std_logic; - clock_tx : out std_logic; - rx : in std_logic; - data_in : in regflit; - credit_o : out std_logic; - clock_rx : in std_logic - ); + port( + clock : in std_logic; + reset : in std_logic; + -- Configuration interface + set_address : in std_logic; + set_address_2 : in std_logic; + set_size : in std_logic; + set_size_2 : in std_logic; + set_op : in std_logic; + start : in std_logic; + config_data : in std_logic_vector(31 downto 0); + -- Status outputs + intr : out std_logic; + send_active : out std_logic; + receive_active : out std_logic; + reset_dmni : out std_logic; + -- Memory interface + mem_address : out std_logic_vector(31 downto 0); + mem_data_write : out std_logic_vector(31 downto 0); + mem_data_read : in std_logic_vector(31 downto 0); + mem_byte_we : out std_logic_vector(3 downto 0); + -- Noc Interface (Local port) + tx : out std_logic; + data_out : out regflit; + credit_i : in std_logic; + clock_tx : out std_logic; + rx : in std_logic; + data_in : in regflit; + credit_o : out std_logic; + clock_rx : in std_logic); end; architecture dmni of dmni is @@ -219,6 +217,7 @@ begin bufferr(CONV_INTEGER(last)) <= data_in; add_buffer <= '1'; last <= last + 1; + --Read from NoC case SR is when HEADER => @@ -235,7 +234,6 @@ begin sizedata_fix <= data_in - 12; SR <= DATA; when DATA => - novo_pacote <= '1'; is_header(CONV_INTEGER(last)) <= '0'; if(payload_size = 0) then SR <= HEADER; @@ -252,7 +250,8 @@ begin end if; if (payload_size = payload_fix) then if (data_in = x"00000290") then --Service 290 dmni_operation - recv_op <= DMMA; + novo_pacote <= '1'; + recv_op <= DMMA; end if; end if; end if; From 6e545f894a741a585ea12836b60f78d695dcb9d9 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Tue, 17 Oct 2017 18:58:59 -0200 Subject: [PATCH 18/54] Fix start_cpu --- hardware/vhdl/pe/dmni/dmni.vhd | 1 + 1 file changed, 1 insertion(+) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 236d555..f28b09d 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -245,6 +245,7 @@ begin if (payload_size = payload_fix) then if (data_in = x"00000300") then --Service 300 start_cpu reset_dmni_s <= '0'; + novo_pacote <= '1'; recv_op <= START_CPU; end if; end if; From 92b628a8c747778bee65c467a0a33a55faee767b Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Wed, 18 Oct 2017 14:03:29 -0200 Subject: [PATCH 19/54] Fix recv_size and recv_address on dmni --- hardware/vhdl/pe/dmni/dmni.vhd | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index f28b09d..4b640d5 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -270,9 +270,16 @@ begin end if; receive_active_2 <= '1'; case recv_op is - when LEGACY => DMNI_Receive <= COPY_TO_MEM; - when DMMA => DMNI_Receive <= COPY_TO_MEM_DMA; - when START_CPU => DMNI_Receive <= DISCARD; + when LEGACY => + DMNI_Receive <= COPY_TO_MEM; + recv_size <= size - 1; + recv_address <= address - WORD_SIZE; + when DMMA => + DMNI_Receive <= COPY_TO_MEM_DMA; + recv_size <= payload_fix + 2; + recv_address <= (others => '0'); + when START_CPU => + DMNI_Receive <= DISCARD; end case; end if; From 82081055f9baed6dadf3829b9eca994e431464de Mon Sep 17 00:00:00 2001 From: Anderson Sant'Ana Date: Wed, 18 Oct 2017 14:16:54 -0200 Subject: [PATCH 20/54] =?UTF-8?q?atualiza=C3=A7=C3=A3o=20das=20tarefas=20d?= =?UTF-8?q?e=20envio=20e=20recebimento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/transmit/receive.c | 274 +++++++++++++++++++++++++++++ applications/transmit/transmit.c | 284 +++++++++++++++++-------------- 2 files changed, 426 insertions(+), 132 deletions(-) create mode 100644 applications/transmit/receive.c diff --git a/applications/transmit/receive.c b/applications/transmit/receive.c new file mode 100644 index 0000000..bb696b4 --- /dev/null +++ b/applications/transmit/receive.c @@ -0,0 +1,274 @@ + + +#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) +#define MemoryRead(A) (*(volatile unsigned int*)(A)) + + +/*********** Hardware addresses ***********/ +#define IRQ_MASK 0x20000010 +#define IRQ_STATUS 0x20000020 + + +/*********** Interrupt bits **************/ +#define IRQ_PENDING_SERVICE 0x01 //bit 0 +#define IRQ_SLACK_TIME 0x02 //bit 1 +#define IRQ_SCHEDULER 0x08 //bit 3 +#define IRQ_NOC 0x20 //bit 5 + +/* DMNI operations */ +#define READ 0 +#define WRITE 1 + + +#define NI_CONFIG 0x20000140 + +/* DMNI*/ +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 + +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) +#define noc_interruption (MemoryRead(IRQ_STATUS) & IRQ_NOC) //!< Signals a incoming packet from NoC + + +#define MESSAGE_DELIVERY 0x00000020 +#define CONSTANT_PKT_SIZE 6 //Tamanho do pacote do header + + +#define UART_WRITE 0x20000000 +#define TESTE 0x20000008 + +typedef struct { + unsigned int header; + unsigned int payload_size; + unsigned int service; + unsigned int source; + unsigned int target; + unsigned int pkt_size; +} ServiceHeader; + + + + + + +int puts(char *string) { + + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + for( + str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); + + !( ( (char*)str_part )[0] == 0 || ( (char*)str_part )[1] == 0 || ( (char*)str_part )[2] == 0 || ( (char*)str_part )[3] == 0); + + *str_part++,MemoryWrite(UART_WRITE, *str_part) + ); + return 0; +} + +/**Converts a integer number to its decimal representation in a array of char + * \param num Integer number to be converted + * \return Array of chars + */ +char *itoa(unsigned int num) +{ + static char buf[12]; + static char buf2[12]; + int i,j; + + if (num==0) + { + buf[0] = '0'; + buf[1] = '\0'; + return &buf[0]; + } + + for(i=0;i<11 && num!=0;i++) + { + buf[i]=(char)((num%10)+'0'); + num/=10; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; +} + + + +char *itoh(unsigned int num) +{ + static char buf[11]; + int i; + buf[10]=0; + + buf[0] = '0'; + buf[1] = 'x'; + + if (num==0) + { + buf[2] = '0'; + buf[3] = '0'; + buf[4] = '0'; + buf[5] = '0'; + buf[6] = '0'; + buf[7] = '0'; + buf[8] = '0'; + buf[9] = '0'; + return buf; + } + + for(i=9;i>=2;--i) + { + if ((num%16) < 10) + buf[i]=(char)((num%16)+'0'); + else + buf[i]=(char)((num%16)+'W'); + + num/=16; + } + + return buf; +} + + + + +void transmite(int target, int service, int *msg, int lenght){ + + + ServiceHeader p; + p.header = target; + p.payload_size = (CONSTANT_PKT_SIZE-2) + lenght; // 6 devido ao service header - 2 flits da noc + p.service = service; + p.source = MemoryRead(NI_CONFIG); + p.target = target; + p.pkt_size = lenght; + + + //Waits the DMNI send process be released + while (MemoryRead(DMNI_SEND_ACTIVE)); + + MemoryWrite(DMNI_SIZE, 6); + + + + puts("apo"); + //puts(itoa((unsigned int)p.header)); + //puts("\n"); + //puts(itoh((unsigned int)(&p))); + //puts("\n"); + + + MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header + + if( lenght > 0 ) { + + MemoryWrite(DMNI_SIZE_2, lenght); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); + + } + + MemoryWrite(DMNI_OP, READ); + MemoryWrite(DMNI_START, 1); +} + + + + + + +void read_packet(ServiceHeader *p){ + + MemoryWrite(DMNI_SIZE, 6); + MemoryWrite(DMNI_OP, WRITE); + MemoryWrite(DMNI_ADDRESS, 0x4001); + MemoryWrite(DMNI_START, 1); + //Waits the DMNI copy all data to memory before release the software to access it + //while (noc_interruption != 1) + while (MemoryRead(DMNI_RECEIVE_ACTIVE)); + + p = 0x4001; +} + + + + + +int main() +{ + volatile ServiceHeader p; + + puts("a"); + +/* + read_packet((ServiceHeader *)&p); + puts("$$$ "); + puts(itoa((unsigned int)p.header)); + puts("\n"); + puts(itoh((unsigned int)p.service)); + puts("\n"); +*/ + + + while(1) + { + int i; + + if (noc_interruption){ + + i=7; + //transmite(0x00000101 ,MESSAGE_DELIVERY, &i ,1); + + read_packet((ServiceHeader *)&p); + //puts("a"); + //puts(itoa((unsigned int)p.header)); + //puts("\n"); + //puts(itoh((unsigned int)p.service)); + //puts("\n"); + + + + int data_receive[4]; + data_receive[0] = MemoryRead(0x4001); + data_receive[1] = MemoryRead(0x4002); + data_receive[2] = MemoryRead(0x4003); + data_receive[3] = 4; + + transmite(0x00000101 ,MESSAGE_DELIVERY, data_receive ,4); + + + + } + + + + } + + + +} + +/* + +USO: +int message[30] +transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) +*/ \ No newline at end of file diff --git a/applications/transmit/transmit.c b/applications/transmit/transmit.c index 0d3c606..e450e90 100644 --- a/applications/transmit/transmit.c +++ b/applications/transmit/transmit.c @@ -30,6 +30,11 @@ #define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) +#define UART_WRITE 0x20000000 +#define TESTE 0x20000008 +#define MESSAGE_DELIVERY 0x00000020 +#define CONSTANT_PKT_SIZE 6 //Tamanho do pacote do header + typedef struct { unsigned int header; unsigned int payload_size; @@ -40,28 +45,132 @@ typedef struct { } ServiceHeader; -void transmite(int target, int service, int *msg, int lenght){ - ServiceHeader *p; - p -> header = target; - p -> payload_size = 6 + lenght; // 6 devido ao service header - p -> service = service; - p -> source = MemoryRead(NI_CONFIG); - p -> target = target; - p -> pkt_size = lenght; +int puts(char *string) { + + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + for( + str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); + + !( ( (char*)str_part )[0] == 0 || ( (char*)str_part )[1] == 0 || ( (char*)str_part )[2] == 0 || ( (char*)str_part )[3] == 0); + + *str_part++,MemoryWrite(UART_WRITE, *str_part) + ); + return 0; +} + +/**Converts a integer number to its decimal representation in a array of char + * \param num Integer number to be converted + * \return Array of chars + */ +char *itoa(unsigned int num) +{ + static char buf[12]; + static char buf2[12]; + int i,j; + + if (num==0) + { + buf[0] = '0'; + buf[1] = '\0'; + return &buf[0]; + } + + for(i=0;i<11 && num!=0;i++) + { + buf[i]=(char)((num%10)+'0'); + num/=10; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; +} + + + +char *itoh(unsigned int num) +{ + static char buf[11]; + int i; + buf[10]=0; + + buf[0] = '0'; + buf[1] = 'x'; + + if (num==0) + { + buf[2] = '0'; + buf[3] = '0'; + buf[4] = '0'; + buf[5] = '0'; + buf[6] = '0'; + buf[7] = '0'; + buf[8] = '0'; + buf[9] = '0'; + return buf; + } + + for(i=9;i>=2;--i) + { + if ((num%16) < 10) + buf[i]=(char)((num%16)+'0'); + else + buf[i]=(char)((num%16)+'W'); + + num/=16; + } + + return buf; +} + + + + + + + +void transmite(int target, int service, int *msg, int lenght){ + + + ServiceHeader p; + p.header = target; + p.payload_size = (CONSTANT_PKT_SIZE-2) + lenght; // 6 devido ao service header - 2 flits da noc + p.service = service; + p.source = MemoryRead(NI_CONFIG); + p.target = target; + p.pkt_size = lenght; + + puts("trm"); //Waits the DMNI send process be released while (MemoryRead(DMNI_SEND_ACTIVE)); MemoryWrite(DMNI_SIZE, 6); - MemoryWrite(DMNI_ADDRESS, (unsigned int)p ); //grava na memoria as informacoes do header + + + + puts("apo"); + //puts(itoa((unsigned int)p.header)); + //puts("\n"); + //puts(itoh((unsigned int)(&p))); + //puts("\n"); + + + MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header if( lenght > 0 ) { MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, msg); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); } @@ -70,130 +179,41 @@ void transmite(int target, int service, int *msg, int lenght){ } + + + + int main() { - ServiceHeader *p; - p -> header = 1; - p -> payload_size = 2; // 6 devido ao service header - p -> service = 3; - p -> source = 4; - p -> target = 5; - p -> pkt_size = 6; - MemoryWrite(DMNI_SIZE, 6); - MemoryWrite(DMNI_ADDRESS, (unsigned int)p ); //grava na memoria as informacoes do header - - - unsigned int data_dma_code[102]; - data_dma_code[0]= 0x241d7fff; - data_dma_code[1]= 0x0c00002c; - data_dma_code[2]= 0x00000000; - data_dma_code[3]= 0x00002021; - data_dma_code[4]= 0x0000000c; - data_dma_code[5]= 0x00000000; - data_dma_code[6]= 0x08000006; - data_dma_code[7]= 0x00000000; - data_dma_code[8]= 0x0000000c; - data_dma_code[9]= 0x00000000; - data_dma_code[10]= 0x03e00008; - data_dma_code[11]= 0x00000000; - data_dma_code[12]= 0x24e20006; - data_dma_code[13]= 0xac450008; - data_dma_code[14]= 0xac440000; - data_dma_code[15]= 0xac420004; - data_dma_code[16]= 0x3c022000; - data_dma_code[17]= 0x34420140; - data_dma_code[18]= 0x8c430000; - data_dma_code[19]= 0x3c052000; - data_dma_code[20]= 0xac43000c; - data_dma_code[21]= 0xac440010; - data_dma_code[22]= 0xac470014; - data_dma_code[23]= 0x34a30250; - data_dma_code[24]= 0x8c620000; - data_dma_code[25]= 0x00000000; - data_dma_code[26]= 0x1440fffd; - data_dma_code[27]= 0x34a20200; - data_dma_code[28]= 0x34a40210; - data_dma_code[29]= 0x24030006; - data_dma_code[30]= 0xac430000; - data_dma_code[31]= 0xac820000; - data_dma_code[32]= 0x18e00004; - data_dma_code[33]= 0x34a20205; - data_dma_code[34]= 0x34a30215; - data_dma_code[35]= 0xac470000; - data_dma_code[36]= 0xac660000; - data_dma_code[37]= 0x34a20230; - data_dma_code[38]= 0x34a30220; - data_dma_code[39]= 0x24040001; - data_dma_code[40]= 0xac600000; - data_dma_code[41]= 0xac440000; - data_dma_code[42]= 0x03e00008; - data_dma_code[43]= 0x00000000; - data_dma_code[44]= 0x27bdffa8; - data_dma_code[45]= 0x24020001; - data_dma_code[46]= 0x24030002; - data_dma_code[47]= 0xafa20010; - data_dma_code[48]= 0xafa30014; - data_dma_code[49]= 0x24020003; - data_dma_code[50]= 0x24030004; - data_dma_code[51]= 0xafa20018; - data_dma_code[52]= 0xafa3001c; - data_dma_code[53]= 0x24020005; - data_dma_code[54]= 0x24030006; - data_dma_code[55]= 0xafa20020; - data_dma_code[56]= 0xafa30024; - data_dma_code[57]= 0x24020007; - data_dma_code[58]= 0x24030008; - data_dma_code[59]= 0xafa20028; - data_dma_code[60]= 0xafa3002c; - data_dma_code[61]= 0x24020009; - data_dma_code[62]= 0x2403000a; - data_dma_code[63]= 0xafa20030; - data_dma_code[64]= 0xafa30034; - data_dma_code[65]= 0x2402000b; - data_dma_code[66]= 0x2403000c; - data_dma_code[67]= 0xafb00050; - data_dma_code[68]= 0xafa20038; - data_dma_code[69]= 0x27b00010; - data_dma_code[70]= 0xafa3003c; - data_dma_code[71]= 0x2402000d; - data_dma_code[72]= 0x2403000e; - data_dma_code[73]= 0x24040001; - data_dma_code[74]= 0x24050290; - data_dma_code[75]= 0x02003021; - data_dma_code[76]= 0x24070010; - data_dma_code[77]= 0xafa20040; - data_dma_code[78]= 0xafa30044; - data_dma_code[79]= 0x2402000f; - data_dma_code[80]= 0x24030010; - data_dma_code[81]= 0xafbf0054; - data_dma_code[82]= 0xafa20048; - data_dma_code[83]= 0x0c00000c; - data_dma_code[84]= 0xafa3004c; - data_dma_code[85]= 0x24040100; - data_dma_code[86]= 0x24050290; - data_dma_code[87]= 0x02003021; - data_dma_code[88]= 0x0c00000c; - data_dma_code[89]= 0x24070010; - data_dma_code[90]= 0x00002021; - data_dma_code[91]= 0x24050290; - data_dma_code[92]= 0x02003021; - data_dma_code[93]= 0x0c00000c; - data_dma_code[94]= 0x24070010; - data_dma_code[95]= 0x02003021; - data_dma_code[96]= 0x24040101; - data_dma_code[97]= 0x24050290; - data_dma_code[98]= 0x0c00000c; - data_dma_code[99]= 0x24070010; - data_dma_code[100]= 0x08000064; - data_dma_code[101]= 0x00000000; - - transmite(0x00000001 ,0x00000290, data_dma_code ,102); - transmite(0x00000100 ,0x00000290, data_dma_code ,102); - transmite(0x00000000 ,0x00000290, data_dma_code ,102); - transmite(0x00000101 ,0x00000290, data_dma_code,102); - - - while(1); + unsigned int i; + int anderson[2]; + puts("$$$"); + anderson[0] = 14; + anderson[1] = 20; + + transmite(0x00000001 ,MESSAGE_DELIVERY, anderson ,2); + puts("aa$"); + + + //transmite(0x00000100 ,0x00000290, data_dma_code ,102); + //transmite(0x00000000 ,0x00000290, data_dma_code ,102); + //transmite(0x00000101 ,0x00000290, data_dma_code,102); + // + + + for(i=0; i<100; i++) + { + MemoryWrite(TESTE, i); //Grava o valor de no endereco da memoria (definida como teste) + *(volatile unsigned int *)(TESTE) = i; + + puts("$$$ "); + puts(itoa(i)); + puts(itoa(&i)); + puts("\n"); + } + + + for(;;); From 8cf7bc0fba5e65108fb08a1370010bdcb72b18d0 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Thu, 19 Oct 2017 14:40:08 -0200 Subject: [PATCH 21/54] Implemented DMMA receive buffer --- hardware/vhdl/pe/dmni/dmni.vhd | 63 ++++++++++++++++++++-------------- hardware/vhdl/standards.vhd | 1 + 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 4b640d5..a5bd524 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -34,6 +34,7 @@ entity dmni is set_size_2 : in std_logic; set_op : in std_logic; start : in std_logic; + set_buff : in std_logic; config_data : in std_logic_vector(31 downto 0); -- Status outputs intr : out std_logic; @@ -93,6 +94,8 @@ architecture dmni of dmni is signal send_size_2 : std_logic_vector(31 downto 0); signal recv_address : std_logic_vector(31 downto 0); signal recv_size : std_logic_vector(31 downto 0); + signal recv_buffer : std_logic_vector(31 downto 0); + signal dmma_done : std_logic; signal prio : std_logic; signal operation : std_logic; signal read_av : std_logic; @@ -107,13 +110,14 @@ architecture dmni of dmni is signal reset_dmni_s : std_logic; signal payload_fix : regflit; signal sizedata_fix : regflit; - signal novo_pacote : std_logic; signal recv_op : operation_type; begin --config proc_config : process(clock) begin - if(clock'event and clock = '1') then + if reset = '1' then + recv_buffer <= (others => '0'); + elsif(clock'event and clock = '1') then if (set_address = '1') then address <= config_data; address_2 <= (others => '0'); @@ -126,6 +130,10 @@ begin size_2 <= config_data; elsif (set_op = '1') then operation <= config_data(0); + elsif set_buff = '1' then + recv_buffer <= config_data; + elsif dmma_done = '1' then + recv_buffer(0) <= '1'; end if; end if; end process proc_config; @@ -193,12 +201,11 @@ begin proc_receive : process (clock, reset) begin if (reset = '1') then - reset_dmni_s <= '1'; - payload_fix <= (others => '0'); - sizedata_fix <= (others => '0'); - novo_pacote <= '0'; - recv_op <= LEGACY; - + reset_dmni_s <= '1'; + payload_fix <= (others => '0'); + sizedata_fix <= (others => '0'); + recv_op <= LEGACY; + dmma_done <= '0'; first <= (others => '0'); last <= (others => '0'); payload_size <= (others => '0'); @@ -231,28 +238,25 @@ begin is_header(CONV_INTEGER(last)) <= '0'; payload_size <= data_in - 1; payload_fix <= data_in - 1; - sizedata_fix <= data_in - 12; + sizedata_fix <= data_in - 2; SR <= DATA; when DATA => is_header(CONV_INTEGER(last)) <= '0'; if(payload_size = 0) then - SR <= HEADER; - novo_pacote <= '0'; - recv_op <= LEGACY; + SR <= HEADER; + recv_op <= LEGACY; else payload_size <= payload_size - 1; if (payload_size = payload_fix) then if (data_in = x"00000300") then --Service 300 start_cpu reset_dmni_s <= '0'; - novo_pacote <= '1'; recv_op <= START_CPU; end if; end if; if (payload_size = payload_fix) then if (data_in = x"00000290") then --Service 290 dmni_operation - novo_pacote <= '1'; - recv_op <= DMMA; + recv_op <= DMMA; end if; end if; end if; @@ -262,9 +266,9 @@ begin --Write to memory case DMNI_Receive is when WAIT_state => - if ((start = '1' and operation = '1') or novo_pacote = '1') then - recv_address <= address - WORD_SIZE; - recv_size <= size - 1; + if (recv_op = LEGACY and start = '1' and operation = '1') or + (rect_op = DMMA and recv_buffer(0) = '0') or + (recv_op = START_CPU) then if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then intr_counter_temp <= intr_counter_temp -1; end if; @@ -277,9 +281,11 @@ begin when DMMA => DMNI_Receive <= COPY_TO_MEM_DMA; recv_size <= payload_fix + 2; - recv_address <= (others => '0'); + recv_address <= recv_buffer(31 downto 2) & "00"; when START_CPU => DMNI_Receive <= DISCARD; + recv_size <= payload_fix + 2; + recv_address <= (others => '0'); end case; end if; @@ -310,24 +316,29 @@ begin end if; when COPY_TO_MEM_DMA => - if (read_enable = '1' and read_av = '1') then - if (recv_size <= sizedata_fix) then + if (recv_size <= sizedata_fix) then + if (read_enable = '1' and read_av = '1') then mem_byte_we <= "1111"; mem_data_write <= bufferr(CONV_INTEGER(first)); recv_address <= recv_address + WORD_SIZE; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + dmma_done <= '1'; + DMNI_Receive <= FINISH; + end if; else - mem_byte_we <= "0000"; - mem_data_write <= (others => '0'); - recv_address <= (others => '0'); + mem_byte_we <= "0000"; end if; + else first <= first + 1; add_buffer <= '0'; recv_size <= recv_size -1; if (recv_size = 0) then + dmma_done <= '1'; DMNI_Receive <= FINISH; end if; - else - mem_byte_we <= "0000"; end if; when FINISH => diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index da56b4a..e0c6831 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -54,6 +54,7 @@ package standards is constant DMNI_SEND_ACTIVE : std_logic_vector(31 downto 0) := x"20000250"; constant DMNI_RECEIVE_ACTIVE : std_logic_vector(31 downto 0) := x"20000260"; + constant DMNI_RECEIVE_BUFFER : std_logic_vector(31 downto 0) := x"20000264"; constant SCHEDULING_REPORT : std_logic_vector(31 downto 0) := x"20000270"; From 778873e37e2c3185f6a11e65ddc9dab2e2efddff Mon Sep 17 00:00:00 2001 From: Anderson Sant'Ana Date: Thu, 19 Oct 2017 15:54:31 -0200 Subject: [PATCH 22/54] =?UTF-8?q?atualiza=C3=A7=C3=A3o=20da=20dmni=20-=20f?= =?UTF-8?q?ora=20corrigido=20alguns=20erros=20de=20sintax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardware/vhdl/pe/dmni/dmni.vhd | 867 ++++++++++++++++----------------- 1 file changed, 433 insertions(+), 434 deletions(-) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index a5bd524..a058f91 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -1,434 +1,433 @@ ------------------------------------------------------------------------------------------------- --- --- DISTRIBUTED HEMPS - version 7.0 --- --- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br --- --- Distribution: May 2015 --- --- Source name: dmni.vhd --- --- Brief description: Implements a DMNI module. --- --- OPERATIONS: --- 0 - Copy from memory --- 1 - Copy to memory ---------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.std_logic_unsigned.all; -use ieee.std_logic_arith.all; -use work.hemps_pkg.all; -use work.standards.all; - -entity dmni is - generic(address_router : regmetadeflit := (others => '0')); - port( - clock : in std_logic; - reset : in std_logic; - -- Configuration interface - set_address : in std_logic; - set_address_2 : in std_logic; - set_size : in std_logic; - set_size_2 : in std_logic; - set_op : in std_logic; - start : in std_logic; - set_buff : in std_logic; - config_data : in std_logic_vector(31 downto 0); - -- Status outputs - intr : out std_logic; - send_active : out std_logic; - receive_active : out std_logic; - reset_dmni : out std_logic; - -- Memory interface - mem_address : out std_logic_vector(31 downto 0); - mem_data_write : out std_logic_vector(31 downto 0); - mem_data_read : in std_logic_vector(31 downto 0); - mem_byte_we : out std_logic_vector(3 downto 0); - -- Noc Interface (Local port) - tx : out std_logic; - data_out : out regflit; - credit_i : in std_logic; - clock_tx : out std_logic; - rx : in std_logic; - data_in : in regflit; - credit_o : out std_logic; - clock_rx : in std_logic); -end; - -architecture dmni of dmni is - - constant DMNI_TIMER : std_logic_vector(4 downto 0) := "10000"; - constant WORD_SIZE : std_logic_vector(4 downto 0) := "00100"; - - type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, DISCARD, FINISH); - type operation_type is (LEGACY, DMMA, START_CPU); - signal DMNI_Send : dmni_state; - signal DMNI_Receive : dmni_state; - - type noc_state is (HEADER, PAYLOAD, DATA); - signal SR : noc_state; - - type arbiter_state is (ROUND, SEND, RECEIVE); - signal ARB : arbiter_state; - - signal bufferr : buff_dmni := (others => (others => '0')); - subtype buffsizebool is std_logic_vector(0 to (TAM_BUFFER_DMNI-1)); - signal is_header : buffsizebool := (others => '0'); - signal intr_count : std_logic_vector(3 downto 0); - - signal first, last : pointer := (others => '0'); - signal add_buffer : std_logic; - - signal payload_size : regflit; - - signal timer : std_logic_vector(4 downto 0); - signal address : std_logic_vector(31 downto 0); - signal address_2 : std_logic_vector(31 downto 0); - signal size : std_logic_vector(31 downto 0); - signal size_2 : std_logic_vector(31 downto 0); - signal send_address : std_logic_vector(31 downto 0); - signal send_address_2 : std_logic_vector(31 downto 0); - signal send_size : std_logic_vector(31 downto 0); - signal send_size_2 : std_logic_vector(31 downto 0); - signal recv_address : std_logic_vector(31 downto 0); - signal recv_size : std_logic_vector(31 downto 0); - signal recv_buffer : std_logic_vector(31 downto 0); - signal dmma_done : std_logic; - signal prio : std_logic; - signal operation : std_logic; - signal read_av : std_logic; - signal slot_available : std_logic; - signal read_enable : std_logic; - signal write_enable : std_logic; - - signal send_active_2 : std_logic; - signal receive_active_2 : std_logic; - signal intr_counter_temp : std_logic_vector(3 downto 0); - - signal reset_dmni_s : std_logic; - signal payload_fix : regflit; - signal sizedata_fix : regflit; - signal recv_op : operation_type; -begin - --config - proc_config : process(clock) - begin - if reset = '1' then - recv_buffer <= (others => '0'); - elsif(clock'event and clock = '1') then - if (set_address = '1') then - address <= config_data; - address_2 <= (others => '0'); - elsif (set_address_2 = '1') then - address_2 <= config_data; - elsif (set_size = '1') then - size <= config_data; - size_2 <= (others => '0'); - elsif (set_size_2 = '1') then - size_2 <= config_data; - elsif (set_op = '1') then - operation <= config_data(0); - elsif set_buff = '1' then - recv_buffer <= config_data; - elsif dmma_done = '1' then - recv_buffer(0) <= '1'; - end if; - end if; - end process proc_config; - - mem_address <= send_address when write_enable = '1' else recv_address; - credit_o <= slot_available; - slot_available <= '0' when (first = last and add_buffer = '1') else '1'; - read_av <= '0' when (first = last and add_buffer = '0') else '1'; - clock_tx <= clock; - send_active <= send_active_2; - receive_active <= receive_active_2; - - arbiter : process (clock, reset) - begin - if reset = '1' then - read_enable <= '0'; - write_enable <= '0'; - timer <= "00000"; - prio <= '0'; - ARB <= ROUND; - elsif (clock'event and clock = '1') then - case ARB is - when ROUND => - if prio = '0' then - if (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then - ARB <= RECEIVE; - read_enable <= '1'; - elsif send_active_2 = '1' then - ARB <= SEND; - write_enable <= '1'; - end if; - else - if send_active_2 = '1' then - ARB <= SEND; - write_enable <= '1'; - elsif (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then - ARB <= RECEIVE; - read_enable <= '1'; - end if; - end if; - - when SEND => - if DMNI_Send = FINISH or (timer = DMNI_TIMER and receive_active_2 = '1') then - timer <= "00000"; - ARB <= ROUND; - write_enable <= '0'; - prio <= not prio; - else - timer <= timer + '1'; - end if; - - when RECEIVE => - if DMNI_Receive = FINISH or (timer = DMNI_TIMER and send_active_2 = '1') then - timer <= "00000"; - ARB <= ROUND; - read_enable <= '0'; - prio <= not prio; - else - timer <= timer + '1'; - end if; - end case; - end if; - end process arbiter; - - proc_receive : process (clock, reset) - begin - if (reset = '1') then - reset_dmni_s <= '1'; - payload_fix <= (others => '0'); - sizedata_fix <= (others => '0'); - recv_op <= LEGACY; - dmma_done <= '0'; - first <= (others => '0'); - last <= (others => '0'); - payload_size <= (others => '0'); - SR <= HEADER; - add_buffer <= '0'; - receive_active_2 <= '0'; - DMNI_Receive <= WAIT_state; - recv_address <= (others => '0'); - recv_size <= (others => '0'); - mem_data_write <= (others => '0'); - is_header <= (others => '0'); - intr_counter_temp <= (others => '0'); - mem_byte_we <= (others => '0'); - elsif (clock'event and clock = '1') then - if (rx = '1' and slot_available = '1') then - bufferr(CONV_INTEGER(last)) <= data_in; - add_buffer <= '1'; - last <= last + 1; - - --Read from NoC - case SR is - when HEADER => - intr_counter_temp <= intr_counter_temp + 1; - assert address_router = x"0000" - report "Master receiving msg" - severity note; - is_header(CONV_INTEGER(last)) <= '1'; - SR <= PAYLOAD; - when PAYLOAD => - is_header(CONV_INTEGER(last)) <= '0'; - payload_size <= data_in - 1; - payload_fix <= data_in - 1; - sizedata_fix <= data_in - 2; - SR <= DATA; - when DATA => - is_header(CONV_INTEGER(last)) <= '0'; - if(payload_size = 0) then - SR <= HEADER; - recv_op <= LEGACY; - else - payload_size <= payload_size - 1; - - if (payload_size = payload_fix) then - if (data_in = x"00000300") then --Service 300 start_cpu - reset_dmni_s <= '0'; - recv_op <= START_CPU; - end if; - end if; - if (payload_size = payload_fix) then - if (data_in = x"00000290") then --Service 290 dmni_operation - recv_op <= DMMA; - end if; - end if; - end if; - end case; - end if; --(rx ='1' and slot_available = '1') - - --Write to memory - case DMNI_Receive is - when WAIT_state => - if (recv_op = LEGACY and start = '1' and operation = '1') or - (rect_op = DMMA and recv_buffer(0) = '0') or - (recv_op = START_CPU) then - if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then - intr_counter_temp <= intr_counter_temp -1; - end if; - receive_active_2 <= '1'; - case recv_op is - when LEGACY => - DMNI_Receive <= COPY_TO_MEM; - recv_size <= size - 1; - recv_address <= address - WORD_SIZE; - when DMMA => - DMNI_Receive <= COPY_TO_MEM_DMA; - recv_size <= payload_fix + 2; - recv_address <= recv_buffer(31 downto 2) & "00"; - when START_CPU => - DMNI_Receive <= DISCARD; - recv_size <= payload_fix + 2; - recv_address <= (others => '0'); - end case; - end if; - - when COPY_TO_MEM => - if (read_enable = '1' and read_av = '1') then - mem_byte_we <= "1111"; - mem_data_write <= bufferr(CONV_INTEGER(first)); - recv_address <= recv_address + WORD_SIZE; - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - DMNI_Receive <= FINISH; - end if; - else - mem_byte_we <= "0000"; - end if; - - when DISCARD => - recv_address <= (others => '0'); - mem_byte_we <= "0000"; - mem_data_write <= (others => '0'); - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - DMNI_Receive <= FINISH; - end if; - - when COPY_TO_MEM_DMA => - if (recv_size <= sizedata_fix) then - if (read_enable = '1' and read_av = '1') then - mem_byte_we <= "1111"; - mem_data_write <= bufferr(CONV_INTEGER(first)); - recv_address <= recv_address + WORD_SIZE; - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - dmma_done <= '1'; - DMNI_Receive <= FINISH; - end if; - else - mem_byte_we <= "0000"; - end if; - else - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - dmma_done <= '1'; - DMNI_Receive <= FINISH; - end if; - end if; - - when FINISH => - receive_active_2 <= '0'; - mem_byte_we <= "0000"; - recv_address <= (others => '0'); - recv_size <= (others => '0'); - DMNI_Receive <= WAIT_state; - when others => - end case; - end if; --rising_edge(clock) - end process proc_receive; - - intr_count <= intr_counter_temp; - intr <= '1' when intr_counter_temp > 0 else '0'; - reset_dmni <= reset_dmni_s; - - proc_send : process (clock, reset) - begin - if(reset = '1') then - DMNI_Send <= WAIT_state; - send_active_2 <= '0'; - tx <= '0'; - send_size <= (others => '0'); - send_size_2 <= (others => '0'); - send_address <= (others => '0'); - send_address_2 <= (others => '0'); - data_out <= (others => '0'); - elsif (clock'event and clock = '1') then - case DMNI_Send is - when WAIT_state => - if (start = '1' and operation = '0') then - send_address <= address; - send_address_2 <= address_2; - send_size <= size; - send_size_2 <= size_2; - send_active_2 <= '1'; - DMNI_Send <= LOAD; - assert address_router = x"0000" - report "Master sending msg" - severity note; - end if; - - when LOAD => - if(credit_i = '1' and write_enable = '1') then - send_address <= send_address + WORD_SIZE; - DMNI_Send <= COPY_FROM_MEM; - end if; - - when COPY_FROM_MEM => - if(credit_i = '1' and write_enable = '1') then - if(send_size > 0) then - tx <= '1'; - data_out <= mem_data_read; - send_address <= send_address + WORD_SIZE; - send_size <= send_size -1; - elsif (send_size_2 > 0) then - send_size <= send_size_2; - send_size_2 <= (others => '0'); - tx <= '0'; - if(send_address_2(30 downto 28) = "000") then - send_address <= send_address_2; - else - send_address <= send_address_2 - WORD_SIZE; - end if; - DMNI_Send <= LOAD; - else - tx <= '0'; - DMNI_Send <= FINISH; - end if; - else - if (credit_i = '0') then - send_size <= send_size + 1; - send_address <= send_address - WORD_SIZE - WORD_SIZE; -- address back 2 positions - else - send_address <= send_address - WORD_SIZE; -- address back 1 position - end if; - tx <= '0'; - DMNI_Send <= LOAD; - end if; - - when FINISH => - send_active_2 <= '0'; - send_address <= (others => '0'); - send_address_2 <= (others => '0'); - send_size <= (others => '0'); - send_size_2 <= (others => '0'); - DMNI_Send <= WAIT_state; - when others => - end case; - end if; --rising_edge(clock) - end process proc_send; -end dmni; +------------------------------------------------------------------------------------------------ +-- +-- DISTRIBUTED HEMPS - version 7.0 +-- +-- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br +-- +-- Distribution: May 2015 +-- +-- Source name: dmni.vhd +-- +-- Brief description: Implements a DMNI module. +-- +-- OPERATIONS: +-- 0 - Copy from memory +-- 1 - Copy to memory +--------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.std_logic_unsigned.all; +use ieee.std_logic_arith.all; +use work.hemps_pkg.all; +use work.standards.all; + +entity dmni is + generic(address_router : regmetadeflit := (others => '0')); + port( + clock : in std_logic; + reset : in std_logic; + -- Configuration interface + set_address : in std_logic; + set_address_2 : in std_logic; + set_size : in std_logic; + set_size_2 : in std_logic; + set_op : in std_logic; + start : in std_logic; + set_buff : in std_logic; + config_data : in std_logic_vector(31 downto 0); + -- Status outputs + intr : out std_logic; + send_active : out std_logic; + receive_active : out std_logic; + reset_dmni : out std_logic; + -- Memory interface + mem_address : out std_logic_vector(31 downto 0); + mem_data_write : out std_logic_vector(31 downto 0); + mem_data_read : in std_logic_vector(31 downto 0); + mem_byte_we : out std_logic_vector(3 downto 0); + -- Noc Interface (Local port) + tx : out std_logic; + data_out : out regflit; + credit_i : in std_logic; + clock_tx : out std_logic; + rx : in std_logic; + data_in : in regflit; + credit_o : out std_logic; + clock_rx : in std_logic); +end; + +architecture dmni of dmni is + + constant DMNI_TIMER : std_logic_vector(4 downto 0) := "10000"; + constant WORD_SIZE : std_logic_vector(4 downto 0) := "00100"; + + type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, DISCARD, FINISH); + type operation_type is (LEGACY, DMMA, START_CPU); + signal DMNI_Send : dmni_state; + signal DMNI_Receive : dmni_state; + + type noc_state is (HEADER, PAYLOAD, DATA); + signal SR : noc_state; + + type arbiter_state is (ROUND, SEND, RECEIVE); + signal ARB : arbiter_state; + + signal bufferr : buff_dmni := (others => (others => '0')); + subtype buffsizebool is std_logic_vector(0 to (TAM_BUFFER_DMNI-1)); + signal is_header : buffsizebool := (others => '0'); + signal intr_count : std_logic_vector(3 downto 0); + + signal first, last : pointer := (others => '0'); + signal add_buffer : std_logic; + + signal payload_size : regflit; + + signal timer : std_logic_vector(4 downto 0); + signal address : std_logic_vector(31 downto 0); + signal address_2 : std_logic_vector(31 downto 0); + signal size : std_logic_vector(31 downto 0); + signal size_2 : std_logic_vector(31 downto 0); + signal send_address : std_logic_vector(31 downto 0); + signal send_address_2 : std_logic_vector(31 downto 0); + signal send_size : std_logic_vector(31 downto 0); + signal send_size_2 : std_logic_vector(31 downto 0); + signal recv_address : std_logic_vector(31 downto 0); + signal recv_size : std_logic_vector(31 downto 0); + signal recv_buffer : std_logic_vector(31 downto 0); + signal dmma_done : std_logic; + signal prio : std_logic; + signal operation : std_logic; + signal read_av : std_logic; + signal slot_available : std_logic; + signal read_enable : std_logic; + signal write_enable : std_logic; + + signal send_active_2 : std_logic; + signal receive_active_2 : std_logic; + signal intr_counter_temp : std_logic_vector(3 downto 0); + + signal reset_dmni_s : std_logic; + signal payload_fix : regflit; + signal sizedata_fix : regflit; + signal recv_op : operation_type; +begin + --config + proc_config : process(clock) + begin + if reset = '1' then + recv_buffer <= (others => '0'); + elsif(clock'event and clock = '1') then + if (set_address = '1') then + address <= config_data; + address_2 <= (others => '0'); + elsif (set_address_2 = '1') then + address_2 <= config_data; + elsif (set_size = '1') then + size <= config_data; + size_2 <= (others => '0'); + elsif (set_size_2 = '1') then + size_2 <= config_data; + elsif (set_op = '1') then + operation <= config_data(0); + elsif set_buff = '1' then + recv_buffer <= config_data; + elsif dmma_done = '1' then + recv_buffer(0) <= '1'; + end if; + end if; + end process proc_config; + + mem_address <= send_address when write_enable = '1' else recv_address; + credit_o <= slot_available; + slot_available <= '0' when (first = last and add_buffer = '1') else '1'; + read_av <= '0' when (first = last and add_buffer = '0') else '1'; + clock_tx <= clock; + send_active <= send_active_2; + receive_active <= receive_active_2; + + arbiter : process (clock, reset) + begin + if reset = '1' then + read_enable <= '0'; + write_enable <= '0'; + timer <= "00000"; + prio <= '0'; + ARB <= ROUND; + elsif (clock'event and clock = '1') then + case ARB is + when ROUND => + if prio = '0' then + if (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then + ARB <= RECEIVE; + read_enable <= '1'; + elsif send_active_2 = '1' then + ARB <= SEND; + write_enable <= '1'; + end if; + else + if send_active_2 = '1' then + ARB <= SEND; + write_enable <= '1'; + elsif (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then + ARB <= RECEIVE; + read_enable <= '1'; + end if; + end if; + + when SEND => + if DMNI_Send = FINISH or (timer = DMNI_TIMER and receive_active_2 = '1') then + timer <= "00000"; + ARB <= ROUND; + write_enable <= '0'; + prio <= not prio; + else + timer <= timer + '1'; + end if; + + when RECEIVE => + if DMNI_Receive = FINISH or (timer = DMNI_TIMER and send_active_2 = '1') then + timer <= "00000"; + ARB <= ROUND; + read_enable <= '0'; + prio <= not prio; + else + timer <= timer + '1'; + end if; + end case; + end if; + end process arbiter; + + proc_receive : process (clock, reset) + begin + if (reset = '1') then + reset_dmni_s <= '1'; + payload_fix <= (others => '0'); + sizedata_fix <= (others => '0'); + recv_op <= LEGACY; + dmma_done <= '0'; + first <= (others => '0'); + last <= (others => '0'); + payload_size <= (others => '0'); + SR <= HEADER; + add_buffer <= '0'; + receive_active_2 <= '0'; + DMNI_Receive <= WAIT_state; + recv_address <= (others => '0'); + recv_size <= (others => '0'); + mem_data_write <= (others => '0'); + is_header <= (others => '0'); + intr_counter_temp <= (others => '0'); + mem_byte_we <= (others => '0'); + elsif (clock'event and clock = '1') then + if (rx = '1' and slot_available = '1') then + bufferr(CONV_INTEGER(last)) <= data_in; + add_buffer <= '1'; + last <= last + 1; + + --Read from NoC + case SR is + when HEADER => + intr_counter_temp <= intr_counter_temp + 1; + assert address_router = x"0000" + report "Master receiving msg" + severity note; + is_header(CONV_INTEGER(last)) <= '1'; + SR <= PAYLOAD; + when PAYLOAD => + is_header(CONV_INTEGER(last)) <= '0'; + payload_size <= data_in - 1; + payload_fix <= data_in - 1; + sizedata_fix <= data_in - 2; + SR <= DATA; + when DATA => + is_header(CONV_INTEGER(last)) <= '0'; + if(payload_size = 0) then + SR <= HEADER; + recv_op <= LEGACY; + else + payload_size <= payload_size - 1; + + if (payload_size = payload_fix) then + if (data_in = x"00000300") then --Service 300 start_cpu + reset_dmni_s <= '0'; + recv_op <= START_CPU; + end if; + end if; + if (payload_size = payload_fix) then + if (data_in = x"00000290") then --Service 290 dmni_operation + recv_op <= DMMA; + end if; + end if; + end if; + end case; + end if; --(rx ='1' and slot_available = '1') + + --Write to memory + case DMNI_Receive is + when WAIT_state => + if ( (recv_op = LEGACY and start = '1' and operation = '1') or (recv_op = DMMA and recv_buffer (0) = '0') or (recv_op = START_CPU) )then + if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then + intr_counter_temp <= intr_counter_temp -1; + end if; + receive_active_2 <= '1'; + + case recv_op is + when LEGACY => + DMNI_Receive <= COPY_TO_MEM; + recv_size <= size - 1; + recv_address <= address - WORD_SIZE; + when DMMA => + DMNI_Receive <= COPY_TO_MEM_DMA; + recv_size <= payload_fix + 2; + recv_address <= recv_buffer(31 downto 2) & "00"; + when START_CPU => + DMNI_Receive <= DISCARD; + recv_size <= payload_fix + 2; + recv_address <= (others => '0'); + end case; + end if; + + when COPY_TO_MEM => + if (read_enable = '1' and read_av = '1') then + mem_byte_we <= "1111"; + mem_data_write <= bufferr(CONV_INTEGER(first)); + recv_address <= recv_address + WORD_SIZE; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + else + mem_byte_we <= "0000"; + end if; + + when DISCARD => + recv_address <= (others => '0'); + mem_byte_we <= "0000"; + mem_data_write <= (others => '0'); + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + + when COPY_TO_MEM_DMA => + if (recv_size <= sizedata_fix) then + if (read_enable = '1' and read_av = '1') then + mem_byte_we <= "1111"; + mem_data_write <= bufferr(CONV_INTEGER(first)); + recv_address <= recv_address + WORD_SIZE; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + dmma_done <= '1'; + DMNI_Receive <= FINISH; + end if; + else + mem_byte_we <= "0000"; + end if; + else + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + dmma_done <= '1'; + DMNI_Receive <= FINISH; + end if; + end if; + + when FINISH => + receive_active_2 <= '0'; + mem_byte_we <= "0000"; + recv_address <= (others => '0'); + recv_size <= (others => '0'); + DMNI_Receive <= WAIT_state; + when others => + end case; + end if; --rising_edge(clock) + end process proc_receive; + + intr_count <= intr_counter_temp; + intr <= '1' when intr_counter_temp > 0 else '0'; + reset_dmni <= reset_dmni_s; + + proc_send : process (clock, reset) + begin + if(reset = '1') then + DMNI_Send <= WAIT_state; + send_active_2 <= '0'; + tx <= '0'; + send_size <= (others => '0'); + send_size_2 <= (others => '0'); + send_address <= (others => '0'); + send_address_2 <= (others => '0'); + data_out <= (others => '0'); + elsif (clock'event and clock = '1') then + case DMNI_Send is + when WAIT_state => + if (start = '1' and operation = '0') then + send_address <= address; + send_address_2 <= address_2; + send_size <= size; + send_size_2 <= size_2; + send_active_2 <= '1'; + DMNI_Send <= LOAD; + assert address_router = x"0000" + report "Master sending msg" + severity note; + end if; + + when LOAD => + if(credit_i = '1' and write_enable = '1') then + send_address <= send_address + WORD_SIZE; + DMNI_Send <= COPY_FROM_MEM; + end if; + + when COPY_FROM_MEM => + if(credit_i = '1' and write_enable = '1') then + if(send_size > 0) then + tx <= '1'; + data_out <= mem_data_read; + send_address <= send_address + WORD_SIZE; + send_size <= send_size -1; + elsif (send_size_2 > 0) then + send_size <= send_size_2; + send_size_2 <= (others => '0'); + tx <= '0'; + if(send_address_2(30 downto 28) = "000") then + send_address <= send_address_2; + else + send_address <= send_address_2 - WORD_SIZE; + end if; + DMNI_Send <= LOAD; + else + tx <= '0'; + DMNI_Send <= FINISH; + end if; + else + if (credit_i = '0') then + send_size <= send_size + 1; + send_address <= send_address - WORD_SIZE - WORD_SIZE; -- address back 2 positions + else + send_address <= send_address - WORD_SIZE; -- address back 1 position + end if; + tx <= '0'; + DMNI_Send <= LOAD; + end if; + + when FINISH => + send_active_2 <= '0'; + send_address <= (others => '0'); + send_address_2 <= (others => '0'); + send_size <= (others => '0'); + send_size_2 <= (others => '0'); + DMNI_Send <= WAIT_state; + when others => + end case; + end if; --rising_edge(clock) + end process proc_send; +end dmni; \ No newline at end of file From c3c3e5149a289bf4e78babe15a8aa2e4fdee1f91 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Thu, 19 Oct 2017 16:04:45 -0200 Subject: [PATCH 23/54] DMNI DMMA Receive Buffer mapped into processor address space --- applications/transmit/receive.c | 15 +- hardware/vhdl/pe/dmni/dmni.vhd | 866 ++++++++++++++++---------------- hardware/vhdl/pe/pe.vhd | 18 +- 3 files changed, 450 insertions(+), 449 deletions(-) diff --git a/applications/transmit/receive.c b/applications/transmit/receive.c index bb696b4..ab73ffb 100644 --- a/applications/transmit/receive.c +++ b/applications/transmit/receive.c @@ -199,19 +199,18 @@ void read_packet(ServiceHeader *p){ MemoryWrite(DMNI_SIZE, 6); MemoryWrite(DMNI_OP, WRITE); - MemoryWrite(DMNI_ADDRESS, 0x4001); + MemoryWrite(DMNI_ADDRESS, 0x4000); MemoryWrite(DMNI_START, 1); //Waits the DMNI copy all data to memory before release the software to access it //while (noc_interruption != 1) while (MemoryRead(DMNI_RECEIVE_ACTIVE)); - p = 0x4001; + p = 0x4000; } - int main() { volatile ServiceHeader p; @@ -247,10 +246,10 @@ int main() int data_receive[4]; - data_receive[0] = MemoryRead(0x4001); - data_receive[1] = MemoryRead(0x4002); - data_receive[2] = MemoryRead(0x4003); - data_receive[3] = 4; + data_receive[0] = MemoryRead(0x4000); + data_receive[1] = MemoryRead(0x4004); + data_receive[2] = MemoryRead(0x4008); + data_receive[3] = MemoryRead(0x400C); transmite(0x00000101 ,MESSAGE_DELIVERY, data_receive ,4); @@ -271,4 +270,4 @@ int main() USO: int message[30] transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) -*/ \ No newline at end of file +*/ diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index a058f91..98e8987 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -1,433 +1,433 @@ ------------------------------------------------------------------------------------------------- --- --- DISTRIBUTED HEMPS - version 7.0 --- --- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br --- --- Distribution: May 2015 --- --- Source name: dmni.vhd --- --- Brief description: Implements a DMNI module. --- --- OPERATIONS: --- 0 - Copy from memory --- 1 - Copy to memory ---------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.std_logic_unsigned.all; -use ieee.std_logic_arith.all; -use work.hemps_pkg.all; -use work.standards.all; - -entity dmni is - generic(address_router : regmetadeflit := (others => '0')); - port( - clock : in std_logic; - reset : in std_logic; - -- Configuration interface - set_address : in std_logic; - set_address_2 : in std_logic; - set_size : in std_logic; - set_size_2 : in std_logic; - set_op : in std_logic; - start : in std_logic; - set_buff : in std_logic; - config_data : in std_logic_vector(31 downto 0); - -- Status outputs - intr : out std_logic; - send_active : out std_logic; - receive_active : out std_logic; - reset_dmni : out std_logic; - -- Memory interface - mem_address : out std_logic_vector(31 downto 0); - mem_data_write : out std_logic_vector(31 downto 0); - mem_data_read : in std_logic_vector(31 downto 0); - mem_byte_we : out std_logic_vector(3 downto 0); - -- Noc Interface (Local port) - tx : out std_logic; - data_out : out regflit; - credit_i : in std_logic; - clock_tx : out std_logic; - rx : in std_logic; - data_in : in regflit; - credit_o : out std_logic; - clock_rx : in std_logic); -end; - -architecture dmni of dmni is - - constant DMNI_TIMER : std_logic_vector(4 downto 0) := "10000"; - constant WORD_SIZE : std_logic_vector(4 downto 0) := "00100"; - - type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, DISCARD, FINISH); - type operation_type is (LEGACY, DMMA, START_CPU); - signal DMNI_Send : dmni_state; - signal DMNI_Receive : dmni_state; - - type noc_state is (HEADER, PAYLOAD, DATA); - signal SR : noc_state; - - type arbiter_state is (ROUND, SEND, RECEIVE); - signal ARB : arbiter_state; - - signal bufferr : buff_dmni := (others => (others => '0')); - subtype buffsizebool is std_logic_vector(0 to (TAM_BUFFER_DMNI-1)); - signal is_header : buffsizebool := (others => '0'); - signal intr_count : std_logic_vector(3 downto 0); - - signal first, last : pointer := (others => '0'); - signal add_buffer : std_logic; - - signal payload_size : regflit; - - signal timer : std_logic_vector(4 downto 0); - signal address : std_logic_vector(31 downto 0); - signal address_2 : std_logic_vector(31 downto 0); - signal size : std_logic_vector(31 downto 0); - signal size_2 : std_logic_vector(31 downto 0); - signal send_address : std_logic_vector(31 downto 0); - signal send_address_2 : std_logic_vector(31 downto 0); - signal send_size : std_logic_vector(31 downto 0); - signal send_size_2 : std_logic_vector(31 downto 0); - signal recv_address : std_logic_vector(31 downto 0); - signal recv_size : std_logic_vector(31 downto 0); - signal recv_buffer : std_logic_vector(31 downto 0); - signal dmma_done : std_logic; - signal prio : std_logic; - signal operation : std_logic; - signal read_av : std_logic; - signal slot_available : std_logic; - signal read_enable : std_logic; - signal write_enable : std_logic; - - signal send_active_2 : std_logic; - signal receive_active_2 : std_logic; - signal intr_counter_temp : std_logic_vector(3 downto 0); - - signal reset_dmni_s : std_logic; - signal payload_fix : regflit; - signal sizedata_fix : regflit; - signal recv_op : operation_type; -begin - --config - proc_config : process(clock) - begin - if reset = '1' then - recv_buffer <= (others => '0'); - elsif(clock'event and clock = '1') then - if (set_address = '1') then - address <= config_data; - address_2 <= (others => '0'); - elsif (set_address_2 = '1') then - address_2 <= config_data; - elsif (set_size = '1') then - size <= config_data; - size_2 <= (others => '0'); - elsif (set_size_2 = '1') then - size_2 <= config_data; - elsif (set_op = '1') then - operation <= config_data(0); - elsif set_buff = '1' then - recv_buffer <= config_data; - elsif dmma_done = '1' then - recv_buffer(0) <= '1'; - end if; - end if; - end process proc_config; - - mem_address <= send_address when write_enable = '1' else recv_address; - credit_o <= slot_available; - slot_available <= '0' when (first = last and add_buffer = '1') else '1'; - read_av <= '0' when (first = last and add_buffer = '0') else '1'; - clock_tx <= clock; - send_active <= send_active_2; - receive_active <= receive_active_2; - - arbiter : process (clock, reset) - begin - if reset = '1' then - read_enable <= '0'; - write_enable <= '0'; - timer <= "00000"; - prio <= '0'; - ARB <= ROUND; - elsif (clock'event and clock = '1') then - case ARB is - when ROUND => - if prio = '0' then - if (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then - ARB <= RECEIVE; - read_enable <= '1'; - elsif send_active_2 = '1' then - ARB <= SEND; - write_enable <= '1'; - end if; - else - if send_active_2 = '1' then - ARB <= SEND; - write_enable <= '1'; - elsif (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then - ARB <= RECEIVE; - read_enable <= '1'; - end if; - end if; - - when SEND => - if DMNI_Send = FINISH or (timer = DMNI_TIMER and receive_active_2 = '1') then - timer <= "00000"; - ARB <= ROUND; - write_enable <= '0'; - prio <= not prio; - else - timer <= timer + '1'; - end if; - - when RECEIVE => - if DMNI_Receive = FINISH or (timer = DMNI_TIMER and send_active_2 = '1') then - timer <= "00000"; - ARB <= ROUND; - read_enable <= '0'; - prio <= not prio; - else - timer <= timer + '1'; - end if; - end case; - end if; - end process arbiter; - - proc_receive : process (clock, reset) - begin - if (reset = '1') then - reset_dmni_s <= '1'; - payload_fix <= (others => '0'); - sizedata_fix <= (others => '0'); - recv_op <= LEGACY; - dmma_done <= '0'; - first <= (others => '0'); - last <= (others => '0'); - payload_size <= (others => '0'); - SR <= HEADER; - add_buffer <= '0'; - receive_active_2 <= '0'; - DMNI_Receive <= WAIT_state; - recv_address <= (others => '0'); - recv_size <= (others => '0'); - mem_data_write <= (others => '0'); - is_header <= (others => '0'); - intr_counter_temp <= (others => '0'); - mem_byte_we <= (others => '0'); - elsif (clock'event and clock = '1') then - if (rx = '1' and slot_available = '1') then - bufferr(CONV_INTEGER(last)) <= data_in; - add_buffer <= '1'; - last <= last + 1; - - --Read from NoC - case SR is - when HEADER => - intr_counter_temp <= intr_counter_temp + 1; - assert address_router = x"0000" - report "Master receiving msg" - severity note; - is_header(CONV_INTEGER(last)) <= '1'; - SR <= PAYLOAD; - when PAYLOAD => - is_header(CONV_INTEGER(last)) <= '0'; - payload_size <= data_in - 1; - payload_fix <= data_in - 1; - sizedata_fix <= data_in - 2; - SR <= DATA; - when DATA => - is_header(CONV_INTEGER(last)) <= '0'; - if(payload_size = 0) then - SR <= HEADER; - recv_op <= LEGACY; - else - payload_size <= payload_size - 1; - - if (payload_size = payload_fix) then - if (data_in = x"00000300") then --Service 300 start_cpu - reset_dmni_s <= '0'; - recv_op <= START_CPU; - end if; - end if; - if (payload_size = payload_fix) then - if (data_in = x"00000290") then --Service 290 dmni_operation - recv_op <= DMMA; - end if; - end if; - end if; - end case; - end if; --(rx ='1' and slot_available = '1') - - --Write to memory - case DMNI_Receive is - when WAIT_state => - if ( (recv_op = LEGACY and start = '1' and operation = '1') or (recv_op = DMMA and recv_buffer (0) = '0') or (recv_op = START_CPU) )then - if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then - intr_counter_temp <= intr_counter_temp -1; - end if; - receive_active_2 <= '1'; - - case recv_op is - when LEGACY => - DMNI_Receive <= COPY_TO_MEM; - recv_size <= size - 1; - recv_address <= address - WORD_SIZE; - when DMMA => - DMNI_Receive <= COPY_TO_MEM_DMA; - recv_size <= payload_fix + 2; - recv_address <= recv_buffer(31 downto 2) & "00"; - when START_CPU => - DMNI_Receive <= DISCARD; - recv_size <= payload_fix + 2; - recv_address <= (others => '0'); - end case; - end if; - - when COPY_TO_MEM => - if (read_enable = '1' and read_av = '1') then - mem_byte_we <= "1111"; - mem_data_write <= bufferr(CONV_INTEGER(first)); - recv_address <= recv_address + WORD_SIZE; - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - DMNI_Receive <= FINISH; - end if; - else - mem_byte_we <= "0000"; - end if; - - when DISCARD => - recv_address <= (others => '0'); - mem_byte_we <= "0000"; - mem_data_write <= (others => '0'); - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - DMNI_Receive <= FINISH; - end if; - - when COPY_TO_MEM_DMA => - if (recv_size <= sizedata_fix) then - if (read_enable = '1' and read_av = '1') then - mem_byte_we <= "1111"; - mem_data_write <= bufferr(CONV_INTEGER(first)); - recv_address <= recv_address + WORD_SIZE; - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - dmma_done <= '1'; - DMNI_Receive <= FINISH; - end if; - else - mem_byte_we <= "0000"; - end if; - else - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - dmma_done <= '1'; - DMNI_Receive <= FINISH; - end if; - end if; - - when FINISH => - receive_active_2 <= '0'; - mem_byte_we <= "0000"; - recv_address <= (others => '0'); - recv_size <= (others => '0'); - DMNI_Receive <= WAIT_state; - when others => - end case; - end if; --rising_edge(clock) - end process proc_receive; - - intr_count <= intr_counter_temp; - intr <= '1' when intr_counter_temp > 0 else '0'; - reset_dmni <= reset_dmni_s; - - proc_send : process (clock, reset) - begin - if(reset = '1') then - DMNI_Send <= WAIT_state; - send_active_2 <= '0'; - tx <= '0'; - send_size <= (others => '0'); - send_size_2 <= (others => '0'); - send_address <= (others => '0'); - send_address_2 <= (others => '0'); - data_out <= (others => '0'); - elsif (clock'event and clock = '1') then - case DMNI_Send is - when WAIT_state => - if (start = '1' and operation = '0') then - send_address <= address; - send_address_2 <= address_2; - send_size <= size; - send_size_2 <= size_2; - send_active_2 <= '1'; - DMNI_Send <= LOAD; - assert address_router = x"0000" - report "Master sending msg" - severity note; - end if; - - when LOAD => - if(credit_i = '1' and write_enable = '1') then - send_address <= send_address + WORD_SIZE; - DMNI_Send <= COPY_FROM_MEM; - end if; - - when COPY_FROM_MEM => - if(credit_i = '1' and write_enable = '1') then - if(send_size > 0) then - tx <= '1'; - data_out <= mem_data_read; - send_address <= send_address + WORD_SIZE; - send_size <= send_size -1; - elsif (send_size_2 > 0) then - send_size <= send_size_2; - send_size_2 <= (others => '0'); - tx <= '0'; - if(send_address_2(30 downto 28) = "000") then - send_address <= send_address_2; - else - send_address <= send_address_2 - WORD_SIZE; - end if; - DMNI_Send <= LOAD; - else - tx <= '0'; - DMNI_Send <= FINISH; - end if; - else - if (credit_i = '0') then - send_size <= send_size + 1; - send_address <= send_address - WORD_SIZE - WORD_SIZE; -- address back 2 positions - else - send_address <= send_address - WORD_SIZE; -- address back 1 position - end if; - tx <= '0'; - DMNI_Send <= LOAD; - end if; - - when FINISH => - send_active_2 <= '0'; - send_address <= (others => '0'); - send_address_2 <= (others => '0'); - send_size <= (others => '0'); - send_size_2 <= (others => '0'); - DMNI_Send <= WAIT_state; - when others => - end case; - end if; --rising_edge(clock) - end process proc_send; -end dmni; \ No newline at end of file +------------------------------------------------------------------------------------------------ +-- +-- DISTRIBUTED HEMPS - version 7.0 +-- +-- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br +-- +-- Distribution: May 2015 +-- +-- Source name: dmni.vhd +-- +-- Brief description: Implements a DMNI module. +-- +-- OPERATIONS: +-- 0 - Copy from memory +-- 1 - Copy to memory +--------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.std_logic_unsigned.all; +use ieee.std_logic_arith.all; +use work.hemps_pkg.all; +use work.standards.all; + +entity dmni is + generic(address_router : regmetadeflit := (others => '0')); + port( + clock : in std_logic; + reset : in std_logic; + -- Configuration interface + set_address : in std_logic; + set_address_2 : in std_logic; + set_size : in std_logic; + set_size_2 : in std_logic; + set_op : in std_logic; + start : in std_logic; + set_buff : in std_logic; + config_data : in std_logic_vector(31 downto 0); + -- Status outputs + intr : out std_logic; + send_active : out std_logic; + receive_active : out std_logic; + reset_dmni : out std_logic; + -- Memory interface + mem_address : out std_logic_vector(31 downto 0); + mem_data_write : out std_logic_vector(31 downto 0); + mem_data_read : in std_logic_vector(31 downto 0); + mem_byte_we : out std_logic_vector(3 downto 0); + -- Noc Interface (Local port) + tx : out std_logic; + data_out : out regflit; + credit_i : in std_logic; + clock_tx : out std_logic; + rx : in std_logic; + data_in : in regflit; + credit_o : out std_logic; + clock_rx : in std_logic); +end; + +architecture dmni of dmni is + + constant DMNI_TIMER : std_logic_vector(4 downto 0) := "10000"; + constant WORD_SIZE : std_logic_vector(4 downto 0) := "00100"; + + type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, DISCARD, FINISH); + type operation_type is (LEGACY, DMMA, START_CPU); + signal DMNI_Send : dmni_state; + signal DMNI_Receive : dmni_state; + + type noc_state is (HEADER, PAYLOAD, DATA); + signal SR : noc_state; + + type arbiter_state is (ROUND, SEND, RECEIVE); + signal ARB : arbiter_state; + + signal bufferr : buff_dmni := (others => (others => '0')); + subtype buffsizebool is std_logic_vector(0 to (TAM_BUFFER_DMNI-1)); + signal is_header : buffsizebool := (others => '0'); + signal intr_count : std_logic_vector(3 downto 0); + + signal first, last : pointer := (others => '0'); + signal add_buffer : std_logic; + + signal payload_size : regflit; + + signal timer : std_logic_vector(4 downto 0); + signal address : std_logic_vector(31 downto 0); + signal address_2 : std_logic_vector(31 downto 0); + signal size : std_logic_vector(31 downto 0); + signal size_2 : std_logic_vector(31 downto 0); + signal send_address : std_logic_vector(31 downto 0); + signal send_address_2 : std_logic_vector(31 downto 0); + signal send_size : std_logic_vector(31 downto 0); + signal send_size_2 : std_logic_vector(31 downto 0); + signal recv_address : std_logic_vector(31 downto 0); + signal recv_size : std_logic_vector(31 downto 0); + signal recv_buffer : std_logic_vector(31 downto 0); + signal dmma_done : std_logic; + signal prio : std_logic; + signal operation : std_logic; + signal read_av : std_logic; + signal slot_available : std_logic; + signal read_enable : std_logic; + signal write_enable : std_logic; + + signal send_active_2 : std_logic; + signal receive_active_2 : std_logic; + signal intr_counter_temp : std_logic_vector(3 downto 0); + + signal reset_dmni_s : std_logic; + signal payload_fix : regflit; + signal sizedata_fix : regflit; + signal recv_op : operation_type; +begin + --config + proc_config : process(clock) + begin + if reset = '1' then + recv_buffer <= (others => '0'); + elsif(clock'event and clock = '1') then + if (set_address = '1') then + address <= config_data; + address_2 <= (others => '0'); + elsif (set_address_2 = '1') then + address_2 <= config_data; + elsif (set_size = '1') then + size <= config_data; + size_2 <= (others => '0'); + elsif (set_size_2 = '1') then + size_2 <= config_data; + elsif (set_op = '1') then + operation <= config_data(0); + elsif set_buff = '1' then + recv_buffer <= config_data; + elsif dmma_done = '1' then + recv_buffer(0) <= '1'; + end if; + end if; + end process proc_config; + + mem_address <= send_address when write_enable = '1' else recv_address; + credit_o <= slot_available; + slot_available <= '0' when (first = last and add_buffer = '1') else '1'; + read_av <= '0' when (first = last and add_buffer = '0') else '1'; + clock_tx <= clock; + send_active <= send_active_2; + receive_active <= receive_active_2; + + arbiter : process (clock, reset) + begin + if reset = '1' then + read_enable <= '0'; + write_enable <= '0'; + timer <= "00000"; + prio <= '0'; + ARB <= ROUND; + elsif (clock'event and clock = '1') then + case ARB is + when ROUND => + if prio = '0' then + if (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then + ARB <= RECEIVE; + read_enable <= '1'; + elsif send_active_2 = '1' then + ARB <= SEND; + write_enable <= '1'; + end if; + else + if send_active_2 = '1' then + ARB <= SEND; + write_enable <= '1'; + elsif (DMNI_Receive = COPY_TO_MEM or DMNI_Receive = COPY_TO_MEM_DMA) then + ARB <= RECEIVE; + read_enable <= '1'; + end if; + end if; + + when SEND => + if DMNI_Send = FINISH or (timer = DMNI_TIMER and receive_active_2 = '1') then + timer <= "00000"; + ARB <= ROUND; + write_enable <= '0'; + prio <= not prio; + else + timer <= timer + '1'; + end if; + + when RECEIVE => + if DMNI_Receive = FINISH or (timer = DMNI_TIMER and send_active_2 = '1') then + timer <= "00000"; + ARB <= ROUND; + read_enable <= '0'; + prio <= not prio; + else + timer <= timer + '1'; + end if; + end case; + end if; + end process arbiter; + + proc_receive : process (clock, reset) + begin + if (reset = '1') then + reset_dmni_s <= '1'; + payload_fix <= (others => '0'); + sizedata_fix <= (others => '0'); + recv_op <= LEGACY; + dmma_done <= '0'; + first <= (others => '0'); + last <= (others => '0'); + payload_size <= (others => '0'); + SR <= HEADER; + add_buffer <= '0'; + receive_active_2 <= '0'; + DMNI_Receive <= WAIT_state; + recv_address <= (others => '0'); + recv_size <= (others => '0'); + mem_data_write <= (others => '0'); + is_header <= (others => '0'); + intr_counter_temp <= (others => '0'); + mem_byte_we <= (others => '0'); + elsif (clock'event and clock = '1') then + if (rx = '1' and slot_available = '1') then + bufferr(CONV_INTEGER(last)) <= data_in; + add_buffer <= '1'; + last <= last + 1; + + --Read from NoC + case SR is + when HEADER => + intr_counter_temp <= intr_counter_temp + 1; + assert address_router = x"0000" + report "Master receiving msg" + severity note; + is_header(CONV_INTEGER(last)) <= '1'; + SR <= PAYLOAD; + when PAYLOAD => + is_header(CONV_INTEGER(last)) <= '0'; + payload_size <= data_in - 1; + payload_fix <= data_in - 1; + sizedata_fix <= data_in - 2; + SR <= DATA; + when DATA => + is_header(CONV_INTEGER(last)) <= '0'; + if(payload_size = 0) then + SR <= HEADER; + recv_op <= LEGACY; + else + payload_size <= payload_size - 1; + + if (payload_size = payload_fix) then + if (data_in = x"00000300") then --Service 300 start_cpu + reset_dmni_s <= '0'; + recv_op <= START_CPU; + end if; + end if; + if (payload_size = payload_fix) then + if (data_in = x"00000290") then --Service 290 dmni_operation + recv_op <= DMMA; + end if; + end if; + end if; + end case; + end if; --(rx ='1' and slot_available = '1') + + --Write to memory + case DMNI_Receive is + when WAIT_state => + if ((recv_op = LEGACY and start = '1' and operation = '1') or (recv_op = DMMA and recv_buffer (0) = '0') or (recv_op = START_CPU))then + if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then + intr_counter_temp <= intr_counter_temp -1; + end if; + receive_active_2 <= '1'; + + case recv_op is + when LEGACY => + DMNI_Receive <= COPY_TO_MEM; + recv_size <= size - 1; + recv_address <= address - WORD_SIZE; + when DMMA => + DMNI_Receive <= COPY_TO_MEM_DMA; + recv_size <= payload_fix + 2; + recv_address <= recv_buffer(31 downto 2) & "00"; + when START_CPU => + DMNI_Receive <= DISCARD; + recv_size <= payload_fix + 2; + recv_address <= (others => '0'); + end case; + end if; + + when COPY_TO_MEM => + if (read_enable = '1' and read_av = '1') then + mem_byte_we <= "1111"; + mem_data_write <= bufferr(CONV_INTEGER(first)); + recv_address <= recv_address + WORD_SIZE; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + else + mem_byte_we <= "0000"; + end if; + + when DISCARD => + recv_address <= (others => '0'); + mem_byte_we <= "0000"; + mem_data_write <= (others => '0'); + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + + when COPY_TO_MEM_DMA => + if (recv_size <= sizedata_fix) then + if (read_enable = '1' and read_av = '1') then + mem_byte_we <= "1111"; + mem_data_write <= bufferr(CONV_INTEGER(first)); + recv_address <= recv_address + WORD_SIZE; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + dmma_done <= '1'; + DMNI_Receive <= FINISH; + end if; + else + mem_byte_we <= "0000"; + end if; + else + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + dmma_done <= '1'; + DMNI_Receive <= FINISH; + end if; + end if; + + when FINISH => + receive_active_2 <= '0'; + mem_byte_we <= "0000"; + recv_address <= (others => '0'); + recv_size <= (others => '0'); + DMNI_Receive <= WAIT_state; + when others => + end case; + end if; --rising_edge(clock) + end process proc_receive; + + intr_count <= intr_counter_temp; + intr <= '1' when intr_counter_temp > 0 else '0'; + reset_dmni <= reset_dmni_s; + + proc_send : process (clock, reset) + begin + if(reset = '1') then + DMNI_Send <= WAIT_state; + send_active_2 <= '0'; + tx <= '0'; + send_size <= (others => '0'); + send_size_2 <= (others => '0'); + send_address <= (others => '0'); + send_address_2 <= (others => '0'); + data_out <= (others => '0'); + elsif (clock'event and clock = '1') then + case DMNI_Send is + when WAIT_state => + if (start = '1' and operation = '0') then + send_address <= address; + send_address_2 <= address_2; + send_size <= size; + send_size_2 <= size_2; + send_active_2 <= '1'; + DMNI_Send <= LOAD; + assert address_router = x"0000" + report "Master sending msg" + severity note; + end if; + + when LOAD => + if(credit_i = '1' and write_enable = '1') then + send_address <= send_address + WORD_SIZE; + DMNI_Send <= COPY_FROM_MEM; + end if; + + when COPY_FROM_MEM => + if(credit_i = '1' and write_enable = '1') then + if(send_size > 0) then + tx <= '1'; + data_out <= mem_data_read; + send_address <= send_address + WORD_SIZE; + send_size <= send_size -1; + elsif (send_size_2 > 0) then + send_size <= send_size_2; + send_size_2 <= (others => '0'); + tx <= '0'; + if(send_address_2(30 downto 28) = "000") then + send_address <= send_address_2; + else + send_address <= send_address_2 - WORD_SIZE; + end if; + DMNI_Send <= LOAD; + else + tx <= '0'; + DMNI_Send <= FINISH; + end if; + else + if (credit_i = '0') then + send_size <= send_size + 1; + send_address <= send_address - WORD_SIZE - WORD_SIZE; -- address back 2 positions + else + send_address <= send_address - WORD_SIZE; -- address back 1 position + end if; + tx <= '0'; + DMNI_Send <= LOAD; + end if; + + when FINISH => + send_active_2 <= '0'; + send_address <= (others => '0'); + send_address_2 <= (others => '0'); + send_size <= (others => '0'); + send_size_2 <= (others => '0'); + DMNI_Send <= WAIT_state; + when others => + end case; + end if; --rising_edge(clock) + end process proc_send; +end dmni; diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index e224e4c..a8b0604 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -79,6 +79,7 @@ architecture structural of pe is signal cpu_set_address_2 : std_logic; signal cpu_set_op : std_logic; signal cpu_start : std_logic; + signal cpu_set_buff : std_logic; signal clock_aux : std_logic; signal clock_hold_s : std_logic; signal pending_service : std_logic; @@ -212,8 +213,7 @@ begin dmni : entity work.dmni generic map( - address_router => router_address - ) + address_router => router_address) port map( clock => clock, reset => reset, @@ -225,6 +225,7 @@ begin set_op => cpu_set_op, start => cpu_start, config_data => dmni_data_read, + set_buff => cpu_set_buff, -- Status outputs intr => ni_intr, @@ -324,12 +325,13 @@ begin irq_status(1) <= '1' when dmni_send_active_sig = '0' and slack_update_timer = SLACK_MONITOR_WINDOW else '0'; irq_status(0) <= (not dmni_send_active_sig and pending_service); - cpu_set_size <= '1' when cpu_mem_address_reg = DMNI_SIZE and write_enable = '1' else '0'; - cpu_set_address <= '1' when cpu_mem_address_reg = DMNI_ADDR and write_enable = '1' else '0'; - cpu_set_size_2 <= '1' when cpu_mem_address_reg = DMNI_SIZE_2 and write_enable = '1' else '0'; - cpu_set_address_2 <= '1' when cpu_mem_address_reg = DMNI_ADDR_2 and write_enable = '1' else '0'; - cpu_set_op <= '1' when (cpu_mem_address_reg = DMNI_OP and write_enable = '1') else '0'; - cpu_start <= '1' when (cpu_mem_address_reg = START_DMNI and write_enable = '1') else '0'; + cpu_set_size <= '1' when cpu_mem_address_reg = DMNI_SIZE and write_enable = '1' else '0'; + cpu_set_address <= '1' when cpu_mem_address_reg = DMNI_ADDR and write_enable = '1' else '0'; + cpu_set_size_2 <= '1' when cpu_mem_address_reg = DMNI_SIZE_2 and write_enable = '1' else '0'; + cpu_set_address_2 <= '1' when cpu_mem_address_reg = DMNI_ADDR_2 and write_enable = '1' else '0'; + cpu_set_op <= '1' when cpu_mem_address_reg = DMNI_OP and write_enable = '1' else '0'; + cpu_start <= '1' when cpu_mem_address_reg = START_DMNI and write_enable = '1' else '0'; + cpu_set_buff <= '1' when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER and write_enable = '1' else '0'; write_enable <= '1' when cpu_mem_write_byte_enable_reg /= "0000" else '0'; From 8d280d8963ba1ac9fc01d25152a1fdf57d3ad7b6 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 20 Oct 2017 18:13:03 -0200 Subject: [PATCH 24/54] IPC Implemented --- applications/transmit/receive.c | 266 +++---- applications/transmit/transmit.c | 387 +++++------ build_env/bin/hemps-wave_gen | 31 +- build_env/bin/payload_builder.py | 32 + build_env/makes/make_app | 2 +- hardware/vhdl/pe/dmni/dmni.vhd | 7 +- hardware/vhdl/pe/pe.vhd | 6 +- .../vhdl/pe/processor/plasma/UartFile.vhd | 179 ++--- software/boot_task/boot_task.asm | 96 +-- software/kernel/master/kernel_master.c | 655 +++--------------- software/kernel/master/receive.h | 253 +++++++ software/kernel/master/transmit.h | 237 +++++++ software/modules/packet.h | 2 +- 13 files changed, 1004 insertions(+), 1149 deletions(-) create mode 100755 build_env/bin/payload_builder.py create mode 100644 software/kernel/master/receive.h create mode 100644 software/kernel/master/transmit.h diff --git a/applications/transmit/receive.c b/applications/transmit/receive.c index ab73ffb..1035ac7 100644 --- a/applications/transmit/receive.c +++ b/applications/transmit/receive.c @@ -1,20 +1,6 @@ - - #define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) #define MemoryRead(A) (*(volatile unsigned int*)(A)) - -/*********** Hardware addresses ***********/ -#define IRQ_MASK 0x20000010 -#define IRQ_STATUS 0x20000020 - - -/*********** Interrupt bits **************/ -#define IRQ_PENDING_SERVICE 0x01 //bit 0 -#define IRQ_SLACK_TIME 0x02 //bit 1 -#define IRQ_SCHEDULER 0x08 //bit 3 -#define IRQ_NOC 0x20 //bit 5 - /* DMNI operations */ #define READ 0 #define WRITE 1 @@ -23,15 +9,17 @@ #define NI_CONFIG 0x20000140 /* DMNI*/ -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 +#define UART_WRITE 0x20000000 +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 #define DMNI_SEND_ACTIVE 0x20000250 #define DMNI_RECEIVE_ACTIVE 0x20000260 +#define DMNI_RECEIVE_BUFFER 0x20000264 /* Manual Routing destination ports */ #define MANUAL_EAST 0x80000000 @@ -40,42 +28,28 @@ #define MANUAL_SOUTH 0xE0000000 #define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) -#define noc_interruption (MemoryRead(IRQ_STATUS) & IRQ_NOC) //!< Signals a incoming packet from NoC - - -#define MESSAGE_DELIVERY 0x00000020 -#define CONSTANT_PKT_SIZE 6 //Tamanho do pacote do header -#define UART_WRITE 0x20000000 -#define TESTE 0x20000008 +#define TESTE 0x20000008 +#define MESSAGE_DELIVERY 0x00000020 +#define DMA_OPERATION 0x290 +#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header typedef struct { unsigned int header; unsigned int payload_size; - unsigned int service; - unsigned int source; - unsigned int target; - unsigned int pkt_size; -} ServiceHeader; - - - - + unsigned int service; +} MacHeader; int puts(char *string) { - int *str_part; //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines //PS: This indicates a hardware developer putting its hands on software development - for( - str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); - - !( ( (char*)str_part )[0] == 0 || ( (char*)str_part )[1] == 0 || ( (char*)str_part )[2] == 0 || ( (char*)str_part )[3] == 0); - - *str_part++,MemoryWrite(UART_WRITE, *str_part) - ); + //PS2: The original author need to review demorgans law for boolean simplification + for(str_part = (int*)string, MemoryWrite(UART_WRITE, *str_part); + ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; + MemoryWrite(UART_WRITE, *(++str_part))); return 0; } @@ -85,45 +59,45 @@ int puts(char *string) { */ char *itoa(unsigned int num) { - static char buf[12]; - static char buf2[12]; - int i,j; + static char buf[12]; + static char buf2[12]; + int i,j; - if (num==0) - { + if (num==0) + { buf[0] = '0'; buf[1] = '\0'; return &buf[0]; - } + } - for(i=0;i<11 && num!=0;i++) - { + for(i=0;i<11 && num!=0;i++) + { buf[i]=(char)((num%10)+'0'); num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; } char *itoh(unsigned int num) { - static char buf[11]; - int i; - buf[10]=0; + static char buf[11]; + int i; + buf[10]=0; - buf[0] = '0'; - buf[1] = 'x'; + buf[0] = '0'; + buf[1] = 'x'; - if (num==0) - { + if (num==0) + { buf[2] = '0'; buf[3] = '0'; buf[4] = '0'; @@ -133,140 +107,76 @@ char *itoh(unsigned int num) buf[8] = '0'; buf[9] = '0'; return buf; - } + } - for(i=9;i>=2;--i) - { + for(i=9;i>=2;--i) + { if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); + buf[i]=(char)((num%16)+'0'); else - buf[i]=(char)((num%16)+'W'); + buf[i]=(char)((num%16)+'W'); num/=16; - } + } - return buf; + return buf; } +void transmite(unsigned int target, unsigned int service, + unsigned int *msg, unsigned int lenght) { + static const unsigned int ZERO = 0; + + MacHeader p; + p.header = target; + p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc + p.service = service; + while (MemoryRead(DMNI_SEND_ACTIVE)); -void transmite(int target, int service, int *msg, int lenght){ - - - ServiceHeader p; - p.header = target; - p.payload_size = (CONSTANT_PKT_SIZE-2) + lenght; // 6 devido ao service header - 2 flits da noc - p.service = service; - p.source = MemoryRead(NI_CONFIG); - p.target = target; - p.pkt_size = lenght; - - - //Waits the DMNI send process be released - while (MemoryRead(DMNI_SEND_ACTIVE)); - - MemoryWrite(DMNI_SIZE, 6); - - - - puts("apo"); - //puts(itoa((unsigned int)p.header)); - //puts("\n"); - //puts(itoh((unsigned int)(&p))); - //puts("\n"); + MemoryWrite(DMNI_SIZE, 3); + MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - - if( lenght > 0 ) { - - MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); - - } - - MemoryWrite(DMNI_OP, READ); - MemoryWrite(DMNI_START, 1); + if(lenght) { + MemoryWrite(DMNI_SIZE_2, lenght); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); + } else { + MemoryWrite(DMNI_SIZE_2, 1); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); + } + + MemoryWrite(DMNI_OP, READ); + MemoryWrite(DMNI_START, 1); } - - - - - -void read_packet(ServiceHeader *p){ - - MemoryWrite(DMNI_SIZE, 6); - MemoryWrite(DMNI_OP, WRITE); - MemoryWrite(DMNI_ADDRESS, 0x4000); - MemoryWrite(DMNI_START, 1); - //Waits the DMNI copy all data to memory before release the software to access it - //while (noc_interruption != 1) - while (MemoryRead(DMNI_RECEIVE_ACTIVE)); - - p = 0x4000; +volatile void *prepare_receive(volatile void *buff) { + buff = (void*)((((unsigned int)buff)+3) & -4); + MemoryWrite(DMNI_RECEIVE_BUFFER, (unsigned int)buff); + return buff; } +void wait_receive(){ + while(!(MemoryRead(DMNI_RECEIVE_BUFFER) & 1)); +} +volatile unsigned int glob_buff[256]; +int main() { + volatile char *buff; -int main() -{ - volatile ServiceHeader p; - - puts("a"); - -/* - read_packet((ServiceHeader *)&p); - puts("$$$ "); - puts(itoa((unsigned int)p.header)); - puts("\n"); - puts(itoh((unsigned int)p.service)); - puts("\n"); -*/ - - - while(1) - { - int i; - - if (noc_interruption){ - - i=7; - //transmite(0x00000101 ,MESSAGE_DELIVERY, &i ,1); - - read_packet((ServiceHeader *)&p); - //puts("a"); - //puts(itoa((unsigned int)p.header)); - //puts("\n"); - //puts(itoh((unsigned int)p.service)); - //puts("\n"); - - - - int data_receive[4]; - data_receive[0] = MemoryRead(0x4000); - data_receive[1] = MemoryRead(0x4004); - data_receive[2] = MemoryRead(0x4008); - data_receive[3] = MemoryRead(0x400C); - - transmite(0x00000101 ,MESSAGE_DELIVERY, data_receive ,4); - - - - } - - - + for(;;) { + buff=prepare_receive(glob_buff); + puts("Prepared to receive\n"); + wait_receive(); + puts("Data Received\n"); + puts((char*)buff); } - - + return 0; } /* - USO: int message[30] transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) diff --git a/applications/transmit/transmit.c b/applications/transmit/transmit.c index e450e90..85df65c 100644 --- a/applications/transmit/transmit.c +++ b/applications/transmit/transmit.c @@ -1,227 +1,160 @@ - - -#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) -#define MemoryRead(A) (*(volatile unsigned int*)(A)) - -/* DMNI operations */ -#define READ 0 -#define WRITE 1 - - -#define NI_CONFIG 0x20000140 - -/* DMNI*/ -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 -#define DMNI_SEND_ACTIVE 0x20000250 -#define DMNI_RECEIVE_ACTIVE 0x20000260 - -/* Manual Routing destination ports */ -#define MANUAL_EAST 0x80000000 -#define MANUAL_WEST 0xA0000000 -#define MANUAL_NORTH 0xC0000000 -#define MANUAL_SOUTH 0xE0000000 - -#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) - - -#define UART_WRITE 0x20000000 -#define TESTE 0x20000008 -#define MESSAGE_DELIVERY 0x00000020 -#define CONSTANT_PKT_SIZE 6 //Tamanho do pacote do header - -typedef struct { - unsigned int header; - unsigned int payload_size; - unsigned int service; - unsigned int source; - unsigned int target; - unsigned int pkt_size; -} ServiceHeader; - - - - - - -int puts(char *string) { - - int *str_part; - //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines - //PS: This indicates a hardware developer putting its hands on software development - for( - str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); - - !( ( (char*)str_part )[0] == 0 || ( (char*)str_part )[1] == 0 || ( (char*)str_part )[2] == 0 || ( (char*)str_part )[3] == 0); - - *str_part++,MemoryWrite(UART_WRITE, *str_part) - ); - return 0; -} - -/**Converts a integer number to its decimal representation in a array of char - * \param num Integer number to be converted - * \return Array of chars - */ -char *itoa(unsigned int num) -{ - static char buf[12]; - static char buf2[12]; - int i,j; - - if (num==0) - { - buf[0] = '0'; - buf[1] = '\0'; - return &buf[0]; - } - - for(i=0;i<11 && num!=0;i++) - { - buf[i]=(char)((num%10)+'0'); - num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; -} - - - -char *itoh(unsigned int num) -{ - static char buf[11]; - int i; - buf[10]=0; - - buf[0] = '0'; - buf[1] = 'x'; - - if (num==0) - { - buf[2] = '0'; - buf[3] = '0'; - buf[4] = '0'; - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '0'; - buf[8] = '0'; - buf[9] = '0'; - return buf; - } - - for(i=9;i>=2;--i) - { - if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); - else - buf[i]=(char)((num%16)+'W'); - - num/=16; - } - - return buf; -} - - - - - - - -void transmite(int target, int service, int *msg, int lenght){ - - - ServiceHeader p; - p.header = target; - p.payload_size = (CONSTANT_PKT_SIZE-2) + lenght; // 6 devido ao service header - 2 flits da noc - p.service = service; - p.source = MemoryRead(NI_CONFIG); - p.target = target; - p.pkt_size = lenght; - - puts("trm"); - //Waits the DMNI send process be released - while (MemoryRead(DMNI_SEND_ACTIVE)); - - MemoryWrite(DMNI_SIZE, 6); - - - - puts("apo"); - //puts(itoa((unsigned int)p.header)); - //puts("\n"); - //puts(itoh((unsigned int)(&p))); - //puts("\n"); - - - MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - - if( lenght > 0 ) { - - MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); - - } - - MemoryWrite(DMNI_OP, READ); - MemoryWrite(DMNI_START, 1); -} - - - - - - -int main() -{ - unsigned int i; - int anderson[2]; - puts("$$$"); - anderson[0] = 14; - anderson[1] = 20; - - transmite(0x00000001 ,MESSAGE_DELIVERY, anderson ,2); - puts("aa$"); - - - //transmite(0x00000100 ,0x00000290, data_dma_code ,102); - //transmite(0x00000000 ,0x00000290, data_dma_code ,102); - //transmite(0x00000101 ,0x00000290, data_dma_code,102); - // - - - for(i=0; i<100; i++) - { - MemoryWrite(TESTE, i); //Grava o valor de no endereco da memoria (definida como teste) - *(volatile unsigned int *)(TESTE) = i; - - puts("$$$ "); - puts(itoa(i)); - puts(itoa(&i)); - puts("\n"); - } - - - for(;;); - - - -} - -/* - -USO: -int message[30] -transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) -*/ \ No newline at end of file +#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) +#define MemoryRead(A) (*(volatile unsigned int*)(A)) + +/* DMNI operations */ +#define READ 0 +#define WRITE 1 + + +#define NI_CONFIG 0x20000140 + +/* DMNI*/ +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 +#define DMNI_RECEIVE_BUFFER 0x20000264 + +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|y)&0xFFFF) + +#define UART_WRITE 0x20000000 +#define TESTE 0x20000008 +#define MESSAGE_DELIVERY 0x00000020 +#define DMA_OPERATION 0x290 +#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header + +typedef struct { + unsigned int header; + unsigned int payload_size; + unsigned int service; +} MacHeader; + + +int puts(char *string) { + + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + //PS2: The original author need to review demorgans law for boolean simplification + for(str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); + ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; + MemoryWrite(UART_WRITE, *(++str_part))); + return 0; +} + +/**Converts a integer number to its decimal representation in a array of char + * \param num Integer number to be converted + * \return Array of chars + */ +char *itoa(unsigned int num) +{ + static char buf[12]; + static char buf2[12]; + int i,j; + + if (num==0) + { + buf[0] = '0'; + buf[1] = '\0'; + return &buf[0]; + } + + for(i=0;i<11 && num!=0;i++) + { + buf[i]=(char)((num%10)+'0'); + num/=10; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; +} + + + +char *itoh(unsigned int num) +{ + static char buf[11]; + int i; + buf[10]=0; + + buf[0] = '0'; + buf[1] = 'x'; + + if (num==0) + { + buf[2] = '0'; + buf[3] = '0'; + buf[4] = '0'; + buf[5] = '0'; + buf[6] = '0'; + buf[7] = '0'; + buf[8] = '0'; + buf[9] = '0'; + return buf; + } + + for(i=9;i>=2;--i) + { + if ((num%16) < 10) + buf[i]=(char)((num%16)+'0'); + else + buf[i]=(char)((num%16)+'W'); + + num/=16; + } + + return buf; +} + + +void transmite(unsigned int target, unsigned int service, + unsigned int *msg, unsigned int lenght) { + static const unsigned int ZERO = 0; + static MacHeader p; + + p.header = target; + p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc + p.service = service; + + MemoryWrite(DMNI_SIZE, 3); + + MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header + + if(lenght) { + MemoryWrite(DMNI_SIZE_2, lenght); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); + } else { + MemoryWrite(DMNI_SIZE_2, 1); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); + } + + MemoryWrite(DMNI_OP, READ); + MemoryWrite(DMNI_START, 1); + + while (MemoryRead(DMNI_SEND_ACTIVE)); +} + +int main() { + unsigned int i; + char hello[] = "Hello World!\n"; + + transmite(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); + + for(;;); +} diff --git a/build_env/bin/hemps-wave_gen b/build_env/bin/hemps-wave_gen index 4544e4e..fdda413 100755 --- a/build_env/bin/hemps-wave_gen +++ b/build_env/bin/hemps-wave_gen @@ -105,8 +105,25 @@ def generate_wave_generic(yaml_r, system_model): wave_lines.append(pe_group + cpu_group + signal_path + "/cpu_mem_address_reg\n") wave_lines.append(pe_group + cpu_group + signal_path + "/cpu_mem_data_write_reg\n") wave_lines.append(pe_group + cpu_group + signal_path + "/cpu_mem_data_read\n") - wave_lines.append(pe_group + cpu_group + signal_path + "/cpu_mem_write_byte_enable\n") + wave_lines.append(pe_group + cpu_group + signal_path + "/cpu_mem_write_byte_enable\n") + + memory_group = "-group MEMORY_"+pe+" " + port_a = "-group PORT_A " + port_b = "-group PORT_B " + + wave_lines.append(pe_group + memory_group + port_a + signal_path + "/cpu_enable_ram\n") + wave_lines.append(pe_group + memory_group + port_a + signal_path + "/addr_a\n") + wave_lines.append(pe_group + memory_group + port_a + signal_path + "/cpu_mem_data_write\n") + wave_lines.append(pe_group + memory_group + port_a + signal_path + "/cpu_mem_write_byte_enable\n") + wave_lines.append(pe_group + memory_group + port_a + signal_path + "/data_read_mem\n") + + wave_lines.append(pe_group + memory_group + port_b + signal_path + "/dmni_enable_internal_ram\n") + wave_lines.append(pe_group + memory_group + port_b + signal_path + "/dmni_mem_write_byte_enable\n") + wave_lines.append(pe_group + memory_group + port_b + signal_path + "/addr_b\n") + wave_lines.append(pe_group + memory_group + port_b + signal_path + "/dmni_mem_data_write\n") + wave_lines.append(pe_group + memory_group + port_b + signal_path + "/mem_data_read\n") + router_config = "-group router_config_"+pe+" " dmni_group = "-group {DMNI "+pe+"} " @@ -134,7 +151,15 @@ def generate_wave_generic(yaml_r, system_model): wave_lines.append(pe_group + dmni_group + config + signal_path + "/set_size_2\n") wave_lines.append(pe_group + dmni_group + config + signal_path + "/set_op\n") wave_lines.append(pe_group + dmni_group + config + signal_path + "/start\n") - wave_lines.append(pe_group + dmni_group + config + signal_path + "/config_data\n") + wave_lines.append(pe_group + dmni_group + config + signal_path + "/config_data\n") + + dmma = "-group dmma_"+pe+" " + wave_lines.append(pe_group + dmni_group + dmma + signal_path + "/recv_buffer\n") + wave_lines.append(pe_group + dmni_group + dmma + signal_path + "/DMNI_Receive\n") + wave_lines.append(pe_group + dmni_group + dmma + signal_path + "/recv_size\n") + wave_lines.append(pe_group + dmni_group + dmma + signal_path + "/recv_op\n") + wave_lines.append(pe_group + dmni_group + dmma + signal_path + "/dmma_done\n") + input_name = "EAST", "WEST", "NORTH", "SOUTH", "LOCAL" @@ -171,4 +196,4 @@ def generate_wave_generic(yaml_r, system_model): #Call of function main, this aproaches enables to call a fucntion before it declaration main() - \ No newline at end of file + diff --git a/build_env/bin/payload_builder.py b/build_env/bin/payload_builder.py new file mode 100755 index 0000000..d25a3d1 --- /dev/null +++ b/build_env/bin/payload_builder.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +import sys +import os + +# apos executar o comando make na pasta + +vetor=[] +ref_arquivo= open(sys.argv[1],'r') +i=0; +for linha in ref_arquivo: + valores = linha.split() + vetor.append(linha) + # print 'data_dma_code[',i,']= 0x',linha,';' + # print ('data_dma_code['+i+']='+valores[1]+';') + # i=i+1; + +ref_arquivo.close() + +print('const unsigned int {}[] = {}'.format(sys.argv[2], '{')) + +for j in range(0,len(vetor)): + teste = str(vetor[j]) + final = '' + for i in teste: + if i != '\n': + final += i + print('\t0x'+final, end='') + if j != len(vetor)-1: + print(',') + else: + print('};') + diff --git a/build_env/makes/make_app b/build_env/makes/make_app index 7df5f2e..7a1af76 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -3,7 +3,7 @@ NC =\033[0m # No Color INCLUDE = ../../software/include -CFLAGS = -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 +CFLAGS = -O2 -Wall -fms-extensions -mips1 -c -s -std=c99 -G 0 GCC_MIPS = mips-elf-gcc $(CFLAGS) AS_MIPS = mips-elf-as LD_MIPS = mips-elf-ld diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 98e8987..b7e7fa6 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -41,6 +41,7 @@ entity dmni is send_active : out std_logic; receive_active : out std_logic; reset_dmni : out std_logic; + recv_buff_out : out std_logic_vector(31 downto 0); -- Memory interface mem_address : out std_logic_vector(31 downto 0); mem_data_write : out std_logic_vector(31 downto 0); @@ -145,6 +146,7 @@ begin clock_tx <= clock; send_active <= send_active_2; receive_active <= receive_active_2; + recv_buff_out <= recv_buffer; arbiter : process (clock, reset) begin @@ -266,7 +268,7 @@ begin --Write to memory case DMNI_Receive is when WAIT_state => - if ((recv_op = LEGACY and start = '1' and operation = '1') or (recv_op = DMMA and recv_buffer (0) = '0') or (recv_op = START_CPU))then + if ((recv_op = LEGACY and start = '1' and operation = '1') or (recv_op = DMMA and recv_buffer(0) = '0') or (recv_op = START_CPU))then if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then intr_counter_temp <= intr_counter_temp -1; end if; @@ -280,7 +282,7 @@ begin when DMMA => DMNI_Receive <= COPY_TO_MEM_DMA; recv_size <= payload_fix + 2; - recv_address <= recv_buffer(31 downto 2) & "00"; + recv_address <= recv_buffer - WORD_SIZE; when START_CPU => DMNI_Receive <= DISCARD; recv_size <= payload_fix + 2; @@ -345,6 +347,7 @@ begin mem_byte_we <= "0000"; recv_address <= (others => '0'); recv_size <= (others => '0'); + dmma_done <= '0'; DMNI_Receive <= WAIT_state; when others => end case; diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index a8b0604..5f4a98d 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -115,6 +115,7 @@ architecture structural of pe is signal data_av : std_logic; signal end_sim_reg : std_logic_vector(31 downto 0); signal uart_write_data : std_logic; + signal dmni_recv_buff : std_logic_vector(31 downto 0); signal slack_update_timer : std_logic_vector(31 downto 0); @@ -207,8 +208,7 @@ begin clock_tx => clock_tx_router, tx => tx_router, data_out => data_out_router, - credit_i => credit_i_router - ); + credit_i => credit_i_router); dmni : entity work.dmni @@ -232,6 +232,7 @@ begin send_active => dmni_send_active_sig, receive_active => dmni_receive_active_sig, reset_dmni => reset_dmni, + recv_buff_out => dmni_recv_buff, -- Memory interface mem_address => dmni_mem_address, @@ -297,6 +298,7 @@ begin req_app when cpu_mem_address_reg = REQ_APP_REG else ZERO(31 downto 1) & dmni_send_active_sig when cpu_mem_address_reg = DMNI_SEND_ACTIVE else ZERO(31 downto 1) & dmni_receive_active_sig when cpu_mem_address_reg = DMNI_RECEIVE_ACTIVE else + dmni_recv_buff when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER else data_read_ram; --Comb assignments diff --git a/hardware/vhdl/pe/processor/plasma/UartFile.vhd b/hardware/vhdl/pe/processor/plasma/UartFile.vhd index 6410842..8ea29bf 100644 --- a/hardware/vhdl/pe/processor/plasma/UartFile.vhd +++ b/hardware/vhdl/pe/processor/plasma/UartFile.vhd @@ -1,110 +1,69 @@ ------------------------------------------------------------------------------------------------- --- --- DISTRIBUTED HEMPS - version 5.0 --- --- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br --- --- Distribution: September 2013 --- --- Source name: UartFile.vhd --- --- AUTHOR: Everton Alceu Carara (everton.carara@pucrs.br) --- --- DATE CREATED: 2/12/2009 --- --- Brief description: Writes strings from Echo() and puts() to the log_file. --- ------------------------------------------------------------------------------------------------- - -library ieee; -use ieee.std_logic_1164.all; -use ieee.std_logic_misc.all; -use ieee.std_logic_arith.all; -use ieee.std_logic_textio.all; -use ieee.std_logic_unsigned.all; -use std.textio.all; -use work.mlite_pack.all; - -entity UartFile is - generic(log_file : string := "UNUSED"); - port( - reset : in std_logic; - data_av : in std_logic; - data_in : in std_logic_vector(31 downto 0)); - end; - -architecture logic of UartFile is - -type state is (S0, S1); -signal CS: state; - -begin - - - process(data_av,reset) - file store_file : text open write_mode is log_file; - variable file_line : line; - variable line_type: character; - variable line_length : natural := 0; - variable str: string (1 to 4); - variable str_end: boolean; - begin - if reset = '1' then - str_end := false; - CS <= S0; - - elsif rising_edge(data_av) then - case CS is - when S0 => - -- Reads the incoming string - line_type := character'val(conv_integer(data_in(7 downto 0))); - - -- Verifies if the string is from Echo() - if line_type = '$' then - write(file_line, line_type); - line_length := line_length + 1; - CS <= S1; - - -- Writes the string to the file - else - str(4) := character'val(conv_integer(data_in(7 downto 0))); - str(3) := character'val(conv_integer(data_in(15 downto 8))); - str(2) := character'val(conv_integer(data_in(23 downto 16))); - str(1) := character'val(conv_integer(data_in(31 downto 24))); - - str_end := false; - - for i in 1 to 4 loop - -- Writes a string in the line - if str(i) /= lf and str(i) /= nul and not str_end then - write(file_line, str(i)); - line_length := line_length + 1; - - -- Detects the string end - elsif str(i) = nul then - str_end := true; - - -- Line feed detected. Writes the line in the file - elsif str(i) = lf then - writeline(store_file, file_line); - line_length := 0; - end if; - end loop; - end if; - - -- Receives from plasma the source processor, source task and writes them to the file - when S1 => - write(file_line, ','); - write(file_line, conv_integer(data_in(7 downto 0))); - line_length := line_length + 1; - - if line_length = 3 then - write(file_line, ','); - CS <= S0; - else - CS <= S1; - end if; - end case; - end if; - end process; -end; +------------------------------------------------------------------------------------------------ +-- +-- DISTRIBUTED HEMPS - version 5.0 +-- +-- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br +-- +-- Distribution: September 2013 +-- +-- Source name: UartFile.vhd +-- +-- AUTHOR: Everton Alceu Carara (everton.carara@pucrs.br) +-- +-- DATE CREATED: 2/12/2009 +-- +-- Brief description: Writes strings from Echo() and puts() to the log_file. +-- +------------------------------------------------------------------------------------------------ + +library ieee; +use ieee.std_logic_1164.all; +use ieee.std_logic_misc.all; +use ieee.std_logic_arith.all; +use ieee.std_logic_textio.all; +use ieee.std_logic_unsigned.all; +use std.textio.all; +use work.mlite_pack.all; + +entity UartFile is + generic(log_file : string := "UNUSED"); + port( + reset : in std_logic; + data_av : in std_logic; + data_in : in std_logic_vector(31 downto 0)); +end; + +architecture logic of UartFile is + +begin + + process(data_av, reset) + file store_file : text open write_mode is log_file; + variable file_line : line; + variable line_type : character; + variable line_length : natural := 0; + variable str : string (1 to 4); + variable str_end : boolean; + begin + if reset = '1' then + str_end := false; + elsif rising_edge(data_av) then + str(4) := character'val(conv_integer(data_in(7 downto 0))); + str(3) := character'val(conv_integer(data_in(15 downto 8))); + str(2) := character'val(conv_integer(data_in(23 downto 16))); + str(1) := character'val(conv_integer(data_in(31 downto 24))); + str_end := false; + for i in 1 to 4 loop + -- Writes a string in the line + if str(i) /= nul and str(i) /= lf and not str_end then + write(file_line, str(i)); + -- Detects the string end + elsif str(i) = nul then + str_end := true; + elsif str(i) = lf then + writeline(store_file, file_line); + end if; + end loop; + end if; + end process; +end; diff --git a/software/boot_task/boot_task.asm b/software/boot_task/boot_task.asm index 5550bee..a90440e 100644 --- a/software/boot_task/boot_task.asm +++ b/software/boot_task/boot_task.asm @@ -1,50 +1,50 @@ -## HEMPS VERSION - 8.0 - support for RT applications -## -## Distribution: June 2016 -## -## Created by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br -## -## Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br -## -## Brief description: Initializes the stack pointer and jumps to main(). Handles the syscall. - - - - .text - .align 2 - .globl entry - .ent entry -entry: - .set noreorder +## HEMPS VERSION - 8.0 - support for RT applications +## +## Distribution: June 2016 +## +## Created by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br +## +## Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br +## +## Brief description: Initializes the stack pointer and jumps to main(). Handles the syscall. + + + + .text + .align 2 + .globl entry + .ent entry +entry: + .set noreorder li $sp,sp_addr # new initialization - - jal main - nop - - move $4,$0 - syscall - nop - -$L1: - j $L1 - nop - - .end entry - -################################################### - - .globl SystemCall - .ent SystemCall -SystemCall: - .set noreorder - - syscall - nop - jr $31 - nop - - .set reorder - .end SystemCall - - + + jal main + nop + + move $4,$0 + syscall + nop + +$L1: + j $L1 + nop + + .end entry + +################################################### + + .globl SystemCall + .ent SystemCall +SystemCall: + .set noreorder + + syscall + nop + jr $31 + nop + + .set reorder + .end SystemCall + + diff --git a/software/kernel/master/kernel_master.c b/software/kernel/master/kernel_master.c index e0f6d7f..d2af424 100644 --- a/software/kernel/master/kernel_master.c +++ b/software/kernel/master/kernel_master.c @@ -744,536 +744,42 @@ void handle_app_request(){ void send_dma_operation(int target){ -/* - int data_dma_operation[6]; - data_dma_operation[0]= 1; - data_dma_operation[1]= 2; - data_dma_operation[2]= 3; - data_dma_operation[3]= 4; - data_dma_operation[4]= 5; - data_dma_operation[5]= 6; -*/ - -if(target == 0x00000101) -{ - -//transmite -unsigned int data_dma_code[271]; -data_dma_code[0]= 0x241d7fff; -data_dma_code[1]= 0x0c0000d4; -data_dma_code[2]= 0x00000000; -data_dma_code[3]= 0x00002021; -data_dma_code[4]= 0x0000000c; -data_dma_code[5]= 0x00000000; -data_dma_code[6]= 0x08000006; -data_dma_code[7]= 0x00000000; -data_dma_code[8]= 0x0000000c; -data_dma_code[9]= 0x00000000; -data_dma_code[10]= 0x03e00008; -data_dma_code[11]= 0x00000000; -data_dma_code[12]= 0x8c820000; -data_dma_code[13]= 0x3c032000; -data_dma_code[14]= 0xac620000; -data_dma_code[15]= 0x00802821; -data_dma_code[16]= 0x80840000; -data_dma_code[17]= 0x00000000; -data_dma_code[18]= 0x10800022; -data_dma_code[19]= 0x00000000; -data_dma_code[20]= 0x80a20001; -data_dma_code[21]= 0x00000000; -data_dma_code[22]= 0x1040001e; -data_dma_code[23]= 0x00000000; -data_dma_code[24]= 0x80a20002; -data_dma_code[25]= 0x00000000; -data_dma_code[26]= 0x1040001a; -data_dma_code[27]= 0x00000000; -data_dma_code[28]= 0x80a20003; -data_dma_code[29]= 0x00000000; -data_dma_code[30]= 0x10400016; -data_dma_code[31]= 0x3c042000; -data_dma_code[32]= 0x0800002e; -data_dma_code[33]= 0x24a50004; -data_dma_code[34]= 0x80a20001; -data_dma_code[35]= 0x00000000; -data_dma_code[36]= 0x10400010; -data_dma_code[37]= 0x00000000; -data_dma_code[38]= 0x80a20002; -data_dma_code[39]= 0x00000000; -data_dma_code[40]= 0x1040000c; -data_dma_code[41]= 0x00000000; -data_dma_code[42]= 0x80a20003; -data_dma_code[43]= 0x00000000; -data_dma_code[44]= 0x10400008; -data_dma_code[45]= 0x24a50004; -data_dma_code[46]= 0x8ca20000; -data_dma_code[47]= 0x00000000; -data_dma_code[48]= 0xac820000; -data_dma_code[49]= 0x80a30000; -data_dma_code[50]= 0x00000000; -data_dma_code[51]= 0x1460ffee; -data_dma_code[52]= 0x00000000; -data_dma_code[53]= 0x03e00008; -data_dma_code[54]= 0x00001021; -data_dma_code[55]= 0x14800009; -data_dma_code[56]= 0x00802821; -data_dma_code[57]= 0x3c020000; -data_dma_code[58]= 0x24440454; -data_dma_code[59]= 0x00802821; -data_dma_code[60]= 0x24030030; -data_dma_code[61]= 0xa0430454; -data_dma_code[62]= 0x00a01021; -data_dma_code[63]= 0x03e00008; -data_dma_code[64]= 0xa0800001; -data_dma_code[65]= 0x3c03cccc; -data_dma_code[66]= 0x3463cccd; -data_dma_code[67]= 0x00830019; -data_dma_code[68]= 0x3c020000; -data_dma_code[69]= 0x24460455; -data_dma_code[70]= 0x3c080000; -data_dma_code[71]= 0x24070001; -data_dma_code[72]= 0x00001810; -data_dma_code[73]= 0x000318c2; -data_dma_code[74]= 0x00031040; -data_dma_code[75]= 0x000320c0; -data_dma_code[76]= 0x00441021; -data_dma_code[77]= 0x00a21023; -data_dma_code[78]= 0x24420030; -data_dma_code[79]= 0x00602821; -data_dma_code[80]= 0x10a00013; -data_dma_code[81]= 0xa1020454; -data_dma_code[82]= 0x3c03cccc; -data_dma_code[83]= 0x3463cccd; -data_dma_code[84]= 0x00a30019; -data_dma_code[85]= 0x24e70001; -data_dma_code[86]= 0x00001810; -data_dma_code[87]= 0x000320c2; -data_dma_code[88]= 0x00041040; -data_dma_code[89]= 0x000418c0; -data_dma_code[90]= 0x00431021; -data_dma_code[91]= 0x00a21023; -data_dma_code[92]= 0x24420030; -data_dma_code[93]= 0xa0c20000; -data_dma_code[94]= 0x2402000b; -data_dma_code[95]= 0x10e2000d; -data_dma_code[96]= 0x24c60001; -data_dma_code[97]= 0x00802821; -data_dma_code[98]= 0x14a0fff0; -data_dma_code[99]= 0x3c03cccc; -data_dma_code[100]= 0x3c040000; -data_dma_code[101]= 0x24820448; -data_dma_code[102]= 0x00e21021; -data_dma_code[103]= 0x24e3ffff; -data_dma_code[104]= 0x04610008; -data_dma_code[105]= 0xa0400000; -data_dma_code[106]= 0x24850448; -data_dma_code[107]= 0x03e00008; -data_dma_code[108]= 0x00a01021; -data_dma_code[109]= 0x3c040000; -data_dma_code[110]= 0x24820448; -data_dma_code[111]= 0x2403000a; -data_dma_code[112]= 0xa040000b; -data_dma_code[113]= 0x24820448; -data_dma_code[114]= 0x00621821; -data_dma_code[115]= 0x3c020000; -data_dma_code[116]= 0x25050454; -data_dma_code[117]= 0x24460447; -data_dma_code[118]= 0x90a20000; -data_dma_code[119]= 0x00000000; -data_dma_code[120]= 0xa0620000; -data_dma_code[121]= 0x2463ffff; -data_dma_code[122]= 0x1466fffb; -data_dma_code[123]= 0x24a50001; -data_dma_code[124]= 0x0800006b; -data_dma_code[125]= 0x24850448; -data_dma_code[126]= 0x3c080000; -data_dma_code[127]= 0x2503043c; -data_dma_code[128]= 0x24050030; -data_dma_code[129]= 0x24020078; -data_dma_code[130]= 0xa0620001; -data_dma_code[131]= 0xa060000a; -data_dma_code[132]= 0x1480000b; -data_dma_code[133]= 0xa105043c; -data_dma_code[134]= 0xa0650009; -data_dma_code[135]= 0xa0650002; -data_dma_code[136]= 0xa0650003; -data_dma_code[137]= 0xa0650004; -data_dma_code[138]= 0xa0650005; -data_dma_code[139]= 0xa0650006; -data_dma_code[140]= 0xa0650007; -data_dma_code[141]= 0xa0650008; -data_dma_code[142]= 0x03e00008; -data_dma_code[143]= 0x2502043c; -data_dma_code[144]= 0x3c020000; -data_dma_code[145]= 0x3c030000; -data_dma_code[146]= 0x24470445; -data_dma_code[147]= 0x08000099; -data_dma_code[148]= 0x2463043d; -data_dma_code[149]= 0xa0e60000; -data_dma_code[150]= 0x24e7ffff; -data_dma_code[151]= 0x10e3fff6; -data_dma_code[152]= 0x00042102; -data_dma_code[153]= 0x3082000f; -data_dma_code[154]= 0x24460030; -data_dma_code[155]= 0x24450057; -data_dma_code[156]= 0x2c42000a; -data_dma_code[157]= 0x1440fff7; -data_dma_code[158]= 0x00000000; -data_dma_code[159]= 0x08000096; -data_dma_code[160]= 0xa0e50000; -data_dma_code[161]= 0x27bdffc8; -data_dma_code[162]= 0xafb1002c; -data_dma_code[163]= 0x00e08821; -data_dma_code[164]= 0x26220004; -data_dma_code[165]= 0xafa20014; -data_dma_code[166]= 0x3c022000; -data_dma_code[167]= 0xafb20030; -data_dma_code[168]= 0xafb00028; -data_dma_code[169]= 0xafa40010; -data_dma_code[170]= 0xafbf0034; -data_dma_code[171]= 0xafa50018; -data_dma_code[172]= 0x34420140; -data_dma_code[173]= 0x8c430000; -data_dma_code[174]= 0x00803821; -data_dma_code[175]= 0x3c040000; -data_dma_code[176]= 0x24840420; -data_dma_code[177]= 0x3c102000; -data_dma_code[178]= 0xafa3001c; -data_dma_code[179]= 0xafa70020; -data_dma_code[180]= 0x00c09021; -data_dma_code[181]= 0x0c00000c; -data_dma_code[182]= 0xafb10024; -data_dma_code[183]= 0x36030250; -data_dma_code[184]= 0x8c620000; -data_dma_code[185]= 0x00000000; -data_dma_code[186]= 0x1440fffd; -data_dma_code[187]= 0x24020006; -data_dma_code[188]= 0x36030200; -data_dma_code[189]= 0x3c040000; -data_dma_code[190]= 0xac620000; -data_dma_code[191]= 0x0c00000c; -data_dma_code[192]= 0x24840424; -data_dma_code[193]= 0x36030210; -data_dma_code[194]= 0x27a20010; -data_dma_code[195]= 0xac620000; -data_dma_code[196]= 0x1a200004; -data_dma_code[197]= 0x36020205; -data_dma_code[198]= 0x36030215; -data_dma_code[199]= 0xac510000; -data_dma_code[200]= 0xac720000; -data_dma_code[201]= 0x36020230; -data_dma_code[202]= 0x36030220; -data_dma_code[203]= 0x24040001; -data_dma_code[204]= 0xac600000; -data_dma_code[205]= 0xac440000; -data_dma_code[206]= 0x8fbf0034; -data_dma_code[207]= 0x8fb20030; -data_dma_code[208]= 0x8fb1002c; -data_dma_code[209]= 0x8fb00028; -data_dma_code[210]= 0x03e00008; -data_dma_code[211]= 0x27bd0038; -data_dma_code[212]= 0x3c040000; -data_dma_code[213]= 0x27bdffc8; -data_dma_code[214]= 0x24840428; -data_dma_code[215]= 0xafbf0030; -data_dma_code[216]= 0xafb3002c; -data_dma_code[217]= 0xafb20028; -data_dma_code[218]= 0xafb10024; -data_dma_code[219]= 0x0c00000c; -data_dma_code[220]= 0xafb00020; -data_dma_code[221]= 0x24030014; -data_dma_code[222]= 0x2402000e; -data_dma_code[223]= 0x24040001; -data_dma_code[224]= 0x24050020; -data_dma_code[225]= 0x27a60014; -data_dma_code[226]= 0x24070002; -data_dma_code[227]= 0xafa30018; -data_dma_code[228]= 0x0c0000a1; -data_dma_code[229]= 0xafa20014; -data_dma_code[230]= 0x3c040000; -data_dma_code[231]= 0x0c00000c; -data_dma_code[232]= 0x2484042c; -data_dma_code[233]= 0x3c022000; -data_dma_code[234]= 0xafa00010; -data_dma_code[235]= 0x34510008; -data_dma_code[236]= 0x27b00010; -data_dma_code[237]= 0x00001821; -data_dma_code[238]= 0x3c120000; -data_dma_code[239]= 0x3c130000; -data_dma_code[240]= 0xae230000; -data_dma_code[241]= 0x26440430; -data_dma_code[242]= 0xae230000; -data_dma_code[243]= 0x0c00000c; -data_dma_code[244]= 0x00000000; -data_dma_code[245]= 0x8fa40010; -data_dma_code[246]= 0x0c000037; -data_dma_code[247]= 0x00000000; -data_dma_code[248]= 0x0c00000c; -data_dma_code[249]= 0x00402021; -data_dma_code[250]= 0x0c000037; -data_dma_code[251]= 0x02002021; -data_dma_code[252]= 0x0c00000c; -data_dma_code[253]= 0x00402021; -data_dma_code[254]= 0x0c00000c; -data_dma_code[255]= 0x26640438; -data_dma_code[256]= 0x8fa30010; -data_dma_code[257]= 0x00000000; -data_dma_code[258]= 0x24630001; -data_dma_code[259]= 0x2c620064; -data_dma_code[260]= 0x1440ffeb; -data_dma_code[261]= 0xafa30010; -data_dma_code[262]= 0x08000106; -data_dma_code[263]= 0x00000000; -data_dma_code[264]= 0x74726d00; -data_dma_code[265]= 0x61706f00; -data_dma_code[266]= 0x24242400; -data_dma_code[267]= 0x61612400; -data_dma_code[268]= 0x24242420; -data_dma_code[269]= 0x00000000; -data_dma_code[270]= 0x0a000000; - - - ServiceHeader *p = get_service_header_slot(); - p->header = 0x00000101; - - p->service = DMA_OPERATION; - send_packet(p, data_dma_code, 271); //send_packet(ServiceHeader *p, Endereco inicial do payload, tamanho do payload) - //Se fosse inteiro era &nome da variavel e tamanho 1 -} -else -//receive -{ - -unsigned int data_dma_code[219]; -data_dma_code[0]= 0x241d7fff; -data_dma_code[1]= 0x0c0000b4; -data_dma_code[2]= 0x00000000; -data_dma_code[3]= 0x00002021; -data_dma_code[4]= 0x0000000c; -data_dma_code[5]= 0x00000000; -data_dma_code[6]= 0x08000006; -data_dma_code[7]= 0x00000000; -data_dma_code[8]= 0x0000000c; -data_dma_code[9]= 0x00000000; -data_dma_code[10]= 0x03e00008; -data_dma_code[11]= 0x00000000; -data_dma_code[12]= 0x8c820000; -data_dma_code[13]= 0x3c032000; -data_dma_code[14]= 0xac620000; -data_dma_code[15]= 0x00802821; -data_dma_code[16]= 0x80840000; -data_dma_code[17]= 0x00000000; -data_dma_code[18]= 0x10800022; -data_dma_code[19]= 0x00000000; -data_dma_code[20]= 0x80a20001; -data_dma_code[21]= 0x00000000; -data_dma_code[22]= 0x1040001e; -data_dma_code[23]= 0x00000000; -data_dma_code[24]= 0x80a20002; -data_dma_code[25]= 0x00000000; -data_dma_code[26]= 0x1040001a; -data_dma_code[27]= 0x00000000; -data_dma_code[28]= 0x80a20003; -data_dma_code[29]= 0x00000000; -data_dma_code[30]= 0x10400016; -data_dma_code[31]= 0x3c042000; -data_dma_code[32]= 0x0800002e; -data_dma_code[33]= 0x24a50004; -data_dma_code[34]= 0x80a20001; -data_dma_code[35]= 0x00000000; -data_dma_code[36]= 0x10400010; -data_dma_code[37]= 0x00000000; -data_dma_code[38]= 0x80a20002; -data_dma_code[39]= 0x00000000; -data_dma_code[40]= 0x1040000c; -data_dma_code[41]= 0x00000000; -data_dma_code[42]= 0x80a20003; -data_dma_code[43]= 0x00000000; -data_dma_code[44]= 0x10400008; -data_dma_code[45]= 0x24a50004; -data_dma_code[46]= 0x8ca20000; -data_dma_code[47]= 0x00000000; -data_dma_code[48]= 0xac820000; -data_dma_code[49]= 0x80a30000; -data_dma_code[50]= 0x00000000; -data_dma_code[51]= 0x1460ffee; -data_dma_code[52]= 0x00000000; -data_dma_code[53]= 0x03e00008; -data_dma_code[54]= 0x00001021; -data_dma_code[55]= 0x14800009; -data_dma_code[56]= 0x00802821; -data_dma_code[57]= 0x3c020000; -data_dma_code[58]= 0x24440384; -data_dma_code[59]= 0x00802821; -data_dma_code[60]= 0x24030030; -data_dma_code[61]= 0xa0430384; -data_dma_code[62]= 0x00a01021; -data_dma_code[63]= 0x03e00008; -data_dma_code[64]= 0xa0800001; -data_dma_code[65]= 0x3c03cccc; -data_dma_code[66]= 0x3463cccd; -data_dma_code[67]= 0x00830019; -data_dma_code[68]= 0x3c020000; -data_dma_code[69]= 0x24460385; -data_dma_code[70]= 0x3c080000; -data_dma_code[71]= 0x24070001; -data_dma_code[72]= 0x00001810; -data_dma_code[73]= 0x000318c2; -data_dma_code[74]= 0x00031040; -data_dma_code[75]= 0x000320c0; -data_dma_code[76]= 0x00441021; -data_dma_code[77]= 0x00a21023; -data_dma_code[78]= 0x24420030; -data_dma_code[79]= 0x00602821; -data_dma_code[80]= 0x10a00013; -data_dma_code[81]= 0xa1020384; -data_dma_code[82]= 0x3c03cccc; -data_dma_code[83]= 0x3463cccd; -data_dma_code[84]= 0x00a30019; -data_dma_code[85]= 0x24e70001; -data_dma_code[86]= 0x00001810; -data_dma_code[87]= 0x000320c2; -data_dma_code[88]= 0x00041040; -data_dma_code[89]= 0x000418c0; -data_dma_code[90]= 0x00431021; -data_dma_code[91]= 0x00a21023; -data_dma_code[92]= 0x24420030; -data_dma_code[93]= 0xa0c20000; -data_dma_code[94]= 0x2402000b; -data_dma_code[95]= 0x10e2000d; -data_dma_code[96]= 0x24c60001; -data_dma_code[97]= 0x00802821; -data_dma_code[98]= 0x14a0fff0; -data_dma_code[99]= 0x3c03cccc; -data_dma_code[100]= 0x3c040000; -data_dma_code[101]= 0x24820378; -data_dma_code[102]= 0x00e21021; -data_dma_code[103]= 0x24e3ffff; -data_dma_code[104]= 0x04610008; -data_dma_code[105]= 0xa0400000; -data_dma_code[106]= 0x24850378; -data_dma_code[107]= 0x03e00008; -data_dma_code[108]= 0x00a01021; -data_dma_code[109]= 0x3c040000; -data_dma_code[110]= 0x24820378; -data_dma_code[111]= 0x2403000a; -data_dma_code[112]= 0xa040000b; -data_dma_code[113]= 0x24820378; -data_dma_code[114]= 0x00621821; -data_dma_code[115]= 0x3c020000; -data_dma_code[116]= 0x25050384; -data_dma_code[117]= 0x24460377; -data_dma_code[118]= 0x90a20000; -data_dma_code[119]= 0x00000000; -data_dma_code[120]= 0xa0620000; -data_dma_code[121]= 0x2463ffff; -data_dma_code[122]= 0x1466fffb; -data_dma_code[123]= 0x24a50001; -data_dma_code[124]= 0x0800006b; -data_dma_code[125]= 0x24850378; -data_dma_code[126]= 0x3c080000; -data_dma_code[127]= 0x2503036c; -data_dma_code[128]= 0x24050030; -data_dma_code[129]= 0x24020078; -data_dma_code[130]= 0xa0620001; -data_dma_code[131]= 0xa060000a; -data_dma_code[132]= 0x1480000b; -data_dma_code[133]= 0xa105036c; -data_dma_code[134]= 0xa0650009; -data_dma_code[135]= 0xa0650002; -data_dma_code[136]= 0xa0650003; -data_dma_code[137]= 0xa0650004; -data_dma_code[138]= 0xa0650005; -data_dma_code[139]= 0xa0650006; -data_dma_code[140]= 0xa0650007; -data_dma_code[141]= 0xa0650008; -data_dma_code[142]= 0x03e00008; -data_dma_code[143]= 0x2502036c; -data_dma_code[144]= 0x3c020000; -data_dma_code[145]= 0x3c030000; -data_dma_code[146]= 0x24470375; -data_dma_code[147]= 0x08000099; -data_dma_code[148]= 0x2463036d; -data_dma_code[149]= 0xa0e60000; -data_dma_code[150]= 0x24e7ffff; -data_dma_code[151]= 0x10e3fff6; -data_dma_code[152]= 0x00042102; -data_dma_code[153]= 0x3082000f; -data_dma_code[154]= 0x24460030; -data_dma_code[155]= 0x24450057; -data_dma_code[156]= 0x2c42000a; -data_dma_code[157]= 0x1440fff7; -data_dma_code[158]= 0x00000000; -data_dma_code[159]= 0x08000096; -data_dma_code[160]= 0xa0e50000; -data_dma_code[161]= 0x3c032000; -data_dma_code[162]= 0x24090001; -data_dma_code[163]= 0x34650200; -data_dma_code[164]= 0x34660220; -data_dma_code[165]= 0x34670210; -data_dma_code[166]= 0x34680230; -data_dma_code[167]= 0x24020006; -data_dma_code[168]= 0xaca20000; -data_dma_code[169]= 0xafa40000; -data_dma_code[170]= 0xacc90000; -data_dma_code[171]= 0x34630260; -data_dma_code[172]= 0xacfd0000; -data_dma_code[173]= 0xad090000; -data_dma_code[174]= 0x8c620000; -data_dma_code[175]= 0x00000000; -data_dma_code[176]= 0x1440fffd; -data_dma_code[177]= 0x00000000; -data_dma_code[178]= 0x03e00008; -data_dma_code[179]= 0x00000000; -data_dma_code[180]= 0x27bdffc8; -data_dma_code[181]= 0xafb1002c; -data_dma_code[182]= 0x3c110000; -data_dma_code[183]= 0x26240368; -data_dma_code[184]= 0xafb00028; -data_dma_code[185]= 0xafbf0030; -data_dma_code[186]= 0x0c00000c; -data_dma_code[187]= 0x27b00010; -data_dma_code[188]= 0x3c022000; -data_dma_code[189]= 0x34420020; -data_dma_code[190]= 0x8c430000; -data_dma_code[191]= 0x00000000; -data_dma_code[192]= 0x30630020; -data_dma_code[193]= 0x1060fffa; -data_dma_code[194]= 0x02002021; -data_dma_code[195]= 0x0c0000a1; -data_dma_code[196]= 0x00000000; -data_dma_code[197]= 0x0c00000c; -data_dma_code[198]= 0x26240368; -data_dma_code[199]= 0x8fa40010; -data_dma_code[200]= 0x0c000037; -data_dma_code[201]= 0x00000000; -data_dma_code[202]= 0x0c00000c; -data_dma_code[203]= 0x00402021; -data_dma_code[204]= 0x8fa40018; -data_dma_code[205]= 0x0c00007e; -data_dma_code[206]= 0x00000000; -data_dma_code[207]= 0x0c00000c; -data_dma_code[208]= 0x00402021; -data_dma_code[209]= 0x3c022000; -data_dma_code[210]= 0x34420020; -data_dma_code[211]= 0x8c430000; -data_dma_code[212]= 0x00000000; -data_dma_code[213]= 0x30630020; -data_dma_code[214]= 0x1060ffe5; -data_dma_code[215]= 0x02002021; -data_dma_code[216]= 0x080000c3; -data_dma_code[217]= 0x00000000; -data_dma_code[218]= 0x61000000; - + /* + int data_dma_operation[6]; + data_dma_operation[0]= 1; + data_dma_operation[1]= 2; + data_dma_operation[2]= 3; + data_dma_operation[3]= 4; + data_dma_operation[4]= 5; + data_dma_operation[5]= 6; + */ + + if(target == 0x00000101) { + //Trasmit + + #include "transmit.h" + + ServiceHeader *p = get_service_header_slot(); + p->header = 0x0101; + + p->service = DMA_OPERATION; + send_packet(p, transmit_code, sizeof(transmit_code)>>2); + //Se fosse inteiro era &nome da variavel e tamanho 1 + } + else { + // Receive - ServiceHeader *p = get_service_header_slot(); - p->header = 0x00000001; + #include "receive.h" - p->service = DMA_OPERATION; - //p->master_ID = cluster_master_address; + ServiceHeader *p = get_service_header_slot(); + + p->header = 0x0001; + p->service = DMA_OPERATION; + //p->master_ID = cluster_master_address; - send_packet(p, data_dma_code, 219); //send_packet(ServiceHeader *p, Endereco inicial do payload, tamanho do payload) - //Se fosse inteiro era &nome da variavel e tamanho 1 -} + send_packet(p, receive_code, sizeof(receive_code)>>2); + //Se fosse inteiro era &nome da variavel e tamanho 1 + } } @@ -1281,14 +787,14 @@ data_dma_code[218]= 0x61000000; void send_start_cpu(unsigned teste){ -/* int data_start_cpu[6]; - data_start_cpu[0]= 10; - data_start_cpu[1]= 11; - data_start_cpu[2]= 12; - data_start_cpu[3]= 13; - data_start_cpu[4]= 14; - data_start_cpu[5]= 15; -*/ + /* int data_start_cpu[6]; + data_start_cpu[0]= 10; + data_start_cpu[1]= 11; + data_start_cpu[2]= 12; + data_start_cpu[3]= 13; + data_start_cpu[4]= 14; + data_start_cpu[5]= 15; + */ ServiceHeader *p = get_service_header_slot(); p->header = teste; @@ -1301,7 +807,7 @@ void send_start_cpu(unsigned teste){ //p->master_ID = cluster_master_address; - send_packet(p, 0, 0); //send_packet(ServiceHeader *p, unsigned int initial_address, unsigned int dmni_msg_size) + send_packet(p, 0, 1); //send_packet(ServiceHeader *p, unsigned int initial_address, unsigned int dmni_msg_size) } @@ -1313,81 +819,76 @@ int main() { NewTask * pending_new_task; //By default HeMPS assumes that GM is positioned at address 0 - if ( MemoryRead(NI_CONFIG) == 0){ + /* if ( MemoryRead(NI_CONFIG) == 0){ - puts("This kernel is global master\n"); + puts("This kernel is global master\n"); - is_global_master = 1; + is_global_master = 1; - global_master_address = net_address; + global_master_address = net_address; - initialize_clusters(); + initialize_clusters(); - initialize_slaves(); - - initialize_cluster_load(); + initialize_slaves(); - } else { + initialize_cluster_load(); - puts("This kernel is local master\n"); + } else { - is_global_master = 0; - } + puts("This kernel is local master\n"); - initialize_applications(); + is_global_master = 0; + } - init_new_task_list(); + initialize_applications(); - init_service_header_slots(); + init_new_task_list(); + init_service_header_slots(); + */ send_dma_operation(0x00000101);//envio um pacote com servico de acesso direto a DMNI + puts("Sent software to PE 1x1\n"); send_dma_operation(0x00000001);//envio um pacote com servico de acesso direto a DMNI + puts("Sent software to PE 0x1\n"); send_start_cpu(0x00000001); + puts("Started PE 0x1\n"); send_start_cpu(0x00000101); + puts("Started PE 1x1\n"); + for (;;);/* { + //LM looping + if (noc_interruption){ + handle_packet(); + } else if (pending_app_to_map && is_reclustering_NOT_active()){ + handle_pending_application(); - puts("Kernel Initialized\n"); - - - for (;;) { - - //LM looping - if (noc_interruption){ - - handle_packet(); + //GM looping + } else if (is_global_master && !MemoryRead(DMNI_SEND_ACTIVE)) { - } else if (pending_app_to_map && is_reclustering_NOT_active()){ + pending_new_task = get_next_new_task(); - handle_pending_application(); + if (pending_new_task){ + send_task_allocation(pending_new_task); - //GM looping - } else if (is_global_master && !MemoryRead(DMNI_SEND_ACTIVE)) { + pending_new_task->task_ID = -1; - pending_new_task = get_next_new_task(); + } else if (app_req_reg) { - if (pending_new_task){ - - send_task_allocation(pending_new_task); - - pending_new_task->task_ID = -1; - - } else if (app_req_reg) { - - handle_app_request(); - } - } - } + handle_app_request(); + } + } + }*/ return 0; } diff --git a/software/kernel/master/receive.h b/software/kernel/master/receive.h new file mode 100644 index 0000000..8a6f09f --- /dev/null +++ b/software/kernel/master/receive.h @@ -0,0 +1,253 @@ +const unsigned int receive_code[] = { + 0x241d7fff, + 0x0c0000db, + 0x00000000, + 0x00002021, + 0x0000000c, + 0x00000000, + 0x08000006, + 0x00000000, + 0x0000000c, + 0x00000000, + 0x03e00008, + 0x00000000, + 0x8c820000, + 0x3c032000, + 0xac620000, + 0x00802821, + 0x80840000, + 0x00000000, + 0x10800022, + 0x00000000, + 0x80a20001, + 0x00000000, + 0x1040001e, + 0x00000000, + 0x80a20002, + 0x00000000, + 0x1040001a, + 0x00000000, + 0x80a20003, + 0x00000000, + 0x10400016, + 0x3c042000, + 0x0800002e, + 0x24a50004, + 0x80a20001, + 0x00000000, + 0x10400010, + 0x00000000, + 0x80a20002, + 0x00000000, + 0x1040000c, + 0x00000000, + 0x80a20003, + 0x00000000, + 0x10400008, + 0x24a50004, + 0x8ca20000, + 0x00000000, + 0xac820000, + 0x80a30000, + 0x00000000, + 0x1460ffee, + 0x00000000, + 0x03e00008, + 0x00001021, + 0x14800009, + 0x00802821, + 0x3c020000, + 0x24440408, + 0x00802821, + 0x24030030, + 0xa0430408, + 0x00a01021, + 0x03e00008, + 0xa0800001, + 0x3c03cccc, + 0x3463cccd, + 0x00830019, + 0x3c020000, + 0x24460409, + 0x3c080000, + 0x24070001, + 0x00001810, + 0x000318c2, + 0x00031040, + 0x000320c0, + 0x00441021, + 0x00a21023, + 0x24420030, + 0x00602821, + 0x10a00013, + 0xa1020408, + 0x3c03cccc, + 0x3463cccd, + 0x00a30019, + 0x24e70001, + 0x00001810, + 0x000320c2, + 0x00041040, + 0x000418c0, + 0x00431021, + 0x00a21023, + 0x24420030, + 0xa0c20000, + 0x2402000b, + 0x10e2000d, + 0x24c60001, + 0x00802821, + 0x14a0fff0, + 0x3c03cccc, + 0x3c040000, + 0x248203fc, + 0x00e21021, + 0x24e3ffff, + 0x04610008, + 0xa0400000, + 0x248503fc, + 0x03e00008, + 0x00a01021, + 0x3c040000, + 0x248203fc, + 0x2403000a, + 0xa040000b, + 0x248203fc, + 0x00621821, + 0x3c020000, + 0x25050408, + 0x244603fb, + 0x90a20000, + 0x00000000, + 0xa0620000, + 0x2463ffff, + 0x1466fffb, + 0x24a50001, + 0x0800006b, + 0x248503fc, + 0x3c080000, + 0x250303f0, + 0x24050030, + 0x24020078, + 0xa0620001, + 0xa060000a, + 0x1480000b, + 0xa10503f0, + 0xa0650009, + 0xa0650002, + 0xa0650003, + 0xa0650004, + 0xa0650005, + 0xa0650006, + 0xa0650007, + 0xa0650008, + 0x03e00008, + 0x250203f0, + 0x3c020000, + 0x3c030000, + 0x244703f9, + 0x08000099, + 0x246303f1, + 0xa0e60000, + 0x24e7ffff, + 0x10e3fff6, + 0x00042102, + 0x3082000f, + 0x24460030, + 0x24450057, + 0x2c42000a, + 0x1440fff7, + 0x00000000, + 0x08000096, + 0xa0e50000, + 0x3c082000, + 0x27bdfff0, + 0x35030250, + 0x8c620000, + 0x00000000, + 0x1440fffd, + 0x35020200, + 0x35040210, + 0x24030003, + 0xac430000, + 0xac9d0000, + 0x10e0000e, + 0x3c020000, + 0x35020205, + 0xac470000, + 0x35030215, + 0x3c022000, + 0xac660000, + 0x34440230, + 0x24030001, + 0x34420220, + 0x27bd0010, + 0xac400000, + 0xac830000, + 0x03e00008, + 0x00000000, + 0x35040205, + 0x24030001, + 0x244203ec, + 0x35050215, + 0xac830000, + 0xaca20000, + 0x3c022000, + 0x34440230, + 0x24030001, + 0x34420220, + 0x27bd0010, + 0xac400000, + 0xac830000, + 0x03e00008, + 0x00000000, + 0x24820003, + 0x3c032000, + 0x2404fffc, + 0x00441024, + 0x34630264, + 0xac620000, + 0x03e00008, + 0x00000000, + 0x3c022000, + 0x34430264, + 0x8c620000, + 0x00000000, + 0x30420001, + 0x1040fffc, + 0x00000000, + 0x03e00008, + 0x00000000, + 0x27bdffd8, + 0xafb3001c, + 0xafb20018, + 0xafb10014, + 0xafbf0020, + 0xafb00010, + 0x3c130000, + 0x3c120000, + 0x3c110000, + 0x0c0000ca, + 0x26640414, + 0x264403c4, + 0x0c00000c, + 0x00408021, + 0x0c0000d2, + 0x00000000, + 0x0c00000c, + 0x262403dc, + 0x0c00000c, + 0x02002021, + 0x080000e4, + 0x00000000, + 0x50726570, + 0x61726564, + 0x20746f20, + 0x72656365, + 0x6976650a, + 0x00000000, + 0x44617461, + 0x20526563, + 0x65697665, + 0x640a0000, + 0x00000000}; diff --git a/software/kernel/master/transmit.h b/software/kernel/master/transmit.h new file mode 100644 index 0000000..278531e --- /dev/null +++ b/software/kernel/master/transmit.h @@ -0,0 +1,237 @@ +const unsigned int transmit_code[] = { + 0x241d7fff, + 0x0c0000d4, + 0x00000000, + 0x00002021, + 0x0000000c, + 0x00000000, + 0x08000006, + 0x00000000, + 0x0000000c, + 0x00000000, + 0x03e00008, + 0x00000000, + 0x8c820000, + 0x3c032000, + 0xac620000, + 0x00802821, + 0x80840000, + 0x00000000, + 0x10800022, + 0x00000000, + 0x80a20001, + 0x00000000, + 0x1040001e, + 0x00000000, + 0x80a20002, + 0x00000000, + 0x1040001a, + 0x00000000, + 0x80a20003, + 0x00000000, + 0x10400016, + 0x3c042000, + 0x0800002e, + 0x24a50004, + 0x80a20001, + 0x00000000, + 0x10400010, + 0x00000000, + 0x80a20002, + 0x00000000, + 0x1040000c, + 0x00000000, + 0x80a20003, + 0x00000000, + 0x10400008, + 0x24a50004, + 0x8ca20000, + 0x00000000, + 0xac820000, + 0x80a30000, + 0x00000000, + 0x1460ffee, + 0x00000000, + 0x03e00008, + 0x00001021, + 0x14800009, + 0x00802821, + 0x3c020000, + 0x244403d4, + 0x00802821, + 0x24030030, + 0xa04303d4, + 0x00a01021, + 0x03e00008, + 0xa0800001, + 0x3c03cccc, + 0x3463cccd, + 0x00830019, + 0x3c020000, + 0x244603d5, + 0x3c080000, + 0x24070001, + 0x00001810, + 0x000318c2, + 0x00031040, + 0x000320c0, + 0x00441021, + 0x00a21023, + 0x24420030, + 0x00602821, + 0x10a00013, + 0xa10203d4, + 0x3c03cccc, + 0x3463cccd, + 0x00a30019, + 0x24e70001, + 0x00001810, + 0x000320c2, + 0x00041040, + 0x000418c0, + 0x00431021, + 0x00a21023, + 0x24420030, + 0xa0c20000, + 0x2402000b, + 0x10e2000d, + 0x24c60001, + 0x00802821, + 0x14a0fff0, + 0x3c03cccc, + 0x3c040000, + 0x248203c8, + 0x00e21021, + 0x24e3ffff, + 0x04610008, + 0xa0400000, + 0x248503c8, + 0x03e00008, + 0x00a01021, + 0x3c040000, + 0x248203c8, + 0x2403000a, + 0xa040000b, + 0x248203c8, + 0x00621821, + 0x3c020000, + 0x250503d4, + 0x244603c7, + 0x90a20000, + 0x00000000, + 0xa0620000, + 0x2463ffff, + 0x1466fffb, + 0x24a50001, + 0x0800006b, + 0x248503c8, + 0x3c080000, + 0x250303bc, + 0x24050030, + 0x24020078, + 0xa0620001, + 0xa060000a, + 0x1480000b, + 0xa10503bc, + 0xa0650009, + 0xa0650002, + 0xa0650003, + 0xa0650004, + 0xa0650005, + 0xa0650006, + 0xa0650007, + 0xa0650008, + 0x03e00008, + 0x250203bc, + 0x3c020000, + 0x3c030000, + 0x244703c5, + 0x08000099, + 0x246303bd, + 0xa0e60000, + 0x24e7ffff, + 0x10e3fff6, + 0x00042102, + 0x3082000f, + 0x24460030, + 0x24450057, + 0x2c42000a, + 0x1440fff7, + 0x00000000, + 0x08000096, + 0xa0e50000, + 0x3c020000, + 0x00e04821, + 0xac4403b0, + 0x00a05821, + 0x10e0001c, + 0x00c05021, + 0x3c032000, + 0x244403b0, + 0x34670215, + 0x34650200, + 0x34660210, + 0x25280001, + 0x34630205, + 0x24020003, + 0xaca20000, + 0xacc40000, + 0xac690000, + 0xacea0000, + 0xac880004, + 0xac8b0008, + 0x3c032000, + 0x34640220, + 0x34650230, + 0x24020001, + 0xac800000, + 0x34630250, + 0xaca20000, + 0x8c620000, + 0x00000000, + 0x1440fffd, + 0x00000000, + 0x03e00008, + 0x00000000, + 0x3c042000, + 0x244503b0, + 0x34830200, + 0x24020003, + 0xac620000, + 0x34870215, + 0x34860210, + 0x24030001, + 0x34840205, + 0x3c020000, + 0xacc50000, + 0x244203ac, + 0xac830000, + 0x24030002, + 0xace20000, + 0xaca30004, + 0x080000b5, + 0xacab0008, + 0x27bdffd8, + 0x3c030000, + 0x2462039c, + 0xafbf0020, + 0x8c68039c, + 0x944a000c, + 0x8c490004, + 0x8c430008, + 0x24040001, + 0x24050290, + 0x27a60010, + 0x24070004, + 0xafa80010, + 0xafa90014, + 0xafa30018, + 0x0c0000a1, + 0xa7aa001c, + 0x080000e5, + 0x00000000, + 0x48656c6c, + 0x6f20576f, + 0x726c6421, + 0x0a000000, + 0x00000000}; diff --git a/software/modules/packet.h b/software/modules/packet.h index d24e616..466b52e 100644 --- a/software/modules/packet.h +++ b/software/modules/packet.h @@ -17,7 +17,7 @@ #include "../../include/kernel_pkg.h" -#define CONSTANT_PKT_SIZE 13 //! Date: Fri, 27 Oct 2017 13:51:48 -0200 Subject: [PATCH 25/54] implemented task return rotine --- applications/transmit/receive.c | 2 - applications/transmit/transmit.c | 2 +- build_env/makes/make_app | 2 +- hardware/vhdl/pe/dmni/dmni.vhd | 29 ++++++---- hardware/vhdl/pe/pe.vhd | 10 ++-- hardware/vhdl/standards.vhd | 21 +++++--- software/boot_task/boot_task.asm | 50 ------------------ software/boot_task/boot_task.s | 81 ++++++++++++++++++++++++++++ software/kernel/master/receive.h | 88 +++++++++++++++++++------------ software/kernel/master/transmit.h | 88 +++++++++++++++++++------------ 10 files changed, 229 insertions(+), 144 deletions(-) delete mode 100644 software/boot_task/boot_task.asm create mode 100644 software/boot_task/boot_task.s diff --git a/applications/transmit/receive.c b/applications/transmit/receive.c index 1035ac7..a7954e8 100644 --- a/applications/transmit/receive.c +++ b/applications/transmit/receive.c @@ -165,13 +165,11 @@ volatile unsigned int glob_buff[256]; int main() { volatile char *buff; - for(;;) { buff=prepare_receive(glob_buff); puts("Prepared to receive\n"); wait_receive(); puts("Data Received\n"); puts((char*)buff); - } return 0; } diff --git a/applications/transmit/transmit.c b/applications/transmit/transmit.c index 85df65c..a9386b8 100644 --- a/applications/transmit/transmit.c +++ b/applications/transmit/transmit.c @@ -156,5 +156,5 @@ int main() { transmite(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); - for(;;); + return 0; } diff --git a/build_env/makes/make_app b/build_env/makes/make_app index 7a1af76..50a9e4d 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -11,7 +11,7 @@ DUMP_MIPS = mips-elf-objdump COPY_MIPS = mips-elf-objcopy -I elf32-bigmips -O binary BOOT_TASK = boot_task -BOOT_TASK_SRC = ../../software/boot_task/boot_task.asm +BOOT_TASK_SRC = ../../software/boot_task/boot_task.s TASK_SRC = $(wildcard *.c) TASK_OBJ = $(TASK_SRC:.c=.o) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index b7e7fa6..3822f96 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -35,12 +35,13 @@ entity dmni is set_op : in std_logic; start : in std_logic; set_buff : in std_logic; + set_reset_cpu : in std_logic; config_data : in std_logic_vector(31 downto 0); -- Status outputs intr : out std_logic; send_active : out std_logic; receive_active : out std_logic; - reset_dmni : out std_logic; + reset_cpu : out std_logic; recv_buff_out : out std_logic_vector(31 downto 0); -- Memory interface mem_address : out std_logic_vector(31 downto 0); @@ -108,7 +109,7 @@ architecture dmni of dmni is signal receive_active_2 : std_logic; signal intr_counter_temp : std_logic_vector(3 downto 0); - signal reset_dmni_s : std_logic; + signal reset_cpu_r : std_logic; signal payload_fix : regflit; signal sizedata_fix : regflit; signal recv_op : operation_type; @@ -118,6 +119,7 @@ begin begin if reset = '1' then recv_buffer <= (others => '0'); + reset_cpu <= '1'; elsif(clock'event and clock = '1') then if (set_address = '1') then address <= config_data; @@ -133,9 +135,18 @@ begin operation <= config_data(0); elsif set_buff = '1' then recv_buffer <= config_data; - elsif dmma_done = '1' then + elsif set_reset_cpu = '1' and config_data = x"DEADBEEF" then + reset_cpu <= '1'; + end if; + + if reset_cpu_r = '1' then + reset_cpu <= '0'; + end if; + + if dmma_done = '1' then recv_buffer(0) <= '1'; end if; + end if; end process proc_config; @@ -203,7 +214,7 @@ begin proc_receive : process (clock, reset) begin if (reset = '1') then - reset_dmni_s <= '1'; + reset_cpu_r <= '0'; payload_fix <= (others => '0'); sizedata_fix <= (others => '0'); recv_op <= LEGACY; @@ -245,15 +256,16 @@ begin when DATA => is_header(CONV_INTEGER(last)) <= '0'; if(payload_size = 0) then - SR <= HEADER; - recv_op <= LEGACY; + SR <= HEADER; + recv_op <= LEGACY; + reset_cpu_r <= '0'; else payload_size <= payload_size - 1; if (payload_size = payload_fix) then if (data_in = x"00000300") then --Service 300 start_cpu - reset_dmni_s <= '0'; - recv_op <= START_CPU; + reset_cpu_r <= '1'; + recv_op <= START_CPU; end if; end if; if (payload_size = payload_fix) then @@ -356,7 +368,6 @@ begin intr_count <= intr_counter_temp; intr <= '1' when intr_counter_temp > 0 else '0'; - reset_dmni <= reset_dmni_s; proc_send : process (clock, reset) begin diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 5f4a98d..c6466d6 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -115,7 +115,8 @@ architecture structural of pe is signal data_av : std_logic; signal end_sim_reg : std_logic_vector(31 downto 0); signal uart_write_data : std_logic; - signal dmni_recv_buff : std_logic_vector(31 downto 0); + signal dmni_recv_buff : std_logic_vector(31 downto 0); + signal cpu_set_reset : std_logic; signal slack_update_timer : std_logic_vector(31 downto 0); @@ -226,12 +227,13 @@ begin start => cpu_start, config_data => dmni_data_read, set_buff => cpu_set_buff, + set_reset_cpu => cpu_set_reset, -- Status outputs intr => ni_intr, send_active => dmni_send_active_sig, receive_active => dmni_receive_active_sig, - reset_dmni => reset_dmni, + reset_cpu => reset_dmni, recv_buff_out => dmni_recv_buff, -- Memory interface @@ -298,7 +300,8 @@ begin req_app when cpu_mem_address_reg = REQ_APP_REG else ZERO(31 downto 1) & dmni_send_active_sig when cpu_mem_address_reg = DMNI_SEND_ACTIVE else ZERO(31 downto 1) & dmni_receive_active_sig when cpu_mem_address_reg = DMNI_RECEIVE_ACTIVE else - dmni_recv_buff when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER else + dmni_recv_buff when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER else + LOADER_NETADDR when cpu_mem_address_reg = LOADER_NETADDR_REG else data_read_ram; --Comb assignments @@ -334,6 +337,7 @@ begin cpu_set_op <= '1' when cpu_mem_address_reg = DMNI_OP and write_enable = '1' else '0'; cpu_start <= '1' when cpu_mem_address_reg = START_DMNI and write_enable = '1' else '0'; cpu_set_buff <= '1' when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER and write_enable = '1' else '0'; + cpu_set_reset <= '1' when cpu_mem_address_reg = SET_CPU_KILL else '0'; write_enable <= '1' when cpu_mem_write_byte_enable_reg /= "0000" else '0'; diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index e0c6831..e1cf23b 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -20,18 +20,22 @@ use work.hemps_pkg.all; package standards is + -- at this moment assume the loader is fixed at router 0 south port + constant LOADER_NETADDR : std_logic_vector(31 downto 0) := x"E0000000"; + -------------------------------------------------------- -- CONSTANTS -------------------------------------------------------- -- Memory map constants. - constant DEBUG : std_logic_vector(31 downto 0) := x"20000000"; - constant IRQ_MASK : std_logic_vector(31 downto 0) := x"20000010"; - constant IRQ_STATUS_ADDR : std_logic_vector(31 downto 0) := x"20000020"; - constant TIME_SLICE_ADDR : std_logic_vector(31 downto 0) := x"20000060"; - constant FIFO_AVAIL : std_logic_vector(31 downto 0) := x"20000040"; - constant END_SIM : std_logic_vector(31 downto 0) := x"20000080"; - constant CLOCK_HOLD : std_logic_vector(31 downto 0) := x"20000090"; - constant NET_ADDRESS : std_logic_vector(31 downto 0) := x"20000140"; + constant DEBUG : std_logic_vector(31 downto 0) := x"20000000"; + constant IRQ_MASK : std_logic_vector(31 downto 0) := x"20000010"; + constant IRQ_STATUS_ADDR : std_logic_vector(31 downto 0) := x"20000020"; + constant TIME_SLICE_ADDR : std_logic_vector(31 downto 0) := x"20000060"; + constant FIFO_AVAIL : std_logic_vector(31 downto 0) := x"20000040"; + constant END_SIM : std_logic_vector(31 downto 0) := x"20000080"; + constant CLOCK_HOLD : std_logic_vector(31 downto 0) := x"20000090"; + constant NET_ADDRESS : std_logic_vector(31 downto 0) := x"20000140"; + constant LOADER_NETADDR_REG : std_logic_vector(31 downto 0) := x"20000144"; -- Network interface mapping. constant NI_STATUS_READ : std_logic_vector(31 downto 0) := x"20000100"; @@ -59,6 +63,7 @@ package standards is constant SCHEDULING_REPORT : std_logic_vector(31 downto 0) := x"20000270"; constant TICK_COUNTER_ADDR : std_logic_vector(31 downto 0) := x"20000300"; + constant SET_CPU_KILL : std_logic_vector(31 downto 0) := x"20000320"; constant REQ_APP_REG : std_logic_vector(31 downto 0) := x"20000350"; constant ACK_APP_REG : std_logic_vector(31 downto 0) := x"20000360"; diff --git a/software/boot_task/boot_task.asm b/software/boot_task/boot_task.asm deleted file mode 100644 index a90440e..0000000 --- a/software/boot_task/boot_task.asm +++ /dev/null @@ -1,50 +0,0 @@ -## HEMPS VERSION - 8.0 - support for RT applications -## -## Distribution: June 2016 -## -## Created by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br -## -## Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br -## -## Brief description: Initializes the stack pointer and jumps to main(). Handles the syscall. - - - - .text - .align 2 - .globl entry - .ent entry -entry: - .set noreorder - - li $sp,sp_addr # new initialization - - jal main - nop - - move $4,$0 - syscall - nop - -$L1: - j $L1 - nop - - .end entry - -################################################### - - .globl SystemCall - .ent SystemCall -SystemCall: - .set noreorder - - syscall - nop - jr $31 - nop - - .set reorder - .end SystemCall - - diff --git a/software/boot_task/boot_task.s b/software/boot_task/boot_task.s new file mode 100644 index 0000000..cdafd52 --- /dev/null +++ b/software/boot_task/boot_task.s @@ -0,0 +1,81 @@ +## HEMPS VERSION - 8.0 - support for RT applications +## +## Distribution: June 2016 +## +## Created by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br +## +## Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br +## +## Brief description: Initializes the stack pointer and jumps to main(). Handles the syscall. + + + + .text + .align 2 + .globl entry + .ent entry +entry: + .set noreorder + + li $sp,sp_addr ; new initialization + + jal main + nop + + beq $zero, $zero, exit + or $a0, $v0, $zero + .end entry + + .globl exit + .ent exit + .set noreorder +exit: + lui $s0, 0x2000 ; $s0 = *HARDWARE_REGISTERS + la $s1, .RET_MSG ; $s1 = *RET_MSG + + ;; assemble the package + lw $t0, 320($s0) ; $t0 = NET_ADDRESS + lw $t1, 324($s0) ; $t1 = LOADER_NETADDR + sw $t0, 12($s1) ; RET_MSG.SOURCE = $t0 + sw $t1, 0($s1) ; RET_MSG.TARGET = $t1 + ori $t0, $zero, 5 ; $t0 = 5 (DMNI_SIZE) + sw $a0, 0($s1) ; RET_MSG.RETURN_CODE = $a0 + + ;; send it + sw $t0, 512($s0) ; *DMNI_SIZE = $t0 + sw $s1, 528($s0) ; *DMNI_ADDR = $s1 + ori $t0, $zero, 1 ; $t0 = 1 + sw $zero, 544($s0) ; READ -> DMNI_OP + sw $t0, 560($s0) ; 1 -> DMNI_START + + ;; commit suicide + li $t0, 0xDEADBEAF ; MAGIC WORD TO KILL CPU +.L1: + beq $zero, $zero, .L1 + sw $t0, 800($s0) ; SET_CPU_KILL + .end exit + +; memory region reserved to assemble termination pkg +.RET_MSG: + .word 0 ; TARGET + .word 2 ; SIZE + .word 0x70 ; SERVICE + .word 0 ; SOURCE + .word 0 ; RETURN_CODE + +################################################### + + .globl SystemCall + .ent SystemCall +SystemCall: + .set noreorder + + syscall + nop + jr $31 + nop + + .set reorder + .end SystemCall + + diff --git a/software/kernel/master/receive.h b/software/kernel/master/receive.h index 8a6f09f..639c0ad 100644 --- a/software/kernel/master/receive.h +++ b/software/kernel/master/receive.h @@ -1,11 +1,29 @@ const unsigned int receive_code[] = { 0x241d7fff, - 0x0c0000db, + 0x3c1f0000, + 0x27ff0014, + 0x080000ed, 0x00000000, - 0x00002021, - 0x0000000c, - 0x00000000, - 0x08000006, + 0x3c102000, + 0x3c110000, + 0x26310058, + 0x8e080140, + 0x8e090144, + 0xae280003, + 0x34080004, + 0xae290000, + 0xae080200, + 0xae110210, + 0x34080001, + 0xae000220, + 0xae080230, + 0x3c08dead, + 0x3508beaf, + 0x08000014, + 0xae080320, + 0x00000000, + 0x00000002, + 0x00000070, 0x00000000, 0x0000000c, 0x00000000, @@ -31,7 +49,7 @@ const unsigned int receive_code[] = { 0x00000000, 0x10400016, 0x3c042000, - 0x0800002e, + 0x08000040, 0x24a50004, 0x80a20001, 0x00000000, @@ -57,10 +75,10 @@ const unsigned int receive_code[] = { 0x14800009, 0x00802821, 0x3c020000, - 0x24440408, + 0x24440450, 0x00802821, 0x24030030, - 0xa0430408, + 0xa0430450, 0x00a01021, 0x03e00008, 0xa0800001, @@ -68,7 +86,7 @@ const unsigned int receive_code[] = { 0x3463cccd, 0x00830019, 0x3c020000, - 0x24460409, + 0x24460451, 0x3c080000, 0x24070001, 0x00001810, @@ -80,7 +98,7 @@ const unsigned int receive_code[] = { 0x24420030, 0x00602821, 0x10a00013, - 0xa1020408, + 0xa1020450, 0x3c03cccc, 0x3463cccd, 0x00a30019, @@ -100,39 +118,39 @@ const unsigned int receive_code[] = { 0x14a0fff0, 0x3c03cccc, 0x3c040000, - 0x248203fc, + 0x24820444, 0x00e21021, 0x24e3ffff, 0x04610008, 0xa0400000, - 0x248503fc, + 0x24850444, 0x03e00008, 0x00a01021, 0x3c040000, - 0x248203fc, + 0x24820444, 0x2403000a, 0xa040000b, - 0x248203fc, + 0x24820444, 0x00621821, 0x3c020000, - 0x25050408, - 0x244603fb, + 0x25050450, + 0x24460443, 0x90a20000, 0x00000000, 0xa0620000, 0x2463ffff, 0x1466fffb, 0x24a50001, - 0x0800006b, - 0x248503fc, + 0x0800007d, + 0x24850444, 0x3c080000, - 0x250303f0, + 0x25030438, 0x24050030, 0x24020078, 0xa0620001, 0xa060000a, 0x1480000b, - 0xa10503f0, + 0xa1050438, 0xa0650009, 0xa0650002, 0xa0650003, @@ -142,12 +160,12 @@ const unsigned int receive_code[] = { 0xa0650007, 0xa0650008, 0x03e00008, - 0x250203f0, + 0x25020438, 0x3c020000, 0x3c030000, - 0x244703f9, - 0x08000099, - 0x246303f1, + 0x24470441, + 0x080000ab, + 0x24630439, 0xa0e60000, 0x24e7ffff, 0x10e3fff6, @@ -158,7 +176,7 @@ const unsigned int receive_code[] = { 0x2c42000a, 0x1440fff7, 0x00000000, - 0x08000096, + 0x080000a8, 0xa0e50000, 0x3c082000, 0x27bdfff0, @@ -188,7 +206,7 @@ const unsigned int receive_code[] = { 0x00000000, 0x35040205, 0x24030001, - 0x244203ec, + 0x24420434, 0x35050215, 0xac830000, 0xaca20000, @@ -227,18 +245,18 @@ const unsigned int receive_code[] = { 0x3c130000, 0x3c120000, 0x3c110000, - 0x0c0000ca, - 0x26640414, - 0x264403c4, - 0x0c00000c, + 0x0c0000dc, + 0x2664045c, + 0x2644040c, + 0x0c00001e, 0x00408021, - 0x0c0000d2, + 0x0c0000e4, 0x00000000, - 0x0c00000c, - 0x262403dc, - 0x0c00000c, + 0x0c00001e, + 0x26240424, + 0x0c00001e, 0x02002021, - 0x080000e4, + 0x080000f6, 0x00000000, 0x50726570, 0x61726564, diff --git a/software/kernel/master/transmit.h b/software/kernel/master/transmit.h index 278531e..27c64bb 100644 --- a/software/kernel/master/transmit.h +++ b/software/kernel/master/transmit.h @@ -1,11 +1,29 @@ const unsigned int transmit_code[] = { 0x241d7fff, - 0x0c0000d4, - 0x00000000, - 0x00002021, - 0x0000000c, - 0x00000000, - 0x08000006, + 0x3c1f0000, + 0x27ff0014, + 0x080000e6, + 0x00000000, + 0x3c102000, + 0x3c110000, + 0x26310058, + 0x8e080140, + 0x8e090144, + 0xae280003, + 0x34080004, + 0xae290000, + 0xae080200, + 0xae110210, + 0x34080001, + 0xae000220, + 0xae080230, + 0x3c08dead, + 0x3508beaf, + 0x08000014, + 0xae080320, + 0x00000000, + 0x00000002, + 0x00000070, 0x00000000, 0x0000000c, 0x00000000, @@ -31,7 +49,7 @@ const unsigned int transmit_code[] = { 0x00000000, 0x10400016, 0x3c042000, - 0x0800002e, + 0x08000040, 0x24a50004, 0x80a20001, 0x00000000, @@ -57,10 +75,10 @@ const unsigned int transmit_code[] = { 0x14800009, 0x00802821, 0x3c020000, - 0x244403d4, + 0x2444041c, 0x00802821, 0x24030030, - 0xa04303d4, + 0xa043041c, 0x00a01021, 0x03e00008, 0xa0800001, @@ -68,7 +86,7 @@ const unsigned int transmit_code[] = { 0x3463cccd, 0x00830019, 0x3c020000, - 0x244603d5, + 0x2446041d, 0x3c080000, 0x24070001, 0x00001810, @@ -80,7 +98,7 @@ const unsigned int transmit_code[] = { 0x24420030, 0x00602821, 0x10a00013, - 0xa10203d4, + 0xa102041c, 0x3c03cccc, 0x3463cccd, 0x00a30019, @@ -100,39 +118,39 @@ const unsigned int transmit_code[] = { 0x14a0fff0, 0x3c03cccc, 0x3c040000, - 0x248203c8, + 0x24820410, 0x00e21021, 0x24e3ffff, 0x04610008, 0xa0400000, - 0x248503c8, + 0x24850410, 0x03e00008, 0x00a01021, 0x3c040000, - 0x248203c8, + 0x24820410, 0x2403000a, 0xa040000b, - 0x248203c8, + 0x24820410, 0x00621821, 0x3c020000, - 0x250503d4, - 0x244603c7, + 0x2505041c, + 0x2446040f, 0x90a20000, 0x00000000, 0xa0620000, 0x2463ffff, 0x1466fffb, 0x24a50001, - 0x0800006b, - 0x248503c8, + 0x0800007d, + 0x24850410, 0x3c080000, - 0x250303bc, + 0x25030404, 0x24050030, 0x24020078, 0xa0620001, 0xa060000a, 0x1480000b, - 0xa10503bc, + 0xa1050404, 0xa0650009, 0xa0650002, 0xa0650003, @@ -142,12 +160,12 @@ const unsigned int transmit_code[] = { 0xa0650007, 0xa0650008, 0x03e00008, - 0x250203bc, + 0x25020404, 0x3c020000, 0x3c030000, - 0x244703c5, - 0x08000099, - 0x246303bd, + 0x2447040d, + 0x080000ab, + 0x24630405, 0xa0e60000, 0x24e7ffff, 0x10e3fff6, @@ -158,16 +176,16 @@ const unsigned int transmit_code[] = { 0x2c42000a, 0x1440fff7, 0x00000000, - 0x08000096, + 0x080000a8, 0xa0e50000, 0x3c020000, 0x00e04821, - 0xac4403b0, + 0xac4403f8, 0x00a05821, 0x10e0001c, 0x00c05021, 0x3c032000, - 0x244403b0, + 0x244403f8, 0x34670215, 0x34650200, 0x34660210, @@ -194,7 +212,7 @@ const unsigned int transmit_code[] = { 0x03e00008, 0x00000000, 0x3c042000, - 0x244503b0, + 0x244503f8, 0x34830200, 0x24020003, 0xac620000, @@ -204,18 +222,18 @@ const unsigned int transmit_code[] = { 0x34840205, 0x3c020000, 0xacc50000, - 0x244203ac, + 0x244203f4, 0xac830000, 0x24030002, 0xace20000, 0xaca30004, - 0x080000b5, + 0x080000c7, 0xacab0008, 0x27bdffd8, 0x3c030000, - 0x2462039c, + 0x246203e4, 0xafbf0020, - 0x8c68039c, + 0x8c6803e4, 0x944a000c, 0x8c490004, 0x8c430008, @@ -226,9 +244,9 @@ const unsigned int transmit_code[] = { 0xafa80010, 0xafa90014, 0xafa30018, - 0x0c0000a1, + 0x0c0000b3, 0xa7aa001c, - 0x080000e5, + 0x080000f7, 0x00000000, 0x48656c6c, 0x6f20576f, From 4e7080743beead188506e716007ccd0c98813bba Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 27 Oct 2017 14:11:13 -0200 Subject: [PATCH 26/54] Integrated Alzermiro's and Krause's modifications --- build_env/bin/ram_generator | Bin 37968 -> 37976 bytes build_env/bin/ram_generator.c | 5 +- build_env/makes/make_app | 4 +- build_env/makes/make_vhdl | 4 +- build_env/makes/sim.do | 2 +- build_env/scripts/app_builder.py | 27 +- build_env/scripts/hw_builder.py | 32 +- build_env/scripts/kernel_builder.py | 3 + build_env/scripts/yaml_intf.py | 35 ++ hardware/vhdl/hemps.vhd | 165 ++++----- hardware/vhdl/inject_data.vhd | 7 + hardware/vhdl/pe/pe.vhd | 60 ++-- hardware/vhdl/standards.vhd | 102 +++--- hardware/vhdl/test_bench.vhd | 533 +++++++++++++--------------- 14 files changed, 521 insertions(+), 458 deletions(-) mode change 100755 => 100644 build_env/bin/ram_generator.c diff --git a/build_env/bin/ram_generator b/build_env/bin/ram_generator index 451a35b61b0e751f96f2d33660a86cca46eb29e6..c70fcc06ee680db2c33279efff07576408f23df0 100755 GIT binary patch delta 5522 zcmZ|T4^&iD9>DQ=kSkaUX3C&~AQB*Z>k9UWY39kyi`YCGauC)l)xtRt+U!#`a8akn=cTTJakw{;QccP%e1{ zGCEOo`LZY*okvyZENVxmku^!whV1ABDn&<-3)LeJszph&MEg(?+O6|M4tKduq_S8i z-XYqo6HzXzLu*kt%0ThSqQxi+rJ-t+jNB*zS!au)&`K1d^Ux@r=Yak?agNCJkcfIw zH9Ch{Q6~!grRXGDf?7}!YC?_ZF!Gx#I*5|cepHC|>O55GF&&a<6YkWBXsb>{n{*<| zLER`5#ixkUQ65@|s!M8&8FJ*PTH z1Uss@Z{gmJnvgwJbQo2kgUEySBio&#y{Hsb>L}WYveQIcQ8n6x+EES)oF~desVM!D zY}7$-fRZZ~+3R{p$t2lHN zB0Ks;I!skt1HDU;phNm;k$&zFR7(0N+{30n~_IL;9_-2kGs!3+e5&9qH|~1?lay0qNbe z4(Z*r3Poo~e@jsnnveYM7tL|NLO2b%Q4CtSN;Cnv&}fwOfape4gAAm%=cRv(^!EH7 z>FxOy(#QN1(%bXzNN>-NkZezf#r+}F`}2LI_vc%P{po%c>FueI-kxPhZ%+r(+p_@a z?fDqe+jBJvd{BB>fr`-Gs2imsN7h5aS+EsNMfOZlBx*$CP*Rp?B&tJ0QS@rj^&U|* zx`3=}L|v!?eTn?miatX{=wswT$9g#b`T%`Er9MFKB7J~fNBRK0jPwC|0qFx&g8Vo? zPa}PPHX?m~9!2{6Jc#u9S%&oaS)lXetT^0rbt1=RhE7DWI+48`j`AKB1)(}L9CagK z6u(Y%xtlz69yOq|$nuEjG_s>MRDn*Q_IdCK40}{mkFrrMszdvb2kl0-Y*9HXMa3vp zEgchMG^?k_Ofp(jwUlk@BPma*Z>8*10YQ_DE;U`s9+e^GRkbZ>lFyJF^+r&H&xjn= z928*$sqZB+QQd5vWW=dNDU;L#Ql_e6DeqBlO4+PFma;{4OWCGI2lEMcNZF|}rR-AA zO4*}orM#;CCS|j_AZ3fPjwOH2*l@|ul(JbBOWC4c9~&N+k< zl&Cf1Q;pxMH^(O!uc-F%AvgYB^4y*6`Y~ynin7rxRD-4>H;Pp8Awfp8Y77~ZlefOV>+upF z=(=v8dI-(B<<|YNTQoUWbWGGW+mP3-9`hdv=rPxbHiw2LH4G#?NFRFa5lD|c80oPG{CB?|)e;(OO?te)_bcBF8hV}z zoDe#;Xdrl8f_)G09Ga}`6XqF5)e94n9WF_7U;kQaeKv?Lh|1GCWM-{$+c)q4X=5)> zYv=3ow1L{ov{^tKC(1&HP%%1yUO}&+MzjaH(JmC2Cvt3u32+Nqgf^f&v<_9FRp=;M ziatm4(GO^jsDFqzZ|ooV3gS_6>kdJ)(I~V6`6Gv}G|viisq96%?i_lCy3T>Rlc25)2CaJh^MnYAhzR$UZ%nkzo zJY)Kr&QRqEzt@OS3nxYzv1;SQOv9$yCZ@@|A}As>V|l*(3{!T({pDAtS<)C#a!vNM zOnIw)d!yA}ZaKQj8+Yn>!T9p@Gvx&xlF@xQ*BcrpAK3MgoSDJx^40SZV;v>lluu-c zUAumgQtk~d{(0B0dPBdXUHVVjz2OZ8{k+{FZ)gqeLJWt+GHARXdV})_8b5X#$aDV5 z8*KVl-#ncBKlAXqj{nbj7$?6abkz=S=a7!`y&XT+*D!d{fcj_WEBOk3E`RXs^-s;r zpEv5Cn)hflcW|Trc`^DLMUN#nfx52)!Y;?!IH8fWqC@OnUbDz z-=bZS@2w28q}zAJab32c?Bas5&lbg;wQv8<&wlK>uiNaX-w-)_@v==hxq0i?S>m$g zsV&Ah-{eJd^^?Etm8MxGSJ#WCN${vL%|^MNd)qWS8OY^+q_1ykkUw50`6J{Mn9PZfk3zUt+I2|nfl^~ZwH@KNuW=3TzhPs)hE9X_eU zf8m?vd(%)q%biknT>jeB<%0P}c74i|9}HE2+ib@1`lZ|M@tHJzN_^bRf;9z?=NBYw zOPDz&e)^Q@F<~>NNPXDt@d-2IXU5M`ZAN(g=SBA!#&MPKOpwtkqX z&s;K$Y_;*(7Yvs&N~Ri(Dxu`0B>V3;DaoBXf{Z2V@{T>mUGLM2 zGA*7}&r`98*UwNWJ+WvW)qmCx;x KGE2q06!jm~wb_>d delta 5587 zcmZ|T4^)-q9l-JXg3gPjU?%_MugJs*0nvcegc*8GOHfIi8JJqIW@361YkDO_aAaM2 z@<_8C>6C?Y<#pH@oJJRqm3YccY9-Fo5f-kOSrc+3{@dN}`*2~bHO}FAKkxJVJulDS z_i%4pozLkyA7`B5te*U)-_oZn`e$kNS@#&%rv4k(rVI_2I%u4`eQMDMBSzg9+THz% zQC(NKXX77ohJ9XN<1=!&)fJmzv7I=UQU99}<%Xk0?#!B-9*_HT^gOzZcA$VCi=IYF zs2Js-N6{+ukjPe5UUx|@yFPSplez}_VQwVFNlH3uK#8ai#iF=Li-hB0;Uv)*REI_& z6WzQ)Vw~tQ%0peK2AxN3=ra_kZu*6WBuyUZ!#SxeYjR27GVCMWi&fIdKu4ZL%~Gw+AyJRuwQkd=%k@@79Xf}#V5=}>iC?3_JXw-&+P;jznl*r-E zgT7Q&qN~?LE$9-mP8D51Y3Lj(L9M6(oj@jPLUAdgdQ^xGqB^u6wV^#Ic$%on0rOxf zszjSn3tES)(?zRM8d{D@&?1p{R(zNhtCa2rBGbt+Q9O#fOB9U?Q4p#_qpq?3ZP1s> z;8fAotD-z~300yCs0E!v)-+KoN<$}532H(Os2-WrBxkWJBRP4~^A%4(O*7XNf$0B%)sA zL>Eyr>OhuzL}yS2I)#eSapXdcs1F@RakE7SP$Al<^H6o4$03QZLMLX3w(3N*Q757z z)Q<8|RHi5w6`%#ki89e?l!_Mf9!WrBej$dV(9LB%KpwIhF&y;w9HHKXhQ6zPTOL3&}nLV97oKzd<5 zMS5XQBE2wf)aPJj-hp~$4xywaQuitD7-xdi6t)UVVS0SARIttAG8nC@EK-(t~QzS18~? z(HCet`V@7elc->s$SrcXPs4Yp%*YcRLN4?w(r<;mNN=azNN=Yyq_@)+q_@+0q<7O= zq<7N_6uexXmxC(NJk*C~Ibh*Wg(;{FO-8mAqDa($#-X@}M7N+CWFWmguY4=g+w&Ww zx968gAM>+FZ_hs=y*)obvOOIZ^IfR-=Mkj$=bMQAY5p4N?WvI7p1Y9Vo(`n9ryc3- z`8d+sa}~0zl&361#pr(2j^-do_QS$-*o+cUTD~Y2xzKnNS0EaLYS9Q3yh?PlN9078 zk@XQ#7ut@_qdxQ*Dqb!62$|?u59ePWpx;xe571jkAE4KeK0q%ceSls-`T&)qKF-fG zNS~h#NS~j_kUl>vkv>05kUl^2b)K9MhdEm(a#*J8L=>+RQ8X%8BML&bXcTHkz9?#~ z=xR54=n|?!7f?4khteJuwW96l1ZtTJn_$3WqI#5v4x(DLADL(mN-7jpp%PSzQdCah zWTR0%6FAXmQngYZQy)lqQvF@ZR^=Zw(KxH7N!g*6OLOX zJrXv@*s0zKOE#WUZDHZJJTH0XCtZ@_d@($5TrIapxIK;DL;)&3JS;f-X9EvBB$ZX= zE%F&jKEBnc{P4h(w!z?5S_D5XZRemol#XgpB5FgiDk(h32v*JEfkg#BA9!?_#0MW; zJ6JuOX6ky48LD9Rc0vI+1+7G`*iMqa?XO{uPlIqp6a^Z&zPO z+-el4f`~w)Ms1FWNUIx6SjjVV-(!&OdkE5f_y6zbn(9N*DN&Y()_PNA34 zadZSVqLb(_>Ocq3HM9=}JSnP138>=2Fk!Y@5FPI*mx}(4@(YQVW!*5UvTn@C>U{EJ z_bcSyMXOqLCu%|y&?yv*&ZE)j5*j9Qo;;pw+jYTh-6$28J0(;p>i;{plX;rJUphU$ z9`|U~7rodBQ41!-8spW53He5nYMqcJ?~0(9h~;xP$=5KuPMGJv^mxjf{mVOLPs@~_ zwv{yp+o~+@E%3(OI&KfE%I&POw@XHM<4SL6r2N6Ix8%$WZMQ}}9~0`Zds9AwdwEfoT-)vhu1n_c`fmQN&lXO;U@QCDYCCq**YxkGcf`(Iv>>5Sni}JMXDpPf zRermxJ)Ro5w!i4{5c^ztJk4_TJ>>DU%Qf;XkB6^rmdG_qu1=SH2PRj`5jEO=hf%E3 z?TJRVDzZIoKZjWjSISUgw+xzRcqvTygFi!%nbUi$1_dt2D8?a zW6@c!%Qar&Q+A X\"",k); for (i = 0; i < 32; i++) - printf("%2.2X",init[k][i]); + printf("%2.2X", init[k][i]); printf("\""); if (k != 63) @@ -706,6 +706,9 @@ int main(int argc, char* argv[]){ else if(strcmp(argv[3],"kernel_slave.txt") == 0){ vhd_ram_parametrized(code, size, i, "slave"); } + else{ + vhd_ram_parametrized(code, size, i, "simple"); + } } else if(strcmp(argv[2],"-h") == 0){ if (strcmp(argv[3],"kernel_master.txt") == 0){ diff --git a/build_env/makes/make_app b/build_env/makes/make_app index 50a9e4d..7df5f2e 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -3,7 +3,7 @@ NC =\033[0m # No Color INCLUDE = ../../software/include -CFLAGS = -O2 -Wall -fms-extensions -mips1 -c -s -std=c99 -G 0 +CFLAGS = -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 GCC_MIPS = mips-elf-gcc $(CFLAGS) AS_MIPS = mips-elf-as LD_MIPS = mips-elf-ld @@ -11,7 +11,7 @@ DUMP_MIPS = mips-elf-objdump COPY_MIPS = mips-elf-objcopy -I elf32-bigmips -O binary BOOT_TASK = boot_task -BOOT_TASK_SRC = ../../software/boot_task/boot_task.s +BOOT_TASK_SRC = ../../software/boot_task/boot_task.asm TASK_SRC = $(wildcard *.c) TASK_OBJ = $(TASK_SRC:.c=.o) diff --git a/build_env/makes/make_vhdl b/build_env/makes/make_vhdl index d14a6e4..ce4f7c3 100644 --- a/build_env/makes/make_vhdl +++ b/build_env/makes/make_vhdl @@ -8,10 +8,10 @@ COMP =vcom -work $(LIB) #VHDL files HEMPS_PKG =hemps_pkg STAND =standards -TOP =receive_data inject_data hemps test_bench +TOP =hemps receive_data inject_data test_bench PE =pe DMNI =dmni -MEMORY =ram_master ram_slave +MEMORY =ram_master ram_slave ram_simple PROCESSOR =mlite_pack UartFile alu bus_mux control mem_ctrl mult pc_next pipeline reg_bank shifter mlite_cpu ROUTER =Hermes_buffer Hermes_crossbar Hermes_switchcontrol RouterCC diff --git a/build_env/makes/sim.do b/build_env/makes/sim.do index ce51019..1764d56 100644 --- a/build_env/makes/sim.do +++ b/build_env/makes/sim.do @@ -1,4 +1,4 @@ -vsim -voptargs=+acc=lprn -t ps +notimingchecks hardware/work.test_bench +vsim -novopt -t ps +notimingchecks hardware/work.test_bench do wave.do onerror {resume} diff --git a/build_env/scripts/app_builder.py b/build_env/scripts/app_builder.py index d8ab419..7f80c9d 100644 --- a/build_env/scripts/app_builder.py +++ b/build_env/scripts/app_builder.py @@ -32,6 +32,8 @@ def main(): #Generates the appstart.txt and appstart_debug.txt files generate_appstart(apps_repo_addr_list, yaml_r) + + generate_cfg_file(yaml_r) def generate_apps_id(apps_name_list): @@ -77,9 +79,32 @@ def generate_appstart(apps_repo_addr_list, yaml_r): app_start_obj.repo_address = app_address - + generate_appstart_file(apps_start_obj_list) +def generate_cfg_file(yaml_r): + + cfg_file_path = "apps.cfg" + + cfg_lines = [] + + app_list = get_apps_name_list(yaml_r) + location = get_apps_location_list(yaml_r) + + num_apps = len(app_list) + + for i in range(0,num_apps): + app = app_list[i] + x_address = location[i][0] + y_address = location[i][1] + pos = x_address << 8 | y_address + size = get_task_txt_size(app, app) + cfg_lines.append("applications/" + app + "/" + app + ".txt\n") + cfg_lines.append(toX(pos)+"\n") + cfg_lines.append(toX(size)+"\n") + + writes_file_into_testcase(cfg_file_path, cfg_lines) + #Function that generates a new repository from the dir: /applications #Please, behold this following peace of art: def generate_repository(yaml_r, apps_name_list): diff --git a/build_env/scripts/hw_builder.py b/build_env/scripts/hw_builder.py index bcd28b9..aef014b 100644 --- a/build_env/scripts/hw_builder.py +++ b/build_env/scripts/hw_builder.py @@ -125,6 +125,9 @@ def generate_to_vhdl(is_master_list, yaml_r): x_mpsoc_dim = get_mpsoc_x_dim(yaml_r) y_mpsoc_dim = get_mpsoc_y_dim(yaml_r) app_number = get_apps_number(yaml_r) + simple_soc = get_simple_soc(yaml_r) + open_ports = get_open_ports(yaml_r) + io_number = get_io_number(yaml_r) #These lines compute the logical memory addresses used by the mlite to index the pages at the local memory @@ -144,6 +147,26 @@ def generate_to_vhdl(is_master_list, yaml_r): #Remove the lost ',' in the string_pe_type_vhdl string_pe_type_vhdl = string_pe_type_vhdl[0:len(string_pe_type_vhdl)-1] + + open_ports_vector = [] + for i in range(0,x_mpsoc_dim*y_mpsoc_dim): + open_ports_vector.append("gnd"); + + for port in open_ports: + index = port[1]*x_mpsoc_dim + port[0] + if port[2] == "N": + open_ports_vector[index] = "nor" + if port[2] == "S": + open_ports_vector[index] = "sou" + if port[2] == "E": + open_ports_vector[index] = "eas" + if port[2] == "W": + open_ports_vector[index] = "wes" + + open_ports_string = "" + for i in range(0,x_mpsoc_dim*y_mpsoc_dim): + open_ports_string = open_ports_string + "\"" + open_ports_vector[i] + "\"," + open_ports_string = open_ports_string[0:len(open_ports_string)-1] file_lines = [] @@ -164,13 +187,18 @@ def generate_to_vhdl(is_master_list, yaml_r): file_lines.append(" constant NUMBER_PROCESSORS_X : integer := "+str(x_mpsoc_dim)+";\n") file_lines.append(" constant NUMBER_PROCESSORS_Y : integer := "+str(y_mpsoc_dim)+";\n") file_lines.append(" constant TAM_BUFFER : integer := "+str(noc_buffer_size)+";\n") - file_lines.append(" constant NUMBER_PROCESSORS : integer := "+str(x_mpsoc_dim*y_mpsoc_dim)+";\n\n") + file_lines.append(" constant NUMBER_PROCESSORS : integer := "+str(x_mpsoc_dim*y_mpsoc_dim)+";\n") + file_lines.append(" constant SIMPLE_SOC : boolean := "+str(simple_soc)+";\n") + file_lines.append(" constant IO_NUMBER : integer := "+str(io_number)+";\n\n") file_lines.append(" subtype kernel_str is string(1 to 3);\n") file_lines.append(" type pe_type_t is array(0 to NUMBER_PROCESSORS-1) of kernel_str;\n") file_lines.append(" constant pe_type : pe_type_t := ("+string_pe_type_vhdl+");\n\n") + file_lines.append(" subtype manual_io_option is string(1 to 3);\n") + file_lines.append(" type manual_io_type is array(0 to NUMBER_PROCESSORS-1) of manual_io_option;\n") + file_lines.append(" constant OPEN_IO : manual_io_type := ("+open_ports_string+");\n\n") file_lines.append("end hemps_pkg;\n") #Use this function to create any file into testcase, it automatically only updates the old file if necessary writes_file_into_testcase("include/hemps_pkg.vhd", file_lines) -main() \ No newline at end of file +main() diff --git a/build_env/scripts/kernel_builder.py b/build_env/scripts/kernel_builder.py index d340cbe..f0a1499 100644 --- a/build_env/scripts/kernel_builder.py +++ b/build_env/scripts/kernel_builder.py @@ -190,6 +190,9 @@ def generate_memory( yaml_r ): ext_slave = os.system("cd software; ram_generator " + str(gen_compatible_mem_size) + " -rtl kernel_slave.txt > ../ram_pe/ram_slave.vhd") ext_master = os.system("cd software; ram_generator " + str(gen_compatible_mem_size) + " -rtl kernel_master.txt > ../ram_pe/ram_master.vhd") + + os.system("cd software; echo 00000000 > ram_simple.txt"); + os.system("cd software; ram_generator " + str(gen_compatible_mem_size) + " -rtl ram_simple.txt > ../ram_pe/ram_simple.vhd") if ext_master != 0 or ext_slave != 0 or gen_compatible_mem_size == 0: sys.exit("ERROR: Error in the ram_generation process") diff --git a/build_env/scripts/yaml_intf.py b/build_env/scripts/yaml_intf.py index 4c64c52..63709b4 100644 --- a/build_env/scripts/yaml_intf.py +++ b/build_env/scripts/yaml_intf.py @@ -78,6 +78,17 @@ def get_apps_name_list(yaml_reader): return apps_name_list +def get_apps_location_list(yaml_reader): + + apps_list = yaml_reader["apps"] + + apps_location_list = [] + + for app in apps_list: + apps_location_list.append(app["location"]) + + return apps_location_list + def get_apps_number(yaml_reader): number = len(get_apps_name_list(yaml_reader)) return number @@ -88,6 +99,30 @@ def get_task_scheduler(yaml_reader): def get_app_repo_size(yaml_reader): return 1000 +def get_simple_soc(yaml_reader): + if 'simple_soc' in yaml_reader["hw"]: + return yaml_reader["hw"]["simple_soc"] + else: + return False + +def get_open_ports(yaml_reader): + io_list = yaml_reader["hw"]["open_port"] + + open_port_list = [] + + for port in io_list: + open_port_list.append(port["port"]) + + return open_port_list + +def get_io_number(yaml_reader): + number = len(get_open_ports(yaml_reader)) + return number + + +#def get_cfg_params(yaml_reader): +# app_names = [] +# for app_n in yaml_reader["apps"]: #------- Repository Generation Scope ------------------- #ATTENTION: STATIC MAPPING ONLY WORKS IF THE APPS START TIME ARE ORDERED diff --git a/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd index ba6ea65..e52424c 100644 --- a/hardware/vhdl/hemps.vhd +++ b/hardware/vhdl/hemps.vhd @@ -28,7 +28,17 @@ entity HeMPS is -- Interface com o ambiente exterior repo_address : out std_logic_vector(29 downto 0); repo_data : in std_logic_vector(31 downto 0); ack_app : out std_logic; - req_app : in std_logic_vector(31 downto 0) + req_app : in std_logic_vector(31 downto 0); + + --NoC Interface (IO) + tx_io : out std_logic_vector((IO_NUMBER-1) downto 0); + data_out_io : out arrayNio_regflit; + credit_i_io : in std_logic_vector((IO_NUMBER-1) downto 0); + clock_tx_io : out std_logic_vector((IO_NUMBER-1) downto 0); + rx_io : in std_logic_vector((IO_NUMBER-1) downto 0); + data_in_io : in arrayNio_regflit; + credit_o_io : out std_logic_vector((IO_NUMBER-1) downto 0); + clock_rx_io : in std_logic_vector((IO_NUMBER-1) downto 0) -- External Debug interface -- write_enable_debug : out std_logic; @@ -81,10 +91,11 @@ begin router_address => RouterAddress(i), kernel_type => pe_type(i), log_file => log_filename(i), - manual_EAST => ManualEASTByPos(i), - manual_WEST => ManualWESTByPos(i), - manual_NORTH => ManualNORTHByPos(i), - manual_SOUTH => ManualSOUTHByPos(i)) + simple_soc => SIMPLE_SOC, + manual_NORTH => ManualNORTHbyPos(i), + manual_SOUTH => ManualSOUTHbyPos(i), + manual_EAST => ManualEASTbyPos(i), + manual_WEST => ManualWESTbyPos(i)) port map( clock => clock, reset => reset, @@ -112,14 +123,14 @@ begin ------------------------------------------------------------------------------ --- REPOSITORY CONNECTIONS ---------------------------------------------------- ------------------------------------------------------------------------------ - repo_mas : if pe_type(i) = "mas" generate -- Caso o PE for mestre + repo_mas : if RouterPosition(i) = BL generate repo_address <= repo_address_sig(i); repo_data_sig(i) <= repo_data; ack_app <= ack_app_sig(i); req_app_sig(i) <= req_app; end generate; - ground_repo : if pe_type(i) /= "mas" generate --Caso o PE nao for mestre + ground_repo : if RouterPosition(i) /= BL generate repo_address_sig(i) <= (others => '0'); repo_data_sig(i) <= (others => '0'); ack_app_sig(i) <= '0'; @@ -149,26 +160,21 @@ begin ------------------------------------------------------------------------------ --- EAST PORT CONNECTIONS ---------------------------------------------------- ------------------------------------------------------------------------------ - east_border : if RouterPosition(i) = BR or RouterPosition(i) = CRX or RouterPosition(i) = TR generate - data_injector : entity work.inject_data - generic map(router_nb => i, - port_name => "EAST") - port map (clock => clock, - reset => reset, - clock_rx => clock_rx(i)(EAST), - rx => rx(i)(EAST), - data_in => data_in(i)(EAST), - credit_o => credit_o(i)(EAST)); - - data_consumer : entity work.receive_data - generic map(router_nb => i, - port_name => "EAST") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(EAST), - tx => tx(i)(EAST), - data_out => data_out(i)(EAST), - credit_i => credit_i(i)(EAST)); + east_io : if OPEN_IO(i) = "eas" generate + rx(i)(EAST) <= rx_io(io_index(i)); + clock_rx(i)(EAST) <= clock_rx_io(io_index(i)); + credit_i(i)(EAST) <= credit_i_io(io_index(i)); + data_in(i)(EAST) <= data_in_io(io_index(i)); + tx_io(io_index(i)) <= tx(i)(EAST); + clock_tx_io(io_index(i)) <= clock_tx(i)(EAST); + credit_o_io(io_index(i)) <= credit_o(i)(EAST); + data_out_io(io_index(i)) <= data_out(i)(EAST); + end generate; + east_grounding : if OPEN_IO(i) = "gnd" and (RouterPosition(i) = BR or RouterPosition(i) = CRX or RouterPosition(i) = TR) generate + rx(i)(EAST) <= '0'; + clock_rx(i)(EAST) <= '0'; + credit_i(i)(EAST) <= '0'; + data_in(i)(EAST) <= (others => '0'); end generate; east_connection : if RouterPosition(i) = BL or RouterPosition(i) = CL or RouterPosition(i) = TL or RouterPosition(i) = BC or RouterPosition(i) = TC or RouterPosition(i) = CC generate @@ -181,26 +187,21 @@ begin ------------------------------------------------------------------------------ --- WEST PORT CONNECTIONS ---------------------------------------------------- ------------------------------------------------------------------------------ - west_border : if RouterPosition(i) = BL or RouterPosition(i) = CL or RouterPosition(i) = TL generate - data_injector : entity work.inject_data - generic map(router_nb => i, - port_name => "WEST") - port map (clock => clock, - reset => reset, - clock_rx => clock_rx(i)(WEST), - rx => rx(i)(WEST), - data_in => data_in(i)(WEST), - credit_o => credit_o(i)(WEST)); - - data_consumer : entity work.receive_data - generic map(router_nb => i, - port_name => "WEST") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(WEST), - tx => tx(i)(WEST), - data_out => data_out(i)(WEST), - credit_i => credit_i(i)(WEST)); + west_io : if OPEN_IO(i) = "wes" generate + rx(i)(WEST) <= rx_io(io_index(i)); + clock_rx(i)(WEST) <= clock_rx_io(io_index(i)); + credit_i(i)(WEST) <= credit_i_io(io_index(i)); + data_in(i)(WEST) <= data_in_io(io_index(i)); + tx_io(io_index(i)) <= tx(i)(WEST); + clock_tx_io(io_index(i)) <= clock_tx(i)(WEST); + credit_o_io(io_index(i)) <= credit_o(i)(WEST); + data_out_io(io_index(i)) <= data_out(i)(WEST); + end generate; + west_grounding : if OPEN_IO(i) = "gnd" and (RouterPosition(i) = BL or RouterPosition(i) = CL or RouterPosition(i) = TL) generate + rx(i)(WEST) <= '0'; + clock_rx(i)(WEST) <= '0'; + credit_i(i)(WEST) <= '0'; + data_in(i)(WEST) <= (others => '0'); end generate; west_connection : if (RouterPosition(i) = BR or RouterPosition(i) = CRX or RouterPosition(i) = TR or RouterPosition(i) = BC or RouterPosition(i) = TC or RouterPosition(i) = CC) generate @@ -213,26 +214,21 @@ begin ------------------------------------------------------------------------------- --- NORTH PORT CONNECTIONS ---------------------------------------------------- ------------------------------------------------------------------------------- - north_border : if RouterPosition(i) = TL or RouterPosition(i) = TC or RouterPosition(i) = TR generate - data_injector : entity work.inject_data - generic map(router_nb => i, - port_name => "NORTH") - port map (clock => clock, - reset => reset, - clock_rx => clock_rx(i)(NORTH), - rx => rx(i)(NORTH), - data_in => data_in(i)(NORTH), - credit_o => credit_o(i)(NORTH)); - - data_consumer : entity work.receive_data - generic map(router_nb => i, - port_name => "NORTH") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(NORTH), - tx => tx(i)(NORTH), - data_out => data_out(i)(NORTH), - credit_i => credit_i(i)(NORTH)); + north_io : if OPEN_IO(i) = "nor" generate + rx(i)(NORTH) <= rx_io(io_index(i)); + clock_rx(i)(NORTH) <= clock_rx_io(io_index(i)); + credit_i(i)(NORTH) <= credit_i_io(io_index(i)); + data_in(i)(NORTH) <= data_in_io(io_index(i)); + tx_io(io_index(i)) <= tx(i)(NORTH); + clock_tx_io(io_index(i)) <= clock_tx(i)(NORTH); + credit_o_io(io_index(i)) <= credit_o(i)(NORTH); + data_out_io(io_index(i)) <= data_out(i)(NORTH); + end generate; + north_grounding : if OPEN_IO(i) = "gnd" and (RouterPosition(i) = TL or RouterPosition(i) = TC or RouterPosition(i) = TR) generate + rx(i)(NORTH) <= '0'; + clock_rx(i)(NORTH) <= '0'; + credit_i(i)(NORTH) <= '0'; + data_in(i)(NORTH) <= (others => '0'); end generate; north_connection : if RouterPosition(i) = BL or RouterPosition(i) = BC or RouterPosition(i) = BR or RouterPosition(i) = CL or RouterPosition(i) = CRX or RouterPosition(i) = CC generate @@ -245,26 +241,21 @@ begin -------------------------------------------------------------------------------- --- SOUTH PORT CONNECTIONS ----------------------------------------------------- --------------------------------------------------------------------------- - south_border : if RouterPosition(i) = BL or RouterPosition(i) = BC or RouterPosition(i) = BR generate - data_injector : entity work.inject_data - generic map(router_nb => i, - port_name => "SOUTH") - port map (clock => clock, - reset => reset, - clock_rx => clock_rx(i)(SOUTH), - rx => rx(i)(SOUTH), - data_in => data_in(i)(SOUTH), - credit_o => credit_o(i)(SOUTH)); - - data_consumer : entity work.receive_data - generic map(router_nb => i, - port_name => "SOUTH") - port map(clock => clock, - reset => reset, - clock_tx => clock_tx(i)(SOUTH), - tx => tx(i)(SOUTH), - data_out => data_out(i)(SOUTH), - credit_i => credit_i(i)(SOUTH)); + south_io : if OPEN_IO(i) = "sou" generate + rx(i)(SOUTH) <= rx_io(io_index(i)); + clock_rx(i)(SOUTH) <= clock_rx_io(io_index(i)); + credit_i(i)(SOUTH) <= credit_i_io(io_index(i)); + data_in(i)(SOUTH) <= data_in_io(io_index(i)); + tx_io(io_index(i)) <= tx(i)(SOUTH); + clock_tx_io(io_index(i)) <= clock_tx(i)(SOUTH); + credit_o_io(io_index(i)) <= credit_o(i)(SOUTH); + data_out_io(io_index(i)) <= data_out(i)(SOUTH); + end generate; + south_grounding : if OPEN_IO(i) = "gnd" and (RouterPosition(i) = BL or RouterPosition(i) = BC or RouterPosition(i) = BR) generate + rx(i)(SOUTH) <= '0'; + clock_rx(i)(SOUTH) <= '0'; + credit_i(i)(SOUTH) <= '0'; + data_in(i)(SOUTH) <= (others => '0'); end generate; south_connection : if RouterPosition(i) = TL or RouterPosition(i) = TC or RouterPosition(i) = TR or RouterPosition(i) = CL or RouterPosition(i) = CRX or RouterPosition(i) = CC generate diff --git a/hardware/vhdl/inject_data.vhd b/hardware/vhdl/inject_data.vhd index ef920ed..1d94ed8 100644 --- a/hardware/vhdl/inject_data.vhd +++ b/hardware/vhdl/inject_data.vhd @@ -114,6 +114,10 @@ begin file_open(fstatus, file_in, "in" & integer'image(router_nb) & port_name & ".txt", read_mode); if fstatus = open_ok then + + assert false report "Reading file in"& integer'image(router_nb) & port_name & ".txt" + severity note; + while not (endfile(file_in)) loop -- one packet per line ----- readline(file_in, ARQ_LINE); @@ -142,6 +146,9 @@ begin wait for 2 ps; --required, to wait the next line :-) end loop; -- end loop da linha + else + assert false report "Could not open in"& integer'image(router_nb) & port_name & ".txt" + severity note; end if; end process; diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index c6466d6..8faa20d 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -22,6 +22,7 @@ entity pe is log_file : string := "output.txt"; router_address : regmetadeflit := (others => '0'); kernel_type : kernel_str; + simple_soc : boolean; manual_NORTH : boolean := false; manual_SOUTH : boolean := false; manual_EAST : boolean := false; @@ -127,40 +128,39 @@ begin ----------------------------------------------------------------------------------- -- PE COMPONENTS INSTANTIATION ----------------------------------------------------------------------------------- - mastercpu : if kernel_type = "mas" generate --Distincao da CPU para Mestre - cpu : entity work.mlite_cpu - port map( - clk => clock_hold_s, - reset_in => reset, - intr_in => irq, - mem_address => cpu_mem_address, - mem_data_w => cpu_mem_data_write, - mem_data_r => cpu_mem_data_read, - mem_byte_we => cpu_mem_write_byte_enable, - mem_pause => cpu_mem_pause, - current_page => current_page - ); - end generate; + cpu : entity work.mlite_cpu + port map( + clk => clock_hold_s, + reset_in => reset_dmni, + intr_in => irq, + mem_address => cpu_mem_address, + mem_data_w => cpu_mem_data_write, + mem_data_r => cpu_mem_data_read, + mem_byte_we => cpu_mem_write_byte_enable, + mem_pause => cpu_mem_pause, + current_page => current_page + ); - slavecpu : if kernel_type = "sla" generate --Distincao da CPU para Escravo - cpu : entity work.mlite_cpu + master : if kernel_type = "mas" and simple_soc = false generate + mem : entity work.ram_master port map( - clk => clock_hold_s, - reset_in => reset_dmni, - intr_in => irq, - mem_address => cpu_mem_address, - mem_data_w => cpu_mem_data_write, - mem_data_r => cpu_mem_data_read, - mem_byte_we => cpu_mem_write_byte_enable, - mem_pause => cpu_mem_pause, - current_page => current_page + clk => clock, + enable_a => cpu_enable_ram, + wbe_a => cpu_mem_write_byte_enable, + address_a => addr_a, + data_write_a => cpu_mem_data_write, + data_read_a => data_read_ram, + enable_b => dmni_enable_internal_ram, + wbe_b => dmni_mem_write_byte_enable, + address_b => addr_b, + data_write_b => dmni_mem_data_write, + data_read_b => mem_data_read ); end generate; - - master : if kernel_type = "mas" generate - mem : entity work.ram_master + slave : if kernel_type = "sla" and simple_soc = false generate + mem : entity work.ram_slave port map( clk => clock, enable_a => cpu_enable_ram, @@ -176,8 +176,8 @@ begin ); end generate; - slave : if kernel_type = "sla" generate - mem : entity work.ram_slave + simple_soc_ram : if simple_soc = true generate + mem : entity work.ram_simple port map( clk => clock, enable_a => cpu_enable_ram, diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index e1cf23b..001f754 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -153,6 +153,7 @@ package standards is type arrayNrot_regmetadeflit is array((NROT-1) downto 0) of regmetadeflit; type arrayNPe_reg32 is array((NUMBER_PROCESSORS -1) downto 0) of reg32; type arrayNPe_reg30 is array((NUMBER_PROCESSORS -1) downto 0) of reg30; + type arrayNio_regflit is array((IO_NUMBER-1) downto 0) of regflit; -- number of ports of the processing_element - 4 - north/south/west/east type arrayNPORT_1_regflit is array(3 downto 0) of regflit; @@ -173,13 +174,14 @@ package standards is --------------------------------------------------------- function RouterPosition(router : integer) return integer; function RouterAddress(router : integer) return std_logic_vector; + function log_filename(i : integer) return string; - function ManualEASTByPos(router : integer) return boolean; - function ManualWESTByPos(router : integer) return boolean; - function ManualNORTHByPos(router : integer) return boolean; - function ManualSOUTHByPos(router : integer) return boolean; + function ManualNORTHbyPos(router : integer) return boolean; + function ManualSOUTHbyPos(router : integer) return boolean; + function ManualEASTbyPos(router : integer) return boolean; + function ManualWESTbyPos(router : integer) return boolean; - function log_filename(i : integer) return string; + function io_index(router : integer) return integer; end standards; @@ -348,73 +350,77 @@ begin end RouterPosition; -function ManualWESTbyPos(router : integer) return boolean is - variable pos : integer; +function RouterAddress(router : integer) return std_logic_vector is + variable pos_x, pos_y : regquartoflit; + variable addr : regmetadeflit; + variable aux : integer; +begin + aux := (router/NUMBER_PROCESSORS_X); + pos_x := conv_std_logic_vector((router mod NUMBER_PROCESSORS_X), QUARTOFLIT); + pos_y := conv_std_logic_vector(aux, QUARTOFLIT); + + addr := pos_x & pos_y; + return addr; +end RouterAddress; + +function log_filename(i : integer) return string is + variable filename : string(1 to 14); + variable aux_x : integer; + variable aux_y : integer; +begin + aux_x := (i mod NUMBER_PROCESSORS_X); + aux_y := (i/NUMBER_PROCESSORS_X); + filename := "log/log" & CONV_HEX(aux_x) & "x" & CONV_HEX(aux_y) & ".txt"; + return filename; +end log_filename; + +function ManualNORTHbyPos(router : integer) return boolean is begin - pos := RouterPosition(router); - if (pos = TL) or (pos = CL) or (pos = BL) then + if (OPEN_IO(router) = "nor") then return true; else return false; end if; -end ManualWESTbyPos; +end ManualNORTHbyPos; -function ManualEASTbyPos(router : integer) return boolean is - variable pos : integer; +function ManualSOUTHbyPos(router : integer) return boolean is begin - pos := RouterPosition(router); - if (pos = TR) or (pos = CRX) or (pos = BR) then + if (OPEN_IO(router) = "sou") then return true; else return false; end if; -end ManualEASTbyPos; +end ManualSOUTHbyPos; -function ManualNORTHbyPos(router : integer) return boolean is - variable pos : integer; +function ManualEASTbyPos(router : integer) return boolean is begin - pos := RouterPosition(router); - if (pos = TL) or (pos = TC) or (pos = TR) then + if (OPEN_IO(router) = "eas") then return true; else return false; end if; -end ManualNORTHbyPos; +end ManualEASTbyPos; -function ManualSOUTHbyPos(router : integer) return boolean is - variable pos : integer; +function ManualWESTbyPos(router : integer) return boolean is begin - pos := RouterPosition(router); - if (pos = BL) or (pos = BC) or (pos = BR) then + if (OPEN_IO(router) = "wes") then return true; else return false; end if; -end ManualSOUTHbyPos; - - -function RouterAddress(router : integer) return std_logic_vector is - variable pos_x, pos_y : regquartoflit; - variable addr : regmetadeflit; - variable aux : integer; -begin - aux := (router/NUMBER_PROCESSORS_X); - pos_x := conv_std_logic_vector((router mod NUMBER_PROCESSORS_X), QUARTOFLIT); - pos_y := conv_std_logic_vector(aux, QUARTOFLIT); - - addr := pos_x & pos_y; - return addr; -end RouterAddress; +end ManualWESTbyPos; -function log_filename(i : integer) return string is - variable filename : string(1 to 14); - variable aux_x : integer; - variable aux_y : integer; +function io_index(router : integer) return integer is + variable i : integer; + variable index : integer; begin - aux_x := (i mod NUMBER_PROCESSORS_X); - aux_y := (i/NUMBER_PROCESSORS_X); - filename := "log/log" & CONV_HEX(aux_x) & "x" & CONV_HEX(aux_y) & ".txt"; - return filename; -end log_filename; + index := 0; + for i in 0 to router loop + if (OPEN_IO(i) = "eas" or OPEN_IO(i) = "wes" or OPEN_IO(i) = "nor" or OPEN_IO(i) = "sou") then + index := index + 1; + end if; + end loop; + return index-1; +end io_index; end standards; diff --git a/hardware/vhdl/test_bench.vhd b/hardware/vhdl/test_bench.vhd index bc4dfae..c1ac90a 100644 --- a/hardware/vhdl/test_bench.vhd +++ b/hardware/vhdl/test_bench.vhd @@ -1,284 +1,249 @@ ------------------------------------------------------------------------------------------------- --- --- DISTRIBUTED HEMPS - version 5.0 --- --- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br --- --- Distribution: September 2013 --- --- Source name: test_bench.vhd --- --- Brief description: Test bench. --- ------------------------------------------------------------------------------------------------- - -library IEEE; -use ieee.std_logic_1164.all; -use ieee.std_logic_arith.all; -use ieee.std_logic_unsigned.all; -use ieee.std_logic_textio.all; -use std.textio.all; -use work.hemps_pkg.all; -use work.standards.all; - ---! @file ---! @ingroup vhdl_group ---! @{ ---! @} - ---! @brief entity brief description - ---! @detailed detailed description -entity test_bench is - - --constant log_file : string := "output_master.txt"; --! port description - constant mlite_description : string := "RTL"; - constant ram_description : string := "RTL"; - constant router_description : string := "RTL"; - - constant REPO_SIZE: integer := (TOTAL_REPO_SIZE_BYTES/4); --This math is because each repoline is 32 bits word - constant APPSTART_SIZE: integer := (APP_NUMBER*2)+1; --THis math is because the appstart file have two values per app plus one end of file mark - type repo_type is array(REPO_SIZE-1 downto 0) of std_logic_vector(31 downto 0); - type appstart_type is array(APPSTART_SIZE-1 downto 0) of std_logic_vector(31 downto 0); - - - impure function load_repo (repo_file : in string) return repo_type is - - file file_ptr : text open read_mode is repo_file; - variable inline : line; - variable i : integer := 0; - - variable mem : repo_type := (others => (others => '0')); - - begin - - while not endfile(file_ptr) loop - - if (i = REPO_SIZE) then - assert false report "ERROR: reposiotory access overflow - i= " & integer'image(i) - severity error; - end if; - - readline(file_ptr, inline); - hread(inline, mem(i)); - i := i + 1; - - end loop; - - file_close(file_ptr); - - return mem; - - end load_repo; - - - impure function load_appstart (appstart_file : in string) return appstart_type is - - file file_ptr2 : text open read_mode is appstart_file; - variable inline : line; - variable i : integer := 0; - - variable mem : appstart_type := (others => (others => '0')); - - begin - - while not endfile(file_ptr2) loop - - if (i = REPO_SIZE) then - assert false report "ERROR: appstart access overflow - i= " & integer'image(i) - severity error; - end if; - - readline(file_ptr2, inline); - hread(inline, mem(i)); - i := i + 1; - - end loop; - - file_close(file_ptr2); - - return mem; - - end load_appstart; - - -end; - -architecture test_bench of test_bench is - - - signal clock : std_logic := '0'; - signal clock_200 : std_logic := '1'; - signal reset : std_logic; --- signal control_write_enable_debug : std_logic; --- signal control_data_out_debug : std_logic_vector(31 downto 0); --- signal control_busy_debug : std_logic; - signal control_hemps_addr : std_logic_vector(29 downto 0); - signal control_hemps_data : std_logic_vector(31 downto 0); - - type state is (LER, WAIT_DDR, WR_HEMPS, START); - signal EA : state; - type state2 is (S0, S1); - - signal CS : state2; - signal counter : integer := 0; - signal ack_app : std_logic; - signal req_app : std_logic_vector(31 downto 0); - - constant repository : repo_type := load_repo("repository.txt"); - constant appstart : appstart_type := load_appstart("appstart.txt"); - - - signal current_time : integer := 0; - signal app_i : integer := 0; - -begin - - -- - -- HeMPS instantiation - -- - HeMPS : entity work.HeMPS - generic map( - mlite_description => mlite_description, - ram_description => ram_description, - router_description => router_description - ) - port map( - clock => clock, - reset => reset, - --repository - repo_address => control_hemps_addr, - repo_data => control_hemps_data, - ack_app => ack_app, - req_app => req_app - --debug - -- write_enable_debug => control_write_enable_debug, - -- data_out_debug => control_data_out_debug, - -- busy_debug => control_busy_debug, - - ); - - - - reset <= '1', '0' after 100 ns; - -- 100 MHz - clock <= not clock after 5 ns; - -- 200 MHz - clock_200 <= not clock_200 after 1.25 ns; - - --Repository data assignment - control_hemps_data <= repository(CONV_INTEGER(control_hemps_addr(23 downto 0)) / 4); - --- App request control - - process (clock, reset) - variable app_repo_address : integer := 0; - variable app_start_time_ms : integer := 0; - begin - - if reset = '1' then - - req_app <= (others => '0'); - app_i <= 0; - current_time <= 0; - - elsif rising_edge(clock) then - - current_time <= current_time + 1; - - if req_app = x"00000000" then - - if appstart(app_i) /= x"deadc0de" then - - app_repo_address := conv_integer(appstart(app_i)); - app_start_time_ms := conv_integer(appstart(app_i+1)); - - if (app_start_time_ms * 100000) <= current_time then - - req_app <= CONV_STD_LOGIC_VECTOR(app_repo_address, 32) or x"80000000"; - - assert false report "Repository requesting app "& integer'image(app_i/2) - severity note; - - app_i <= app_i+2; - - end if; - end if; - elsif ack_app = '1' then - req_app <= (others => '0'); - end if; - - end if; - - end process; - - -- - -- creates the output file. This code was not removed because it can be useful in a protipation. In fact, all debug traces all only commented in testbench, hemps, pe - -- --- process(control_write_enable_debug,reset) --- file store_file : text open write_mode is log_file; --- variable file_line : line; --- variable line_type: character; --- variable line_length : natural := 0; --- variable str: string (1 to 4); --- variable str_end: boolean; --- begin --- if reset = '1' then --- str_end := false; --- CS <= S0; --- elsif rising_edge(control_write_enable_debug) then --- case CS is --- when S0 => --- -- Reads the incoming string --- line_type := character'val(conv_integer(control_data_out_debug(7 downto 0))); --- --- -- Verifies if the string is from Echo() --- if line_type = '$' then --- write(file_line, line_type); --- line_length := line_length + 1; --- CS <= S1; --- --- -- Writes the string to the file --- else --- str(4) := character'val(conv_integer(control_data_out_debug(7 downto 0))); --- str(3) := character'val(conv_integer(control_data_out_debug(15 downto 8))); --- str(2) := character'val(conv_integer(control_data_out_debug(23 downto 16))); --- str(1) := character'val(conv_integer(control_data_out_debug(31 downto 24))); --- --- str_end := false; --- --- for i in 1 to 4 loop --- -- Writes a string in the line --- if str(i) /= lf and str(i) /= nul and not str_end then --- write(file_line, str(i)); --- line_length := line_length + 1; --- --- -- Detects the string end --- elsif str(i) = nul then --- str_end := true; --- --- -- Line feed detected. Writes the line in the file --- elsif str(i) = lf then --- writeline(store_file, file_line); --- line_length := 0; --- end if; --- end loop; --- end if; --- --- -- Receives from plasma the source processor, source task and writes them to the file --- when S1 => --- write(file_line, ','); --- write(file_line, conv_integer(control_data_out_debug(7 downto 0))); --- line_length := line_length + 1; --- --- if line_length = 3 then --- write(file_line, ','); --- CS <= S0; --- else --- CS <= S1; --- end if; --- end case; --- end if; --- end process; - -end test_bench; \ No newline at end of file +------------------------------------------------------------------------------------------------ +-- +-- DISTRIBUTED HEMPS - version 5.0 +-- +-- Research group: GAPH-PUCRS - contact fernando.moraes@pucrs.br +-- +-- Distribution: September 2013 +-- +-- Source name: test_bench.vhd +-- +-- Brief description: Test bench. +-- +------------------------------------------------------------------------------------------------ + +library IEEE; +use ieee.std_logic_1164.all; +use ieee.std_logic_arith.all; +use ieee.std_logic_unsigned.all; +use ieee.std_logic_textio.all; +use std.textio.all; +use work.hemps_pkg.all; +use work.standards.all; + +entity test_bench is + + type config is record + code_name : string(1 to 34); + position : std_logic_vector(31 downto 0); + code_size : std_logic_vector(31 downto 0); + end record; + + type list_of_apps is array(0 to APP_NUMBER-1) of config; + + --constant log_file : string := "output_master.txt"; --! port description + constant mlite_description : string := "RTL"; + constant ram_description : string := "RTL"; + constant router_description : string := "RTL"; + + constant REPO_SIZE : integer := (TOTAL_REPO_SIZE_BYTES/4); --This math is because each repoline is 32 bits word + constant TAM_PACKSTART : integer := 13; + + type repo_type is array(REPO_SIZE-1 downto 0) of std_logic_vector(31 downto 0); + + impure function load_repo (repo_file : in string) return repo_type is + file file_ptr : text open read_mode is repo_file; + variable inline : line; + variable i : integer := 0; + + variable mem : repo_type := (others => (others => '0')); + + begin + while not endfile(file_ptr) loop + if (i = REPO_SIZE) then + assert false report "ERROR: reposiotory access overflow - i= " & integer'image(i) + severity error; + end if; + + readline(file_ptr, inline); + hread(inline, mem(i)); + i := i + 1; + end loop; + + file_close(file_ptr); + return mem; + end load_repo; + + impure function get_cfg (cfg_file : in string) return list_of_apps is + + file file_ptr : text open read_mode is cfg_file; + variable inline : line; + variable strline : string(1 to 34); + variable cfg : list_of_apps; + begin + + for i in 0 to APP_NUMBER-1 loop + readline(file_ptr, inline); + read(inline, strline(1 to inline'length)); + cfg(i).code_name := strline; + readline(file_ptr, inline); + hread(inline, cfg(i).position); + readline(file_ptr, inline); + hread(inline, cfg(i).code_size); + end loop; + file_close(file_ptr); + return cfg; + end get_cfg; + +end; + +architecture test_bench of test_bench is + + signal clock : std_logic := '0'; + signal clock_200 : std_logic := '1'; + signal reset : std_logic; + + constant app_cfg : list_of_apps := get_cfg("apps.cfg"); + + signal current_time : integer := 0; + signal app_i : integer := 0; + + --NoC Interface (IO) + signal tx_io : std_logic_vector((IO_NUMBER-1) downto 0); + signal data_out_io : arrayNio_regflit; + signal credit_i_io : std_logic_vector((IO_NUMBER-1) downto 0); + signal clock_tx_io : std_logic_vector((IO_NUMBER-1) downto 0); + signal rx_io : std_logic_vector((IO_NUMBER-1) downto 0); + signal data_in_io : arrayNio_regflit; + signal credit_o_io : std_logic_vector((IO_NUMBER-1) downto 0); + signal clock_rx_io : std_logic_vector((IO_NUMBER-1) downto 0); + + --Leitura para IO + signal rd_addr : std_logic_vector(23 downto 0); + signal flit_counter : integer; + signal file_counter : integer; + signal packstart_counter : integer; + type packstart_type is array(0 to TAM_PACKSTART-1) of regflit; + signal packstart_data : packstart_type; + signal app_code : repo_type; + +begin + + --packstart_data(12) <= x"00000101"; + packstart_data(11) <= x"0000000B"; + packstart_data(10) <= x"00000300"; + packstart_data(9) <= x"00000000"; + packstart_data(8) <= x"00000000"; + packstart_data(7) <= x"00000000"; + packstart_data(6) <= x"00000000"; + packstart_data(5) <= x"00000000"; + packstart_data(4) <= x"00000000"; + packstart_data(3) <= x"00000000"; + packstart_data(2) <= x"00000000"; + packstart_data(1) <= x"00000000"; + packstart_data(0) <= x"00000000"; + + -- + -- HeMPS instantiation + -- + HeMPS : entity work.HeMPS + generic map( + mlite_description => mlite_description, + ram_description => ram_description, + router_description => router_description + ) + port map( + clock => clock, + reset => reset, + --repository + repo_address => open, + repo_data => (others => '0'), + ack_app => open, + req_app => (others => '0'), + + --NoC Interface (IO) + tx_io => tx_io, + data_out_io => data_out_io, + credit_i_io => credit_i_io, + clock_tx_io => clock_tx_io, + rx_io => rx_io, + data_in_io => data_in_io, + credit_o_io => credit_o_io, + clock_rx_io => clock_rx_io + ); + + --data_injector : entity work.inject_data + --generic map ( + -- router_nb => 1, + -- port_name => "IO" + --) + --port map ( + -- clock => clock, + -- reset => reset, + -- clock_rx => clock_rx_io, + -- rx => rx_io, + -- data_in => data_in_io, + -- credit_o => credit_o_io + --); + + data_consumer : entity work.receive_data + generic map ( + router_nb => 1, + port_name => "IO" + ) + port map ( + clock => clock, + reset => reset, + clock_tx => clock_tx_io(0), + tx => tx_io(0), + data_out => data_out_io(0), + credit_i => credit_i_io(0) + ); + + + reset <= '1', '0' after 100 ns; + -- 100 MHz + clock <= not clock after 5 ns; + -- 200 MHz + clock_200 <= not clock_200 after 1.25 ns; + + --Conecta o testbench inicialmente no IO 0 + clock_rx_io(0) <= clock; + process (clock, reset) + begin + if reset = '1' then + rx_io(0) <= '0'; + rd_addr <= (others => '0'); + flit_counter <= 0; + packstart_counter <= 0; + file_counter <= 0; + elsif rising_edge(clock) then + if credit_o_io(0) = '1' then + if flit_counter > 0 then + rx_io(0) <= '1'; + rd_addr <= rd_addr + 1; + if rd_addr = 0 then + data_in_io(0) <= app_cfg(file_counter).position; + elsif rd_addr = 1 then + data_in_io(0) <= app_cfg(file_counter).code_size; + file_counter <= file_counter + 1; + elsif rd_addr = 2 then + data_in_io(0) <= x"00000290"; + else + data_in_io(0) <= app_code(CONV_INTEGER(rd_addr-3)); + flit_counter <= flit_counter - 1; + end if; + else + if(file_counter > 0 and packstart_counter > 0) then + rx_io(0) <= '1'; + packstart_counter <= packstart_counter - 1; + data_in_io(0) <= packstart_data(packstart_counter-1); + else + rx_io(0) <= '0'; + rd_addr <= (others => '0'); + if file_counter < APP_NUMBER then + app_code <= load_repo(app_cfg(file_counter).code_name); + flit_counter <= CONV_INTEGER(app_cfg(file_counter).code_size); + packstart_counter <= TAM_PACKSTART; + packstart_data(TAM_PACKSTART-1) <= app_cfg(file_counter).position; + end if; + end if; + end if; + end if; + end if; + end process; + +end test_bench; + + + From 69b1e231dabb75b583b95c925971617d9f409a3d Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Sat, 28 Oct 2017 18:31:22 -0200 Subject: [PATCH 27/54] Kernel Master restored --- build_env/bin/kernel_master.txt | 4104 ++++++++++++++++++++++++ build_env/bin/ram_simple | 2 + build_env/bin/ram_simple.txt | 2 + software/kernel/master/kernel_master.c | 147 +- software/kernel/master/receive.h | 271 -- software/kernel/master/transmit.h | 255 -- 6 files changed, 4140 insertions(+), 641 deletions(-) create mode 100755 build_env/bin/kernel_master.txt create mode 100755 build_env/bin/ram_simple create mode 100755 build_env/bin/ram_simple.txt delete mode 100644 software/kernel/master/receive.h delete mode 100644 software/kernel/master/transmit.h diff --git a/build_env/bin/kernel_master.txt b/build_env/bin/kernel_master.txt new file mode 100755 index 0000000..34624cf --- /dev/null +++ b/build_env/bin/kernel_master.txt @@ -0,0 +1,4104 @@ +341dffff +0c000556 +00000000 +08000003 +00000000 +3c030000 +246240a4 +ac40000c +ac6040a4 +ac400004 +03e00008 +ac400008 +27bdffe8 +3c020000 +308500ff +00043203 +afbf0010 +24433fb8 +00002021 +24070004 +8c620000 +00000000 +00c2102a +14400010 +00000000 +8c620008 +00000000 +0046102a +1440000b +00000000 +8c620004 +00000000 +00a2102a +14400006 +00000000 +8c62000c +00000000 +0045102a +10400009 +3c020000 +24840001 +1487ffea +2463001c +3c040000 +0c000615 +24843994 +0800002e +00000000 +00041940 +00042080 +00641823 +24423fb0 +00621821 +8c620000 +8c640004 +00021200 +8fbf0010 +00441025 +03e00008 +27bd0018 +27bdffe8 +3c020000 +afbf0010 +24433fb0 +00003021 +24070004 +8c620000 +00000000 +1044000c +00000000 +24c60001 +14c7fffa +2463001c +3c040000 +0c000615 +248439b4 +2406ffff +8fbf0010 +00c01021 +03e00008 +27bd0018 +8c620004 +00000000 +1445fff3 +24c60001 +0800004d +24c6ffff +27bdffd8 +afbf0020 +afb3001c +afb20018 +00a09821 +00809021 +afb10014 +0c000777 +afb00010 +00408021 +3c040000 +3c020000 +8c434038 +8c82402c +00032940 +ae020000 +00031880 +3c020000 +00a32823 +24423fb0 +24030240 +00a22821 +ae030008 +8ca30000 +8ca20004 +00031a00 +00621825 +ae030010 +8e420008 +3c040000 +248439d4 +0c000615 +ae020020 +8e04000c +0c000640 +3c110000 +0c000615 +00402021 +0c000615 +26243c14 +3c040000 +0c000615 +248439fc +8e440000 +0c000640 +00000000 +0c000615 +00402021 +0c000615 +26243c14 +8e460008 +02002021 +02602821 +0c0007b3 +00063080 +3c022000 +34430250 +8c620000 +00000000 +1440fffd +00000000 +8fbf0020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0028 +27bdffe0 +afbf0018 +afb10014 +afb00010 +0c000777 +00808821 +00408021 +8e220008 +24030040 +ae020000 +ae030008 +8e220004 +3c051000 +ae020010 +8e230000 +02002021 +ae03000c +8e260010 +00000000 +ae060028 +8e22000c +0c0007b3 +00452825 +3c040000 +0c000615 +24843a08 +8e04000c +0c000640 +00000000 +0c000615 +00402021 +3c040000 +0c000615 +24843a24 +8e040000 +0c000687 +00000000 +0c000615 +00402021 +3c040000 +8fbf0018 +8fb10014 +8fb00010 +24843c14 +08000615 +27bd0020 +27bdffe0 +afbf0018 +afb10014 +afb00010 +00a08821 +0c000777 +00808021 +3c030000 +8c64402c +24030140 +ac440000 +ac430008 +8e050000 +00402021 +ac45000c +8e030008 +00000000 +ac430020 +8e060008 +0c0007b3 +02202821 +3c022000 +34430250 +8c620000 +00000000 +1440fffd +00000000 +8fbf0018 +8fb10014 +8fb00010 +03e00008 +27bd0020 +27bdffc0 +afbe0038 +afb40028 +afb30024 +afbf003c +afb70034 +afb60030 +afb5002c +afb20020 +afb1001c +afb00018 +8c860008 +03a0f021 +00061080 +2442000e +000210c2 +000210c0 +afdd0010 +03a2e823 +00809821 +18c00030 +27b40010 +02801821 +00002821 +8c820024 +24a50001 +ac620000 +24840078 +14c5fffb +24630004 +02608821 +00009021 +3c170000 +24160250 +24150002 +0c000777 +26520001 +00408021 +8e220024 +ae160008 +ae020000 +8e660008 +02802821 +ae060020 +8e220010 +02002021 +ae02000c +8e230018 +00000000 +ae030024 +8e22001c +0c0007b3 +ae02002c +3c020000 +ae350030 +0c000615 +24443a34 +8e04000c +0c000640 +26310078 +0c000615 +00402021 +0c000615 +26e43c14 +8e630008 +00000000 +0243182a +1460ffdf +00000000 +24020001 +3c032000 +ae620004 +34630250 +8c620000 +00000000 +1440fffd +00000000 +8fdd0010 +03c0e821 +8fdf003c +8fbe0038 +8fb70034 +8fb60030 +8fb5002c +8fb40028 +8fb30024 +8fb20020 +8fb1001c +8fb00018 +03e00008 +27bd0040 +27bdffc8 +afb40020 +3c020000 +3c140000 +afbe0030 +afb7002c +afb60028 +afb50024 +afb3001c +afb20018 +afb10014 +afbf0034 +afb00010 +3c130000 +24523fb0 +00008821 +3c170000 +0280b021 +3c150000 +241e0160 +8e420000 +8e430004 +00021200 +26e43a54 +0c000615 +00438025 +0c000640 +02202021 +0c000615 +00402021 +0c000615 +26843c14 +8e62402c +00000000 +12020025 +26a43a6c +0c000615 +00000000 +0c000640 +02002021 +0c000615 +00402021 +0c000615 +26c43c14 +0c000777 +00000000 +3c040000 +8c83402c +00002821 +ac500000 +ac430014 +ac5e0008 +ac510010 +00402021 +0c0007b3 +00003021 +26310001 +24020004 +1622ffd9 +2652001c +8fbf0034 +8fbe0030 +8fb7002c +8fb60028 +8fb50024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0038 +3c020000 +0c000615 +24443a78 +0c000640 +02202021 +0c000615 +00402021 +0c000615 +26c43c14 +0c000918 +02202021 +0800017d +26310001 +27bdffc8 +afb3001c +3c130000 +afb40020 +afbf0034 +afbe0030 +afb7002c +afb60028 +afb50024 +afb20018 +afb10014 +0c000c6f +afb00010 +8e624038 +00000000 +00022940 +00022080 +3c020000 +24463fb0 +00a41823 +00661821 +8c620010 +8c740008 +00000000 +0054102a +1440003c +00c0b821 +0014aa00 +00c0f021 +8e624038 +00a42023 +00023140 +00022880 +00c51823 +00972021 +00771821 +8c91000c +8c620014 +00000000 +0051102a +14400022 +00000000 +02358021 +03c09021 +24160170 +00c51023 +00521021 +8c430000 +8c450004 +00031a00 +00651825 +26310001 +1070000b +02002021 +0c000d4d +00000000 +0c000777 +00000000 +ac500000 +ac560008 +00402021 +00002821 +0c0007b3 +00003021 +8e624038 +00000000 +00023140 +00022880 +00c51023 +00521021 +8c430014 +00000000 +0071182a +1060ffe3 +26100001 +8e624038 +26940001 +00022940 +00022080 +00a41023 +00571021 +8c430010 +00000000 +0074182a +1060ffc8 +26b50100 +8fbf0034 +8fbe0030 +8fb7002c +8fb60028 +8fb50024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0038 +27bdffb0 +afbe0044 +afb5003c +afb40038 +afb20030 +afbf0048 +afb60040 +afb30034 +afb1002c +afb00028 +8c850008 +0080a821 +3c040000 +8c83403c +00051100 +24420008 +03a0f021 +2463ffff +03a0a021 +03a2e823 +ac83403c +18a0006b +27b20010 +26b00010 +8e080014 +2402ffff +11020059 +00008821 +00009821 +08000230 +3c160000 +8e030000 +26730001 +aca30000 +8e020014 +001320c0 +acc20000 +8e030010 +26310004 +ace30000 +8e020004 +001319c0 +ad220000 +8ea20008 +00641823 +24630010 +0262102a +10400032 +02a38021 +8e080014 +2402ffff +11020041 +3c040000 +00111880 +00722821 +26220001 +26230002 +00021080 +00031880 +00523021 +00723821 +26220003 +92c34020 +00021080 +27c40010 +00524821 +1060ffdc +ae000020 +3c020000 +8c434038 +3c020000 +00032940 +00031880 +00a32823 +24423fb0 +00a22821 +8ca30000 +8ca20004 +8e070000 +8e050010 +8e060004 +00031a00 +00621825 +26730001 +afc30014 +afc80018 +afc5001c +afc60020 +0c000afd +afc70010 +8ea20008 +001320c0 +001319c0 +00641823 +24630010 +0262102a +1440ffd0 +02a38021 +92c24020 +00000000 +1040001e +3c020000 +ac404044 +0280e821 +03c0e821 +8fbf0048 +8fbe0044 +8fb60040 +8fb5003c +8fb40038 +8fb30034 +8fb20030 +8fb1002c +8fb00028 +03e00008 +27bd0050 +3c040000 +0c000615 +24843a9c +8e040000 +0c000640 +00000000 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +0800027a +00000000 +0800025d +3c160000 +02a02021 +0c000057 +02402821 +08000263 +0280e821 +00061080 +27bdffd8 +2442000e +afbe001c +afb20018 +afb10014 +afb00010 +afbf0020 +000210c2 +3c030000 +00c03821 +000210c0 +90664020 +03a0f021 +03a09021 +03a2e823 +00808821 +10c0003b +27b00010 +0c0008ab +02202021 +8c470008 +00000000 +18e0003f +00408021 +3c090000 +8d234038 +3c080000 +00031880 +250240a4 +00621021 +8c460000 +02002021 +00002821 +8c820028 +24a50001 +00c23021 +14e5fffc +24840078 +250240a4 +00621021 +ac460000 +3c030000 +8c62403c +8e050000 +8d244038 +24420001 +0c000e1b +ac62403c +1040000e +3c040000 +24020004 +ae020004 +0c0001fb +02002021 +0240e821 +03c0e821 +8fbf0020 +8fbe001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0028 +0c000615 +24843abc +24030003 +ae030004 +0240e821 +03c0e821 +8fbf0020 +8fbe001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0028 +00e02821 +0c000790 +02002021 +02002821 +0c0008ab +02202021 +8c470008 +00000000 +1ce0ffc3 +00408021 +080002ad +3c090000 +27bdffc8 +3c022000 +afb3001c +afb20018 +afbf0030 +afb7002c +afb60028 +afb50024 +afb40020 +afb10014 +afb00010 +34420350 +8c440000 +3c037fff +3463ffff +3c021000 +00832024 +00829025 +3c130000 +8e510000 +8e623fa8 +00000000 +0051102b +14400005 +3c170000 +8ee24044 +00000000 +1040000c +00111880 +8fbf0030 +8fb7002c +8fb60028 +8fb50024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0038 +00111100 +00431023 +3c030000 +8c644038 +00511021 +02202821 +00021040 +0c000d9a +24550001 +3c040000 +24843ae0 +0c000615 +0040a021 +0c000687 +02402021 +3c100000 +0c000615 +00402021 +0c000615 +26043c14 +3c040000 +24843b24 +0c000615 +3c160000 +8ec44048 +0c000640 +00000000 +0c000615 +00402021 +0c000615 +26043c14 +00143880 +00141940 +3c020000 +24423fb0 +00671823 +00621821 +8c640000 +8c660004 +8e653fa8 +3c020000 +00042200 +8c43402c +00b12823 +24020001 +00868025 +aee24044 +12030026 +ae653fa8 +1220000c +3c020000 +244240a4 +00e23021 +26440040 +00002821 +8c830000 +8cc20000 +24a50001 +00431021 +acc20000 +1625fffa +24840068 +02802021 +0c000d7f +02202821 +0c000777 +00000000 +8ec44048 +24030150 +ac44000c +ac500000 +ac430008 +ac550020 +00402021 +02402821 +0c0007b3 +02a03021 +8ec24048 +24030001 +24420001 +aec24048 +3c022000 +34420360 +ac430000 +080002f9 +00000000 +8ec44048 +02402821 +0c000283 +02a03021 +08000351 +00000000 +27bdffd0 +afb3001c +00062202 +00a09821 +30c500ff +afb60028 +afb20018 +afbf002c +afb50024 +afb40020 +afb10014 +afb00010 +0c00003c +00c09021 +12600030 +0040b021 +3c020000 +3c030000 +24514024 +24753fb0 +00008021 +0800038b +3c140000 +8e834038 +30e500ff +00031140 +00031880 +00431023 +00551021 +8c430000 +8c460004 +00031a00 +00661825 +10e30006 +00072202 +0c00003c +00000000 +00402021 +0c000d8f +24050001 +26100001 +12130015 +26310004 +8e270000 +00000000 +1647ffe9 +02c02021 +8e834038 +00000000 +00031140 +00031880 +00431023 +00551021 +8c430000 +8c450004 +00031a00 +00651825 +1243ffee +24050001 +0c000d8f +26100001 +1613ffed +26310004 +3c050000 +3c100000 +8ca23fa8 +8e034040 +3c040000 +24630001 +02621021 +24843b30 +aca23fa8 +0c000615 +ae034040 +8e044040 +00000000 +00041900 +00042080 +00832021 +00041080 +00822021 +0c000640 +00042042 +0c000615 +00402021 +3c040000 +0c000615 +24843b40 +8e034040 +24020002 +1062000b +00000000 +8fbf002c +8fb60028 +8fb50024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0030 +3c040000 +24843b44 +0c000615 +3c102000 +36030300 +8c640000 +0c000640 +36100080 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +24020001 +ae020000 +080003bc +00000000 +27bdff60 +afb00078 +27b00044 +02002021 +afbf0098 +afb70094 +afb60090 +afb5008c +afb40088 +afb30084 +afb20080 +0c0007d5 +afb1007c +8fa3004c +24020160 +10620041 +2c620161 +14400030 +24020090 +24020200 +1062004e +2c620201 +14400050 +24020180 +24020240 +106200a3 +24020260 +10620124 +24020235 +1462004d +00000000 +3c040000 +0c000615 +24843bac +8fa40050 +0c000640 +3c100000 +0c000615 +00402021 +3c040000 +0c000615 +24843bd0 +8fa40058 +0c000640 +00000000 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +8fa40050 +8fa50058 +0c0008f6 +00000000 +8fa50064 +8e044038 +8fa60050 +0c000e50 +00000000 +8fa50058 +8e044038 +8fa60050 +0c000dfe +00000000 +0800042f +00000000 +10620020 +2c620091 +1440003e +24020050 +24020140 +106200ca +24020150 +14620022 +3c040000 +8fa40050 +8fa60064 +0c000283 +00002821 +0800042f +00000000 +8fa20058 +8fa40054 +3c030000 +0c000918 +ac62402c +0c000199 +00000000 +8fbf0098 +8fb70094 +8fb60090 +8fb5008c +8fb40088 +8fb30084 +8fb20080 +8fb1007c +8fb00078 +03e00008 +27bd00a0 +0c000a30 +02002021 +0800042f +00000000 +106200a2 +24020190 +1062fff9 +00000000 +3c040000 +0c000615 +24843bdc +8fa4004c +0c000687 +3c100000 +0c000615 +00402021 +0c000615 +26043c14 +3c040000 +0c000615 +24843bf4 +3c032000 +34630300 +8c640000 +0c000640 +00000000 +0c000615 +00402021 +0c000615 +26043c14 +0800042f +00000000 +10620099 +24020070 +1462ffe5 +00000000 +8fa40050 +3c170000 +0c000875 +00042202 +8fa50050 +00402021 +0c000868 +00408021 +8ee74038 +3c120000 +00071880 +00071140 +00431023 +26513fb0 +00511021 +8c430000 +8c440004 +00031a00 +8fa20054 +00641825 +104300c6 +00000000 +8e05000c +8e020008 +00000000 +14a2ffb7 +00000000 +18a000a3 +02002021 +8ee24038 +00000000 +00021940 +00021080 +00621823 +3c020000 +00714821 +24474024 +00003021 +0800048b +2408ffff +24c60001 +ace20000 +24840078 +10a60093 +24e70004 +8c82002c +00000000 +1448fff8 +00000000 +8d220000 +8d230004 +00021200 +08000486 +00431025 +8fa50064 +27b00024 +00052880 +0c000790 +02002021 +8fa20064 +00000000 +10400042 +3c120000 +26563fb0 +00008821 +3c150000 +27b40010 +3c130000 +3c120000 +3c170000 +8e030004 +8e06000c +8e050008 +8fa70054 +8e020000 +02802021 +afa30018 +afa60020 +afa5001c +afa70014 +0c000afd +afa20010 +0c000615 +26643b80 +8fa40010 +0c000640 +26310001 +0c000615 +00402021 +0c000615 +26443b98 +8fa40018 +0c000687 +26100010 +0c000615 +00402021 +0c000615 +26a43c14 +8fa40018 +0c00000c +00000000 +00403021 +8ee24038 +00000000 +00021940 +00021080 +00621823 +00761821 +8c620000 +8c640004 +00021200 +00441025 +10c2000a +00000000 +8fa20014 +30c500ff +10c20006 +00062203 +0c00003c +00000000 +00402021 +0c000d7f +24050001 +8fa20064 +00000000 +0222102b +1440ffc7 +00000000 +3c020000 +0800042f +ac404044 +3c020000 +8fa50058 +8c444038 +8fa60050 +0c000e50 +00000000 +0800042f +00000000 +8fa50064 +3c040000 +0c000790 +24844024 +8fa40050 +8fa50064 +8fa60058 +0c000360 +00000000 +0800042f +00000000 +3c040000 +0c000615 +24843b4c +8fa40050 +0c000640 +3c110000 +0c000615 +00402021 +0c000615 +26243c14 +8fa40050 +0c000875 +00042202 +8fa50050 +00402021 +0c0007e7 +00409021 +3c040000 +00408021 +0c000615 +24843b6c +0c000640 +02002021 +0c000615 +00402021 +0c000615 +26243c14 +8e430008 +00000000 +1603ff1d +00000000 +0c0000e9 +02402021 +0800042f +00000000 +8fa40058 +8fa50070 +0c000d70 +00000000 +0800042f +00000000 +3c020000 +90434020 +00000000 +10600012 +26443fb0 +8ee34038 +00000000 +00031140 +00031880 +00431023 +00441021 +8c460000 +8c430004 +00063200 +8e040000 +0c000360 +00c33025 +8e040000 +0c00089d +00000000 +0800042f +00000000 +3c050000 +24a54024 +0c0000c9 +02002021 +0800052e +00000000 +8fa50058 +8fa60050 +0c000e50 +00e02021 +08000474 +00000000 +3c040000 +27bdffe8 +24843bfc +afbf0014 +0c000615 +afb00010 +0c00081a +00000000 +00402021 +0c000a05 +00408021 +14400005 +02002021 +8fbf0014 +8fb00010 +03e00008 +27bd0018 +24020004 +ae020004 +8fbf0014 +8fb00010 +080001fb +27bd0018 +27bdffd8 +3c022000 +afbf0020 +afb3001c +afb20018 +afb10014 +afb00010 +34420140 +8c430000 +00000000 +1460005c +00000000 +3c040000 +0c000615 +24843c18 +3c040000 +8c834038 +3c020000 +00032940 +00031880 +00a32823 +24423fb0 +00a22821 +8ca30000 +8ca20004 +00031a00 +00621825 +24040001 +3c020000 +3c130000 +ac43402c +0c000144 +a2644020 +0c000199 +00000000 +0c000005 +00000000 +0c000809 +3c120000 +0c000ae0 +00000000 +0c00078a +00000000 +3c040000 +0c000615 +24843c58 +3c022000 +34420020 +8c430000 +00000000 +30630020 +1460001e +00000000 +8e42403c +00000000 +1440001e +00000000 +92624020 +00000000 +1040fff3 +3c022000 +3c112000 +36220250 +8c430000 +00000000 +1460ffed +3c022000 +0c000ae7 +00000000 +10400018 +00408021 +0c00009b +00402021 +2402ffff +ae020000 +3c022000 +34420020 +8c430000 +00000000 +30630020 +1060ffe4 +00000000 +0c0003d7 +00000000 +08000585 +3c022000 +0c000932 +00000000 +1040ffe0 +00000000 +0c00053f +00000000 +08000585 +3c022000 +36220350 +8c430000 +00000000 +0461ffcc +00000000 +0c0002dc +00000000 +08000585 +3c022000 +3c040000 +24843c38 +0c000615 +3c130000 +0800057b +a2604020 +27bdffd8 +afb00010 +00048203 +afb20018 +00809021 +02002021 +afb3001c +afbf0020 +afb10014 +0c000875 +00a09821 +8c430004 +3c040000 +24020001 +10620019 +24843c6c +0c000615 +00000000 +0c000640 +02402021 +0c000615 +00402021 +3c040000 +0c000615 +24843c94 +0c000640 +02002021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +8fbf0020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +00001021 +03e00008 +27bd0028 +0c000777 +00000000 +02402021 +0c000c81 +00408021 +00408821 +24020210 +00002821 +00003021 +ae020008 +ae130020 +ae110000 +ae12000c +0c0007b3 +02002021 +0c000909 +02402021 +3c040000 +0c000615 +24843cb4 +0c000640 +02402021 +0c000615 +00402021 +3c040000 +0c000615 +24843cd4 +0c000640 +02202021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +8fbf0020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +24020001 +03e00008 +27bd0028 +8c820000 +3c032000 +ac620000 +00802821 +80840000 +00000000 +10800022 +00000000 +80a20001 +00000000 +1040001e +00000000 +80a20002 +00000000 +1040001a +00000000 +80a20003 +00000000 +10400016 +3c042000 +08000637 +24a50004 +80a20001 +00000000 +10400010 +00000000 +80a20002 +00000000 +1040000c +00000000 +80a20003 +00000000 +10400008 +24a50004 +8ca20000 +00000000 +ac820000 +80a30000 +00000000 +1460ffee +00000000 +03e00008 +00001021 +14800009 +00802821 +3c020000 +24444084 +00802821 +24030030 +a0434084 +00a01021 +03e00008 +a0800001 +3c03cccc +3463cccd +00830019 +3c020000 +24464085 +3c080000 +24070001 +00001810 +000318c2 +00031040 +000320c0 +00441021 +00a21023 +24420030 +00602821 +10a00013 +a1024084 +3c03cccc +3463cccd +00a30019 +24e70001 +00001810 +000320c2 +00041040 +000418c0 +00431021 +00a21023 +24420030 +a0c20000 +2402000b +10e2000d +24c60001 +00802821 +14a0fff0 +3c03cccc +3c040000 +24824078 +00e21021 +24e3ffff +04610008 +a0400000 +24854078 +03e00008 +00a01021 +3c040000 +24824078 +2403000a +a040000b +24824078 +00621821 +3c020000 +25054084 +24464077 +90a20000 +00000000 +a0620000 +2463ffff +1466fffb +24a50001 +08000674 +24854078 +3c080000 +2503406c +24050030 +24020078 +a0620001 +a060000a +1480000b +a105406c +a0650009 +a0650002 +a0650003 +a0650004 +a0650005 +a0650006 +a0650007 +a0650008 +03e00008 +2502406c +3c020000 +3c030000 +24474075 +080006a2 +2463406d +a0e60000 +24e7ffff +10e3fff6 +00042102 +3082000f +24460030 +24450057 +2c42000a +1440fff7 +00000000 +0800069f +a0e50000 +04800003 +00801021 +03e00008 +00000000 +03e00008 +00041023 +30820001 +00021023 +3042b400 +00042043 +00822026 +14c00002 +0086001a +0007000d +00001010 +03e00008 +00451021 +03e00008 +00851021 +03e00008 +00851023 +18c00008 +00801021 +30a500ff +00c43021 +00801821 +a0650000 +24630001 +1466fffd +00000000 +03e00008 +00000000 +0480004b +3c0b0000 +10800042 +3c020000 +3c0b0000 +00802821 +00003021 +080006da +2567405c +10400084 +24020030 +a0e20000 +24c60001 +2402000c +10c20015 +24e70001 +00051fc3 +10a0fff7 +28c20005 +3c026666 +34426667 +00a20018 +24c60001 +00001010 +00021083 +00431023 +00021840 +000220c0 +00641821 +00a31823 +24630030 +00402821 +2402000c +a0e30000 +14c2ffed +24e70001 +3c090000 +2522404c +2406000c +a040000d +2567405c +00002821 +2522404c +90e40000 +00c21821 +24c6ffff +24a50001 +24e70001 +00c24021 +04c00010 +a0640000 +24020004 +14a2fff6 +2522404c +2402002e +a1020000 +24c6ffff +2522404c +90e40000 +00c21821 +24c6ffff +24a50001 +24e70001 +00c24021 +04c1fff2 +a0640000 +2525404c +03e00008 +00a01021 +2444405c +00802821 +24030030 +a043405c +00a01021 +03e00008 +a0800001 +3c026666 +00042823 +344a6667 +00003021 +2567405c +24090030 +08000724 +2408000c +10400040 +00000000 +24c60001 +a0e90000 +10c80012 +24e70001 +00051fc3 +10a0fff8 +28c20005 +00aa0018 +24c60001 +00001010 +00021083 +00431023 +00021840 +000220c0 +00641821 +00a31823 +24630030 +a0e30000 +00402821 +14c8fff0 +24e70001 +3c090000 +2522404c +a040000e +2405000d +2567405c +00003021 +2522404c +90e40000 +00a21821 +24a5ffff +24c60001 +24e70001 +00a24021 +04a00010 +a0640000 +24020004 +14c2fff6 +2522404c +2402002e +a1020000 +24a5ffff +2522404c +90e40000 +00a21821 +24a5ffff +24c60001 +24e70001 +00a24021 +04a1fff2 +a0640000 +2525404c +2402002d +a122404c +03e00008 +00a01021 +3c090000 +2522404c +00c21021 +04c1ff96 +a0400001 +0800070d +2525404c +3c090000 +2522404c +00c21021 +24c50001 +04a1ffd5 +a0400002 +08000754 +2525404c +00801821 +80a20000 +24a50001 +a0620000 +1440fffc +24630001 +03e00008 +00801021 +00801821 +80620000 +00000000 +1440fffd +24630001 +00641023 +03e00008 +2442ffff +3c020000 +244440ec +8c820034 +3c030000 +246340b4 +10400007 +00802821 +24030001 +3c020000 +ac4340e8 +00a01021 +03e00008 +ac800034 +24020001 +00602821 +ac820034 +00a01021 +03e00008 +ac600034 +24020001 +3c030000 +3c040000 +ac6240e8 +03e00008 +ac824120 +3c022000 +24090001 +34430200 +34460220 +34470210 +34480230 +ac650000 +acc90000 +34430260 +ace40000 +ad090000 +8c620000 +00000000 +1440fffd +00000000 +03e00008 +00000000 +3c062000 +00804021 +00a03821 +34c30250 +8c620000 +00000000 +1440fffd +34c20200 +ac470000 +34c50230 +34c30220 +34c40210 +24020001 +ac600000 +ac880000 +aca20000 +03e00008 +00000000 +24c2000b +ac820004 +3c022000 +ac80001c +34420140 +8c430000 +3c072000 +ac830014 +00804021 +00a04821 +34e30250 +8c620000 +00000000 +1440fffd +34e20300 +8c430000 +34e40200 +34e50210 +2402000d +ad030018 +ac820000 +aca80000 +10c00004 +34e20205 +34e30215 +ac460000 +ac690000 +34e20230 +34e30220 +24040001 +ac600000 +ac440000 +03e00008 +00000000 +3c032000 +24090001 +34650200 +34660220 +34670210 +34680230 +2402000d +aca20000 +34630260 +acc90000 +ace40000 +ad090000 +8c620000 +00000000 +1440fffd +00000000 +03e00008 +00000000 +8c870008 +00000000 +18e0001c +00801821 +00004821 +00003021 +080007f7 +24080001 +8c620030 +00000000 +10480012 +00000000 +24c60001 +00c7102a +1040000c +24630078 +8c620010 +00000000 +1445fff5 +00000000 +ac680030 +8c870008 +24c60001 +00c7102a +25290001 +1440fff6 +24630078 +03e00008 +01201021 +080007f3 +25290001 +00004821 +03e00008 +01201021 +3c050000 +24a24124 +2403ffff +24040002 +ac430200 +ac440204 +aca34124 +ac40020c +ac400008 +ac440004 +ac40000c +ac430100 +ac400108 +ac440104 +ac40010c +03e00008 +ac400208 +27bdffe8 +3c020000 +3c030000 +afbf0010 +24444128 +24674428 +00002821 +24060003 +8c820000 +00000000 +1046000a +00000000 +24840100 +1487fffa +00000000 +10a0000f +00a01021 +8fbf0010 +00000000 +03e00008 +27bd0018 +10a00007 +00000000 +8ca20000 +8c83fffc +00000000 +0062102a +1040fff0 +00000000 +08000826 +2485fffc +3c040000 +0c000615 +24843ce0 +0800083c +00000000 +27bdffe8 +afb00010 +afbf0014 +8c860008 +00000000 +18c0000e +00a08021 +8c820010 +00000000 +10a20016 +00802821 +0800084f +00001821 +8ca20088 +00000000 +12020011 +24a50078 +24630001 +1466fffa +00000000 +3c040000 +0c000615 +24843d08 +0c000640 +02002021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +0800085c +00000000 +00001821 +000311c0 +000318c0 +00431023 +24420010 +8fbf0014 +8fb00010 +00821021 +03e00008 +27bd0018 +27bdffe8 +afbf0010 +8c83000c +00000000 +24630001 +0c00083e +ac83000c +24030003 +ac430020 +8fbf0010 +00000000 +03e00008 +27bd0018 +27bdffe8 +afb00010 +afbf0014 +3c050000 +8ca24124 +00000000 +1082001f +00808021 +24a34124 +8c620100 +00000000 +10820018 +00000000 +8c620200 +00000000 +1082000c +3c040000 +0c000615 +24843d20 +0c000640 +02002021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +0800088f +00000000 +24030002 +00031a00 +24a24124 +8fbf0014 +8fb00010 +00621021 +03e00008 +27bd0018 +08000892 +24030001 +08000892 +00001821 +27bdffe8 +afbf0010 +0c000875 +00000000 +2403ffff +24040002 +ac430000 +ac440004 +ac40000c +ac400008 +8fbf0010 +00000000 +03e00008 +27bd0018 +27bdffd8 +afb1001c +00808821 +2404ffff +afb00018 +afbf0020 +0c000875 +00a08021 +ac510000 +00405821 +8e020000 +00000000 +18400038 +ad620008 +26050004 +00115200 +00006021 +2409ffff +8ca30000 +24a80068 +afa30010 +8fa20010 +24a70018 +304200ff +afa20010 +8fa30010 +8ca40004 +000311c0 +000318c0 +00431023 +24420010 +01623021 +acc40004 +8ca30008 +00c02021 +acc30008 +8ca2000c +00000000 +acc2000c +8ca30010 +acc90014 +acc30010 +acc00024 +8ca30014 +8fa20010 +acc30018 +004a1025 +acc20000 +acc9001c +8ce20000 +00000000 +004a1025 +ac820028 +8ce30004 +24e70008 +ac83002c +10490005 +24840008 +8cc20024 +00000000 +24420001 +acc20024 +14e8fff2 +00000000 +8d620008 +258c0001 +0182102a +1440ffce +00e02821 +8fbf0020 +8fb1001c +8fb00018 +01601021 +03e00008 +27bd0028 +27bdffe0 +afb00010 +00808021 +00042203 +afbf0018 +afb10014 +0c000875 +00a08821 +00402021 +0c00083e +02002821 +24030002 +ac510014 +ac430020 +8fbf0018 +8fb10014 +8fb00010 +03e00008 +27bd0020 +27bdffe8 +afb00010 +00808021 +afbf0014 +0c000875 +00042203 +00402021 +0c00083e +02002821 +24030004 +ac430020 +8fbf0014 +8fb00010 +03e00008 +27bd0018 +00042880 +00041940 +3c020000 +00651823 +24423fb0 +00621821 +8c620008 +8c650010 +8c67000c +8c660014 +00a22823 +24a50001 +3c020000 +00c73023 +ac454034 +3c030000 +3c020000 +24c60001 +24050001 +ac664030 +ac454094 +3c030000 +3c020000 +ac644038 +03e00008 +ac404428 +3c030000 +8c624428 +03e00008 +2c420001 +27bdffe0 +afbf001c +afb20018 +afb10014 +00a09021 +00c08821 +afb00010 +0c000777 +00808021 +24030090 +ac500000 +ac430008 +ac51000c +ac520020 +8fbf001c +8fb20018 +8fb10014 +8fb00010 +00402021 +00002821 +00003021 +080007b3 +27bd0020 +27bdffd8 +afbf0020 +afb3001c +afb20018 +00c09821 +00a09021 +afb10014 +afb00010 +00e08821 +0c000777 +00808021 +24030200 +ac500000 +ac430008 +ac52000c +ac510010 +ac530020 +8fbf0020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +00402021 +00002821 +00003021 +080007b3 +27bd0028 +27bdffe0 +afbf0018 +afb10014 +afb00010 +00a08821 +0c000777 +00808021 +3c040000 +8c834038 +ac500000 +00032940 +00031880 +00a32823 +24030190 +ac430008 +3c030000 +24633fb0 +ac51000c +00a32821 +8ca40000 +8ca30004 +00042200 +00832025 +ac440020 +8fbf0018 +8fb10014 +8fb00010 +00402021 +00002821 +00003021 +080007b3 +27bd0020 +27bdffc0 +3c020000 +afb00018 +24504424 +3c0200ff +2403ffff +3442ffff +3c040000 +afbf003c +afbe0038 +afb70034 +afb60030 +afb30024 +afb20020 +afb1001c +afb5002c +afb40028 +3c110000 +ae030014 +ae030010 +3c130000 +ae02000c +ae000008 +8e354034 +8e744030 +0c000615 +24843d40 +8e244034 +0c000640 +3c120000 +0c000615 +00402021 +0c000615 +26443c14 +3c040000 +0c000615 +24843d5c +8e644030 +0c000640 +3c1e0000 +0c000615 +00402021 +0c000615 +26443c14 +8e050018 +8fc24038 +02850018 +24a6ffff +3c040000 +24843fb0 +00809021 +00008821 +00001812 +afa30010 +00021940 +02860018 +00021080 +00621823 +00641821 +8c760004 +8c730000 +24140004 +0000b812 +00000000 +00000000 +02a50018 +00008012 +00000000 +00000000 +02a60018 +0000a812 +8fc24038 +8e440000 +8e460004 +10510013 +02641823 +04600022 +00000000 +02c62823 +04a0001d +00000000 +02a3102a +14400004 +0203102a +02e5102a +10400008 +0203102a +14400006 +00000000 +8fa30010 +00000000 +0065102a +10400014 +3c030000 +26310001 +1634ffe7 +2652001c +8fbf003c +8fbe0038 +8fb70034 +8fb60030 +8fb5002c +8fb40028 +8fb30024 +8fb20020 +8fb1001c +8fb00018 +03e00008 +27bd0040 +080009d9 +00052823 +080009d6 +00031823 +8c624424 +00042200 +8c450000 +0c000968 +00c42025 +3c030000 +24634424 +8c620008 +00000000 +24420001 +080009e6 +ac620008 +27bdffe8 +afbf0010 +8c870008 +00000000 +18e0000e +2402ffff +8c830024 +00000000 +10620020 +00802821 +08000a15 +00003021 +8ca3009c +00000000 +10620008 +24a50078 +24c60001 +14c7fffa +2402ffff +8fbf0010 +24020001 +03e00008 +27bd0018 +00c01821 +000311c0 +000318c0 +00431023 +24420010 +00822821 +10a0fff5 +3c020000 +24444424 +24030001 +ac830018 +ac830004 +0c000988 +ac454424 +8fbf0010 +00001021 +03e00008 +27bd0018 +08000a1d +00001821 +27bdffe0 +afb10014 +afbf001c +afb20018 +afb00010 +8c830008 +24020190 +1062000c +00808821 +24020200 +1062002e +24020090 +10620077 +3c020000 +8fbf001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0020 +3c120000 +8e434038 +3c020000 +00032140 +00031880 +00832023 +24423fb0 +00822021 +8c830018 +00000000 +1860007b +2406ffff +8e24000c +0c000dbb +00000000 +8e270020 +00408021 +304400ff +00101a03 +00071202 +30e700ff +8e25000c +00e43821 +00431021 +8e240014 +02003021 +0c00094d +00e23821 +8e444038 +8e26000c +02002821 +8fbf001c +8fb20018 +8fb10014 +8fb00010 +08000dfe +27bd0020 +3c120000 +26504424 +8e020008 +2404ffff +2442ffff +ae020008 +8e250020 +00000000 +10a40016 +00000000 +8e230010 +8e02000c +00000000 +0062102b +10400062 +00000000 +8e050010 +00000000 +10a40005 +ae03000c +8e040014 +8e26000c +0c000936 +00000000 +8e220020 +00000000 +ae020010 +8e230014 +00000000 +ae030014 +26504424 +8e020008 +00000000 +1440ffb3 +3c110000 +8e030010 +2402ffff +1062002e +3c040000 +0c000615 +24843d78 +8e040010 +0c000687 +00000000 +0c000615 +00402021 +3c040000 +0c000615 +24843db4 +8e234424 +00000000 +8c640000 +0c000640 +00000000 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +8e234424 +8e020010 +ae000004 +ac620014 +8e050014 +8c640000 +ac65001c +0c000875 +00042203 +00402021 +8fbf001c +8fb20018 +8fb10014 +8fb00010 +08000a05 +27bd0020 +8e26000c +8e250020 +8c444038 +8fbf001c +8fb20018 +8fb10014 +8fb00010 +08000e50 +27bd0020 +8e020018 +3c030000 +8c644094 +24420001 +0082202a +14800010 +ae020018 +8fbf001c +8fb20018 +8fb10014 +8fb00010 +08000988 +27bd0020 +8e25000c +8e240014 +8fbf001c +8fb20018 +8fb10014 +8fb00010 +2407ffff +0800094d +27bd0020 +3c040000 +24020001 +24843dc0 +0c000615 +ae020018 +08000ac4 +00000000 +8e26000c +8e240014 +0c000936 +26504424 +08000a88 +00000000 +3c020000 +2403ffff +24444440 +ac830028 +ac434440 +03e00008 +ac830014 +3c070000 +8ce640a0 +3c050000 +10c0000e +00001021 +8ca34098 +24020002 +1062000c +24640001 +aca44098 +24c2ffff +00032100 +ace240a0 +00031880 +3c020000 +00641821 +24424440 +00621021 +03e00008 +00000000 +08000af1 +aca04098 +3c0a0000 +27bdffe8 +8d4340a0 +afbf0010 +3c060000 +24020003 +8cc5409c +1062001e +00804821 +24020002 +10a20019 +24a20001 +acc2409c +00051100 +00051880 +8d4440a0 +00621821 +3c020000 +8d250010 +8d260000 +8d270004 +8d280008 +24424440 +8d29000c +00621821 +24840001 +ac650010 +ad4440a0 +ac660000 +ac670004 +ac680008 +ac69000c +8fbf0010 +00000000 +03e00008 +27bd0018 +08000b0a +acc0409c +3c040000 +0c000615 +24843de4 +08000b26 +00000000 +3c050000 +3c020000 +2442447c +2403ffff +24a44ab8 +ac830008 +a0400634 +aca34ab8 +a040020c +a0400420 +03e00008 +ac830004 +3c020000 +3c030000 +24454688 +24634cc4 +00003821 +24060002 +80a20000 +00000000 +10460006 +00000000 +24a50214 +14a3fffa +00e01021 +03e00008 +00000000 +8ca2fdf4 +00000000 +1444fff8 +00000000 +08000b3e +24e70001 +3c020000 +3c030000 +24444688 +24634cc4 +00002821 +24060002 +80820000 +00000000 +10460005 +24840214 +1483fffb +00000000 +03e00008 +00a01021 +1483fff7 +24a50001 +08000b55 +00000000 +3c080000 +8d033fac +24020003 +14620004 +3c030000 +00003021 +03e00008 +00c01021 +3c020000 +2446447c +24634ab8 +00005021 +240bffff +08000b6d +24070002 +24c60214 +10c30015 +00000000 +80c2020c +00000000 +1447fffa +00000000 +8cc20000 +00000000 +1482fff6 +00000000 +8cc20004 +00000000 +14a2fff2 +00000000 +8cc90210 +00000000 +012b102b +1040ffed +00000000 +01205821 +08000b6a +00c05021 +1140ffdf +01403021 +a140020c +8d033fac +30a2ffff +00042400 +00822025 +3c022000 +24630001 +34420285 +ad033fac +ac440000 +03e00008 +00c01021 +3c050000 +24a3447c +8062020c +00000000 +1040000b +00002021 +80620420 +00000000 +10400007 +24040001 +80620634 +24040002 +10400003 +00001821 +03e00008 +00601021 +000419c0 +00041080 +00431021 +00441021 +00021080 +24a3447c +00431821 +03e00008 +00601021 +27bdffd8 +afb40020 +afb3001c +afb10014 +afb00010 +afbf0024 +afb20018 +3c130000 +8e623fac +00808021 +00a0a021 +1040004d +00c08821 +3c020000 +3c030000 +24444688 +24634cc4 +00009021 +00003821 +08000bc0 +24060002 +24840214 +10830014 +24020003 +80820000 +00000000 +1446fffa +00000000 +8c82fdf4 +00000000 +1602fff6 +24e50001 +8c82fdf8 +00000000 +1682fff2 +30a700ff +8c850004 +00000000 +0245102b +1040ffed +00000000 +08000bbd +00a09021 +10e2002e +00003021 +0c000b8f +00000000 +10400029 +00402821 +ac500000 +ac540004 +8e220000 +26440001 +24030002 +aca20008 +a0a3020c +aca40210 +8e270000 +00000000 +18e0000a +00a02021 +26260004 +00002821 +8cc20000 +24a50001 +00a7182a +ac82000c +24c60004 +1460fffa +24840004 +8e633fac +3282ffff +00102400 +00822025 +3c022000 +34420280 +2463ffff +ae633fac +ac440000 +24060001 +8fbf0024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +00c01021 +03e00008 +27bd0028 +00003021 +8fbf0024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +00c01021 +03e00008 +27bd0028 +3c060000 +24c24ab8 +8c430004 +00000000 +10640003 +00001021 +03e00008 +00000000 +8cc24ab8 +00000000 +00451026 +03e00008 +2c420001 +3c060000 +24c74ab8 +8ce20004 +00000000 +14440007 +00e04021 +8cc44ab8 +00021400 +3083ffff +00431825 +10850004 +2409ffff +00004021 +03e00008 +01001021 +3c022000 +34420295 +ac430000 +01001021 +acc94ab8 +03e00008 +ace90004 +3c070000 +24e64ab8 +8cc20004 +2409ffff +14440012 +00004021 +8ce34ab8 +24080003 +aca30000 +8cc20004 +00000000 +aca20004 +8cc30008 +3c022000 +aca30008 +8ce44ab8 +94c30006 +00042400 +00832025 +34420295 +ac440000 +acc90004 +ace94ab8 +03e00008 +01001021 +3c080000 +00041c00 +30a2ffff +8d074ab8 +27bdffe8 +00804821 +00621825 +3c040000 +2402ffff +afbf0010 +250b4ab8 +240a0001 +10e20008 +24843e00 +0c000615 +00000000 +00005021 +8fbf0010 +01401021 +03e00008 +27bd0018 +3c022000 +34420290 +ad660008 +ac430000 +8fbf0010 +01401021 +27bd0018 +ad054ab8 +03e00008 +ad690004 +00041900 +3c020000 +00042080 +00832021 +24424ac4 +00822021 +8c820000 +03e00008 +00000000 +3c060000 +24c24ac4 +2403ffff +24040001 +24050064 +acc34ac4 +ac430038 +ac44002c +ac450030 +ac440004 +ac450008 +ac430010 +ac430014 +ac440018 +ac45001c +ac430024 +03e00008 +ac430028 +27bdffe8 +3c020000 +3c030000 +afb00010 +afbf0014 +00808021 +24454ac8 +24634b04 +24060001 +2407ffff +8ca20000 +00000000 +10460009 +00000000 +8ca4fffc +00000000 +10870005 +00000000 +8ca2000c +00000000 +1202000e +00000000 +24a50014 +14a3fff2 +3c040000 +0c000615 +24843e20 +0c000640 +02002021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +2404ffff +8fbf0014 +8fb00010 +00801021 +03e00008 +27bd0018 +27bdffe8 +afb00010 +afbf0014 +3c050000 +8ca24ac4 +00000000 +1082001f +00808021 +24a34ac4 +8c620014 +00000000 +10820011 +24020001 +8c620028 +00000000 +1082000c +3c040000 +0c000615 +24843e4c +0c000640 +02002021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +08000cc3 +00000000 +24020002 +00021900 +00021080 +00431021 +24a44ac4 +8fbf0014 +8fb00010 +00441021 +03e00008 +27bd0018 +08000cc6 +00001021 +27bdffe8 +afbf0010 +0c000ca9 +00000000 +8c420004 +8fbf0010 +00000000 +03e00008 +27bd0018 +27bdffe0 +afb10014 +afb00010 +afbf0018 +00808021 +0c000ca9 +00a08821 +8c430004 +00402021 +24020001 +10620019 +00000000 +8c820010 +00000000 +16220009 +24620001 +2403ffff +ac820004 +ac830010 +8fbf0018 +8fb10014 +8fb00010 +03e00008 +27bd0020 +3c040000 +0c000615 +24843e88 +0c000640 +02202021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +08000cfc +00000000 +3c040000 +0c000615 +24843e68 +0c000640 +02002021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +08000d08 +00000000 +27bdffe0 +afb10014 +afb00010 +afbf0018 +00a08021 +0c000ca9 +00808821 +8c430004 +00000000 +10600021 +00402821 +8c460010 +2402ffff +10c2000f +00000000 +1206000f +2404ffff +28820000 +14400024 +00041080 +00451021 +2463ffff +ac500010 +aca30004 +8fbf0018 +8fb10014 +8fb00010 +03e00008 +27bd0020 +1606fff3 +00002021 +3c040000 +0c000615 +24843ee4 +0c000640 +02002021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +08000d33 +00000000 +3c040000 +0c000615 +24843eac +0c000640 +02202021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +08000d3f +00000000 +3c040000 +0c000615 +24843f00 +0c000640 +02202021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +08000d4b +00000000 +27bdffe8 +afb00010 +00808021 +afbf0014 +0c000ca9 +2404ffff +2403ffff +24040001 +ac430010 +ac440004 +ac500000 +ac400008 +ac40000c +8fbf0014 +8fb00010 +03e00008 +27bd0018 +27bdffe8 +afbf0010 +0c000ca9 +00000000 +8c43000c +00000000 +10600007 +24040064 +8c420008 +00000000 +14600002 +0043001b +0007000d +00002012 +8fbf0010 +00801021 +03e00008 +27bd0018 +27bdffe8 +afbf0014 +afb00010 +0c000ca9 +00a08021 +8c440008 +8c43000c +00902021 +24630001 +ac43000c +ac440008 +8fbf0014 +8fb00010 +03e00008 +27bd0018 +00043140 +3c020000 +00042080 +24423fb0 +00c43023 +00c23021 +8cc30018 +00000000 +00651023 +00a3182a +10600003 +00000000 +03e00008 +acc20018 +03e00008 +acc00018 +00043140 +3c020000 +00042080 +00c43023 +24423fb0 +00c23021 +8cc30018 +00000000 +00651821 +03e00008 +acc30018 +3c020000 +00803821 +24453fc8 +2409ffff +00003021 +00002021 +24080004 +10e40008 +00000000 +8ca30000 +00000000 +00c3102a +10400003 +00000000 +00603021 +00804821 +24840001 +1488fff5 +24a5001c +00071880 +00072140 +3c020000 +00832023 +24423fb0 +00822021 +8c830018 +00000000 +00c3182a +10600002 +00000000 +00e04821 +03e00008 +01201021 +27bdffd0 +afb50024 +afb40020 +afb3001c +afb20018 +afb10014 +afbf0028 +afb00010 +0080a821 +2414ffff +2413ffff +00008821 +24120003 +0c000c66 +02202021 +00402021 +0c000cd1 +00408021 +26310001 +18400009 +02002021 +0c000d5e +00000000 +00401821 +0262102a +10400003 +00000000 +0200a021 +00609821 +1632ffef +2402ffff +1282001c +00000000 +3c040000 +0c000615 +24843f28 +0c000640 +02a02021 +0c000615 +00402021 +3c040000 +0c000615 +24843f40 +0c000687 +02802021 +0c000615 +00402021 +3c040000 +0c000615 +24843c14 +02801021 +8fbf0028 +8fb50024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +03e00008 +27bd0030 +3c040000 +0c000615 +24843f50 +0c000640 +02a02021 +08000de8 +00000000 +27bdffe8 +afb00010 +00808021 +00a02021 +afbf0014 +0c000d0a +00c02821 +00102140 +3c020000 +00108080 +24423fb0 +00902023 +00822021 +8c830018 +00000000 +2462ffff +28630002 +14600006 +00000000 +ac820018 +8fbf0014 +8fb00010 +03e00008 +27bd0018 +ac800018 +8fbf0014 +8fb00010 +03e00008 +27bd0018 +27bdffd8 +afb40020 +0080a021 +00a02021 +afb20018 +afbf0024 +afb3001c +afb10014 +0c000875 +afb00010 +00409021 +8c420008 +00000000 +1840001b +00008821 +2413ffff +08000e35 +26500010 +8e060000 +0c000dfe +ae020014 +8e420008 +00000000 +0222102a +10400010 +26100078 +8e040000 +0c000dbb +26310001 +00402821 +1453fff3 +02802021 +8fbf0024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +00001021 +03e00008 +27bd0028 +3c040000 +0c000615 +24843f88 +8fbf0024 +8fb40020 +8fb3001c +8fb20018 +8fb10014 +8fb00010 +24020001 +03e00008 +27bd0028 +27bdffe8 +afb00010 +00808021 +00a02021 +afbf0014 +0c000cda +00c02821 +00102140 +3c020000 +00108080 +00902023 +24423fb0 +00822021 +8c830018 +00000000 +24630001 +ac830018 +8fbf0014 +8fb00010 +03e00008 +27bd0018 +4552524f +523a206e +6f206d61 +73746572 +20616464 +72657373 +20666f75 +6e640a00 +4552524f +52202d20 +636c7573 +74657220 +6e616f20 +656e636f +6e747261 +646f0a00 +53656e64 +206e6577 +20415050 +20524551 +55455354 +20746f20 +6d617374 +6572202d +2069643a +20000000 +20617070 +2069643a +20000000 +5461736b +20616c6c +6f636174 +696f6e20 +73656e64 +202d2069 +643a2000 +2073656e +6420746f +2070726f +633a2000 +0a202d3e +2073656e +64205441 +534b5f52 +454c4541 +53452074 +6f207461 +736b2000 +56616920 +696e6963 +69616c69 +7a722063 +6c757374 +65722000 +41646472 +6573733a +20000000 +496e6963 +69616c69 +7a6f7520 +6d657374 +72652067 +6c6f6261 +6c20636f +6d204944 +20000000 +4552524f +52207461 +736b2069 +64206e6f +7420616c +6c6f6361 +7465643a +20000000 +4170706c +69636174 +696f6e20 +77616974 +696e6720 +7265636c +75737465 +72696e67 +0a000000 +0a48616e +646c6520 +6170706c +69636174 +696f6e20 +72657175 +65737420 +66726f6d +20726570 +6f736974 +6f72790a +09417070 +6c696361 +74696f6e +20616464 +72657373 +3a200000 +09617070 +2069643a +20000000 +53494d55 +4c5f5052 +4f475245 +53532000 +250a0000 +46494e49 +53482000 +0a202d3e +20544153 +4b20414c +4c4f4341 +54454420 +66726f6d +20746173 +6b200000 +416c6c6f +63617465 +64207461 +736b733a +20000000 +4e657720 +7461736b +20726571 +75697369 +74696f6e +3a200000 +20616c6c +6f636174 +65642070 +726f6320 +00000000 +52656365 +69766564 +20746173 +6b206d69 +67726174 +6564202d +20746173 +6b206964 +3a200000 +206e6577 +2070726f +63200000 +4552524f +523a2073 +65727669 +63652075 +6e6b6e6f +776e2000 +54696d65 +3a200000 +48616e64 +6c65206e +65787420 +6170706c +69636174 +696f6e20 +0a000000 +54686973 +206b6572 +6e656c20 +69732067 +6c6f6261 +6c206d61 +73746572 +0a000000 +54686973 +206b6572 +6e656c20 +6973206c +6f63616c +206d6173 +7465720a +00000000 +4b65726e +656c2049 +6e697469 +616c697a +65640a00 +5761726e +696e6721 +203a3a20 +5461736b +206d6967 +72617469 +6f6e2066 +6f722074 +61736b20 +00000000 +20726566 +75736564 +2c206973 +206e6f74 +2072756e +6e696e67 +20617070 +20000000 +5461736b +206d6967 +72617469 +6f6e206f +72646572 +206f6620 +7461736b +20000000 +20746f20 +70726f63 +20000000 +4552524f +523a206e +6f206f6e +65206170 +70207761 +6974696e +67207265 +636c7573 +74657269 +6e670a00 +4552524f +523a2054 +61736b20 +6e6f7420 +666f756e +64200000 +4552524f +523a2041 +70706c69 +63617469 +6f6e7320 +6e6f7420 +666f756e +64200000 +73746172 +74696e67 +5f785f63 +6c757374 +65725f73 +697a653a +20000000 +73746172 +74696e67 +5f795f63 +6c757374 +65725f73 +697a653a +20000000 +5265636c +75737465 +72696e67 +20616361 +6361626f +7520636f +6d207375 +63657373 +6f2c2074 +61726566 +6120616c +6f636164 +61206e6f +2070726f +63200000 +20636f6d +20696420 +00000000 +5761726e +696e673a +20726563 +6c757374 +6572696e +67207265 +70656174 +6564210a +00000000 +4552524f +523a206e +65772074 +61736b20 +6f766572 +666c6f77 +0a000000 +4552524f +52202d20 +72657175 +65737420 +7461626c +65206966 +2066756c +6c0a0000 +57617269 +6e696e67 +3a205461 +736b206e +6f742066 +6f756e64 +20617420 +616e7920 +70726f63 +6573736f +72200000 +4552524f +523a2050 +726f6365 +73736f72 +206e6f74 +20666f75 +6e642000 +4552524f +523a2041 +6c6c2070 +61676573 +20667265 +6520666f +72207072 +6f630000 +4552524f +523a2054 +61736b20 +6e6f7420 +666f756e +6420746f +2072656d +6f766520 +00000000 +4552524f +523a2046 +72656520 +70616765 +73206973 +2030202d +206e6f74 +20616464 +20746173 +6b20656e +61626c65 +6420666f +72207072 +6f630000 +4552524f +523a2054 +61736b20 +616c7265 +61647920 +61646465 +64200000 +4552524f +523a204e +6f742066 +72656520 +736c6f74 +20696e74 +6f207072 +6f636573 +736f7220 +00000000 +5461736b +206d6170 +70696e67 +20666f72 +20746173 +6b200000 +206d6170 +65642061 +74207072 +6f632000 +5741524e +494e473a +206e6f20 +7265736f +75726365 +73206176 +61696c61 +626c6520 +696e2063 +6c757374 +65722074 +6f206d61 +70207461 +736b2000 +41707020 +68617665 +20616c6c +20697473 +20746173 +6b206d61 +70706564 +0a000000 +0000000c +00000003 +00000000 +00000000 +00000000 +00000000 +00000001 +00000001 +00000003 +00000002 +00000000 +00000002 +00000000 +00000003 +00000001 +00000003 +00000000 +00000002 +00000000 +00000002 +00000001 +00000003 +00000003 +00000002 +00000002 +00000002 +00000002 +00000003 +00000003 +00000003 diff --git a/build_env/bin/ram_simple b/build_env/bin/ram_simple new file mode 100755 index 0000000..30b238e --- /dev/null +++ b/build_env/bin/ram_simple @@ -0,0 +1,2 @@ +00000000 +00000000 diff --git a/build_env/bin/ram_simple.txt b/build_env/bin/ram_simple.txt new file mode 100755 index 0000000..30b238e --- /dev/null +++ b/build_env/bin/ram_simple.txt @@ -0,0 +1,2 @@ +00000000 +00000000 diff --git a/software/kernel/master/kernel_master.c b/software/kernel/master/kernel_master.c index d2af424..1b01060 100644 --- a/software/kernel/master/kernel_master.c +++ b/software/kernel/master/kernel_master.c @@ -742,153 +742,70 @@ void handle_app_request(){ } - -void send_dma_operation(int target){ - /* - int data_dma_operation[6]; - data_dma_operation[0]= 1; - data_dma_operation[1]= 2; - data_dma_operation[2]= 3; - data_dma_operation[3]= 4; - data_dma_operation[4]= 5; - data_dma_operation[5]= 6; - */ - - if(target == 0x00000101) { - //Trasmit - - #include "transmit.h" - - ServiceHeader *p = get_service_header_slot(); - p->header = 0x0101; - - p->service = DMA_OPERATION; - send_packet(p, transmit_code, sizeof(transmit_code)>>2); - //Se fosse inteiro era &nome da variavel e tamanho 1 - } - else { - // Receive - - #include "receive.h" - - ServiceHeader *p = get_service_header_slot(); - - p->header = 0x0001; - p->service = DMA_OPERATION; - //p->master_ID = cluster_master_address; - - send_packet(p, receive_code, sizeof(receive_code)>>2); - //Se fosse inteiro era &nome da variavel e tamanho 1 - } - - -} - - -void send_start_cpu(unsigned teste){ - - /* int data_start_cpu[6]; - data_start_cpu[0]= 10; - data_start_cpu[1]= 11; - data_start_cpu[2]= 12; - data_start_cpu[3]= 13; - data_start_cpu[4]= 14; - data_start_cpu[5]= 15; - */ - ServiceHeader *p = get_service_header_slot(); - - p->header = teste; - - p->service = START_CPU; - - p->period = 0x010; - - - - //p->master_ID = cluster_master_address; - - send_packet(p, 0, 1); //send_packet(ServiceHeader *p, unsigned int initial_address, unsigned int dmni_msg_size) - -} - - - - int main() { NewTask * pending_new_task; //By default HeMPS assumes that GM is positioned at address 0 - /* if ( MemoryRead(NI_CONFIG) == 0){ - - puts("This kernel is global master\n"); - - is_global_master = 1; + if ( MemoryRead(NI_CONFIG) == 0){ - global_master_address = net_address; + puts("This kernel is global master\n"); - initialize_clusters(); + is_global_master = 1; - initialize_slaves(); + global_master_address = net_address; - initialize_cluster_load(); + initialize_clusters(); - } else { + initialize_slaves(); - puts("This kernel is local master\n"); + initialize_cluster_load(); - is_global_master = 0; - } - - initialize_applications(); + } else { - init_new_task_list(); + puts("This kernel is local master\n"); - init_service_header_slots(); - */ + is_global_master = 0; + } - send_dma_operation(0x00000101);//envio um pacote com servico de acesso direto a DMNI - puts("Sent software to PE 1x1\n"); + initialize_applications(); - send_dma_operation(0x00000001);//envio um pacote com servico de acesso direto a DMNI - puts("Sent software to PE 0x1\n"); + init_new_task_list(); - send_start_cpu(0x00000001); - puts("Started PE 0x1\n"); + init_service_header_slots(); - send_start_cpu(0x00000101); - puts("Started PE 1x1\n"); + puts("Kernel Initialized\n"); - for (;;);/* { + for (;;) { - //LM looping - if (noc_interruption){ + //LM looping + if (noc_interruption){ - handle_packet(); + handle_packet(); - } else if (pending_app_to_map && is_reclustering_NOT_active()){ + } else if (pending_app_to_map && is_reclustering_NOT_active()){ - handle_pending_application(); + handle_pending_application(); - //GM looping - } else if (is_global_master && !MemoryRead(DMNI_SEND_ACTIVE)) { + //GM looping + } else if (is_global_master && !MemoryRead(DMNI_SEND_ACTIVE)) { - pending_new_task = get_next_new_task(); + pending_new_task = get_next_new_task(); - if (pending_new_task){ + if (pending_new_task){ - send_task_allocation(pending_new_task); + send_task_allocation(pending_new_task); - pending_new_task->task_ID = -1; + pending_new_task->task_ID = -1; - } else if (app_req_reg) { + } else if (app_req_reg) { - handle_app_request(); - } - } - }*/ + handle_app_request(); + } + } + } return 0; } diff --git a/software/kernel/master/receive.h b/software/kernel/master/receive.h deleted file mode 100644 index 639c0ad..0000000 --- a/software/kernel/master/receive.h +++ /dev/null @@ -1,271 +0,0 @@ -const unsigned int receive_code[] = { - 0x241d7fff, - 0x3c1f0000, - 0x27ff0014, - 0x080000ed, - 0x00000000, - 0x3c102000, - 0x3c110000, - 0x26310058, - 0x8e080140, - 0x8e090144, - 0xae280003, - 0x34080004, - 0xae290000, - 0xae080200, - 0xae110210, - 0x34080001, - 0xae000220, - 0xae080230, - 0x3c08dead, - 0x3508beaf, - 0x08000014, - 0xae080320, - 0x00000000, - 0x00000002, - 0x00000070, - 0x00000000, - 0x0000000c, - 0x00000000, - 0x03e00008, - 0x00000000, - 0x8c820000, - 0x3c032000, - 0xac620000, - 0x00802821, - 0x80840000, - 0x00000000, - 0x10800022, - 0x00000000, - 0x80a20001, - 0x00000000, - 0x1040001e, - 0x00000000, - 0x80a20002, - 0x00000000, - 0x1040001a, - 0x00000000, - 0x80a20003, - 0x00000000, - 0x10400016, - 0x3c042000, - 0x08000040, - 0x24a50004, - 0x80a20001, - 0x00000000, - 0x10400010, - 0x00000000, - 0x80a20002, - 0x00000000, - 0x1040000c, - 0x00000000, - 0x80a20003, - 0x00000000, - 0x10400008, - 0x24a50004, - 0x8ca20000, - 0x00000000, - 0xac820000, - 0x80a30000, - 0x00000000, - 0x1460ffee, - 0x00000000, - 0x03e00008, - 0x00001021, - 0x14800009, - 0x00802821, - 0x3c020000, - 0x24440450, - 0x00802821, - 0x24030030, - 0xa0430450, - 0x00a01021, - 0x03e00008, - 0xa0800001, - 0x3c03cccc, - 0x3463cccd, - 0x00830019, - 0x3c020000, - 0x24460451, - 0x3c080000, - 0x24070001, - 0x00001810, - 0x000318c2, - 0x00031040, - 0x000320c0, - 0x00441021, - 0x00a21023, - 0x24420030, - 0x00602821, - 0x10a00013, - 0xa1020450, - 0x3c03cccc, - 0x3463cccd, - 0x00a30019, - 0x24e70001, - 0x00001810, - 0x000320c2, - 0x00041040, - 0x000418c0, - 0x00431021, - 0x00a21023, - 0x24420030, - 0xa0c20000, - 0x2402000b, - 0x10e2000d, - 0x24c60001, - 0x00802821, - 0x14a0fff0, - 0x3c03cccc, - 0x3c040000, - 0x24820444, - 0x00e21021, - 0x24e3ffff, - 0x04610008, - 0xa0400000, - 0x24850444, - 0x03e00008, - 0x00a01021, - 0x3c040000, - 0x24820444, - 0x2403000a, - 0xa040000b, - 0x24820444, - 0x00621821, - 0x3c020000, - 0x25050450, - 0x24460443, - 0x90a20000, - 0x00000000, - 0xa0620000, - 0x2463ffff, - 0x1466fffb, - 0x24a50001, - 0x0800007d, - 0x24850444, - 0x3c080000, - 0x25030438, - 0x24050030, - 0x24020078, - 0xa0620001, - 0xa060000a, - 0x1480000b, - 0xa1050438, - 0xa0650009, - 0xa0650002, - 0xa0650003, - 0xa0650004, - 0xa0650005, - 0xa0650006, - 0xa0650007, - 0xa0650008, - 0x03e00008, - 0x25020438, - 0x3c020000, - 0x3c030000, - 0x24470441, - 0x080000ab, - 0x24630439, - 0xa0e60000, - 0x24e7ffff, - 0x10e3fff6, - 0x00042102, - 0x3082000f, - 0x24460030, - 0x24450057, - 0x2c42000a, - 0x1440fff7, - 0x00000000, - 0x080000a8, - 0xa0e50000, - 0x3c082000, - 0x27bdfff0, - 0x35030250, - 0x8c620000, - 0x00000000, - 0x1440fffd, - 0x35020200, - 0x35040210, - 0x24030003, - 0xac430000, - 0xac9d0000, - 0x10e0000e, - 0x3c020000, - 0x35020205, - 0xac470000, - 0x35030215, - 0x3c022000, - 0xac660000, - 0x34440230, - 0x24030001, - 0x34420220, - 0x27bd0010, - 0xac400000, - 0xac830000, - 0x03e00008, - 0x00000000, - 0x35040205, - 0x24030001, - 0x24420434, - 0x35050215, - 0xac830000, - 0xaca20000, - 0x3c022000, - 0x34440230, - 0x24030001, - 0x34420220, - 0x27bd0010, - 0xac400000, - 0xac830000, - 0x03e00008, - 0x00000000, - 0x24820003, - 0x3c032000, - 0x2404fffc, - 0x00441024, - 0x34630264, - 0xac620000, - 0x03e00008, - 0x00000000, - 0x3c022000, - 0x34430264, - 0x8c620000, - 0x00000000, - 0x30420001, - 0x1040fffc, - 0x00000000, - 0x03e00008, - 0x00000000, - 0x27bdffd8, - 0xafb3001c, - 0xafb20018, - 0xafb10014, - 0xafbf0020, - 0xafb00010, - 0x3c130000, - 0x3c120000, - 0x3c110000, - 0x0c0000dc, - 0x2664045c, - 0x2644040c, - 0x0c00001e, - 0x00408021, - 0x0c0000e4, - 0x00000000, - 0x0c00001e, - 0x26240424, - 0x0c00001e, - 0x02002021, - 0x080000f6, - 0x00000000, - 0x50726570, - 0x61726564, - 0x20746f20, - 0x72656365, - 0x6976650a, - 0x00000000, - 0x44617461, - 0x20526563, - 0x65697665, - 0x640a0000, - 0x00000000}; diff --git a/software/kernel/master/transmit.h b/software/kernel/master/transmit.h deleted file mode 100644 index 27c64bb..0000000 --- a/software/kernel/master/transmit.h +++ /dev/null @@ -1,255 +0,0 @@ -const unsigned int transmit_code[] = { - 0x241d7fff, - 0x3c1f0000, - 0x27ff0014, - 0x080000e6, - 0x00000000, - 0x3c102000, - 0x3c110000, - 0x26310058, - 0x8e080140, - 0x8e090144, - 0xae280003, - 0x34080004, - 0xae290000, - 0xae080200, - 0xae110210, - 0x34080001, - 0xae000220, - 0xae080230, - 0x3c08dead, - 0x3508beaf, - 0x08000014, - 0xae080320, - 0x00000000, - 0x00000002, - 0x00000070, - 0x00000000, - 0x0000000c, - 0x00000000, - 0x03e00008, - 0x00000000, - 0x8c820000, - 0x3c032000, - 0xac620000, - 0x00802821, - 0x80840000, - 0x00000000, - 0x10800022, - 0x00000000, - 0x80a20001, - 0x00000000, - 0x1040001e, - 0x00000000, - 0x80a20002, - 0x00000000, - 0x1040001a, - 0x00000000, - 0x80a20003, - 0x00000000, - 0x10400016, - 0x3c042000, - 0x08000040, - 0x24a50004, - 0x80a20001, - 0x00000000, - 0x10400010, - 0x00000000, - 0x80a20002, - 0x00000000, - 0x1040000c, - 0x00000000, - 0x80a20003, - 0x00000000, - 0x10400008, - 0x24a50004, - 0x8ca20000, - 0x00000000, - 0xac820000, - 0x80a30000, - 0x00000000, - 0x1460ffee, - 0x00000000, - 0x03e00008, - 0x00001021, - 0x14800009, - 0x00802821, - 0x3c020000, - 0x2444041c, - 0x00802821, - 0x24030030, - 0xa043041c, - 0x00a01021, - 0x03e00008, - 0xa0800001, - 0x3c03cccc, - 0x3463cccd, - 0x00830019, - 0x3c020000, - 0x2446041d, - 0x3c080000, - 0x24070001, - 0x00001810, - 0x000318c2, - 0x00031040, - 0x000320c0, - 0x00441021, - 0x00a21023, - 0x24420030, - 0x00602821, - 0x10a00013, - 0xa102041c, - 0x3c03cccc, - 0x3463cccd, - 0x00a30019, - 0x24e70001, - 0x00001810, - 0x000320c2, - 0x00041040, - 0x000418c0, - 0x00431021, - 0x00a21023, - 0x24420030, - 0xa0c20000, - 0x2402000b, - 0x10e2000d, - 0x24c60001, - 0x00802821, - 0x14a0fff0, - 0x3c03cccc, - 0x3c040000, - 0x24820410, - 0x00e21021, - 0x24e3ffff, - 0x04610008, - 0xa0400000, - 0x24850410, - 0x03e00008, - 0x00a01021, - 0x3c040000, - 0x24820410, - 0x2403000a, - 0xa040000b, - 0x24820410, - 0x00621821, - 0x3c020000, - 0x2505041c, - 0x2446040f, - 0x90a20000, - 0x00000000, - 0xa0620000, - 0x2463ffff, - 0x1466fffb, - 0x24a50001, - 0x0800007d, - 0x24850410, - 0x3c080000, - 0x25030404, - 0x24050030, - 0x24020078, - 0xa0620001, - 0xa060000a, - 0x1480000b, - 0xa1050404, - 0xa0650009, - 0xa0650002, - 0xa0650003, - 0xa0650004, - 0xa0650005, - 0xa0650006, - 0xa0650007, - 0xa0650008, - 0x03e00008, - 0x25020404, - 0x3c020000, - 0x3c030000, - 0x2447040d, - 0x080000ab, - 0x24630405, - 0xa0e60000, - 0x24e7ffff, - 0x10e3fff6, - 0x00042102, - 0x3082000f, - 0x24460030, - 0x24450057, - 0x2c42000a, - 0x1440fff7, - 0x00000000, - 0x080000a8, - 0xa0e50000, - 0x3c020000, - 0x00e04821, - 0xac4403f8, - 0x00a05821, - 0x10e0001c, - 0x00c05021, - 0x3c032000, - 0x244403f8, - 0x34670215, - 0x34650200, - 0x34660210, - 0x25280001, - 0x34630205, - 0x24020003, - 0xaca20000, - 0xacc40000, - 0xac690000, - 0xacea0000, - 0xac880004, - 0xac8b0008, - 0x3c032000, - 0x34640220, - 0x34650230, - 0x24020001, - 0xac800000, - 0x34630250, - 0xaca20000, - 0x8c620000, - 0x00000000, - 0x1440fffd, - 0x00000000, - 0x03e00008, - 0x00000000, - 0x3c042000, - 0x244503f8, - 0x34830200, - 0x24020003, - 0xac620000, - 0x34870215, - 0x34860210, - 0x24030001, - 0x34840205, - 0x3c020000, - 0xacc50000, - 0x244203f4, - 0xac830000, - 0x24030002, - 0xace20000, - 0xaca30004, - 0x080000c7, - 0xacab0008, - 0x27bdffd8, - 0x3c030000, - 0x246203e4, - 0xafbf0020, - 0x8c6803e4, - 0x944a000c, - 0x8c490004, - 0x8c430008, - 0x24040001, - 0x24050290, - 0x27a60010, - 0x24070004, - 0xafa80010, - 0xafa90014, - 0xafa30018, - 0x0c0000b3, - 0xa7aa001c, - 0x080000f7, - 0x00000000, - 0x48656c6c, - 0x6f20576f, - 0x726c6421, - 0x0a000000, - 0x00000000}; From ddc62d9d57660d44d05268e81e24d03e5cf2c55b Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Sat, 28 Oct 2017 19:10:37 -0200 Subject: [PATCH 28/54] Fixed boot_task.asm compilation --- applications/receive/receive.c | 203 +++++++++++++++------------------ build_env/makes/make_app | 6 +- software/boot_task/boot_task.s | 75 ++++++------ testcases/integ.yaml | 19 +++ 4 files changed, 148 insertions(+), 155 deletions(-) create mode 100644 testcases/integ.yaml diff --git a/applications/receive/receive.c b/applications/receive/receive.c index 9d58b22..a7954e8 100644 --- a/applications/receive/receive.c +++ b/applications/receive/receive.c @@ -1,5 +1,3 @@ - - #define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) #define MemoryRead(A) (*(volatile unsigned int*)(A)) @@ -11,15 +9,17 @@ #define NI_CONFIG 0x20000140 /* DMNI*/ -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 +#define UART_WRITE 0x20000000 +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 #define DMNI_SEND_ACTIVE 0x20000250 #define DMNI_RECEIVE_ACTIVE 0x20000260 +#define DMNI_RECEIVE_BUFFER 0x20000264 /* Manual Routing destination ports */ #define MANUAL_EAST 0x80000000 @@ -30,35 +30,26 @@ #define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) -#define UART_WRITE 0x20000000 -#define TESTE 0x20000008 +#define TESTE 0x20000008 +#define MESSAGE_DELIVERY 0x00000020 +#define DMA_OPERATION 0x290 +#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header typedef struct { unsigned int header; unsigned int payload_size; - unsigned int service; - unsigned int source; - unsigned int target; - unsigned int pkt_size; -} ServiceHeader; - - - - + unsigned int service; +} MacHeader; int puts(char *string) { - int *str_part; //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines //PS: This indicates a hardware developer putting its hands on software development - for( - str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); - - !( ( (char*)str_part )[0] == 0 || ( (char*)str_part )[1] == 0 || ( (char*)str_part )[2] == 0 || ( (char*)str_part )[3] == 0); - - *str_part++,MemoryWrite(UART_WRITE, *str_part) - ); + //PS2: The original author need to review demorgans law for boolean simplification + for(str_part = (int*)string, MemoryWrite(UART_WRITE, *str_part); + ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; + MemoryWrite(UART_WRITE, *(++str_part))); return 0; } @@ -68,45 +59,45 @@ int puts(char *string) { */ char *itoa(unsigned int num) { - static char buf[12]; - static char buf2[12]; - int i,j; + static char buf[12]; + static char buf2[12]; + int i,j; - if (num==0) - { + if (num==0) + { buf[0] = '0'; buf[1] = '\0'; return &buf[0]; - } + } - for(i=0;i<11 && num!=0;i++) - { + for(i=0;i<11 && num!=0;i++) + { buf[i]=(char)((num%10)+'0'); num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; } char *itoh(unsigned int num) { - static char buf[11]; - int i; - buf[10]=0; + static char buf[11]; + int i; + buf[10]=0; - buf[0] = '0'; - buf[1] = 'x'; + buf[0] = '0'; + buf[1] = 'x'; - if (num==0) - { + if (num==0) + { buf[2] = '0'; buf[3] = '0'; buf[4] = '0'; @@ -116,91 +107,75 @@ char *itoh(unsigned int num) buf[8] = '0'; buf[9] = '0'; return buf; - } + } - for(i=9;i>=2;--i) - { + for(i=9;i>=2;--i) + { if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); + buf[i]=(char)((num%16)+'0'); else - buf[i]=(char)((num%16)+'W'); + buf[i]=(char)((num%16)+'W'); num/=16; - } + } - return buf; + return buf; } +void transmite(unsigned int target, unsigned int service, + unsigned int *msg, unsigned int lenght) { + static const unsigned int ZERO = 0; + + MacHeader p; + p.header = target; + p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc + p.service = service; + while (MemoryRead(DMNI_SEND_ACTIVE)); + MemoryWrite(DMNI_SIZE, 3); + MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header -void read_packet(ServiceHeader *p){ - - MemoryWrite(DMNI_SIZE, 6); - MemoryWrite(DMNI_OP, WRITE); - MemoryWrite(DMNI_ADDRESS, (unsigned int) p); - MemoryWrite(DMNI_START, 1); - //Waits the DMNI copy all data to memory before release the software to access it - while (MemoryRead(DMNI_RECEIVE_ACTIVE)); - + if(lenght) { + MemoryWrite(DMNI_SIZE_2, lenght); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); + } else { + MemoryWrite(DMNI_SIZE_2, 1); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); + } + + MemoryWrite(DMNI_OP, READ); + MemoryWrite(DMNI_START, 1); } +volatile void *prepare_receive(volatile void *buff) { + buff = (void*)((((unsigned int)buff)+3) & -4); + MemoryWrite(DMNI_RECEIVE_BUFFER, (unsigned int)buff); + return buff; +} +void wait_receive(){ + while(!(MemoryRead(DMNI_RECEIVE_BUFFER) & 1)); +} +volatile unsigned int glob_buff[256]; +int main() { + volatile char *buff; -int main() -{ - - int anderson[2]; - anderson[0] = 14; - anderson[1] = 20; - - volatile ServiceHeader p; - - read_packet((ServiceHeader *)&p); - puts("$$$ "); - puts(itoa((unsigned int)p.header)); - puts("\n"); - puts(itoh((unsigned int)p.service)); - puts("\n"); - - transmite(0x00000001 ,0x00000290, anderson ,2); - - - //transmite(0x00000100 ,0x00000290, data_dma_code ,102); - //transmite(0x00000000 ,0x00000290, data_dma_code ,102); - //transmite(0x00000101 ,0x00000290, data_dma_code,102); - // - - while(1) - { - int i; - - for(i=0; i<100; i++) - { - MemoryWrite(TESTE, i); //Grava o valor de no endereco da memoria (definida como teste) - *(volatile unsigned int *)(TESTE) = i; - - puts("$$$ "); - puts(itoa(i)); - puts(itoa(&i)); - puts("\n"); - } - - - - } - - + buff=prepare_receive(glob_buff); + puts("Prepared to receive\n"); + wait_receive(); + puts("Data Received\n"); + puts((char*)buff); + return 0; } /* - USO: int message[30] transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) -*/ \ No newline at end of file +*/ diff --git a/build_env/makes/make_app b/build_env/makes/make_app index 7df5f2e..270896c 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -11,7 +11,7 @@ DUMP_MIPS = mips-elf-objdump COPY_MIPS = mips-elf-objcopy -I elf32-bigmips -O binary BOOT_TASK = boot_task -BOOT_TASK_SRC = ../../software/boot_task/boot_task.asm +BOOT_TASK_SRC = ../../software/boot_task/boot_task.s TASK_SRC = $(wildcard *.c) TASK_OBJ = $(TASK_SRC:.c=.o) @@ -19,8 +19,8 @@ TASK_OBJ = $(TASK_SRC:.c=.o) default: $(BOOT_TASK).o $(TASK_OBJ) boot_task.o: $(BOOT_TASK_SRC) - @printf "${GREEN}Compiling boot task: %s ...${NC}\n" "$*.c" - $(AS_MIPS) --defsym sp_addr=$(PAGE_SP_INIT) -o $@ $^ + @printf "${GREEN}Compiling boot task: %s ...${NC}\n" "$*.S" + $(AS_MIPS) -mips1 --defsym sp_addr=$(PAGE_SP_INIT) -o $@ $^ #[$*] - only the filename - #https://www.gnu.org/software/make/manual/make.html#Automatic-Variables $(TASK_OBJ): $(TASK_SRC) diff --git a/software/boot_task/boot_task.s b/software/boot_task/boot_task.s index cdafd52..b30be99 100644 --- a/software/boot_task/boot_task.s +++ b/software/boot_task/boot_task.s @@ -1,12 +1,12 @@ -## HEMPS VERSION - 8.0 - support for RT applications -## -## Distribution: June 2016 -## -## Created by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br -## -## Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br -## -## Brief description: Initializes the stack pointer and jumps to main(). Handles the syscall. +# HEMPS VERSION - 8.0 - support for RT applications +# +# Distribution: June 2016 +# +# Created by: Marcelo Ruaro - contact: marcelo.ruaro@acad.pucrs.br +# +# Research group: GAPH-PUCRS - contact: fernando.moraes@pucrs.br +# +# Brief description: Initializes the stack pointer and jumps to main(). Handles the syscall. @@ -17,53 +17,52 @@ entry: .set noreorder - li $sp,sp_addr ; new initialization + la $sp,sp_addr # new initialization jal main nop - beq $zero, $zero, exit - or $a0, $v0, $zero + beq $0, $0, exit + or $4, $2, $0 .end entry .globl exit .ent exit .set noreorder exit: - lui $s0, 0x2000 ; $s0 = *HARDWARE_REGISTERS - la $s1, .RET_MSG ; $s1 = *RET_MSG + lui $16, 0x2000 # $16 = *HARDWARE_REGISTERS + la $17, .RET_MSG # $17 = *RET_MSG - ;; assemble the package - lw $t0, 320($s0) ; $t0 = NET_ADDRESS - lw $t1, 324($s0) ; $t1 = LOADER_NETADDR - sw $t0, 12($s1) ; RET_MSG.SOURCE = $t0 - sw $t1, 0($s1) ; RET_MSG.TARGET = $t1 - ori $t0, $zero, 5 ; $t0 = 5 (DMNI_SIZE) - sw $a0, 0($s1) ; RET_MSG.RETURN_CODE = $a0 + # assemble the package + lw $8, 320($16) # $8 = NET_ADDRESS + lw $9, 324($16) # $9 = LOADER_NETADDR + sw $8, 12($17) # RET_MSG.SOURCE = $8 + sw $9, 0($17) # RET_MSG.TARGET = $9 + ori $8, $0, 5 # $8 = 5 (DMNI_SIZE) + sw $4, 0($17) # RET_MSG.RETURN_CODE = $4 - ;; send it - sw $t0, 512($s0) ; *DMNI_SIZE = $t0 - sw $s1, 528($s0) ; *DMNI_ADDR = $s1 - ori $t0, $zero, 1 ; $t0 = 1 - sw $zero, 544($s0) ; READ -> DMNI_OP - sw $t0, 560($s0) ; 1 -> DMNI_START + # send it + sw $8, 512($16) # *DMNI_SIZE = $8 + sw $17, 528($16) # *DMNI_ADDR = $17 + ori $8, $0, 1 # $8 = 1 + sw $0, 544($16) # READ -> DMNI_OP + sw $8, 560($16) # 1 -> DMNI_START - ;; commit suicide - li $t0, 0xDEADBEAF ; MAGIC WORD TO KILL CPU + # commit suicide + li $8, 0xDEADBEAF # MAGIC WORD TO KILL CPU .L1: - beq $zero, $zero, .L1 - sw $t0, 800($s0) ; SET_CPU_KILL + beq $0, $0, .L1 + sw $8, 800($16) # SET_CPU_KILL .end exit -; memory region reserved to assemble termination pkg +# memory region reserved to assemble termination pkg .RET_MSG: - .word 0 ; TARGET - .word 2 ; SIZE - .word 0x70 ; SERVICE - .word 0 ; SOURCE - .word 0 ; RETURN_CODE + .word 0 # TARGET + .word 2 # SIZE + .word 0x70 # SERVICE + .word 0 # SOURCE + .word 0 # RETURN_CODE -################################################### .globl SystemCall .ent SystemCall diff --git a/testcases/integ.yaml b/testcases/integ.yaml new file mode 100644 index 0000000..7afadc3 --- /dev/null +++ b/testcases/integ.yaml @@ -0,0 +1,19 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: vhdl + noc_buffer_size: 8 + mpsoc_dimension: [2,2] + cluster_dimension: [2,2] + master_location: LB + simple_soc: true + open_port: + - port: [0,0,S] +apps: + - name: transmit + start_time_ms: 1 + location: [1,1] + - name: receive + start_time_ms: 0 + location: [0,1] From 110a11c2c6b12994fcbf88d90f3221a154eb9694 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Tue, 31 Oct 2017 12:40:41 -0200 Subject: [PATCH 29/54] Melhorias no Testbench --- hardware/vhdl/test_bench.vhd | 101 +++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/hardware/vhdl/test_bench.vhd b/hardware/vhdl/test_bench.vhd index c1ac90a..448a8dd 100644 --- a/hardware/vhdl/test_bench.vhd +++ b/hardware/vhdl/test_bench.vhd @@ -24,7 +24,7 @@ use work.standards.all; entity test_bench is type config is record - code_name : string(1 to 34); + code_name : string(1 to 40); position : std_logic_vector(31 downto 0); code_size : std_logic_vector(31 downto 0); end record; @@ -37,7 +37,7 @@ entity test_bench is constant router_description : string := "RTL"; constant REPO_SIZE : integer := (TOTAL_REPO_SIZE_BYTES/4); --This math is because each repoline is 32 bits word - constant TAM_PACKSTART : integer := 13; + constant TAM_PACKSTART : integer := 4; type repo_type is array(REPO_SIZE-1 downto 0) of std_logic_vector(31 downto 0); @@ -68,14 +68,17 @@ entity test_bench is file file_ptr : text open read_mode is cfg_file; variable inline : line; - variable strline : string(1 to 34); + variable strline : string(1 to 40); variable cfg : list_of_apps; + variable str_len : integer; begin for i in 0 to APP_NUMBER-1 loop readline(file_ptr, inline); + str_len := inline'length; read(inline, strline(1 to inline'length)); - cfg(i).code_name := strline; + cfg(i).code_name(1 to str_len) := strline(1 to str_len); + cfg(i).code_name(str_len+1 to 40) := (others => NUL); readline(file_ptr, inline); hread(inline, cfg(i).position); readline(file_ptr, inline); @@ -117,21 +120,14 @@ architecture test_bench of test_bench is signal packstart_data : packstart_type; signal app_code : repo_type; + type send_state is (WAIT_state, SEND_APP, SEND_START); + signal SEND: send_state; + begin - --packstart_data(12) <= x"00000101"; - packstart_data(11) <= x"0000000B"; - packstart_data(10) <= x"00000300"; - packstart_data(9) <= x"00000000"; - packstart_data(8) <= x"00000000"; - packstart_data(7) <= x"00000000"; - packstart_data(6) <= x"00000000"; - packstart_data(5) <= x"00000000"; - packstart_data(4) <= x"00000000"; - packstart_data(3) <= x"00000000"; + packstart_data(0) <= x"00000002"; + packstart_data(1) <= x"00000300"; packstart_data(2) <= x"00000000"; - packstart_data(1) <= x"00000000"; - packstart_data(0) <= x"00000000"; -- -- HeMPS instantiation @@ -207,43 +203,54 @@ begin flit_counter <= 0; packstart_counter <= 0; file_counter <= 0; + SEND <= WAIT_state; elsif rising_edge(clock) then - if credit_o_io(0) = '1' then - if flit_counter > 0 then - rx_io(0) <= '1'; - rd_addr <= rd_addr + 1; - if rd_addr = 0 then - data_in_io(0) <= app_cfg(file_counter).position; - elsif rd_addr = 1 then - data_in_io(0) <= app_cfg(file_counter).code_size; - file_counter <= file_counter + 1; - elsif rd_addr = 2 then - data_in_io(0) <= x"00000290"; - else - data_in_io(0) <= app_code(CONV_INTEGER(rd_addr-3)); - flit_counter <= flit_counter - 1; + case SEND is + when WAIT_state => + if file_counter < APP_NUMBER then + flit_counter <= CONV_INTEGER(app_cfg(file_counter).code_size); + app_code <= load_repo(app_cfg(file_counter).code_name); + rd_addr <= (others => '0'); + SEND <= SEND_APP; end if; - else - if(file_counter > 0 and packstart_counter > 0) then - rx_io(0) <= '1'; - packstart_counter <= packstart_counter - 1; - data_in_io(0) <= packstart_data(packstart_counter-1); - else + + when SEND_APP => + if credit_o_io(0) = '1' and flit_counter > 0 then + rx_io(0) <= '1'; + rd_addr <= rd_addr + 1; + if rd_addr = 0 then + data_in_io(0) <= app_cfg(file_counter).position; + elsif rd_addr = 1 then + data_in_io(0) <= app_cfg(file_counter).code_size + 1; + elsif rd_addr = 2 then + data_in_io(0) <= x"00000290"; + else + data_in_io(0) <= app_code(CONV_INTEGER(rd_addr-3)); + flit_counter <= flit_counter - 1; + end if; + elsif flit_counter = 0 then + SEND <= SEND_START; + rd_addr <= (others => '0'); rx_io(0) <= '0'; - rd_addr <= (others => '0'); - if file_counter < APP_NUMBER then - app_code <= load_repo(app_cfg(file_counter).code_name); - flit_counter <= CONV_INTEGER(app_cfg(file_counter).code_size); - packstart_counter <= TAM_PACKSTART; - packstart_data(TAM_PACKSTART-1) <= app_cfg(file_counter).position; + end if; + + when SEND_START => + if credit_o_io(0) = '1' and rd_addr < TAM_PACKSTART then + rx_io(0) <= '1'; + rd_addr <= rd_addr + 1; + if rd_addr = 0 then + data_in_io(0) <= app_cfg(file_counter).position; + else + data_in_io(0) <= packstart_data(CONV_INTEGER(rd_addr-1)); end if; + else + file_counter <= file_counter + 1; + rx_io(0) <= '0'; + SEND <= WAIT_state; end if; - end if; - end if; + + end case; end if; end process; end test_bench; - - - From 6222e8f6a2e675e5e3c3788700c70d4e91066584 Mon Sep 17 00:00:00 2001 From: acsantana Date: Wed, 1 Nov 2017 15:29:51 -0200 Subject: [PATCH 30/54] Validated --- software/boot_task/boot_task.s | 10 ++++++---- testcases/integ.yaml | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/software/boot_task/boot_task.s b/software/boot_task/boot_task.s index b30be99..a11b112 100644 --- a/software/boot_task/boot_task.s +++ b/software/boot_task/boot_task.s @@ -29,6 +29,7 @@ entry: .globl exit .ent exit .set noreorder + exit: lui $16, 0x2000 # $16 = *HARDWARE_REGISTERS la $17, .RET_MSG # $17 = *RET_MSG @@ -38,8 +39,8 @@ exit: lw $9, 324($16) # $9 = LOADER_NETADDR sw $8, 12($17) # RET_MSG.SOURCE = $8 sw $9, 0($17) # RET_MSG.TARGET = $9 - ori $8, $0, 5 # $8 = 5 (DMNI_SIZE) - sw $4, 0($17) # RET_MSG.RETURN_CODE = $4 + ori $8, $0, 5 # $8 = 5 (DMNI_SIZE) + sw $4, 16($17) # RET_MSG.RETURN_CODE = $4 # send it sw $8, 512($16) # *DMNI_SIZE = $8 @@ -49,7 +50,7 @@ exit: sw $8, 560($16) # 1 -> DMNI_START # commit suicide - li $8, 0xDEADBEAF # MAGIC WORD TO KILL CPU + li $8, 0xDEADBEEF # MAGIC WORD TO KILL CPU .L1: beq $0, $0, .L1 sw $8, 800($16) # SET_CPU_KILL @@ -58,7 +59,7 @@ exit: # memory region reserved to assemble termination pkg .RET_MSG: .word 0 # TARGET - .word 2 # SIZE + .word 3 # SIZE .word 0x70 # SERVICE .word 0 # SOURCE .word 0 # RETURN_CODE @@ -66,6 +67,7 @@ exit: .globl SystemCall .ent SystemCall + SystemCall: .set noreorder diff --git a/testcases/integ.yaml b/testcases/integ.yaml index 7afadc3..cfc4a27 100644 --- a/testcases/integ.yaml +++ b/testcases/integ.yaml @@ -11,9 +11,9 @@ hw: open_port: - port: [0,0,S] apps: - - name: transmit - start_time_ms: 1 - location: [1,1] - name: receive start_time_ms: 0 location: [0,1] + - name: transmit + start_time_ms: 0 + location: [1,1] From 0c555c3563e322fc39fdf3cb97d44bbbccc70c1a Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Wed, 1 Nov 2017 16:39:17 -0200 Subject: [PATCH 31/54] LOADER_NETADDR gerado automaticamente --- build_env/scripts/hw_builder.py | 15 ++++++++++++++- hardware/vhdl/standards.vhd | 3 --- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/build_env/scripts/hw_builder.py b/build_env/scripts/hw_builder.py index aef014b..9a9ee01 100644 --- a/build_env/scripts/hw_builder.py +++ b/build_env/scripts/hw_builder.py @@ -163,6 +163,18 @@ def generate_to_vhdl(is_master_list, yaml_r): if port[2] == "W": open_ports_vector[index] = "wes" + if open_ports[0][2] == "N": + loader_addr = 0xC0000000 + if open_ports[0][2] == "S": + loader_addr = 0xE0000000 + if open_ports[0][2] == "E": + loader_addr = 0x80000000 + if open_ports[0][2] == "W": + loader_addr = 0xA0000000 + + loader_addr = loader_addr + (open_ports[0][1] << 8) + open_ports[0][1] + + open_ports_string = "" for i in range(0,x_mpsoc_dim*y_mpsoc_dim): open_ports_string = open_ports_string + "\"" + open_ports_vector[i] + "\"," @@ -189,7 +201,8 @@ def generate_to_vhdl(is_master_list, yaml_r): file_lines.append(" constant TAM_BUFFER : integer := "+str(noc_buffer_size)+";\n") file_lines.append(" constant NUMBER_PROCESSORS : integer := "+str(x_mpsoc_dim*y_mpsoc_dim)+";\n") file_lines.append(" constant SIMPLE_SOC : boolean := "+str(simple_soc)+";\n") - file_lines.append(" constant IO_NUMBER : integer := "+str(io_number)+";\n\n") + file_lines.append(" constant IO_NUMBER : integer := "+str(io_number)+";\n") + file_lines.append(" constant LOADER_NETADDR : std_logic_vector(31 downto 0) := x\"%x\";\n\n" % loader_addr) file_lines.append(" subtype kernel_str is string(1 to 3);\n") file_lines.append(" type pe_type_t is array(0 to NUMBER_PROCESSORS-1) of kernel_str;\n") file_lines.append(" constant pe_type : pe_type_t := ("+string_pe_type_vhdl+");\n\n") diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index 001f754..0f0f020 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -20,9 +20,6 @@ use work.hemps_pkg.all; package standards is - -- at this moment assume the loader is fixed at router 0 south port - constant LOADER_NETADDR : std_logic_vector(31 downto 0) := x"E0000000"; - -------------------------------------------------------- -- CONSTANTS -------------------------------------------------------- From 705f61221ebc852e0c57ebff31650260fdf1776a Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Mon, 6 Nov 2017 17:35:03 -0200 Subject: [PATCH 32/54] =?UTF-8?q?Mudan=C3=A7as=20na=20estrutura=20do=20.ya?= =?UTF-8?q?ml=20para=20suporte=20a=20tasks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/pc_test/receive.c | 181 ++++++++++++++++++++++++++++ applications/pc_test/transmit.c | 160 ++++++++++++++++++++++++ build_env/scripts/app_builder.py | 57 +++++++-- build_env/scripts/hw_builder.py | 12 ++ build_env/scripts/kernel_builder.py | 15 +-- build_env/scripts/yaml_intf.py | 5 + hardware/vhdl/test_bench.vhd | 90 +++++++++++--- testcases/integ.yaml | 12 +- 8 files changed, 490 insertions(+), 42 deletions(-) create mode 100644 applications/pc_test/receive.c create mode 100644 applications/pc_test/transmit.c diff --git a/applications/pc_test/receive.c b/applications/pc_test/receive.c new file mode 100644 index 0000000..a7954e8 --- /dev/null +++ b/applications/pc_test/receive.c @@ -0,0 +1,181 @@ +#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) +#define MemoryRead(A) (*(volatile unsigned int*)(A)) + +/* DMNI operations */ +#define READ 0 +#define WRITE 1 + + +#define NI_CONFIG 0x20000140 + +/* DMNI*/ +#define UART_WRITE 0x20000000 +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 +#define DMNI_RECEIVE_BUFFER 0x20000264 + +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) + + +#define TESTE 0x20000008 +#define MESSAGE_DELIVERY 0x00000020 +#define DMA_OPERATION 0x290 +#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header + +typedef struct { + unsigned int header; + unsigned int payload_size; + unsigned int service; +} MacHeader; + + +int puts(char *string) { + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + //PS2: The original author need to review demorgans law for boolean simplification + for(str_part = (int*)string, MemoryWrite(UART_WRITE, *str_part); + ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; + MemoryWrite(UART_WRITE, *(++str_part))); + return 0; +} + +/**Converts a integer number to its decimal representation in a array of char + * \param num Integer number to be converted + * \return Array of chars + */ +char *itoa(unsigned int num) +{ + static char buf[12]; + static char buf2[12]; + int i,j; + + if (num==0) + { + buf[0] = '0'; + buf[1] = '\0'; + return &buf[0]; + } + + for(i=0;i<11 && num!=0;i++) + { + buf[i]=(char)((num%10)+'0'); + num/=10; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; +} + + + +char *itoh(unsigned int num) +{ + static char buf[11]; + int i; + buf[10]=0; + + buf[0] = '0'; + buf[1] = 'x'; + + if (num==0) + { + buf[2] = '0'; + buf[3] = '0'; + buf[4] = '0'; + buf[5] = '0'; + buf[6] = '0'; + buf[7] = '0'; + buf[8] = '0'; + buf[9] = '0'; + return buf; + } + + for(i=9;i>=2;--i) + { + if ((num%16) < 10) + buf[i]=(char)((num%16)+'0'); + else + buf[i]=(char)((num%16)+'W'); + + num/=16; + } + + return buf; +} + + +void transmite(unsigned int target, unsigned int service, + unsigned int *msg, unsigned int lenght) { + static const unsigned int ZERO = 0; + + MacHeader p; + p.header = target; + p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc + p.service = service; + + while (MemoryRead(DMNI_SEND_ACTIVE)); + + MemoryWrite(DMNI_SIZE, 3); + + MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header + + if(lenght) { + MemoryWrite(DMNI_SIZE_2, lenght); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); + } else { + MemoryWrite(DMNI_SIZE_2, 1); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); + } + + MemoryWrite(DMNI_OP, READ); + MemoryWrite(DMNI_START, 1); +} + +volatile void *prepare_receive(volatile void *buff) { + buff = (void*)((((unsigned int)buff)+3) & -4); + MemoryWrite(DMNI_RECEIVE_BUFFER, (unsigned int)buff); + return buff; +} + +void wait_receive(){ + while(!(MemoryRead(DMNI_RECEIVE_BUFFER) & 1)); +} + +volatile unsigned int glob_buff[256]; + +int main() { + volatile char *buff; + + buff=prepare_receive(glob_buff); + puts("Prepared to receive\n"); + wait_receive(); + puts("Data Received\n"); + puts((char*)buff); + + return 0; +} + +/* +USO: +int message[30] +transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) +*/ diff --git a/applications/pc_test/transmit.c b/applications/pc_test/transmit.c new file mode 100644 index 0000000..a9386b8 --- /dev/null +++ b/applications/pc_test/transmit.c @@ -0,0 +1,160 @@ +#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) +#define MemoryRead(A) (*(volatile unsigned int*)(A)) + +/* DMNI operations */ +#define READ 0 +#define WRITE 1 + + +#define NI_CONFIG 0x20000140 + +/* DMNI*/ +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 +#define DMNI_RECEIVE_BUFFER 0x20000264 + +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|y)&0xFFFF) + +#define UART_WRITE 0x20000000 +#define TESTE 0x20000008 +#define MESSAGE_DELIVERY 0x00000020 +#define DMA_OPERATION 0x290 +#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header + +typedef struct { + unsigned int header; + unsigned int payload_size; + unsigned int service; +} MacHeader; + + +int puts(char *string) { + + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + //PS2: The original author need to review demorgans law for boolean simplification + for(str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); + ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; + MemoryWrite(UART_WRITE, *(++str_part))); + return 0; +} + +/**Converts a integer number to its decimal representation in a array of char + * \param num Integer number to be converted + * \return Array of chars + */ +char *itoa(unsigned int num) +{ + static char buf[12]; + static char buf2[12]; + int i,j; + + if (num==0) + { + buf[0] = '0'; + buf[1] = '\0'; + return &buf[0]; + } + + for(i=0;i<11 && num!=0;i++) + { + buf[i]=(char)((num%10)+'0'); + num/=10; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; +} + + + +char *itoh(unsigned int num) +{ + static char buf[11]; + int i; + buf[10]=0; + + buf[0] = '0'; + buf[1] = 'x'; + + if (num==0) + { + buf[2] = '0'; + buf[3] = '0'; + buf[4] = '0'; + buf[5] = '0'; + buf[6] = '0'; + buf[7] = '0'; + buf[8] = '0'; + buf[9] = '0'; + return buf; + } + + for(i=9;i>=2;--i) + { + if ((num%16) < 10) + buf[i]=(char)((num%16)+'0'); + else + buf[i]=(char)((num%16)+'W'); + + num/=16; + } + + return buf; +} + + +void transmite(unsigned int target, unsigned int service, + unsigned int *msg, unsigned int lenght) { + static const unsigned int ZERO = 0; + static MacHeader p; + + p.header = target; + p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc + p.service = service; + + MemoryWrite(DMNI_SIZE, 3); + + MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header + + if(lenght) { + MemoryWrite(DMNI_SIZE_2, lenght); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); + } else { + MemoryWrite(DMNI_SIZE_2, 1); + MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); + } + + MemoryWrite(DMNI_OP, READ); + MemoryWrite(DMNI_START, 1); + + while (MemoryRead(DMNI_SEND_ACTIVE)); +} + +int main() { + unsigned int i; + char hello[] = "Hello World!\n"; + + transmite(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); + + return 0; +} diff --git a/build_env/scripts/app_builder.py b/build_env/scripts/app_builder.py index 7f80c9d..2a34c98 100644 --- a/build_env/scripts/app_builder.py +++ b/build_env/scripts/app_builder.py @@ -34,6 +34,8 @@ def main(): generate_appstart(apps_repo_addr_list, yaml_r) generate_cfg_file(yaml_r) + + generate_map_pkg(yaml_r) def generate_apps_id(apps_name_list): @@ -84,26 +86,57 @@ def generate_appstart(apps_repo_addr_list, yaml_r): def generate_cfg_file(yaml_r): - cfg_file_path = "apps.cfg" + apps_file_path = "apps.cfg" cfg_lines = [] + apps_lines = [] - app_list = get_apps_name_list(yaml_r) - location = get_apps_location_list(yaml_r) + app_list = get_apps_list(yaml_r) num_apps = len(app_list) for i in range(0,num_apps): app = app_list[i] - x_address = location[i][0] - y_address = location[i][1] - pos = x_address << 8 | y_address - size = get_task_txt_size(app, app) - cfg_lines.append("applications/" + app + "/" + app + ".txt\n") - cfg_lines.append(toX(pos)+"\n") - cfg_lines.append(toX(size)+"\n") - - writes_file_into_testcase(cfg_file_path, cfg_lines) + name = app["name"] + tasks_list = app["tasks"] + apps_lines.append(name + ".cfg\n") + for task in tasks_list: + task_name = task["task"] + location = task["location"] + x_address = location[0] + y_address = location[1] + pos = x_address << 8 | y_address + size = get_task_txt_size(name, task_name) + cfg_lines.append("applications/" + name + "/" + task_name+".txt\n") + cfg_lines.append(toX(pos)+"\n") + cfg_lines.append(toX(size)+"\n") + cfg_file_path = name + ".cfg" + writes_file_into_testcase(cfg_file_path, cfg_lines) + + writes_file_into_testcase(apps_file_path, apps_lines) + +def generate_map_pkg(yaml_r): + + app_list = get_apps_list(yaml_r) + + file_lines = [] + #---------------- C SINTAX ------------------ + file_lines.append("#ifndef _MAP_PKG_\n") + file_lines.append("#define _MAP_PKG_\n\n") + + for app in app_list: + tasks_list = app["tasks"] + for task in tasks_list: + task_name = task["task"] + location = task["location"] + x_address = location[0] + y_address = location[1] + pos = x_address << 8 | y_address + file_lines.append("#define " + task_name + "\t0x" + toX(pos) + "\n") + + file_lines.append("\n#endif\n") + + writes_file_into_testcase("include/map_pkg.h", file_lines) #Function that generates a new repository from the dir: /applications #Please, behold this following peace of art: diff --git a/build_env/scripts/hw_builder.py b/build_env/scripts/hw_builder.py index 9a9ee01..7895da7 100644 --- a/build_env/scripts/hw_builder.py +++ b/build_env/scripts/hw_builder.py @@ -128,6 +128,7 @@ def generate_to_vhdl(is_master_list, yaml_r): simple_soc = get_simple_soc(yaml_r) open_ports = get_open_ports(yaml_r) io_number = get_io_number(yaml_r) + apps_list = get_apps_list(yaml_r) #These lines compute the logical memory addresses used by the mlite to index the pages at the local memory @@ -179,6 +180,16 @@ def generate_to_vhdl(is_master_list, yaml_r): for i in range(0,x_mpsoc_dim*y_mpsoc_dim): open_ports_string = open_ports_string + "\"" + open_ports_vector[i] + "\"," open_ports_string = open_ports_string[0:len(open_ports_string)-1] + + #Computes the max of tasks into an app + max_task_per_app = 0 #len(taks_list) + for app in apps_list: + tasks_list = app["tasks"] + + task_count = len( tasks_list ) + + if task_count > max_task_per_app: + max_task_per_app = task_count file_lines = [] @@ -193,6 +204,7 @@ def generate_to_vhdl(is_master_list, yaml_r): file_lines.append(" constant MEMORY_SIZE_BYTES : integer := "+str(memory_size_KB*1024)+";\n") file_lines.append(" constant TOTAL_REPO_SIZE_BYTES : integer := "+str(repo_size_bytes)+";\n") file_lines.append(" constant APP_NUMBER : integer := "+str(app_number)+";\n") + file_lines.append(" constant MAX_TASKS_APP : integer := "+str(max_task_per_app)+";\n") file_lines.append(" constant PAGE_SIZE_H_INDEX : integer := "+str(page_size_h_index)+";\n") file_lines.append(" constant PAGE_NUMBER_H_INDEX : integer := "+str(page_number_h_index)+";\n") file_lines.append(" -- Hemps top definitions\n") diff --git a/build_env/scripts/kernel_builder.py b/build_env/scripts/kernel_builder.py index f0a1499..0311249 100644 --- a/build_env/scripts/kernel_builder.py +++ b/build_env/scripts/kernel_builder.py @@ -43,7 +43,7 @@ def generate_sw_pkg( yaml_r ): x_cluster_dim = get_cluster_x_dim(yaml_r) y_cluster_dim = get_cluster_y_dim(yaml_r) master_location = get_master_location(yaml_r) - apps_list = get_apps_name_list(yaml_r) + apps_list = get_apps_list(yaml_r) static_mapping_list = get_static_mapping_list(yaml_r) @@ -53,14 +53,15 @@ def generate_sw_pkg( yaml_r ): max_slave_processors = (x_mpsoc_dim*y_mpsoc_dim) - master_number max_cluster_slave = (x_cluster_dim * y_cluster_dim) - 1 apps_number = len(apps_list) - static_lenght = str(len(static_mapping_list)) - + static_lenght = str(len(static_mapping_list)) + + #Computes the max of tasks into an app - max_task_per_app = 0 - - for app_name in apps_list: + max_task_per_app = 0 #len(taks_list) + for app in apps_list: + tasks_list = app["tasks"] - task_count = len( get_app_task_name_list(".", app_name) ) + task_count = len( tasks_list ) if task_count > max_task_per_app: max_task_per_app = task_count diff --git a/build_env/scripts/yaml_intf.py b/build_env/scripts/yaml_intf.py index 63709b4..8f87890 100644 --- a/build_env/scripts/yaml_intf.py +++ b/build_env/scripts/yaml_intf.py @@ -78,6 +78,11 @@ def get_apps_name_list(yaml_reader): return apps_name_list +def get_apps_list(yaml_reader): + + apps_list = yaml_reader["apps"] + return apps_list + def get_apps_location_list(yaml_reader): apps_list = yaml_reader["apps"] diff --git a/hardware/vhdl/test_bench.vhd b/hardware/vhdl/test_bench.vhd index 448a8dd..049f7ae 100644 --- a/hardware/vhdl/test_bench.vhd +++ b/hardware/vhdl/test_bench.vhd @@ -29,7 +29,8 @@ entity test_bench is code_size : std_logic_vector(31 downto 0); end record; - type list_of_apps is array(0 to APP_NUMBER-1) of config; + type list_of_tasks is array(0 to MAX_TASKS_APP-1) of config; + type list_of_apps is array(0 to APP_NUMBER-1) of string(1 to 40); --constant log_file : string := "output_master.txt"; --! port description constant mlite_description : string := "RTL"; @@ -64,16 +65,17 @@ entity test_bench is return mem; end load_repo; - impure function get_cfg (cfg_file : in string) return list_of_apps is + impure function get_cfg (cfg_file : in string) return list_of_tasks is file file_ptr : text open read_mode is cfg_file; variable inline : line; variable strline : string(1 to 40); - variable cfg : list_of_apps; + variable cfg : list_of_tasks; variable str_len : integer; + variable i : integer := 0; begin - for i in 0 to APP_NUMBER-1 loop + while not endfile(file_ptr) loop readline(file_ptr, inline); str_len := inline'length; read(inline, strline(1 to inline'length)); @@ -83,11 +85,49 @@ entity test_bench is hread(inline, cfg(i).position); readline(file_ptr, inline); hread(inline, cfg(i).code_size); + i := i + 1; end loop; file_close(file_ptr); return cfg; end get_cfg; + impure function get_num_tasks(cfg_file : in string) return integer is + + file file_ptr : text open read_mode is cfg_file; + variable inline : line; + variable i : integer := 0; + begin + + while not endfile(file_ptr) loop + readline(file_ptr, inline); + readline(file_ptr, inline); + readline(file_ptr, inline); + i := i + 1; + end loop; + file_close(file_ptr); + return i; + end get_num_tasks; + + impure function get_apps_cfg (cfg_file : in string) return list_of_apps is + + file file_ptr : text open read_mode is cfg_file; + variable inline : line; + variable strline : string(1 to 15); + variable apps_cfg : list_of_apps; + variable str_len : integer; + begin + + for i in 0 to APP_NUMBER-1 loop + readline(file_ptr, inline); + str_len := inline'length; + read(inline, strline(1 to inline'length)); + apps_cfg(i)(1 to str_len) := strline(1 to str_len); + apps_cfg(i)(str_len+1 to 15) := (others => NUL); + end loop; + file_close(file_ptr); + return apps_cfg; + end get_apps_cfg; + end; architecture test_bench of test_bench is @@ -96,7 +136,7 @@ architecture test_bench of test_bench is signal clock_200 : std_logic := '1'; signal reset : std_logic; - constant app_cfg : list_of_apps := get_cfg("apps.cfg"); + constant apps_cfg : list_of_apps := get_apps_cfg("apps.cfg"); signal current_time : integer := 0; signal app_i : integer := 0; @@ -112,15 +152,18 @@ architecture test_bench of test_bench is signal clock_rx_io : std_logic_vector((IO_NUMBER-1) downto 0); --Leitura para IO + signal task_cfg : list_of_tasks; + signal task_num : integer; signal rd_addr : std_logic_vector(23 downto 0); signal flit_counter : integer; signal file_counter : integer; + signal app_counter : integer; signal packstart_counter : integer; type packstart_type is array(0 to TAM_PACKSTART-1) of regflit; signal packstart_data : packstart_type; - signal app_code : repo_type; + signal task_code : repo_type; - type send_state is (WAIT_state, SEND_APP, SEND_START); + type send_state is (WAIT_state, GET_CODE, SEND_TASK, SEND_START); signal SEND: send_state; begin @@ -203,29 +246,42 @@ begin flit_counter <= 0; packstart_counter <= 0; file_counter <= 0; + app_counter <= 0; + task_num <= 0; SEND <= WAIT_state; elsif rising_edge(clock) then case SEND is when WAIT_state => - if file_counter < APP_NUMBER then - flit_counter <= CONV_INTEGER(app_cfg(file_counter).code_size); - app_code <= load_repo(app_cfg(file_counter).code_name); + if app_counter < APP_NUMBER then + task_cfg <= get_cfg(apps_cfg(app_counter)); + task_num <= get_num_tasks(apps_cfg(app_counter)); + SEND <= GET_CODE; + end if; + + when GET_CODE => + if file_counter < task_num then + flit_counter <= CONV_INTEGER(task_cfg(file_counter).code_size); + task_code <= load_repo(task_cfg(file_counter).code_name); rd_addr <= (others => '0'); - SEND <= SEND_APP; + SEND <= SEND_TASK; + else + app_counter <= app_counter + 1; + file_counter <= 0; + SEND <= WAIT_state; end if; - when SEND_APP => + when SEND_TASK => if credit_o_io(0) = '1' and flit_counter > 0 then rx_io(0) <= '1'; rd_addr <= rd_addr + 1; if rd_addr = 0 then - data_in_io(0) <= app_cfg(file_counter).position; + data_in_io(0) <= task_cfg(file_counter).position; elsif rd_addr = 1 then - data_in_io(0) <= app_cfg(file_counter).code_size + 1; + data_in_io(0) <= task_cfg(file_counter).code_size + 1; elsif rd_addr = 2 then data_in_io(0) <= x"00000290"; else - data_in_io(0) <= app_code(CONV_INTEGER(rd_addr-3)); + data_in_io(0) <= task_code(CONV_INTEGER(rd_addr-3)); flit_counter <= flit_counter - 1; end if; elsif flit_counter = 0 then @@ -239,14 +295,14 @@ begin rx_io(0) <= '1'; rd_addr <= rd_addr + 1; if rd_addr = 0 then - data_in_io(0) <= app_cfg(file_counter).position; + data_in_io(0) <= task_cfg(file_counter).position; else data_in_io(0) <= packstart_data(CONV_INTEGER(rd_addr-1)); end if; else file_counter <= file_counter + 1; rx_io(0) <= '0'; - SEND <= WAIT_state; + SEND <= GET_CODE; end if; end case; diff --git a/testcases/integ.yaml b/testcases/integ.yaml index cfc4a27..95d0e6f 100644 --- a/testcases/integ.yaml +++ b/testcases/integ.yaml @@ -11,9 +11,9 @@ hw: open_port: - port: [0,0,S] apps: - - name: receive - start_time_ms: 0 - location: [0,1] - - name: transmit - start_time_ms: 0 - location: [1,1] + - name: pc_test + tasks: + - task: receive + location: [0,1] + - task: transmit + location: [1,1] From 942ebcaf1cc3d8c94a3d36131d61ca3f3ec06f54 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Wed, 8 Nov 2017 16:31:40 -0200 Subject: [PATCH 33/54] Resetting dmni receive buffer on cpu kill to receive next task --- hardware/vhdl/pe/dmni/dmni.vhd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 3822f96..91dd3b8 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -136,7 +136,8 @@ begin elsif set_buff = '1' then recv_buffer <= config_data; elsif set_reset_cpu = '1' and config_data = x"DEADBEEF" then - reset_cpu <= '1'; + recv_buffer <= (others => '0'); + reset_cpu <= '1'; end if; if reset_cpu_r = '1' then From 177a2544c351ed487d1d1016827feb668c1aed57 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 10 Nov 2017 18:17:19 -0200 Subject: [PATCH 34/54] included bareOS --- applications/receive/receive.c | 181 -------------- applications/transmit/receive.c | 181 -------------- applications/transmit/transmit.c | 160 ------------- applications/transmit_receive/receive.c | 13 ++ applications/transmit_receive/transmit.c | 10 + build_env/makes/make_app | 92 ++++---- software/bareOS/comm.c | 41 ++++ software/bareOS/crt0.s | 22 ++ software/bareOS/hal.c | 31 +++ software/bareOS/hemps.ld | 38 +++ software/bareOS/include/comm.h | 33 +++ software/bareOS/include/hal.h | 108 +++++++++ software/bareOS/include/libos.h | 50 ++++ software/bareOS/include/prototypes.h | 18 ++ software/bareOS/libos.c | 192 +++++++++++++++ software/bareOS/malloc.c | 106 +++++++++ software/bareOS/softmul.c | 285 +++++++++++++++++++++++ testcases/integ.yaml | 2 +- 18 files changed, 998 insertions(+), 565 deletions(-) delete mode 100644 applications/receive/receive.c delete mode 100644 applications/transmit/receive.c delete mode 100644 applications/transmit/transmit.c create mode 100644 applications/transmit_receive/receive.c create mode 100644 applications/transmit_receive/transmit.c create mode 100644 software/bareOS/comm.c create mode 100644 software/bareOS/crt0.s create mode 100644 software/bareOS/hal.c create mode 100644 software/bareOS/hemps.ld create mode 100644 software/bareOS/include/comm.h create mode 100644 software/bareOS/include/hal.h create mode 100644 software/bareOS/include/libos.h create mode 100644 software/bareOS/include/prototypes.h create mode 100644 software/bareOS/libos.c create mode 100644 software/bareOS/malloc.c create mode 100644 software/bareOS/softmul.c diff --git a/applications/receive/receive.c b/applications/receive/receive.c deleted file mode 100644 index a7954e8..0000000 --- a/applications/receive/receive.c +++ /dev/null @@ -1,181 +0,0 @@ -#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) -#define MemoryRead(A) (*(volatile unsigned int*)(A)) - -/* DMNI operations */ -#define READ 0 -#define WRITE 1 - - -#define NI_CONFIG 0x20000140 - -/* DMNI*/ -#define UART_WRITE 0x20000000 -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 -#define DMNI_SEND_ACTIVE 0x20000250 -#define DMNI_RECEIVE_ACTIVE 0x20000260 -#define DMNI_RECEIVE_BUFFER 0x20000264 - -/* Manual Routing destination ports */ -#define MANUAL_EAST 0x80000000 -#define MANUAL_WEST 0xA0000000 -#define MANUAL_NORTH 0xC0000000 -#define MANUAL_SOUTH 0xE0000000 - -#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) - - -#define TESTE 0x20000008 -#define MESSAGE_DELIVERY 0x00000020 -#define DMA_OPERATION 0x290 -#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header - -typedef struct { - unsigned int header; - unsigned int payload_size; - unsigned int service; -} MacHeader; - - -int puts(char *string) { - int *str_part; - //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines - //PS: This indicates a hardware developer putting its hands on software development - //PS2: The original author need to review demorgans law for boolean simplification - for(str_part = (int*)string, MemoryWrite(UART_WRITE, *str_part); - ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; - MemoryWrite(UART_WRITE, *(++str_part))); - return 0; -} - -/**Converts a integer number to its decimal representation in a array of char - * \param num Integer number to be converted - * \return Array of chars - */ -char *itoa(unsigned int num) -{ - static char buf[12]; - static char buf2[12]; - int i,j; - - if (num==0) - { - buf[0] = '0'; - buf[1] = '\0'; - return &buf[0]; - } - - for(i=0;i<11 && num!=0;i++) - { - buf[i]=(char)((num%10)+'0'); - num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; -} - - - -char *itoh(unsigned int num) -{ - static char buf[11]; - int i; - buf[10]=0; - - buf[0] = '0'; - buf[1] = 'x'; - - if (num==0) - { - buf[2] = '0'; - buf[3] = '0'; - buf[4] = '0'; - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '0'; - buf[8] = '0'; - buf[9] = '0'; - return buf; - } - - for(i=9;i>=2;--i) - { - if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); - else - buf[i]=(char)((num%16)+'W'); - - num/=16; - } - - return buf; -} - - -void transmite(unsigned int target, unsigned int service, - unsigned int *msg, unsigned int lenght) { - static const unsigned int ZERO = 0; - - MacHeader p; - p.header = target; - p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc - p.service = service; - - while (MemoryRead(DMNI_SEND_ACTIVE)); - - MemoryWrite(DMNI_SIZE, 3); - - MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - - if(lenght) { - MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); - } else { - MemoryWrite(DMNI_SIZE_2, 1); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); - } - - MemoryWrite(DMNI_OP, READ); - MemoryWrite(DMNI_START, 1); -} - -volatile void *prepare_receive(volatile void *buff) { - buff = (void*)((((unsigned int)buff)+3) & -4); - MemoryWrite(DMNI_RECEIVE_BUFFER, (unsigned int)buff); - return buff; -} - -void wait_receive(){ - while(!(MemoryRead(DMNI_RECEIVE_BUFFER) & 1)); -} - -volatile unsigned int glob_buff[256]; - -int main() { - volatile char *buff; - - buff=prepare_receive(glob_buff); - puts("Prepared to receive\n"); - wait_receive(); - puts("Data Received\n"); - puts((char*)buff); - - return 0; -} - -/* -USO: -int message[30] -transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) -*/ diff --git a/applications/transmit/receive.c b/applications/transmit/receive.c deleted file mode 100644 index a7954e8..0000000 --- a/applications/transmit/receive.c +++ /dev/null @@ -1,181 +0,0 @@ -#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) -#define MemoryRead(A) (*(volatile unsigned int*)(A)) - -/* DMNI operations */ -#define READ 0 -#define WRITE 1 - - -#define NI_CONFIG 0x20000140 - -/* DMNI*/ -#define UART_WRITE 0x20000000 -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 -#define DMNI_SEND_ACTIVE 0x20000250 -#define DMNI_RECEIVE_ACTIVE 0x20000260 -#define DMNI_RECEIVE_BUFFER 0x20000264 - -/* Manual Routing destination ports */ -#define MANUAL_EAST 0x80000000 -#define MANUAL_WEST 0xA0000000 -#define MANUAL_NORTH 0xC0000000 -#define MANUAL_SOUTH 0xE0000000 - -#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) - - -#define TESTE 0x20000008 -#define MESSAGE_DELIVERY 0x00000020 -#define DMA_OPERATION 0x290 -#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header - -typedef struct { - unsigned int header; - unsigned int payload_size; - unsigned int service; -} MacHeader; - - -int puts(char *string) { - int *str_part; - //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines - //PS: This indicates a hardware developer putting its hands on software development - //PS2: The original author need to review demorgans law for boolean simplification - for(str_part = (int*)string, MemoryWrite(UART_WRITE, *str_part); - ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; - MemoryWrite(UART_WRITE, *(++str_part))); - return 0; -} - -/**Converts a integer number to its decimal representation in a array of char - * \param num Integer number to be converted - * \return Array of chars - */ -char *itoa(unsigned int num) -{ - static char buf[12]; - static char buf2[12]; - int i,j; - - if (num==0) - { - buf[0] = '0'; - buf[1] = '\0'; - return &buf[0]; - } - - for(i=0;i<11 && num!=0;i++) - { - buf[i]=(char)((num%10)+'0'); - num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; -} - - - -char *itoh(unsigned int num) -{ - static char buf[11]; - int i; - buf[10]=0; - - buf[0] = '0'; - buf[1] = 'x'; - - if (num==0) - { - buf[2] = '0'; - buf[3] = '0'; - buf[4] = '0'; - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '0'; - buf[8] = '0'; - buf[9] = '0'; - return buf; - } - - for(i=9;i>=2;--i) - { - if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); - else - buf[i]=(char)((num%16)+'W'); - - num/=16; - } - - return buf; -} - - -void transmite(unsigned int target, unsigned int service, - unsigned int *msg, unsigned int lenght) { - static const unsigned int ZERO = 0; - - MacHeader p; - p.header = target; - p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc - p.service = service; - - while (MemoryRead(DMNI_SEND_ACTIVE)); - - MemoryWrite(DMNI_SIZE, 3); - - MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - - if(lenght) { - MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); - } else { - MemoryWrite(DMNI_SIZE_2, 1); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); - } - - MemoryWrite(DMNI_OP, READ); - MemoryWrite(DMNI_START, 1); -} - -volatile void *prepare_receive(volatile void *buff) { - buff = (void*)((((unsigned int)buff)+3) & -4); - MemoryWrite(DMNI_RECEIVE_BUFFER, (unsigned int)buff); - return buff; -} - -void wait_receive(){ - while(!(MemoryRead(DMNI_RECEIVE_BUFFER) & 1)); -} - -volatile unsigned int glob_buff[256]; - -int main() { - volatile char *buff; - - buff=prepare_receive(glob_buff); - puts("Prepared to receive\n"); - wait_receive(); - puts("Data Received\n"); - puts((char*)buff); - - return 0; -} - -/* -USO: -int message[30] -transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) -*/ diff --git a/applications/transmit/transmit.c b/applications/transmit/transmit.c deleted file mode 100644 index a9386b8..0000000 --- a/applications/transmit/transmit.c +++ /dev/null @@ -1,160 +0,0 @@ -#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) -#define MemoryRead(A) (*(volatile unsigned int*)(A)) - -/* DMNI operations */ -#define READ 0 -#define WRITE 1 - - -#define NI_CONFIG 0x20000140 - -/* DMNI*/ -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 -#define DMNI_SEND_ACTIVE 0x20000250 -#define DMNI_RECEIVE_ACTIVE 0x20000260 -#define DMNI_RECEIVE_BUFFER 0x20000264 - -/* Manual Routing destination ports */ -#define MANUAL_EAST 0x80000000 -#define MANUAL_WEST 0xA0000000 -#define MANUAL_NORTH 0xC0000000 -#define MANUAL_SOUTH 0xE0000000 - -#define ROUTER_ADDR(x, y) (((x<<8)|y)&0xFFFF) - -#define UART_WRITE 0x20000000 -#define TESTE 0x20000008 -#define MESSAGE_DELIVERY 0x00000020 -#define DMA_OPERATION 0x290 -#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header - -typedef struct { - unsigned int header; - unsigned int payload_size; - unsigned int service; -} MacHeader; - - -int puts(char *string) { - - int *str_part; - //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines - //PS: This indicates a hardware developer putting its hands on software development - //PS2: The original author need to review demorgans law for boolean simplification - for(str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); - ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; - MemoryWrite(UART_WRITE, *(++str_part))); - return 0; -} - -/**Converts a integer number to its decimal representation in a array of char - * \param num Integer number to be converted - * \return Array of chars - */ -char *itoa(unsigned int num) -{ - static char buf[12]; - static char buf2[12]; - int i,j; - - if (num==0) - { - buf[0] = '0'; - buf[1] = '\0'; - return &buf[0]; - } - - for(i=0;i<11 && num!=0;i++) - { - buf[i]=(char)((num%10)+'0'); - num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; -} - - - -char *itoh(unsigned int num) -{ - static char buf[11]; - int i; - buf[10]=0; - - buf[0] = '0'; - buf[1] = 'x'; - - if (num==0) - { - buf[2] = '0'; - buf[3] = '0'; - buf[4] = '0'; - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '0'; - buf[8] = '0'; - buf[9] = '0'; - return buf; - } - - for(i=9;i>=2;--i) - { - if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); - else - buf[i]=(char)((num%16)+'W'); - - num/=16; - } - - return buf; -} - - -void transmite(unsigned int target, unsigned int service, - unsigned int *msg, unsigned int lenght) { - static const unsigned int ZERO = 0; - static MacHeader p; - - p.header = target; - p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc - p.service = service; - - MemoryWrite(DMNI_SIZE, 3); - - MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - - if(lenght) { - MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); - } else { - MemoryWrite(DMNI_SIZE_2, 1); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); - } - - MemoryWrite(DMNI_OP, READ); - MemoryWrite(DMNI_START, 1); - - while (MemoryRead(DMNI_SEND_ACTIVE)); -} - -int main() { - unsigned int i; - char hello[] = "Hello World!\n"; - - transmite(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); - - return 0; -} diff --git a/applications/transmit_receive/receive.c b/applications/transmit_receive/receive.c new file mode 100644 index 0000000..e83681d --- /dev/null +++ b/applications/transmit_receive/receive.c @@ -0,0 +1,13 @@ +#include + +int main() { + volatile char *buff; + + buff=prepare_receive(glob_buff); + puts("Prepared to receive\n"); + wait_receive(); + puts("Data Received\n"); + puts((char*)buff); + + return 0; +} diff --git a/applications/transmit_receive/transmit.c b/applications/transmit_receive/transmit.c new file mode 100644 index 0000000..b620703 --- /dev/null +++ b/applications/transmit_receive/transmit.c @@ -0,0 +1,10 @@ +#include + +int main() { + unsigned int i; + char hello[] = "Hello World!\n"; + + transmit(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); + + return 0; +} diff --git a/build_env/makes/make_app b/build_env/makes/make_app index 270896c..58b3e80 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -1,43 +1,51 @@ -GREEN =\033[0;32m -NC =\033[0m # No Color - -INCLUDE = ../../software/include - -CFLAGS = -O2 -Wall -fms-extensions -c -s -std=c99 -G 0 -GCC_MIPS = mips-elf-gcc $(CFLAGS) -AS_MIPS = mips-elf-as -LD_MIPS = mips-elf-ld -DUMP_MIPS = mips-elf-objdump -COPY_MIPS = mips-elf-objcopy -I elf32-bigmips -O binary - -BOOT_TASK = boot_task -BOOT_TASK_SRC = ../../software/boot_task/boot_task.s - -TASK_SRC = $(wildcard *.c) -TASK_OBJ = $(TASK_SRC:.c=.o) - -default: $(BOOT_TASK).o $(TASK_OBJ) - -boot_task.o: $(BOOT_TASK_SRC) - @printf "${GREEN}Compiling boot task: %s ...${NC}\n" "$*.S" - $(AS_MIPS) -mips1 --defsym sp_addr=$(PAGE_SP_INIT) -o $@ $^ - -#[$*] - only the filename - #https://www.gnu.org/software/make/manual/make.html#Automatic-Variables -$(TASK_OBJ): $(TASK_SRC) - @printf "${GREEN}Compiling task: %s ...${NC}\n" "$*.c" - $(GCC_MIPS) $(CFLAGS) $*.c -o $*.o --include id_tasks.h -I $(INCLUDE) - $(LD_MIPS) -Ttext 0 -eentry -Map $*.map -s -N -o $*.bin $(BOOT_TASK).o $*.o - $(LD_MIPS) -Ttext 0 -eentry -Map $*_debug.map -o $*_debug.bin $(BOOT_TASK).o $*.o - $(DUMP_MIPS) -S $*_debug.bin > $*.lst - $(COPY_MIPS) $*.bin $*.dump - hexdump -v -e '1/1 "%02x" 1/1 "%02x" 1/1 "%02x" 1/1 "%02x" "\n"' $*.dump > $*.txt - -clean: - @printf "Cleaning up\n" - @rm -rf *.o - @rm -rf *.bin - @rm -rf *.map - @rm -rf *.lst - @rm -rf *.txt - @rm -rf *.dump +BAREOS_DIR = ../../software/bareOS +TRIPLET = mips-elf +CC = $(TRIPLET)-gcc +CFLAGS = -I$(BAREOS_DIR)/include -O2 -fno-builtin -Wall -fms-extensions -nostdinc +AS = $(TRIPLET)-as +ASFLAGS = --defsym _stack=$(PAGE_SP_INIT) +CPP = $(TRIPLET)-g++ +CCFLAGS = $(CFLAGS) +LD = $(TRIPLET)-gcc +LDFLAGS = -nostdlib -T$(BAREOS_DIR)/hemps.ld +OBJCOPY = $(TRIPLET)-objcopy +OBJDUMP = $(TRIPLET)-objdump +PROGNAME = $(basename $(wildcard *.c)) + +BIN_FILES = $(addsuffix .bin, $(PROGNAME)) +LST_FILES = $(addsuffix .lst, $(PROGNAME)) +TXT_FILES = $(addsuffix .txt, $(PROGNAME)) + +BARE_OS = $(BAREOS_DIR)/crt0.o \ + $(BAREOS_DIR)/hal.o \ + $(BAREOS_DIR)/libos.o \ + $(BAREOS_DIR)/malloc.o \ + $(BAREOS_DIR)/comm.o \ + + +all : $(BIN_FILES) $(LST_FILES) + +%.bin : %.elf + $(OBJCOPY) -O binary $< $@ + +%.lst : %.elf + $(OBJDUMP) -d $< > $@ + +%.txt : %.bin + hexdump -v -e '1/1 "%02x" 1/1 "%02x" 1/1 "%02x" 1/1 "%02x" "\n"' $< > $@ + +%.o: %.c + $(CC) $(CFLAGS) -o $@ -c $< + +%.o: %.cpp + $(CPP) $(CCFLAGS) -o $@ -c $< + +%.o: %.s + $(AS) $(ASFLAGS) -o $@ $< + +%.elf: $(BARE_OS) %.o + $(LD) -o $@ $+ $(LDFLAGS) + +clean : + rm -f $(BIN_FILES) $(LST_FILES) $(BARE_OS) $(wildcard *~) $(wildcard *.o) diff --git a/software/bareOS/comm.c b/software/bareOS/comm.c new file mode 100644 index 0000000..e98b680 --- /dev/null +++ b/software/bareOS/comm.c @@ -0,0 +1,41 @@ +#include "include/libos.h" + +void transmit(flit_t target, flit_t service, + void *msg, size_t len) { + static const flit_t zero = 0; + static mac_header_t p; + + len = align_type(len, flit_t); + + p.header = target; + p.payload_size = (MAC_HEADER_LEN-2) + (len ? len : 1); // 3 devido ao service header - 2 flits da noc + p.service = service; + + // Configure DMNI for package header transmission + MemoryWrite32(DMNI_SIZE, MAC_HEADER_LEN); + MemoryWrite32(DMNI_ADDRESS, (size_t)(&p) ); + + // Configure DMNI for package payload transmission + if(len) { + MemoryWrite32(DMNI_SIZE_2, len); + MemoryWrite32(DMNI_ADDRESS_2, (size_t)msg); + } else { + MemoryWrite32(DMNI_SIZE_2, 1); + MemoryWrite32(DMNI_ADDRESS_2, (size_t)(&zero)); + } + + MemoryWrite32(DMNI_OP, READ); + MemoryWrite32(DMNI_START, 1); + + while (MemoryRead32(DMNI_SEND_ACTIVE)); +} + +volatile void *prepare_receive(volatile void *buff) { + buff = (void*)align((size_t)buff, 2); + MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)buff); + return buff; +} + +void wait_receive(){ + while(!(MemoryRead32(DMNI_RECEIVE_BUFFER) & 1)); +} diff --git a/software/bareOS/crt0.s b/software/bareOS/crt0.s new file mode 100644 index 0000000..9e89c94 --- /dev/null +++ b/software/bareOS/crt0.s @@ -0,0 +1,22 @@ + .section .text.init + .global _entry + .ent _entry + .set noreorder +_entry: + la $sp, _stack + la $gp, _gp + la $a0, _bss_start + la $a1, _bss_end +.clr_bss: + beq a0, a1, .clr_bss_done + nop + sw zero, 0($a0) + beq $zero, $zero, .clr_bss + addiu a0, a0, 4 +.clr_bss_done: + jal main + not + j exit + or $a0, $v0, $zero + .set reorder + .end _entry diff --git a/software/bareOS/hal.c b/software/bareOS/hal.c new file mode 100644 index 0000000..1637591 --- /dev/null +++ b/software/bareOS/hal.c @@ -0,0 +1,31 @@ +#include "include/libos.h" + +typedef struct { + flit_t source; + flit_t retcode; +} exit_msg_t; + +void exit(int code) { + exit_msg_t msg; + + msg.source = MemoryRead32(NET_ADDRESS); + msg.retcode = code; + + transmit(MemoryRead32(LOADER_NETADDR), EXIT_OPERATION, &msg, sizeof(exit_msg_t)); + + for(;;) MemoryWrite32(CPU_KILL, CPU_KILL_MAGIC); +} + +void putchar(char c) { + MemoryWrite32(UART_WRITE, (uint32_t)c); +} + +void puts(const char *string) { + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + //PS2: The original author need to review demorgans law for boolean simplification + for(str_part = (int*)string, MemoryWrite32(UART_WRITE, *str_part); + ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; + MemoryWrite32(UART_WRITE, *(++str_part))); +} diff --git a/software/bareOS/hemps.ld b/software/bareOS/hemps.ld new file mode 100644 index 0000000..88eeb13 --- /dev/null +++ b/software/bareOS/hemps.ld @@ -0,0 +1,38 @@ +ENTRY(_entry) + +SECTIONS { + . = 0; + + .text : { + _text = .; + *(.text.init) + *(.text) + *(.text.*) + _etext = .; + } + + .data : { + _rodata = .; + *(.rdata) + *(.rodata) + *(.rodata.*) + _erodata = .; + _data = .; + *(.data) + *(.data.*) + _gp = . + 0x800; + *(.sdata) + *(.sdata.*) + . = ALIGN(16); + _edata = .; + _bss_start = .; + *(.sbss) + *(.sbss.*) + *(.bss) + *(.bss.*) + . = ALIGN(4); + _bss_end = . ; + } + _end = .; +} + diff --git a/software/bareOS/include/comm.h b/software/bareOS/include/comm.h new file mode 100644 index 0000000..ae185f2 --- /dev/null +++ b/software/bareOS/include/comm.h @@ -0,0 +1,33 @@ +#ifndef _COMM_H +#define _COMM_H + +#include "prototypes.h" + +/* Manual Routing destination ports */ +#define MANUAL_EAST 0x80000000 +#define MANUAL_WEST 0xA0000000 +#define MANUAL_NORTH 0xC0000000 +#define MANUAL_SOUTH 0xE0000000 + +#define ROUTER_ADDR(x, y) (((x<<8)|y)&0xFFFF) +#define MAC_HEADER_LEN (sizeof(mac_header_t)/sizeof(flit_t)) + +#define EXIT_OPERATION 0x70 +#define DMA_OPERATION 0x290 +#define REQ_OPERATION 0x480 + +typedef uint32_t flit_t; + +typedef struct { + flit_t header; + flit_t payload_size; + flit_t service; +} mac_header_t; + +void transmit(flit_t target, flit_t service, + void *msg, size_t len); + +volatile void *prepare_receive(volatile void *buff); +void wait_receive(); + +#endif /* !_COMM_H */ diff --git a/software/bareOS/include/hal.h b/software/bareOS/include/hal.h new file mode 100644 index 0000000..5604620 --- /dev/null +++ b/software/bareOS/include/hal.h @@ -0,0 +1,108 @@ +#ifndef _HAL_H +#define _HAL_H + +#include "prototypes.h" + +/* Paramenters used by malloc */ +//pointer to the end of static program memory +extern size_t _end; +//assumes _stack points to the end of the memory +extern size_t _stack; +#define MALLOC_ALIGNMENT 4 + +#define HEAP_START ((void*)&_end) +#define HEAP_END ((void*)((&_stack)-1024)) // stack - 4kB +#define HEAP_ALLOCATION_GRAIN 10 //1kB + +/*********** Hardware addresses ***********/ +#define UART_WRITE 0x20000000 +#define UART_READ 0x20000000 +#define IRQ_MASK 0x20000010 +#define IRQ_STATUS 0x20000020 +#define TIME_SLICE 0x20000060 +#define SYS_CALL 0x20000070 +#define END_SIM 0x20000080 +#define CLOCK_HOLD 0x20000090 + +/* Network Interface*/ +#define NI_STATUS_RECV 0x20000100 +#define NI_STATUS_SEND 0x20000110 +#define NI_RECV 0x20000120 +#define NI_SEND 0x20000130 +#define NI_CONFIG 0x20000140 +#define NI_ACK 0x20000150 +#define NI_NACK 0x20000160 +#define NI_END 0x20000170 +#define CURRENT_PAGE 0x20000180 +#define NEXT_PAGE 0x20000190 + +/* Network information */ +#define NET_ADDRESS 0x20000140 +#define LOADER_NETADDR 0x20000144 + +/* Task termination */ +#define CPU_KILL 0x20000320 +#define CPU_KILL_MAGIC 0xDEADBEAF + +/* DMNI */ +#define DMNI_SIZE_2 0x20000205 +#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 +#define DMNI_RECEIVE_BUFFER 0x20000264 + +//Scheduling report +#define SCHEDULING_REPORT 0x20000270 +#define INTERRUPTION 0x10000 +//#define SYSCALL 0x20000 +#define SCHEDULER 0x40000 +#define IDLE 0x80000 + +//Communication graphical debbug +#define ADD_PIPE_DEBUG 0x20000280 +#define REM_PIPE_DEBUG 0x20000285 +#define ADD_REQUEST_DEBUG 0x20000290 +#define REM_REQUEST_DEBUG 0x20000295 + +/* DMNI operations */ +#define READ 0 +#define WRITE 1 + +#define TICK_COUNTER 0x20000300 +#define CURRENT_TASK 0x20000400 + +#define REQ_APP 0x20000350 +#define ACK_APP 0x20000360 + +#define SLACK_TIME_MONITOR 0x20000370 + +//Kernel pending service FIFO +#define PENDING_SERVICE_INTR 0x20000400 + +#define SLACK_TIME_WINDOW 50000 // half milisecond + +/*********** Interrupt bits **************/ +#define IRQ_PENDING_SERVICE 0x01 //bit 0 +#define IRQ_SLACK_TIME 0x02 //bit 1 +#define IRQ_SCHEDULER 0x08 //bit 3 +#define IRQ_NOC 0x20 //bit 5 + +/*Memory Access*/ +#define MemoryRead32(A) (*(volatile uint32_t*)(A)) +#define MemoryWrite32(A,V) *(volatile uint32_t*)(A)=(V) +#define MemoryRead16(A) (*(volatile uint16_t*)(A)) +#define MemoryWrite16(A,V) *(volatile uint16_t*)(A)=(V) +#define MemoryRead8(A) (*(volatile uint8_t*)(A)) +#define MemoryWrite8(A,V) *(volatile uint8_t*)(A)=(V) + +// Stubs, need real implementation if running on real hardware +static inline int enter_critical() { return 0; } +static inline void leave_critical(int i) {} + + +#endif diff --git a/software/bareOS/include/libos.h b/software/bareOS/include/libos.h new file mode 100644 index 0000000..567cb95 --- /dev/null +++ b/software/bareOS/include/libos.h @@ -0,0 +1,50 @@ +#ifndef _LIBOS_H +#define _LIBOS_H + +#include "hal.h" +#include "comm.h" + +#define isprint(c) (' '<=(c)&&(c)<='~') +#define isspace(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\r') +#define isdigit(c) ('0'<=(c)&&(c)<='9') +#define islower(c) ('a'<=(c)&&(c)<='z') +#define isupper(c) ('A'<=(c)&&(c)<='Z') +#define isalpha(c) (islower(c)||isupper(c)) +#define isalnum(c) (isalpha(c)||isdigit(c)) +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) +#define ntohs(A) (((A)>>8) | (((A)&0xff)<<8)) +#define ntohl(A) (((A)>>24) | (((A)&0xff0000)>>8) | (((A)&0xff00)<<8) | ((A)<<24)) + +#define va_start(ap, argN) __builtin_va_start(ap, argN) +#define va_arg(ap, type) __builtin_va_arg(ap, type) +#define va_end(ap) __builtin_va_end(ap) +#define va_copy(dst, src) __builtin_va_copy(dst, src) + +#define new(type) calloc(1, sizeof(type)) +#define align_type(x, type) (((x)+sizeof(type)-1) & -sizeof(type)) +#define align(x, bits) (((x)+(1<>= 1); + + if(b == 1) { + b = (1 << shift)-1; + do { + *q++ = '0' + (i & b); + } while(i >>= shift); + } else + do { + *q++ = '0' + (i % base); + } while (i /= base); + + for (*q = 0; p <= --q; p++){ + (*p > '9')?(c = *p + 39):(c = *p); + (*q > '9')?(*p = *q + 39):(*p = *q); + *q = c; + } + + return s; +} + +char *itoa(int i, char *s, int base){ + char c; + char *p = s; + char *q = s; + + if (i >= 0) + return utoa(i, s, base); + + *q++ = '-'; + p++; + do{ + *q++ = '0' - (i % base); + } while (i /= base); + + for (*q = 0; p <= --q; p++){ + (*p > '9')?(c = *p + 39):(c = *p); + (*q > '9')?(*p = *q + 39):(*p = *q); + *q = c; + } + + return s; +} + +void *memset(void *dst, int ic, size_t bytes) { + uint8_t c; + uint32_t f; + + /* Probably the most assemblish code ever written in C! + * This is what you get when you put a processor designer + * to write software */ + + c = ic; + f = (c << 24) | (c << 16) | (c << 8) | c; + + switch(bytes & 3) { + case 3: + *((uint8_t*)dst++) = c; + bytes--; + case 2: + *((uint8_t*)dst++) = c; + bytes--; + case 1: + *((uint8_t*)dst++) = c; + bytes--; + case 0: + while(bytes){ + *((uint32_t*)dst++) = f; + bytes -= 4; + } + } + + return dst; +} + +void *memcpy(void *dst, const void *src, size_t bytes) { + + switch(bytes & 3) { + case 3: + *((uint8_t*)dst++) = *((uint8_t*)src++); + bytes--; + case 2: + *((uint8_t*)dst++) = *((uint8_t*)src++); + bytes--; + case 1: + *((uint8_t*)dst++) = *((uint8_t*)src++); + bytes--; + case 0: + switch(((size_t)dst | (size_t)src) & 3) { + case 1: + case 3: + while(bytes){ + *((uint8_t*)dst++) = *((uint8_t*)src++); + bytes--; + } + break; + case 2: + while(bytes){ + *((uint16_t*)dst++) = *((uint16_t*)src++); + bytes-=2; + } + break; + case 0: + while(bytes){ + *((uint32_t*)dst++) = *((uint32_t*)src++); + bytes-=4; + } + } + } + + return dst; +} + +int printf(const char *fmt, ...) { + va_list ap; + int ret; + + va_start(ap, fmt); + ret = vprintf(fmt, ap); + va_end(ap); + + return ret; +} + +int vprintf(const char *fmt, va_list ap){ + char *s; + int i,j; + char buf[32]; + + while (*fmt){ + if (*fmt != '%') + putchar(*fmt++); + else{ + j = 0; + switch (*++fmt){ + case 'i': + case 'd': + i = va_arg(ap, int); + itoa(i,buf,10); + puts(buf); + break; + case 'u': + i = va_arg(ap, int); + utoa(i, buf, 10); + puts(buf); + break; + case 'o': + i = va_arg(ap, int); + utoa(i,buf,8); + puts(buf); + break; + case 'p': + puts("0x"); + case 'X': + i = va_arg(ap, int); + utoa(i,buf,16); + j=0; + while (buf[j]) + buf[j] = islower(buf[j]) ? buf[j++] - 0x20 : buf[j++]; + puts(buf); + break; + case 'x': + i = va_arg(ap, int); + itoa(i,buf,16); + puts(buf); + break; + case 'c': + putchar(va_arg(ap, int)); + break; + case 's': + s = va_arg(ap, char*); + if (!s) s = "(null)"; + puts(s); + break; + case '%' : + putchar('%'); + break; + } + fmt++; + } + } + + return 0; +} diff --git a/software/bareOS/malloc.c b/software/bareOS/malloc.c new file mode 100644 index 0000000..07646c7 --- /dev/null +++ b/software/bareOS/malloc.c @@ -0,0 +1,106 @@ +#include "include/libos.h" + +/* Shamelessly stolen from K&R C Programing Language Book */ + +typedef struct header { + struct header *ptr; + size_t size; +} header_t __attribute__ ((aligned(MALLOC_ALIGNMENT))); + +static header_t base = {.ptr = &base, .size = 0 }; +static header_t *freep = &base; + +static header_t *morecore(size_t nunits) { + static header_t *lastp = HEAP_START; + header_t *p; + size_t size; + + size = align_type(min(align(nunits*sizeof(header_t), HEAP_ALLOCATION_GRAIN), + ((size_t)lastp)-((size_t)HEAP_END)), + header_t)/sizeof(header_t); + + if(((void*)lastp <= HEAP_END) || size < nunits) + return NULL; + + p = lastp; + p->size = size; + lastp += size; + + return p; +} + +void *malloc(size_t nbytes) { + header_t *p, *prevp; + unsigned nunits; + int critical; + nunits = (nbytes+sizeof(header_t)-1)/sizeof(header_t) + 1; + + critical = enter_critical(); + + prevp = freep; + for (p = prevp->ptr; ; prevp = p, p = p->ptr) { + if (p->size >= nunits) { + if (p->size == nunits) + prevp->ptr = p->ptr; + else { + p->size -= nunits; + p += p->size; + p->size = nunits; + } + freep = prevp; + leave_critical(critical); + return (void *)(p+1); + } + if (p == freep) { + if((p = morecore(nunits)) == NULL) { + leave_critical(critical); + return NULL; + } + } + } +} + +void free(void *ap) { + header_t *bp, *p; + int critical; + bp = (header_t *)ap - 1; + +#ifdef DEBUG + printf("free: Freeing %d bytes\n", bp->size*sizeof(header_t)); +#endif + + critical = enter_critical(); + + for (p = freep; !(bp > p && bp < p->ptr); p = p->ptr) + if (p >= p->ptr && (bp > p || bp < p->ptr)) + break; /* freed block at start or end of arena */ + + if (bp + bp->size == p->ptr) { + /* join to upper nbr */ + bp->size += p->ptr->size; + bp->ptr = p->ptr->ptr; + } else + bp->ptr = p->ptr; + if (p + p->size == bp) { + /* join to lower nbr */ + p->size += bp->size; + p->ptr = bp->ptr; + } else + p->ptr = bp; + freep = p; + + leave_critical(critical); +} + +void *calloc(size_t qty, size_t type_size){ + size_t *buf, *end, *a; + size_t size; + + size = qty == 1 ? align_type(type_size, size_t) : align_type(qty*type_size, size_t); + + if((buf = malloc(size))) + for(end = (size_t*)((size_t)buf + size), a = buf ; a < end ; a++) + *a = 0; + + return (void *)buf; +} diff --git a/software/bareOS/softmul.c b/software/bareOS/softmul.c new file mode 100644 index 0000000..9c740f7 --- /dev/null +++ b/software/bareOS/softmul.c @@ -0,0 +1,285 @@ +/* + * software implementation of multiply/divide and 64-bit routines + * copied from Hellfire-OS by Sergio Johann Filho + * https://github.com/sjohann81/hellfireos +*/ + +#include "include/prototypes.h" + +typedef union{ + int64_t all; + struct{ +#if LITTLE_ENDIAN + uint32_t low; + int32_t high; +#else + int32_t high; + uint32_t low; +#endif + } s; +} dwords; + +int32_t __mulsi3(uint32_t a, uint32_t b){ + uint32_t answer = 0; + + while(b){ + if(b & 1) + answer += a; + a <<= 1; + b >>= 1; + } + return answer; +} + +int64_t __muldsi3(uint32_t a, uint32_t b){ + dwords r; + + const int32_t bits_in_word_2 = (int32_t)(sizeof(int32_t) * 8) / 2; + const uint32_t lower_mask = (uint32_t)~0 >> bits_in_word_2; + r.s.low = (a & lower_mask) * (b & lower_mask); + uint32_t t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; + t += (a >> bits_in_word_2) * (b & lower_mask); + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high = t >> bits_in_word_2; + t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; + t += (b >> bits_in_word_2) * (a & lower_mask); + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high += t >> bits_in_word_2; + r.s.high += (a >> bits_in_word_2) * (b >> bits_in_word_2); + + return r.all; +} + +int64_t __muldi3(int64_t a, int64_t b){ + dwords x; + x.all = a; + dwords y; + y.all = b; + dwords r; + r.all = __muldsi3(x.s.low, y.s.low); +/* r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; */ + r.s.high += __mulsi3(x.s.high, y.s.low) + __mulsi3(x.s.low, y.s.high); + + return r.all; +} + +uint32_t __udivmodsi4(uint32_t num, uint32_t den, int32_t modwanted){ + uint32_t bit = 1; + uint32_t res = 0; + + while (den < num && bit && !(den & (1L << 31))) { + den <<= 1; + bit <<= 1; + } + while (bit){ + if (num >= den){ + num -= den; + res |= bit; + } + bit >>= 1; + den >>= 1; + } + if (modwanted) + return num; + return res; +} + +int32_t __divsi3(int32_t a, int32_t b){ + int32_t neg = 0; + int32_t res; + + if (a < 0){ + a = -a; + neg = !neg; + } + + if (b < 0){ + b = -b; + neg = !neg; + } + + res = __udivmodsi4(a, b, 0); + + if (neg) + res = -res; + + return res; +} + +int32_t __modsi3(int32_t a, int32_t b){ + int32_t neg = 0; + int32_t res; + + if (a < 0){ + a = -a; + neg = 1; + } + + if (b < 0) + b = -b; + + res = __udivmodsi4(a, b, 1); + + if (neg) + res = -res; + + return res; +} + +uint32_t __udivsi3 (uint32_t a, uint32_t b){ + return __udivmodsi4(a, b, 0); +} + +uint32_t __umodsi3 (uint32_t a, uint32_t b){ + return __udivmodsi4(a, b, 1); +} + +int64_t __ashldi3(int64_t u, uint32_t b){ + dwords uu, w; + uint32_t bm; + + if (b == 0) + return u; + + uu.all = u; + bm = 32 - b; + + if (bm <= 0){ + w.s.low = 0; + w.s.high = (uint32_t) uu.s.low << -bm; + }else{ + const uint32_t carries = (uint32_t) uu.s.low >> bm; + + w.s.low = (uint32_t) uu.s.low << b; + w.s.high = ((uint32_t) uu.s.high << b) | carries; + } + + return w.all; +} + +int64_t __ashrdi3(int64_t u, uint32_t b){ + dwords uu, w; + uint32_t bm; + + if (b == 0) + return u; + + uu.all = u; + bm = 32 - b; + + if (bm <= 0){ + /* w.s.high = 1..1 or 0..0 */ + w.s.high = uu.s.high >> 31; + w.s.low = uu.s.low >> -bm; + }else{ + const uint32_t carries = (uint32_t) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((uint32_t) uu.s.low >> b) | carries; + } + + return w.all; +} + +int64_t __lshrdi3(int64_t u, uint32_t b){ + dwords uu, w; + uint32_t bm; + + if (b == 0) + return u; + + uu.all = u; + bm = 32 - b; + + if (bm <= 0){ + w.s.high = 0; + w.s.low = (uint32_t) uu.s.high >> -bm; + }else{ + const uint32_t carries = (uint32_t) uu.s.high << bm; + + w.s.high = (uint32_t) uu.s.high >> b; + w.s.low = ((uint32_t) uu.s.low >> b) | carries; + } + + return w.all; +} + +uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p){ + uint64_t quot = 0, qbit = 1; + + if (den == 0){ + return 1 / ((uint32_t)den); + } + + while ((int64_t)den >= 0){ + den <<= 1; + qbit <<= 1; + } + + while (qbit){ + if (den <= num){ + num -= den; + quot += qbit; + } + den >>= 1; + qbit >>= 1; + } + + if (rem_p) + *rem_p = num; + + return quot; +} + +uint64_t __umoddi3(uint64_t num, uint64_t den){ + uint64_t v; + + (void) __udivmoddi4(num, den, &v); + return v; +} + +uint64_t __udivdi3(uint64_t num, uint64_t den){ + return __udivmoddi4(num, den, NULL); +} + +int64_t __moddi3(int64_t num, int64_t den){ + int minus = 0; + int64_t v; + + if (num < 0){ + num = -num; + minus = 1; + } + if (den < 0){ + den = -den; + minus ^= 1; + } + + (void) __udivmoddi4(num, den, (uint64_t *)&v); + if (minus) + v = -v; + + return v; +} + +int64_t __divdi3(int64_t num, int64_t den){ + int minus = 0; + int64_t v; + + if (num < 0){ + num = -num; + minus = 1; + } + if (den < 0){ + den = -den; + minus ^= 1; + } + + v = __udivmoddi4(num, den, NULL); + if (minus) + v = -v; + + return v; +} diff --git a/testcases/integ.yaml b/testcases/integ.yaml index 95d0e6f..8b0b7b1 100644 --- a/testcases/integ.yaml +++ b/testcases/integ.yaml @@ -11,7 +11,7 @@ hw: open_port: - port: [0,0,S] apps: - - name: pc_test + - name: transmit_receive tasks: - task: receive location: [0,1] From 1d855879c9575b94cdead6395e79d386e1f8d368 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 10 Nov 2017 19:30:35 -0200 Subject: [PATCH 35/54] bareOS working --- applications/pc_test/receive.c | 184 +---------------------- applications/pc_test/transmit.c | 154 +------------------ applications/transmit_receive/receive.c | 13 -- applications/transmit_receive/transmit.c | 10 -- build_env/makes/make_app | 13 +- software/bareOS/crt0.s | 20 ++- software/bareOS/include/hal.h | 6 +- software/bareOS/include/prototypes.h | 16 +- testcases/integ.yaml | 2 +- 9 files changed, 41 insertions(+), 377 deletions(-) delete mode 100644 applications/transmit_receive/receive.c delete mode 100644 applications/transmit_receive/transmit.c diff --git a/applications/pc_test/receive.c b/applications/pc_test/receive.c index a7954e8..0e30e61 100644 --- a/applications/pc_test/receive.c +++ b/applications/pc_test/receive.c @@ -1,181 +1,13 @@ -#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) -#define MemoryRead(A) (*(volatile unsigned int*)(A)) - -/* DMNI operations */ -#define READ 0 -#define WRITE 1 - - -#define NI_CONFIG 0x20000140 - -/* DMNI*/ -#define UART_WRITE 0x20000000 -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 -#define DMNI_SEND_ACTIVE 0x20000250 -#define DMNI_RECEIVE_ACTIVE 0x20000260 -#define DMNI_RECEIVE_BUFFER 0x20000264 - -/* Manual Routing destination ports */ -#define MANUAL_EAST 0x80000000 -#define MANUAL_WEST 0xA0000000 -#define MANUAL_NORTH 0xC0000000 -#define MANUAL_SOUTH 0xE0000000 - -#define ROUTER_ADDR(x, y) (((x<<8)|x)&0xFFFF) - - -#define TESTE 0x20000008 -#define MESSAGE_DELIVERY 0x00000020 -#define DMA_OPERATION 0x290 -#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header - -typedef struct { - unsigned int header; - unsigned int payload_size; - unsigned int service; -} MacHeader; - - -int puts(char *string) { - int *str_part; - //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines - //PS: This indicates a hardware developer putting its hands on software development - //PS2: The original author need to review demorgans law for boolean simplification - for(str_part = (int*)string, MemoryWrite(UART_WRITE, *str_part); - ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; - MemoryWrite(UART_WRITE, *(++str_part))); - return 0; -} - -/**Converts a integer number to its decimal representation in a array of char - * \param num Integer number to be converted - * \return Array of chars - */ -char *itoa(unsigned int num) -{ - static char buf[12]; - static char buf2[12]; - int i,j; - - if (num==0) - { - buf[0] = '0'; - buf[1] = '\0'; - return &buf[0]; - } - - for(i=0;i<11 && num!=0;i++) - { - buf[i]=(char)((num%10)+'0'); - num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; -} - - - -char *itoh(unsigned int num) -{ - static char buf[11]; - int i; - buf[10]=0; - - buf[0] = '0'; - buf[1] = 'x'; - - if (num==0) - { - buf[2] = '0'; - buf[3] = '0'; - buf[4] = '0'; - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '0'; - buf[8] = '0'; - buf[9] = '0'; - return buf; - } - - for(i=9;i>=2;--i) - { - if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); - else - buf[i]=(char)((num%16)+'W'); - - num/=16; - } - - return buf; -} - - -void transmite(unsigned int target, unsigned int service, - unsigned int *msg, unsigned int lenght) { - static const unsigned int ZERO = 0; - - MacHeader p; - p.header = target; - p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc - p.service = service; - - while (MemoryRead(DMNI_SEND_ACTIVE)); - - MemoryWrite(DMNI_SIZE, 3); - - MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - - if(lenght) { - MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); - } else { - MemoryWrite(DMNI_SIZE_2, 1); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); - } - - MemoryWrite(DMNI_OP, READ); - MemoryWrite(DMNI_START, 1); -} - -volatile void *prepare_receive(volatile void *buff) { - buff = (void*)((((unsigned int)buff)+3) & -4); - MemoryWrite(DMNI_RECEIVE_BUFFER, (unsigned int)buff); - return buff; -} - -void wait_receive(){ - while(!(MemoryRead(DMNI_RECEIVE_BUFFER) & 1)); -} - -volatile unsigned int glob_buff[256]; +#include int main() { volatile char *buff; - - buff=prepare_receive(glob_buff); - puts("Prepared to receive\n"); - wait_receive(); - puts("Data Received\n"); - puts((char*)buff); - + + buff=prepare_receive(malloc(256)); + puts("Prepared to receive\n"); + wait_receive(); + puts("Data Received\n"); + puts((char*)buff); + return 0; } - -/* -USO: -int message[30] -transmit( ROUTER_ADDR(X,Y)|MANUAL_, message, 30) -*/ diff --git a/applications/pc_test/transmit.c b/applications/pc_test/transmit.c index a9386b8..b620703 100644 --- a/applications/pc_test/transmit.c +++ b/applications/pc_test/transmit.c @@ -1,160 +1,10 @@ -#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) -#define MemoryRead(A) (*(volatile unsigned int*)(A)) - -/* DMNI operations */ -#define READ 0 -#define WRITE 1 - - -#define NI_CONFIG 0x20000140 - -/* DMNI*/ -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 -#define DMNI_SEND_ACTIVE 0x20000250 -#define DMNI_RECEIVE_ACTIVE 0x20000260 -#define DMNI_RECEIVE_BUFFER 0x20000264 - -/* Manual Routing destination ports */ -#define MANUAL_EAST 0x80000000 -#define MANUAL_WEST 0xA0000000 -#define MANUAL_NORTH 0xC0000000 -#define MANUAL_SOUTH 0xE0000000 - -#define ROUTER_ADDR(x, y) (((x<<8)|y)&0xFFFF) - -#define UART_WRITE 0x20000000 -#define TESTE 0x20000008 -#define MESSAGE_DELIVERY 0x00000020 -#define DMA_OPERATION 0x290 -#define CONSTANT_PKT_SIZE 3 //Tamanho do pacote do header - -typedef struct { - unsigned int header; - unsigned int payload_size; - unsigned int service; -} MacHeader; - - -int puts(char *string) { - - int *str_part; - //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines - //PS: This indicates a hardware developer putting its hands on software development - //PS2: The original author need to review demorgans law for boolean simplification - for(str_part = (int*)string, MemoryWrite(UART_WRITE,*str_part); - ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; - MemoryWrite(UART_WRITE, *(++str_part))); - return 0; -} - -/**Converts a integer number to its decimal representation in a array of char - * \param num Integer number to be converted - * \return Array of chars - */ -char *itoa(unsigned int num) -{ - static char buf[12]; - static char buf2[12]; - int i,j; - - if (num==0) - { - buf[0] = '0'; - buf[1] = '\0'; - return &buf[0]; - } - - for(i=0;i<11 && num!=0;i++) - { - buf[i]=(char)((num%10)+'0'); - num/=10; - } - buf2[i] = '\0'; - j = 0; - i--; - for(;i>=0;i--){ - buf2[i]=buf[j]; - j++; - } - return &buf2[0]; -} - - - -char *itoh(unsigned int num) -{ - static char buf[11]; - int i; - buf[10]=0; - - buf[0] = '0'; - buf[1] = 'x'; - - if (num==0) - { - buf[2] = '0'; - buf[3] = '0'; - buf[4] = '0'; - buf[5] = '0'; - buf[6] = '0'; - buf[7] = '0'; - buf[8] = '0'; - buf[9] = '0'; - return buf; - } - - for(i=9;i>=2;--i) - { - if ((num%16) < 10) - buf[i]=(char)((num%16)+'0'); - else - buf[i]=(char)((num%16)+'W'); - - num/=16; - } - - return buf; -} - - -void transmite(unsigned int target, unsigned int service, - unsigned int *msg, unsigned int lenght) { - static const unsigned int ZERO = 0; - static MacHeader p; - - p.header = target; - p.payload_size = (CONSTANT_PKT_SIZE-2) + (lenght ? lenght : 1); // 3 devido ao service header - 2 flits da noc - p.service = service; - - MemoryWrite(DMNI_SIZE, 3); - - MemoryWrite(DMNI_ADDRESS, (unsigned int) (&p) ); //grava na memoria as informacoes do header - - if(lenght) { - MemoryWrite(DMNI_SIZE_2, lenght); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int) msg); - } else { - MemoryWrite(DMNI_SIZE_2, 1); - MemoryWrite(DMNI_ADDRESS_2, (unsigned int)(&ZERO)); - } - - MemoryWrite(DMNI_OP, READ); - MemoryWrite(DMNI_START, 1); - - while (MemoryRead(DMNI_SEND_ACTIVE)); -} +#include int main() { unsigned int i; char hello[] = "Hello World!\n"; - transmite(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); + transmit(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); return 0; } diff --git a/applications/transmit_receive/receive.c b/applications/transmit_receive/receive.c deleted file mode 100644 index e83681d..0000000 --- a/applications/transmit_receive/receive.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -int main() { - volatile char *buff; - - buff=prepare_receive(glob_buff); - puts("Prepared to receive\n"); - wait_receive(); - puts("Data Received\n"); - puts((char*)buff); - - return 0; -} diff --git a/applications/transmit_receive/transmit.c b/applications/transmit_receive/transmit.c deleted file mode 100644 index b620703..0000000 --- a/applications/transmit_receive/transmit.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -int main() { - unsigned int i; - char hello[] = "Hello World!\n"; - - transmit(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); - - return 0; -} diff --git a/build_env/makes/make_app b/build_env/makes/make_app index 58b3e80..4a9ddc5 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -13,9 +13,10 @@ OBJDUMP = $(TRIPLET)-objdump PROGNAME = $(basename $(wildcard *.c)) -BIN_FILES = $(addsuffix .bin, $(PROGNAME)) +DUMP_FILES = $(addsuffix .dump, $(PROGNAME)) LST_FILES = $(addsuffix .lst, $(PROGNAME)) TXT_FILES = $(addsuffix .txt, $(PROGNAME)) +BIN_FILES = $(addsuffix .bin, $(PROGNAME)) BARE_OS = $(BAREOS_DIR)/crt0.o \ $(BAREOS_DIR)/hal.o \ @@ -24,15 +25,15 @@ BARE_OS = $(BAREOS_DIR)/crt0.o \ $(BAREOS_DIR)/comm.o \ -all : $(BIN_FILES) $(LST_FILES) +all : $(DUMP_FILES) $(LST_FILES) $(TXT_FILES) $(BIN_FILES) -%.bin : %.elf +%.dump : %.bin $(OBJCOPY) -O binary $< $@ -%.lst : %.elf +%.lst : %.bin $(OBJDUMP) -d $< > $@ -%.txt : %.bin +%.txt : %.dump hexdump -v -e '1/1 "%02x" 1/1 "%02x" 1/1 "%02x" 1/1 "%02x" "\n"' $< > $@ %.o: %.c @@ -44,7 +45,7 @@ all : $(BIN_FILES) $(LST_FILES) %.o: %.s $(AS) $(ASFLAGS) -o $@ $< -%.elf: $(BARE_OS) %.o +%.bin: $(BARE_OS) %.o $(LD) -o $@ $+ $(LDFLAGS) clean : diff --git a/software/bareOS/crt0.s b/software/bareOS/crt0.s index 9e89c94..8689838 100644 --- a/software/bareOS/crt0.s +++ b/software/bareOS/crt0.s @@ -5,18 +5,22 @@ _entry: la $sp, _stack la $gp, _gp - la $a0, _bss_start - la $a1, _bss_end + la $4, _bss_start + la $5, _bss_end .clr_bss: - beq a0, a1, .clr_bss_done + beq $4, $5, .clr_bss_done nop - sw zero, 0($a0) - beq $zero, $zero, .clr_bss - addiu a0, a0, 4 + sw $0, 0($4) + beq $0, $0, .clr_bss + addiu $4, $4, 4 .clr_bss_done: jal main - not + nop j exit - or $a0, $v0, $zero + or $4, $2, $0 .set reorder .end _entry + + .section data + .global _mem_end_ptr +_mem_end_ptr: .word _stack diff --git a/software/bareOS/include/hal.h b/software/bareOS/include/hal.h index 5604620..bcca3e5 100644 --- a/software/bareOS/include/hal.h +++ b/software/bareOS/include/hal.h @@ -5,13 +5,13 @@ /* Paramenters used by malloc */ //pointer to the end of static program memory -extern size_t _end; +extern uint8_t _end; //assumes _stack points to the end of the memory -extern size_t _stack; +extern uint8_t* _mem_end_ptr; #define MALLOC_ALIGNMENT 4 #define HEAP_START ((void*)&_end) -#define HEAP_END ((void*)((&_stack)-1024)) // stack - 4kB +#define HEAP_END ((void*)(_mem_end_ptr-1024)) // stack - 1kB #define HEAP_ALLOCATION_GRAIN 10 //1kB /*********** Hardware addresses ***********/ diff --git a/software/bareOS/include/prototypes.h b/software/bareOS/include/prototypes.h index c1f9f5a..18b31ca 100644 --- a/software/bareOS/include/prototypes.h +++ b/software/bareOS/include/prototypes.h @@ -2,14 +2,14 @@ #define PROTOTYPES_H #ifdef __GNUC__ -typedef __INT8_TYPE__ int8_t; -typedef __INT16_TYPE__ int16_t; -typedef __INT32_TYPE__ int32_t; -typedef __INT64_TYPE__ int64_t; -typedef __UINT8_TYPE__ uint8_t; -typedef __UINT16_TYPE__ uint16_t; -typedef __UINT32_TYPE__ uint32_t; -typedef __UINT64_TYPE__ uint64_t; +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long int uint64_t; typedef __SIZE_TYPE__ size_t; #endif diff --git a/testcases/integ.yaml b/testcases/integ.yaml index 8b0b7b1..95d0e6f 100644 --- a/testcases/integ.yaml +++ b/testcases/integ.yaml @@ -11,7 +11,7 @@ hw: open_port: - port: [0,0,S] apps: - - name: transmit_receive + - name: pc_test tasks: - task: receive location: [0,1] From 4abbf0750da64a1236ee0f93de26b8e4e429a9c2 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Mon, 13 Nov 2017 16:12:49 -0200 Subject: [PATCH 36/54] Corrected typo in DEADBEEF --- software/bareOS/include/hal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/bareOS/include/hal.h b/software/bareOS/include/hal.h index bcca3e5..6d2b8d4 100644 --- a/software/bareOS/include/hal.h +++ b/software/bareOS/include/hal.h @@ -42,7 +42,7 @@ extern uint8_t* _mem_end_ptr; /* Task termination */ #define CPU_KILL 0x20000320 -#define CPU_KILL_MAGIC 0xDEADBEAF +#define CPU_KILL_MAGIC 0xDEADBEEF /* DMNI */ #define DMNI_SIZE_2 0x20000205 From e5289db57bf0ff5cd47a7625243634a7acd5e110 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Mon, 13 Nov 2017 16:18:16 -0200 Subject: [PATCH 37/54] Added support to map_pkg.h include to get tasks location --- applications/pc_test/{receive.c => receiver.c} | 0 applications/pc_test/sender.c | 11 +++++++++++ applications/pc_test/transmit.c | 10 ---------- build_env/scripts/app_builder.py | 10 +++++----- testcases/integ.yaml | 8 ++++---- 5 files changed, 20 insertions(+), 19 deletions(-) rename applications/pc_test/{receive.c => receiver.c} (100%) create mode 100644 applications/pc_test/sender.c delete mode 100644 applications/pc_test/transmit.c diff --git a/applications/pc_test/receive.c b/applications/pc_test/receiver.c similarity index 100% rename from applications/pc_test/receive.c rename to applications/pc_test/receiver.c diff --git a/applications/pc_test/sender.c b/applications/pc_test/sender.c new file mode 100644 index 0000000..d94623d --- /dev/null +++ b/applications/pc_test/sender.c @@ -0,0 +1,11 @@ +#include +#include "map_pkg.h" + +int main() { + unsigned int i; + char hello[] = "Hello World!\n"; + + transmit(receiver, DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); + + return 0; +} diff --git a/applications/pc_test/transmit.c b/applications/pc_test/transmit.c deleted file mode 100644 index b620703..0000000 --- a/applications/pc_test/transmit.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -int main() { - unsigned int i; - char hello[] = "Hello World!\n"; - - transmit(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); - - return 0; -} diff --git a/build_env/scripts/app_builder.py b/build_env/scripts/app_builder.py index 2a34c98..b3791bd 100644 --- a/build_env/scripts/app_builder.py +++ b/build_env/scripts/app_builder.py @@ -21,6 +21,8 @@ def main(): page_size_bytes = get_page_size_KB(yaml_r) * 1024 generate_apps_id(apps_name_list) + + generate_map_pkg(yaml_r) exit_status = os.system("cd applications/; make sp_init=" + str(page_size_bytes -1) ) @@ -34,8 +36,6 @@ def main(): generate_appstart(apps_repo_addr_list, yaml_r) generate_cfg_file(yaml_r) - - generate_map_pkg(yaml_r) def generate_apps_id(apps_name_list): @@ -126,6 +126,7 @@ def generate_map_pkg(yaml_r): for app in app_list: tasks_list = app["tasks"] + app_name = app["name"] for task in tasks_list: task_name = task["task"] location = task["location"] @@ -133,10 +134,9 @@ def generate_map_pkg(yaml_r): y_address = location[1] pos = x_address << 8 | y_address file_lines.append("#define " + task_name + "\t0x" + toX(pos) + "\n") - - file_lines.append("\n#endif\n") + file_lines.append("\n#endif\n") + writes_file_into_testcase("applications/" + app_name + "/map_pkg.h", file_lines) - writes_file_into_testcase("include/map_pkg.h", file_lines) #Function that generates a new repository from the dir: /applications #Please, behold this following peace of art: diff --git a/testcases/integ.yaml b/testcases/integ.yaml index 95d0e6f..b50d760 100644 --- a/testcases/integ.yaml +++ b/testcases/integ.yaml @@ -4,8 +4,8 @@ hw: repository_size_MB: 1 model_description: vhdl noc_buffer_size: 8 - mpsoc_dimension: [2,2] - cluster_dimension: [2,2] + mpsoc_dimension: [3,2] + cluster_dimension: [3,2] master_location: LB simple_soc: true open_port: @@ -13,7 +13,7 @@ hw: apps: - name: pc_test tasks: - - task: receive + - task: receiver location: [0,1] - - task: transmit + - task: sender location: [1,1] From 3ad0a32b605506cbbf29cc23a5006c81b7d11c81 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Thu, 16 Nov 2017 11:40:26 -0200 Subject: [PATCH 38/54] Added comunication primitives --- applications/pc_test/receive.c | 19 +++-- applications/pc_test/transmit.c | 5 +- build_env/makes/make_app | 11 +-- hardware/vhdl/pe/dmni/dmni.vhd | 115 ++++++++++++++++++++++----- hardware/vhdl/pe/pe.vhd | 35 ++++---- hardware/vhdl/standards.vhd | 8 ++ software/bareOS/comm.c | 66 ++++++++++++--- software/bareOS/crt0.s | 4 - software/bareOS/hal.c | 2 +- software/bareOS/include/comm.h | 13 ++- software/bareOS/include/hal.h | 9 ++- software/bareOS/include/libos.h | 5 ++ software/bareOS/include/prototypes.h | 3 +- software/bareOS/libos.c | 27 +++++++ software/bareOS/malloc.c | 17 ++-- 15 files changed, 260 insertions(+), 79 deletions(-) diff --git a/applications/pc_test/receive.c b/applications/pc_test/receive.c index 0e30e61..dbf3306 100644 --- a/applications/pc_test/receive.c +++ b/applications/pc_test/receive.c @@ -1,13 +1,18 @@ #include int main() { - volatile char *buff; - - buff=prepare_receive(malloc(256)); - puts("Prepared to receive\n"); - wait_receive(); - puts("Data Received\n"); - puts((char*)buff); + char *msg; + flit_t src; + size_t size; + + do { + prepare_recv_msg(&src, &size); + puts("Prepared to receive\n"); + msg = wait_receive(); + printf("%d bytes received from %X\n", size, src); + puts(msg); + free(msg); + } while(strcmp(msg, "END")); return 0; } diff --git a/applications/pc_test/transmit.c b/applications/pc_test/transmit.c index b620703..987d951 100644 --- a/applications/pc_test/transmit.c +++ b/applications/pc_test/transmit.c @@ -1,10 +1,9 @@ #include int main() { - unsigned int i; - char hello[] = "Hello World!\n"; - transmit(ROUTER_ADDR(0,1), DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); + send_msg(ROUTER_ADDR(0, 1), "HELLO WORLD\n", strlen("HELLO WORLD\n")+1); + send_msg(ROUTER_ADDR(0, 1), "END", strlen("END")+1); return 0; } diff --git a/build_env/makes/make_app b/build_env/makes/make_app index 4a9ddc5..facd5cf 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -1,13 +1,14 @@ -BAREOS_DIR = ../../software/bareOS +BASEDIR = ../.. +BAREOS_DIR = $(BASEDIR)/software/bareOS TRIPLET = mips-elf CC = $(TRIPLET)-gcc -CFLAGS = -I$(BAREOS_DIR)/include -O2 -fno-builtin -Wall -fms-extensions -nostdinc +CFLAGS = -I$(BAREOS_DIR)/include -O2 -fno-builtin -Wall -fms-extensions -nostdinc -mips1 AS = $(TRIPLET)-as -ASFLAGS = --defsym _stack=$(PAGE_SP_INIT) +ASFLAGS = -mips1 CPP = $(TRIPLET)-g++ CCFLAGS = $(CFLAGS) -LD = $(TRIPLET)-gcc -LDFLAGS = -nostdlib -T$(BAREOS_DIR)/hemps.ld +LD = $(TRIPLET)-ld +LDFLAGS = -nostdlib -T$(BAREOS_DIR)/hemps.ld --defsym=_stack=$(PAGE_SP_INIT) OBJCOPY = $(TRIPLET)-objcopy OBJDUMP = $(TRIPLET)-objdump diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 91dd3b8..15f1d92 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -36,6 +36,7 @@ entity dmni is start : in std_logic; set_buff : in std_logic; set_reset_cpu : in std_logic; + request_read : in std_logic; config_data : in std_logic_vector(31 downto 0); -- Status outputs intr : out std_logic; @@ -43,6 +44,7 @@ entity dmni is receive_active : out std_logic; reset_cpu : out std_logic; recv_buff_out : out std_logic_vector(31 downto 0); + last_req : out std_logic_vector(31 downto 0); -- Memory interface mem_address : out std_logic_vector(31 downto 0); mem_data_write : out std_logic_vector(31 downto 0); @@ -64,8 +66,8 @@ architecture dmni of dmni is constant DMNI_TIMER : std_logic_vector(4 downto 0) := "10000"; constant WORD_SIZE : std_logic_vector(4 downto 0) := "00100"; - type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, DISCARD, FINISH); - type operation_type is (LEGACY, DMMA, START_CPU); + type dmni_state is (WAIT_state, LOAD, COPY_FROM_MEM, COPY_TO_MEM, COPY_TO_MEM_DMA, COPY_TO_FIFO, DISCARD, FINISH); + type operation_type is (LEGACY, DMMA, MSG_REQ, START_CPU); signal DMNI_Send : dmni_state; signal DMNI_Receive : dmni_state; @@ -113,9 +115,54 @@ architecture dmni of dmni is signal payload_fix : regflit; signal sizedata_fix : regflit; signal recv_op : operation_type; + + type req_fifo_t is array(0 to 7) of regflit; + signal req_fifo : req_fifo_t; + signal req_rcount : std_logic_vector(3 downto 0); + signal req_wcount : std_logic_vector(3 downto 0); + signal req_we : std_logic; + signal req_slot_avail : std_logic; + signal req_read_avail : std_logic; begin + + --request messages fifo controller + proc_req_fifo : process(clock, reset) + variable rcount, wcount : std_logic_vector(3 downto 0); + begin + if reset = '1' then + req_rcount <= (others => '0'); + req_wcount <= (others => '0'); + elsif rising_edge(clock) then + if req_we = '1' then + wcount := req_wcount + 1; + else + wcount := req_wcount; + end if; + + if request_read = '1' and req_read_avail = '1' then + rcount := req_rcount + 1; + else + rcount := req_rcount; + end if; + + if rcount = wcount then + rcount := (others => '0'); + wcount := (others => '0'); + end if; + + req_rcount <= rcount; + req_wcount <= wcount; + end if; + end process proc_req_fifo; + + req_slot_avail <= '1' when req_wcount - req_rcount < 8 else '0'; + req_read_avail <= '0' when req_wcount = req_rcount else '1'; + + last_req <= req_fifo(conv_integer(req_rcount(2 downto 0))) when req_read_avail = '1' + else (others => '0'); + --config - proc_config : process(clock) + proc_config : process(clock, reset) begin if reset = '1' then recv_buffer <= (others => '0'); @@ -233,6 +280,7 @@ begin is_header <= (others => '0'); intr_counter_temp <= (others => '0'); mem_byte_we <= (others => '0'); + req_we <= '0'; elsif (clock'event and clock = '1') then if (rx = '1' and slot_available = '1') then bufferr(CONV_INTEGER(last)) <= data_in; @@ -264,14 +312,13 @@ begin payload_size <= payload_size - 1; if (payload_size = payload_fix) then - if (data_in = x"00000300") then --Service 300 start_cpu + if data_in = START_CPU_OPERATION then --Service 300 start_cpu reset_cpu_r <= '1'; recv_op <= START_CPU; - end if; - end if; - if (payload_size = payload_fix) then - if (data_in = x"00000290") then --Service 290 dmni_operation + elsif data_in = DMMA_OPERATION then --Service 290 dmni_operation recv_op <= DMMA; + elsif data_in = REQ_OPERATION then + recv_op <= MSG_REQ; end if; end if; end if; @@ -281,7 +328,10 @@ begin --Write to memory case DMNI_Receive is when WAIT_state => - if ((recv_op = LEGACY and start = '1' and operation = '1') or (recv_op = DMMA and recv_buffer(0) = '0') or (recv_op = START_CPU))then + if ((recv_op = LEGACY and start = '1' and operation = '1') or + (recv_op = DMMA and recv_buffer(0) = '0') or + (recv_op = START_CPU) or + (recv_op = MSG_REQ)) then if(is_header(CONV_INTEGER(first)) = '1' and intr_counter_temp > 0) then intr_counter_temp <= intr_counter_temp -1; end if; @@ -300,6 +350,10 @@ begin DMNI_Receive <= DISCARD; recv_size <= payload_fix + 2; recv_address <= (others => '0'); + when MSG_REQ => + DMNI_Receive <= COPY_TO_FIFO; + recv_size <= payload_fix + 2; + recv_address <= (others => '0'); end case; end if; @@ -319,14 +373,38 @@ begin end if; when DISCARD => - recv_address <= (others => '0'); - mem_byte_we <= "0000"; - mem_data_write <= (others => '0'); - first <= first + 1; - add_buffer <= '0'; - recv_size <= recv_size -1; - if (recv_size = 0) then - DMNI_Receive <= FINISH; + if (read_av = '1') then + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + end if; + + when COPY_TO_FIFO => + if (read_av = '1') then + if (recv_size = sizedata_fix) then + if req_slot_avail = '1' then + req_fifo(conv_integer(req_rcount(2 downto 0))) <= bufferr(CONV_INTEGER(first)); + + req_we <= '1'; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + end if; + else + req_we <= '0'; + first <= first + 1; + add_buffer <= '0'; + recv_size <= recv_size -1; + if (recv_size = 0) then + DMNI_Receive <= FINISH; + end if; + end if; end if; when COPY_TO_MEM_DMA => @@ -345,7 +423,7 @@ begin else mem_byte_we <= "0000"; end if; - else + elsif read_av = '1' then first <= first + 1; add_buffer <= '0'; recv_size <= recv_size -1; @@ -356,6 +434,7 @@ begin end if; when FINISH => + req_we <= '0'; receive_active_2 <= '0'; mem_byte_we <= "0000"; recv_address <= (others => '0'); diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 8faa20d..4c18127 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -122,7 +122,8 @@ architecture structural of pe is signal slack_update_timer : std_logic_vector(31 downto 0); signal reset_dmni : std_logic; - + signal last_req : std_logic_vector(31 downto 0); + signal req_read : std_logic; begin ----------------------------------------------------------------------------------- @@ -216,26 +217,26 @@ begin generic map( address_router => router_address) port map( - clock => clock, - reset => reset, + clock => clock, + reset => reset, --Configuration interface - set_address => cpu_set_address, - set_address_2 => cpu_set_address_2, - set_size => cpu_set_size, - set_size_2 => cpu_set_size_2, - set_op => cpu_set_op, - start => cpu_start, - config_data => dmni_data_read, - set_buff => cpu_set_buff, - set_reset_cpu => cpu_set_reset, - + set_address => cpu_set_address, + set_address_2 => cpu_set_address_2, + set_size => cpu_set_size, + set_size_2 => cpu_set_size_2, + set_op => cpu_set_op, + start => cpu_start, + config_data => dmni_data_read, + set_buff => cpu_set_buff, + set_reset_cpu => cpu_set_reset, + request_read => req_read, -- Status outputs intr => ni_intr, send_active => dmni_send_active_sig, receive_active => dmni_receive_active_sig, reset_cpu => reset_dmni, recv_buff_out => dmni_recv_buff, - + last_req => last_req, -- Memory interface mem_address => dmni_mem_address, mem_data_write => dmni_mem_data_write, @@ -302,6 +303,7 @@ begin ZERO(31 downto 1) & dmni_receive_active_sig when cpu_mem_address_reg = DMNI_RECEIVE_ACTIVE else dmni_recv_buff when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER else LOADER_NETADDR when cpu_mem_address_reg = LOADER_NETADDR_REG else + last_req when cpu_mem_address_reg = DMNI_REQ_FIFO else data_read_ram; --Comb assignments @@ -321,7 +323,7 @@ begin irq <= '1' when (irq_status /= x"00" and irq_mask_reg /= x"00") else '0'; dmni_data_read <= cpu_mem_data_write_reg; dmni_mem_data_read <= mem_data_read when dmni_enable_internal_ram = '1' else repo_data_read; - cpu_enable_ram <= '1' when cpu_mem_address(30 downto 28) = "000" else '0'; + cpu_enable_ram <= '1' when cpu_mem_address(30 downto 28) = "000" and reset_dmni = '0' else '0'; dmni_enable_internal_ram <= '1' when dmni_mem_address(30 downto 28) = "000" else '0'; end_sim_reg <= x"00000000" when cpu_mem_address_reg = END_SIM and write_enable = '1' else x"00000001"; irq_status(7 downto 4) <= "00" & ni_intr & '0'; @@ -337,7 +339,8 @@ begin cpu_set_op <= '1' when cpu_mem_address_reg = DMNI_OP and write_enable = '1' else '0'; cpu_start <= '1' when cpu_mem_address_reg = START_DMNI and write_enable = '1' else '0'; cpu_set_buff <= '1' when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER and write_enable = '1' else '0'; - cpu_set_reset <= '1' when cpu_mem_address_reg = SET_CPU_KILL else '0'; + cpu_set_reset <= '1' when cpu_mem_address_reg = SET_CPU_KILL and write_enable = '1' else '0'; + req_read <= '1' when cpu_mem_address_reg = DMNI_REQ_FIFO and write_enable = '0' else '0'; write_enable <= '1' when cpu_mem_write_byte_enable_reg /= "0000" else '0'; diff --git a/hardware/vhdl/standards.vhd b/hardware/vhdl/standards.vhd index 0f0f020..4e280e9 100644 --- a/hardware/vhdl/standards.vhd +++ b/hardware/vhdl/standards.vhd @@ -56,6 +56,7 @@ package standards is constant DMNI_SEND_ACTIVE : std_logic_vector(31 downto 0) := x"20000250"; constant DMNI_RECEIVE_ACTIVE : std_logic_vector(31 downto 0) := x"20000260"; constant DMNI_RECEIVE_BUFFER : std_logic_vector(31 downto 0) := x"20000264"; + constant DMNI_REQ_FIFO : std_logic_vector(31 downto 0) := x"20000268"; constant SCHEDULING_REPORT : std_logic_vector(31 downto 0) := x"20000270"; @@ -82,6 +83,13 @@ package standards is constant TC : integer := 7; constant TR : integer := 8; + ----------------------------------------------------------------------------- + -- DMNI Hardware handled operations + ----------------------------------------------------------------------------- + constant DMMA_OPERATION : std_logic_vector(31 downto 0) := x"00000290"; + constant START_CPU_OPERATION : std_logic_vector(31 downto 0) := x"00000300"; + constant REQ_OPERATION : std_logic_vector(31 downto 0) := x"00000480"; + --------------------------------------------------------- -- CONSTANTS INDEPENDENTES --------------------------------------------------------- diff --git a/software/bareOS/comm.c b/software/bareOS/comm.c index e98b680..20916b3 100644 --- a/software/bareOS/comm.c +++ b/software/bareOS/comm.c @@ -1,14 +1,17 @@ #include "include/libos.h" +static void *send_buff = NULL; + void transmit(flit_t target, flit_t service, void *msg, size_t len) { static const flit_t zero = 0; static mac_header_t p; - len = align_type(len, flit_t); - + while (MemoryRead32(DMNI_SEND_ACTIVE)); + + len = (len + 3) >> 2; p.header = target; - p.payload_size = (MAC_HEADER_LEN-2) + (len ? len : 1); // 3 devido ao service header - 2 flits da noc + p.payload_size = (MAC_HEADER_LEN-2) + (len ? len : 1); p.service = service; // Configure DMNI for package header transmission @@ -17,8 +20,12 @@ void transmit(flit_t target, flit_t service, // Configure DMNI for package payload transmission if(len) { + free(send_buff); + if(!(send_buff = malloc(len<<2))) + panic("Cannot allocate memory for transmit buffer.\n"); + memcpy(send_buff, msg, len<<2); MemoryWrite32(DMNI_SIZE_2, len); - MemoryWrite32(DMNI_ADDRESS_2, (size_t)msg); + MemoryWrite32(DMNI_ADDRESS_2, (size_t)send_buff); } else { MemoryWrite32(DMNI_SIZE_2, 1); MemoryWrite32(DMNI_ADDRESS_2, (size_t)(&zero)); @@ -26,16 +33,57 @@ void transmit(flit_t target, flit_t service, MemoryWrite32(DMNI_OP, READ); MemoryWrite32(DMNI_START, 1); - - while (MemoryRead32(DMNI_SEND_ACTIVE)); } -volatile void *prepare_receive(volatile void *buff) { +void *prepare_receive(void *buff) { + if((size_t)buff & 3) + panic("unalighned buffer %p", buff); + buff = (void*)align((size_t)buff, 2); MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)buff); return buff; } -void wait_receive(){ - while(!(MemoryRead32(DMNI_RECEIVE_BUFFER) & 1)); +void *wait_receive(){ + uint32_t ret; + while(!((ret = MemoryRead32(DMNI_RECEIVE_BUFFER)) & 1)); + return (void*)(ret & -4); +} + +void send_msg(flit_t target, void *msg, size_t len) { + msg_req_t msg_req; + volatile msg_req_t *ack; + + msg_req.addr = MemoryRead32(NET_ADDRESS); + msg_req.size = (len+3) >> 2; + + transmit(target, REQ_OPERATION, &msg_req, sizeof(msg_req_t)); + prepare_receive(&msg_req); + ack = wait_receive(); + + transmit(target, DMA_OPERATION, msg, len); +} + +void *prepare_recv_msg(flit_t *src, size_t *size) { + uint32_t reqi; + msg_req_t *req = (msg_req_t*)&reqi; + void *buff; + + while(!(reqi = MemoryRead32(DMNI_REQ_FIFO))); + + printf("read %X from REQ_FIFO at %p\n", reqi, req); + + if(!(buff = malloc(req->size << 2))) { + puts("Could not allocated memory for message reception\n"); + return NULL; + } + + prepare_receive(buff); + + if(src) *src = req->addr; + if(size) *size = req->size; + + transmit(req->addr, DMA_OPERATION, req, sizeof(msg_req_t)); + + return buff; } diff --git a/software/bareOS/crt0.s b/software/bareOS/crt0.s index 8689838..c828e9e 100644 --- a/software/bareOS/crt0.s +++ b/software/bareOS/crt0.s @@ -20,7 +20,3 @@ _entry: or $4, $2, $0 .set reorder .end _entry - - .section data - .global _mem_end_ptr -_mem_end_ptr: .word _stack diff --git a/software/bareOS/hal.c b/software/bareOS/hal.c index 1637591..5c35a54 100644 --- a/software/bareOS/hal.c +++ b/software/bareOS/hal.c @@ -26,6 +26,6 @@ void puts(const char *string) { //PS: This indicates a hardware developer putting its hands on software development //PS2: The original author need to review demorgans law for boolean simplification for(str_part = (int*)string, MemoryWrite32(UART_WRITE, *str_part); - ((char*)str_part)[0] && ((char*)str_part )[1] && ((char*)str_part )[2] && ((char*)str_part)[3]; + ((char*)str_part)[0] && ((char*)str_part)[1] && ((char*)str_part)[2] && ((char*)str_part)[3]; MemoryWrite32(UART_WRITE, *(++str_part))); } diff --git a/software/bareOS/include/comm.h b/software/bareOS/include/comm.h index ae185f2..0baca34 100644 --- a/software/bareOS/include/comm.h +++ b/software/bareOS/include/comm.h @@ -2,6 +2,7 @@ #define _COMM_H #include "prototypes.h" +//#include /* Manual Routing destination ports */ #define MANUAL_EAST 0x80000000 @@ -24,10 +25,18 @@ typedef struct { flit_t service; } mac_header_t; +typedef struct { + uint16_t addr; + uint16_t size; +} msg_req_t; + void transmit(flit_t target, flit_t service, void *msg, size_t len); -volatile void *prepare_receive(volatile void *buff); -void wait_receive(); +void *prepare_receive(void *buff); +void *wait_receive(); + +void send_msg(flit_t target, void *msg, size_t len); +void *prepare_recv_msg(flit_t *src, size_t *size); #endif /* !_COMM_H */ diff --git a/software/bareOS/include/hal.h b/software/bareOS/include/hal.h index bcca3e5..09a40fa 100644 --- a/software/bareOS/include/hal.h +++ b/software/bareOS/include/hal.h @@ -7,11 +7,11 @@ //pointer to the end of static program memory extern uint8_t _end; //assumes _stack points to the end of the memory -extern uint8_t* _mem_end_ptr; +extern uint8_t _stack; #define MALLOC_ALIGNMENT 4 #define HEAP_START ((void*)&_end) -#define HEAP_END ((void*)(_mem_end_ptr-1024)) // stack - 1kB +#define HEAP_END ((void*)((&_stack)-1024)) // stack - 1kB #define HEAP_ALLOCATION_GRAIN 10 //1kB /*********** Hardware addresses ***********/ @@ -45,8 +45,8 @@ extern uint8_t* _mem_end_ptr; #define CPU_KILL_MAGIC 0xDEADBEAF /* DMNI */ -#define DMNI_SIZE_2 0x20000205 -#define DMNI_ADDRESS_2 0x20000215 +#define DMNI_SIZE_2 0x20000204 +#define DMNI_ADDRESS_2 0x20000214 #define DMNI_SIZE 0x20000200 #define DMNI_ADDRESS 0x20000210 #define DMNI_OP 0x20000220 @@ -55,6 +55,7 @@ extern uint8_t* _mem_end_ptr; #define DMNI_SEND_ACTIVE 0x20000250 #define DMNI_RECEIVE_ACTIVE 0x20000260 #define DMNI_RECEIVE_BUFFER 0x20000264 +#define DMNI_REQ_FIFO 0x20000268 //Scheduling report #define SCHEDULING_REPORT 0x20000270 diff --git a/software/bareOS/include/libos.h b/software/bareOS/include/libos.h index 567cb95..8d8789a 100644 --- a/software/bareOS/include/libos.h +++ b/software/bareOS/include/libos.h @@ -46,5 +46,10 @@ void *malloc(size_t size); void *calloc(size_t qty, size_t type_size); void free(void *ap); void exit(int code) __attribute__ ((noreturn)); +int strcmp(const char *a, const char *b); +size_t srtlen(const char *a); + +void panic(const char *fmt, ...) + __attribute__((format(printf, 1, 2),noreturn)); #endif /* !_LIBOS_H */ diff --git a/software/bareOS/include/prototypes.h b/software/bareOS/include/prototypes.h index 18b31ca..b77a280 100644 --- a/software/bareOS/include/prototypes.h +++ b/software/bareOS/include/prototypes.h @@ -1,7 +1,6 @@ #ifndef PROTOTYPES_H #define PROTOTYPES_H -#ifdef __GNUC__ typedef char int8_t; typedef short int16_t; typedef int int32_t; @@ -11,7 +10,7 @@ typedef unsigned short uint16_t; typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef __SIZE_TYPE__ size_t; -#endif + #define NULL ((void*)0) diff --git a/software/bareOS/libos.c b/software/bareOS/libos.c index 6b29746..0cbd267 100644 --- a/software/bareOS/libos.c +++ b/software/bareOS/libos.c @@ -119,6 +119,33 @@ void *memcpy(void *dst, const void *src, size_t bytes) { return dst; } +int strcmp(const char *a, const char *b) { + while(*a && *b && *a == *b) a++, b++; + + return *a - *b; +} + +size_t strlen(const char *a) { + size_t ret; + + for(ret = 0 ; *a ; a++, ret++); + + return ret; +} + +void panic(const char *fmt, ...) { + va_list ap; + int ret; + + puts("PANIC: "); + + va_start(ap, fmt); + ret = vprintf(fmt, ap); + va_end(ap); + + exit(-1); +} + int printf(const char *fmt, ...) { va_list ap; int ret; diff --git a/software/bareOS/malloc.c b/software/bareOS/malloc.c index 07646c7..8486b2b 100644 --- a/software/bareOS/malloc.c +++ b/software/bareOS/malloc.c @@ -16,15 +16,17 @@ static header_t *morecore(size_t nunits) { size_t size; size = align_type(min(align(nunits*sizeof(header_t), HEAP_ALLOCATION_GRAIN), - ((size_t)lastp)-((size_t)HEAP_END)), - header_t)/sizeof(header_t); + ((size_t)lastp)-((size_t)HEAP_END)), header_t); + size /= sizeof(header_t); - if(((void*)lastp <= HEAP_END) || size < nunits) + if(((void*)lastp >= HEAP_END) || size < nunits) return NULL; p = lastp; - p->size = size; lastp += size; + + p->size = size; + free(p+1); return p; } @@ -63,11 +65,10 @@ void *malloc(size_t nbytes) { void free(void *ap) { header_t *bp, *p; int critical; - bp = (header_t *)ap - 1; -#ifdef DEBUG - printf("free: Freeing %d bytes\n", bp->size*sizeof(header_t)); -#endif + if(!ap) return; + + bp = (header_t *)ap - 1; critical = enter_critical(); From ad82e79073e6363340d1c04ed94406cca0ef1f7f Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Thu, 16 Nov 2017 14:40:23 -0200 Subject: [PATCH 39/54] Message transmission and bareOS passing pc_test --- applications/pc_test/receiver.c | 9 +++-- applications/pc_test/sender.c | 8 +++-- applications/pc_test/transmit.c | 9 ----- build_env/makes/make_app | 4 +-- build_env/makes/sim.do | 2 +- hardware/vhdl/pe/pe.vhd | 2 +- software/bareOS/comm.c | 63 ++++++++++++++++++--------------- software/bareOS/crt0.s | 8 +++-- software/bareOS/hal.c | 2 +- software/bareOS/libos.c | 61 +++++++++++++++---------------- 10 files changed, 82 insertions(+), 86 deletions(-) delete mode 100644 applications/pc_test/transmit.c diff --git a/applications/pc_test/receiver.c b/applications/pc_test/receiver.c index dbf3306..7b3bfc6 100644 --- a/applications/pc_test/receiver.c +++ b/applications/pc_test/receiver.c @@ -1,18 +1,17 @@ #include int main() { - char *msg; + char *msg = NULL; flit_t src; size_t size; do { + free(msg); prepare_recv_msg(&src, &size); - puts("Prepared to receive\n"); + printf("Waiting to receive %d bytes from %X\n", size, src); msg = wait_receive(); - printf("%d bytes received from %X\n", size, src); puts(msg); - free(msg); - } while(strcmp(msg, "END")); + } while(strcmp(msg, "END\n")); return 0; } diff --git a/applications/pc_test/sender.c b/applications/pc_test/sender.c index d94623d..560662f 100644 --- a/applications/pc_test/sender.c +++ b/applications/pc_test/sender.c @@ -2,10 +2,12 @@ #include "map_pkg.h" int main() { - unsigned int i; - char hello[] = "Hello World!\n"; + const char *hello = "Hello World!\n"; - transmit(receiver, DMA_OPERATION, (unsigned int*)hello, (sizeof(hello)+3) >> 2); + send_msg(receiver, hello, strlen(hello)+1); + printf("Message transmited to %X\n", receiver); + send_msg(receiver, "END\n", strlen("END\n")+1); + printf("Termination message sent to %X, terminating\n", receiver); return 0; } diff --git a/applications/pc_test/transmit.c b/applications/pc_test/transmit.c deleted file mode 100644 index 987d951..0000000 --- a/applications/pc_test/transmit.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -int main() { - - send_msg(ROUTER_ADDR(0, 1), "HELLO WORLD\n", strlen("HELLO WORLD\n")+1); - send_msg(ROUTER_ADDR(0, 1), "END", strlen("END")+1); - - return 0; -} diff --git a/build_env/makes/make_app b/build_env/makes/make_app index facd5cf..cb9b9ba 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -2,9 +2,9 @@ BASEDIR = ../.. BAREOS_DIR = $(BASEDIR)/software/bareOS TRIPLET = mips-elf CC = $(TRIPLET)-gcc -CFLAGS = -I$(BAREOS_DIR)/include -O2 -fno-builtin -Wall -fms-extensions -nostdinc -mips1 +CFLAGS = -I$(BAREOS_DIR)/include -O2 -fno-builtin -Wall -fms-extensions -nostdinc AS = $(TRIPLET)-as -ASFLAGS = -mips1 +ASFLAGS = CPP = $(TRIPLET)-g++ CCFLAGS = $(CFLAGS) LD = $(TRIPLET)-ld diff --git a/build_env/makes/sim.do b/build_env/makes/sim.do index 1764d56..ce51019 100644 --- a/build_env/makes/sim.do +++ b/build_env/makes/sim.do @@ -1,4 +1,4 @@ -vsim -novopt -t ps +notimingchecks hardware/work.test_bench +vsim -voptargs=+acc=lprn -t ps +notimingchecks hardware/work.test_bench do wave.do onerror {resume} diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 4c18127..1c197e7 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -340,7 +340,7 @@ begin cpu_start <= '1' when cpu_mem_address_reg = START_DMNI and write_enable = '1' else '0'; cpu_set_buff <= '1' when cpu_mem_address_reg = DMNI_RECEIVE_BUFFER and write_enable = '1' else '0'; cpu_set_reset <= '1' when cpu_mem_address_reg = SET_CPU_KILL and write_enable = '1' else '0'; - req_read <= '1' when cpu_mem_address_reg = DMNI_REQ_FIFO and write_enable = '0' else '0'; + req_read <= '1' when cpu_mem_address_reg = DMNI_REQ_FIFO and write_enable = '1' else '0'; write_enable <= '1' when cpu_mem_write_byte_enable_reg /= "0000" else '0'; diff --git a/software/bareOS/comm.c b/software/bareOS/comm.c index 20916b3..5d5adba 100644 --- a/software/bareOS/comm.c +++ b/software/bareOS/comm.c @@ -3,28 +3,37 @@ static void *send_buff = NULL; void transmit(flit_t target, flit_t service, - void *msg, size_t len) { + void *msg, size_t msg_len) { static const flit_t zero = 0; static mac_header_t p; + size_t flit_len, len; + // Waiting untill last transmission has finished while (MemoryRead32(DMNI_SEND_ACTIVE)); - len = (len + 3) >> 2; + len = align_type(msg_len, flit_t); + flit_len = len/sizeof(flit_t); + p.header = target; - p.payload_size = (MAC_HEADER_LEN-2) + (len ? len : 1); p.service = service; + p.payload_size = (MAC_HEADER_LEN-2) + (flit_len ? flit_len : 1); // Configure DMNI for package header transmission MemoryWrite32(DMNI_SIZE, MAC_HEADER_LEN); - MemoryWrite32(DMNI_ADDRESS, (size_t)(&p) ); + MemoryWrite32(DMNI_ADDRESS, (size_t)(&p)); // Configure DMNI for package payload transmission - if(len) { + if(flit_len) { free(send_buff); - if(!(send_buff = malloc(len<<2))) + + if(!(send_buff = malloc(len))) panic("Cannot allocate memory for transmit buffer.\n"); - memcpy(send_buff, msg, len<<2); - MemoryWrite32(DMNI_SIZE_2, len); + + memcpy(send_buff, msg, msg_len); + if(len - msg_len) + memset(send_buff+msg_len, 0, len-msg_len); + + MemoryWrite32(DMNI_SIZE_2, flit_len); MemoryWrite32(DMNI_ADDRESS_2, (size_t)send_buff); } else { MemoryWrite32(DMNI_SIZE_2, 1); @@ -35,55 +44,51 @@ void transmit(flit_t target, flit_t service, MemoryWrite32(DMNI_START, 1); } -void *prepare_receive(void *buff) { - if((size_t)buff & 3) - panic("unalighned buffer %p", buff); - +void *prepare_receive(void *buff) { buff = (void*)align((size_t)buff, 2); MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)buff); return buff; } void *wait_receive(){ - uint32_t ret; + size_t ret; while(!((ret = MemoryRead32(DMNI_RECEIVE_BUFFER)) & 1)); return (void*)(ret & -4); } void send_msg(flit_t target, void *msg, size_t len) { msg_req_t msg_req; - volatile msg_req_t *ack; msg_req.addr = MemoryRead32(NET_ADDRESS); msg_req.size = (len+3) >> 2; transmit(target, REQ_OPERATION, &msg_req, sizeof(msg_req_t)); prepare_receive(&msg_req); - ack = wait_receive(); + wait_receive(); transmit(target, DMA_OPERATION, msg, len); } +typedef union { + uint32_t i32; + uint16_t i16[2]; + msg_req_t s; +} msg_req_u; + void *prepare_recv_msg(flit_t *src, size_t *size) { - uint32_t reqi; - msg_req_t *req = (msg_req_t*)&reqi; + static msg_req_u req; void *buff; - while(!(reqi = MemoryRead32(DMNI_REQ_FIFO))); + while(!(req.i32 = MemoryRead32(DMNI_REQ_FIFO))); + MemoryWrite32(DMNI_REQ_FIFO, 0); - printf("read %X from REQ_FIFO at %p\n", reqi, req); - - if(!(buff = malloc(req->size << 2))) { - puts("Could not allocated memory for message reception\n"); + if(!(buff = malloc(req.s.size << 2))) return NULL; - } - prepare_receive(buff); - - if(src) *src = req->addr; - if(size) *size = req->size; + if(src) *src = req.s.addr; + if(size) *size = req.s.size << 2; - transmit(req->addr, DMA_OPERATION, req, sizeof(msg_req_t)); + transmit(req.s.addr, DMA_OPERATION, &req, sizeof(msg_req_t)); - return buff; + return prepare_receive(buff); } diff --git a/software/bareOS/crt0.s b/software/bareOS/crt0.s index c828e9e..26088d4 100644 --- a/software/bareOS/crt0.s +++ b/software/bareOS/crt0.s @@ -4,15 +4,17 @@ .set noreorder _entry: la $sp, _stack + addiu $sp, $sp, 3 + li $2, -4 + and $sp, $sp, $2 la $gp, _gp la $4, _bss_start la $5, _bss_end .clr_bss: beq $4, $5, .clr_bss_done - nop - sw $0, 0($4) - beq $0, $0, .clr_bss addiu $4, $4, 4 + beq $0, $0, .clr_bss + sw $0, -4($4) .clr_bss_done: jal main nop diff --git a/software/bareOS/hal.c b/software/bareOS/hal.c index 5c35a54..b5518a0 100644 --- a/software/bareOS/hal.c +++ b/software/bareOS/hal.c @@ -17,7 +17,7 @@ void exit(int code) { } void putchar(char c) { - MemoryWrite32(UART_WRITE, (uint32_t)c); + MemoryWrite32(UART_WRITE, (uint32_t)c<<24); } void puts(const char *string) { diff --git a/software/bareOS/libos.c b/software/bareOS/libos.c index 0cbd267..78a837b 100644 --- a/software/bareOS/libos.c +++ b/software/bareOS/libos.c @@ -50,30 +50,40 @@ char *itoa(int i, char *s, int base){ return s; } +union ptr { + const void *v; + uint8_t *uint8; + uint16_t *uint16; + uint32_t *uint32; +}; + + void *memset(void *dst, int ic, size_t bytes) { uint8_t c; uint32_t f; + union ptr d = {.v = dst}; + /* Probably the most assemblish code ever written in C! * This is what you get when you put a processor designer * to write software */ c = ic; - f = (c << 24) | (c << 16) | (c << 8) | c; switch(bytes & 3) { case 3: - *((uint8_t*)dst++) = c; + *(d.uint8++) = c; bytes--; case 2: - *((uint8_t*)dst++) = c; + *(d.uint8++) = c; bytes--; case 1: - *((uint8_t*)dst++) = c; + *(d.uint8++) = c; bytes--; case 0: + f = (c << 24) | (c << 16) | (c << 8) | c; while(bytes){ - *((uint32_t*)dst++) = f; + *(d.uint32++) = f; bytes -= 4; } } @@ -83,36 +93,23 @@ void *memset(void *dst, int ic, size_t bytes) { void *memcpy(void *dst, const void *src, size_t bytes) { - switch(bytes & 3) { - case 3: - *((uint8_t*)dst++) = *((uint8_t*)src++); - bytes--; - case 2: - *((uint8_t*)dst++) = *((uint8_t*)src++); - bytes--; - case 1: - *((uint8_t*)dst++) = *((uint8_t*)src++); - bytes--; - case 0: - switch(((size_t)dst | (size_t)src) & 3) { - case 1: - case 3: - while(bytes){ - *((uint8_t*)dst++) = *((uint8_t*)src++); - bytes--; - } + union ptr d = {.v = dst} , s = {.v = src}; + + while(bytes) { + switch(((size_t)d.v | (size_t)s.v | bytes) & 3) { + case 0: + *(d.uint32++) = *(s.uint32++); + bytes-=4; break; case 2: - while(bytes){ - *((uint16_t*)dst++) = *((uint16_t*)src++); - bytes-=2; - } + *(d.uint16++) = *(s.uint16++); + bytes-=2; + break; + case 1: + case 3: + *(d.uint8++) = *(s.uint8++); + bytes--; break; - case 0: - while(bytes){ - *((uint32_t*)dst++) = *((uint32_t*)src++); - bytes-=4; - } } } From 5c2b8be7375d8c7548e59b2b7920ca9080f0038f Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 17 Nov 2017 09:19:58 -0200 Subject: [PATCH 40/54] master slave quicksort application added --- applications/sort/master.c | 80 ++++++++++++++++++++++++++++++++++++++ applications/sort/slave1.c | 28 +++++++++++++ applications/sort/slave2.c | 28 +++++++++++++ applications/sort/slave3.c | 28 +++++++++++++ applications/sort/sort.h | 80 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 244 insertions(+) create mode 100644 applications/sort/master.c create mode 100644 applications/sort/slave1.c create mode 100644 applications/sort/slave2.c create mode 100644 applications/sort/slave3.c create mode 100644 applications/sort/sort.h diff --git a/applications/sort/master.c b/applications/sort/master.c new file mode 100644 index 0000000..c0836a2 --- /dev/null +++ b/applications/sort/master.c @@ -0,0 +1,80 @@ +#include +#include "map_pkg.h" + +#include "sort.h" + +#define TASKS 40 +#define SLAVES 3 + +void init_array(int *array, int size){ + int i; + + for (i = 0; i < size; i++) + array[i] = size - i; +} + +void print_array(int *array, int size){ + int i; + for (i = 0; i < size; i++) { + puts(itoasc(array[i])); + puts(" "); + } + puts("\n"); + +} + +int get_id(int src) { + if (src==slave1) + return 0; + if (src==slave2) + return 1; + if (src==slave3) + return 2; +} + +int main(){ + int i; + int *buff; + int slave_addr[SLAVES] = {slave1, slave2, slave3}; + + int array[TASKS][ARRAY_SIZE]; + int slave_task[SLAVES]; + int task = 0; + int slave_id; + + int msg_kill; + flit_t src; + size_t size; + + for (i = 0; i < TASKS; i++) + init_array(array[i], ARRAY_SIZE); + + for (i = 0; i < SLAVES; i++){ + prepare_recv_msg(&src, &size); + printf("Waiting to receive %d bytes from slave %X\n", size, src); + buff = wait_receive(); + puts(itoasc(buff[0])); + puts("\n"); + slave_task[buff[0]] = task; + send_msg(slave_addr[buff[0]], (unsigned int*)array[task], ARRAY_SIZE*4); + task++; + } + + for (i = 0; i < TASKS; i++){ + prepare_recv_msg(&src, &size); + printf("Waiting to receive %d bytes from slave %X\n", size, src); + buff = wait_receive(); + print_array(buff, ARRAY_SIZE); + slave_id = get_id(src); + slave_task[slave_id] = task; + if (task == TASKS){ + send_msg(slave_addr[slave_id], &msg_kill, 4); + printf("Master Sening kill to %X\n", src); + } + else { + send_msg(slave_addr[slave_id], (unsigned int*)array[task], ARRAY_SIZE*4); + task++; + } + } + +} diff --git a/applications/sort/slave1.c b/applications/sort/slave1.c new file mode 100644 index 0000000..ce2e5ad --- /dev/null +++ b/applications/sort/slave1.c @@ -0,0 +1,28 @@ +#include +#include "map_pkg.h" + +#include "sort.h" + +#define SLAVE_ID 0 + +int main(){ + int task_request[2]; + int *array; + + flit_t src; + size_t size; + + task_request[0] = SLAVE_ID; + task_request[1] = TASK_REQUEST; + /*Requests initial task*/ + send_msg(master, &task_request, 2*4); + + /* Wait for a task, execute and return result to master*/ + for (;;) { + prepare_recv_msg(&src, &size); + array=wait_receive(); + if (size < ARRAY_SIZE*4) break; + quicksort(array, 0, ARRAY_SIZE-1); + send_msg(master, (unsigned int*)array, ARRAY_SIZE*4); + } +} \ No newline at end of file diff --git a/applications/sort/slave2.c b/applications/sort/slave2.c new file mode 100644 index 0000000..6c6e67c --- /dev/null +++ b/applications/sort/slave2.c @@ -0,0 +1,28 @@ +#include +#include "map_pkg.h" + +#include "sort.h" + +#define SLAVE_ID 1 + +int main(){ + int task_request[2]; + int *array; + + flit_t src; + size_t size; + + task_request[0] = SLAVE_ID; + task_request[1] = TASK_REQUEST; + /*Requests initial task*/ + send_msg(master, &task_request, 2*4); + + /* Wait for a task, execute and return result to master*/ + for (;;) { + prepare_recv_msg(&src, &size); + array=wait_receive(); + if (size < ARRAY_SIZE*4) break; + quicksort(array, 0, ARRAY_SIZE-1); + send_msg(master, (unsigned int*)array, ARRAY_SIZE*4); + } +} \ No newline at end of file diff --git a/applications/sort/slave3.c b/applications/sort/slave3.c new file mode 100644 index 0000000..7741e5a --- /dev/null +++ b/applications/sort/slave3.c @@ -0,0 +1,28 @@ +#include +#include "map_pkg.h" + +#include "sort.h" + +#define SLAVE_ID 2 + +int main(){ + int task_request[2]; + int *array; + + flit_t src; + size_t size; + + task_request[0] = SLAVE_ID; + task_request[1] = TASK_REQUEST; + /*Requests initial task*/ + send_msg(master, &task_request, 2*4); + + /* Wait for a task, execute and return result to master*/ + for (;;) { + prepare_recv_msg(&src, &size); + array=wait_receive(); + if (size < ARRAY_SIZE*4) break; + quicksort(array, 0, ARRAY_SIZE-1); + send_msg(master, (unsigned int*)array, ARRAY_SIZE*4); + } +} \ No newline at end of file diff --git a/applications/sort/sort.h b/applications/sort/sort.h new file mode 100644 index 0000000..91b9bfe --- /dev/null +++ b/applications/sort/sort.h @@ -0,0 +1,80 @@ +#include + +#define ARRAY_SIZE 40 +#define LFSR_POL 0xA3000000 + +#define TASK_REQUEST 1 +#define KILL_PROC 2 +#define MSG_ACK 3 + +char *itoasc(unsigned int num) +{ + static char buf[12]; + static char buf2[12]; + int i,j; + + if (num==0) + { + buf[0] = '0'; + buf[1] = '\0'; + return &buf[0]; + } + + for(i=0;i<11 && num!=0;i++) + { + buf[i]=(char)((num%10)+'0'); + num/=10; + } + buf2[i] = '\0'; + j = 0; + i--; + for(;i>=0;i--){ + buf2[i]=buf[j]; + j++; + } + return &buf2[0]; +} + +unsigned int rand_val = LFSR_POL; + +unsigned int rand(){ + rand_val = (rand_val >> 1) ^ (-(rand_val & 1u) & LFSR_POL); + return rand_val; +} + +void swap(int *array, int a, int b){ + int aux; + + aux = array[a]; + array[a] = array[b]; + array[b] = aux; +} + +int partition(int *array, int lo, int hi){ + int pivo, i, j; + int index; + + i = lo - 1; + index = rand() % (hi - lo) + lo; + swap(array, index, hi); + pivo = array[hi]; + + for (j = lo; j < hi; j++){ + if (array[j] < pivo){ + i++; + swap(array, i, j); + } + } + if (array[hi] < array[i+1]) + swap(array, i+1, hi); + return i+1; +} + +void quicksort(int *array, int lo, int hi) { + int p; + if (lo < hi){ + p = partition(array, lo, hi); + quicksort(array, lo, p - 1); + quicksort(array, p + 1, hi); + } +} From 35f851eb45c1a6e04784346d402a516fe8376e52 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 17 Nov 2017 09:21:47 -0200 Subject: [PATCH 41/54] fixed a bug in req fifo --- hardware/vhdl/pe/dmni/dmni.vhd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/vhdl/pe/dmni/dmni.vhd b/hardware/vhdl/pe/dmni/dmni.vhd index 15f1d92..1b69c99 100644 --- a/hardware/vhdl/pe/dmni/dmni.vhd +++ b/hardware/vhdl/pe/dmni/dmni.vhd @@ -386,7 +386,7 @@ begin if (read_av = '1') then if (recv_size = sizedata_fix) then if req_slot_avail = '1' then - req_fifo(conv_integer(req_rcount(2 downto 0))) <= bufferr(CONV_INTEGER(first)); + req_fifo(conv_integer(req_wcount(2 downto 0))) <= bufferr(CONV_INTEGER(first)); req_we <= '1'; first <= first + 1; From 365ad9cda067ddfc92128d4653f17e9a28695bd8 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 17 Nov 2017 09:23:10 -0200 Subject: [PATCH 42/54] add testcase for quicksort application deploy --- testcases/sort.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 testcases/sort.yaml diff --git a/testcases/sort.yaml b/testcases/sort.yaml new file mode 100644 index 0000000..bc60b47 --- /dev/null +++ b/testcases/sort.yaml @@ -0,0 +1,23 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: vhdl + noc_buffer_size: 8 + mpsoc_dimension: [3,2] + cluster_dimension: [3,2] + master_location: LB + simple_soc: true + open_port: + - port: [0,0,S] +apps: + - name: sort + tasks: + - task: master + location: [1,1] + - task: slave1 + location: [1,0] + - task: slave2 + location: [2,1] + - task: slave3 + location: [2,0] \ No newline at end of file From c28f6978f6f1a8e7ef74150dbce374cfc623cafd Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 1 Dec 2017 09:06:14 -0200 Subject: [PATCH 43/54] improvements on sort source code --- applications/sort/master.c | 11 ++++++----- applications/sort/slave1.c | 4 ++-- applications/sort/slave2.c | 4 ++-- applications/sort/slave3.c | 4 ++-- applications/sort/sort.h | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/applications/sort/master.c b/applications/sort/master.c index c0836a2..837e4f5 100644 --- a/applications/sort/master.c +++ b/applications/sort/master.c @@ -42,7 +42,7 @@ int main(){ int task = 0; int slave_id; - int msg_kill; + int msg_kill = KILL_PROC; flit_t src; size_t size; @@ -56,7 +56,8 @@ int main(){ puts(itoasc(buff[0])); puts("\n"); slave_task[buff[0]] = task; - send_msg(slave_addr[buff[0]], (unsigned int*)array[task], ARRAY_SIZE*4); + send_msg(slave_addr[buff[0]], (unsigned int*)array[task], sizeof(array[task])); + free(buff); task++; } @@ -65,16 +66,16 @@ int main(){ printf("Waiting to receive %d bytes from slave %X\n", size, src); buff = wait_receive(); print_array(buff, ARRAY_SIZE); + free(buff); slave_id = get_id(src); slave_task[slave_id] = task; if (task == TASKS){ - send_msg(slave_addr[slave_id], &msg_kill, 4); + send_msg(slave_addr[slave_id], &msg_kill, sizeof(msg_kill)); printf("Master Sening kill to %X\n", src); } else { - send_msg(slave_addr[slave_id], (unsigned int*)array[task], ARRAY_SIZE*4); + send_msg(slave_addr[slave_id], (unsigned int*)array[task], sizeof(array[task])); task++; } } - } diff --git a/applications/sort/slave1.c b/applications/sort/slave1.c index ce2e5ad..a51ecd7 100644 --- a/applications/sort/slave1.c +++ b/applications/sort/slave1.c @@ -15,13 +15,13 @@ int main(){ task_request[0] = SLAVE_ID; task_request[1] = TASK_REQUEST; /*Requests initial task*/ - send_msg(master, &task_request, 2*4); + send_msg(master, &task_request, sizeof(task_request)); /* Wait for a task, execute and return result to master*/ for (;;) { prepare_recv_msg(&src, &size); array=wait_receive(); - if (size < ARRAY_SIZE*4) break; + if (array[0] == KILL_PROC) break; quicksort(array, 0, ARRAY_SIZE-1); send_msg(master, (unsigned int*)array, ARRAY_SIZE*4); } diff --git a/applications/sort/slave2.c b/applications/sort/slave2.c index 6c6e67c..1a56485 100644 --- a/applications/sort/slave2.c +++ b/applications/sort/slave2.c @@ -15,13 +15,13 @@ int main(){ task_request[0] = SLAVE_ID; task_request[1] = TASK_REQUEST; /*Requests initial task*/ - send_msg(master, &task_request, 2*4); + send_msg(master, &task_request, sizeof(task_request)); /* Wait for a task, execute and return result to master*/ for (;;) { prepare_recv_msg(&src, &size); array=wait_receive(); - if (size < ARRAY_SIZE*4) break; + if (array[0] == KILL_PROC) break; quicksort(array, 0, ARRAY_SIZE-1); send_msg(master, (unsigned int*)array, ARRAY_SIZE*4); } diff --git a/applications/sort/slave3.c b/applications/sort/slave3.c index 7741e5a..13a0069 100644 --- a/applications/sort/slave3.c +++ b/applications/sort/slave3.c @@ -15,13 +15,13 @@ int main(){ task_request[0] = SLAVE_ID; task_request[1] = TASK_REQUEST; /*Requests initial task*/ - send_msg(master, &task_request, 2*4); + send_msg(master, &task_request, sizeof(task_request)); /* Wait for a task, execute and return result to master*/ for (;;) { prepare_recv_msg(&src, &size); array=wait_receive(); - if (size < ARRAY_SIZE*4) break; + if (array[0] == KILL_PROC) break; quicksort(array, 0, ARRAY_SIZE-1); send_msg(master, (unsigned int*)array, ARRAY_SIZE*4); } diff --git a/applications/sort/sort.h b/applications/sort/sort.h index 91b9bfe..1c7aa76 100644 --- a/applications/sort/sort.h +++ b/applications/sort/sort.h @@ -3,9 +3,9 @@ #define ARRAY_SIZE 40 #define LFSR_POL 0xA3000000 -#define TASK_REQUEST 1 -#define KILL_PROC 2 -#define MSG_ACK 3 +#define TASK_REQUEST 0x1000 +#define KILL_PROC 0x2000 +#define MSG_ACK 0x3000 char *itoasc(unsigned int num) { From 428c9c1aa833bf5003f347e98e0ec6b98e5cc261 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 1 Dec 2017 09:14:05 -0200 Subject: [PATCH 44/54] Changes to simplify testcase definition --- build_env/makes/make_testcase | 2 +- build_env/makes/make_vhdl | 2 +- build_env/scripts/app_builder.py | 4 ++-- build_env/scripts/hw_builder.py | 16 ++++++++-------- build_env/scripts/kernel_builder.py | 12 ++++++------ build_env/testcase_builder.py | 6 +++--- hardware/vhdl/hemps.vhd | 2 +- hardware/vhdl/pe/pe.vhd | 4 ++-- hardware/vhdl/test_bench.vhd | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/build_env/makes/make_testcase b/build_env/makes/make_testcase index ee2de40..d583a9d 100644 --- a/build_env/makes/make_testcase +++ b/build_env/makes/make_testcase @@ -3,7 +3,7 @@ TC_NAME=$(notdir ${CURDIR}) default: all -all: banner apps kernel hw +all: banner kernel apps hw update: @cd ..; hemps-gen $(TC_NAME).yaml 1; cd $(TC_NAME); make clean; make all; cd ..; diff --git a/build_env/makes/make_vhdl b/build_env/makes/make_vhdl index ce4f7c3..9c85ca9 100644 --- a/build_env/makes/make_vhdl +++ b/build_env/makes/make_vhdl @@ -11,7 +11,7 @@ STAND =standards TOP =hemps receive_data inject_data test_bench PE =pe DMNI =dmni -MEMORY =ram_master ram_slave ram_simple +MEMORY =ram_simple ram_master ram_slave PROCESSOR =mlite_pack UartFile alu bus_mux control mem_ctrl mult pc_next pipeline reg_bank shifter mlite_cpu ROUTER =Hermes_buffer Hermes_crossbar Hermes_switchcontrol RouterCC diff --git a/build_env/scripts/app_builder.py b/build_env/scripts/app_builder.py index b3791bd..ce16298 100644 --- a/build_env/scripts/app_builder.py +++ b/build_env/scripts/app_builder.py @@ -30,10 +30,10 @@ def main(): sys.exit("\nError compiling applications' source code\n"); #Generate the repository.txt and repository_debug.txt files, returning a list of tuple {app_name, repo_address} - apps_repo_addr_list = generate_repository(yaml_r, apps_name_list); + #apps_repo_addr_list = generate_repository(yaml_r, apps_name_list); #Generates the appstart.txt and appstart_debug.txt files - generate_appstart(apps_repo_addr_list, yaml_r) + #generate_appstart(apps_repo_addr_list, yaml_r) generate_cfg_file(yaml_r) diff --git a/build_env/scripts/hw_builder.py b/build_env/scripts/hw_builder.py index 7895da7..519f795 100644 --- a/build_env/scripts/hw_builder.py +++ b/build_env/scripts/hw_builder.py @@ -29,12 +29,12 @@ def generate_hw_pkg( yaml_r ): #Variables from yaml used into this function x_mpsoc_dim = get_mpsoc_x_dim(yaml_r) y_mpsoc_dim = get_mpsoc_y_dim(yaml_r) - x_cluster_dim = get_cluster_x_dim(yaml_r) - y_cluster_dim = get_cluster_y_dim(yaml_r) - master_location = get_master_location(yaml_r) + x_cluster_dim = get_mpsoc_x_dim(yaml_r) + y_cluster_dim = get_mpsoc_y_dim(yaml_r) + #master_location = get_master_location(yaml_r) system_model_desc = get_model_description(yaml_r) - cluster_list = create_cluster_list(x_mpsoc_dim, y_mpsoc_dim, x_cluster_dim, y_cluster_dim, master_location) + cluster_list = [] #create_cluster_list(x_mpsoc_dim, y_mpsoc_dim, x_cluster_dim, y_cluster_dim, master_location) pe_type = [] #----------- Generates PEs types ---------------- @@ -120,7 +120,7 @@ def generate_to_vhdl(is_master_list, yaml_r): #Variables from yaml used into this function page_size_KB = get_page_size_KB(yaml_r) memory_size_KB = get_memory_size_KB(yaml_r) - repo_size_bytes = get_repository_size_BYTES(yaml_r) + #repo_size_bytes = get_repository_size_BYTES(yaml_r) noc_buffer_size = get_noc_buffer_size(yaml_r) x_mpsoc_dim = get_mpsoc_x_dim(yaml_r) y_mpsoc_dim = get_mpsoc_y_dim(yaml_r) @@ -202,7 +202,7 @@ def generate_to_vhdl(is_master_list, yaml_r): file_lines.append(" -- paging definitions\n") file_lines.append(" constant PAGE_SIZE_BYTES : integer := "+str(page_size_KB*1024)+";\n") file_lines.append(" constant MEMORY_SIZE_BYTES : integer := "+str(memory_size_KB*1024)+";\n") - file_lines.append(" constant TOTAL_REPO_SIZE_BYTES : integer := "+str(repo_size_bytes)+";\n") + #file_lines.append(" constant TOTAL_REPO_SIZE_BYTES : integer := "+str(repo_size_bytes)+";\n") file_lines.append(" constant APP_NUMBER : integer := "+str(app_number)+";\n") file_lines.append(" constant MAX_TASKS_APP : integer := "+str(max_task_per_app)+";\n") file_lines.append(" constant PAGE_SIZE_H_INDEX : integer := "+str(page_size_h_index)+";\n") @@ -216,8 +216,8 @@ def generate_to_vhdl(is_master_list, yaml_r): file_lines.append(" constant IO_NUMBER : integer := "+str(io_number)+";\n") file_lines.append(" constant LOADER_NETADDR : std_logic_vector(31 downto 0) := x\"%x\";\n\n" % loader_addr) file_lines.append(" subtype kernel_str is string(1 to 3);\n") - file_lines.append(" type pe_type_t is array(0 to NUMBER_PROCESSORS-1) of kernel_str;\n") - file_lines.append(" constant pe_type : pe_type_t := ("+string_pe_type_vhdl+");\n\n") + #file_lines.append(" type pe_type_t is array(0 to NUMBER_PROCESSORS-1) of kernel_str;\n") + #file_lines.append(" constant pe_type : pe_type_t := ("+string_pe_type_vhdl+");\n\n") file_lines.append(" subtype manual_io_option is string(1 to 3);\n") file_lines.append(" type manual_io_type is array(0 to NUMBER_PROCESSORS-1) of manual_io_option;\n") file_lines.append(" constant OPEN_IO : manual_io_type := ("+open_ports_string+");\n\n") diff --git a/build_env/scripts/kernel_builder.py b/build_env/scripts/kernel_builder.py index 0311249..6d5ded5 100644 --- a/build_env/scripts/kernel_builder.py +++ b/build_env/scripts/kernel_builder.py @@ -40,9 +40,9 @@ def generate_sw_pkg( yaml_r ): max_local_tasks = get_tasks_per_PE(yaml_r) x_mpsoc_dim = get_mpsoc_x_dim(yaml_r) y_mpsoc_dim = get_mpsoc_y_dim(yaml_r) - x_cluster_dim = get_cluster_x_dim(yaml_r) - y_cluster_dim = get_cluster_y_dim(yaml_r) - master_location = get_master_location(yaml_r) + x_cluster_dim = get_mpsoc_x_dim(yaml_r) + y_cluster_dim = get_mpsoc_y_dim(yaml_r) + master_location = "LB" #get_master_location(yaml_r) apps_list = get_apps_list(yaml_r) static_mapping_list = get_static_mapping_list(yaml_r) @@ -162,10 +162,10 @@ def generate_memory( yaml_r ): #Variables from yaml used into this function x_mpsoc_dim = get_mpsoc_x_dim(yaml_r) y_mpsoc_dim = get_mpsoc_y_dim(yaml_r) - x_cluster_dim = get_cluster_x_dim(yaml_r) - y_cluster_dim = get_cluster_y_dim(yaml_r) + x_cluster_dim = get_mpsoc_x_dim(yaml_r) + y_cluster_dim = get_mpsoc_y_dim(yaml_r) model_descr = get_model_description(yaml_r) - master_location = get_master_location(yaml_r) + master_location = "LB" #get_master_location(yaml_r) mem_size_KB = get_memory_size_KB(yaml_r) diff --git a/build_env/testcase_builder.py b/build_env/testcase_builder.py index a2ab2f4..9fa068e 100644 --- a/build_env/testcase_builder.py +++ b/build_env/testcase_builder.py @@ -84,6 +84,8 @@ def main(): copy_hardware( HEMPS_PATH, TESTCASE_NAME, model_description) copy_makefiles( HEMPS_PATH, TESTCASE_NAME, page_size_KB, memory_size_KB, model_description, apps_name_list, simul_time) copy_testcase_file( TESTCASE_NAME, INPUT_TESTCASE_FILE_PATH) + #Calls the hemps-wave_gen script if + generate_wave(INPUT_TESTCASE_FILE_PATH) #Create other importatants dirs create_ifn_exists(TESTCASE_NAME+"/include") @@ -91,9 +93,7 @@ def main(): #Calls the deloream_env.py to generate all necessary debugging dir and files generate_deloream_env(TESTCASE_NAME, yaml_reader) - - #Calls the hemps-wave_gen script if - generate_wave(INPUT_TESTCASE_FILE_PATH) + # ----------------------------------------- FUNCTIONS --------------------------------------------- diff --git a/hardware/vhdl/hemps.vhd b/hardware/vhdl/hemps.vhd index e52424c..53876f7 100644 --- a/hardware/vhdl/hemps.vhd +++ b/hardware/vhdl/hemps.vhd @@ -89,7 +89,7 @@ begin PE : entity work.pe generic map ( router_address => RouterAddress(i), - kernel_type => pe_type(i), + kernel_type => "sla", log_file => log_filename(i), simple_soc => SIMPLE_SOC, manual_NORTH => ManualNORTHbyPos(i), diff --git a/hardware/vhdl/pe/pe.vhd b/hardware/vhdl/pe/pe.vhd index 1c197e7..9f90873 100644 --- a/hardware/vhdl/pe/pe.vhd +++ b/hardware/vhdl/pe/pe.vhd @@ -157,7 +157,7 @@ begin address_b => addr_b, data_write_b => dmni_mem_data_write, data_read_b => mem_data_read - ); + ); end generate; slave : if kernel_type = "sla" and simple_soc = false generate @@ -174,7 +174,7 @@ begin address_b => addr_b, data_write_b => dmni_mem_data_write, data_read_b => mem_data_read - ); + ); end generate; simple_soc_ram : if simple_soc = true generate diff --git a/hardware/vhdl/test_bench.vhd b/hardware/vhdl/test_bench.vhd index 049f7ae..5fe2325 100644 --- a/hardware/vhdl/test_bench.vhd +++ b/hardware/vhdl/test_bench.vhd @@ -37,7 +37,7 @@ entity test_bench is constant ram_description : string := "RTL"; constant router_description : string := "RTL"; - constant REPO_SIZE : integer := (TOTAL_REPO_SIZE_BYTES/4); --This math is because each repoline is 32 bits word + constant REPO_SIZE : integer := (MEMORY_SIZE_BYTES/4); --This math is because each repoline is 32 bits word constant TAM_PACKSTART : integer := 4; type repo_type is array(REPO_SIZE-1 downto 0) of std_logic_vector(31 downto 0); From 332cb5cead4c2a4d22d6d0861acf2d7926128ffe Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 1 Dec 2017 09:15:13 -0200 Subject: [PATCH 45/54] removed unecessary parameters --- testcases/sort.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/testcases/sort.yaml b/testcases/sort.yaml index bc60b47..d371399 100644 --- a/testcases/sort.yaml +++ b/testcases/sort.yaml @@ -1,12 +1,9 @@ hw: - page_size_KB: 32 tasks_per_PE: 1 - repository_size_MB: 1 + page_size_KB: 32 model_description: vhdl noc_buffer_size: 8 mpsoc_dimension: [3,2] - cluster_dimension: [3,2] - master_location: LB simple_soc: true open_port: - port: [0,0,S] @@ -20,4 +17,4 @@ apps: - task: slave2 location: [2,1] - task: slave3 - location: [2,0] \ No newline at end of file + location: [2,0] From 16e6cfdb3061da7f1c6d478a335921e5d2a864d5 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 1 Dec 2017 09:26:24 -0200 Subject: [PATCH 46/54] fixed bug on map_pkg.h generation --- build_env/scripts/app_builder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build_env/scripts/app_builder.py b/build_env/scripts/app_builder.py index ce16298..b2a6619 100644 --- a/build_env/scripts/app_builder.py +++ b/build_env/scripts/app_builder.py @@ -119,14 +119,14 @@ def generate_map_pkg(yaml_r): app_list = get_apps_list(yaml_r) - file_lines = [] - #---------------- C SINTAX ------------------ - file_lines.append("#ifndef _MAP_PKG_\n") - file_lines.append("#define _MAP_PKG_\n\n") for app in app_list: tasks_list = app["tasks"] app_name = app["name"] + #---------------- C SINTAX ------------------ + file_lines = [] + file_lines.append("#ifndef _MAP_PKG_\n") + file_lines.append("#define _MAP_PKG_\n\n") for task in tasks_list: task_name = task["task"] location = task["location"] From a750aae3f3e91b0962471973257d7abc7dfd64a0 Mon Sep 17 00:00:00 2001 From: "Alzemiro Lucas Silva (Aluno MSc - Moraes)" Date: Fri, 1 Dec 2017 10:20:51 -0200 Subject: [PATCH 47/54] fixed a bug on tasks config file generation --- build_env/scripts/app_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_env/scripts/app_builder.py b/build_env/scripts/app_builder.py index b2a6619..e333c7c 100644 --- a/build_env/scripts/app_builder.py +++ b/build_env/scripts/app_builder.py @@ -88,7 +88,6 @@ def generate_cfg_file(yaml_r): apps_file_path = "apps.cfg" - cfg_lines = [] apps_lines = [] app_list = get_apps_list(yaml_r) @@ -100,6 +99,7 @@ def generate_cfg_file(yaml_r): name = app["name"] tasks_list = app["tasks"] apps_lines.append(name + ".cfg\n") + cfg_lines = [] for task in tasks_list: task_name = task["task"] location = task["location"] From e0a643256f4374e9797c875d3f5c444d983d422e Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 1 Dec 2017 13:58:53 -0200 Subject: [PATCH 48/54] Fix bug on send_msg that could potentially induce reception lost --- build_env/makes/make_app | 2 +- software/bareOS/comm.c | 33 ++++++++++++++++++++++++++------- software/bareOS/include/comm.h | 7 +++++-- software/bareOS/include/libos.h | 2 ++ software/bareOS/libos.c | 2 ++ 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/build_env/makes/make_app b/build_env/makes/make_app index cb9b9ba..e9348fc 100644 --- a/build_env/makes/make_app +++ b/build_env/makes/make_app @@ -23,7 +23,7 @@ BARE_OS = $(BAREOS_DIR)/crt0.o \ $(BAREOS_DIR)/hal.o \ $(BAREOS_DIR)/libos.o \ $(BAREOS_DIR)/malloc.o \ - $(BAREOS_DIR)/comm.o \ + $(BAREOS_DIR)/comm.o all : $(DUMP_FILES) $(LST_FILES) $(TXT_FILES) $(BIN_FILES) diff --git a/software/bareOS/comm.c b/software/bareOS/comm.c index 5d5adba..19ac543 100644 --- a/software/bareOS/comm.c +++ b/software/bareOS/comm.c @@ -14,9 +14,10 @@ void transmit(flit_t target, flit_t service, len = align_type(msg_len, flit_t); flit_len = len/sizeof(flit_t); - p.header = target; + p.target = target; p.service = service; - p.payload_size = (MAC_HEADER_LEN-2) + (flit_len ? flit_len : 1); + p.length = (flit_len ? flit_len : 1); + p.length += mem_offset(p, p.length)/sizeof(flit_t); // Configure DMNI for package header transmission MemoryWrite32(DMNI_SIZE, MAC_HEADER_LEN); @@ -57,21 +58,34 @@ void *wait_receive(){ } void send_msg(flit_t target, void *msg, size_t len) { - msg_req_t msg_req; + msg_req_t msg_req, ack_reply; + void *old_buff; + size_t received_len; msg_req.addr = MemoryRead32(NET_ADDRESS); - msg_req.size = (len+3) >> 2; - + msg_req.size = align_type(len, flit_t)/sizeof(flit_t); + + /* waits previous operation to finish + * this avoids overwriting previous buffer pointer */ + old_buff = wait_receive(); + transmit(target, REQ_OPERATION, &msg_req, sizeof(msg_req_t)); - prepare_receive(&msg_req); + prepare_receive(&ack_reply); wait_receive(); + // restauring previous buffer + MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)old_buff & 1); + + if((ack_reply.addr != msg_req.addr)) + panic("Received ACK diverges from expected\n"); + + received_len = ack_reply.size*sizeof(flit_t); + len = min(received_len, len); transmit(target, DMA_OPERATION, msg, len); } typedef union { uint32_t i32; - uint16_t i16[2]; msg_req_t s; } msg_req_u; @@ -92,3 +106,8 @@ void *prepare_recv_msg(flit_t *src, size_t *size) { return prepare_receive(buff); } + +void *receive_msg(flit_t *src, size_t *size) { + prepare_recv_msg(src, size); + return wait_receive(); +} diff --git a/software/bareOS/include/comm.h b/software/bareOS/include/comm.h index 0baca34..5c2dcde 100644 --- a/software/bareOS/include/comm.h +++ b/software/bareOS/include/comm.h @@ -20,9 +20,10 @@ typedef uint32_t flit_t; typedef struct { - flit_t header; - flit_t payload_size; + flit_t target; + flit_t length; flit_t service; + flit_t payload[]; } mac_header_t; typedef struct { @@ -39,4 +40,6 @@ void *wait_receive(); void send_msg(flit_t target, void *msg, size_t len); void *prepare_recv_msg(flit_t *src, size_t *size); +void *receive_msg(flit_t *src, size_t *size); + #endif /* !_COMM_H */ diff --git a/software/bareOS/include/libos.h b/software/bareOS/include/libos.h index 8d8789a..29d580b 100644 --- a/software/bareOS/include/libos.h +++ b/software/bareOS/include/libos.h @@ -29,6 +29,8 @@ #define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b) #define ct_assert(e) enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) } +#define mem_offset(base, target) ((size_t)&(target) - (size_t)&(base)) + typedef __builtin_va_list __gnuc_va_list; typedef __gnuc_va_list va_list; diff --git a/software/bareOS/libos.c b/software/bareOS/libos.c index 78a837b..956823a 100644 --- a/software/bareOS/libos.c +++ b/software/bareOS/libos.c @@ -140,6 +140,8 @@ void panic(const char *fmt, ...) { ret = vprintf(fmt, ap); va_end(ap); + putchar('\n'); + exit(-1); } From 8746055e7551ed5cbc715af0edcfef1e48cd5b7f Mon Sep 17 00:00:00 2001 From: Bruno Scherer Oliveira Date: Fri, 8 Dec 2017 11:09:51 -0200 Subject: [PATCH 49/54] Commited applications: mpeg, AES and Synthetic --- .gitignore | 1 + applications/.DS_Store | Bin 0 -> 10244 bytes applications/aes/.DS_Store | Bin 0 -> 8196 bytes applications/aes/aes.h | 134 ++++++++++---------- applications/aes/aes_generator/aes.h | 132 +++++++++---------- applications/aes/aes_generator/aes_master.c | 95 +++++++------- applications/aes/aes_generator/aes_sl.c | 60 ++++----- applications/aes/aes_master.c | 106 ++++++++-------- applications/aes/aes_master.h | 2 +- applications/aes/aes_slave1.c | 63 +++++---- applications/aes/aes_slave2.c | 63 +++++---- applications/aes/aes_slave3.c | 63 +++++---- applications/aes/aes_slave4.c | 95 -------------- applications/aes/aes_slave5.c | 95 -------------- applications/aes/aes_slave6.c | 95 -------------- applications/aes/aes_slave7.c | 95 -------------- applications/aes/aes_slave8.c | 95 -------------- applications/mpeg/.DS_Store | Bin 0 -> 6148 bytes applications/mpeg/idct.c | 57 +++------ applications/mpeg/iquant.c | 47 +++---- applications/mpeg/ivlc.c | 55 +++----- applications/mpeg/mpeg_std.h | 2 +- applications/mpeg/print.c | 35 ++--- applications/mpeg/start.c | 52 ++------ applications/synthetic/.DS_Store | Bin 0 -> 6148 bytes applications/synthetic/taskA.c | 28 ++-- applications/synthetic/taskB.c | 30 ++--- applications/synthetic/taskC.c | 40 +++--- applications/synthetic/taskD.c | 34 ++--- applications/synthetic/taskE.c | 37 +++--- applications/synthetic/taskF.c | 28 ++-- testcases/aes.yaml | 25 ++++ testcases/mpeg.yaml | 25 ++++ testcases/syn.yaml | 27 ++++ 34 files changed, 612 insertions(+), 1104 deletions(-) create mode 100644 applications/.DS_Store create mode 100644 applications/aes/.DS_Store delete mode 100644 applications/aes/aes_slave4.c delete mode 100644 applications/aes/aes_slave5.c delete mode 100644 applications/aes/aes_slave6.c delete mode 100644 applications/aes/aes_slave7.c delete mode 100644 applications/aes/aes_slave8.c create mode 100644 applications/mpeg/.DS_Store create mode 100644 applications/synthetic/.DS_Store create mode 100644 testcases/aes.yaml create mode 100644 testcases/mpeg.yaml create mode 100644 testcases/syn.yaml diff --git a/.gitignore b/.gitignore index 38487ca..d8c3c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ \#*\# *.o *.vlw +.DS_Store diff --git a/applications/.DS_Store b/applications/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..84642979855b7a890b5c6e6706cb3bd71a134951 GIT binary patch literal 10244 zcmeHMU2GIp6h3EL%FIycEdphbrJL3&AU|y>77WyFyJ)IKD%;XRfp&IhY)7Xvb!WCq zsl_I~7=wQgDj0py#KhDm6ce9}@df`Atr0am_~3)S_~=hG@!Ywy4KB-z34-R{WbV25 z+;isM^UXJN_TB{m?8=)h00{t4=;D%9Q&pz$aeiG7Xjy0+3w%y-#gM zCfp|x$z&wwgrpHFC|pSjSB$n8DBMY(i0qP)oD)*G14f$4*18ivg9F5mq-dv$c6kqOEy$OJb&_br-eUckG&-Rh7D?mc2cr6VoSW9-TdP zMns9xmjY@^qCQLgN{Hes8?@t3b&H^5FBXHoSPWX#mgznBYP~~t)^pSLNo$1F_!M&w zb^CJG6va1~^_={K>yNP7tl?zyjuBX$j>C=pp};y3@YWIE%LUz`;Rs`S-#TcKojqlx z$eLVN@;e=v3~bN!4_P^%WMi^f#G=kuuZ}m|dVBNEJMT&@EMHN>w3XVb!71CfGmbS- zu+3onu;FJd*RFclNrLab2D4($($=kv7 z0$WkDd_%pi9W`ln`#qE2&1B~lH5_TI*Y#mO(w(!YHWfuIYNNhcWrou4Q@ld6RokvI zU+sUG9(AbETeUWYnd*RJWGqLh+O^#ZyH6dQ5@8GF9<4*E#VzVk)|;51c>HkYWT&nl z=QH;jesEyYa%oi;XnIz+cFjIo)nPu?X_|aZN@H@Pz%N8VWjyKV&;V_)2m0VJm{5Sz z@I1T#ufjaM1@FQK@ELp#U%;1e5x$2X;b-^_euqEcPprZkT#p;D9uv3;cj6t`j!Epq zZcJeh9>g>b;2|7F6D=IWadfeOC-5ZB;Ny52pTcMHIeZCU!*lpHp2v6aJ^To?V$qqQqGA7jbWyPQTLZv-(y!W0P+KEA&(k+WG}ce55BAYNG~O5cDY$JtWOAZ0-(cEl6$ z28Fo7qHa_CHiZbyV&T0uZH{ZKg1D=O-EG^oI9ozARl@F$Hcexd#A7kKYd4Kn5o5*Z z-VPcC{-&wnOj=Vsr78?d`FBQoVV>p7NXy8NW5c@ow#A#yRES|#0@Ckg9IQTR^gJxG`JAJIOUB1Y{>pkb4Qs-Wx}8| zBNN6Ao-oQ2SEde`I{43)Yo9vG@UJ9^h&&@}iGW1l+9OaQrbzJf|9w~g|Nq)AM9v@) zkO*8i1h6udPIb}r#nXn;mGHCn1YM(a@xtxqgbZD%3XkJShR5;L;m7geVGHS^L#xm) hNqX)-CnU9~{Of-P$o;?E|NrB&<1#;E|AYJgzW@u32^|0c literal 0 HcmV?d00001 diff --git a/applications/aes/.DS_Store b/applications/aes/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..cf13a7b81a9160158fe3f4e7cfc4874ff4458f46 GIT binary patch literal 8196 zcmeHMU2GLa6h7xt%I?zADMH&tZhJ$m0#f=zvBd!1wiitmq;gwYC~&*CySA&_-FkO# zFHnn3d?5z^9#k;;qKS#YClnK(jPV8k6Ri<7Jow;)zWC@*H1W*L-p01HZ;A;!$;_FV zbI#11Z@<~ixfcMiD{r;{)Bu1&l}omon(Gv<=XFtug)=22k^BKh!2*|R4va4bP|ipxTxm_2Jz(gHVTys$o%9KAPBIzF87ZYZpmYZecg8S7L9sjeC4@O( zQp%`}5Qq?1i~zqr<&>>k;6r9!{vLn_xop9o$U0t@tgd7y9NQ0?o4>)>ijtM3s}x?! zmE-9#uaFLmAn$h>xgkF4HG;8h*zfZ^XRdE#58GBD!`5|sZeZB1l@rdkX_3jX0oygb zLYJ3!O<$~&mI{@Z46B}+YHZ$?XltI{mY8a3?Vx`9j*jVRRjF=h+0!#Te(Lnppk~t`v>h2&rRE>tqiO1Dc~L&_U5cf z3T|M;bMoV^pJA0FhBK0PjKJ!29B%9n2G+@d_m28rF6b798OHLyb;u$+d(ujgHMy?k zD;=B&Y|r%%TRER(eX>~wqFyXpAK!HQoy|M%z9%(XzNUg{YqfO)leTYX9jm`!o59!- z!ymC+({@LX5`=DGKWtk$wKDdb+UFYM)@)UE4bwO18<+A@SiLfs&)SdW?cmfbTT@Y9 zTc>NsOgh~G&*ZC_?6RT?O?{oN4{=R*&Z5>-6nUu4`c{=0N}o^h%9%#3NoBs;_b5GQ zF{8I?Z3;8he#gjKj+|=Ob}8%ubzoA4Ehl$tdzDJurVfsHiP-3^M1n* z4o+Auo$3m0&#G&x_R*=1a9yWq@-r#*$;}c!fq=^R2SDx2 zT!gpbJ@^nlhcDnu_zJGV5AYNG0>8r_@F)C*rC5O*u@>tvfm?7V-i7U$#7^wS6!zdD zOk+PD#vwG(!ciPU7Yle2PvaCmiRbWXd=8(-m+^JHgzw;Gd>7xxkMLvs1V6>E@jLup zo-T3~X5XD(cthHrpTw^PU&8iq~Z_?syB@tHOxR8-c^6^c$1Rua>#Kfy`4Ss~5;a3FWU>Q~s2NPJ2w_yWr$0lsSR&2vP zxHn|uetZyn@gZX55FW=24x@pOphJB0Z~{*eAE)sQK7nWPDPrX__$;2s3&hM<@Kt;R zFD~F=PmzIA;#ueUhP^k&> 8) & 0xFF; subkey[3] = (w[0]) & 0xFF; - //Echo(" "); - //Echo("subkey"); + //puts(" "); + //puts("subkey"); //for(j=0; j<4;j++){ - // Echo(itoh(subkey[j])); + // puts(itoh(subkey[j])); //} - //Echo(" "); + //puts(" "); // - //Echo(" "); - //Echo("state"); + //puts(" "); + //puts("state"); //for(j=0; j<4;j++){ - // Echo(itoh(state[j][0])); + // puts(itoh(state[j][0])); //} - //Echo(" "); + //puts(" "); state[0][0] ^= subkey[0]; state[1][0] ^= subkey[1]; @@ -361,14 +361,14 @@ void AddRoundKey(BYTE state[][4], const WORD w[]) state[3][3] ^= subkey[3]; #ifdef debug_aes_on - Echo(" "); - Echo("AddRoundKey"); + puts(" "); + puts("AddRoundKey"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -402,14 +402,14 @@ void SubBytes(BYTE state[][4]) state[3][3] = aes_sbox[state[3][3] >> 4][state[3][3] & 0x0F]; #ifdef debug_aes_on - Echo(" "); - Echo("SubBytes"); + puts(" "); + puts("SubBytes"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -437,14 +437,14 @@ void InvSubBytes(BYTE state[][4]) state[3][3] = aes_invsbox[state[3][3] >> 4][state[3][3] & 0x0F]; #ifdef debug_aes_on - Echo(" "); - Echo("InvSubBytes"); + puts(" "); + puts("InvSubBytes"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -482,14 +482,14 @@ void ShiftRows(BYTE state[][4]) state[3][1] = t; #ifdef debug_aes_on - Echo(" "); - Echo("ShiftRows"); + puts(" "); + puts("ShiftRows"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif @@ -523,14 +523,14 @@ void InvShiftRows(BYTE state[][4]) state[3][2] = t; #ifdef debug_aes_on - Echo(" "); - Echo("InvShiftRows"); + puts(" "); + puts("InvShiftRows"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -635,14 +635,14 @@ void MixColumns(BYTE state[][4]) state[3][3] ^= gf_mul[col[3]][0]; #ifdef debug_aes_on - Echo(" "); - Echo("MixColumns"); + puts(" "); + puts("MixColumns"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -738,14 +738,14 @@ void InvMixColumns(BYTE state[][4]) state[3][3] ^= gf_mul[col[2]][2]; state[3][3] ^= gf_mul[col[3]][5]; #ifdef debug_aes_on - Echo(" "); - Echo("InvMixColumns"); + puts(" "); + puts("InvMixColumns"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -768,12 +768,12 @@ void aes_encrypt(const BYTE in[], BYTE out[], const WORD key[], int keysize) // column, then row. Accessing an element in C requires row then column. Thus, all state // references in AES must have the column and row indexes reversed for C implementation. - //Echo(" "); - //Echo("in"); + //puts(" "); + //puts("in"); //for(i=0; i 128) { if (keysize > 192) { AddRoundKey(state,&key[56]); - Echo("ROUND 0 finished."); + puts("ROUND 0 finished."); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[52]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[48]);InvMixColumns(state); } else { AddRoundKey(state,&key[48]); - Echo("ROUND 0 finished."); + puts("ROUND 0 finished."); } InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[44]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[40]);InvMixColumns(state); } else { AddRoundKey(state,&key[40]); - Echo("ROUND 0 finished."); + puts("ROUND 0 finished."); } InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[36]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[32]);InvMixColumns(state); @@ -921,7 +921,7 @@ void aes_decrypt(const BYTE in[], BYTE out[], const WORD key[], int keysize) InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[8]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[4]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[0]); - Echo("ROUND Final finished."); + puts("ROUND Final finished."); // Copy the state to the output array. out[0] = state[0][0]; diff --git a/applications/aes/aes_generator/aes.h b/applications/aes/aes_generator/aes.h index c2d078f..fe94e65 100644 --- a/applications/aes/aes_generator/aes.h +++ b/applications/aes/aes_generator/aes.h @@ -314,19 +314,19 @@ void AddRoundKey(BYTE state[][4], const WORD w[]) subkey[2] = (w[0] >> 8) & 0xFF; subkey[3] = (w[0]) & 0xFF; - //Echo(" "); - //Echo("subkey"); + //puts(" "); + //puts("subkey"); //for(j=0; j<4;j++){ - // Echo(itoh(subkey[j])); + // puts(itoh(subkey[j])); //} - //Echo(" "); + //puts(" "); // - //Echo(" "); - //Echo("state"); + //puts(" "); + //puts("state"); //for(j=0; j<4;j++){ - // Echo(itoh(state[j][0])); + // puts(itoh(state[j][0])); //} - //Echo(" "); + //puts(" "); state[0][0] ^= subkey[0]; state[1][0] ^= subkey[1]; @@ -361,14 +361,14 @@ void AddRoundKey(BYTE state[][4], const WORD w[]) state[3][3] ^= subkey[3]; #ifdef debug_aes_on - Echo(" "); - Echo("AddRoundKey"); + puts(" "); + puts("AddRoundKey"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -402,14 +402,14 @@ void SubBytes(BYTE state[][4]) state[3][3] = aes_sbox[state[3][3] >> 4][state[3][3] & 0x0F]; #ifdef debug_aes_on - Echo(" "); - Echo("SubBytes"); + puts(" "); + puts("SubBytes"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -437,14 +437,14 @@ void InvSubBytes(BYTE state[][4]) state[3][3] = aes_invsbox[state[3][3] >> 4][state[3][3] & 0x0F]; #ifdef debug_aes_on - Echo(" "); - Echo("InvSubBytes"); + puts(" "); + puts("InvSubBytes"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -482,14 +482,14 @@ void ShiftRows(BYTE state[][4]) state[3][1] = t; #ifdef debug_aes_on - Echo(" "); - Echo("ShiftRows"); + puts(" "); + puts("ShiftRows"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif @@ -523,14 +523,14 @@ void InvShiftRows(BYTE state[][4]) state[3][2] = t; #ifdef debug_aes_on - Echo(" "); - Echo("InvShiftRows"); + puts(" "); + puts("InvShiftRows"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -635,14 +635,14 @@ void MixColumns(BYTE state[][4]) state[3][3] ^= gf_mul[col[3]][0]; #ifdef debug_aes_on - Echo(" "); - Echo("MixColumns"); + puts(" "); + puts("MixColumns"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -738,14 +738,14 @@ void InvMixColumns(BYTE state[][4]) state[3][3] ^= gf_mul[col[2]][2]; state[3][3] ^= gf_mul[col[3]][5]; #ifdef debug_aes_on - Echo(" "); - Echo("InvMixColumns"); + puts(" "); + puts("InvMixColumns"); for(i=0; i<4;i++){ for(j=0; j<4;j++){ - Echo(itoh(state[j][i])); + puts(itoh(state[j][i])); } } - Echo(" "); + puts(" "); #endif } @@ -768,12 +768,12 @@ void aes_encrypt(const BYTE in[], BYTE out[], const WORD key[], int keysize) // column, then row. Accessing an element in C requires row then column. Thus, all state // references in AES must have the column and row indexes reversed for C implementation. - //Echo(" "); - //Echo("in"); + //puts(" "); + //puts("in"); //for(i=0; i 128) { if (keysize > 192) { AddRoundKey(state,&key[56]); - Echo("ROUND 0 finished."); + puts("ROUND 0 finished."); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[52]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[48]);InvMixColumns(state); } else { AddRoundKey(state,&key[48]); - Echo("ROUND 0 finished."); + puts("ROUND 0 finished."); } InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[44]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[40]);InvMixColumns(state); } else { AddRoundKey(state,&key[40]); - Echo("ROUND 0 finished."); + puts("ROUND 0 finished."); } InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[36]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[32]);InvMixColumns(state); @@ -921,7 +921,7 @@ void aes_decrypt(const BYTE in[], BYTE out[], const WORD key[], int keysize) InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[8]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[4]);InvMixColumns(state); InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[0]); - Echo("ROUND Final finished."); + puts("ROUND Final finished."); // Copy the state to the output array. out[0] = state[0][0]; diff --git a/applications/aes/aes_generator/aes_master.c b/applications/aes/aes_generator/aes_master.c index 7d940d0..18d4616 100644 --- a/applications/aes/aes_generator/aes_master.c +++ b/applications/aes/aes_generator/aes_master.c @@ -7,8 +7,8 @@ *********************************************************************/ /*************************** HEADER FILES ***************************/ -#include -#include +#include +#include "map_pkg.h" #include "aes_master.h" /***************************** DEFINES ******************************/ // total message length @@ -22,7 +22,7 @@ //index of slaves (slave names) int Slave[MAX_SLAVES] = {}; -Message msg; +int *msg; /*************************** MAIN PROGRAM ***************************/ @@ -34,30 +34,29 @@ int main() int msg_length, blocks, qtd_messages[MAX_SLAVES]; int pad_value, aux_msg[3]; int aux1_blocks_PE; - int aux2_blocks_PE; + int aux2_blocks_PE; + int size; + int src; + int msg1[4*AES_BLOCK_SIZE]; // fill each block with values 'A', 'B', ... for(x = 0; x < MSG_LENGHT; x++){ plain_msg[x] = ((x/16)%26)+0x41; } - Echo("task AES started."); - Echo(itoa(GetTick())); - + puts("task AES started.\n"); // calculate number of block and pad value (PCKS5) of last block msg_length = MSG_LENGHT; blocks = (MSG_LENGHT%AES_BLOCK_SIZE)==0 ? (MSG_LENGHT/AES_BLOCK_SIZE) : (MSG_LENGHT/AES_BLOCK_SIZE)+1; pad_value = (AES_BLOCK_SIZE - (msg_length%AES_BLOCK_SIZE))%AES_BLOCK_SIZE; - Echo(" "); - Echo("Blocks:"); - Echo(itoa(blocks)); + puts(" "); + puts("Blocks:\n"); #ifdef debug_comunication_on - Echo(" "); - Echo("plain msg"); + puts(" "); + puts("plain msg\n"); for(x=0; x= NUMBER_OF_SLAVES) // zero messages to Slave not used aux_msg[0] = END_TASK; - memcpy(&msg.msg, &aux_msg, 4*msg.length); - Send(&msg, Slave[x]); - } + memcpy(msg1, &aux_msg, 4*sizeof(aux_msg)); + send_msg(Slave[x], (unsigned int*)msg1, sizeof(msg1)); + } // Send blocks to Cipher and // Receive the correspondent block Encrypted @@ -94,20 +93,21 @@ int main() // send a block to Slave_PE encrypt for(y = 0; y < NUMBER_OF_SLAVES; y++){ if(qtd_messages[(x+y) % NUMBER_OF_SLAVES] != 0){ - msg.length = 4*AES_BLOCK_SIZE; - memcpy(msg.msg, &plain_msg[(x+y)*AES_BLOCK_SIZE], 4*AES_BLOCK_SIZE); - Send(&msg, Slave[(x+y) % NUMBER_OF_SLAVES]); + size = 4*AES_BLOCK_SIZE; + memcpy(msg1, &plain_msg[(x+y)*AES_BLOCK_SIZE], 4*AES_BLOCK_SIZE); + send_msg(Slave[x+y], (unsigned int*)msg1, sizeof(msg1)); } } // Receive Encrypted block from Slave_PE for(y = 0; y < NUMBER_OF_SLAVES; y++){ if(qtd_messages[(x+y) % NUMBER_OF_SLAVES] != 0){ - Receive(&msg, Slave[(x+y) % NUMBER_OF_SLAVES]); + prepare_recv_msg(&src, &size); + msg = wait_receive(); j = 0; for (i=(x+y)*AES_BLOCK_SIZE;i < ((x+y)*AES_BLOCK_SIZE) + AES_BLOCK_SIZE; i++) { - cipher_msg[i] = msg.msg[j]; + cipher_msg[i] = msg[j]; j++; } j = 0; @@ -116,12 +116,11 @@ int main() } } #ifdef debug_comunication_on - Echo(" "); - Echo("cipher msg"); + puts(" "); + puts("cipher msg\n"); for(i=0; i -#include +#include +#include "map_pkg.h" #include "aes.h" /**************************** VARIABLES *****************************/ -Message msg; +int *msg; /*************************** MAIN PROGRAM ***************************/ @@ -20,27 +20,29 @@ int main() { unsigned int key_schedule[60]; int qtd_messages, op_mode, x, flag=1, id = -1, i; + int size; + int src; + int msg1[4*AES_BLOCK_SIZE]; unsigned int enc_buf[128]; unsigned int input_text[16]; unsigned int key[1][32] = { {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} }; - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); + puts("task AES SLAVE started - ID:\n"); aes_key_setup(&key[0][0], key_schedule, 256); while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 12); #ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); + puts(" "); + puts("Slave configuration\n"); for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif op_mode = input_text[0]; @@ -49,46 +51,40 @@ int main() if(id == -1){ id = x; - Echo(itoa(id)); } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); + puts("Operation:\n"); + puts("Blocks:\n"); if (op_mode == END_TASK){ flag = 0; qtd_messages = 0; } for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 4*AES_BLOCK_SIZE); #ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); + puts(" "); + puts("received msg"); for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif if(op_mode == CIPHER_MODE){ - Echo("encript"); + puts("encript"); aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } else{ - Echo("decript"); + puts("decript"); aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); + size = 4*AES_BLOCK_SIZE; + memcpy( msg1, enc_buf,4*AES_BLOCK_SIZE); + send_msg(aes_master, (unsigned int*)msg1, sizeof(msg1)); } } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); + puts("task AES SLAVE finished - ID: \n"); + exit(); } diff --git a/applications/aes/aes_master.c b/applications/aes/aes_master.c index a778117..18d4616 100644 --- a/applications/aes/aes_master.c +++ b/applications/aes/aes_master.c @@ -1,29 +1,28 @@ /********************************************************************* * Filename: aes_main.c * Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) +* Copyleft: * Disclaimer: This code is presented "as is" without any guarantees. * Details: *********************************************************************/ /*************************** HEADER FILES ***************************/ -#include -#include +#include +#include "map_pkg.h" #include "aes_master.h" /***************************** DEFINES ******************************/ // total message length -#define MSG_LENGHT 256 +#define MSG_LENGHT // number of efectived used slaves -#define NUMBER_OF_SLAVES 8 +#define NUMBER_OF_SLAVES // number of total slaves allocated -#define MAX_SLAVES 8 +#define MAX_SLAVES /**************************** VARIABLES *****************************/ //index of slaves (slave names) -int Slave[MAX_SLAVES] = {aes_slave1,aes_slave2,aes_slave3,aes_slave4,aes_slave5,aes_slave6,aes_slave7,aes_slave8}; -Message msg; +int Slave[MAX_SLAVES] = {}; +int *msg; /*************************** MAIN PROGRAM ***************************/ @@ -35,30 +34,29 @@ int main() int msg_length, blocks, qtd_messages[MAX_SLAVES]; int pad_value, aux_msg[3]; int aux1_blocks_PE; - int aux2_blocks_PE; + int aux2_blocks_PE; + int size; + int src; + int msg1[4*AES_BLOCK_SIZE]; // fill each block with values 'A', 'B', ... for(x = 0; x < MSG_LENGHT; x++){ plain_msg[x] = ((x/16)%26)+0x41; } - Echo("task AES started."); - Echo(itoa(GetTick())); - + puts("task AES started.\n"); // calculate number of block and pad value (PCKS5) of last block msg_length = MSG_LENGHT; blocks = (MSG_LENGHT%AES_BLOCK_SIZE)==0 ? (MSG_LENGHT/AES_BLOCK_SIZE) : (MSG_LENGHT/AES_BLOCK_SIZE)+1; pad_value = (AES_BLOCK_SIZE - (msg_length%AES_BLOCK_SIZE))%AES_BLOCK_SIZE; - Echo(" "); - Echo("Blocks:"); - Echo(itoa(blocks)); + puts(" "); + puts("Blocks:\n"); #ifdef debug_comunication_on - Echo(" "); - Echo("plain msg"); + puts(" "); + puts("plain msg\n"); for(x=0; x= NUMBER_OF_SLAVES) // zero messages to Slave not used aux_msg[0] = END_TASK; - memcpy(&msg.msg, &aux_msg, 4*msg.length); - Send(&msg, Slave[x]); - } + memcpy(msg1, &aux_msg, 4*sizeof(aux_msg)); + send_msg(Slave[x], (unsigned int*)msg1, sizeof(msg1)); + } // Send blocks to Cipher and // Receive the correspondent block Encrypted @@ -95,20 +93,21 @@ int main() // send a block to Slave_PE encrypt for(y = 0; y < NUMBER_OF_SLAVES; y++){ if(qtd_messages[(x+y) % NUMBER_OF_SLAVES] != 0){ - msg.length = 4*AES_BLOCK_SIZE; - memcpy(msg.msg, &plain_msg[(x+y)*AES_BLOCK_SIZE], 4*AES_BLOCK_SIZE); - Send(&msg, Slave[(x+y) % NUMBER_OF_SLAVES]); + size = 4*AES_BLOCK_SIZE; + memcpy(msg1, &plain_msg[(x+y)*AES_BLOCK_SIZE], 4*AES_BLOCK_SIZE); + send_msg(Slave[x+y], (unsigned int*)msg1, sizeof(msg1)); } } // Receive Encrypted block from Slave_PE for(y = 0; y < NUMBER_OF_SLAVES; y++){ if(qtd_messages[(x+y) % NUMBER_OF_SLAVES] != 0){ - Receive(&msg, Slave[(x+y) % NUMBER_OF_SLAVES]); + prepare_recv_msg(&src, &size); + msg = wait_receive(); j = 0; for (i=(x+y)*AES_BLOCK_SIZE;i < ((x+y)*AES_BLOCK_SIZE) + AES_BLOCK_SIZE; i++) { - cipher_msg[i] = msg.msg[j]; + cipher_msg[i] = msg[j]; j++; } j = 0; @@ -117,12 +116,11 @@ int main() } } #ifdef debug_comunication_on - Echo(" "); - Echo("cipher msg"); + puts(" "); + puts("cipher msg\n"); for(i=0; i -#include +#include +#include "map_pkg.h" #include "aes.h" /**************************** VARIABLES *****************************/ -Message msg; +int *msg; /*************************** MAIN PROGRAM ***************************/ @@ -21,27 +20,29 @@ int main() { unsigned int key_schedule[60]; int qtd_messages, op_mode, x, flag=1, id = -1, i; + int size; + int src; + int msg1[4*AES_BLOCK_SIZE]; unsigned int enc_buf[128]; unsigned int input_text[16]; unsigned int key[1][32] = { {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} }; - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); + puts("task AES SLAVE started - ID:\n"); aes_key_setup(&key[0][0], key_schedule, 256); while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 12); #ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); + puts(" "); + puts("Slave configuration\n"); for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif op_mode = input_text[0]; @@ -50,46 +51,40 @@ int main() if(id == -1){ id = x; - Echo(itoa(id)); } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); + puts("Operation:\n"); + puts("Blocks:\n"); if (op_mode == END_TASK){ flag = 0; qtd_messages = 0; } for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 4*AES_BLOCK_SIZE); #ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); + puts(" "); + puts("received msg"); for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif if(op_mode == CIPHER_MODE){ - Echo("encript"); + puts("encript"); aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } else{ - Echo("decript"); + puts("decript"); aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); + size = 4*AES_BLOCK_SIZE; + memcpy( msg1, enc_buf,4*AES_BLOCK_SIZE); + send_msg(aes_master, (unsigned int*)msg1, sizeof(msg1)); } } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); + puts("task AES SLAVE finished - ID: \n"); + exit(); } diff --git a/applications/aes/aes_slave2.c b/applications/aes/aes_slave2.c index df04729..26250e1 100644 --- a/applications/aes/aes_slave2.c +++ b/applications/aes/aes_slave2.c @@ -1,19 +1,18 @@ /********************************************************************* * Filename: aes_sl(n).c * Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) +* Copyleft: * Disclaimer: This code is presented "as is" without any guarantees. * Details: *********************************************************************/ /*************************** HEADER FILES ***************************/ -#include -#include +#include +#include "map_pkg.h" #include "aes.h" /**************************** VARIABLES *****************************/ -Message msg; +int *msg; /*************************** MAIN PROGRAM ***************************/ @@ -21,27 +20,29 @@ int main() { unsigned int key_schedule[60]; int qtd_messages, op_mode, x, flag=1, id = -1, i; + int size; + int src; + int msg1[4*AES_BLOCK_SIZE]; unsigned int enc_buf[128]; unsigned int input_text[16]; unsigned int key[1][32] = { {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} }; - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); + puts("task AES SLAVE started - ID:\n"); aes_key_setup(&key[0][0], key_schedule, 256); while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 12); #ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); + puts(" "); + puts("Slave configuration\n"); for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif op_mode = input_text[0]; @@ -50,46 +51,40 @@ int main() if(id == -1){ id = x; - Echo(itoa(id)); } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); + puts("Operation:\n"); + puts("Blocks:\n"); if (op_mode == END_TASK){ flag = 0; qtd_messages = 0; } for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 4*AES_BLOCK_SIZE); #ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); + puts(" "); + puts("received msg"); for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif if(op_mode == CIPHER_MODE){ - Echo("encript"); + puts("encript"); aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } else{ - Echo("decript"); + puts("decript"); aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); + size = 4*AES_BLOCK_SIZE; + memcpy( msg1, enc_buf,4*AES_BLOCK_SIZE); + send_msg(aes_master, (unsigned int*)msg1, sizeof(msg1)); } } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); + puts("task AES SLAVE finished - ID: \n"); + exit(); } diff --git a/applications/aes/aes_slave3.c b/applications/aes/aes_slave3.c index df04729..26250e1 100644 --- a/applications/aes/aes_slave3.c +++ b/applications/aes/aes_slave3.c @@ -1,19 +1,18 @@ /********************************************************************* * Filename: aes_sl(n).c * Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) +* Copyleft: * Disclaimer: This code is presented "as is" without any guarantees. * Details: *********************************************************************/ /*************************** HEADER FILES ***************************/ -#include -#include +#include +#include "map_pkg.h" #include "aes.h" /**************************** VARIABLES *****************************/ -Message msg; +int *msg; /*************************** MAIN PROGRAM ***************************/ @@ -21,27 +20,29 @@ int main() { unsigned int key_schedule[60]; int qtd_messages, op_mode, x, flag=1, id = -1, i; + int size; + int src; + int msg1[4*AES_BLOCK_SIZE]; unsigned int enc_buf[128]; unsigned int input_text[16]; unsigned int key[1][32] = { {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} }; - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); + puts("task AES SLAVE started - ID:\n"); aes_key_setup(&key[0][0], key_schedule, 256); while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 12); #ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); + puts(" "); + puts("Slave configuration\n"); for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif op_mode = input_text[0]; @@ -50,46 +51,40 @@ int main() if(id == -1){ id = x; - Echo(itoa(id)); } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); + puts("Operation:\n"); + puts("Blocks:\n"); if (op_mode == END_TASK){ flag = 0; qtd_messages = 0; } for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); + prepare_recv_msg(&src, &size); + msg = wait_receive(); + memcpy(input_text, msg, 4*AES_BLOCK_SIZE); #ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); + puts(" "); + puts("received msg"); for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); } - Echo(" "); + puts(" "); #endif if(op_mode == CIPHER_MODE){ - Echo("encript"); + puts("encript"); aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } else{ - Echo("decript"); + puts("decript"); aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); + size = 4*AES_BLOCK_SIZE; + memcpy( msg1, enc_buf,4*AES_BLOCK_SIZE); + send_msg(aes_master, (unsigned int*)msg1, sizeof(msg1)); } } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); + puts("task AES SLAVE finished - ID: \n"); + exit(); } diff --git a/applications/aes/aes_slave4.c b/applications/aes/aes_slave4.c deleted file mode 100644 index df04729..0000000 --- a/applications/aes/aes_slave4.c +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************* -* Filename: aes_sl(n).c -* Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) -* Disclaimer: This code is presented "as is" without any guarantees. -* Details: -*********************************************************************/ - -/*************************** HEADER FILES ***************************/ -#include -#include -#include "aes.h" -/**************************** VARIABLES *****************************/ - -Message msg; - -/*************************** MAIN PROGRAM ***************************/ - -int main() -{ - unsigned int key_schedule[60]; - int qtd_messages, op_mode, x, flag=1, id = -1, i; - unsigned int enc_buf[128]; - unsigned int input_text[16]; - unsigned int key[1][32] = { - {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} - }; - - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); - aes_key_setup(&key[0][0], key_schedule, 256); - - while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); - -#ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); - for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - op_mode = input_text[0]; - qtd_messages = input_text[1]; - x = input_text[2]; - - if(id == -1){ - id = x; - Echo(itoa(id)); - } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); - - if (op_mode == END_TASK){ - flag = 0; - qtd_messages = 0; - } - for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); - -#ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); - for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - if(op_mode == CIPHER_MODE){ - Echo("encript"); - aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - else{ - Echo("decript"); - aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); - } - } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); -} diff --git a/applications/aes/aes_slave5.c b/applications/aes/aes_slave5.c deleted file mode 100644 index df04729..0000000 --- a/applications/aes/aes_slave5.c +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************* -* Filename: aes_sl(n).c -* Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) -* Disclaimer: This code is presented "as is" without any guarantees. -* Details: -*********************************************************************/ - -/*************************** HEADER FILES ***************************/ -#include -#include -#include "aes.h" -/**************************** VARIABLES *****************************/ - -Message msg; - -/*************************** MAIN PROGRAM ***************************/ - -int main() -{ - unsigned int key_schedule[60]; - int qtd_messages, op_mode, x, flag=1, id = -1, i; - unsigned int enc_buf[128]; - unsigned int input_text[16]; - unsigned int key[1][32] = { - {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} - }; - - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); - aes_key_setup(&key[0][0], key_schedule, 256); - - while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); - -#ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); - for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - op_mode = input_text[0]; - qtd_messages = input_text[1]; - x = input_text[2]; - - if(id == -1){ - id = x; - Echo(itoa(id)); - } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); - - if (op_mode == END_TASK){ - flag = 0; - qtd_messages = 0; - } - for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); - -#ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); - for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - if(op_mode == CIPHER_MODE){ - Echo("encript"); - aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - else{ - Echo("decript"); - aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); - } - } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); -} diff --git a/applications/aes/aes_slave6.c b/applications/aes/aes_slave6.c deleted file mode 100644 index df04729..0000000 --- a/applications/aes/aes_slave6.c +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************* -* Filename: aes_sl(n).c -* Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) -* Disclaimer: This code is presented "as is" without any guarantees. -* Details: -*********************************************************************/ - -/*************************** HEADER FILES ***************************/ -#include -#include -#include "aes.h" -/**************************** VARIABLES *****************************/ - -Message msg; - -/*************************** MAIN PROGRAM ***************************/ - -int main() -{ - unsigned int key_schedule[60]; - int qtd_messages, op_mode, x, flag=1, id = -1, i; - unsigned int enc_buf[128]; - unsigned int input_text[16]; - unsigned int key[1][32] = { - {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} - }; - - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); - aes_key_setup(&key[0][0], key_schedule, 256); - - while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); - -#ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); - for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - op_mode = input_text[0]; - qtd_messages = input_text[1]; - x = input_text[2]; - - if(id == -1){ - id = x; - Echo(itoa(id)); - } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); - - if (op_mode == END_TASK){ - flag = 0; - qtd_messages = 0; - } - for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); - -#ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); - for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - if(op_mode == CIPHER_MODE){ - Echo("encript"); - aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - else{ - Echo("decript"); - aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); - } - } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); -} diff --git a/applications/aes/aes_slave7.c b/applications/aes/aes_slave7.c deleted file mode 100644 index df04729..0000000 --- a/applications/aes/aes_slave7.c +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************* -* Filename: aes_sl(n).c -* Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) -* Disclaimer: This code is presented "as is" without any guarantees. -* Details: -*********************************************************************/ - -/*************************** HEADER FILES ***************************/ -#include -#include -#include "aes.h" -/**************************** VARIABLES *****************************/ - -Message msg; - -/*************************** MAIN PROGRAM ***************************/ - -int main() -{ - unsigned int key_schedule[60]; - int qtd_messages, op_mode, x, flag=1, id = -1, i; - unsigned int enc_buf[128]; - unsigned int input_text[16]; - unsigned int key[1][32] = { - {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} - }; - - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); - aes_key_setup(&key[0][0], key_schedule, 256); - - while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); - -#ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); - for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - op_mode = input_text[0]; - qtd_messages = input_text[1]; - x = input_text[2]; - - if(id == -1){ - id = x; - Echo(itoa(id)); - } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); - - if (op_mode == END_TASK){ - flag = 0; - qtd_messages = 0; - } - for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); - -#ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); - for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - if(op_mode == CIPHER_MODE){ - Echo("encript"); - aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - else{ - Echo("decript"); - aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); - } - } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); -} diff --git a/applications/aes/aes_slave8.c b/applications/aes/aes_slave8.c deleted file mode 100644 index df04729..0000000 --- a/applications/aes/aes_slave8.c +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************* -* Filename: aes_sl(n).c -* Author: Leonardo Rezende Juracy and Luciano L. Caimi -* Copyleft: Original AES implementation: Brad Conte -* (brad AT bradconte.com) -* Disclaimer: This code is presented "as is" without any guarantees. -* Details: -*********************************************************************/ - -/*************************** HEADER FILES ***************************/ -#include -#include -#include "aes.h" -/**************************** VARIABLES *****************************/ - -Message msg; - -/*************************** MAIN PROGRAM ***************************/ - -int main() -{ - unsigned int key_schedule[60]; - int qtd_messages, op_mode, x, flag=1, id = -1, i; - unsigned int enc_buf[128]; - unsigned int input_text[16]; - unsigned int key[1][32] = { - {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4} - }; - - Echo(itoa(GetTick())); - Echo("task AES SLAVE started - ID:"); - aes_key_setup(&key[0][0], key_schedule, 256); - - while(flag){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 12); - -#ifdef debug_comunication_on - Echo(" "); - Echo("Slave configuration"); - for(i=0; i<3;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - op_mode = input_text[0]; - qtd_messages = input_text[1]; - x = input_text[2]; - - if(id == -1){ - id = x; - Echo(itoa(id)); - } - Echo("Operation:"); - Echo(itoa(op_mode)); - Echo("Blocks:"); - Echo(itoa(qtd_messages)); - - if (op_mode == END_TASK){ - flag = 0; - qtd_messages = 0; - } - for(x = 0; x < qtd_messages; x++){ - Receive(&msg, aes_master); - memcpy(input_text, msg.msg, 4*AES_BLOCK_SIZE); - -#ifdef debug_comunication_on - Echo(" "); - Echo("received msg"); - for(i=0; i<16;i++){ - Echo(itoh(input_text[i])); - } - Echo(" "); -#endif - - if(op_mode == CIPHER_MODE){ - Echo("encript"); - aes_encrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - else{ - Echo("decript"); - aes_decrypt(input_text, enc_buf, key_schedule, KEY_SIZE); - } - msg.length = 4*AES_BLOCK_SIZE; - memcpy( msg.msg, enc_buf,4*AES_BLOCK_SIZE); - Send(&msg, aes_master); - } - } - Echo("task AES SLAVE finished - ID: "); - Echo(itoa(id)); - Echo(itoa(GetTick())); - - exit(); -} diff --git a/applications/mpeg/.DS_Store b/applications/mpeg/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 4150 Cicli * // ********************************************************************************************************** -#include -#include + +#include +#include "map_pkg.h" #include "mpeg_std.h" typedef int type_DATA; //unsigned @@ -58,9 +46,6 @@ typedef int type_DATA; //unsigned int out; -Message msg1; - - /* iclip table */ short int iclp[1024] = { -256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256,-256, @@ -223,35 +208,31 @@ void idct_func(type_DATA *block,int lx) int main() { - unsigned int time_a, time_b; + printf("MPEG Task D start: iDCT "); int i,j; type_DATA block[64]; - - - Echo("MPEG Task D start: iDCT "); - Echo(itoa(GetTick())); + int msg1[128]; + int size; + int *buff; + int src; for(j=0;j 4214 * // ********************************************************************************************************* - -#include -#include +#include +#include "map_pkg.h" #include "mpeg_std.h" typedef int type_DATA; //unsigned -Message msg1; unsigned char intramatrix[64]={ @@ -86,37 +84,34 @@ void iquant_func(type_DATA *src, int lx, int dc_prec, int mquant) int main() { - unsigned int time_a, time_b; - int i,j; + int msg1[128]; + int size; + int *buff; + int src; + int i,j; type_DATA clk_count; type_DATA block[64]; - - - Echo("MPEG Task C start: iquant "); - Echo(itoa(GetTick())); + puts("MPEG Task C start: iquant \n"); for(j=0;j 57026 * // ********************************************************************************************************* -#include -#include +#include +#include "map_pkg.h" #include "mpeg_std.h" typedef int type_DATA; //unsigned @@ -460,42 +448,37 @@ void ivlc_func(type_DATA *block, short int comp, short int lx, type_DATA *buffer return; } -Message msg1; - int main() { - unsigned int time_a, time_b; + puts("MPEG Task B start: iVLC \n"); + int msg1[128]; + int size; + int *buff; + int src; int i,j; type_DATA vlc_array[128]; type_DATA block[64]; - Echo("MPEG Task B start: iVLC "); - Echo(itoa(GetTick())); - for(j=0;j -#include +#include +#include "map_pkg.h" #include "mpeg_std.h" typedef int type_DATA; //unsigned -Message msg1; + int main() { - unsigned int time_a, time_b; + printf("MPEG Task PRINT start:\n"); int i; + int *buff; + int size; + int src; + - Echo("MPEG Task PRINT start:"); for(i=0;i -#include +#include +#include "map_pkg.h" #include "mpeg_std.h" - unsigned int vlc_array[128] = { // array containing the compressed data stream // It must be specified as an input 0xfa,0xb8,0x20,0x05,0x20,0x20,0x02,0x38, @@ -27,38 +14,23 @@ unsigned int vlc_array[128] = { // array containing the compressed data stream 0xa7,0x3c,0x73,0xb6,0x31,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; -Message msg1; - int main(){ - - unsigned int time_a, time_b; - int i; - - Echo("MPEG Task A start: "); - Echo(itoa(GetTick())); - + puts("MPEG started\n"); + int i; + int size; + int msg1[128]; for(i=0; i<128; i++) - msg1.msg[i] = vlc_array[i]; - - - msg1.length = 128; + msg1[i] = vlc_array[i]; + size = 128; for(i=0;iH1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 -#include -#include "syn_std.h" - -Message msg; +#include +#include "map_pkg.h" +#include "syn_std.h" int main() { int i, j,t; + int msg1[30]; + int size; + //msg1 = malloc(sizeof(int)); - Echo("synthetic task A started."); - Echo(itoa(GetTick())); + puts("synthetic task A started.\n"); for(i=0;i -#include -#include "syn_std.h" - -Message msg; +#include +#include "map_pkg.h" +#include "syn_std.h" int main() { int i, j,t; + int msg1[30]; + int size; - Echo("synthetic task B started."); - Echo(itoa(GetTick())); + puts("synthetic task B started.\n"); -for(i=0;i -#include -#include "syn_std.h" - -Message msg; +#include +#include "map_pkg.h" +#include "syn_std.h" int main() { int i, j,t; + int msg1[30]; + int size; + int *buff; + int src; + puts("synthetic task C started.\n"); - Echo("synthetic task C started."); - Echo(itoa(GetTick())); + //msg1 = malloc(sizeof(int)); for(i=0;i -#include -#include "syn_std.h" - -Message msg; +#include +#include "map_pkg.h" +#include "syn_std.h" int main() { int i, j,t; + int msg1[30]; + int size; + flit_t src; + int *buff; + //msg1 = malloc(sizeof(int)); - Echo("synthetic task D started."); - Echo(itoa(GetTick())); + puts("synthetic task D started.\n"); for(i=0;i -#include -#include "syn_std.h" -Message msg; +#include +#include "map_pkg.h" +#include "syn_std.h" int main() { int i, j,t; + int msg1[30]; + int size; + int *buff; + int src; + //msg1 = malloc(sizeof(int)); - Echo("synthetic task E started."); - Echo(itoa(GetTick())); + puts("synthetic task E started.\n"); for(i=0;i -#include -#include "syn_std.h" - -Message msg; +#include +#include "map_pkg.h" +#include "syn_std.h" int main() { int i,t; + int msg1[30]; + int size; + int src; + int *buff; - Echo("synthetic task F started."); - Echo(itoa(GetTick())); + puts("synthetic task F started.\n"); for(i=0;i Date: Fri, 8 Dec 2017 11:19:12 -0200 Subject: [PATCH 50/54] Removed .DS_Store files --- applications/.DS_Store | Bin 10244 -> 0 bytes applications/aes/.DS_Store | Bin 8196 -> 0 bytes applications/mpeg/.DS_Store | Bin 6148 -> 0 bytes applications/synthetic/.DS_Store | Bin 6148 -> 0 bytes 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 applications/.DS_Store delete mode 100644 applications/aes/.DS_Store delete mode 100644 applications/mpeg/.DS_Store delete mode 100644 applications/synthetic/.DS_Store diff --git a/applications/.DS_Store b/applications/.DS_Store deleted file mode 100644 index 84642979855b7a890b5c6e6706cb3bd71a134951..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMU2GIp6h3EL%FIycEdphbrJL3&AU|y>77WyFyJ)IKD%;XRfp&IhY)7Xvb!WCq zsl_I~7=wQgDj0py#KhDm6ce9}@df`Atr0am_~3)S_~=hG@!Ywy4KB-z34-R{WbV25 z+;isM^UXJN_TB{m?8=)h00{t4=;D%9Q&pz$aeiG7Xjy0+3w%y-#gM zCfp|x$z&wwgrpHFC|pSjSB$n8DBMY(i0qP)oD)*G14f$4*18ivg9F5mq-dv$c6kqOEy$OJb&_br-eUckG&-Rh7D?mc2cr6VoSW9-TdP zMns9xmjY@^qCQLgN{Hes8?@t3b&H^5FBXHoSPWX#mgznBYP~~t)^pSLNo$1F_!M&w zb^CJG6va1~^_={K>yNP7tl?zyjuBX$j>C=pp};y3@YWIE%LUz`;Rs`S-#TcKojqlx z$eLVN@;e=v3~bN!4_P^%WMi^f#G=kuuZ}m|dVBNEJMT&@EMHN>w3XVb!71CfGmbS- zu+3onu;FJd*RFclNrLab2D4($($=kv7 z0$WkDd_%pi9W`ln`#qE2&1B~lH5_TI*Y#mO(w(!YHWfuIYNNhcWrou4Q@ld6RokvI zU+sUG9(AbETeUWYnd*RJWGqLh+O^#ZyH6dQ5@8GF9<4*E#VzVk)|;51c>HkYWT&nl z=QH;jesEyYa%oi;XnIz+cFjIo)nPu?X_|aZN@H@Pz%N8VWjyKV&;V_)2m0VJm{5Sz z@I1T#ufjaM1@FQK@ELp#U%;1e5x$2X;b-^_euqEcPprZkT#p;D9uv3;cj6t`j!Epq zZcJeh9>g>b;2|7F6D=IWadfeOC-5ZB;Ny52pTcMHIeZCU!*lpHp2v6aJ^To?V$qqQqGA7jbWyPQTLZv-(y!W0P+KEA&(k+WG}ce55BAYNG~O5cDY$JtWOAZ0-(cEl6$ z28Fo7qHa_CHiZbyV&T0uZH{ZKg1D=O-EG^oI9ozARl@F$Hcexd#A7kKYd4Kn5o5*Z z-VPcC{-&wnOj=Vsr78?d`FBQoVV>p7NXy8NW5c@ow#A#yRES|#0@Ckg9IQTR^gJxG`JAJIOUB1Y{>pkb4Qs-Wx}8| zBNN6Ao-oQ2SEde`I{43)Yo9vG@UJ9^h&&@}iGW1l+9OaQrbzJf|9w~g|Nq)AM9v@) zkO*8i1h6udPIb}r#nXn;mGHCn1YM(a@xtxqgbZD%3XkJShR5;L;m7geVGHS^L#xm) hNqX)-CnU9~{Of-P$o;?E|NrB&<1#;E|AYJgzW@u32^|0c diff --git a/applications/aes/.DS_Store b/applications/aes/.DS_Store deleted file mode 100644 index cf13a7b81a9160158fe3f4e7cfc4874ff4458f46..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMU2GLa6h7xt%I?zADMH&tZhJ$m0#f=zvBd!1wiitmq;gwYC~&*CySA&_-FkO# zFHnn3d?5z^9#k;;qKS#YClnK(jPV8k6Ri<7Jow;)zWC@*H1W*L-p01HZ;A;!$;_FV zbI#11Z@<~ixfcMiD{r;{)Bu1&l}omon(Gv<=XFtug)=22k^BKh!2*|R4va4bP|ipxTxm_2Jz(gHVTys$o%9KAPBIzF87ZYZpmYZecg8S7L9sjeC4@O( zQp%`}5Qq?1i~zqr<&>>k;6r9!{vLn_xop9o$U0t@tgd7y9NQ0?o4>)>ijtM3s}x?! zmE-9#uaFLmAn$h>xgkF4HG;8h*zfZ^XRdE#58GBD!`5|sZeZB1l@rdkX_3jX0oygb zLYJ3!O<$~&mI{@Z46B}+YHZ$?XltI{mY8a3?Vx`9j*jVRRjF=h+0!#Te(Lnppk~t`v>h2&rRE>tqiO1Dc~L&_U5cf z3T|M;bMoV^pJA0FhBK0PjKJ!29B%9n2G+@d_m28rF6b798OHLyb;u$+d(ujgHMy?k zD;=B&Y|r%%TRER(eX>~wqFyXpAK!HQoy|M%z9%(XzNUg{YqfO)leTYX9jm`!o59!- z!ymC+({@LX5`=DGKWtk$wKDdb+UFYM)@)UE4bwO18<+A@SiLfs&)SdW?cmfbTT@Y9 zTc>NsOgh~G&*ZC_?6RT?O?{oN4{=R*&Z5>-6nUu4`c{=0N}o^h%9%#3NoBs;_b5GQ zF{8I?Z3;8he#gjKj+|=Ob}8%ubzoA4Ehl$tdzDJurVfsHiP-3^M1n* z4o+Auo$3m0&#G&x_R*=1a9yWq@-r#*$;}c!fq=^R2SDx2 zT!gpbJ@^nlhcDnu_zJGV5AYNG0>8r_@F)C*rC5O*u@>tvfm?7V-i7U$#7^wS6!zdD zOk+PD#vwG(!ciPU7Yle2PvaCmiRbWXd=8(-m+^JHgzw;Gd>7xxkMLvs1V6>E@jLup zo-T3~X5XD(cthHrpTw^PU&8iq~Z_?syB@tHOxR8-c^6^c$1Rua>#Kfy`4Ss~5;a3FWU>Q~s2NPJ2w_yWr$0lsSR&2vP zxHn|uetZyn@gZX55FW=24x@pOphJB0Z~{*eAE)sQK7nWPDPrX__$;2s3&hM<@Kt;R zFD~F=PmzIA;#ueUhP^k&H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Fri, 8 Dec 2017 11:42:31 -0200 Subject: [PATCH 51/54] Reverted comm.c to previous implementation due to bug introdution --- software/bareOS/comm.c | 160 ++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/software/bareOS/comm.c b/software/bareOS/comm.c index 19ac543..37e27b4 100644 --- a/software/bareOS/comm.c +++ b/software/bareOS/comm.c @@ -3,111 +3,111 @@ static void *send_buff = NULL; void transmit(flit_t target, flit_t service, - void *msg, size_t msg_len) { - static const flit_t zero = 0; - static mac_header_t p; - size_t flit_len, len; - - // Waiting untill last transmission has finished - while (MemoryRead32(DMNI_SEND_ACTIVE)); - - len = align_type(msg_len, flit_t); - flit_len = len/sizeof(flit_t); - - p.target = target; - p.service = service; - p.length = (flit_len ? flit_len : 1); - p.length += mem_offset(p, p.length)/sizeof(flit_t); - - // Configure DMNI for package header transmission - MemoryWrite32(DMNI_SIZE, MAC_HEADER_LEN); - MemoryWrite32(DMNI_ADDRESS, (size_t)(&p)); - - // Configure DMNI for package payload transmission - if(flit_len) { - free(send_buff); - - if(!(send_buff = malloc(len))) - panic("Cannot allocate memory for transmit buffer.\n"); - - memcpy(send_buff, msg, msg_len); - if(len - msg_len) - memset(send_buff+msg_len, 0, len-msg_len); - - MemoryWrite32(DMNI_SIZE_2, flit_len); - MemoryWrite32(DMNI_ADDRESS_2, (size_t)send_buff); - } else { - MemoryWrite32(DMNI_SIZE_2, 1); - MemoryWrite32(DMNI_ADDRESS_2, (size_t)(&zero)); - } - - MemoryWrite32(DMNI_OP, READ); - MemoryWrite32(DMNI_START, 1); + void *msg, size_t msg_len) { + static const flit_t zero = 0; + static mac_header_t p; + size_t flit_len, len; + + // Waiting untill last transmission has finished + while (MemoryRead32(DMNI_SEND_ACTIVE)); + + len = align_type(msg_len, flit_t); + flit_len = len/sizeof(flit_t); + + p.target = target; + p.service = service; + p.length = (flit_len ? flit_len : 1); + p.length += mem_offset(p, p.length)/sizeof(flit_t); + + // Configure DMNI for package header transmission + MemoryWrite32(DMNI_SIZE, MAC_HEADER_LEN); + MemoryWrite32(DMNI_ADDRESS, (size_t)(&p)); + + // Configure DMNI for package payload transmission + if(flit_len) { + free(send_buff); + + if(!(send_buff = malloc(len))) + panic("Cannot allocate memory for transmit buffer.\n"); + + memcpy(send_buff, msg, msg_len); + if(len - msg_len) + memset(send_buff+msg_len, 0, len-msg_len); + + MemoryWrite32(DMNI_SIZE_2, flit_len); + MemoryWrite32(DMNI_ADDRESS_2, (size_t)send_buff); + } else { + MemoryWrite32(DMNI_SIZE_2, 1); + MemoryWrite32(DMNI_ADDRESS_2, (size_t)(&zero)); + } + + MemoryWrite32(DMNI_OP, READ); + MemoryWrite32(DMNI_START, 1); } -void *prepare_receive(void *buff) { - buff = (void*)align((size_t)buff, 2); - MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)buff); - return buff; +void *prepare_receive(void *buff) { + buff = (void*)align((size_t)buff, 2); + MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)buff); + return buff; } void *wait_receive(){ - size_t ret; - while(!((ret = MemoryRead32(DMNI_RECEIVE_BUFFER)) & 1)); - return (void*)(ret & -4); + size_t ret; + while(!((ret = MemoryRead32(DMNI_RECEIVE_BUFFER)) & 1)); + return (void*)(ret & -4); } void send_msg(flit_t target, void *msg, size_t len) { - msg_req_t msg_req, ack_reply; - void *old_buff; - size_t received_len; + msg_req_t msg_req, ack_reply; + void *old_buff; + size_t received_len; - msg_req.addr = MemoryRead32(NET_ADDRESS); - msg_req.size = align_type(len, flit_t)/sizeof(flit_t); + msg_req.addr = MemoryRead32(NET_ADDRESS); + msg_req.size = align_type(len, flit_t)/sizeof(flit_t); - /* waits previous operation to finish - * this avoids overwriting previous buffer pointer */ - old_buff = wait_receive(); + /* waits previous operation to finish + * this avoids overwriting previous buffer pointer */ + //old_buff = wait_receive(); - transmit(target, REQ_OPERATION, &msg_req, sizeof(msg_req_t)); - prepare_receive(&ack_reply); - wait_receive(); + transmit(target, REQ_OPERATION, &msg_req, sizeof(msg_req_t)); + prepare_receive(&ack_reply); + wait_receive(); - // restauring previous buffer - MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)old_buff & 1); + // restauring previous buffer + //MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)old_buff & 1); - if((ack_reply.addr != msg_req.addr)) - panic("Received ACK diverges from expected\n"); + if((ack_reply.addr != msg_req.addr)) + panic("Received ACK diverges from expected\n"); - received_len = ack_reply.size*sizeof(flit_t); - len = min(received_len, len); - transmit(target, DMA_OPERATION, msg, len); + received_len = ack_reply.size*sizeof(flit_t); + len = min(received_len, len); + transmit(target, DMA_OPERATION, msg, len); } typedef union { - uint32_t i32; - msg_req_t s; + uint32_t i32; + msg_req_t s; } msg_req_u; void *prepare_recv_msg(flit_t *src, size_t *size) { - static msg_req_u req; - void *buff; + static msg_req_u req; + void *buff; - while(!(req.i32 = MemoryRead32(DMNI_REQ_FIFO))); - MemoryWrite32(DMNI_REQ_FIFO, 0); + while(!(req.i32 = MemoryRead32(DMNI_REQ_FIFO))); + MemoryWrite32(DMNI_REQ_FIFO, 0); - if(!(buff = malloc(req.s.size << 2))) - return NULL; + if(!(buff = malloc(req.s.size << 2))) + return NULL; - if(src) *src = req.s.addr; - if(size) *size = req.s.size << 2; - - transmit(req.s.addr, DMA_OPERATION, &req, sizeof(msg_req_t)); + if(src) *src = req.s.addr; + if(size) *size = req.s.size << 2; + + transmit(req.s.addr, DMA_OPERATION, &req, sizeof(msg_req_t)); - return prepare_receive(buff); + return prepare_receive(buff); } void *receive_msg(flit_t *src, size_t *size) { - prepare_recv_msg(src, size); - return wait_receive(); + prepare_recv_msg(src, size); + return wait_receive(); } From c330726b616be0725072dbaa1f53e27e7a6ce89d Mon Sep 17 00:00:00 2001 From: "Luis Fernando Krause (Academico - Hessel)" Date: Fri, 8 Dec 2017 11:51:29 -0200 Subject: [PATCH 52/54] testbench rodando aplicacoes em paralelo --- applications/pc_test2/receiver.c | 17 ++++ applications/pc_test2/sender.c | 13 +++ hardware/vhdl/test_bench.vhd | 164 ++++++++++++++++++++++++++++--- testcases/paralel.yaml | 35 +++++++ 4 files changed, 218 insertions(+), 11 deletions(-) create mode 100644 applications/pc_test2/receiver.c create mode 100644 applications/pc_test2/sender.c create mode 100644 testcases/paralel.yaml diff --git a/applications/pc_test2/receiver.c b/applications/pc_test2/receiver.c new file mode 100644 index 0000000..7b3bfc6 --- /dev/null +++ b/applications/pc_test2/receiver.c @@ -0,0 +1,17 @@ +#include + +int main() { + char *msg = NULL; + flit_t src; + size_t size; + + do { + free(msg); + prepare_recv_msg(&src, &size); + printf("Waiting to receive %d bytes from %X\n", size, src); + msg = wait_receive(); + puts(msg); + } while(strcmp(msg, "END\n")); + + return 0; +} diff --git a/applications/pc_test2/sender.c b/applications/pc_test2/sender.c new file mode 100644 index 0000000..560662f --- /dev/null +++ b/applications/pc_test2/sender.c @@ -0,0 +1,13 @@ +#include +#include "map_pkg.h" + +int main() { + const char *hello = "Hello World!\n"; + + send_msg(receiver, hello, strlen(hello)+1); + printf("Message transmited to %X\n", receiver); + send_msg(receiver, "END\n", strlen("END\n")+1); + printf("Termination message sent to %X, terminating\n", receiver); + + return 0; +} diff --git a/hardware/vhdl/test_bench.vhd b/hardware/vhdl/test_bench.vhd index 5fe2325..a601ebd 100644 --- a/hardware/vhdl/test_bench.vhd +++ b/hardware/vhdl/test_bench.vhd @@ -23,6 +23,14 @@ use work.standards.all; entity test_bench is + type procload is record + position : std_logic_vector(31 downto 0); + status : std_logic; + end record; + + type list_of_procs is array(0 to MAX_TASKS_APP-1) of procload; + + type config is record code_name : string(1 to 40); position : std_logic_vector(31 downto 0); @@ -91,6 +99,38 @@ entity test_bench is return cfg; end get_cfg; + + impure function get_procs (cfg_file : in string) return list_of_procs is + + file file_ptr : text open read_mode is cfg_file; + variable inline : line; + variable strline : string(1 to 40); + variable procs : list_of_procs; + variable cfg : list_of_tasks; + variable str_len : integer; + variable i : integer := 0; + begin + + while not endfile(file_ptr) loop + readline(file_ptr, inline); + str_len := inline'length; + read(inline, strline(1 to inline'length)); + cfg(i).code_name(1 to str_len) := strline(1 to str_len); + cfg(i).code_name(str_len+1 to 40) := (others => NUL); + readline(file_ptr, inline); + hread(inline, cfg(i).position); + procs(i).position := cfg(i).position; + procs(i).status := '1'; + readline(file_ptr, inline); + hread(inline, cfg(i).code_size); + i := i + 1; + end loop; + file_close(file_ptr); + return procs; + end get_procs; + + + impure function get_num_tasks(cfg_file : in string) return integer is file file_ptr : text open read_mode is cfg_file; @@ -128,8 +168,34 @@ entity test_bench is return apps_cfg; end get_apps_cfg; + + impure function next_wave (taloc : in integer; vapp_counter: in integer; vapps_cfg: list_of_apps; vlisttask_ocupacao: arrayNPe_reg32) return integer is + variable talocret: integer := 0; + variable task_cfg : list_of_tasks; + variable proc_load : list_of_procs; + variable task_num : integer; + begin + if (vapp_counter+1 < APP_NUMBER) then + task_cfg := get_cfg(vapps_cfg(vapp_counter+1)); + proc_load := get_procs(vapps_cfg(vapp_counter+1)); + task_num := get_num_tasks(vapps_cfg(vapp_counter+1)); + for i in 0 to task_num-1 loop + for j in 0 to NUMBER_PROCESSORS-1 loop + if (task_cfg(i).position = RouterAddress(j)) then + if (vlisttask_ocupacao(j) = x"00000001") then + talocret := 1; + end if; + end if; + end loop; + end loop; + end if; + + return talocret; + end next_wave; + end; + architecture test_bench of test_bench is signal clock : std_logic := '0'; @@ -152,8 +218,12 @@ architecture test_bench of test_bench is signal clock_rx_io : std_logic_vector((IO_NUMBER-1) downto 0); --Leitura para IO + signal task_cfg : list_of_tasks; + signal ntask_cfg : list_of_tasks; + signal proc_load : list_of_procs; signal task_num : integer; + signal ntask_num : integer; signal rd_addr : std_logic_vector(23 downto 0); signal flit_counter : integer; signal file_counter : integer; @@ -163,6 +233,13 @@ architecture test_bench of test_bench is signal packstart_data : packstart_type; signal task_code : repo_type; + --- Variaveis novas testbench + signal listtask_ocupacao_ret : arrayNPe_reg32:= (others=>x"00000010"); + signal listtask_ocupacao_env : arrayNPe_reg32:= (others=>x"00000010"); + signal listtask_ocupacao : arrayNPe_reg32; + + --- Variaveis novas testbench Fim + type send_state is (WAIT_state, GET_CODE, SEND_TASK, SEND_START); signal SEND: send_state; @@ -171,7 +248,7 @@ begin packstart_data(0) <= x"00000002"; packstart_data(1) <= x"00000300"; packstart_data(2) <= x"00000000"; - + -- -- HeMPS instantiation -- @@ -230,6 +307,37 @@ begin ); + +--------------------------------------------------------------------------------------------- +-- recebe retornos de encerramento +--------------------------------------------------------------------------------------------- + + process + begin + wait until (clock_tx_io(0)'event and clock_tx_io(0) = '1') or (reset'event and reset = '1'); + if reset = '1' then + for i in 0 to NUMBER_PROCESSORS -1 loop + listtask_ocupacao_ret(i) <= listtask_ocupacao_ret(i) + x"00000000"; + end loop; + else + if (data_out_io(0) = x"E0000000") then + wait until (clock_tx_io(0)'event and clock_tx_io(0) = '1'); + wait until (clock_tx_io(0)'event and clock_tx_io(0) = '1'); + wait until (clock_tx_io(0)'event and clock_tx_io(0) = '1'); + if (data_out_io(0) = x"00000070") then + wait until (clock_tx_io(0)'event and clock_tx_io(0) = '1'); + for i in 0 to NUMBER_PROCESSORS -1 loop + if (RouterAddress(i) = data_out_io(0)) then + listtask_ocupacao_ret(i) <= listtask_ocupacao_ret(i) + x"00000001"; + end if; + end loop; + end if; + end if; + end if; + end process; + + + reset <= '1', '0' after 100 ns; -- 100 MHz clock <= not clock after 5 ns; @@ -238,27 +346,61 @@ begin --Conecta o testbench inicialmente no IO 0 clock_rx_io(0) <= clock; - process (clock, reset) + process + variable liberar_envio : integer := 1; begin + wait until (clock'event and clock = '1') or (reset'event and reset = '1'); if reset = '1' then rx_io(0) <= '0'; rd_addr <= (others => '0'); - flit_counter <= 0; + flit_counter <= 0; packstart_counter <= 0; file_counter <= 0; app_counter <= 0; task_num <= 0; + liberar_envio := 1; SEND <= WAIT_state; - elsif rising_edge(clock) then + else + for i in 0 to NUMBER_PROCESSORS-1 loop + listtask_ocupacao(i) <= listtask_ocupacao_env(i) - listtask_ocupacao_ret(i); + end loop; case SEND is when WAIT_state => - if app_counter < APP_NUMBER then + if (liberar_envio = 0) then + liberar_envio := 1; + for i in 0 to ntask_num-1 loop + for j in 0 to NUMBER_PROCESSORS-1 loop + if (ntask_cfg(i).position = RouterAddress(j)) then + if (listtask_ocupacao(j) = x"00000001") then + liberar_envio := 0; + end if; + end if; + end loop; + end loop; + end if; + wait until (clock'event and clock = '1'); + if ((app_counter < APP_NUMBER) and (liberar_envio = 1)) then + liberar_envio := 0; task_cfg <= get_cfg(apps_cfg(app_counter)); - task_num <= get_num_tasks(apps_cfg(app_counter)); + proc_load <= get_procs(apps_cfg(app_counter)); + task_num <= get_num_tasks(apps_cfg(app_counter)); + if(app_counter+1 < APP_NUMBER) then + ntask_cfg <= get_cfg(apps_cfg(app_counter+1)); + ntask_num <= get_num_tasks(apps_cfg(app_counter+1)); + end if; + wait until (clock'event and clock = '1'); + for i in 0 to NUMBER_PROCESSORS-1 loop + for j in 0 to task_num-1 loop + if (proc_load(j).position = RouterAddress(i)) then + listtask_ocupacao_env(i) <= listtask_ocupacao_env(i) + x"00000001"; + end if; + end loop; + end loop; SEND <= GET_CODE; + end if; - when GET_CODE => + when GET_CODE => if file_counter < task_num then flit_counter <= CONV_INTEGER(task_cfg(file_counter).code_size); task_code <= load_repo(task_cfg(file_counter).code_name); @@ -267,10 +409,10 @@ begin else app_counter <= app_counter + 1; file_counter <= 0; - SEND <= WAIT_state; + SEND <= WAIT_state; end if; - when SEND_TASK => + when SEND_TASK => if credit_o_io(0) = '1' and flit_counter > 0 then rx_io(0) <= '1'; rd_addr <= rd_addr + 1; @@ -285,13 +427,13 @@ begin flit_counter <= flit_counter - 1; end if; elsif flit_counter = 0 then - SEND <= SEND_START; + SEND <= SEND_START; rd_addr <= (others => '0'); rx_io(0) <= '0'; end if; when SEND_START => - if credit_o_io(0) = '1' and rd_addr < TAM_PACKSTART then + if credit_o_io(0) = '1' and rd_addr < TAM_PACKSTART then rx_io(0) <= '1'; rd_addr <= rd_addr + 1; if rd_addr = 0 then diff --git a/testcases/paralel.yaml b/testcases/paralel.yaml new file mode 100644 index 0000000..42523aa --- /dev/null +++ b/testcases/paralel.yaml @@ -0,0 +1,35 @@ +hw: + page_size_KB: 32 + tasks_per_PE: 1 + repository_size_MB: 1 + model_description: vhdl + noc_buffer_size: 8 + mpsoc_dimension: [3,2] + cluster_dimension: [3,2] + master_location: LB + simple_soc: true + open_port: + - port: [0,0,S] +apps: + - name: pc_test + tasks: + - task: receiver + location: [0,1] + - task: sender + location: [1,1] + - name: pc_test2 + tasks: + - task: receiver + location: [2,1] + - task: sender + location: [2,0] + - name: sort + tasks: + - task: master + location: [1,1] + - task: slave1 + location: [0,1] + - task: slave2 + location: [0,0] + - task: slave3 + location: [1,0] \ No newline at end of file From 1722b9685a88476aa7b78bfe456eb53b93677300 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 8 Dec 2017 14:45:24 -0200 Subject: [PATCH 53/54] Untabify bareOS source code --- software/bareOS/hal.c | 32 +- software/bareOS/include/comm.h | 14 +- software/bareOS/include/hal.h | 100 +++---- software/bareOS/include/libos.h | 22 +- software/bareOS/include/prototypes.h | 1 - software/bareOS/libos.c | 180 +++++------ software/bareOS/malloc.c | 60 ++-- software/bareOS/softmul.c | 428 +++++++++++++-------------- 8 files changed, 418 insertions(+), 419 deletions(-) diff --git a/software/bareOS/hal.c b/software/bareOS/hal.c index b5518a0..775f048 100644 --- a/software/bareOS/hal.c +++ b/software/bareOS/hal.c @@ -1,31 +1,31 @@ #include "include/libos.h" typedef struct { - flit_t source; - flit_t retcode; + flit_t source; + flit_t retcode; } exit_msg_t; void exit(int code) { - exit_msg_t msg; + exit_msg_t msg; - msg.source = MemoryRead32(NET_ADDRESS); - msg.retcode = code; + msg.source = MemoryRead32(NET_ADDRESS); + msg.retcode = code; - transmit(MemoryRead32(LOADER_NETADDR), EXIT_OPERATION, &msg, sizeof(exit_msg_t)); - - for(;;) MemoryWrite32(CPU_KILL, CPU_KILL_MAGIC); + transmit(MemoryRead32(LOADER_NETADDR), EXIT_OPERATION, &msg, sizeof(exit_msg_t)); + + for(;;) MemoryWrite32(CPU_KILL, CPU_KILL_MAGIC); } void putchar(char c) { - MemoryWrite32(UART_WRITE, (uint32_t)c<<24); + MemoryWrite32(UART_WRITE, (uint32_t)c<<24); } void puts(const char *string) { - int *str_part; - //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines - //PS: This indicates a hardware developer putting its hands on software development - //PS2: The original author need to review demorgans law for boolean simplification - for(str_part = (int*)string, MemoryWrite32(UART_WRITE, *str_part); - ((char*)str_part)[0] && ((char*)str_part)[1] && ((char*)str_part)[2] && ((char*)str_part)[3]; - MemoryWrite32(UART_WRITE, *(++str_part))); + int *str_part; + //This is the most crazy and complicated FOR declaration that I ever seen. For obviously purposes, I divided the FOR section in lines + //PS: This indicates a hardware developer putting its hands on software development + //PS2: The original author need to review demorgans law for boolean simplification + for(str_part = (int*)string, MemoryWrite32(UART_WRITE, *str_part); + ((char*)str_part)[0] && ((char*)str_part)[1] && ((char*)str_part)[2] && ((char*)str_part)[3]; + MemoryWrite32(UART_WRITE, *(++str_part))); } diff --git a/software/bareOS/include/comm.h b/software/bareOS/include/comm.h index 5c2dcde..3f32201 100644 --- a/software/bareOS/include/comm.h +++ b/software/bareOS/include/comm.h @@ -20,19 +20,19 @@ typedef uint32_t flit_t; typedef struct { - flit_t target; - flit_t length; - flit_t service; - flit_t payload[]; + flit_t target; + flit_t length; + flit_t service; + flit_t payload[]; } mac_header_t; typedef struct { - uint16_t addr; - uint16_t size; + uint16_t addr; + uint16_t size; } msg_req_t; void transmit(flit_t target, flit_t service, - void *msg, size_t len); + void *msg, size_t len); void *prepare_receive(void *buff); void *wait_receive(); diff --git a/software/bareOS/include/hal.h b/software/bareOS/include/hal.h index 4c003e4..5a7d969 100644 --- a/software/bareOS/include/hal.h +++ b/software/bareOS/include/hal.h @@ -15,29 +15,29 @@ extern uint8_t _stack; #define HEAP_ALLOCATION_GRAIN 10 //1kB /*********** Hardware addresses ***********/ -#define UART_WRITE 0x20000000 -#define UART_READ 0x20000000 -#define IRQ_MASK 0x20000010 -#define IRQ_STATUS 0x20000020 -#define TIME_SLICE 0x20000060 -#define SYS_CALL 0x20000070 -#define END_SIM 0x20000080 -#define CLOCK_HOLD 0x20000090 +#define UART_WRITE 0x20000000 +#define UART_READ 0x20000000 +#define IRQ_MASK 0x20000010 +#define IRQ_STATUS 0x20000020 +#define TIME_SLICE 0x20000060 +#define SYS_CALL 0x20000070 +#define END_SIM 0x20000080 +#define CLOCK_HOLD 0x20000090 /* Network Interface*/ -#define NI_STATUS_RECV 0x20000100 -#define NI_STATUS_SEND 0x20000110 -#define NI_RECV 0x20000120 -#define NI_SEND 0x20000130 -#define NI_CONFIG 0x20000140 -#define NI_ACK 0x20000150 -#define NI_NACK 0x20000160 -#define NI_END 0x20000170 -#define CURRENT_PAGE 0x20000180 -#define NEXT_PAGE 0x20000190 +#define NI_STATUS_RECV 0x20000100 +#define NI_STATUS_SEND 0x20000110 +#define NI_RECV 0x20000120 +#define NI_SEND 0x20000130 +#define NI_CONFIG 0x20000140 +#define NI_ACK 0x20000150 +#define NI_NACK 0x20000160 +#define NI_END 0x20000170 +#define CURRENT_PAGE 0x20000180 +#define NEXT_PAGE 0x20000190 /* Network information */ -#define NET_ADDRESS 0x20000140 +#define NET_ADDRESS 0x20000140 #define LOADER_NETADDR 0x20000144 /* Task termination */ @@ -45,53 +45,53 @@ extern uint8_t _stack; #define CPU_KILL_MAGIC 0xDEADBEEF /* DMNI */ -#define DMNI_SIZE_2 0x20000204 -#define DMNI_ADDRESS_2 0x20000214 -#define DMNI_SIZE 0x20000200 -#define DMNI_ADDRESS 0x20000210 -#define DMNI_OP 0x20000220 -#define DMNI_START 0x20000230 -#define DMNI_ACK 0x20000240 -#define DMNI_SEND_ACTIVE 0x20000250 -#define DMNI_RECEIVE_ACTIVE 0x20000260 +#define DMNI_SIZE_2 0x20000204 +#define DMNI_ADDRESS_2 0x20000214 +#define DMNI_SIZE 0x20000200 +#define DMNI_ADDRESS 0x20000210 +#define DMNI_OP 0x20000220 +#define DMNI_START 0x20000230 +#define DMNI_ACK 0x20000240 +#define DMNI_SEND_ACTIVE 0x20000250 +#define DMNI_RECEIVE_ACTIVE 0x20000260 #define DMNI_RECEIVE_BUFFER 0x20000264 #define DMNI_REQ_FIFO 0x20000268 //Scheduling report -#define SCHEDULING_REPORT 0x20000270 -#define INTERRUPTION 0x10000 -//#define SYSCALL 0x20000 -#define SCHEDULER 0x40000 -#define IDLE 0x80000 +#define SCHEDULING_REPORT 0x20000270 +#define INTERRUPTION 0x10000 +//#define SYSCALL 0x20000 +#define SCHEDULER 0x40000 +#define IDLE 0x80000 //Communication graphical debbug -#define ADD_PIPE_DEBUG 0x20000280 -#define REM_PIPE_DEBUG 0x20000285 -#define ADD_REQUEST_DEBUG 0x20000290 -#define REM_REQUEST_DEBUG 0x20000295 +#define ADD_PIPE_DEBUG 0x20000280 +#define REM_PIPE_DEBUG 0x20000285 +#define ADD_REQUEST_DEBUG 0x20000290 +#define REM_REQUEST_DEBUG 0x20000295 /* DMNI operations */ -#define READ 0 -#define WRITE 1 +#define READ 0 +#define WRITE 1 -#define TICK_COUNTER 0x20000300 -#define CURRENT_TASK 0x20000400 +#define TICK_COUNTER 0x20000300 +#define CURRENT_TASK 0x20000400 -#define REQ_APP 0x20000350 -#define ACK_APP 0x20000360 +#define REQ_APP 0x20000350 +#define ACK_APP 0x20000360 -#define SLACK_TIME_MONITOR 0x20000370 +#define SLACK_TIME_MONITOR 0x20000370 //Kernel pending service FIFO -#define PENDING_SERVICE_INTR 0x20000400 +#define PENDING_SERVICE_INTR 0x20000400 -#define SLACK_TIME_WINDOW 50000 // half milisecond +#define SLACK_TIME_WINDOW 50000 // half milisecond /*********** Interrupt bits **************/ -#define IRQ_PENDING_SERVICE 0x01 //bit 0 -#define IRQ_SLACK_TIME 0x02 //bit 1 -#define IRQ_SCHEDULER 0x08 //bit 3 -#define IRQ_NOC 0x20 //bit 5 +#define IRQ_PENDING_SERVICE 0x01 //bit 0 +#define IRQ_SLACK_TIME 0x02 //bit 1 +#define IRQ_SCHEDULER 0x08 //bit 3 +#define IRQ_NOC 0x20 //bit 5 /*Memory Access*/ #define MemoryRead32(A) (*(volatile uint32_t*)(A)) diff --git a/software/bareOS/include/libos.h b/software/bareOS/include/libos.h index 29d580b..4487523 100644 --- a/software/bareOS/include/libos.h +++ b/software/bareOS/include/libos.h @@ -4,17 +4,17 @@ #include "hal.h" #include "comm.h" -#define isprint(c) (' '<=(c)&&(c)<='~') -#define isspace(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\r') -#define isdigit(c) ('0'<=(c)&&(c)<='9') -#define islower(c) ('a'<=(c)&&(c)<='z') -#define isupper(c) ('A'<=(c)&&(c)<='Z') -#define isalpha(c) (islower(c)||isupper(c)) -#define isalnum(c) (isalpha(c)||isdigit(c)) -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#define ntohs(A) (((A)>>8) | (((A)&0xff)<<8)) -#define ntohl(A) (((A)>>24) | (((A)&0xff0000)>>8) | (((A)&0xff00)<<8) | ((A)<<24)) +#define isprint(c) (' '<=(c)&&(c)<='~') +#define isspace(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\r') +#define isdigit(c) ('0'<=(c)&&(c)<='9') +#define islower(c) ('a'<=(c)&&(c)<='z') +#define isupper(c) ('A'<=(c)&&(c)<='Z') +#define isalpha(c) (islower(c)||isupper(c)) +#define isalnum(c) (isalpha(c)||isdigit(c)) +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) +#define ntohs(A) (((A)>>8) | (((A)&0xff)<<8)) +#define ntohl(A) (((A)>>24) | (((A)&0xff0000)>>8) | (((A)&0xff00)<<8) | ((A)<<24)) #define va_start(ap, argN) __builtin_va_start(ap, argN) #define va_arg(ap, type) __builtin_va_arg(ap, type) diff --git a/software/bareOS/include/prototypes.h b/software/bareOS/include/prototypes.h index b77a280..643808a 100644 --- a/software/bareOS/include/prototypes.h +++ b/software/bareOS/include/prototypes.h @@ -11,7 +11,6 @@ typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef __SIZE_TYPE__ size_t; - #define NULL ((void*)0) #endif /* !PROTOTYPES_H */ diff --git a/software/bareOS/libos.c b/software/bareOS/libos.c index 956823a..2759ae4 100644 --- a/software/bareOS/libos.c +++ b/software/bareOS/libos.c @@ -51,10 +51,10 @@ char *itoa(int i, char *s, int base){ } union ptr { - const void *v; - uint8_t *uint8; - uint16_t *uint16; - uint32_t *uint32; + const void *v; + uint8_t *uint8; + uint16_t *uint16; + uint32_t *uint32; }; @@ -62,87 +62,87 @@ void *memset(void *dst, int ic, size_t bytes) { uint8_t c; uint32_t f; - union ptr d = {.v = dst}; - - /* Probably the most assemblish code ever written in C! - * This is what you get when you put a processor designer - * to write software */ - - c = ic; - - switch(bytes & 3) { - case 3: - *(d.uint8++) = c; - bytes--; - case 2: - *(d.uint8++) = c; - bytes--; - case 1: - *(d.uint8++) = c; - bytes--; - case 0: - f = (c << 24) | (c << 16) | (c << 8) | c; - while(bytes){ - *(d.uint32++) = f; - bytes -= 4; - } - } - + union ptr d = {.v = dst}; + + /* Probably the most assemblish code ever written in C! + * This is what you get when you put a processor designer + * to write software */ + + c = ic; + + switch(bytes & 3) { + case 3: + *(d.uint8++) = c; + bytes--; + case 2: + *(d.uint8++) = c; + bytes--; + case 1: + *(d.uint8++) = c; + bytes--; + case 0: + f = (c << 24) | (c << 16) | (c << 8) | c; + while(bytes){ + *(d.uint32++) = f; + bytes -= 4; + } + } + return dst; } void *memcpy(void *dst, const void *src, size_t bytes) { - union ptr d = {.v = dst} , s = {.v = src}; - - while(bytes) { - switch(((size_t)d.v | (size_t)s.v | bytes) & 3) { - case 0: - *(d.uint32++) = *(s.uint32++); - bytes-=4; - break; - case 2: - *(d.uint16++) = *(s.uint16++); - bytes-=2; - break; - case 1: - case 3: - *(d.uint8++) = *(s.uint8++); - bytes--; - break; - } - } - + union ptr d = {.v = dst} , s = {.v = src}; + + while(bytes) { + switch(((size_t)d.v | (size_t)s.v | bytes) & 3) { + case 0: + *(d.uint32++) = *(s.uint32++); + bytes-=4; + break; + case 2: + *(d.uint16++) = *(s.uint16++); + bytes-=2; + break; + case 1: + case 3: + *(d.uint8++) = *(s.uint8++); + bytes--; + break; + } + } + return dst; } int strcmp(const char *a, const char *b) { - while(*a && *b && *a == *b) a++, b++; + while(*a && *b && *a == *b) a++, b++; - return *a - *b; + return *a - *b; } size_t strlen(const char *a) { - size_t ret; + size_t ret; - for(ret = 0 ; *a ; a++, ret++); + for(ret = 0 ; *a ; a++, ret++); - return ret; + return ret; } void panic(const char *fmt, ...) { va_list ap; int ret; - puts("PANIC: "); + puts("PANIC: "); va_start(ap, fmt); ret = vprintf(fmt, ap); va_end(ap); - putchar('\n'); + putchar('\n'); - exit(-1); + exit(-1); } int printf(const char *fmt, ...) { @@ -169,46 +169,46 @@ int vprintf(const char *fmt, va_list ap){ switch (*++fmt){ case 'i': case 'd': - i = va_arg(ap, int); - itoa(i,buf,10); - puts(buf); - break; + i = va_arg(ap, int); + itoa(i,buf,10); + puts(buf); + break; case 'u': - i = va_arg(ap, int); - utoa(i, buf, 10); - puts(buf); - break; + i = va_arg(ap, int); + utoa(i, buf, 10); + puts(buf); + break; case 'o': - i = va_arg(ap, int); - utoa(i,buf,8); - puts(buf); - break; + i = va_arg(ap, int); + utoa(i,buf,8); + puts(buf); + break; case 'p': - puts("0x"); + puts("0x"); case 'X': - i = va_arg(ap, int); - utoa(i,buf,16); - j=0; - while (buf[j]) - buf[j] = islower(buf[j]) ? buf[j++] - 0x20 : buf[j++]; - puts(buf); - break; + i = va_arg(ap, int); + utoa(i,buf,16); + j=0; + while (buf[j]) + buf[j] = islower(buf[j]) ? buf[j++] - 0x20 : buf[j++]; + puts(buf); + break; case 'x': - i = va_arg(ap, int); - itoa(i,buf,16); - puts(buf); - break; + i = va_arg(ap, int); + itoa(i,buf,16); + puts(buf); + break; case 'c': - putchar(va_arg(ap, int)); - break; + putchar(va_arg(ap, int)); + break; case 's': - s = va_arg(ap, char*); - if (!s) s = "(null)"; - puts(s); - break; + s = va_arg(ap, char*); + if (!s) s = "(null)"; + puts(s); + break; case '%' : - putchar('%'); - break; + putchar('%'); + break; } fmt++; } diff --git a/software/bareOS/malloc.c b/software/bareOS/malloc.c index 8486b2b..664192f 100644 --- a/software/bareOS/malloc.c +++ b/software/bareOS/malloc.c @@ -3,32 +3,32 @@ /* Shamelessly stolen from K&R C Programing Language Book */ typedef struct header { - struct header *ptr; - size_t size; + struct header *ptr; + size_t size; } header_t __attribute__ ((aligned(MALLOC_ALIGNMENT))); static header_t base = {.ptr = &base, .size = 0 }; static header_t *freep = &base; static header_t *morecore(size_t nunits) { - static header_t *lastp = HEAP_START; - header_t *p; - size_t size; - - size = align_type(min(align(nunits*sizeof(header_t), HEAP_ALLOCATION_GRAIN), - ((size_t)lastp)-((size_t)HEAP_END)), header_t); - size /= sizeof(header_t); - - if(((void*)lastp >= HEAP_END) || size < nunits) - return NULL; - - p = lastp; - lastp += size; - - p->size = size; - free(p+1); - - return p; + static header_t *lastp = HEAP_START; + header_t *p; + size_t size; + + size = align_type(min(align(nunits*sizeof(header_t), HEAP_ALLOCATION_GRAIN), + ((size_t)lastp)-((size_t)HEAP_END)), header_t); + size /= sizeof(header_t); + + if(((void*)lastp >= HEAP_END) || size < nunits) + return NULL; + + p = lastp; + lastp += size; + + p->size = size; + free(p+1); + + return p; } void *malloc(size_t nbytes) { @@ -43,21 +43,21 @@ void *malloc(size_t nbytes) { for (p = prevp->ptr; ; prevp = p, p = p->ptr) { if (p->size >= nunits) { if (p->size == nunits) - prevp->ptr = p->ptr; + prevp->ptr = p->ptr; else { - p->size -= nunits; - p += p->size; - p->size = nunits; + p->size -= nunits; + p += p->size; + p->size = nunits; } freep = prevp; leave_critical(critical); return (void *)(p+1); } if (p == freep) { - if((p = morecore(nunits)) == NULL) { - leave_critical(critical); - return NULL; - } + if((p = morecore(nunits)) == NULL) { + leave_critical(critical); + return NULL; + } } } } @@ -66,9 +66,9 @@ void free(void *ap) { header_t *bp, *p; int critical; - if(!ap) return; + if(!ap) return; - bp = (header_t *)ap - 1; + bp = (header_t *)ap - 1; critical = enter_critical(); diff --git a/software/bareOS/softmul.c b/software/bareOS/softmul.c index 9c740f7..a7d748d 100644 --- a/software/bareOS/softmul.c +++ b/software/bareOS/softmul.c @@ -2,284 +2,284 @@ * software implementation of multiply/divide and 64-bit routines * copied from Hellfire-OS by Sergio Johann Filho * https://github.com/sjohann81/hellfireos -*/ + */ #include "include/prototypes.h" typedef union{ - int64_t all; - struct{ + int64_t all; + struct{ #if LITTLE_ENDIAN - uint32_t low; - int32_t high; + uint32_t low; + int32_t high; #else - int32_t high; - uint32_t low; + int32_t high; + uint32_t low; #endif - } s; + } s; } dwords; int32_t __mulsi3(uint32_t a, uint32_t b){ - uint32_t answer = 0; - - while(b){ - if(b & 1) - answer += a; - a <<= 1; - b >>= 1; - } - return answer; + uint32_t answer = 0; + + while(b){ + if(b & 1) + answer += a; + a <<= 1; + b >>= 1; + } + return answer; } int64_t __muldsi3(uint32_t a, uint32_t b){ - dwords r; - - const int32_t bits_in_word_2 = (int32_t)(sizeof(int32_t) * 8) / 2; - const uint32_t lower_mask = (uint32_t)~0 >> bits_in_word_2; - r.s.low = (a & lower_mask) * (b & lower_mask); - uint32_t t = r.s.low >> bits_in_word_2; - r.s.low &= lower_mask; - t += (a >> bits_in_word_2) * (b & lower_mask); - r.s.low += (t & lower_mask) << bits_in_word_2; - r.s.high = t >> bits_in_word_2; - t = r.s.low >> bits_in_word_2; - r.s.low &= lower_mask; - t += (b >> bits_in_word_2) * (a & lower_mask); - r.s.low += (t & lower_mask) << bits_in_word_2; - r.s.high += t >> bits_in_word_2; - r.s.high += (a >> bits_in_word_2) * (b >> bits_in_word_2); - - return r.all; + dwords r; + + const int32_t bits_in_word_2 = (int32_t)(sizeof(int32_t) * 8) / 2; + const uint32_t lower_mask = (uint32_t)~0 >> bits_in_word_2; + r.s.low = (a & lower_mask) * (b & lower_mask); + uint32_t t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; + t += (a >> bits_in_word_2) * (b & lower_mask); + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high = t >> bits_in_word_2; + t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; + t += (b >> bits_in_word_2) * (a & lower_mask); + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high += t >> bits_in_word_2; + r.s.high += (a >> bits_in_word_2) * (b >> bits_in_word_2); + + return r.all; } int64_t __muldi3(int64_t a, int64_t b){ - dwords x; - x.all = a; - dwords y; - y.all = b; - dwords r; - r.all = __muldsi3(x.s.low, y.s.low); -/* r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; */ - r.s.high += __mulsi3(x.s.high, y.s.low) + __mulsi3(x.s.low, y.s.high); - - return r.all; + dwords x; + x.all = a; + dwords y; + y.all = b; + dwords r; + r.all = __muldsi3(x.s.low, y.s.low); + /* r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; */ + r.s.high += __mulsi3(x.s.high, y.s.low) + __mulsi3(x.s.low, y.s.high); + + return r.all; } uint32_t __udivmodsi4(uint32_t num, uint32_t den, int32_t modwanted){ - uint32_t bit = 1; - uint32_t res = 0; - - while (den < num && bit && !(den & (1L << 31))) { - den <<= 1; - bit <<= 1; - } - while (bit){ - if (num >= den){ - num -= den; - res |= bit; - } - bit >>= 1; - den >>= 1; - } - if (modwanted) - return num; - return res; + uint32_t bit = 1; + uint32_t res = 0; + + while (den < num && bit && !(den & (1L << 31))) { + den <<= 1; + bit <<= 1; + } + while (bit){ + if (num >= den){ + num -= den; + res |= bit; + } + bit >>= 1; + den >>= 1; + } + if (modwanted) + return num; + return res; } int32_t __divsi3(int32_t a, int32_t b){ - int32_t neg = 0; - int32_t res; + int32_t neg = 0; + int32_t res; - if (a < 0){ - a = -a; - neg = !neg; - } + if (a < 0){ + a = -a; + neg = !neg; + } - if (b < 0){ - b = -b; - neg = !neg; - } + if (b < 0){ + b = -b; + neg = !neg; + } - res = __udivmodsi4(a, b, 0); + res = __udivmodsi4(a, b, 0); - if (neg) - res = -res; + if (neg) + res = -res; - return res; + return res; } int32_t __modsi3(int32_t a, int32_t b){ - int32_t neg = 0; - int32_t res; + int32_t neg = 0; + int32_t res; - if (a < 0){ - a = -a; - neg = 1; - } + if (a < 0){ + a = -a; + neg = 1; + } - if (b < 0) - b = -b; + if (b < 0) + b = -b; - res = __udivmodsi4(a, b, 1); + res = __udivmodsi4(a, b, 1); - if (neg) - res = -res; + if (neg) + res = -res; - return res; + return res; } uint32_t __udivsi3 (uint32_t a, uint32_t b){ - return __udivmodsi4(a, b, 0); + return __udivmodsi4(a, b, 0); } uint32_t __umodsi3 (uint32_t a, uint32_t b){ - return __udivmodsi4(a, b, 1); + return __udivmodsi4(a, b, 1); } int64_t __ashldi3(int64_t u, uint32_t b){ - dwords uu, w; - uint32_t bm; - - if (b == 0) - return u; - - uu.all = u; - bm = 32 - b; - - if (bm <= 0){ - w.s.low = 0; - w.s.high = (uint32_t) uu.s.low << -bm; - }else{ - const uint32_t carries = (uint32_t) uu.s.low >> bm; - - w.s.low = (uint32_t) uu.s.low << b; - w.s.high = ((uint32_t) uu.s.high << b) | carries; - } - - return w.all; + dwords uu, w; + uint32_t bm; + + if (b == 0) + return u; + + uu.all = u; + bm = 32 - b; + + if (bm <= 0){ + w.s.low = 0; + w.s.high = (uint32_t) uu.s.low << -bm; + }else{ + const uint32_t carries = (uint32_t) uu.s.low >> bm; + + w.s.low = (uint32_t) uu.s.low << b; + w.s.high = ((uint32_t) uu.s.high << b) | carries; + } + + return w.all; } int64_t __ashrdi3(int64_t u, uint32_t b){ - dwords uu, w; - uint32_t bm; - - if (b == 0) - return u; - - uu.all = u; - bm = 32 - b; - - if (bm <= 0){ - /* w.s.high = 1..1 or 0..0 */ - w.s.high = uu.s.high >> 31; - w.s.low = uu.s.low >> -bm; - }else{ - const uint32_t carries = (uint32_t) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((uint32_t) uu.s.low >> b) | carries; - } - - return w.all; + dwords uu, w; + uint32_t bm; + + if (b == 0) + return u; + + uu.all = u; + bm = 32 - b; + + if (bm <= 0){ + /* w.s.high = 1..1 or 0..0 */ + w.s.high = uu.s.high >> 31; + w.s.low = uu.s.low >> -bm; + }else{ + const uint32_t carries = (uint32_t) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((uint32_t) uu.s.low >> b) | carries; + } + + return w.all; } int64_t __lshrdi3(int64_t u, uint32_t b){ - dwords uu, w; - uint32_t bm; - - if (b == 0) - return u; - - uu.all = u; - bm = 32 - b; - - if (bm <= 0){ - w.s.high = 0; - w.s.low = (uint32_t) uu.s.high >> -bm; - }else{ - const uint32_t carries = (uint32_t) uu.s.high << bm; - - w.s.high = (uint32_t) uu.s.high >> b; - w.s.low = ((uint32_t) uu.s.low >> b) | carries; - } - - return w.all; + dwords uu, w; + uint32_t bm; + + if (b == 0) + return u; + + uu.all = u; + bm = 32 - b; + + if (bm <= 0){ + w.s.high = 0; + w.s.low = (uint32_t) uu.s.high >> -bm; + }else{ + const uint32_t carries = (uint32_t) uu.s.high << bm; + + w.s.high = (uint32_t) uu.s.high >> b; + w.s.low = ((uint32_t) uu.s.low >> b) | carries; + } + + return w.all; } uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p){ - uint64_t quot = 0, qbit = 1; - - if (den == 0){ - return 1 / ((uint32_t)den); - } - - while ((int64_t)den >= 0){ - den <<= 1; - qbit <<= 1; - } - - while (qbit){ - if (den <= num){ - num -= den; - quot += qbit; - } - den >>= 1; - qbit >>= 1; - } - - if (rem_p) - *rem_p = num; - - return quot; + uint64_t quot = 0, qbit = 1; + + if (den == 0){ + return 1 / ((uint32_t)den); + } + + while ((int64_t)den >= 0){ + den <<= 1; + qbit <<= 1; + } + + while (qbit){ + if (den <= num){ + num -= den; + quot += qbit; + } + den >>= 1; + qbit >>= 1; + } + + if (rem_p) + *rem_p = num; + + return quot; } uint64_t __umoddi3(uint64_t num, uint64_t den){ - uint64_t v; + uint64_t v; - (void) __udivmoddi4(num, den, &v); - return v; + (void) __udivmoddi4(num, den, &v); + return v; } uint64_t __udivdi3(uint64_t num, uint64_t den){ - return __udivmoddi4(num, den, NULL); + return __udivmoddi4(num, den, NULL); } int64_t __moddi3(int64_t num, int64_t den){ - int minus = 0; - int64_t v; - - if (num < 0){ - num = -num; - minus = 1; - } - if (den < 0){ - den = -den; - minus ^= 1; - } - - (void) __udivmoddi4(num, den, (uint64_t *)&v); - if (minus) - v = -v; - - return v; + int minus = 0; + int64_t v; + + if (num < 0){ + num = -num; + minus = 1; + } + if (den < 0){ + den = -den; + minus ^= 1; + } + + (void) __udivmoddi4(num, den, (uint64_t *)&v); + if (minus) + v = -v; + + return v; } int64_t __divdi3(int64_t num, int64_t den){ - int minus = 0; - int64_t v; - - if (num < 0){ - num = -num; - minus = 1; - } - if (den < 0){ - den = -den; - minus ^= 1; - } - - v = __udivmoddi4(num, den, NULL); - if (minus) - v = -v; - - return v; + int minus = 0; + int64_t v; + + if (num < 0){ + num = -num; + minus = 1; + } + if (den < 0){ + den = -den; + minus ^= 1; + } + + v = __udivmoddi4(num, den, NULL); + if (minus) + v = -v; + + return v; } From 404d937697b1b5587e6c133a32c5e872aea3dda9 Mon Sep 17 00:00:00 2001 From: Marcos Sartori Date: Fri, 8 Dec 2017 17:19:56 -0200 Subject: [PATCH 54/54] Permanent fix for bug on send_message --- software/bareOS/comm.c | 4 ++-- software/bareOS/include/hal.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/software/bareOS/comm.c b/software/bareOS/comm.c index 37e27b4..dc0eada 100644 --- a/software/bareOS/comm.c +++ b/software/bareOS/comm.c @@ -67,14 +67,14 @@ void send_msg(flit_t target, void *msg, size_t len) { /* waits previous operation to finish * this avoids overwriting previous buffer pointer */ - //old_buff = wait_receive(); + old_buff = wait_receive(); transmit(target, REQ_OPERATION, &msg_req, sizeof(msg_req_t)); prepare_receive(&ack_reply); wait_receive(); // restauring previous buffer - //MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)old_buff & 1); + MemoryWrite32(DMNI_RECEIVE_BUFFER, (size_t)old_buff | 1); if((ack_reply.addr != msg_req.addr)) panic("Received ACK diverges from expected\n"); diff --git a/software/bareOS/include/hal.h b/software/bareOS/include/hal.h index 5a7d969..7b322ee 100644 --- a/software/bareOS/include/hal.h +++ b/software/bareOS/include/hal.h @@ -101,9 +101,11 @@ extern uint8_t _stack; #define MemoryRead8(A) (*(volatile uint8_t*)(A)) #define MemoryWrite8(A,V) *(volatile uint8_t*)(A)=(V) -// Stubs, need real implementation if running on real hardware -static inline int enter_critical() { return 0; } -static inline void leave_critical(int i) {} +// Stubs, need implementation if running on sharedmemory platforms +static inline int __attribute__((unused)) enter_critical () { return 0; } + +static inline void __attribute__((unused)) +leave_critical(int __attribute__((unused)) i) {} #endif