La présentation est en train de télécharger. S'il vous plaît, attendez

La présentation est en train de télécharger. S'il vous plaît, attendez

UE SYSTEMC – Cours 5 SystemC + Logiciel embarqué

Présentations similaires


Présentation au sujet: "UE SYSTEMC – Cours 5 SystemC + Logiciel embarqué"— Transcription de la présentation:

1 UE SYSTEMC – Cours 5 SystemC + Logiciel embarqué

2 Cheminement des paquets (1)
Initiateur émet Une requête CMDVAL=1 @, etc initiateur0 Interconnect VGMN Virtual Generic Micro Network (Latence variable) cible0 initiateur1

3 Cheminement des paquets (2)
L’interconnect lit L’adresse, et détermine Le composant VCI cible initiateur0 Interconnect cible0 initiateur1

4 Cheminement des paquets (3)
La cible reçoit le paquet Commande, fait son Travail et génère un paquet Réponse (SRCID) initiateur0 Interconnect cible0 initiateur1

5 Cheminement des paquets (4)
initiateur0 Interconnect cible0 initiateur1 Le paquet réponse Transite par l’interconnect

6 Cheminement des paquets (5)
initiateur0 Interconnect cible0 …et revient vers L’initiateur initiateur1

7 Table des segments 8 bits for target decoding 2 bits for cacheability
0xFF reset 0xBFC = text 0x = excep 0x = data 0x = timer 0xB = tty 0xC = mask 0x = 0xC0 2 = tty U 0xBF 0 = reset C 0xB0 1 = timer U 0x80 0 = excep C 8 bits for target decoding 2 bits for cacheability 0x10 0 = data C 0x00 0 = text C Même approche pour les réponses (SRCID) Platform address space = Mapping table

8 soclib_vci_iss.h RSP_LOAD REQ_LOAD CMDACK=1 RSPVAL=1 CMDACK=0 RSPVAL=0 REQ_IFETCH CMDACK=1 RSP_IFETCH RSPVAL=1 DECODE & EXEC CMDACK=0 RSPVAL=0

