Last active
May 2, 2024 00:17
-
-
Save Holzhaus/a55f32dab374fa674ac09ced217ca38e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[border=5pt]{standalone} | |
\usepackage{tikz} | |
\usetikzlibrary{arrows, calc, chains, positioning} | |
\begin{document} | |
\begin{tikzpicture}[node distance = 4mm and 0mm, | |
box/.style = {shape=rectangle, draw, minimum size=2em, outer sep=0pt, on chain=#1}, | |
sum/.style = {shape=circle, draw, inner sep=0pt, node contents={$+$}}, | |
every path/.append style = {-latex'} | |
] | |
\def\scopeyshift{19mm} | |
\begin{scope}[start chain=ch1 going left] | |
\foreach \i in {0,...,2}{ | |
\node [box=ch1] (ch1-\i) {$s_{\i}$}; | |
} | |
\node (c1) [sum,below=of ch1-1]; | |
\node at ($(ch1-0) + (2.5,0)$) (output) {$y = s_0 $ (output bit)}; | |
\draw (ch1-0) -- (output); | |
\draw (c1) -| ([xshift=-5mm] ch1-2.west) node [near end, left=1pt] {$x = s_0 + s_1 \pmod 2$ (feedback bit)} -- (ch1-2); | |
\draw (ch1-0) |- (c1.east); | |
\draw (ch1-1) -- (c1); | |
\end{scope} | |
\end{tikzpicture} | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[border=5pt]{standalone} | |
\usepackage{tikz} | |
\usetikzlibrary{arrows, calc, chains, positioning} | |
\begin{document} | |
\begin{tikzpicture}[node distance = 4mm and 0mm, | |
box/.style = {shape=rectangle, draw, minimum size=2em, outer sep=0pt, on chain=#1}, | |
sum/.style = {shape=circle, draw, inner sep=0pt, node contents={$+$}}, | |
every path/.append style = {-latex'} | |
] | |
\def\scopeyshift{19mm} | |
\begin{scope}[start chain=ch1 going left] | |
\foreach \i in {0,...,19}{ | |
\node [box=ch1] (ch1-\i) {$s_{\i}$}; | |
} | |
\node (c1) [sum,below=of ch1-2]; | |
\draw (ch1-2) -- (c1); | |
\draw (ch1-0) |- (c1.east); | |
\node (c2) [sum,below=of ch1-4]; | |
\draw (ch1-4) -- (c2); | |
\draw (c1) -- (c2); | |
\node (c3) [sum,below=of ch1-6]; | |
\draw (ch1-6) -- (c3); | |
\draw (c2) -- (c3); | |
\node (c4) [sum,below=of ch1-8]; | |
\draw (ch1-8) -- (c4); | |
\draw (c3) -- (c4); | |
\node (c5) [sum,below=of ch1-10]; | |
\draw (ch1-10) -- (c5); | |
\draw (c4) -- (c5); | |
\node (c6) [sum,below=of ch1-11]; | |
\draw (ch1-11) -- (c6); | |
\draw (c5) -- (c6); | |
\node (c7) [sum,below=of ch1-14]; | |
\draw (ch1-14) -- (c7); | |
\draw (c6) -- (c7); | |
\node (c8) [sum,below=of ch1-16]; | |
\draw (ch1-16) -- (c8); | |
\draw (c7) -- (c8); | |
\node (c9) [sum,below=of ch1-17]; | |
\draw (ch1-17) -- (c9); | |
\draw (c8) -- (c9); | |
\node at ($(ch1-0) + (2.5,0)$) (output) {$y = s_0 $ (output bit)}; | |
\draw (ch1-0) -- (output); | |
\draw (c9) -| ([xshift=-5mm] ch1-19.west) -- (ch1-19.west); | |
\node (label) [below = of c9, xshift=100pt, yshift=10pt] {$x = s_0 + s_2 + s_4 + s_6 + s_8 + s_{10} + s_{11} + s_{14} + s_{16} + s_{17} \pmod 2$ (feedback bit)}; | |
\end{scope} | |
\end{tikzpicture} | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plot | |
from matplotlib.collections import PatchCollection | |
from matplotlib.patches import Rectangle | |
import math | |
# Use 'Mixxx' color scheme | |
plot.rcParams['axes.prop_cycle'] = plot.cycler(color=['#dc5d1e']) | |
for param, value in plot.rcParams.items(): | |
if 'color' in param: | |
if value in ('black', 'white'): | |
plot.rcParams[param] = 'black' if value == 'white' else 'white' | |
plot.rcParams['figure.dpi'] = 80 | |
plot.rcParams['savefig.dpi'] = 80 | |
plot.rcParams['font.size'] = 20 | |
figure = plot.figure(figsize=(20, 9), tight_layout=True) | |
subplot = figure.subplots(1) | |
def make_signal(bits): | |
time_values = [] | |
amplitude_values = [] | |
step = 0.001 | |
# Get x values of the sine wave | |
time = np.arange(start=0, stop=1, step=step) | |
amplitude = np.sin([x * 2 * math.pi for x in time]) | |
annotations = [] | |
for i, bit in enumerate(bits): | |
# Amplitude of the sine wave is sine of a variable like time | |
amplitude_values.extend([x if bit else (x * 0.8) for x in amplitude]) | |
annotations.append((bit, (i + 0.20, 1.1))) | |
time_values = np.arange(start=0, stop=len(bits), step=step) | |
return time_values, amplitude_values, annotations | |
bits = [ | |
0, 0, 0, | |
0, 0, 1, | |
0, 1, 0, | |
0, 1, 1, | |
1, 0, 0, | |
1, 0, 1, | |
1, 1, 0, | |
1, 1, 1, | |
] | |
time, amplitude, annotations = make_signal(bits) | |
# Plot a sine wave using time and amplitude obtained for the sine wave | |
subplot.plot(time, amplitude) | |
for text, xy in annotations: | |
subplot.annotate(text, xy) | |
# Give x axis label for the sine wave plot | |
subplot.set_xlabel('Cycle') | |
subplot.set_xlim(left=0, right=len(bits)) | |
subplot.set_xticks(np.arange(0, len(bits), 1)) | |
# Give y axis label for the sine wave plot | |
subplot.set_ylabel('Amplitude') | |
subplot.set_yticks(np.arange(-1, 1.2, 0.2)) | |
subplot.set_ylim(bottom=-1.1, top=1.2) | |
subplot.grid(True, which='both', color='#404040', linestyle='dashed') | |
subplot.axhline(y=0, color='white') | |
subplot.axvline(x=3, color='white') | |
subplot.axvline(x=6, color='white') | |
subplot.axvline(x=9, color='white') | |
subplot.axvline(x=12, color='white') | |
subplot.axvline(x=15, color='white') | |
subplot.axvline(x=18, color='white') | |
subplot.axvline(x=21, color='white') | |
# Loop over data points; create box from errors at each point | |
#boxes = [Rectangle((x, -1.0), 3, 2) for x in (3, 8, 13)] | |
#pc = PatchCollection(boxes, facecolor="#ff0000", alpha=0.3, edgecolor="#ff0000") | |
#subplot.add_collection(pc) | |
plot.savefig('simple_bitstream.svg', transparent=True) | |
#plot.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment