---
# System prepended metadata

title: 'Konsultacje (zaliczenie listy 8 i 12), 9 lipca 2023, g. 21.15'
tags: [pwit, ćwiczenia, SYK23]

---



###### tags: `SYK23` `ćwiczenia` `pwit`

## Deklaracje


### Lista 8

:::danger
|                        | 1     | 2   | 3   | 4   | 5   | 6   |
| ----------------------:| ----- | --- | --- | --- | --- | --- |
|      Michał Mękarski    |   x   |   x   |   x   |   x   |   x   | x |
|      Maksymilian Wiśniewski   |   X    |  X   |  X   |     |     |

:::


### Lista 12

:::danger
|                        | 1     | 2   | 3   | 4   | 5   | 6   | 7   |
| ----------------------:| ----- | --- | --- | --- | --- | --- | --- |
|      Michał Mękarski    |   x   |   x  |   x   |   x   |   x   |     |
|      Maksymilian Wiśniewski   |   X    |  X   |   X  |  X   |  X   |   X  |     |

:::

## Zadania problematyczne
- [ ] Lista 08 - zadanie 6
- [ ] Lista 12 - zadanie 7


## Zadanie 8.1
:::success
Autor: Michał Mękarski	
:::

![](https://hackmd.io/_uploads/S1uPttOth.png)

### Control Hazard

Powoduje go instrukcja skoku warunkowego, gdyż do 4 fazy nie wiadomo czy takowy podejmiemy czy też nie.

### Structural Hazard

Problem dostępu do zasobu tj. kilka instrukcji chce z niego skorzystać w tym samym momencie.

### Data Hazards
#### **RAW** - *Read After Write*
jedna instrukcja zapisuje a kolejna czyta ten rejestr
#### **WAR** - *Write After Read*
odwrotnie niż **RAW**
#### **WAW** - *Writa After Write*
dwie instrukcje zapisują jedna po drugiej

### Jednocyklowy

Powyżej opisane Hazardy mogą wystąpić tylko wtedy, gdy wykonanie operacji próbujemy zrównoleglić, ergo tutaj nie mamy problemu.

### Potokowy

✅ Control
❎ Structural
✅ RAW
❎ WAR
❎ WAW

### Potokowy z wieloma ALU

✅ Control
✅ Structural
✅ RAW
✅ WAR
✅ WAW

## Zadanie 8.2
:::success
Autor: Maksymilian Wiśniewski	
:::

![](https://hackmd.io/_uploads/By4f9FOK3.png)


## Zadanie 8.3
:::success
Autor: Michał Mękarski	
:::

![](https://hackmd.io/_uploads/Hk2utKOFh.png)

### Data Hazards

Wprowadzenie bufora eliminuje **Hazardy Danych** ponieważ dane w pamięci zawsze zapisane są w prawidłowej kolejności.
Dzieje sie tak dlatego, że 
1. zapisy pisane są na wejście bufora
2. gdyby miał nastąpić hazard **RAW** nasz algorytm musi poczekać na pojawienie się jego "rejestrów" na wejściowym buforze


## Zadanie 8.5
:::success
Autor: Michał Mękarski	
:::

![](https://hackmd.io/_uploads/HyL9Yt_K3.png)

### a)

| Kolejne_instrukcje | 1   | 2   | 3   | 4   | 5   | 6   | 7   | 8   | 9   | 10  | 11  | 12  | 13  | 14  | 15  | 16  | 17  | 18  | 19  | 20  | 21  | 22  | 23  | 24  | 25  | 26  | 27  | 28  | 29  |  30  |
| -------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| r3 = r1 * r2   | F   | D   | E1  | E2  | E3  | E4  | E5  | E6  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r5 = r4 + r3   |     | F   | D   | D   | D   | D   | D   | D   | D   | E1  | E2  | E3  | E4  | E5  | E6  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r7 = r2 + r6   |     |     | F   | F   | F   | F   | F   | F   | F   | D   | E1  | E2  | E3  | E4  | E5  | E6  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r10 = r8 + r9  |     |     |     |     |     |     |     |     |     | F   | D   | E1  | E2  | E3  | E4  | E5  | E6  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |
| r11 = r7 * r10 |     |     |     |     |     |     |     |     |     |     | F   | D   | D   | D   | D   | D   | D   | E1  | E2  | E3  | E4  | E5  | E6  |  WB  |     |     |     |     |     |     |
| r5 = r5 + r11  |     |     |     |     |     |     |     |     |     |     |     | F   | F   | F   | F   | F   | F   | D   | D   | D   | D   | D   | D   | E1  | E2  | E3  |  E4  | E5  |  E6  |  WB  |

Liczba cykli: 30 


### b)
| Kolejne_instrukcje | 1   | 2   | 3   | 4   | 5   | 6   | 7   | 8   | 9   | 10  | 11  | 12  | 13  | 14  | 15  | 16  | 17  | 18  | 19  | 20  | 21  | 22  | 23  | 24  | 25  | 26  | 27  | 28  | 29  | 30  | 31  | 32  | 33  | 34  | 35    | 36    |
| -------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| r3 = r1 * r2   | F   | D   | E1  | E2  | E3  | E4  | E5  | E6  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r5 = r4 + r3   |     | F   | D   |     |     |     |     |     | D   | E1  | E2  | E3  | E4  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r7 = r2 + r6   |     |     | F   |     |     |     |     |     |     | D   |     |     |     | E1  | E2  | E3  | E4  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r10 = r8 + r9  |     |     |     |     |     |     |     |     |     | F   |     |     |    | D    |     |     |     | E1  | E2  | E3  | E4  | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r11 = r7 * r10 |     |     |     |     |     |     |     |     |     |     |     |     |    |  F   |     |     |     |     |     |     |     | D   | E1  | E2  | E3  | E4  | E5  | E6  | WB  |     |     |     |     |     |     |     |
| r5 = r5 + r11  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     | F   | D   |     |     |     |     |     | D   | E1  | E2  | E3  | E4  | E5  | E6  | WB    |

Liczba cykli: 36

### c)
| Kolejne_instrukcje | 1   | 2   | 3   | 4   | 5   | 6   | 7   | 8   | 9   | 10  | 11  | 12  | 13  | 14  | 15  | 16  | 17  | 18  | 19  | 20  | 21  | 22  | 23  | 24  | 25  | 26  | 27  | 28  | 29  | 30  |
| -------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| r3 = r1 * r2   | F   | D   | E1  | E2  | E3  | E4  | E5  | E6  | R   | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r5 = r4 + r3   |     | F   | D   |     |     |     |     |     | E1  | E2  | E3  | E4  | R   | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r7 = r2 + r6   |     |     | F   | D   | E1  | E2  | E3  | E4  |     | R   |     |     |     |     | WB  |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
| r10 = r8 + r9  |     |     |     | F   | D   |     |     |     |     |     |     |     | E1  | E2  | E3  | E4  | R   | WB  |     |     |     |     |     |     |     |     |     |     |     |     |
| r11 = r7 * r10 |     |     |     |     | F   | D   |     |     |     |     |     |     |     |     |     |     | E1  | E2  | E3  | E4  | E5  | E6  | R   | WB  |     |     |     |     |     |     |
| r5 = r5 + r11  |     |     |     |     |     | F   | D   |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     | E1  | E2  | E3  | E4  | E5  | E6  |  R  |  WB   |

Liczba cykli: 30


## Zadanie 12.1
:::success
Autor: Maksymilian Wiśniewski	
:::

![](https://hackmd.io/_uploads/SyQH5KOKh.png)


## Zadanie 12.3
:::success
Autor: Maksymilian Wiśniewski	
:::

![](https://hackmd.io/_uploads/S1dwqY_tn.png)


## Zadanie 12.4
:::success
Autor: Michał Mękarski	
:::

![](https://hackmd.io/_uploads/HkHTl9utn.png)

![](https://hackmd.io/_uploads/ByrQb5dt2.png)


## Zadanie 12.5
:::success
Autor: Maksymilian Wiśniewski	
:::

![](https://hackmd.io/_uploads/HyNtqKuK2.png)



## 8.6

![](https://hackmd.io/_uploads/BJzG59_F3.png)



