tp
This commit is contained in:
parent
200263a90e
commit
070b0481eb
46 changed files with 1648 additions and 52 deletions
67
A1/Cours.md
67
A1/Cours.md
|
@ -1,6 +1,71 @@
|
|||
# Cours A1
|
||||
|
||||
## Cours/TP 12/10
|
||||
|
||||
Injection de fautes, exploiter les failles.
|
||||
Mecanismes cryptographiques, algo mathematiquement robustes. Quand on veut les implémenter, ils peuvent êtres soumis à différentes attaques.
|
||||
|
||||
Attaque par injection de code. (Injecter des données, qui peuvent correspondre à du code donné, exploitation de bug dans le code logiciel)
|
||||
Attaque par canaux auxiliaires. (temps d'execution, consommation elec, connexion)
|
||||
|
||||
Raison d'optimisation (multiplication), multiplier par 0 -> pas de calcul, temps de calcul très long donc si secret = 0, temps de calcul court.
|
||||
Attaque physique. (Ouvrir le circuit, sonder (microprobing) entre la mémoire et le processeur, FIB ?)
|
||||
|
||||
Certaines attaques nécessitent le composant physique, d'autres à distances (marron et bleu p4)
|
||||
Tirs lasers pour modifier la mémoire, injecter des fautes.
|
||||
|
||||
|
||||
p9. nécessite une précision en cycle processeur très grande. Il faut cibler une ou quelques cycles.
|
||||
p10. Algo plus connus/utilisé.
|
||||
|
||||
Evaluation : QCM sur toutes les parties. (qu'est-ce qu'une attaque etc... Contres mesures et classification) Dans quel cas on utilise certaines contre mesure et dans cette attaque là quelle contre mesure utiliser ?
|
||||
|
||||
p12. CRC pour protéger les CSP (critical security parameters) pour éviter de changer les p,q qui sont premiers.
|
||||
|
||||
p14. On faute l'exposant d_i de proche en proche pour obtenir les m_i
|
||||
p15. Contre mesure = rajouter un produit avec un nombre aléatoire (Stratégie Résilience)
|
||||
|
||||
Vérification de valeur -> Stratégie détection
|
||||
|
||||
p19. On déplace l'instant d'exécution de l'instruction sensible -> Observation de la consommation électrique
|
||||
On peut rajouter des capteurs (lumière pour l'ouverture de la puce, f_clk pour le downclocking pour observer les signaux)
|
||||
|
||||
### TD
|
||||
|
||||
Q1 Donner l'équation de R_16 en fonction de R_15 et L_15
|
||||
R_16 = L_15 ^ f(R_15,K_16) #f(.,.) p40
|
||||
f(R_15,K_16) = P(S_1-8(E(R_15) ^ K_16))
|
||||
|
||||
Q2 Entrée R_15 fautée : R_15'
|
||||
R_16' = L_15' ^ P(S_1-8(E(R_15') ^ K_16))
|
||||
|
||||
Q3 Delta(R_16) = R_16 ^ R_16'
|
||||
= Delta(L_15) ^ P(a) ^ P(b)
|
||||
= Delta(L_15) ^ P(S_1-8(E(R_15) ^ K_16) ^ S_1-8(E(R_15') ^ K_16))
|
||||
|
||||
Q4
|
||||
Connues : R_16, R_15 = L_16 et R_15' = L_16'
|
||||
Inconnues : Delta(L_15) et K_16
|
||||
|
||||
On veut Delta(L_15) = 0 donc ne pas toucher L_15 lors de la faute.
|
||||
|
||||
Q5
|
||||
P⁻¹(Delta(R_16)) = S_1-8(E(R_15) ^ K_16) ^ S_1-8(E(R_15') ^ K_16)
|
||||
|
||||
On teste les clés K_16 pour avoir égalité des deux côtés, si elle c'est vérifié, la clé est une candidate.
|
||||
|
||||
Défi 4 :
|
||||
|
||||
Q1
|
||||
P⁻¹_1(Delta(R_16)) = S_1(E(R_15) ^ K_16,1) ^ S_1(E(R_15') ^ K_16,1)
|
||||
|
||||
|
||||
## 19/10 Side-Channel Analysis
|
||||
|
||||
p9: ce qu'on attaque, c'est pas l'algo, c'est l'implémentation de celui-ci
|
||||
p9: ce qu'on attaque, c'est pas l'algo, c'est l'implémentation de celui-ci.
|
||||
|
||||
p10: 10000 essais en force brute, 40 avec canal auxiliaire en regardant le temps d'exécution et sa variation pour chaque digit.
|
||||
|
||||
p15: le pic de courant indique le nombre de portes logiques qui ont changé d'état
|
||||
|
||||
p58: Si on a pas de connaissances à priori sur le système, on regarde une fenetre temporelle élevée pour déterminer la trace. On réduit la fenêtre quand on cible l'attaque.
|
||||
|
|
BIN
B1/WCET-CACHE-STREC-18.pdf
Normal file
BIN
B1/WCET-CACHE-STREC-18.pdf
Normal file
Binary file not shown.
|
@ -2,3 +2,6 @@
|
|||
|
||||
Niveau de criticalité : tolérance de fautes, fautes critiques
|
||||
|
||||
# Cours 26/10
|
||||
|
||||
Boundaries of a tasks time
|
BIN
B1/strec-ipet.tar_
Normal file
BIN
B1/strec-ipet.tar_
Normal file
Binary file not shown.
13
B1/strec-ipet/Makefile
Normal file
13
B1/strec-ipet/Makefile
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
export PATH := $(PATH):/infres/ir600/users/brandner/patmos-misc/local/bin/
|
||||
|
||||
OWCET=owcet
|
||||
|
||||
.PHONY: analyse clean
|
||||
|
||||
analyse: heli heli.ff patmos_wcet.osx patmos_wcet/caches.xml patmos_wcet/memory.xml patmos_wcet/pipeline.xml
|
||||
@mkdir -p out
|
||||
$(OWCET) -f heli.ff -s patmos_wcet.osx heli
|
||||
|
||||
clean:
|
||||
rm -rf out
|
BIN
B1/strec-ipet/heli
Executable file
BIN
B1/strec-ipet/heli
Executable file
Binary file not shown.
29
B1/strec-ipet/heli.ff
Normal file
29
B1/strec-ipet/heli.ff
Normal file
|
@ -0,0 +1,29 @@
|
|||
//**** jumptable (source: llvm)
|
||||
// TODO: find corresponding C and assembly code (Exercise 1).
|
||||
multibranch 0x20b00 to "processSensorData"+0x70,
|
||||
"processSensorData"+0x1b0,
|
||||
"processSensorData"+0x320,
|
||||
"processSensorData"+0x460;
|
||||
|
||||
//****
|
||||
loop "main"+0x4c 32;
|
||||
loop "main"+0x150 10; // assumed bound
|
||||
|
||||
//****
|
||||
// TODO: find tighter loop bound, later, specify loop bounds depending on
|
||||
// calling context (Exercise 2).
|
||||
loop "fixFilter"+0x24 10000;
|
||||
|
||||
//****
|
||||
loop "calibrateArom"+0x48 128;
|
||||
loop "calibrateArom"+0xf0 128;
|
||||
loop "calibrateArom"+0x190 128;
|
||||
|
||||
//****
|
||||
loop "processSensorData"+0xb8 8;
|
||||
loop "processSensorData"+0x214 32;
|
||||
loop "processSensorData"+0x384 32;
|
||||
loop "processSensorData"+0x4c0 32;
|
||||
|
||||
//****
|
||||
loop "runFlightPlan"+0x1bc 1; // watchdog loop
|
5
B1/strec-ipet/patmos_env
Normal file
5
B1/strec-ipet/patmos_env
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
export PATH=$PATH:/infres/ir600/users/brandner/patmos-misc/local/bin/
|
||||
export LD_LIBRARY_PATH=$LD_LIBARY_PATH:/infres/ir600/users/brandner/patmos-misc/local/lib/
|
35
B1/strec-ipet/patmos_wcet.osx
Normal file
35
B1/strec-ipet/patmos_wcet.osx
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<otawa-script
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<platform>
|
||||
<xi:include href="patmos_wcet/pipeline.xml"/>
|
||||
<xi:include href="patmos_wcet/memory.xml"/>
|
||||
<xi:include href="patmos_wcet/caches.xml"/>
|
||||
</platform>
|
||||
|
||||
<script>
|
||||
<config name="otawa::ILPNAME" value="out/ipet.lp"/>
|
||||
<config name="otawa::ipet::EXPLICIT" value="true"/>
|
||||
|
||||
<!-- TODO: uncomment the following line (Exercise 2) /> -->
|
||||
<!-- <step require="otawa::VIRTUALIZED_CFG_FEATURE" /> -->
|
||||
<step processor="tcrest::patmos_wcet::BBTimer">
|
||||
<config name="otawa::GRAPHS_OUTPUT_DIRECTORY" value="out"/>
|
||||
</step>
|
||||
|
||||
<!-- WCET computation -->
|
||||
<step require="tcrest::patmos::METHOD_CACHE_CONTRIBUTION_FEATURE"/>
|
||||
<step require="otawa::ipet::WCET_FEATURE"/>
|
||||
|
||||
<step processor="otawa::ipet::WCETCountRecorder"/>
|
||||
<step processor="otawa::display::CFGOutput">
|
||||
<config name="otawa::display::CFGOutput::PATH" value="out"/>
|
||||
</step>
|
||||
<!-- TODO: uncomment the following line (Exercise 4) /> -->
|
||||
<!-- <step processor="otawa::BBRatioDisplayer" /> -->
|
||||
</script>
|
||||
|
||||
</otawa-script>
|
||||
|
15
B1/strec-ipet/patmos_wcet/caches.xml
Normal file
15
B1/strec-ipet/patmos_wcet/caches.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<cache-config>
|
||||
<dcache>
|
||||
<block_bits>5</block_bits>
|
||||
<way_bits>2</way_bits>
|
||||
<row_bits>9</row_bits>
|
||||
<miss_penalty>25</miss_penalty>
|
||||
</dcache>
|
||||
<icache>
|
||||
<block_bits>5</block_bits>
|
||||
<way_bits>2</way_bits>
|
||||
<row_bits>9</row_bits>
|
||||
<miss_penalty>25</miss_penalty>
|
||||
</icache>
|
||||
</cache-config>
|
14
B1/strec-ipet/patmos_wcet/memory.xml
Normal file
14
B1/strec-ipet/patmos_wcet/memory.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<memory>
|
||||
<banks>
|
||||
<bank>
|
||||
<name>RAM</name>
|
||||
<address><offset>0x00000000</offset></address>
|
||||
<size>0x1fffffff</size>
|
||||
<type>DRAM</type>
|
||||
<latency>25</latency>
|
||||
<writable>true</writable>
|
||||
<cachable>true</cachable>
|
||||
</bank>
|
||||
</banks>
|
||||
</memory>
|
54
B1/strec-ipet/patmos_wcet/pipeline.xml
Normal file
54
B1/strec-ipet/patmos_wcet/pipeline.xml
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<processor class="otawa::hard::Processor">
|
||||
<arch>patmos</arch>
|
||||
<model>patmos</model>
|
||||
|
||||
<stages>
|
||||
|
||||
<stage id="FE">
|
||||
<name>FE</name>
|
||||
<width>2</width>
|
||||
<type>FETCH</type>
|
||||
</stage>
|
||||
|
||||
<stage id="DE">
|
||||
<name>DE</name>
|
||||
<width>2</width>
|
||||
<type>LAZY</type>
|
||||
</stage>
|
||||
|
||||
<stage id="EX">
|
||||
<name>EX</name>
|
||||
<width>2</width>
|
||||
<type>EXEC</type>
|
||||
<ordered>true</ordered>
|
||||
<fus>
|
||||
<fu id="ALU">
|
||||
<name>ALU</name>
|
||||
<width>2</width>
|
||||
<latency>1</latency>
|
||||
</fu>
|
||||
</fus>
|
||||
<dispatch>
|
||||
<inst>
|
||||
<type/>
|
||||
<fu ref="ALU"/>
|
||||
</inst>
|
||||
</dispatch>
|
||||
|
||||
</stage>
|
||||
|
||||
<stage id="MEM">
|
||||
<name>MEM</name>
|
||||
<width>2</width>
|
||||
<type>LAZY</type>
|
||||
</stage>
|
||||
|
||||
<stage id="CM">
|
||||
<name>CM</name>
|
||||
<width>2</width>
|
||||
<type>COMMIT</type>
|
||||
</stage>
|
||||
</stages>
|
||||
|
||||
</processor>
|
416
B1/strec-ipet/src/heli.c
Normal file
416
B1/strec-ipet/src/heli.c
Normal file
|
@ -0,0 +1,416 @@
|
|||
// helico.c
|
||||
// this code is inspired from: http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2006/rg242/webpage/ece%20476.htm
|
||||
|
||||
#include "io.h"
|
||||
|
||||
// define sensor channels
|
||||
#define GYRO_CHANNEL 0
|
||||
#define AROMX_CHANNEL 1
|
||||
#define AROMY_CHANNEL 2
|
||||
#define AROMZ_CHANNEL 3
|
||||
char currentChannel = GYRO_CHANNEL;
|
||||
|
||||
// define Helicopter states
|
||||
#define GROUND 0
|
||||
#define LANDING 1
|
||||
#define TAKEOFF 2
|
||||
#define HOVER 3
|
||||
char heliState = GROUND;
|
||||
|
||||
// define flight phases
|
||||
#define TAKEOFF_START 5
|
||||
#define HOVER_START 23
|
||||
#define LANDING_START 299
|
||||
#define LANDING_END 400
|
||||
#define GROUNDED_START 410
|
||||
|
||||
// define motor speeds
|
||||
#define MINIMUM_PWM_VALUE 0
|
||||
#define MAXIMUM_ROTOR_PWM_VALUE (100<<8)
|
||||
#define MARKS_PER_SEC 1600
|
||||
int pwm_ticks = 0;
|
||||
int marks = 0;
|
||||
volatile int sec = 0;
|
||||
|
||||
#define MAX_TAKEOFF_MOTOR_SPEED (95<<8)
|
||||
#define TAKEOFF_ROTOR_SPEED_INCR 16
|
||||
#define ROTOR_SPEED_INCR 8
|
||||
#define HOVER_ROTOR_SPEED_INCR_HIGH 2
|
||||
#define HOVER_ROTOR_SPEED_INCR_LOW 5
|
||||
#define MAX_STAB_MOTOR_SPEED (60<<8)
|
||||
#define MIN_STAB_MOTOR_SPEED 0
|
||||
#define STAB_SPEED_INCR 256
|
||||
#define MIN_LANDING_ROTOR_SPEED (50<<8)
|
||||
#define LANDING_ROTOR_SPEED_INCR 1
|
||||
|
||||
int topRotorSpeed = 0;
|
||||
int bottomRotorSpeed = 0;
|
||||
int stabMotorSpeed1 = 0;
|
||||
int stabMotorSpeed2 = 0;
|
||||
int stabMotorSpeed3 = 0;
|
||||
|
||||
// ADC
|
||||
char data_in;
|
||||
#define ADMUX_GYRO 0b01100000
|
||||
#define ADMUX_AROMX 0b01100001
|
||||
#define ADMUX_AROMY 0b01100010
|
||||
#define ADMUX_AROMZ 0b01100011
|
||||
|
||||
// Sensors
|
||||
uint8_t gyroCalibrateThresholdLow;
|
||||
uint8_t gyroCalibrateThresholdHigh;
|
||||
uint8_t aromXCalibrateThresholdLow;
|
||||
uint8_t aromXCalibrateThresholdHigh;
|
||||
uint8_t aromYCalibrateThresholdLow;
|
||||
uint8_t aromYCalibrateThresholdHigh;
|
||||
uint8_t aromZCalibrateThresholdLow;
|
||||
uint8_t aromZCalibrateThresholdHigh;
|
||||
uint8_t gyro[32];
|
||||
uint8_t aromX[128];
|
||||
uint8_t aromY[128];
|
||||
uint8_t aromZ[128];
|
||||
|
||||
|
||||
void updatePWM(void);
|
||||
void processSensorData(void) __attribute__((noinline));
|
||||
void runFlightPlan(void) __attribute__((noinline));
|
||||
void calibrateGyro(void);
|
||||
void calibrateArom(void);
|
||||
uint8_t fixFilter(uint8_t *f, int size) __attribute__((noinline));
|
||||
void addSample(uint8_t *f, int size, uint8_t value);
|
||||
|
||||
|
||||
void timer_interrupt(void){
|
||||
pwm_ticks++;
|
||||
marks++;
|
||||
if (marks == MARKS_PER_SEC){
|
||||
sec++;
|
||||
marks = 0;
|
||||
}
|
||||
updatePWM();
|
||||
}
|
||||
|
||||
void updatePWM(void){
|
||||
char command = 0;
|
||||
int ticks = pwm_ticks << 8;
|
||||
// generate PWM command for the 5 motors
|
||||
if (ticks <= topRotorSpeed)
|
||||
command |= PIN0;
|
||||
if (ticks <= bottomRotorSpeed)
|
||||
command |= PIN1;
|
||||
if (ticks <= stabMotorSpeed1)
|
||||
command |= PIN2;
|
||||
if (ticks <= stabMotorSpeed2)
|
||||
command |= PIN3;
|
||||
if (ticks <= stabMotorSpeed3)
|
||||
command |= PIN4;
|
||||
PORTC = command;
|
||||
if (ticks == MAXIMUM_ROTOR_PWM_VALUE)
|
||||
pwm_ticks = 0;
|
||||
}
|
||||
|
||||
|
||||
int main(void){
|
||||
calibrateGyro();
|
||||
calibrateArom();
|
||||
|
||||
// start
|
||||
topRotorSpeed = 0;
|
||||
bottomRotorSpeed = 0;
|
||||
stabMotorSpeed1 = 0;
|
||||
stabMotorSpeed2 = 0;
|
||||
stabMotorSpeed3 = 0;
|
||||
|
||||
sec = 0;
|
||||
|
||||
static volatile int x = 1;
|
||||
__llvm_pcmarker(31);
|
||||
while (x) {
|
||||
__llvm_pcmarker(32);
|
||||
if ( (ADCSR & PIN6) == 0) { // end of ADC conversion
|
||||
processSensorData();
|
||||
__llvm_pcmarker(33);
|
||||
}
|
||||
runFlightPlan();
|
||||
}
|
||||
}
|
||||
|
||||
void runFlightPlan(void){
|
||||
// take off
|
||||
if (sec <= TAKEOFF_START){
|
||||
heliState = TAKEOFF;
|
||||
topRotorSpeed += TAKEOFF_ROTOR_SPEED_INCR;
|
||||
if (topRotorSpeed > MAX_TAKEOFF_MOTOR_SPEED)
|
||||
topRotorSpeed = MAX_TAKEOFF_MOTOR_SPEED;
|
||||
bottomRotorSpeed += TAKEOFF_ROTOR_SPEED_INCR;
|
||||
if (bottomRotorSpeed > MAX_TAKEOFF_MOTOR_SPEED)
|
||||
bottomRotorSpeed = MAX_TAKEOFF_MOTOR_SPEED;
|
||||
}
|
||||
|
||||
// hover
|
||||
if (sec == HOVER_START)
|
||||
heliState = HOVER;
|
||||
|
||||
// landing
|
||||
if (sec == LANDING_START){
|
||||
heliState = LANDING;
|
||||
stabMotorSpeed1 = 0;
|
||||
stabMotorSpeed2 = 0;
|
||||
stabMotorSpeed3 = 0;
|
||||
}
|
||||
|
||||
if ( (sec > LANDING_START) && (sec <= LANDING_END) ){
|
||||
topRotorSpeed -= LANDING_ROTOR_SPEED_INCR;
|
||||
if (topRotorSpeed < MIN_LANDING_ROTOR_SPEED)
|
||||
topRotorSpeed = MIN_LANDING_ROTOR_SPEED;
|
||||
bottomRotorSpeed -= LANDING_ROTOR_SPEED_INCR;
|
||||
if (bottomRotorSpeed < MIN_LANDING_ROTOR_SPEED)
|
||||
bottomRotorSpeed = MIN_LANDING_ROTOR_SPEED;
|
||||
}
|
||||
|
||||
// grounded
|
||||
if(sec >= GROUNDED_START){
|
||||
heliState = GROUND;
|
||||
WDTCR = 0x08; //enable watchdog
|
||||
while (1) ; //just wait for watchdog to reset machine
|
||||
}
|
||||
}
|
||||
|
||||
void processSensorData(void){
|
||||
char filtered_data;
|
||||
char data_in_last;
|
||||
|
||||
data_in_last = data_in;
|
||||
data_in = ADCH;
|
||||
|
||||
switch (currentChannel) {
|
||||
|
||||
case GYRO_CHANNEL:
|
||||
// start conversion for next channel
|
||||
currentChannel = AROMX_CHANNEL;
|
||||
ADMUX = ADMUX_AROMX;
|
||||
ADCSR = ADCSR | PIN6;
|
||||
|
||||
addSample(gyro, 5, data_in);
|
||||
filtered_data = fixFilter(gyro,5);
|
||||
|
||||
if (filtered_data < gyroCalibrateThresholdLow) {
|
||||
topRotorSpeed += ROTOR_SPEED_INCR;;
|
||||
if (topRotorSpeed > MAXIMUM_ROTOR_PWM_VALUE)
|
||||
topRotorSpeed = MAXIMUM_ROTOR_PWM_VALUE;
|
||||
bottomRotorSpeed -= ROTOR_SPEED_INCR;
|
||||
if (bottomRotorSpeed < MINIMUM_PWM_VALUE)
|
||||
bottomRotorSpeed = MINIMUM_PWM_VALUE;
|
||||
}
|
||||
else
|
||||
if (filtered_data > gyroCalibrateThresholdHigh) {
|
||||
topRotorSpeed -= ROTOR_SPEED_INCR;
|
||||
if (topRotorSpeed < MINIMUM_PWM_VALUE)
|
||||
topRotorSpeed = MINIMUM_PWM_VALUE;
|
||||
bottomRotorSpeed += ROTOR_SPEED_INCR;
|
||||
if (bottomRotorSpeed > MAXIMUM_ROTOR_PWM_VALUE)
|
||||
bottomRotorSpeed = MAXIMUM_ROTOR_PWM_VALUE;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case AROMX_CHANNEL:
|
||||
// start conversion for next channel
|
||||
currentChannel = AROMY_CHANNEL;
|
||||
ADMUX = ADMUX_AROMY;
|
||||
ADCSR |= PIN6;
|
||||
|
||||
if (heliState == HOVER) {
|
||||
|
||||
__llvm_pcmarker(21);
|
||||
addSample(aromX,7,data_in);
|
||||
filtered_data = fixFilter(aromX,7);
|
||||
|
||||
if (filtered_data < aromXCalibrateThresholdLow) {
|
||||
stabMotorSpeed1 -= STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed1 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed1 = MIN_STAB_MOTOR_SPEED;
|
||||
stabMotorSpeed2 += STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed2 > MAX_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed2 = MAX_STAB_MOTOR_SPEED;
|
||||
stabMotorSpeed3 += STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed3 > MAX_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed3 = MAX_STAB_MOTOR_SPEED;
|
||||
}
|
||||
else if (filtered_data > aromXCalibrateThresholdHigh) {
|
||||
stabMotorSpeed1 += STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed1 > MAX_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed1 = MAX_STAB_MOTOR_SPEED;
|
||||
stabMotorSpeed2 -= STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed2 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed2 = MIN_STAB_MOTOR_SPEED;
|
||||
stabMotorSpeed3 -= STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed3 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed3 = MIN_STAB_MOTOR_SPEED;
|
||||
}
|
||||
else {
|
||||
stabMotorSpeed1 -= STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed1 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed1 = MIN_STAB_MOTOR_SPEED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AROMY_CHANNEL:
|
||||
// starting new conversion
|
||||
currentChannel = AROMZ_CHANNEL;
|
||||
ADMUX = ADMUX_AROMZ;
|
||||
ADCSR |= PIN6;
|
||||
|
||||
if (heliState == HOVER){
|
||||
|
||||
__llvm_pcmarker(22);
|
||||
addSample(aromY, 7, data_in);
|
||||
filtered_data = fixFilter(aromY,7);
|
||||
|
||||
if (filtered_data < aromYCalibrateThresholdLow) {
|
||||
stabMotorSpeed2 += STAB_SPEED_INCR*4;
|
||||
if (stabMotorSpeed2 > MAX_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed2 = MAX_STAB_MOTOR_SPEED;
|
||||
stabMotorSpeed3 -= STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed3 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed3 = MIN_STAB_MOTOR_SPEED;
|
||||
}
|
||||
else if (filtered_data > aromYCalibrateThresholdHigh) {
|
||||
stabMotorSpeed2 -= STAB_SPEED_INCR*2;
|
||||
if (stabMotorSpeed2 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed2 = MIN_STAB_MOTOR_SPEED;
|
||||
stabMotorSpeed3 += STAB_SPEED_INCR*4;
|
||||
if (stabMotorSpeed3 > MAX_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed3 = MAX_STAB_MOTOR_SPEED;
|
||||
}
|
||||
else {
|
||||
stabMotorSpeed2 -= STAB_SPEED_INCR;
|
||||
if (stabMotorSpeed2 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed2 = MIN_STAB_MOTOR_SPEED;
|
||||
stabMotorSpeed3 -= STAB_SPEED_INCR;
|
||||
if (stabMotorSpeed3 < MIN_STAB_MOTOR_SPEED)
|
||||
stabMotorSpeed3 = MIN_STAB_MOTOR_SPEED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AROMZ_CHANNEL:
|
||||
// Starting new conversion
|
||||
currentChannel = GYRO_CHANNEL;
|
||||
ADMUX = ADMUX_GYRO;
|
||||
ADCSR |= PIN6;
|
||||
|
||||
if (heliState == HOVER){
|
||||
|
||||
__llvm_pcmarker(23);
|
||||
addSample(aromZ, 7, data_in);
|
||||
filtered_data = fixFilter(aromZ,8);
|
||||
|
||||
if (filtered_data > aromZCalibrateThresholdHigh){
|
||||
topRotorSpeed -= HOVER_ROTOR_SPEED_INCR_HIGH;
|
||||
if (topRotorSpeed < MINIMUM_PWM_VALUE)
|
||||
topRotorSpeed = MINIMUM_PWM_VALUE;
|
||||
bottomRotorSpeed -= HOVER_ROTOR_SPEED_INCR_HIGH;
|
||||
if (bottomRotorSpeed < MINIMUM_PWM_VALUE)
|
||||
bottomRotorSpeed = MINIMUM_PWM_VALUE;
|
||||
}
|
||||
else if (filtered_data == aromZCalibrateThresholdLow){
|
||||
topRotorSpeed += HOVER_ROTOR_SPEED_INCR_LOW;
|
||||
if (topRotorSpeed > MAXIMUM_ROTOR_PWM_VALUE)
|
||||
topRotorSpeed = MAXIMUM_ROTOR_PWM_VALUE;
|
||||
bottomRotorSpeed += HOVER_ROTOR_SPEED_INCR_LOW;
|
||||
if(bottomRotorSpeed > MAXIMUM_ROTOR_PWM_VALUE)
|
||||
bottomRotorSpeed = MAXIMUM_ROTOR_PWM_VALUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void calibrateGyro(void) {
|
||||
char gyroCalibrate;
|
||||
int i;
|
||||
|
||||
ADMUX = ADMUX_GYRO;
|
||||
ADCSR = 0b11000110;
|
||||
|
||||
for (i=0; i<31; i++){
|
||||
gyro[i] = ADCH;
|
||||
ADCSR |= PIN6;;
|
||||
}
|
||||
gyro[31] = ADCH;
|
||||
|
||||
gyroCalibrate = fixFilter(gyro,5);
|
||||
gyroCalibrateThresholdLow = gyroCalibrate - 1;
|
||||
gyroCalibrateThresholdHigh = gyroCalibrate + 1;
|
||||
}
|
||||
|
||||
void calibrateArom(void){
|
||||
char aromCalibrate;
|
||||
int i;
|
||||
|
||||
ADMUX = ADMUX_AROMX;
|
||||
ADCSR |= PIN6;
|
||||
|
||||
for (i=0; i<127; i++){
|
||||
aromX[i] = ADCH;
|
||||
ADCSR |= PIN6;
|
||||
}
|
||||
aromX[127] = ADCH;
|
||||
aromCalibrate = fixFilter(aromX,7);
|
||||
aromXCalibrateThresholdLow = aromCalibrate;
|
||||
aromXCalibrateThresholdHigh = aromCalibrate + 1;
|
||||
|
||||
ADMUX = ADMUX_AROMY;
|
||||
ADCSR |= PIN6;
|
||||
|
||||
for (i=0; i<127; i++){
|
||||
aromY[i] = ADCH;
|
||||
ADCSR |= PIN6;
|
||||
}
|
||||
aromY[127] = ADCH;
|
||||
aromCalibrate = fixFilter(aromY,7);
|
||||
aromYCalibrateThresholdLow = aromCalibrate;
|
||||
aromYCalibrateThresholdHigh = aromCalibrate;
|
||||
|
||||
ADMUX = ADMUX_AROMZ;
|
||||
ADCSR |= PIN6;
|
||||
|
||||
for (i=0; i<127; i++){
|
||||
aromZ[i] = ADCH;
|
||||
ADCSR |= PIN6;
|
||||
}
|
||||
aromZ[127] = ADCH;
|
||||
aromCalibrate = fixFilter(aromZ,7);
|
||||
aromZCalibrateThresholdLow = aromCalibrate;
|
||||
aromZCalibrateThresholdHigh = aromCalibrate + 3;
|
||||
|
||||
ADMUX = ADMUX_GYRO;
|
||||
ADCSR |= PIN6;
|
||||
|
||||
}
|
||||
|
||||
uint8_t fixFilter(uint8_t *f, int size){
|
||||
int i;
|
||||
int length = 1 << size;
|
||||
int sum = 0;
|
||||
for(i = 0; i < length; i++){
|
||||
sum = sum + f[i];
|
||||
}
|
||||
// divide by length
|
||||
sum = sum >> size;
|
||||
return sum;
|
||||
}
|
||||
|
||||
void addSample(uint8_t *f, int size, uint8_t value){
|
||||
int i;
|
||||
int length = 1 << size;
|
||||
for (i = 0;i < length; i++){
|
||||
f[i] = f[i+1];
|
||||
}
|
||||
f[length-1] = value;
|
||||
}
|
||||
|
||||
|
||||
|
23
B1/strec-ipet/src/io.h
Normal file
23
B1/strec-ipet/src/io.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**************** io.h **************/
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
#define _SFR_BASE 0xF0000
|
||||
#define _SFR_MEM8(mem_addr) (*(volatile uint8_t *)(mem_addr + _SFR_BASE))
|
||||
|
||||
#define ADCH _SFR_MEM8(0x05)
|
||||
#define ADCSR _SFR_MEM8(0x06)
|
||||
#define ADMUX _SFR_MEM8(0x07)
|
||||
#define PIND _SFR_MEM8(0x10)
|
||||
#define PORTD _SFR_MEM8(0x12)
|
||||
#define PORTC _SFR_MEM8(0x15)
|
||||
#define WDTCR _SFR_MEM8(0x31)
|
||||
|
||||
|
||||
#define PIN0 0x1
|
||||
#define PIN1 0x2
|
||||
#define PIN2 0x4
|
||||
#define PIN3 0x8
|
||||
#define PIN4 0x10
|
||||
#define PIN5 0x20
|
||||
#define PIN6 0x40
|
||||
#define PIN7 0x80
|
128
D3/TP/Cours.ipynb
Normal file
128
D3/TP/Cours.ipynb
Normal file
|
@ -0,0 +1,128 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Cours D3\n",
|
||||
"\n",
|
||||
"## Cours Méthodes d'analyse non supervisées\n",
|
||||
"\n",
|
||||
"Exemple de clustering complete linkage :\n",
|
||||
"On prend 4 singletons avec leur matrice de dissimilarité."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[0. 0.3 0.4 0.8 ]\n",
|
||||
" [0.3 0. 0.5 0.8 ]\n",
|
||||
" [0.4 0.5 0. 0.45]\n",
|
||||
" [0.8 0.8 0.45 0. ]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"D = np.array([[0, 0.3, 0.4, 0.7],[0, 0, 0.5, 0.8],[0, 0, 0, 0.45],[0, 0, 0, 0]])\n",
|
||||
"D += D.T\n",
|
||||
"print(D)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"On link les 2 clusters les plus proches (a,b) donc on prend le max de différence entre (a,b) et c et d."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[0. 0.5 0.8 ]\n",
|
||||
" [0.5 0. 0.45]\n",
|
||||
" [0.8 0.45 0. ]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"D2 = np.array([[0, 0.5, 0.8],[0.5, 0, 0.45],[0.8, 0.45, 0]])\n",
|
||||
"print(D2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"On coupe au saut le plus important sur le dendrogramme (on continu jusqu'a avoir K-clusters)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[0. 0.8]\n",
|
||||
" [0.8 0. ]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# (a,b,c) et d\n",
|
||||
"D3 = np.array([[0, 0.8],[0.8,0]])\n",
|
||||
"print(D3)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.10 64-bit",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.10"
|
||||
},
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
230
D3/TP/TP1.ipynb
230
D3/TP/TP1.ipynb
File diff suppressed because one or more lines are too long
9
Projet/Projet.md
Normal file
9
Projet/Projet.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Optimisation robot
|
||||
Trouver meilleurs compromis performance/consommation.
|
||||
Répartition sur 5/6 groupes.
|
||||
On peut commencer dès que les groupes sont faits.
|
||||
|
||||
|
||||
## Jetson
|
||||
Pour optimiser le code, il faut connaître le matériel.
|
||||
Faire beaucoup de doc et de tests :)
|
|
@ -14,5 +14,6 @@ p6. temps exécution = nombre instruction * temps moyen par instruction * temps
|
|||
|
||||
p8. instructions simples, donc décomposition des instructions complexes en instructions simples.
|
||||
|
||||
### T1-C3 Pipeline
|
||||
### T1-C5 Hiérarchie mémoire
|
||||
|
||||
p2: courbe correspondant à une technologie, on ne sait pas laquelle.
|
14
T1/TD/[SETI]T1_TD/Bibliographie.bib
Normal file
14
T1/TD/[SETI]T1_TD/Bibliographie.bib
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
|
||||
|
||||
@article{Ref,
|
||||
author = "",
|
||||
title = "",
|
||||
journal = "",
|
||||
volume = "",
|
||||
number = "",
|
||||
pages = "",
|
||||
year = "",
|
||||
DOI = "",
|
||||
keywords = ""
|
||||
}
|
232
T1/TD/[SETI]T1_TD/Content/TD1.tex
Normal file
232
T1/TD/[SETI]T1_TD/Content/TD1.tex
Normal file
|
@ -0,0 +1,232 @@
|
|||
\chapter{Processeurs scalaires, superscalaires et VLIW}
|
||||
|
||||
\section{Prédiction de branchement}
|
||||
|
||||
Un branchement a le comportement suivant, où N signifie non pris, P signifie pris et P*k indique une suite de k branchements pris.\\
|
||||
PPNP*kNP*kNP*kNP*kNP*k...
|
||||
|
||||
\subsection{Prédiction après phase d'initialisation}
|
||||
|
||||
\subsubsection{a)}
|
||||
|
||||
Pour un prédicteur 1 bit, à chaque mauvaise prédiction la prochaine prédiction sera inversée ou plutôt on ne change pas la prédiction tant qu'elle est bonne.
|
||||
|
||||
- $k=1$
|
||||
|
||||
\begin{tabular}{l l}
|
||||
Branchement &: P P N P N P N P N P \\
|
||||
Prédicteur &: \color{blue}{X} \color{green}{P} \color{red}{P N P N P N P N}
|
||||
\end{tabular}
|
||||
|
||||
Prédictions bonnes à $\frac{k-1}{(k-1)+2} = 0 \implies 0\%$
|
||||
|
||||
- $k=3$
|
||||
|
||||
\begin{tabular}{l l}
|
||||
Branchement &: P P N P P P N P P P N P P P N P P P\\
|
||||
Prédicteur &: \color{blue}{X} \color{green}{P} \color{red}{P N} \color{green}{P P} \color{red}{P N} \color{green}{P P} \color{red}{P N} \color{green}{P P} \color{red}{P N} \color{green}{P P}
|
||||
\end{tabular}
|
||||
|
||||
Prédiction bonnes à $\frac{k-1}{(k-1)+2} = \frac{1}{2} \implies 50\%$
|
||||
|
||||
- $k=5$
|
||||
|
||||
\begin{tabular}{l l}
|
||||
Branchement &: P P N P P P P P N P P P P P N P P P P P N P P P P P\\
|
||||
Prédicteur &: \color{blue}{X} \color{green}{P} \color{red}{P N} \color{green}{P P P P} \color{red}{P N} \color{green}{P P P P} \color{red}{P N} \color{green}{P P P P} \color{red}{P N} \color{green}{P P P P}
|
||||
\end{tabular}
|
||||
|
||||
Prédiction bonnes à $\frac{k-1}{(k-1)+2} = \frac{4}{6} \implies 66\%$
|
||||
|
||||
On a bien la conclusion que plus une boucle est longue et donc une répétition de branchements est importante et plus le prédicteur sera efficace.
|
||||
|
||||
\subsubsection{b)}
|
||||
|
||||
Pour un prédicteur 2 bits, on passe d'un niveau fort (FX) à faible (fx) lors d'une erreur de prédiction avant de changer la prédiction de branchement. Lorsque la prédiction est bonne en revanche, on passe d'un état faible à un état fort.
|
||||
|
||||
FP $\iff$ fp $\iff$ fn $\iff$ FN
|
||||
|
||||
- $k=1$
|
||||
|
||||
\begin{tabular}{l l}
|
||||
Branchement &: P ~~~~~P ~~~~N ~~P ~N ~~P ~N ~~P ~N ~P \\
|
||||
Prédicteur &: \color{blue}{fx} \color{green}{FP|fp} \color{red}{FP} \color{green}{fp} \color{red}{FP} \color{green}{fp} \color{red}{FP} \color{green}{fp} \color{red}{FP} \color{green}{fp}
|
||||
\end{tabular}
|
||||
|
||||
Prédictions bonnes de 50\% à condition de ne pas commencer par FNP.
|
||||
|
||||
- $k=3$
|
||||
|
||||
\begin{tabular}{l l}
|
||||
Branchement &: P ~~~~~P ~~~~N ~~P ~P ~~P ~~N ~~P ~~P ~~P ~~N ~~P ~~P ~~P ~~N ~~P ~~P ~P\\
|
||||
Prédicteur &: \color{blue}{fx} \color{green}{FP|fp} \color{red}{FP} \color{green}{fp FP FP} \color{red}{FP} \color{green}{fp FP FP} \color{red}{FP} \color{green}{fp FP FP} \color{red}{FP} \color{green}{fp FP FP}
|
||||
\end{tabular}
|
||||
|
||||
Prédictions bonnes à 75\%. Si la première prédiction est à FN, on perd seulement la validité de quelques (4) premiers branchements.
|
||||
|
||||
- $k=5$
|
||||
|
||||
(FX $\longrightarrow$ X, fx $\longrightarrow$ x)
|
||||
|
||||
\begin{tabular}{l l}
|
||||
Branchement &: P ~~~~~P ~~~N P P P P P N P P P P P N P P P P P N P P P P P\\
|
||||
Prédicteur &: \color{blue}{fx} \color{green}{FP|fp} \color{red}{P} \color{green}{p P P P P} \color{red}{~P} \color{green}{p P P P P} \color{red}{P} \color{green}{p P P P P} \color{red}{~P} \color{green}{p P P P P}
|
||||
\end{tabular}
|
||||
|
||||
Prédiction bonnes à 83\% avec le même problème que pour $k=3$.
|
||||
|
||||
On remarque cette fois-ci que le taux de bonne prédiction suit $\frac{k}{(k-1)+2}$.
|
||||
On devient plus résilient aux boucles imbriquées.
|
||||
|
||||
\subsection{Prédicteur un bit et un bit d'historique initialisé à N}
|
||||
Prédicteur P : si P est une bonne prédiction, le reste de ses prédictions sera à N sinon il sera à P.\\
|
||||
Prédicteur N : si N est une bonne prédiction, le reste de ses prédictions sera à N sinon à P.
|
||||
|
||||
- $k=1$
|
||||
|
||||
\begin{tabular}{llllllllllll}
|
||||
Branchement &: &P &P &N &P &N &P &N &P &N &P \\
|
||||
Historique &: &\color{blue}X &\color{blue}P &\color{blue}P &\color{blue}N &\color{blue}P &\color{blue}N &\color{blue}P &\color{blue}N &\color{blue}P &\color{blue}N \\
|
||||
Prédicteur P &: &\color{blue}X &\color{green}\boxed{P} &\color{red}\boxed{P} &\color{red}N &\color{green}\boxed{N} &\color{red}N &\color{green}\boxed{N} &\color{red}N &\color{green}\boxed{N} &\color{red}N \\
|
||||
Prédicteur N &: &\color{blue}X &\color{red}N &\color{green}N &\color{red}\boxed{N} &\color{red}P &\color{green}\boxed{P} &\color{red}P &\color{green}\boxed{P} &\color{red}P &\color{green}\boxed{P}
|
||||
\end{tabular}
|
||||
|
||||
Prédictions bonnes à 100\% car le cycle de répétition (période) est de 2 ce qui est la limite d'historique pour un prédicteur 1 bit ($2^1$).
|
||||
|
||||
- $k=3$
|
||||
|
||||
\begin{tabular}{llllllllllllllllllll}
|
||||
Branchement &: &P &P &N &P &P &P &N &P &P &P &N &P &P &P &N &P &P &P\\
|
||||
Historique &: &\color{blue}X &\color{blue}P &\color{blue}P &\color{blue}N &\color{blue}P &\color{blue}P &\color{blue}P &\color{blue}N &\color{blue}P &\color{blue}P &\color{blue}P &\color{blue}N &\color{blue}P &\color{blue}P &\color{blue}P &\color{blue}N &\color{blue}P &\color{blue}P \\
|
||||
Prédicteur P &: &\color{blue}{X} &\color{green}\boxed{P} &\color{red}\boxed{P} &\color{gray}N &\color{red}\boxed{N} &\color{green}\boxed{P} &\color{red}{\boxed{P}} &\color{gray}N &\color{red}\boxed{N} &\color{green}\boxed{P} &\color{red}{\boxed{P}} &\color{gray}N &\color{red}\boxed{N} &\color{green}\boxed{P} &\color{red}{\boxed{P}} &\color{gray}N &\color{red}\boxed{N} &\color{green}\boxed{P}\\
|
||||
Prédicteur N &: &\color{blue}{X} &\color{gray}{N} &\color{gray}{N} &\color{red}\boxed{N} &\color{gray}P &\color{gray}P &\color{gray}{P} &\color{green}\boxed{P} &\color{gray}P &\color{gray}P &\color{gray}{P} &\color{green}\boxed{P} &\color{gray}P &\color{gray}P &\color{gray}{P} &\color{green}\boxed{P} &\color{gray}P &\color{gray}P
|
||||
\end{tabular}
|
||||
|
||||
Prédiction bonnes à 50\%
|
||||
|
||||
- $k=5$
|
||||
|
||||
\begin{tabular}{l l}
|
||||
Branchement &: P P N P P P P P N P P P P P N P P P P P N P P P P P\\
|
||||
Historique &: \color{blue}X P P N P P P P P N P P P P P N P P P P P N P P P P \\
|
||||
Prédicteur P &: \color{blue}{X} \color{green}{P} \color{red}{P} \color{gray}{N} \color{red}{N} \color{green}{P P P} \color{red}{P} \color{gray}{N} \color{red}{N} \color{green}{P P P} \color{red}{P} \color{gray}{N} \color{red}{N} \color{green}{ P P P} \color{red}{P} \color{gray}{N} \color{red}{N} \color{green}{P P P}\\
|
||||
Prédicteur N &: \color{blue}{X} \color{gray}{N N} \color{green}P \color{gray}{ P P P P P} \color{green}{P} \color{gray}{P P P P P} \color{green}{P} \color{gray}{P P P P P} \color{green}{P} \color{gray}{P P P P}
|
||||
\end{tabular}
|
||||
|
||||
Prédiction bonnes de $\frac{2}{3}$
|
||||
|
||||
\section{Processeurs scalaires et superscalaires : exécution de boucles}
|
||||
|
||||
\subsection{Version scalaire du processeur et caches parfaits
|
||||
(aucun cycle d’attente mémoire)}
|
||||
|
||||
Corps du programme en assembleur :
|
||||
|
||||
\begin{minted}[linenos, breaklines, frame = single]{asm}
|
||||
boucle:
|
||||
lf f1, (r1) //f1 ← x[i]
|
||||
lf f2, (r2) //f2 ← y[i]
|
||||
fmul f1, f1, f0 //f1 ← x[i]*a
|
||||
NOP*3
|
||||
fadd f2, f2, f1 //f2 ← y[i]+x[i]*a
|
||||
NOP*3
|
||||
sf f2, (r2) //y[i] ← f2
|
||||
addi r1, r1, 4 //x[i++]
|
||||
addi r2, r2, 4 //y[i++]
|
||||
addi r3, r3, -1 //i++
|
||||
bne r3, boucle //1000 itérations
|
||||
\end{minted}
|
||||
|
||||
On part de la valeur i (r3) = 1000 jusqu'à 0 (while(i>0)) et on incrémente les indices en conséquence.
|
||||
Avec les 6 NOP, on arrive à 15 cycles/opérations.
|
||||
|
||||
On optimise les latences en modifiant les chargements et incrémentation d'indices.
|
||||
|
||||
\begin{minted}[linenos, breaklines, frame = single]{asm}
|
||||
boucle:
|
||||
lf f1, (r1) //f1 ← x[i]
|
||||
lf f2, (r2) //f2 ← y[i]
|
||||
fmul f1, f1, f0 //f1 ← x[i]*a
|
||||
addi r1, r1, 4 //x[i++]
|
||||
addi r2, r2, 4 //y[i++]
|
||||
addi r3, r3, -1 //i--
|
||||
fadd f2, f2, f1 //f2 ← y[i]+x[i]*a
|
||||
NOP*3
|
||||
sf f2, -4(r2) //y[i-1] ← f2
|
||||
bne r3, boucle //1000 itérations
|
||||
\end{minted}
|
||||
On gagne 3 cycles par opération soit 12 cycles/op.
|
||||
|
||||
\subsection{Version déroulée}
|
||||
\begin{minted}[linenos, breaklines, frame = single]{asm}
|
||||
boucle:
|
||||
lf f1, (r1) //f1 ← x[i]
|
||||
lf f3, 4(r1) //f3 ← x[i+1]
|
||||
lf f5, 8(r1) //f5 ← x[i+2]
|
||||
lf f7, 12(r1) //f7 ← x[i+3]
|
||||
lf f2, (r2) //f2 ← y[i]
|
||||
lf f4, 4(r2) //f4 ← y[i+1]
|
||||
lf f6, 8(r2) //f6 ← y[i+2]
|
||||
lf f8, 12(r2) //f8 ← y[i+3]
|
||||
fmul f1, f1, f0 //f1 ← x[i]*a
|
||||
fmul f3, f3, f0 //f3 ← x[i+1]*a
|
||||
fmul f5, f5, f0 //f5 ← x[i+2]*a
|
||||
fmul f7, f7, f0 //f7 ← x[i+3]*a
|
||||
fadd f2, f2, f1 //f2 ← y[i]+x[i]*a
|
||||
fadd f4, f4, f3 //f4 ← y[i+1]+x[i+1]*a
|
||||
fadd f6, f6, f5 //f6 ← y[i+2]+x[i+2]*a
|
||||
fadd f8, f8, f7 //f8 ← y[i+3]+x[i+3]*a
|
||||
addi r1, r1, 16 //x[i++]
|
||||
addi r2, r2, 16 //x[i++]
|
||||
addi r3, r3, -4 //i++
|
||||
sf f2, -12(r2) //y[i-3] ← f2
|
||||
sf f4, -8(r2) //y[i-2] ← f4
|
||||
sf f6, -4(r2) //y[i-1] ← f6
|
||||
sf f8, (r2) //y[i] ← f8
|
||||
bne r3, boucle //1000 itérations
|
||||
\end{minted}
|
||||
|
||||
On a 24 cycles pour 4 itérations, soit 6 cycles/itération.
|
||||
|
||||
\subsection{Superscalaire}
|
||||
|
||||
\begin{tabular}{r|c|c|c|c}
|
||||
&E0 & E1 & FM & FA \\
|
||||
\hline
|
||||
1&lf f1,(r1) & & &\\
|
||||
2&lf f2,(r2) & & & \\
|
||||
3&addi r1,r1,4& addi r2,r2,4&fmul f1,f1,f0 & \\
|
||||
4&addi r3,r3,-1&&&\\
|
||||
5&&&&\\
|
||||
6&&&&\\
|
||||
7&& & & fadd f2,f2,f1\\
|
||||
8&& & & \\
|
||||
9&&&&\\
|
||||
10&&&&\\
|
||||
11& sf f2,-4(r2)&bne r3, boucle & &
|
||||
\end{tabular}
|
||||
|
||||
On ne gagne qu'un cycle avec cette version (11cycles/itération).
|
||||
|
||||
\subsection{Superscalaire déroulé}
|
||||
|
||||
\begin{tabular}{r|c|c|c|c}
|
||||
&E0 & E1 & FM & FA \\
|
||||
\hline
|
||||
1&lf f1,(r1) & lf f3,4(r1) & &\\
|
||||
2& lf f5,8(r1)& lf f7,12(r1) & &\\
|
||||
3& lf f2,(r2)& lf f4,4(r2)& fmul f1,f1,f0&\\
|
||||
4& lf f6,8(r2)& lf f8,12(r2)& fmul f3,f3,f0&\\
|
||||
5& addi r1,r1,16& addi r2,r2,16& fmul f5,f5,f0 & \\
|
||||
6& addi r3,r3,-4& & fmul f5,f5,f0& \\
|
||||
7&&&& fadd f2,f2,f1\\
|
||||
8&&&& fadd f4,f4,f3\\
|
||||
9&&&& fadd f6,f6,f5\\
|
||||
10&& & & fadd f8,f8,f7\\
|
||||
11&sf f2,-12(r2) & & & \\
|
||||
12&sf f4,-8(r2)&&&\\
|
||||
13&sf f6,-4(r2)&&&\\
|
||||
14&sf f8, (r2) &bne r3, boucle & &
|
||||
\end{tabular}
|
||||
|
||||
Cette fois-ci, on utilise 14 cycles pour 4 itérations, soit 3,5 cycles/itération.
|
69
T1/TD/[SETI]T1_TD/Content/useful_commands.tex
Normal file
69
T1/TD/[SETI]T1_TD/Content/useful_commands.tex
Normal file
|
@ -0,0 +1,69 @@
|
|||
|
||||
% -------------------- Plot --------------------
|
||||
|
||||
\begin{figure}[ht]
|
||||
\centering
|
||||
\includegraphics[width = 0.3\linewidth]{}
|
||||
\caption{}
|
||||
\end{figure}
|
||||
|
||||
% -------------------- Subplot --------------------
|
||||
|
||||
\begin{figure}[ht]
|
||||
\centering
|
||||
\begin{subfigure}[b]{0.4\textwidth}
|
||||
\includegraphics[width = \linewidth]{}
|
||||
\caption{}
|
||||
\end{subfigure}
|
||||
\hfill
|
||||
\begin{subfigure}[b]{0.4\textwidth}
|
||||
\includegraphics[width = \linewidth]{}
|
||||
\caption{}
|
||||
\end{subfigure}
|
||||
\caption{}
|
||||
\end{figure}
|
||||
|
||||
% -------------------- Bullet list --------------------
|
||||
|
||||
\begin{list}{\textbullet}{}
|
||||
|
||||
\end{list}
|
||||
|
||||
% -------------------- Code matlab --------------------
|
||||
|
||||
\begin{minted}[linenos, breaklines, frame = single]{matlab}
|
||||
|
||||
\end{minted}
|
||||
|
||||
% -------------------- Separate the sheet into smaller sheets ----------------
|
||||
|
||||
\begin{minipage}{0.55\linewidth}
|
||||
|
||||
\end{minipage}\hfill
|
||||
\begin{minipage}{0.45\linewidth}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width = 0.3\linewidth]{TitlePage/ens_logo.png}
|
||||
\caption{}
|
||||
\end{figure}
|
||||
\end{minipage}
|
||||
|
||||
% ------------------- Biblio ------------------
|
||||
|
||||
@article{Ref,
|
||||
author = "",
|
||||
title = "",
|
||||
journal = "",
|
||||
volume = "",
|
||||
number = "",
|
||||
pages = "",
|
||||
year = "",
|
||||
DOI = "",
|
||||
keywords = ""
|
||||
}
|
||||
|
||||
@misc{ref,
|
||||
author = "",
|
||||
title = "",
|
||||
url = {}
|
||||
}
|
BIN
T1/TD/[SETI]T1_TD/TitlePage/ens_logo.png
Normal file
BIN
T1/TD/[SETI]T1_TD/TitlePage/ens_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
48
T1/TD/[SETI]T1_TD/TitlePage/titlepage.tex
Normal file
48
T1/TD/[SETI]T1_TD/TitlePage/titlepage.tex
Normal file
|
@ -0,0 +1,48 @@
|
|||
\begin{titlepage}
|
||||
\makeatletter
|
||||
\begin{center}
|
||||
|
||||
% ------- Main logo --------
|
||||
\null\vspace{1.1cm}
|
||||
\includegraphics[width=.65\linewidth]{\@mainlogo}\\[2cm]
|
||||
|
||||
% ------ Project type ------
|
||||
\ifdefined \@field {\large \@field}\\[0.2\baselineskip] \fi
|
||||
\ifdefined \@project {\large \@project}\\ \fi
|
||||
\vspace{.65cm}
|
||||
|
||||
% ------- Top rule --------
|
||||
\hrule width \hsize height .5mm % Thick horizontal rule
|
||||
\vspace{.035\textheight} % White space between the top rule and title
|
||||
|
||||
% --------- Title ----------
|
||||
\begin{minipage}{.85\textwidth}
|
||||
\bfseries\Huge\centering
|
||||
\textcolor{black}{\@title}
|
||||
\end{minipage}
|
||||
|
||||
% ------ Bottom rule ------
|
||||
\vspace{.035\textheight} % White space between the bottom rule and title
|
||||
\hrule width \hsize height 0.5mm % Thick horizontal rule
|
||||
|
||||
\vspace{.065\textheight}
|
||||
|
||||
% --------- Author ---------
|
||||
\textsc{
|
||||
\Large
|
||||
\begin{tabular}[t]{c}
|
||||
\@author % Author name (array)
|
||||
\end{tabular}
|
||||
}
|
||||
|
||||
\vspace{.02\textheight} % White space between the author name and date
|
||||
|
||||
\vfill % White space between the date and publisher
|
||||
|
||||
\end{center}
|
||||
|
||||
% ---------- Bottom of the page ----------
|
||||
{\large\textsc{\@date}}\hfill % Date of publishing
|
||||
|
||||
\makeatother
|
||||
\end{titlepage}
|
BIN
T1/TD/[SETI]T1_TD/TitlePage/ups_logo.png
Normal file
BIN
T1/TD/[SETI]T1_TD/TitlePage/ups_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
1
T1/TD/[SETI]T1_TD/main.aux
Normal file
1
T1/TD/[SETI]T1_TD/main.aux
Normal file
|
@ -0,0 +1 @@
|
|||
\relax
|
24
T1/TD/[SETI]T1_TD/main.fdb_latexmk
Normal file
24
T1/TD/[SETI]T1_TD/main.fdb_latexmk
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Fdb version 3
|
||||
["pdflatex"] 1666439580 "/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.tex" "/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.pdf" "main" 1666439580
|
||||
"/etc/texmf/web2c/texmf.cnf" 1666438621 475 c0e671620eb5563b2130f56340a5fde8 ""
|
||||
"/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/fouriernc.sty" 0 -1 0 ""
|
||||
"/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.aux" 1666439580 8 a94a2480d3289e625eea47cd1b285758 ""
|
||||
"/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.tex" 1666431070 923 abf7d419c375b72e4f4f9c709bb179f9 ""
|
||||
"/usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map" 1577235249 3524 cb3e574dea2d1052e39280babc910dc8 ""
|
||||
"/usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr12.tfm" 1136768653 1288 655e228510b4c2a1abe905c368440826 ""
|
||||
"/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty" 1573336935 6902 30fdaf7dc5636b8e3afa306210c45cae ""
|
||||
"/usr/share/texlive/texmf-dist/tex/generic/iftex/ifvtex.sty" 1572645307 1057 525c2192b5febbd8c1f662c9468335bb ""
|
||||
"/usr/share/texlive/texmf-dist/tex/latex/base/report.cls" 1580683321 23082 a0e9a5941c744eda6abe56770037a201 ""
|
||||
"/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo" 1580683321 8447 5c4b8ee712f8e349df2722115bc8c513 ""
|
||||
"/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty" 1578002852 41601 9cf6c5257b1bc7af01a58859749dd37a ""
|
||||
"/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty" 1580683321 2590 e3b24ff953e5b58d924f163d25380312 ""
|
||||
"/usr/share/texlive/texmf-dist/web2c/texmf.cnf" 1581979058 38841 ce3692aa899bb693b90b87eaa5d4d84e ""
|
||||
"/usr/share/texmf/web2c/texmf.cnf" 1581979058 38841 ce3692aa899bb693b90b87eaa5d4d84e ""
|
||||
"/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1666439343 4810548 a74f27742f4cc733b879ee587b4a5a24 ""
|
||||
"fouriernc.sty" 0 -1 0 ""
|
||||
"main.tex" 1666431070 923 abf7d419c375b72e4f4f9c709bb179f9 ""
|
||||
"setup.tex" 1666431070 6569 45b84894af7d35b3cf1be8404cef5ccb ""
|
||||
(generated)
|
||||
"/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.pdf"
|
||||
"/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.log"
|
||||
"main.log"
|
23
T1/TD/[SETI]T1_TD/main.fls
Normal file
23
T1/TD/[SETI]T1_TD/main.fls
Normal file
|
@ -0,0 +1,23 @@
|
|||
PWD /home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD
|
||||
INPUT /etc/texmf/web2c/texmf.cnf
|
||||
INPUT /usr/share/texmf/web2c/texmf.cnf
|
||||
INPUT /usr/share/texlive/texmf-dist/web2c/texmf.cnf
|
||||
INPUT /var/lib/texmf/web2c/pdftex/pdflatex.fmt
|
||||
INPUT /home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.tex
|
||||
OUTPUT /home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.log
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/report.cls
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/report.cls
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/size12.clo
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/size12.clo
|
||||
INPUT /usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map
|
||||
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr12.tfm
|
||||
INPUT /home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/setup.tex
|
||||
INPUT /home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/setup.tex
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/generic/iftex/ifvtex.sty
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/generic/iftex/ifvtex.sty
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty
|
||||
INPUT /usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty
|
72
T1/TD/[SETI]T1_TD/main.log
Normal file
72
T1/TD/[SETI]T1_TD/main.log
Normal file
|
@ -0,0 +1,72 @@
|
|||
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex 2022.10.22) 22 OCT 2022 13:53
|
||||
entering extended mode
|
||||
restricted \write18 enabled.
|
||||
file:line:error style messages enabled.
|
||||
%&-line parsing enabled.
|
||||
**/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.tex
|
||||
(/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/main.tex
|
||||
LaTeX2e <2020-02-02> patch level 2
|
||||
L3 programming layer <2020-02-14> (/usr/share/texlive/texmf-dist/tex/latex/base/report.cls
|
||||
Document Class: report 2019/12/20 v1.4l Standard LaTeX document class
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo
|
||||
File: size12.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
|
||||
)
|
||||
\c@part=\count167
|
||||
\c@chapter=\count168
|
||||
\c@section=\count169
|
||||
\c@subsection=\count170
|
||||
\c@subsubsection=\count171
|
||||
\c@paragraph=\count172
|
||||
\c@subparagraph=\count173
|
||||
\c@figure=\count174
|
||||
\c@table=\count175
|
||||
\abovecaptionskip=\skip47
|
||||
\belowcaptionskip=\skip48
|
||||
\bibindent=\dimen134
|
||||
) (/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/setup.tex (/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
|
||||
Package: geometry 2020/01/02 v5.9 Page Geometry
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
|
||||
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
|
||||
\KV@toks@=\toks14
|
||||
) (/usr/share/texlive/texmf-dist/tex/generic/iftex/ifvtex.sty
|
||||
Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty
|
||||
Package: iftex 2019/11/07 v1.0c TeX engine tests
|
||||
))
|
||||
\Gm@cnth=\count176
|
||||
\Gm@cntv=\count177
|
||||
\c@Gm@tempcnt=\count178
|
||||
\Gm@bindingoffset=\dimen135
|
||||
\Gm@wd@mp=\dimen136
|
||||
\Gm@odd@mp=\dimen137
|
||||
\Gm@even@mp=\dimen138
|
||||
\Gm@layoutwidth=\dimen139
|
||||
\Gm@layoutheight=\dimen140
|
||||
\Gm@layouthoffset=\dimen141
|
||||
\Gm@layoutvoffset=\dimen142
|
||||
\Gm@dimlist=\toks15
|
||||
)
|
||||
|
||||
! LaTeX Error: File `fouriernc.sty' not found.
|
||||
|
||||
Type X to quit or <RETURN> to proceed,
|
||||
or enter new name. (Default extension: sty)
|
||||
|
||||
Enter file name:
|
||||
/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/setup.tex:5: Emergency stop.
|
||||
<read *>
|
||||
|
||||
l.5 \usepackage
|
||||
[utf8]{inputenc} % Required for inputting international UTF-8...
|
||||
*** (cannot \read from terminal in nonstop modes)
|
||||
|
||||
|
||||
Here is how much of TeX's memory you used:
|
||||
789 strings out of 483154
|
||||
10866 string characters out of 5965022
|
||||
241641 words of memory out of 5000000
|
||||
15886 multiletter control sequences out of 15000+600000
|
||||
532636 words of font info for 25 fonts, out of 8000000 for 9000
|
||||
14 hyphenation exceptions out of 8191
|
||||
33i,0n,27p,208b,36s stack positions out of 5000i,500n,10000p,200000b,80000s
|
||||
/home/higepi/Documents/M2R_SETI/M2_SETI/T1/TD/[SETI]T1_TD/setup.tex:5: ==> Fatal error occurred, no output PDF file produced!
|
44
T1/TD/[SETI]T1_TD/main.tex
Normal file
44
T1/TD/[SETI]T1_TD/main.tex
Normal file
|
@ -0,0 +1,44 @@
|
|||
\documentclass[a4paper, 12pt, french]{report}
|
||||
\input{setup.tex}
|
||||
|
||||
\begin{document}
|
||||
|
||||
% Title page placeholders
|
||||
\title{T1 - Architecture avancée - TD}
|
||||
\author{Saša Radosavljevic}
|
||||
\date{\today}
|
||||
\field{M2 E3A - SETI}
|
||||
\mainlogo{TitlePage/ups_logo.png}
|
||||
|
||||
|
||||
% Make title page
|
||||
\include{TitlePage/titlepage}
|
||||
\newpage
|
||||
\
|
||||
\thispagestyle{empty}
|
||||
\newpage
|
||||
% Front matter - Page numbers in alphabetic style
|
||||
\changepagenumbering{arabic}
|
||||
|
||||
% TOC - links are black to ensure color integrity
|
||||
{
|
||||
\hypersetup{linkcolor=black}
|
||||
\tableofcontents
|
||||
}
|
||||
|
||||
% Set new paragraph style after the TOC
|
||||
\setlength{\parindent}{0em} % Indentation size to none
|
||||
\setlength{\parskip}{1em} % Paragraph intervall size
|
||||
|
||||
\include{Content/TD1}
|
||||
|
||||
% Main matter - Include every chapter/part here
|
||||
|
||||
|
||||
\printbibliography
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
\end{document}
|
127
T1/TD/[SETI]T1_TD/setup.tex
Normal file
127
T1/TD/[SETI]T1_TD/setup.tex
Normal file
|
@ -0,0 +1,127 @@
|
|||
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
|
||||
|
||||
% ----------------- Fonts, encoding and language packages ------------------
|
||||
\usepackage{fouriernc} % Use the New Century Schoolbook font
|
||||
\usepackage[utf8]{inputenc} % Required for inputting international UTF-8 characters
|
||||
\usepackage[T1]{fontenc} % Output font encoding for international characters
|
||||
\usepackage{babel} % Language package (language is defined in documentclass)
|
||||
\usepackage{setspace} % Font/line (and others) spacing configuration
|
||||
\usepackage{tocbibind} % Insert TOC reference link into TOC
|
||||
\usepackage[section]{placeins} % Place figures in their section only
|
||||
|
||||
% ------------- Tables, figures and other special environments -------------
|
||||
\usepackage{graphicx} % Import and manage graphics
|
||||
\usepackage{tabularx} % Better table control (ie. auto cell's width)
|
||||
\usepackage{multirow} % Allows multirow cells in tables
|
||||
\usepackage{pdfpages} % Insert PDF documents
|
||||
\usepackage{subcaption} % To use subfigures
|
||||
\usepackage[export]{adjustbox} % Adjust figures position
|
||||
\usepackage{marginnote} % Insert notes in doc margins
|
||||
|
||||
% Table column types (gray italic column / centered expanding column)
|
||||
\newcolumntype{\grayc}{>{\itshape\large\raggedright\arraybackslash\columncolor{gray90}}c}
|
||||
\newcolumntype{\centerX}{>{\centering\arraybackslash}X}
|
||||
|
||||
% --------------------- Codes and scripts environments ---------------------
|
||||
\usepackage{listings} % Create lists with line numbers (used for code view)
|
||||
\usepackage{minted} % Color syntax for scripts in multiple languages
|
||||
|
||||
% ----------------------------- Color defines ------------------------------
|
||||
\usepackage{xcolor,colortbl} % Table cells color editing
|
||||
\usepackage{color} % Main color package (define colors)
|
||||
\definecolor{accentcolor}{RGB}{0,119,139} % Accent color used in the whole doc
|
||||
\definecolor{gray75}{gray}{0.75} % Title lines main color
|
||||
\definecolor{gray90}{gray}{0.90} % Table main rows/columns
|
||||
\definecolor{darkgreen}{rgb}{.0, .5, .0} % EXTENDS command color
|
||||
|
||||
% Insert links, color them and modify PDF settings
|
||||
\usepackage[colorlinks=true,allcolors=accentcolor,bookmarks=true]{hyperref}
|
||||
|
||||
\definecolor{ENSBlue}{RGB}{0, 119, 139}
|
||||
\definecolor{ENSGrey}{rgb}{0.3, 0.3, 0.3}
|
||||
\definecolor{ENSLightGrey}{RGB}{190, 200, 200}
|
||||
\definecolor{ENSDarkBlue}{RGB}{10, 50, 80}
|
||||
\definecolor{matlabGreen}{RGB}{28, 172, 0} % Pour le listing des codes
|
||||
\definecolor{matlabLilas}{RGB}{170, 55, 241}
|
||||
|
||||
% -------------------- Bibliography configuration --------------------------
|
||||
\usepackage[backend=biber,style=numeric,sorting=none]{biblatex}
|
||||
\usepackage{csquotes} % To ensure quotes with biblatex are working well
|
||||
\addbibresource{Bibliographie.bib} % Bibliography file to load
|
||||
|
||||
% --------------------------- Title style editing --------------------------
|
||||
\usepackage{titlesec} % Lets modify header styles (chapter, section, etc)
|
||||
\newcommand{\hspct}{\hspace{18pt}} % Horizontal space for chapter title
|
||||
\newcommand{\hspst}{\hspace{9pt}} % Horizontal space for section title
|
||||
\newcommand{\hspsst}{\hspace{4.5pt}} % Horizontal space for subsection title
|
||||
|
||||
\titleformat{\chapter}[hang]
|
||||
{\color{ENSBlue}\Huge\bfseries\raggedright} % Huge size and bold font
|
||||
{\thechapter\hspct % Number and horizontal space
|
||||
\textcolor{ENSBlue}{\rule[-0.25\baselineskip]{5pt}{\baselineskip}}
|
||||
\hspct}{0pt}{} % Horizontal space then name
|
||||
|
||||
\titleformat{\section}[hang]
|
||||
{\color{ENSBlue}\Large\bfseries\raggedright} % Huge size and bold font
|
||||
{\thesection\hspst\textcolor{ENSDarkBlue}{-}\hspst}{0pt}{} % Number, horizontal space then name
|
||||
[\hrule height 0.5pt]
|
||||
|
||||
\titleformat{\subsection}[hang]
|
||||
{\color{ENSBlue}\large\bfseries\raggedright} % Color, Huge size and bold font
|
||||
{\thesubsection\hspsst\textcolor{ENSDarkBlue}{-}\hspsst}{0pt}{} % Number, horizontal space then name
|
||||
|
||||
\titleformat{\subsubsection}[hang]
|
||||
{\color{ENSBlue}\large\bfseries\raggedright} % Color, Huge size and bold font
|
||||
{\thesubsection\hspsst\textcolor{ENSDarkBlue}{-}\hspsst}{0pt}{} % Number, horizontal space then name
|
||||
|
||||
\titleformat{\subsubsubsection}[hang]
|
||||
{\color{ENSBlue}\large\bfseries\raggedright} % Color, Huge size and bold font
|
||||
{\thesubsection\hspsst\textcolor{ENSDarkBlue}{-}\hspsst}{0pt}{} % Number, horizontal space then name
|
||||
|
||||
|
||||
% -------------------------- Mathematic packages --------------------------
|
||||
\usepackage{amsmath} % Create matrices, subequations and more
|
||||
\usepackage{amssymb} % Math font to create symbols from characters
|
||||
|
||||
% Mathematic new commands
|
||||
\newcommand{\sgn}{\text{sgn}} % Sign function as text
|
||||
|
||||
% -------------------------- FRENCH translations --------------------------
|
||||
|
||||
\iflanguage{french}{ % Replace "Table" with "Tableau" in FRENCH only
|
||||
\AtBeginDocument{\renewcommand\tablename{\textsc{Tableau}}}
|
||||
\AtBeginDocument{\renewcommand\listingscaption{\textsc{Code}}}
|
||||
\AtBeginDocument{\renewcommand\lstlistlistingname{Liste des codes}}
|
||||
}
|
||||
|
||||
% -------------------------- New useful commands --------------------------
|
||||
\newcommand{\todo}[1]{\textbf{\textcolor{blue}{(TODO: #1)}} \PackageWarning{setup}{#1}} % TODO command
|
||||
\newcommand{\extend}[1]{\textbf{\textcolor{darkgreen}{(EXTEND: #1)}} \PackageWarning{setup}{#1}} % EXTENDS command
|
||||
\newcommand{\draft}[1]{\textbf{\textcolor{red}{(DRAFT: #1)}} \PackageWarning{setup}{#1}} % DRAFT command
|
||||
|
||||
% Reset page number and change page numbering style
|
||||
\newcommand{\changepagenumbering}[1]{
|
||||
\setcounter{page}{1}
|
||||
\pagenumbering{#1}
|
||||
}
|
||||
|
||||
\makeatletter
|
||||
\newcommand*{\field}[1]{\gdef\@field{#1}} % Defines "field" variable used in title page
|
||||
\newcommand*{\project}[1]{\gdef\@project{#1}} % Defines "project" variable used in title page
|
||||
\newcommand*{\mainlogo}[1]{\gdef\@mainlogo{#1}} % Defines "mainlogo" variable used in title page
|
||||
\newcommand*{\logoCN}[1]{\gdef\@logoCN{#1}} % Defines "optionallogo" variable used in title page
|
||||
\newcommand*{\logoCNRS}[1]{\gdef\@logoCNRS{#1}} % Defines "optionallogo" variable used in title page
|
||||
\makeatother
|
||||
|
||||
% Existing environments configuration
|
||||
\usepackage{etoolbox} % Allows to append commands to existing environements
|
||||
|
||||
\iflanguage{english}{
|
||||
\AtBeginEnvironment{itemize}{\setlength{\baselineskip}{0em}} % Change itemize line skip
|
||||
\AtBeginEnvironment{itemize}{\setlength{\parskip}{.7em}} % Change itemize line vertical space
|
||||
|
||||
\AtBeginEnvironment{enumerate}{\setlength{\baselineskip}{0em}} % Change enumerate line skip
|
||||
\AtBeginEnvironment{enumerate}{\setlength{\parskip}{.7em}} % Change enumerate line vertical space
|
||||
}
|
||||
|
||||
\AtBeginEnvironment{tabularx}{\def\arraystretch{1.6}} % Change array vertical padding within cells
|
Loading…
Reference in a new issue