jan

jan / TUHH - Computer Engineering - Sheet 04

Last active 17 minutes ago

Like 0

Mandatory Homework Sheet 04 for the Computer Engineering course at TUHH

Revision 05dac790d68e8a933edcde3cc7b622012f19fdf0

sheet04_665250_664237.typ Raw
1#import "@preview/finite:0.5.1": automaton
2#show link: it => underline(it)
3#show link: set text(fill: blue)
4#show heading: set text(font: "Noto Sans")
5#show raw: set text(font: "JetBrains Mono", ligatures: true)
6
7// helper function, full width sepearator with two newlines
8#let separator() = [
9 \
10 #line(stroke: 0.5pt + black, length: 100%)
11 \
12]
13
14#let framed(body) = box(stroke: 1pt, inset: 6pt, body)
15
16= Computer Engineering - Sheet 04
17\
18#underline("Group Members:") \
19Jan Meyer: `664237` \
20Luke Ethe: `665250` \
21\
22#underline("Information about this document:") \
23This document was created using #link("https://typst.app", "typst").
24The original typst file can be found
25#link("https://gist.jnmr.dev/jan/CompEngSheet04", "here") \;
26a copy of the documents source code has been appended to the end of the PDF.\
27No AI / LLM was used for the content of the answers.
28
29#separator()
30
31== Exercise 4-1: Types of Automata
32=== _a)_
33_Moore-Automata:_ Automata the output of which depends only on
34its current state. The outputs are placed inside the state.
35The Moore automata is also slower, as it reacts to inputs once clock cycle later
36and it's state and output are generated synchronously.
37
38_Mealy-Automata:_ Automata the output of which depends on both its state and
39present input. The outputs are placed on transitions, rather than inside the
40state - we get something like "$1 slash 0$" (if input $1$, output $0$ and
41transition). \
42Mealy automata react faster to inputs and generates its output asynchronously.
43
44$arrow.double$ While Moore automata are easier to build, Mealy automata tend to
45be faster and more efficient. A Moore automata is easier to design while a mealy
46automata trades of that simplicity for a faster output and fewer necessary states.
47
48*Examples:*
49Here we have an example on how to build a "Rising Edge Detector" (RED) as a
50Mealy-automaton or as a Moore-automaton. \
51The RED detects when an input shifts from zero to one and outputs $bold(1)$ only when
52that change actually occurs, otherwise $bold(0)$.
53
54#grid(
55 columns: (1fr, auto, 2fr, auto, 1fr),
56 align: bottom,
57 column-gutter: 1.5em,
58 [],
59 figure(
60 automaton(
61 (
62 s0: (s0: [$0 slash 0$], s1: [$1 slash 1$]),
63 s1: (s0: [$0 slash 0$], s1: [$1 slash 0$]),
64 ),
65 initial: "s0",
66 final: (),
67 ),
68 caption: [Mealy-automaton],
69 numbering: none,
70 ),
71 [],
72 figure(
73 automaton(
74 (
75 A: (A: $0$, B: $1$),
76 B: (A: $0$, C: $1$),
77 C: (A: $0$, C: $1$),
78 ),
79 initial: "A",
80 labels: (A: "A/0", B: "B/1", C: "C/0"),
81 final: (),
82 ),
83 caption: [Moore-automaton],
84 numbering: none,
85 ),
86 [],
87)
88
89#pagebreak()
90=== _b)_
91To convert a Moore-automaton to a Mealy automaton you first copy all the states
92and transitions. Then look at each transition and look at the target states
93output and write the transition in the form of "Input / Output" and remove the
94output from the target state. Finally you minimize as often there are duplicate
95states that can be merged.
96
97#figure(
98 automaton(
99 (
100 Q0: (Q0: 1, Q1: 0),
101 Q1: (Q0: 0, Q2: 1),
102 Q2: (Q1: 1, Q2: 0),
103 ),
104 initial: (),
105 final: (),
106 labels: (
107 Q0: $Q_0 slash a$,
108 Q1: $Q_1 slash b$,
109 Q2: $Q_2 slash b$,
110 ),
111 ),
112 supplement: "Step",
113 caption: [Copy all the states and transitions],
114)
115
116#figure(
117 automaton(
118 (
119 Q0: (Q0: $1 slash a$, Q1: $0 slash b$),
120 Q1: (Q0: $0 slash a$, Q2: $1 slash b$),
121 Q2: (Q1: $1 slash b$, Q2: $0 slash b$),
122 ),
123 initial: (),
124 final: (),
125 ),
126 supplement: "Step",
127 caption: [Move the output from states to transitions],
128)
129
130Here we are already done because we cannot minify as all the states are
131distinguishable.
132
133
134#pagebreak()
135== Exercise 4-2: Sequence Detection
136
137#pagebreak()
138= Document source code:
139#separator()
140#raw(read("sheet04_665250_664237.typ"), block: true, lang: "typ")
141
142