From 4010ce002a6513b409c91d8cbd2c4d3f15572a62 Mon Sep 17 00:00:00 2001 From: Reinier van der Walle <walle@astron.nl> Date: Wed, 9 Dec 2020 09:20:35 +0100 Subject: [PATCH] Prcocessed review comments --- .../ta2_unb2b_mm_demo/ta2_unb2b_mm_demo.cl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/applications/ta2/designs/ta2_unb2b_mm_demo/ta2_unb2b_mm_demo.cl b/applications/ta2/designs/ta2_unb2b_mm_demo/ta2_unb2b_mm_demo.cl index fef8a8c511..04aedd4c2e 100644 --- a/applications/ta2/designs/ta2_unb2b_mm_demo/ta2_unb2b_mm_demo.cl +++ b/applications/ta2/designs/ta2_unb2b_mm_demo/ta2_unb2b_mm_demo.cl @@ -29,6 +29,8 @@ #include <ihc_apint.h> +#define DIVIDE_AND_ROUND_UP(A,B) (((A)+(B)-1)/(B)) + enum mm_channel { CH_PROCESS_A, CH_PROCESS_B, @@ -48,12 +50,12 @@ struct param_process_b_struct { union param_process_a { struct param_process_a_struct parameters; - uint arr[sizeof(struct param_process_a_struct)/sizeof(uint)]; + uint arr[DIVIDE_AND_ROUND_UP(sizeof(struct param_process_a_struct),sizeof(uint))]; }; union param_process_b { struct param_process_b_struct parameters; - uint arr[sizeof(struct param_process_b_struct)/sizeof(uint)]; + uint arr[DIVIDE_AND_ROUND_UP(sizeof(struct param_process_b_struct),sizeof(uint))]; }; @@ -66,7 +68,7 @@ struct reg { struct mm_in { uint wrdata; uint address; - uchar wr; + bool wr; } __attribute__((packed)); struct mm_out { @@ -88,8 +90,8 @@ __kernel void mm_in_controller() { // Regmap table with offset, size const struct reg regmap[LAST_MM_CHANNEL_ENTRY] = { - {0x00, sizeof(struct param_process_a_struct)/sizeof(uint)}, - {0x02, sizeof(struct param_process_b_struct)/sizeof(uint)} + {0x00, DIVIDE_AND_ROUND_UP(sizeof(struct param_process_a_struct),sizeof(uint))}, + {0x02, DIVIDE_AND_ROUND_UP(sizeof(struct param_process_b_struct),sizeof(uint))} }; while(1) { @@ -159,7 +161,7 @@ __kernel void process_a() // handle MM read/write requests struct mm_in mm_request = read_channel_intel(mm_channel_in[CH_PROCESS_A]); //blocking read struct mm_out mm_response; - if(mm_request.wr > 0) //write request + if(mm_request.wr) //write request { reg.arr[mm_request.address] = mm_request.wrdata; } else { //read request @@ -187,7 +189,7 @@ __kernel void process_b() // handle MM read/write requests struct mm_in mm_request = read_channel_intel(mm_channel_in[CH_PROCESS_B]); //blocking read struct mm_out mm_response; - if(mm_request.wr > 0) //write request + if(mm_request.wr) //write request { reg.arr[mm_request.address] = mm_request.wrdata; } else { //read request @@ -196,7 +198,7 @@ __kernel void process_b() } // Do someting with parameters - if(mm_request.wr > 0 && mm_request.address == 1) + if(mm_request.wr && mm_request.address == 1) reg.parameters.acc += 2; } -- GitLab