Skip to content

Commit

Permalink
lab0
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcioc committed Sep 25, 2024
1 parent 3153b8e commit 8b87f08
Show file tree
Hide file tree
Showing 49 changed files with 634 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Vivado Slim Dev",
//"build": { "dockerfile": "Dockerfile" },
"image": "gitlab.cs.pub.ro:5050/ac/ac-public/vivado-slim:1.0.0",
"runArgs": [
"--rm",
"--privileged"
],
//"appPort": [3121, 60001, 3042],
"mounts": ["type=bind,source=/dev,target=/dev"],
//"otherPortsAttributes": {"requireLocalPort": "true", "elevateIfNeeded" : "true"},
"customizations": {
"vscode": {
"extensions": [
"mshr-h.veriloghdl"
]
}
}
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REPO_NAME = oer-template
REPO_NAME = computer-architecture
IMAGE_NAME = $(REPO_NAME)/docusaurus:latest
CONTAINER_NAME = open-edu-hub-$(REPO_NAME)-bash
OUTPUT_DIR = $$PWD/.output/$(REPO_NAME)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python

def main():
print(f'Hello world')

if __name__ == '__main__':
main()
22 changes: 22 additions & 0 deletions chapters/lab0/combinational/drills/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Practice: Baby Steps

We recommend that for practice, you add a subsection for the exercises.
This will make it so you can delimit the exercises from the lab's text.

1. You can number the exercises as such.
And have the text roll over to the next line.

1. This is a second numbered exercise.

**Be careful!**
You can even link to other chapters internally [like this](questions.md)

Another neat feature is that you can add inline code that uses language specific highlight.

```Python
with event:
while len(messages) == 0:
event.wait()
```

