Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jules Saget
M1 internship report
Commits
048f8a1d
Commit
048f8a1d
authored
Sep 08, 2020
by
Jules Saget
Browse files
Finish v1!
parent
0deee8fb
Changes
16
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
048f8a1d
...
...
@@ -43,6 +43,7 @@ tables:
clean
:
$(MAKE)
-C
figures clean
$(MAKE)
-C
tables clean
rm
-f
*
.bbl
rm
-f
*
.blg
rm
-f
*
.out
...
...
figures/.gitignore
View file @
048f8a1d
add_fsm_*
mul_fsm_*
figures/Makefile
View file @
048f8a1d
built_figs
=
comparator.pdf simple_graph_reductions.pdf ski_combinators.pdf 4ph.pdf add-sub.pdf mul.pdf clean.pdf tree.pdf add_fsm.pdf
built_figs
=
comparator.pdf simple_graph_reductions.pdf ski_combinators.pdf 4ph.pdf add-sub.pdf mul.pdf clean.pdf tree.pdf add_fsm.pdf
mul_fsm.pdf
other_figs
=
andor.png gr_ex_0.pdf gr_ex_1.pdf gr_ex_2.pdf gr_ex_3.pdf gr_ex_4.pdf
figs
:
$(built_figs) $(other_figs) add_fsm_figs
figs
:
$(built_figs) $(other_figs) add_fsm_figs
mul_fsm_figs
add_fsm_figs
:
./generate_add_fsm_highlights.sh
mul_fsm_figs
:
./generate_mul_fsm_highlights.sh
%.pdf
:
%.gv
dot
-o
$@
-Tpdf
$<
clean
:
rm
-f
$(built_figs)
./clean_add_fsm_highlights.sh
./clean_mul_fsm_highlights.sh
figures/add_fsm.gv
View file @
048f8a1d
...
...
@@ -11,9 +11,9 @@ digraph addsub_FSM {
AB_WRITE;
AB_READ_A;
AB_READ_B;
AB_ADD
SUB
;
AB_ADD;
AB_ALLOC -> AB_WRITE -> AB_READ_A -> AB_READ_B -> AB_ADD
SUB
-> AB_ALLOC;
AB_ALLOC -> AB_WRITE -> AB_READ_A -> AB_READ_B -> AB_ADD -> AB_ALLOC;
label = "A unfinished, B unfinished";
}
...
...
@@ -25,9 +25,10 @@ digraph addsub_FSM {
A_ALLOC;
A_WRITE;
A_READ;
A_ADDSUB;
A_ADD;
A_LINK;
A_CHECK -> A_ALLOC -> A_WRITE -> A_READ -> A_ADD
SUB
-> A_CHECK;
A_CHECK -> A_ALLOC -> A_WRITE -> A_READ -> A_ADD -> A_CHECK;
A_CHECK -> A_LINK;
label = "A unfinished, B finished";
}
...
...
@@ -55,18 +56,19 @@ digraph addsub_FSM {
B_ALLOC;
B_WRITE;
B_READ;
B_ADDSUB;
B_ADD;
B_LINK;
B_CHECK -> B_LINK;
B_CHECK -> B_ALLOC -> B_WRITE -> B_READ -> B_ADD
SUB
-> B_CHECK;
B_CHECK -> B_ALLOC -> B_WRITE -> B_READ -> B_ADD -> B_CHECK;
label = "A finished, B unfinished";
}
IDLE -> AB_READ_A;
AB_ADD
SUB
-> A_CHECK;
AB_ADD
SUB
-> B_CHECK;
AB_ADD
SUB
-> FINAL_CHECK;
AB_ADD -> A_CHECK;
AB_ADD -> B_CHECK;
AB_ADD -> FINAL_CHECK;
A_LINK -> DONE;
B_LINK -> DONE;
FINAL_LINK -> DONE;
...
...
figures/clean_add_fsm_highlights.sh
View file @
048f8a1d
add_fsm_states
=
"idle done ab_read_a ab_read_b ab_add ab_alloc ab_write a_check a_link a_alloc a_write a_read a_add
sub
b_check b_link b_alloc b_write b_read b_add
sub
final_check final_link final_alloc final_write final_last_write"
add_fsm_states
=
"idle done ab_read_a ab_read_b ab_add ab_alloc ab_write a_check a_link a_alloc a_write a_read a_add b_check b_link b_alloc b_write b_read b_add final_check final_link final_alloc final_write final_last_write"
for
state
in
$add_fsm_states
do
...
...
figures/clean_mul_fsm_highlights.sh
0 → 100755
View file @
048f8a1d
mul_fsm_states
=
"idle done read_a a_loop_check read_b mul b_loop_check ready_res read_res add ready_address alloc write add_loop_check"
for
state
in
$mul_fsm_states
do
rm
-f
mul_fsm_
$state
.pdf
rm
-f
mul_fsm_
$state
.gv
done
figures/generate_add_fsm_highlights.sh
View file @
048f8a1d
add_fsm_states
=
"idle done ab_read_a ab_read_b ab_add ab_alloc ab_write a_check a_link a_alloc a_write a_read a_add
sub
b_check b_link b_alloc b_write b_read b_add
sub
final_check final_link final_alloc final_write final_last_write"
add_fsm_states
=
"idle done ab_read_a ab_read_b ab_add ab_alloc ab_write a_check a_link a_alloc a_write a_read a_add b_check b_link b_alloc b_write b_read b_add final_check final_link final_alloc final_write final_last_write"
for
state
in
$add_fsm_states
do
...
...
figures/generate_fig.py
View file @
048f8a1d
...
...
@@ -3,7 +3,7 @@ import sys
argument_list
=
sys
.
argv
def
is_target_def
(
line
,
target
):
return
(
target
in
line
and
';'
in
line
and
"->"
not
in
line
)
return
((
(
target
+
" "
)
in
line
or
(
target
+
';'
in
line
))
and
';'
in
line
and
not
(
"->"
in
line
or
"rank"
in
line
)
)
def
add_color
(
def_line
):
# Always add red
if
']'
in
def_line
:
...
...
figures/generate_mul_fsm_highlights.sh
0 → 100755
View file @
048f8a1d
mul_fsm_states
=
"idle done read_a a_loop_check read_b mul b_loop_check ready_res read_res add ready_address alloc write add_loop_check"
for
state
in
$mul_fsm_states
do
echo
$state
python generate_fig.py mul_fsm
$state
make mul_fsm_
$state
.pdf
done
figures/mul.gv
View file @
048f8a1d
...
...
@@ -13,7 +13,7 @@ digraph mul_FSM {
color = azure1;
READ_A;
A_LOOP_CHECK [
color = invis,
fillcolor = lightgrey];
A_LOOP_CHECK [fillcolor = lightgrey];
{ rank = same; READ_A, A_LOOP_CHECK }
...
...
@@ -24,7 +24,7 @@ digraph mul_FSM {
READ_B;
MUL;
B_LOOP_CHECK [
color = invis,
fillcolor = lightgrey];
B_LOOP_CHECK [fillcolor = lightgrey];
{ rank = same; B_LOOP_CHECK, READ_B, MUL }
...
...
@@ -33,13 +33,13 @@ digraph mul_FSM {
color = azure3;
label = "Add loop";
READY_RES [
color=invis,
fillcolor = lightgrey];
READY_RES [fillcolor = lightgrey];
READ_RES;
ADD;
READY_ADDRESS [
color=invis,
fillcolor = lightgrey];
READY_ADDRESS [fillcolor = lightgrey];
ALLOC;
WRITE;
ADD_LOOP_CHECK [
color=invis,
fillcolor = lightgrey];
ADD_LOOP_CHECK [fillcolor = lightgrey];
{ rank = same; READY_RES, ADD, READY_ADDRESS, WRITE, ADD_LOOP_CHECK }
...
...
figures/mul_fsm.gv
0 → 120000
View file @
048f8a1d
mul.gv
\ No newline at end of file
slides.tex
View file @
048f8a1d
\documentclass
{
beamer
}
\documentclass
[table,xcdraw]
{
beamer
}
\usepackage
[utf8]
{
inputenc
}
\usepackage
[T1]
{
fontenc
}
\usepackage
[english]
{
babel
}
%\usepackage[hidelinks]{hyperref} % Already in beamer
\usepackage
{
graphicx
}
\usepackage
{
amsmath,amssymb
}
\usepackage
{
multirow
}
\usepackage
{
minted
}
\usepackage
{
graphicx
}
\usepackage
{
url
}
%\usepackage[hidelinks]{hyperref}
\newcommand
{
\urlfootnote
}
[1]
{
\footnote
{
\url
{
#1
}}}
\usepackage
{
array
}
\usepackage
{
tabularx
}
\usepackage
{
setspace
}
\usepackage
{
csquotes
}
\usetheme
{
CambridgeUS
}
\usecolortheme
{
wolverine
}
...
...
@@ -124,8 +139,44 @@
\section
[ALU]
{
Designing the ALU
}
\subsection
{
\emph
{
“Simple”
}
units
}
\begin{frame}
{
Logic Unit
}
NOT, AND, OR, COND (if then else)
\\
\phantom
{
CO
}
\begin{minipage}
{
0.8
\textwidth
}
\begin{itemize}
\item
<2-5>[NOT] straightforward
\item
<3-5>[AND]
\texttt
{
AND A B
}
is
\texttt
{
FALSE
}
if
\texttt
{
NOT A
}
else
\texttt
{
B
}
\item
<4-5>[OR]
\texttt
{
OR A B
}
is
\texttt
{
TRUE
}
if
\texttt
{
A
}
else
\texttt
{
B
}
\item
<5>[COND]
\texttt
{
COND A B C
}
is
\texttt
{
B
}
if
\texttt
{
A
}
else
\texttt
{
C
}
\end{itemize}
\end{minipage}
\end{frame}
\begin{frame}
{
Comparator Unit
}
Operations:
$
=
$
,
$
\neq
$
,
$
\geq
$
,
$
>
$
\begin{figure}
[h]
\centering
\includegraphics
[width=\textwidth]
{
figures/comparator.pdf
}
\label
{
fig:comparator
_
fsm
}
\end{figure}
\end{frame}
\subsection
{
Addition Unit
}
\begin{frame}
{
Addition FSM
}
\begin{figure}
[h]
\centering
\includegraphics
[width=0.65\textwidth]
{
figures/add
_
fsm
}
\label
{
fig:add
_
fsm
}
\end{figure}
\end{frame}
\begin{frame}
{
1 + 2
}
\begin{minipage}
{
0.34
\textwidth
}
\texttt
{
001 + 010
}
:
...
...
@@ -153,7 +204,7 @@
\end{minipage}
\end{frame}
\begin{frame}
{
1
+
3
}
\begin{frame}
{
1
+
3
}
\begin{minipage}
{
0.34
\textwidth
}
\texttt
{
001+011
}
:
\begin{itemize}
...
...
@@ -184,8 +235,168 @@
\end{minipage}
\end{frame}
\begin{frame}
{
Final example: -34 + 2
}
\begin{minipage}
{
0.34
\textwidth
}
\texttt
{
111·011·110 + 010
}
\begin{itemize}
\item
<2-12> Read
\texttt
{
A
}
and
\texttt
{
B
}
, and add them:
\texttt
{
000
}
\item
<5-12> Go into A mode: there is a carry!
\item
<6-12> Allocate then write:
\texttt
{
·000
}
\item
<8-12> Read
\texttt
{
A
}
, propagate carry:
\texttt
{
100
}
\item
<10-12> Second check: nothing left to do!
\item
<11-12> Write the result to memory,
\texttt
{
111·100
}
\item
<12> Done!
\end{itemize}
\end{minipage}
\begin{minipage}
{
0.65
\textwidth
}
\begin{figure}
[h]
\centering
\only
<1>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
idle.pdf
}}
\only
<2>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
ab
_
read
_
a.pdf
}}
\only
<3>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
ab
_
read
_
b.pdf
}}
\only
<4>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
ab
_
add.pdf
}}
\only
<5>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
a
_
check.pdf
}}
\only
<6>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
a
_
alloc.pdf
}}
\only
<7>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
a
_
write.pdf
}}
\only
<8>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
a
_
read.pdf
}}
\only
<9>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
a
_
add.pdf
}}
\only
<10>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
a
_
check.pdf
}}
\only
<11>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
a
_
link.pdf
}}
\only
<12>
{
\includegraphics
[width=\textwidth]
{
figures/add
_
fsm
_
done.pdf
}}
\label
{
fig:add
_
ex
_
3
}
\end{figure}
\end{minipage}
\end{frame}
\subsubsection
{
Subtraction
}
\begin{frame}
{
A small word on subtraction
}
\centering
\Huge
\texttt
{
A - B = A + (-B)
}
\end{frame}
\subsection
{
Multiplication Unit
}
\begin{frame}
{
Multiplcation FSM
}
\begin{figure}
[h]
\centering
\includegraphics
[width=\textwidth]
{
figures/mul
_
fsm.pdf
}
\label
{
fig:mul
_
fsm
}
\end{figure}
\end{frame}
%\begin{frame}{Example : $23 * 31$}
% \begin{figure}[h]
% \centering
% \only<1>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_idle.pdf}}
% \only<2>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_a.pdf}}
% \only<3>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_b.pdf}}
% \only<4>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_mul.pdf}}
% \only<5>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<6>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<7>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<8>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_alloc.pdf}}
% \only<9>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<10>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<11>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<12>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<13>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<14>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_alloc.pdf}}
% \only<15>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<16>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<17>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_b_loop_check.pdf}}
% \only<18>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_b.pdf}}
% \only<19>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_mul.pdf}}
% \only<20>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<21>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_res.pdf}}
% \only<22>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<23>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<24>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<25>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<26>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<27>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<28>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<29>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_alloc.pdf}}
% \only<30>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<31>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<32>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_b_loop_check.pdf}}
% \only<33>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_a_loop_check.pdf}}
% \only<34>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_a.pdf}}
% \only<35>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_b.pdf}}
% \only<36>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_mul.pdf}}
% \only<37>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<38>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_res.pdf}}
% \only<39>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<40>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<41>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<42>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<43>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<44>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_res.pdf}}
% \only<45>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<46>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<47>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<48>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<49>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_b_loop_check.pdf}}
% \only<50>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_b.pdf}}
% \only<51>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_mul.pdf}}
% \only<52>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<53>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_read_res.pdf}}
% \only<54>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<55>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<56>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<57>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<58>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_res.pdf}}
% \only<59>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add.pdf}}
% \only<60>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_ready_address.pdf}}
% \only<61>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_write.pdf}}
% \only<62>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_add_loop_check.pdf}}
% \only<63>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_b_loop_check.pdf}}
% \only<64>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_a_loop_check.pdf}}
% \only<65>{\includegraphics[width=0.8\textwidth]{figures/mul_fsm_done.pdf}}
% \label{fig:mul_ex}
% \end{figure}
% \def\oldtabcolsep{\tabcolsep}
% \setlength{\tabcolsep}{4pt}
% \tiny
% \only<1>{\input{tables/mul_2by2_0.tex}}
% \only<2>{\input{tables/mul_2by2_0.tex}}
% \only<3>{\input{tables/mul_2by2_0.tex}}
% \only<4-5>{\input{tables/mul_2by2_1.tex}}
% \only<6-7>{\input{tables/mul_2by2_2.tex}}
% \only<8>{\input{tables/mul_2by2_3.tex}}
% \only<9-11>{\input{tables/mul_2by2_4.tex}}
% \only<12-13>{\input{tables/mul_2by2_5.tex}}
% \only<14>{\input{tables/mul_2by2_6.tex}}
% \only<15-17>{\input{tables/mul_2by2_7.tex}}
% \only<18>{\input{tables/mul_2by2_8.tex}}
% \only<19-20>{\input{tables/mul_2by2_9.tex}}
% \only<21>{\input{tables/mul_2by2_10.tex}}
% \only<22-23>{\input{tables/mul_2by2_11.tex}}
% \only<24-26>{\input{tables/mul_2by2_12.tex}}
% \only<27-28>{\input{tables/mul_2by2_13.tex}}
% \only<29>{\input{tables/mul_2by2_14.tex}}
% \only<30-33>{\input{tables/mul_2by2_15.tex}}
% \only<34>{\input{tables/mul_2by2_16.tex}}
% \only<35>{\input{tables/mul_2by2_17.tex}}
% \only<36-37>{\input{tables/mul_2by2_18.tex}}
% \only<38>{\input{tables/mul_2by2_19.tex}}
% \only<39-40>{\input{tables/mul_2by2_20.tex}}
% \only<41-43>{\input{tables/mul_2by2_21.tex}}
% \only<44>{\input{tables/mul_2by2_22.tex}}
% \only<45-46>{\input{tables/mul_2by2_23.tex}}
% \only<47-49>{\input{tables/mul_2by2_24.tex}}
% \only<50>{\input{tables/mul_2by2_25.tex}}
% \only<51-52>{\input{tables/mul_2by2_26.tex}}
% \only<53>{\input{tables/mul_2by2_27.tex}}
% \only<54-55>{\input{tables/mul_2by2_28.tex}}
% \only<56-58>{\input{tables/mul_2by2_29.tex}}
% \only<59-60>{\input{tables/mul_2by2_30.tex}}
% \only<61-64>{\input{tables/mul_2by2_31.tex}}
% \only<65>{\input{tables/mul_2by2_32.tex}}
% \setlength{\tabcolsep}{\oldtabcolsep}
%\end{frame}
\section*
{}
\begin{frame}
...
...
tables/.gitignore
0 → 100644
View file @
048f8a1d
mul_2by2_*
tables/Makefile
View file @
048f8a1d
tables
:
arith_2cpl.tex arith_ex_clean.tex arith_ex_gonewrong.tex arith_ex_simple.tex mul_2by2.tex
tables
:
mul_exs arith_2cpl.tex arith_ex_clean.tex arith_ex_gonewrong.tex arith_ex_simple.tex
mul_exs
:
mul_2by2.tex
#python diapize.py
clean
:
rm
-f
mul_2by2_
*
.tex
tables/diapize.py
0 → 100644
View file @
048f8a1d
import
sys
number_of_lines
=
5
start_tokens
=
[
"
\\
begin"
,
"
\\
centering"
,
"multi"
,
"size"
]
start_lines
=
[]
end_tokens
=
[
"
\\
end"
,
"
\\
caption"
,
"
\\
label"
]
end_lines
=
[]
base_file_name
=
"mul_2by2"
extension
=
".tex"
filenum
=
0
out_files
=
[]
base_file
=
open
(
base_file_name
+
extension
,
"rt"
)
def
has_a_member
(
test_list
,
source
):
if
test_list
==
[]:
return
False
else
:
elt
=
test_list
[
-
1
]
if
elt
in
source
:
return
True
else
:
return
(
has_a_member
(
test_list
[:
-
1
],
source
))
n
=
0
for
line
in
base_file
:
if
has_a_member
(
start_tokens
,
line
):
start_lines
.
append
(
line
)
elif
has_a_member
(
end_tokens
,
line
):
end_lines
.
append
(
line
)
else
:
new_out_file
=
open
(
base_file_name
+
'_'
+
str
(
filenum
)
+
extension
,
"wt"
)
filenum
+=
1
for
sl
in
start_lines
:
new_out_file
.
write
(
sl
)
out_files
.
append
(
new_out_file
)
if
n
<
number_of_lines
:
n
+=
1
for
out_file
in
out_files
[
-
n
:]:
out_file
.
write
(
line
)
base_file
.
close
()
for
out_file
in
out_files
:
for
el
in
end_lines
:
out_file
.
write
(
el
)
out_file
.
close
()
tables/mul_2by2.tex
View file @
048f8a1d
% Please add the following required packages to your document preamble:
% \usepackage{multirow}
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}
[ht]
\footnotesize
\centering
\begin{tabular}
{
l|rr|rr|rr|rrcrc|rrrr
}
&
\multicolumn
{
2
}{
c|
}{}
&
\multicolumn
{
2
}{
c|
}{}
&
\multicolumn
{
2
}{
c|
}{}
&
\multicolumn
{
5
}{
c|
}{
ADD
}
&
\multicolumn
{
4
}{
c
}{}
\\
&
\multicolumn
{
2
}{
c|
}{}
&
\multicolumn
{
2
}{
c|
}{}
&
\multicolumn
{
2
}{
c|
}{}
&
\multicolumn
{
3
}{
c
}{
inputs
}
&
\multicolumn
{
2
}{
c|
}{
outputs
}
&
\multicolumn
{
4
}{
c
}{}
\\
\multicolumn
{
1
}{
c|
}{
\multirow
{
-3
}{
*
}{
State
}}
&
\multicolumn
{
2
}{
c|
}{
\multirow
{
-3
}{
*
}{
A
}}
&
\multicolumn
{
2
}{
c|
}{
\multirow
{
-3
}{
*
}{
B
}}
&
\multicolumn
{
2
}{
c|
}{
\multirow
{
-3
}{
*
}{
MUL
}}
&
in1
&
in2
&
c
&
res
&
c
&
\multicolumn
{
4
}{
c
}{
\multirow
{
-3
}{
*
}{
Result
}}
\\
\hline
IDLE
&
010
&
·111
&
011
&
111
&
&
&
&
&
&
&
&
\textit
{}
&
&
&
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
A
&
010
&
\textbf
{
·111
}
&
011
&
111
&
&
&
&
&
&
&
&
\textit
{}
&
&
&
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
A
&
010
&
\textbf
{
·111
}
&
011
&
111
&
&
&
&
&
&
&
&
\textit
{}
&
&
&
\\
READ
\_
B
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
\textit
{}
&
&
&
\\
\rowcolor
[HTML]
{
EFEFEF
}
MUL
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
110
&
001
&
&
&
&
&
&
\textit
{}
&
&
&
\\
\rowcolor
[HTML]
{
EFEFEF
}
MUL
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
110
&
001
&
&
&
&
&
&
\textit
{}
&
&
&
\\
ADD
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
001
&
000
&
0
&
001
&
0
&
&
&
&
\\
\rowcolor
[HTML]
{
EFEFEF
}
ALLOC
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
&
&
\\
\rowcolor
[HTML]
{
EFEFEF
}
ALLOC
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
&
&
\\
WRITE
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
&
&
\textit
{
·001
}
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
110
&
000
&
0
&
110
&
0
&
&
&
&
\textit
{
·001
}
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
110
&
000
&
0
&
110
&
0
&
&
&
&
\textit
{
·001
}
\\
ALLOC
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
&
&
\textit
{
·001
}
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
&
\textit
{
·110
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
010
&
\textbf
{
·111
}
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
&
\textit
{
·110
}
&
·001
\\
READ
\_
B
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
&
\textit
{
·110
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
MUL
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
010
&
101
&
&
&
&
&
&
&
&
\textit
{
·110
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
MUL
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
010
&
101
&
&
&
&
&
&
&
&
\textit
{
·110
}
&
·001
\\
READ
\_
RES
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textbf
{}
&
&
\textit
{
\textbf
{
·110
}}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
101
&
110
&
0
&
011
&
1
&
\textbf
{}
&
&
\textit
{
\textbf
{
·110
}}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
101
&
110
&
0
&
011
&
1
&
\textbf
{}
&
&
\textit
{
\textbf
{
·110
}}
&
·001
\\
WRITE
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
&
\textit
{
·011
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
010
&
000
&
1
&
011
&
0
&
&
&
\textit
{
·011
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
010
&
000
&
1
&
011
&
0
&
&
&
\textit
{
·011
}
&
·001
\\
ALLOC
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
&
\textit
{
·011
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
\textit
{
·011
}
&
·011
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
010
&
\textbf
{
·111
}
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
\textit
{
·011
}
&
·011
&
·001
\\
READ
\_
A
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
\textit
{
·011
}
&
·011
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
B
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
\textit
{
·011
}
&
·011
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
B
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
\textit
{
·011
}
&
·011
&
·001
\\
MUL
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
001
&
110
&
&
&
&
&
&
&
\textit
{
·011
}
&
·011
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
RES
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
\textbf
{}
&
\textit
{
·011
}
&
\textbf
{
·011
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
RES
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
\textbf
{}
&
\textit
{
·011
}
&
\textbf
{
·011
}
&
·001
\\
ADD
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
110
&
011
&
0
&
001
&
1
&
\textbf
{}
&
\textit
{
·011
}
&
\textbf
{
·011
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
·011
&
\textit
{
·001
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
·011
&
\textit
{
·001
}
&
·001
\\
READ
\_
RES
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
\textbf
{}
&
\textbf
{
·011
}
&
\textit
{
·001
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
001
&
011
&
1
&
101
&
0
&
\textbf
{}
&
\textbf
{
·011
}
&
\textit
{
·001
}
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
ADD
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
001
&
011
&
1
&
101
&
0
&
\textbf
{}
&
\textbf
{
·011
}
&
\textit
{
·001
}
&
·001
\\
WRITE
&
\textbf
{
010
}
&
·111
&
011
&
\textbf
{
111
}
&
&
&
&
&
&
&
&
&
\textit
{
·101
}
&
·001
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
B
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
\textit
{
·101
}
&
·001
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
B
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
&
\textit
{
·101
}
&
·001
&
·001
\\
MUL
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
000
&
110
&
&
&
&
&
&
&
\textit
{
·101
}
&
·001
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
RES
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textbf
{}
&
\textit
{
\textbf
{
·101
}}
&
·001
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
READ
\_
RES
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textbf
{}
&
\textit
{
\textbf
{
·101
}}
&
·001
&
·001
\\
ADD
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
110
&
101
&
0
&
011
&
1
&
&
\textit
{
\textbf
{
·101
}}
&
·001
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textbf
{}
&
\textit
{
·011
}
&
·001
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textbf
{}
&
\textit
{
·011
}
&
·001
&
·001
\\
ADD
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
000
&
000
&
1
&
001
&
0
&
&
\textit
{
·011
}
&
·001
&
·001
\\
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textit
{
001
}
&
\cellcolor
[HTML]
{
EFEFEF
}
·011
&
·001
&
·001
\\
DONE
&
\textbf
{
0
1
0
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textit
{
00
1
}
&
·011
&
·001
&
·001
\rowcolor
[HTML]
{
EFEFEF
}
WRITE
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textit
{
001
}
&
·011
&
·001
&
·001
\\
DONE
&
\textbf
{
010
}
&
·111
&
\textbf
{
011
}
&
111
&
&
&
&
&
&
&
&
\textit
{
001
}
&
·011
&
·001
&
·001
\\
\phantom
{
READ
\_
RES
}
&
\phantom
{
0
0
0
}
&
\phantom
{
·000
}
&
\phantom
{
000
}
&
\phantom
{
·000
}
&
\phantom
{
000
}
&
\phantom
{
000
}
&
\phantom
{
000
}
&
\phantom
{
000
}
&
\phantom
{
0
}
&
\phantom
{
000
}
&
\phantom
{
0
}
&
\phantom
{
0
00
}
&
\phantom
{
·000
}
&
\phantom
{
·000
}
&
\phantom
{
·000
}
%\end
\end{tabular}
\caption
{
Example of multiplication
}
\label
{
tab:mul
_
2by2
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment