.
This commit is contained in:
parent
e664c5e777
commit
c72c930bc0
83
.gitignore
vendored
Normal file
83
.gitignore
vendored
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
## Core latex/pdflatex auxiliary files:
|
||||||
|
*.aux
|
||||||
|
*.lof
|
||||||
|
*.log
|
||||||
|
*.lot
|
||||||
|
*.fls
|
||||||
|
*.out
|
||||||
|
*.toc
|
||||||
|
|
||||||
|
## Intermediate documents:
|
||||||
|
*.dvi
|
||||||
|
# these rules might exclude image files for figures etc.
|
||||||
|
*.ps
|
||||||
|
*.eps
|
||||||
|
*.pdf
|
||||||
|
|
||||||
|
## Bibliography auxiliary files (bibtex/biblatex/biber):
|
||||||
|
*.bbl
|
||||||
|
*.bcf
|
||||||
|
*.blg
|
||||||
|
*-blx.aux
|
||||||
|
*-blx.bib
|
||||||
|
*.run.xml
|
||||||
|
|
||||||
|
## Build tool auxiliary files:
|
||||||
|
*.fdb_latexmk
|
||||||
|
*.synctex.gz
|
||||||
|
*.pdfsync
|
||||||
|
|
||||||
|
## Auxiliary and intermediate files from other packages:
|
||||||
|
|
||||||
|
# algorithms
|
||||||
|
*.alg
|
||||||
|
*.loa
|
||||||
|
|
||||||
|
# amsthm
|
||||||
|
*.thm
|
||||||
|
|
||||||
|
# beamer
|
||||||
|
*.nav
|
||||||
|
*.snm
|
||||||
|
*.vrb
|
||||||
|
|
||||||
|
# glossaries
|
||||||
|
*.acn
|
||||||
|
*.acr
|
||||||
|
*.glg
|
||||||
|
*.glo
|
||||||
|
*.gls
|
||||||
|
|
||||||
|
# hyperref
|
||||||
|
*.brf
|
||||||
|
|
||||||
|
# listings
|
||||||
|
*.lol
|
||||||
|
|
||||||
|
# makeidx
|
||||||
|
*.idx
|
||||||
|
*.ilg
|
||||||
|
*.ind
|
||||||
|
*.ist
|
||||||
|
|
||||||
|
# minitoc
|
||||||
|
*.maf
|
||||||
|
*.mtc
|
||||||
|
*.mtc0
|
||||||
|
|
||||||
|
# minted
|
||||||
|
*.pyg
|
||||||
|
|
||||||
|
# nomencl
|
||||||
|
*.nlo
|
||||||
|
|
||||||
|
# todonotes
|
||||||
|
*.tdo
|
||||||
|
|
||||||
|
# xindy
|
||||||
|
*.xdy
|
||||||
|
|
||||||
|
# verilog
|
||||||
|
*.vcd
|
||||||
|
|
||||||
|
/examples
|
12
Makefile
12
Makefile
@ -2,18 +2,15 @@ C99?=c99
|
|||||||
|
|
||||||
all: bericht check fsm_tb
|
all: bericht check fsm_tb
|
||||||
|
|
||||||
|
bericht:
|
||||||
|
cd bericht && make
|
||||||
|
|
||||||
check: sqrt
|
check: sqrt
|
||||||
./sqrt
|
./sqrt
|
||||||
|
|
||||||
sqrt: c/sqrt.c
|
sqrt: c/sqrt.c
|
||||||
$(C99) -lm -o sqrt c/sqrt.c
|
$(C99) -lm -o sqrt c/sqrt.c
|
||||||
|
|
||||||
bericht/graph.pdf: bericht/graph.dot
|
|
||||||
cd bericht; dot -Tpdf graph.dot > graph.pdf
|
|
||||||
|
|
||||||
bericht: bericht/graph.pdf
|
|
||||||
latexmk -pdf bericht/bericht.tex;
|
|
||||||
|
|
||||||
fsm: verilog/heron_fsm.vcd
|
fsm: verilog/heron_fsm.vcd
|
||||||
gtkwave verilog/heron_fsm.vcd
|
gtkwave verilog/heron_fsm.vcd
|
||||||
|
|
||||||
@ -28,3 +25,6 @@ ctrl_tb: verilog/heron_ctrl.vcd
|
|||||||
|
|
||||||
%.vvp: %_tb.v %.v
|
%.vvp: %_tb.v %.v
|
||||||
iverilog -o $@ -Iverilog verilog/heron_{fsm,ctrl}.v
|
iverilog -o $@ -Iverilog verilog/heron_{fsm,ctrl}.v
|
||||||
|
|
||||||
|
sync:
|
||||||
|
rsync -av --inplace --rsync-path=~/rsync-3.1.0/rsync -avHz -e ssh verilog/ eeets2:verilog
|
||||||
|
38
SQRT.v
38
SQRT.v
@ -1,38 +0,0 @@
|
|||||||
module SQRT(A, Y, clk, reset);
|
|
||||||
|
|
||||||
parameter width = 31;
|
|
||||||
`define width 31
|
|
||||||
|
|
||||||
input [width:0] A;
|
|
||||||
reg [width:0] x;
|
|
||||||
reg [width:0] old_x;
|
|
||||||
output [width:0] Y;
|
|
||||||
|
|
||||||
always @(A)
|
|
||||||
begin
|
|
||||||
case(state)
|
|
||||||
WAIT: Y = 0;
|
|
||||||
CALC1:
|
|
||||||
x = CALC1
|
|
||||||
state = OUTPUT
|
|
||||||
CALC2:
|
|
||||||
if (old_x <= x) begin
|
|
||||||
state = OUTPUT
|
|
||||||
end
|
|
||||||
OUTPUT: Y = Y_t;
|
|
||||||
default: Y = 0;
|
|
||||||
endcase
|
|
||||||
end
|
|
||||||
|
|
||||||
initial begin : parameter_check
|
|
||||||
if (width < 1) begin
|
|
||||||
$display("ERROR: %m :\n Invalid value (%d) for parameter width (lower bound: 1)", width);
|
|
||||||
$finish;
|
|
||||||
end
|
|
||||||
if (width > 32) begin
|
|
||||||
$display("ERROR: %m :\n Invalid value (%d) for parameter width (upper bound: 32)", width);
|
|
||||||
$finish;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
endmodule
|
|
11
bericht/Makefile
Normal file
11
bericht/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
all: bericht
|
||||||
|
|
||||||
|
%.pdf: %.tex
|
||||||
|
latexmk -pdf $<
|
||||||
|
|
||||||
|
%.pdf: %.dot
|
||||||
|
dot -Tpdf $< > $@
|
||||||
|
|
||||||
|
bericht.pdf: graph.pdf
|
||||||
|
|
||||||
|
bericht: bericht.pdf
|
@ -24,7 +24,7 @@
|
|||||||
listoftables, % includes list of tables
|
listoftables, % includes list of tables
|
||||||
listoflistings, % includes list of listings
|
listoflistings, % includes list of listings
|
||||||
abbrevations, % includes index of symbols and abbrevations
|
abbrevations, % includes index of symbols and abbrevations
|
||||||
bibIfa, % citation style (IfA standard), alternatives: bibNumeric, bibHarvard
|
bibNumeric, % citation style (IfA standard), alternatives: bibNumeric, bibHarvard
|
||||||
langDE % define the language (default: langDE)
|
langDE % define the language (default: langDE)
|
||||||
]{ifathesis}
|
]{ifathesis}
|
||||||
\ifaThesis{Belegarbeit}
|
\ifaThesis{Belegarbeit}
|
||||||
@ -36,6 +36,7 @@
|
|||||||
\ifaKeywords{Praktikum, Schaltungsentwurf, Verilog} % Keywords included in pdf-file. Could be found e.g. by Windows file search.
|
\ifaKeywords{Praktikum, Schaltungsentwurf, Verilog} % Keywords included in pdf-file. Could be found e.g. by Windows file search.
|
||||||
\ifaTitleDE{Schaltkreis- und Systementwurf}
|
\ifaTitleDE{Schaltkreis- und Systementwurf}
|
||||||
\ifaTitleEN{}
|
\ifaTitleEN{}
|
||||||
|
\bibliography{bibliography}
|
||||||
|
|
||||||
\ifaSupervisorA{Jens-Uwe Schlüßler}
|
\ifaSupervisorA{Jens-Uwe Schlüßler}
|
||||||
\ifaProfessor{Prof. Dr.-Ing. habil. René Schüffny}
|
\ifaProfessor{Prof. Dr.-Ing. habil. René Schüffny}
|
||||||
@ -46,99 +47,103 @@
|
|||||||
\ifaAbstractEN{example_files/00_abstract_en__invalid}
|
\ifaAbstractEN{example_files/00_abstract_en__invalid}
|
||||||
\usepackage{tabularx}
|
\usepackage{tabularx}
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\usepackage{color}
|
|
||||||
|
|
||||||
\definecolor{mygreen}{rgb}{0,0.6,0}
|
% Keine Kapitelnummerierung
|
||||||
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
|
\makeatletter
|
||||||
\definecolor{mymauve}{rgb}{0.58,0,0.82}
|
\renewcommand{\thesection}{
|
||||||
|
\ifnum\c@chapter<1 \@arabic\c@section
|
||||||
\lstset{ %
|
\else \thechapter.\@arabic\c@section
|
||||||
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
|
\fi
|
||||||
basicstyle=\footnotesize, % the size of the fonts that are used for the code
|
|
||||||
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
|
|
||||||
breaklines=true, % sets automatic line breaking
|
|
||||||
captionpos=b, % sets the caption-position to bottom
|
|
||||||
commentstyle=\color{mygreen}, % comment style
|
|
||||||
deletekeywords={...}, % if you want to delete keywords from the given language
|
|
||||||
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
|
|
||||||
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
|
|
||||||
frame=single, % adds a frame around the code
|
|
||||||
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
|
|
||||||
keywordstyle=\color{blue}, % keyword style
|
|
||||||
language=C, % the language of the code
|
|
||||||
morekeywords={*,...}, % if you want to add more keywords to the set
|
|
||||||
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
|
|
||||||
numbersep=5pt, % how far the line-numbers are from the code
|
|
||||||
numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
|
|
||||||
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
|
|
||||||
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
|
|
||||||
showstringspaces=false, % underline spaces within strings only
|
|
||||||
showtabs=false, % show tabs within strings adding particular underscores
|
|
||||||
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
|
|
||||||
stringstyle=\color{mymauve}, % string literal style
|
|
||||||
tabsize=2, % sets default tabsize to 2 spaces
|
|
||||||
title=\lstname % show the filename of files included with \lstinputlisting; also try caption instead of title
|
|
||||||
}
|
}
|
||||||
|
\makeatother
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
|
||||||
\chapter{Einleitung}
|
\section{Einleitung}
|
||||||
TODO Kapitel 5.1 -> Aufgabenstellung
|
Aufgabe des Praktikums \emph{Schaltkreis- und Systementwurf} ist es einen integrierten Schaltkreis (ASIC) für
|
||||||
|
einen numerischen Algorithmus zu entwickeln. Der Schaltkreis ist mit der
|
||||||
|
Enwicklungsumgebung \emph{Cadence} zu erstellen. Dabei ist den Arbeitsschritten der Aufgabenstellung
|
||||||
|
\cite{aufgabenstellung} zu folgen. Die Schaltung ist durch Simulation zu verifizieren.
|
||||||
|
Der folgende Bericht enthält die geforderte Dokumentation nach Kapitel 5.1
|
||||||
|
\cite{dokumentation} der Aufgabenstellung.
|
||||||
|
|
||||||
\chapter{Beschreibung des Algorithmus}
|
\section{Beschreibung des Algorithmus}
|
||||||
|
Der hier selbst gewählte Algorithmus ist Ziehen der Quadratwurzel mithilfe des
|
||||||
|
Heron’sche Näherungsverfahren (auch Babylonverfahren genannt). Es ist benannt
|
||||||
|
nach dem Altgriechen Heron von Alexandria, der es zum 1. Mal beschrieb. Es ist
|
||||||
|
vermutlich das älteste Nährungsverfahren für die Quadratwurzel. Wegen seines
|
||||||
|
einfachen Aufbaus, war es ein beliebter Algorithmus für die Implementierung in
|
||||||
|
Software bevor Hardwareimplementierung sich verbreitet haben.
|
||||||
|
|
||||||
|
Die Iterationsvorschrift des Verfahren lautet:
|
||||||
|
|
||||||
\begin{align}
|
\begin{align}
|
||||||
x_{n+1}=\frac{x_n + \frac{a}{x_n}}{2}
|
x_{n+1} & =\frac{x_n + \frac{a}{x_n}}{2} \\
|
||||||
|
lim_{n \rightarrow \infty} x_n & = \sqrt{a}
|
||||||
\end{align}
|
\end{align}
|
||||||
|
|
||||||
\section{Implementierung in C}
|
wobei $a$ der Ausgangswert ist, aus welchem die Wurzel berechnet werden soll und
|
||||||
\begin{lstlisting}
|
$x_n$ der sich von Iterations zu Iterations an die Quadratwurzel annähernde
|
||||||
typedef uint32_t u32;
|
Wert.
|
||||||
void heron_sqrt(u32 *mem) {
|
|
||||||
int i = mem[0];
|
|
||||||
while (i > 0) {
|
|
||||||
u32 s = mem[i];
|
|
||||||
if (s > 1) {
|
|
||||||
// x_0 = (s + 1) / 2
|
|
||||||
// without increment to avoid overflow for 0xffffffff
|
|
||||||
u32 x = s >> 1;
|
|
||||||
u32 old_x = x;
|
|
||||||
|
|
||||||
while(1) {
|
Herleiten lässt sich die Folge aus dem Newton-Verfahren zur Bestimmung der
|
||||||
// x_{n + 1} = (x_n + (s / x_n)) / 2
|
Nullstellen ($x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}$):
|
||||||
x = (x >> 1) + ((s/x) >> 1);
|
|
||||||
if (old_x <= x) {
|
\begin{align}
|
||||||
break;
|
x^2 &= a \\
|
||||||
}
|
f(x) &= x^2 - a \\
|
||||||
old_x = x;
|
f'(x) &= 2x \\
|
||||||
}
|
x_{n + 1} &= x_n - \frac{f(x_n)}{f'(x_n)} \\
|
||||||
mem[i] = x;
|
&= x_n - \frac{x_n^2 - a}{2x_n} \\
|
||||||
}
|
&= x_n - \frac{x_n - a/x_n}{2} \\
|
||||||
i--;
|
&= \frac{x_n + a/x_n}{2}
|
||||||
}
|
\end{align}
|
||||||
}
|
|
||||||
\end{lstlisting}
|
Wobei in diesem Praktikum die Quadratwurzel von mehreren hintereinander im
|
||||||
\subsection{Speicherbelegung}
|
Speicher abgelegten Zahlen berechnet wird.
|
||||||
|
|
||||||
|
\section{Implementierung in C}
|
||||||
|
Der Prototyp des Algorithmus erfolgte in der Programmiersprache C nach dem
|
||||||
|
C99-Standard.
|
||||||
|
|
||||||
|
\ifalisting{Implementierung in C}{lst:implementierung}{c}{code/sqrt.c}{true}
|
||||||
|
|
||||||
|
Wie auch in der zu realisierenden Schaltung erwartet die Funktion im
|
||||||
|
Speicherfeld die Operanden für die Quadratwurzel-Berechnung. Wobei das 1. Feld
|
||||||
|
die Anzahl der Operanden angibt (siehe Speicherbelegung \ref{tbl:speicherbelegung}).
|
||||||
|
|
||||||
|
\subsection{Speicherbelegung und Zahlenformat}
|
||||||
|
|
||||||
Es wird angenommen, das jeder Speicherplatz 32 Bit breit ist.
|
Es wird angenommen, das jeder Speicherplatz 32 Bit breit ist.
|
||||||
Jedes Datenfeld wird als vorzeichenlose Festkommazahl interpretiert.
|
Jedes Datenfeld wird als vorzeichenlose Festkommazahl interpretiert.
|
||||||
|
Die Anzahl der Nachkommastellen lässt sich sowohl in der Schaltung
|
||||||
|
(heron\_comma\_fix) als auch in
|
||||||
|
der C-Implementierung (siehe Zeile \ref{comma}) leicht anpassen, wobei
|
||||||
|
vorrausgesetzt wird, dass die Anzahl durch 2 teilbar sein muss. Für die
|
||||||
|
Verifikation wurden 8. Kommastellen festgesetzt.
|
||||||
|
|
||||||
|
\begin{table}
|
||||||
\begin{tabularx}{\textwidth}{X|X}
|
\begin{tabularx}{\textwidth}{X|X}
|
||||||
Speicherplatz & Beschreibung \\\hline
|
Speicherplatz & Beschreibung \\\hline
|
||||||
MEM[0] & Anzahl der Operanden (n) \\
|
MEM[0] & Anzahl der Operanden (N) \\
|
||||||
MEM[1] & 1. Operand \\
|
MEM[1] & 1. Operand \\
|
||||||
MEM[2] & 2. Operand \\
|
MEM[2] & 2. Operand \\
|
||||||
$\ldots$ & $\dots$ \\
|
$\ldots$ & $\dots$ \\
|
||||||
MEM[N] & N. Operand
|
MEM[N] & N. Operand
|
||||||
\end{tabularx}
|
\end{tabularx}
|
||||||
|
\caption{Speicherbelegung}
|
||||||
|
\label{tbl:speicherbelegung}
|
||||||
|
\end{table}
|
||||||
|
|
||||||
\subsection{Datenflussgraph}
|
\subsection{Datenflussgraph}
|
||||||
\begin{figure}[ht]
|
\begin{figure}[ht]
|
||||||
\centering
|
\centering
|
||||||
\includegraphics[width=0.3\textwidth]{graph.pdf}
|
\includegraphics[width=0.6\textwidth]{graph.pdf}
|
||||||
\label{fig1}
|
\label{fig1}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
\subsection{Datenpfad}
|
\subsection{Datenpfad}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
|
% vim:spelllang=de
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
%% This BibTeX bibliography file was created using BibDesk.
|
|
||||||
%% http://bibdesk.sourceforge.net/
|
|
||||||
|
|
||||||
|
|
||||||
%% Saved with string encoding Unicode (UTF-8)
|
%% Saved with string encoding Unicode (UTF-8)
|
||||||
|
|
||||||
#@misc{mda,
|
@inbook {aufgabenstellung,
|
||||||
# Date-Added = {2010-01-09 12:34:49 +0100},
|
Date-Added = {2013-01-11 13:00:00 +0100},
|
||||||
# Date-Modified = {2010-01-09 12:35:30 +0100},
|
crossref = {einführung},
|
||||||
# Title = {{Model Driven Architecture}},
|
pages = "8"
|
||||||
# Url = {http://omg.org/mda}}
|
}
|
||||||
|
|
||||||
|
@inbook {dokumentation,
|
||||||
|
Date-Added = {2013-01-11 13:00:00 +0100},
|
||||||
|
crossref = {einführung},
|
||||||
|
pages = "9"
|
||||||
|
}
|
||||||
|
|
||||||
|
@book{einführung,
|
||||||
|
Date-Added = {2013-01-11 13:00:00 +0100},
|
||||||
|
author = "Jens-Uwe Schlüßler",
|
||||||
|
title = "Einführung in die Anwendung des Entwurfssystems CADENCE für die
|
||||||
|
Lehrveranstaltung Schaltkreis- und Systementwurf",
|
||||||
|
year = "2013",
|
||||||
|
}
|
||||||
|
30
bericht/code/sqrt.c
Normal file
30
bericht/code/sqrt.c
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
typedef uint32_t u32;
|
||||||
|
|
||||||
|
// have to a multiply of 2
|
||||||
|
#define COMMA 8 @\label{comma}@
|
||||||
|
#define COMMA_FIX (COMMA >> 1)
|
||||||
|
|
||||||
|
void heron_sqrt(u32 *mem) {
|
||||||
|
int i = mem[0];
|
||||||
|
while (i > 0) {
|
||||||
|
u32 s = mem[i];
|
||||||
|
u32 x = s;
|
||||||
|
if (s > 1) {
|
||||||
|
// x_0 = (s + 1) / 2
|
||||||
|
// without increment to avoid overflow for 0xffffffff
|
||||||
|
x = x >> 1;
|
||||||
|
u32 old_x = x;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
// x_{n + 1} = (x_n + (s / x_n)) / 2
|
||||||
|
x = (x >> 1) + ((s/x) >> 1);
|
||||||
|
if (old_x <= x) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
old_x = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mem[i] = x << COMMA_FIX;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
@ -225,29 +225,29 @@
|
|||||||
%-------------------------------------------------------------------------
|
%-------------------------------------------------------------------------
|
||||||
% Usage: \listing{<Caption>}{<Label>}{<[Dialect]Language>}{<Pfad>}{<float?>}
|
% Usage: \listing{<Caption>}{<Label>}{<[Dialect]Language>}{<Pfad>}{<float?>}
|
||||||
|
|
||||||
\newcommand*{\ifalisting}[6]{
|
\newcommand*{\ifalisting}[5]{
|
||||||
\renewcommand{\lstlistingname}{\hspace{-0.6cm}Listing}
|
\renewcommand{\lstlistingname}{\hspace{-0.6cm}Listing}
|
||||||
\ifthenelse{\equal{#6}{true}}{
|
\ifthenelse{\equal{#5}{true}}{
|
||||||
\ifalistingFloat{#1}{#2}{#3}{#4}{#5}
|
\ifalistingFloat{#1}{#2}{#3}{#4}
|
||||||
}{
|
}{
|
||||||
\ifalistingNoFloat{#1}{#2}{#3}{#4}{#5}
|
\ifalistingNoFloat{#1}{#2}{#3}{#4}
|
||||||
}
|
}
|
||||||
\vspace{4.5mm}
|
\vspace{4.5mm}
|
||||||
}
|
}
|
||||||
|
|
||||||
\newcommand*{\ifalistingFloat}[5]{%
|
\newcommand*{\ifalistingFloat}[4]{%
|
||||||
\begin{minipage}{0.96\textwidth}
|
\begin{minipage}{0.96\textwidth}
|
||||||
\lstset{belowcaptionskip=2mm} % Abstand unterhalb der Beschriftung
|
\lstset{belowcaptionskip=2mm} % Abstand unterhalb der Beschriftung
|
||||||
\ifalistingRaw{#1}{#2}{#3}{#4}{#5}
|
\ifalistingRaw{#1}{#2}{#3}{#4}
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
}
|
}
|
||||||
|
|
||||||
% Thanks to Matthias Freund who provided the code to enables listings which are longer than one page.
|
% Thanks to Matthias Freund who provided the code to enables listings which are longer than one page.
|
||||||
%
|
%
|
||||||
\newcommand*{\ifalistingNoFloat}[5]{%
|
\newcommand*{\ifalistingNoFloat}[4]{%
|
||||||
\begin{addmargin}[4mm]{1.5mm} % verändert den Abstand ohne Verwendung einer Minipage
|
\begin{addmargin}[4mm]{1.5mm} % verändert den Abstand ohne Verwendung einer Minipage
|
||||||
\lstset{belowcaptionskip=2mm} % Abstand unterhalb der Beschriftung
|
\lstset{belowcaptionskip=2mm} % Abstand unterhalb der Beschriftung
|
||||||
\ifalistingRaw{#1}{#2}{#3}{#4}{#5}
|
\ifalistingRaw{#1}{#2}{#3}{#4}
|
||||||
\vspace{-1mm}
|
\vspace{-1mm}
|
||||||
\begin{flushright}
|
\begin{flushright}
|
||||||
\scriptsize
|
\scriptsize
|
||||||
@ -256,25 +256,48 @@
|
|||||||
\end{addmargin}
|
\end{addmargin}
|
||||||
}
|
}
|
||||||
|
|
||||||
\newcommand*{\ifalistingRaw}[5]{
|
\usepackage{color}
|
||||||
|
|
||||||
|
\definecolor{mygreen}{rgb}{0,0.6,0}
|
||||||
|
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
|
||||||
|
\definecolor{mymauve}{rgb}{0.58,0,0.82}
|
||||||
|
|
||||||
|
\newcommand*{\ifalistingRaw}[4]{
|
||||||
\lstinputlisting[
|
\lstinputlisting[
|
||||||
caption={#1},
|
caption={#1},
|
||||||
label={#2},
|
label={#2},
|
||||||
language={#3},
|
language={#3},
|
||||||
keywordstyle=\bfseries\color{blue},
|
|
||||||
identifierstyle=\bf,
|
|
||||||
stringstyle=\itshape\color{red},
|
|
||||||
basicstyle=\ttfamily\color{black}\footnotesize, % Schriftschnitt des Codes
|
|
||||||
showstringspaces=false, % Leerzeichen nicht markieren
|
showstringspaces=false, % Leerzeichen nicht markieren
|
||||||
commentstyle=\color{green}, % Schriftschnitt der Kommentare
|
|
||||||
tabsize=2, % Tabulatorengröße in Leerzeichen
|
tabsize=2, % Tabulatorengröße in Leerzeichen
|
||||||
breaklines=true, % zu lange Zeilen umbrechen
|
breaklines=true, % zu lange Zeilen umbrechen
|
||||||
frame=tb, % Rahmen um das Listing
|
frame=tb, % Rahmen um das Listing
|
||||||
abovecaptionskip=3mm, % Abstand oberhalb der Beschriftung
|
abovecaptionskip=3mm, % Abstand oberhalb der Beschriftung
|
||||||
captionpos=t, % Position der Beschriftung (b=bottom, t=top)
|
captionpos=t, % Position der Beschriftung (b=bottom, t=top)
|
||||||
numbers=#4,
|
numbers=left,
|
||||||
numbersep=5pt
|
numbersep=5pt,
|
||||||
]{#5}
|
commentstyle=\color{mygreen}, % comment style
|
||||||
|
deletekeywords={...}, % if you want to delete keywords from the given language
|
||||||
|
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
|
||||||
|
escapechar=@,
|
||||||
|
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
|
||||||
|
frame=single, % adds a frame around the code
|
||||||
|
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
|
||||||
|
keywordstyle=\color{blue}, % keyword style
|
||||||
|
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
|
||||||
|
basicstyle=\footnotesize, % the size of the fonts that are used for the code
|
||||||
|
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
|
||||||
|
breaklines=true, % sets automatic line breaking
|
||||||
|
captionpos=b, % sets the caption-position to bottom
|
||||||
|
morekeywords={*,...}, % if you want to add more keywords to the set
|
||||||
|
numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
|
||||||
|
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
|
||||||
|
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
|
||||||
|
showstringspaces=false, % underline spaces within strings only
|
||||||
|
showtabs=false, % show tabs within strings adding particular underscores
|
||||||
|
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
|
||||||
|
stringstyle=\color{mymauve}, % string literal style
|
||||||
|
tabsize=2, % sets default tabsize to 2 spaces
|
||||||
|
]{#4}
|
||||||
}
|
}
|
||||||
|
|
||||||
% Erlaubt das Einfügen eines automatischen Symbolverzeichnisses
|
% Erlaubt das Einfügen eines automatischen Symbolverzeichnisses
|
||||||
|
5
c/sqrt.c
5
c/sqrt.c
@ -2,12 +2,11 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
typedef uint32_t u32;
|
typedef uint32_t u32;
|
||||||
|
|
||||||
// have to a multiply of 2
|
// have to a multiply of 2
|
||||||
#define COMMA 10
|
#define COMMA 8
|
||||||
#define COMMA_FIX (COMMA >> 1)
|
#define COMMA_FIX (COMMA >> 1)
|
||||||
|
|
||||||
void heron_sqrt(u32 *mem) {
|
void heron_sqrt(u32 *mem) {
|
||||||
@ -37,7 +36,7 @@ void heron_sqrt(u32 *mem) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
float data[] = {
|
float data[] = {
|
||||||
/0,
|
0,
|
||||||
//0.5,
|
//0.5,
|
||||||
1.0 / (1 << COMMA),
|
1.0 / (1 << COMMA),
|
||||||
1.0 / (1 << (COMMA - 1)),
|
1.0 / (1 << (COMMA - 1)),
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module heron_ctrl(
|
module heron_ctrl(
|
||||||
// data path
|
// data path
|
||||||
a_to_adr,
|
a_to_eab,
|
||||||
a_to_i,
|
a_to_i,
|
||||||
a_to_old_x,
|
a_to_old_x,
|
||||||
a_to_s,
|
a_to_s,
|
||||||
@ -36,7 +36,7 @@ module heron_ctrl(
|
|||||||
parameter PLUS = 1'b0;
|
parameter PLUS = 1'b0;
|
||||||
|
|
||||||
// data path
|
// data path
|
||||||
output a_to_adr;
|
output a_to_eab;
|
||||||
output a_to_i;
|
output a_to_i;
|
||||||
output a_to_old_x;
|
output a_to_old_x;
|
||||||
output a_to_s;
|
output a_to_s;
|
||||||
@ -64,7 +64,7 @@ module heron_ctrl(
|
|||||||
output ram_wr_en;
|
output ram_wr_en;
|
||||||
|
|
||||||
// data path
|
// data path
|
||||||
reg a_to_adr;
|
reg a_to_eab;
|
||||||
reg a_to_i;
|
reg a_to_i;
|
||||||
reg a_to_old_x;
|
reg a_to_old_x;
|
||||||
reg a_to_s;
|
reg a_to_s;
|
||||||
@ -92,7 +92,7 @@ module heron_ctrl(
|
|||||||
reg ram_wr_en;
|
reg ram_wr_en;
|
||||||
|
|
||||||
always @(state) begin
|
always @(state) begin
|
||||||
a_to_adr = OFF;
|
a_to_eab = OFF;
|
||||||
a_to_i = OFF;
|
a_to_i = OFF;
|
||||||
a_to_old_x = OFF;
|
a_to_old_x = OFF;
|
||||||
a_to_s = OFF;
|
a_to_s = OFF;
|
||||||
@ -124,7 +124,7 @@ module heron_ctrl(
|
|||||||
end
|
end
|
||||||
`LD_N_1: begin
|
`LD_N_1: begin
|
||||||
k0_to_a = ON;
|
k0_to_a = ON;
|
||||||
a_to_adr = ON;
|
a_to_eab = ON;
|
||||||
edb_to_din = ON;
|
edb_to_din = ON;
|
||||||
ram_rd_en = ON;
|
ram_rd_en = ON;
|
||||||
end
|
end
|
||||||
@ -141,7 +141,7 @@ module heron_ctrl(
|
|||||||
`LD_S_1: begin
|
`LD_S_1: begin
|
||||||
i_to_a = ON;
|
i_to_a = ON;
|
||||||
edb_to_din = ON;
|
edb_to_din = ON;
|
||||||
a_to_adr = ON;
|
a_to_eab = ON;
|
||||||
ram_rd_en = ON;
|
ram_rd_en = ON;
|
||||||
end
|
end
|
||||||
`LD_S_2: begin
|
`LD_S_2: begin
|
||||||
|
@ -1,4 +1,39 @@
|
|||||||
|
|
||||||
module heron_top_tb ( );
|
module heron_top_tb ( );
|
||||||
|
task assert;
|
||||||
|
input condition;
|
||||||
|
input [(20*8 - 1):0] message;
|
||||||
|
begin
|
||||||
|
if (condition !== 1'b1)
|
||||||
|
begin
|
||||||
|
$display("Assertion Failed: %s", message);
|
||||||
|
$finish(2);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
|
||||||
|
parameter CYCLE = 50;
|
||||||
|
|
||||||
|
wire [31:0] edb;
|
||||||
|
wire [31:0] eab;
|
||||||
|
wire ready;
|
||||||
|
wire ram_wr_en;
|
||||||
|
wire ram_rd_en;
|
||||||
|
|
||||||
|
reg clk, reset;
|
||||||
|
reg load;
|
||||||
|
|
||||||
|
reg [31:0] ram [0:1023];
|
||||||
|
|
||||||
|
heron_top heron(
|
||||||
|
.eab(eab),
|
||||||
|
.edb(edb),
|
||||||
|
.clk(clk),
|
||||||
|
.reset(reset),
|
||||||
|
.ram_wr_en(ram_wr_en),
|
||||||
|
.ram_rd_en(ram_rd_en),
|
||||||
|
.ready(ready),
|
||||||
|
.load(load)
|
||||||
|
);
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user