For now, a quiz can only be linked to as such: [Quiz 1](questions.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/hello-world
19 changes: 19 additions & 0 deletions chapters/lab0/combinational/drills/hello-world/solution/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CFLAGS = -Wall -Wextra
CPPFLAGS = -I utils/ -I utils/log/

EXEC = hello-world
OBJ = $(patsubst %,%.o,$(EXEC))
SRC = $(patsubst %,%.c,$(EXEC))

all: $(EXEC)

$(EXEC): $(OBJ) utils/log/log.o

$(OBJ): $(SRC)

utils/log/log.o: utils/log/log.c

clean::
-rm -f $(OBJ) utils/log/log.o
-rm -f $(EXEC)
-rm -f *~
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

#include "utils.h"

int main(void)
{
/**
* TODO 1: Print a hello world message
*/
printf("Hello world\n");

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../../../../../common/utils/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/hello-world
19 changes: 19 additions & 0 deletions chapters/lab0/combinational/drills/hello-world/support/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CFLAGS = -Wall -Wextra
CPPFLAGS = -I utils/ -I utils/log/

EXEC = hello-world
OBJ = $(patsubst %,%.o,$(EXEC))
SRC = $(patsubst %,%.c,$(EXEC))

all: $(EXEC)

$(EXEC): $(OBJ) utils/log/log.o

$(OBJ): $(SRC)

utils/log/log.o: utils/log/log.c

clean::
-rm -f $(OBJ) utils/log/log.o
-rm -f $(EXEC)
-rm -f *~
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

#include "utils.h"

int main(void)
{
/**
* TODO 1: Print a hello world message
*/

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../../../../../common/utils/
20 changes: 20 additions & 0 deletions chapters/lab0/combinational/drills/questions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# TODO question

## Question Text

Which answer is the correct answer?

## Question Answers

- Bad answer 1
+ Correct answer
- Bad answer 2
- Bad answer 3

## Feedback

Correct answer is the correct answer

```console
echo "Guess why"
```
15 changes: 15 additions & 0 deletions chapters/lab0/combinational/guides/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Guides

## Executable Paths

Single instances of commands should be written using monotype fonts such as this `ls`.

For longer outputs, you will use the following syntax:

```console
student@os:~$ which ls
/usr/bin/ls

student@os:~$ file /usr/bin/ls
/usr/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6e3da6f0bc36b6398b8651bbc2e08831a21a90da, for GNU/Linux 3.2.0, stripped
```
4 changes: 4 additions & 0 deletions chapters/lab0/combinational/media/app-os-cpu-interaction.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/lab0/combinational/media/gate-and.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/lab0/combinational/media/gate-nand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/lab0/combinational/media/gate-nor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/lab0/combinational/media/gate-not.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/lab0/combinational/media/gate-or.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/lab0/combinational/media/gate-xnor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/lab0/combinational/media/gate-xor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions chapters/lab0/combinational/reading/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Circuite combinaționale

Circuitele logice combinaționale aplică funcții logice pe semnalele de intrare pentru a obține semnalele de ieșire. Valorile de ieșire depind doar de valorile de intrare, iar când starea unei intrări se schimbă, acest lucru se reflectă imediat la ieșirile circuitului.

![Diagrama bloc pentru un circuit combinațional cu n intrări și m ieșiri](../media/circuit-comb.png)



Logica combinațională poate fi reprezentată prin:
- diagrame structurale la nivel de porți logice
- tabele de adevăr
- expresii booleene (funcții logice)

Circuitele combinaționale sunt folosite în procesoare în cadrul componentelor de calcul, iar cele mai des întâlnite sunt:
- multiplexoarele și demultiplexoarele
- codificatoarele și decodificatoarele
- sumatoarele
- comparatoarele
- memoriile ROM (read-only, nu păstrează stare)

Un exemplu de folosire a sumatoarelor este în cadrul Unităților Aritmetice-Logice (UAL) din interiorul procesoarelor.

## Porți logice

Porțile logice reprezintă componentele de bază disponibile în realizarea circuitelor combinaționale. Ele oglindesc operațiile din algebra booleană, algebră care stă la baza teoriei circuitelor combinaționale. În sunt prezentate cele mai întâlnite porți logice împreună cu operația booleană pe care o implementează.

<table>
<tr>
<td>Denumire</td>
<td>Simbol</td>
<td>Operator</td>
<td colspan='3'> Tabel de adevăr </td>
</tr>
<tr>

</tr>
</table>


| Denumire | Simbol | Operator | <td colspan='3'> Tabel de adevăr </td> |
|:-:|:-:|:-:|:-:|:-:|:-:|
|Inversor (NOT)|![](../media/gate-not.png)|f = !a | <td colspan='2'>a | f |
||| <td colspan='2'> 0 | 1 |
||| <td colspan='2'> 1 | 0 |

| Poarta SAU \\ (OR) | ![](../media/gate-not.png) | f = a %%||%% b | a | b | f |
| | | | 0 | 0 | 0 |
| | | | 0 | 1 | 1 |
| | | | 1 | 0 | 1 |
| | | | 1 | 1 | 1 |
| Poarta ŞI \\ (AND) | ![](../media/gate-not.png) | f = a && b | a | b | f |
| | | | 0 | 0 | 0 |
| | | | 0 | 1 | 0 |
| | | | 1 | 0 | 0 |
| | | | 1 | 1 | 1 |
| Poarta \\ SAU-NU \\ (NOR) | ![](../media/gate-not.png) | f = !(a %%||%% b) | a | b | f |
| | | | 0 | 0 | 1 |
| | | | 0 | 1 | 0 |
| | | | 1 | 0 | 0 |
| | | | 1 | 1 | 0 |
| Poarta \\ ŞI-NU \\ (NAND) | ![](../media/gate-not.png) | f = !(a && b) | a | b | f |
| | | | 0 | 0 | 1 |
| | | | 0 | 1 | 1 |
| | | | 1 | 0 | 1 |
| | | | 1 | 1 | 0 |
| Poarta \\ SAU EXCLUSIV \\ (XOR) | ![](../media/gate-not.png) | f = a %%^%% b | a | b | f |
| | | | 0 | 0 | 0 |
| | | | 0 | 1 | 1 |
| | | | 1 | 0 | 1 |
| | | | 1 | 1 | 0 |
| Poarta \\ SAU EXCLUSIV NU \\ (XNOR) | ![](../media/gate-not.png) | f = !(a %%^%% b) | a | b | f |
| | | | 0 | 0 | 1 |
| | | | 0 | 1 | 0 |
| | | | 1 | 0 | 0 |
| | | | 1 | 1 | 1 |
Porțile logice de bază


3 changes: 3 additions & 0 deletions chapters/lab0/combinational/slides/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/slides.md
/_site/
/media/
35 changes: 35 additions & 0 deletions chapters/lab0/combinational/slides/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
RVMD = reveal-md
MDPP = markdown-pp
FFMPEG = ffmpeg

SLIDES ?= slides.mdpp
SLIDES_OUT ?= slides.md
MEDIA_DIR ?= ../media
SITE ?= _site
OPEN ?= xdg-open

.PHONY: all html clean videos

all: videos html

html: $(SITE)

$(SITE): $(SLIDES)
$(MDPP) $< -o $(SLIDES_OUT)
$(RVMD) $(SLIDES_OUT) --static $@

videos:
test -z $(TARGETS) || for TARGET in $(TARGETS); do \
$(FFMPEG) -framerate 0.5 -f image2 -y \
-i "$(MEDIA_DIR)/$$TARGET/$$TARGET-%d.svg" -vf format=yuv420p $(MEDIA_DIR)/$$TARGET-generated.gif; \
done

open: $(SITE)
$(OPEN) $</index.html

clean:
-rm -f $(MEDIA_DIR)/*-generated.gif
-rm -fr media/
-rm -fr $(SITE)
-rm -f $(SLIDES_OUT)
-rm -f *~
43 changes: 43 additions & 0 deletions chapters/lab0/combinational/slides/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Slides hierarchy

---

## Slides Hierarchy

* Slides are organized in two levels
* We use `---` in order to open up a new topic.
This leads to a new horizontal slide figuring a topic that can be expanded by vertical slides.
* We expand discussions on the same topic by vertical slides.
We use `----`, which adds a new vertical slide

----

### New Vertical Slide

* This slide illustrates a new item of discussion on the matter of the slides hierarchy

---

### Animated Slides

* You can even animate slides like this

``` [1 - 2 | 3 - 4]
student@os:~/.../compute/lecture/demo/create-process$ strace -e clone ./fork_exec
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f7e83aa4810) = 5302
student@os:~/.../compute/lecture/demo/create-thread$ strace -e clone ./create_thread
clone(child_stack=0x7f9ea7df0fb0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, tls=0x7f9ea7df1700, child_tidptr=0x7f9ea7df19d0) = 5389
```

---

### Tables

You can include tables:

| Advantages | Disadvantages |
| :------------------------------: | :----------------------------------------: |
| implemented by libraries | implemented by the kernel |
| blocking actions stall process | blocking actions only stall current thread |
| more mapped on one kernel thread | provide support for user level threads |
| Java, Python | Linux KThreads, Windows threads |
Loading

0 comments on commit 8b87f08

Please sign in to comment.