-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from ErickOF/dev
Integrating Virtual Prototype
- Loading branch information
Showing
195 changed files
with
68,285 additions
and
1,102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM ubuntu:bionic | ||
LABEL maintainer="Màrius Montón" | ||
ENV SYSTEMC_VERSION 2.3.3 | ||
|
||
RUN apt-get update -q && apt-get install -qy gcc-riscv64-linux-gnu | ||
|
||
RUN apt-get update -q && apt-get install -qy --no-install-recommends \ | ||
build-essential curl \ | ||
cmake \ | ||
git \ | ||
openssh-client \ | ||
wget \ | ||
g++-8 \ | ||
xterm \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p /usr/src/systemc \ | ||
&& wget --no-check-certificate https://accellera.org/images/downloads/standards/systemc/systemc-$SYSTEMC_VERSION.tar.gz \ | ||
&& tar fzxC systemc-$SYSTEMC_VERSION.tar.gz /usr/src/systemc \ | ||
&& cd /usr/src/systemc/systemc-$SYSTEMC_VERSION \ | ||
&& mkdir objs \ | ||
&& cd objs \ | ||
&& export CXX=g++-8 \ | ||
&& mkdir -p /usr/local/systemc-$SYSTEMC_VERSION \ | ||
&& ../configure --prefix=/usr/local/systemc-$SYSTEMC_VERSION CXXFLAGS="-DSC_CPLUSPLUS=201103L"\ | ||
&& make \ | ||
&& make install \ | ||
&& cd / \ | ||
&& rm -rf /usr/src/systemc | ||
|
||
ENV CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/systemc-$SYSTEMC_VERSION/include | ||
ENV LIBRARY_PATH=$LIBRARY_PATH:/usr/local/systemc-$SYSTEMC_VERSION/lib-linux64 | ||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/systemc-$SYSTEMC_VERSION/lib-linux64 | ||
ENV SYSTEMC=/usr/local/systemc-$SYSTEMC_VERSION | ||
|
||
RUN mkdir -p /root/.ssh | ||
RUN ssh-keyscan github.com > /root/.ssh/known_hosts | ||
|
||
|
||
|
||
RUN rm -fr /usr/src/riscv64 \ | ||
&& mkdir -p /usr/src/riscv64 \ | ||
&& cd /usr/src/riscv64 \ | ||
&& git config --global http.sslVerify false \ | ||
&& git clone https://github.com/mariusmm/RISC-V-TLM.git \ | ||
&& cd RISC-V-TLM \ | ||
&& mkdir obj \ | ||
&& make | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#include "FreeRTOS.h" | ||
#include "task.h" | ||
#include "queue.h" | ||
#include "timers.h" | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
//Testbench Defines | ||
#define IMAG_ROWS 452 | ||
#define IMAG_COLS 640 | ||
#define RBG_CHANNELS_NUM 3 | ||
#define GRAY_CHANNELS_NUM 1 | ||
|
||
//Testbench Includes | ||
#include "../inc/address_map.hpp" | ||
#include "../inc/common_func.hpp" | ||
// #include "tb_aux_functions.c" | ||
// #include "img_unification.c" | ||
//#include "img_filtering.cpp" | ||
|
||
#define TRACE (*(unsigned char *)0x40000000) | ||
|
||
extern void register_timer_isr(); | ||
|
||
QueueHandle_t my_queue = NULL; | ||
|
||
static void task_1(void *pParameter) { | ||
|
||
int data = 5; | ||
printf("Task 1 starts\n"); | ||
|
||
while(1) { | ||
printf("T1: Tick %ld\n", xTaskGetTickCount() ); | ||
xQueueSend(my_queue, &data, portMAX_DELAY); | ||
vTaskDelay(100 / portTICK_PERIOD_MS); | ||
} | ||
} | ||
|
||
static void task_2(void *pParameter) { | ||
|
||
int data = 7; | ||
|
||
printf("Task 2 starts\n"); | ||
|
||
while(1) { | ||
printf("T2: Tick %ld\n", xTaskGetTickCount() ); | ||
xQueueSend(my_queue, &data, portMAX_DELAY); | ||
vTaskDelay(500 / portTICK_PERIOD_MS); | ||
} | ||
} | ||
|
||
static void task_3(void *pParameter) { | ||
int data; | ||
|
||
printf("Task 3 starts\n"); | ||
|
||
while(1) { | ||
xQueueReceive(my_queue, &data, portMAX_DELAY); | ||
printf("T3: Tick %ld. Recv: %ld\n", xTaskGetTickCount(), data); | ||
//vTaskDelay(1000 / portTICK_PERIOD_MS); | ||
} | ||
|
||
} | ||
|
||
static void testbench(void *pParameter) { | ||
|
||
//Set the pointers to memory, where images are stored | ||
unsigned char *img_x = (unsigned char*) IMG_INPUT_ADDRESS_LO; | ||
unsigned char *img_y = (unsigned char*) IMG_INPUT_ADDRESS_LO + IMAG_ROWS*IMAG_COLS; | ||
unsigned char *img_result = (unsigned char*) IMG_OUTPUT_ADDRESS_LO; | ||
|
||
printf("Starting Testbench\n"); | ||
|
||
printf("Starting IMG Filtering Step: \n"); | ||
filter_img(img_x, img_result, IMAG_ROWS, IMAG_COLS); | ||
printf("Done IMG Filtering Step: \n"); | ||
|
||
// printf("Starting IMG Unification Step: \n"); | ||
// unificate_img(img_x, img_y, img_result, IMAG_ROWS*IMAG_COLS, GRAY_CHANNELS_NUM); | ||
// printf("Done IMG Unification Step: \n"); | ||
|
||
printf("Testbench Done\n"); | ||
} | ||
|
||
int main( void ) | ||
{ | ||
BaseType_t xReturned; | ||
printf("Starting FreeRTOS test\n"); | ||
|
||
/* Create tasks */ | ||
xReturned = xTaskCreate(testbench, "test_unificate", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL); | ||
|
||
printf("Returned: %0d\n", xReturned); | ||
/* Start the kernel. From here on, only tasks and interrupts will run. */ | ||
vTaskStartScheduler(); | ||
|
||
/* Exit FreeRTOS */ | ||
return 0; | ||
} | ||
|
||
void vApplicationMallocFailedHook( void ) | ||
{ | ||
/* vApplicationMallocFailedHook() will only be called if | ||
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook | ||
function that will get called if a call to pvPortMalloc() fails. | ||
pvPortMalloc() is called internally by the kernel whenever a task, queue, | ||
timer or semaphore is created. It is also called by various parts of the | ||
demo application. If heap_1.c or heap_2.c are used, then the size of the | ||
heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in | ||
FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used | ||
to query the size of free heap space that remains (although it does not | ||
provide information on how the remaining heap might be fragmented). */ | ||
taskDISABLE_INTERRUPTS(); | ||
|
||
TRACE='M'; | ||
for( ;; ); | ||
} | ||
/*-----------------------------------------------------------*/ | ||
|
||
void vApplicationIdleHook( void ) | ||
{ | ||
/* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set | ||
to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle | ||
task. It is essential that code added to this hook function never attempts | ||
to block in any way (for example, call xQueueReceive() with a block time | ||
specified, or call vTaskDelay()). If the application makes use of the | ||
vTaskDelete() API function (as this demo application does) then it is also | ||
important that vApplicationIdleHook() is permitted to return to its calling | ||
function, because it is the responsibility of the idle task to clean up | ||
memory allocated by the kernel to any task that has since been deleted. */ | ||
} | ||
/*-----------------------------------------------------------*/ | ||
|
||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) | ||
{ | ||
( void ) pcTaskName; | ||
( void ) pxTask; | ||
|
||
/* Run time stack overflow checking is performed if | ||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook | ||
function is called if a stack overflow is detected. */ | ||
taskDISABLE_INTERRUPTS(); | ||
TRACE = 'S'; | ||
for( ;; ); | ||
} | ||
/*-----------------------------------------------------------*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#ifndef IMG_FILTERING_CPP | ||
#define IMG_FILTERING_CPP | ||
|
||
#include <string.h> | ||
#include <stdlib.h> | ||
#include "../inc/address_map.hpp" | ||
#include "../inc/common_func.hpp" | ||
|
||
#define IPS_FILTER_KERNEL_SIZE 9 | ||
|
||
|
||
void filter_img (unsigned char* input_img, unsigned char* output_img, int img_width, int img_height) | ||
{ | ||
unsigned char* filter_kernel_ptr = (unsigned char*) IMG_FILTER_KERNEL_ADDRESS_LO; | ||
unsigned char* filter_output_ptr = (unsigned char*) IMG_FILTER_OUTPUT_ADDRESS_LO; | ||
unsigned char* local_window_ptr = malloc(IPS_FILTER_KERNEL_SIZE*sizeof(char)); | ||
unsigned char* read_ptr; | ||
unsigned char data_returned; | ||
|
||
int local_count = 0; | ||
int current_number_of_pixels = 0; | ||
int next_target_of_completion = 10; | ||
int local_group_count = 0; | ||
int total_number_of_pixels = img_width*img_height; | ||
unsigned char* local_results; | ||
|
||
for (int i = 0; i < img_width; i++) | ||
{ | ||
local_group_count = 0; | ||
for (int j = 0; j < img_height; j++) | ||
{ | ||
extract_window(i, j, input_img, local_window_ptr, img_width, img_height); | ||
memcpy(filter_kernel_ptr, local_window_ptr, IPS_FILTER_KERNEL_SIZE*sizeof(char)); //Write to filter kernel | ||
memcpy(read_ptr, filter_output_ptr, sizeof(char)); //Read filter output | ||
data_returned = *read_ptr; | ||
|
||
if (local_count == 0) | ||
{ | ||
local_results = malloc(8); | ||
} | ||
|
||
if (data_returned > 255) { | ||
*(local_results + local_count) = 255; | ||
} | ||
else { | ||
*(local_results + local_count) = data_returned; | ||
} | ||
|
||
local_count++; | ||
|
||
if (local_count == 8) | ||
{ | ||
memcpy(output_img + ((i * img_height) + (local_group_count * 8 * sizeof(char))), local_results, 8 * sizeof(char)); | ||
local_count = 0; | ||
local_group_count++; | ||
} | ||
|
||
current_number_of_pixels++; | ||
if ((((current_number_of_pixels*100) / (total_number_of_pixels))) >= next_target_of_completion) { | ||
printf("Image Filtering completed at %f\n", next_target_of_completion); | ||
next_target_of_completion += 10.0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
#endif // IMG_FILTERING_CPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef IMG_UNIFICATION_CPP | ||
#define IMG_UNIFICATION_CPP | ||
|
||
#include <../inc/address_map.hpp> | ||
#include <math.h> | ||
|
||
//Test Unificate in FreeRTOS | ||
int intSqrt(int x) | ||
{ | ||
unsigned int s = 0; | ||
for (unsigned int i = (1 << 15); i > 0; i >>= 1){ | ||
if (((s+i) * (s+i)) <= x){ | ||
s += i; | ||
} | ||
} | ||
return s; | ||
} | ||
|
||
int norm(int a, int b) | ||
{ | ||
int norm_result = 0; | ||
|
||
norm_result = intSqrt(a*a+b*b); //sqrt(pow(a, 2) + pow(b, 2)); | ||
|
||
|
||
return norm_result; | ||
} | ||
|
||
void unificate_img(unsigned char *x_img, unsigned char *y_img, unsigned char *unificated_img, int img_size) | ||
{ | ||
//Iterate over image | ||
for(unsigned char *x = x_img, *y = y_img, *u = unificated_img; x < x_img + img_size && y < y_img + img_size && u < unificated_img + img_size; x++, y++, u++){ | ||
int pixel_magnitude; | ||
int pixel_x = (int) *x; | ||
int pixel_y = (int) *y; | ||
|
||
pixel_magnitude = norm(pixel_x, pixel_y); | ||
|
||
if (pixel_magnitude > 255) {pixel_magnitude = 255;}; | ||
*u = (unsigned char) pixel_magnitude; | ||
} | ||
} | ||
|
||
#endif // IMG_UNIFICATION_CPP |
Oops, something went wrong.