fibonacci

main
higepi 1 year ago
parent 75ad3b3d06
commit 7ad8a8d9ab

@ -0,0 +1,61 @@
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import numpy as np
Y = [1100, 2150, 3200, 4250, 5300, 6350, 7400, 8450, 9500]
Y2 = [1100, 2150, 3200, 4250, 5300, 6350, 7400, 8450, 9500]
Y_ARM = [912, 1736 , 2560 , 3352, 4216, 5304 , 5840, 6704, 7464]
Y_ARMO3 = [173, 329, 480, 633, 789, 945, 1098, 1308, 1406]
Y_gcc = [2296, 5119, 6715, 9078, 10830, 12541, 15041, 16780, 18883]
Y_O3 = [165, 287, 380, 559, 900, 901, 776, 1122, 1574]
f_RISCV1 = 50e6
f_RISCV2 = 100e6
f_ARM = 800e6
f_PC = 2400e6
X = []
for i in range(9) :
Y[i] = (Y[i]*1e9)/f_RISCV1
Y2[i] = (Y2[i]*1e9)/f_RISCV2
Y_ARM[i] = (Y_ARM[i]*1e9)/f_ARM
Y_ARMO3[i] = (Y_ARMO3[i]*1e9)/f_ARM
Y_gcc[i] = (Y_gcc[i]*1e9)/f_PC
Y_O3[i] = (Y_O3[i]*1e9)/f_PC
X.append(50*(1+i))
plt.scatter(X, Y, color="b", marker="x", label="RISCV 50 MHz")
plt.scatter(X, Y2, color="g", marker="x", label="RISCV 100 MHz")
plt.scatter(X, Y_ARM, color="b", label="mesures ARM")
plt.scatter(X, Y_ARMO3, color="g", label="mesures ARM -O3")
plt.scatter(X, Y_gcc, color="b",marker="*", label="desktop -O0 2,4Ghz")
plt.scatter(X, Y_O3, color="g", marker="*",label="desktop -O3 2,4Ghz")
x = np.array(X).reshape(-1, 1)
y = np.array(Y).reshape(-1, 1)
y2 = np.array(Y2).reshape(-1, 1)
reg = LinearRegression().fit(x, y)
reg2 = LinearRegression().fit(x, y2)
print("score obtenu : " + str(reg.score(x, y)))
print("score obtenu : " + str(reg.score(x, y2)))
print("attente à zéro : {}".format(reg.intercept_))
print("attente à zéro : {}".format(reg2.intercept_))
x_lin = [0, max(X)]
y_lin = [reg.predict(np.array([0]).reshape(-1, 1)), reg.predict(np.array([x_lin[1]]).reshape(-1, 1))]
y_lin2 = [reg2.predict(np.array([0]).reshape(-1, 1)), reg2.predict(np.array([x_lin[1]]).reshape(-1, 1))]
y_lin = [y_lin[0][0][0], y_lin[1][0][0]]
y_lin2 = [y_lin2[0][0][0], y_lin2[1][0][0]]
# plt.plot(x_lin, y_lin, color = "r", label="RegLin 50 score : {:.4f}".format(reg.score(x, y)))
# plt.plot(x_lin, y_lin2, color = "r")
plt.yscale("log")
plt.xlim([0, 500])
plt.ylim([0, 1000000])
plt.legend()
plt.title("Temps d'exécution en fonction de n_max")
plt.ylabel("T (ns)")
plt.xlabel("N_max")
plt.show()
plt.savefig("M2_SETI/A2/fibonacci/linéaire.png")

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

@ -0,0 +1,108 @@
// #################################################################################################
// # << NEORV32 - "Hello World" Demo Program >> #
// # ********************************************************************************************* #
// # BSD 3-Clause License #
// # #
// # Copyright (c) 2022, Stephan Nolting. All rights reserved. #
// # #
// # Redistribution and use in source and binary forms, with or without modification, are #
// # permitted provided that the following conditions are met: #
// # #
// # 1. Redistributions of source code must retain the above copyright notice, this list of #
// # conditions and the following disclaimer. #
// # #
// # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
// # conditions and the following disclaimer in the documentation and/or other materials #
// # provided with the distribution. #
// # #
// # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
// # endorse or promote products derived from this software without specific prior written #
// # permission. #
// # #
// # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
// # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
// # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
// # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
// # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
// # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
// # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
// # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
// # OF THE POSSIBILITY OF SUCH DAMAGE. #
// # ********************************************************************************************* #
// # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
// #################################################################################################
/**********************************************************************//**
* @file hello_world/main.c
* @author Stephan Nolting
* @brief Classic 'hello world' demo program.
**************************************************************************/
#include <neorv32.h>
/**********************************************************************//**
* @name User configuration
**************************************************************************/
/**@{*/
/** UART BAUD rate */
#define BAUD_RATE 19200
/**@}*/
void fibonnaci(uint32_t *n_max, uint32_t *f_n){
uint32_t max = *n_max;
uint32_t fn_1 = 0;
uint32_t fn_copy = 1;
uint32_t fn_test = 1;
for(uint32_t i=0; i<max; i++){
fn_copy = fn_test;
fn_test = fn_test + fn_1;
fn_1 = fn_copy;
}
*f_n = fn_test;
}
/**********************************************************************//**
* Main function; prints some fancy stuff via UART.
*
* @note This program requires the UART interface to be synthesized.
*
* @return 0 if execution was successful
**************************************************************************/
int main() {
long Begin_Time, End_Time, User_Time;
uint32_t n_max, f;
// capture all exceptions and give debug info via UART
// this is not required, but keeps us safe
neorv32_rte_setup();
// init UART at default baud rate, no parity bits, no HW flow control
neorv32_uart0_setup(BAUD_RATE, PARITY_NONE, FLOW_CONTROL_NONE);
// check available hardware extensions and compare with compiler flags
neorv32_rte_check_isa(0); // silent = 0 -> show message if isa mismatch
// say hello
neorv32_uart0_puts("Fibonnacci cycles measure :\n");
neorv32_uart0_printf("NEORV32: Freq = %u\n",NEORV32_SYSINFO.CLK);
for(uint8_t i=1; i<10; i++){
n_max = 50;
Begin_Time = (long)neorv32_mtime_get_time();
for(uint32_t j=0; j<2*454546; j++){
fibonnaci(&n_max, &f);
}
End_Time = (long)neorv32_mtime_get_time();
User_Time = End_Time - Begin_Time;
neorv32_uart0_printf("NEORV32: mean cycles n_max = %u : %u\n",n_max, (uint32_t)User_Time);
}
neorv32_uart0_puts("end:\n");
return 0;
}

Binary file not shown.

Binary file not shown.

@ -0,0 +1,4 @@
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
NEORV32_HOME ?= ../../..
include $(NEORV32_HOME)/sw/common/common.mk

Binary file not shown.

@ -58,7 +58,22 @@ Ext. bus endianness: little
[ ] XIP
[ ] ONEWIRE
### Clock
On peut augmenter la fréquence du processeur à l'aide de l'outil PLL Intel FPGA IP que l'on vient monter à 100 MHz. Monter à 200 Mhz indique un timing fail et une Fmax à 130 Mhz.
Il faut ensuite modifier l'input de clock vers le signal de pll.
```
library pll;
pll_100: entity pll.pll(rtl)
port map(
refclk => clk_i, -- refclk.clk
--rst : in std_logic := '0'; -- reset.reset
outclk_0 => clk_100, -- outclk0.clk
locked => open -- locked.export
);
```
### Software
Print sur le série :

Loading…
Cancel
Save