9 Code de l’ISS MIPS case ISS_DECODE_AND_EXECUTE : {
int opcod=(IR>>26)&0x3F; int rs,rt,rd,func,imm; switch (opcod) case OP_ADDI: rs=(IR>>21)&0x1F; rt=(IR>>16)&0x1F; imm=(IR&0xFFFF); if (imm & 0x8000) imm |= 0xFFFF0000; GPR[rt]=GPR[rs] + imm; PC=PC+4; ISS_FSM=ISS_REQ_IFETCH; break; case OP_ORI: GPR[rt]=GPR[rs] | imm; Code de l’ISS MIPS

10 Processeur scalaire simple : ISS MIPS32
Schéma extrêmement peu efficace MIPS32 (0) Interconnect RAM I, D MIPS32 (1)

11 Performance Le temps passé à attendre une réponse de la mémoire (attente mémoire) a un impact fondamental sur le temps d'exécution d'un programme: Temps d'exécution = (# cycles d'exécution + # cycles d'attente mémoire)  Temps de cycle La pénalité d'accès est le temps (nombre des cycles) nécessaire pour transférer une donnée de la mémoire au processeur. Cycles d'attente mémoire = # accès ¥ Pénalité d'accès = # instructions  # accès par instruction  Pénalité d'accès Le cache est un moyen de réduire la pénalité d'accès. lslwww.epfl.ch/~tempesti/UNIL/Semaine09.ppt

12 Cache mémoire Antémémoire, près du processeur, accessible en 1 cycle d’horloge MIPS32 Cache MIPS32(0) Interconnect RAM LI, LD I, D MIPS32 Cache MIPS32(1)

13 Localité des références
Observation: les références aux données et surtout aux instructions ne sont pas, d'habitude, indépendantes. Les programmes ont tendance à réutiliser les données et les instructions qu'ils ont utilisées récemment. Localité spatiale: les éléments dont les adresses sont proches les unes des autres auront tendance à être référencés dans un temps rapproché (p.ex. instructions, images). Localité temporelle: les éléments auxquels on a eu accès récemment seront probablement accédés dans un futur proche (p.ex. boucles). lslwww.epfl.ch/~tempesti/UNIL/Semaine09.ppt

14 Questions À cause de la localité spatiale, les données et les instructions sont transférées de la mémoire principale au cache en petits blocs de 2-8 mots mémoire. Plusieurs questions s'imposent: Où peut-on placer un bloc dans le cache? Placement de bloc Comment trouver un bloc s'il est présent dans le cache? Identification de bloc Quel bloc doit être remplacé en cas d'échec? Remplacement de bloc Qu'arrive-t-il lors d'une écriture? Stratégie d'écriture lslwww.epfl.ch/~tempesti/UNIL/Semaine09.ppt

15 Placement de bloc - Stratégie I
Si chaque bloc a uniquement une seule place possible dans le cache, celui-ci est appelé à correspondance directe (direct-mapped). La correspondance est généralement la suivante: numéro de bloc mod nombre de blocs dans le cache Cette stratégie de placement est la plus simple à mettre en œuvre, mais aussi la moins performante. lslwww.epfl.ch/~tempesti/UNIL/Semaine09.ppt CACHE À CORRESPONDANCE DIRECTE MÉMOIRE PRINCIPALE BLOC 12  12 mod 8 = 4

16 Structure d’un cache courses.cs.tamu.edu/cpsc321/walker/lectures/lec12.ppt

17 Identification de bloc
Un répertoire est associé à chaque cache associatif. Le répertoire contient le numéro (adresse) de chaque bloc dans le cache, appelé étiquette. Toute les étiquettes dans le répertoire sont examinées en parallèle. Pour un cache totalement associatif, chaque adresse contient donc une étiquette et un déplacement dans le bloc. PROCESSEUR Données entrantes Étiquette Déplacement RÉPERTOIRE MÉMOIRE CACHE = ... = = ... = lslwww.epfl.ch/~tempesti/UNIL/Semaine09.ppt

18 Stratégie d'écriture (1)
La stratégie d'écriture est fondamentale pour la performance du cache de données (environ 25% des accès à ce cache sont des écritures). Deux stratégies sont couramment employées: L'écriture simultanée ou rangement simultané (write-through) consiste à écrire simultanément dans le bloc de cache et dans la mémoire principale. PROCESSEUR Données entrantes Étiquette Déplacement Données sortantes RÉPERTOIRE MÉMOIRE CACHE = ... = = ... = MÉMOIRE PRINCIPALE lslwww.epfl.ch/~tempesti/UNIL/Semaine09.ppt

19 Stratégie d'écriture (2)
La recherche de données en mémoire principale lors d'un échec de lecture dans le cache est prioritaire par rapport à l'écriture. Cette dernière peut donc être suspendue en utilisant un tampon d'écriture (write buffer). Cependant, les tampons d'écriture compliquent les choses car ils peuvent contenir des valeurs modifiées d'un bloc qui fait l'objet d'un échec en lecture. TAMPON D'ÉCRITURE ... = Étiquette RÉPERTOIRE MÉMOIRE CACHE Déplacement PROCESSEUR Données sortantes Données entrantes MÉMOIRE PRINCIPALE Bit modifié lslwww.epfl.ch/~tempesti/UNIL/Semaine09.ppt

20 Cache mémoire Antémémoire, près du processeur, accessible en 1 cycle d’horloge Les périphériques ne sont pas cachés! MIPS32 Cache MIPS32(0) Interconnect RAM LI, LD I, D MIPS32 Cache MIPS32(1)

21 Exemple de plateforme compliquée
2.4 GHz communication channel MIPS RX TX MIPS RX TX Cache ICU Timer Serdes Cache ICU Timer Serdes Interconnect Interconnect RAM Seismic sensor I2C Ctrl RAM Seismic sensor I2C Ctrl Node 0 Node 3 SOFT SOFT Seismic perturbation generator N2 N3 Digital, BCA, SocLib Analog, SystemC-AMS TDF, RF Analog, SystemC-AMS TDF, Physics, ΣΔ (xe,ye) Analog, SystemC-AMS ELN, Electrical, Bus N0 N1 Embedded software

22 Plateforme simplifiée
MIPS MIPS Cache ICU Timer Serdes Cache ICU Timer Serdes Interconnect Interconnect RAM TTY RAM TTY Node 0 Node 1 SOFT SOFT ICU : Interrupt Controller Unit SERDES/UART : Serialiseur, Déserialiseur Les périphériques sont accessibles à des adresses mémoire qui correspondent à des registres. Pour le logiciel, agir sur un périphérique consiste à faire un LW ou un SW sur le registre correspondant.

23 ISS API void reset() void getInstructionRequest(uint32_t &address)
resets the ISS. void getInstructionRequest(uint32_t &address) returns the next initiator PC address void getDataRequest(uint32_t &type, uint32_t &address, uint32_t &wdata) returns the next initiator Data type, address and wdata void setInstruction(bool error, uint32_t val) assigns the ISS IR register with cache instruction void setRdata(bool error, uint32_t rdata) assigns the ISS data register with cache read word void setIrq(uint32_t irq) assigns the ISS irq register with pending interrupt lines void step() executes one ISS step MEM_NONE MEM_LB MEM_LBU MEM_LH MEM_LHU MEM_LW MEM_SB MEM_SH MEM_SW MEM_INVAL

24 r_pc r_npc r_mem r_gp Xcache instruction Xcache instruction Xcache
getInstruction Request getInstruction Request step Xcache instruction step r_npc Xcache instruction setInstruction setInstruction r_mem getData Request getData Request Xcache data Xcache data setRdata setRdata r_gp

25 ISS MIPS32 soclib/soclib/iss Avec une API

26 VciICU This VCI target is a memory mapped peripheral implementing vectorized interrupt controller. It can concentrate up to 32 independent interrupt lines p_irq_in[i] to a single p_irq interrupt line. The active state is high, and the output interrupt is the logical OR of all input interrupts. Each input interrupt can be individually masked through a programmable register. This component can be addressed to return the index of the highest priority active interrupt p_irq_[i]. The priority scheme is fixed : The lower indexes have the highest priority. This hardware component checks for segmentation violation, and can be used as a default target. This component contains 5 memory mapped registers: ICU_INT Each bit in this register reflects the state of the corresponding interrupt line. This is read-only. ICU_MASK Each bit in this register reflects the state of the enable for the corresponding interrupt line. This is read-only. ICU_MASK_SET Each bit set in the written word will be set in the ICU MASK. (ICU_MASK = ICU_MASK | written_data). This is write-only. ICU_MASK_CLEAR Each bit set in the written word will be reset in the ICU MASK. (ICU_MASK = ICU_MASK & ~written_data). This is write-only. ICU_IT_VECTOR This register gives the number of the highest-priority active interrupt. If no interrupt is active, (-1) is returned. This is read-only.

27 Exemple de code #include "soclib/icu.h"
static const volatile void* icu_address = 0xD ; static icu_test() { // Getting / setting interrupt mask uint32_t current_interrupt_mask = soclib_io_get( icu_address, ICU_MASK ); // Enabling IRQ #5 soclib_io_set( icu_address, ICU_MASK_SET, 1<<5 ); // Disabling IRQ #0 soclib_io_set( icu_address, ICU_MASK_CLEAR, 1<<0 ); // When interrupt is raised, you may do: int irq_to_serve = soclib_io_get( icu_address, ICU_IT_VECTOR ); // This should be equivalent to (see man 3 ffs) int irq_to_serve = ffs( soclib_io_get( icu_address, ICU_IT_VECTOR ) & soclib_io_get( icu_address, ICU_MASK ) ); }

28 VciTimer This VCI target is a memory mapped peripheral that can control up to 256 software controlled timers. Each timer can optionally generate an independent periodic interrupt. The memory segment allocated to this component must be aligned on 4K bytes boundary. Each timer contains 4 memory mapped registers: TIMER_VALUE This 32 bits register is unconditionally incremented at each cycle. A read request returns the current time contained in this register. A write request sets a new value in this register. TIMER_MODE This register contains two flags: Bit 0: TIMER_RUNNING. When 1, the associated timer will decrease on each cycle Bit 1: TIMER_IRQ_ENABLED: When 1, the associated IRQ line will be activated if the timer underflows. TIMER_PERIOD This 32 bits register defines the period between two successive interrupts. It may be read or written to. When written to, the new period is immediatly taken into account. TIMER_RESETIRQ Any write request in this Boolean register will reset the pending IRQ. A read request returns the zero value when there is no pending interrupt, and returns a non zero value if there is a pending interrupt.

29 Exemple de code #include "soclib/timer.h"
static const volatile void* timer_address = 0xc ; static timer_test(const size_t timer_no) { // Getting / setting timer current value soclib_io_set( timer_address, TIMER_SPAN*timer_no + TIMER_VALUE, 0x2a00 ); uint32_t foo = soclib_io_get( timer_address, TIMER_SPAN*timer_no + TIMER_VALUE ); // Enabling timer and interrupt soclib_io_set( timer_address, TIMER_SPAN*timer_no + TIMER_MODE, TIMER_RUNNING | TIMER_IRQ_ENABLED ); // Getting IRQ status, and resetting IRQ if ( soclib_io_get( timer_address, TIMER_SPAN*timer_no + TIMER_RESETIRQ ) ) soclib_io_set( timer_address, TIMER_SPAN*timer_no + TIMER_RESETIRQ, 0 ); }

30 SERDES/UART BR (en nb de cycles) B0 B1 … B31 PAR STOP TX BR/2
UART_DATA UART_BR UART_CTRL

31 SERDES/UART, FSM émetteur
B0 B1 B31 PAR STOP TX UART_TX_START UART_TX_PARITY UART_TX_IDLE UART_TX_STOP UART_TX_BIT

32 SERDES/UART, FSM Récepteur
On attend Le front montant BR B0 B1 B31 PAR STOP TX UART_RX_IDLE UART_RX_START UART_RX_PARITY UART_RX_STOP UART_RX_BIT UART_RX_WAITFOREND UART_RX_WAITFORNEXTBIT UART_RX_WAITFORSTOPBIT

33 Etude de la plateforme matérielle

34 TX RX irq1 irq0 4 3 2 1 VciXCacheWrapper VciIcu VciTimer VciUart U U U
BASE=0xD SIZE=0x U timer BASE=0xB SIZE=0x U uart BASE=0xB SIZE=0x U 4 3 2 VciVgmn VciRam VciMultiTty 1 reset BASE=0xBFC00000 SIZE=0x C tty BASE=0xC SIZE=0x U text BASE=0x SIZE=0x C excep BASE=0x SIZE=0x C data BASE=0x SIZE=0x C

35 typedef soclib::caba::VciParams<4,6,32,1,1,1,8,1,1,1> vci_param;
VciVgmn soclib::caba::VciSignals<vci_param> signal_vci_vcitimer("signal_vci_vcitimer"); VciTimer timer BASE=0xB SIZE=0x U typedef soclib::caba::VciParams<4,6,32,1,1,1,8,1,1,1> vci_param; trdid_size = 1 bit wrplen_size = 1 bit pktid_size = 1 bit srcid_size = 8 bits plen_size = 64 words cell_size = 4 * 8 = 32 bits addr_size = 32 bits rerror_size = 1 bit clen_size = 1 bit rflag_size = 1 bit

36 Etude du logiciel embarqué
Programme principal Configuration des périphériques Boucle infinie ISR (Interrupt Service Routine) Si IRQ UART, lire et afficher caractère Si IRQ Timer, compter et acquitter interruption

37 Building the embedded application
MIPS32 *.s mipsel-soclib-elf-unknown-gcc mipsel-soclib-elf-unknown-as Application binary composed of sections Section reset (0xBFC00000) *.o ldscript Section excep (0x ) mipsel-soclib-elf-unknown-ld Section text (0x ) bin.soft (elf format) Section data (0x )

38 Building the embedded application
GCC *.c mipsel-soclib-elf-unknown-gcc -S MIPS32 *.s *.c mipsel-soclib-elf-unknown-gcc -c *.o AS *.s mipsel-soclib-elf-unknown-as *.o LD *.o mipsel-soclib-elf-unknown-ld exec ELF ldscript

39 Structure d’un ldscript
SECTIONS { . = 0x ; .excep : { *(.excep) *(.excep.*) } . = 0xbfc00000; .reset : { *(.reset) *(.reset.*) . = 0x ; .text : { *(.text) ... On crée dans le fichier ELF Une section .excep Qui va contenir toutes les Sections .excep des fichiers .o Le code C standard généré Par Gcc est mis dans une Section .text. On assemble Ensemble ces sections .text Et on en crée une nouvelle, commune


Télécharger ppt "UE SYSTEMC – Cours 5 SystemC + Logiciel embarqué"

Présentations similaires


Annonces Google