OpenCores
URL https://opencores.org/ocsvn/cpu_lecture/cpu_lecture/trunk

Subversion Repositories cpu_lecture

[/] [cpu_lecture/] [trunk/] [html/] [01_Introduction_and_Overview.html] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jsauermann
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
3
<HTML>
4
<HEAD>
5
<TITLE>html/Introduction_and_Overview</TITLE>
6
<META NAME="generator" CONTENT="HTML::TextToHTML v2.46">
7
<LINK REL="stylesheet" TYPE="text/css" HREF="lecture.css">
8
</HEAD>
9
<BODY>
10
<P><table class="ttop"><th class="ttop"></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="02_Top_Level.html">Next Lesson</a></th></table>
11
<hr>
12
 
13
<H1><A NAME="section_1">1 INTRODUCTION AND OVERVIEW</A></H1>
14
 
15
<P>This lecture describes in detail how you can design a CPU (actually
16
an embedded system) in VHDL.
17
 
18
<P>The CPU has an instruction set similar to the instruction set of the
19
popular 8-bit CPUs made by <STRONG>Atmel</STRONG>. The instruction set is described in
20
<A HREF="http://www.atmel.com/dyn/resources/prod_documents/doc0856.pdf">http://www.atmel.com/dyn/resources/prod_documents/doc0856.pdf</A>. We use
21
an existing CPU so that we can reuse a software tool chain (<STRONG>avr-gcc</STRONG>)
22
for this kind of CPU and focus on the hardware aspects of the design.
23
At the end of the lecture, however, you will be able to design your own
24
CPU with a different instruction set.
25
 
26
<P>We will not implement the full instruction set; only the fraction needed
27
to explain the principles, and to run a simple "Hello world" program (and
28
probably most C programs) will be described.
29
 
30
<H2><A NAME="section_1_1">1.1 Prerequisites</A></H2>
31
 
32
<P>Initially you will need two programs:
33
 
34
<UL>
35
  <LI><STRONG>ghdl</STRONG> from <A HREF="http://ghdl.free.fr">http://ghdl.free.fr</A> (a free VHDL compiler and simulator) and
36
  <LI><STRONG>gtkwave</STRONG> from <A HREF="http://gtkwave.sourceforge.net">http://gtkwave.sourceforge.net</A> (a free visualization tool
37
for the output of ghdl).
38
</UL>
39
<P>These two programs allow you to design the CPU and simulate its functions.
40
 
41
<P>Later on, you will need a FPGA toolchain for creating FPGA design files
42
and to perform timing simulations. For this lecture we assume that the
43
free <STRONG>Xilinx Webpack</STRONG> tool chain is used (<A HREF="http://www.xilinx.com">http://www.xilinx.com</A>).
44
The latest version of the Xilinx Webpack provides ISE 11 (as of Nov. 2009)
45
but we used ISE 10.1 because we used an FPGA board providing a good old
46
Spartan 2E FPGA (actually an xc2s300e device) which is no longer supported
47
in ISE 11.
48
 
49
<P>Once the CPU design is finished, you need a C compiler that generates code
50
for the AVR CPU. For downloading <STRONG>avr-gcc</STRONG>, start here:
51
 
52
<P><A HREF="http://www.avrfreaks.net/wiki/index.php/Documentation:AVR_GCC#AVR-GCC_on_Unix_and_Linux">http://www.avrfreaks.net/wiki/index.php/Documentation:AVR_GCC#AVR-GCC_on_Unix_and_Linux</A>
53
 
54
<P>In order to try out the CPU, you will need some FPGA board
55
and a programming cable. We used a Memec "Spartan-IIE LC Development Kit"
56
board and an Avnet "Parallel Cable 3" for this purpose.
57
These days you will want to use a more recent development environment.
58
When the hardware runs, the final thing to get is a software toolchain,
59
for example <STRONG>avr-gcc</STRONG> for the instruction set and memory layout
60
used in this lecture. Optional, but rather helpful, is <STRONG>eclipse</STRONG>
61
(<A HREF="http://www.eclipse.org">http://www.eclipse.org</A>) with the AVR plugin.
62
 
63
<P>Another important prerequisite is that the reader is familiar with
64
VHDL to some extent. You do not need to be a VHDL expert in order
65
to follow this lecture, but you should not be a VHDL novice either.
66
 
67
<H2><A NAME="section_1_2">1.2 Other useful links.</A></H2>
68
 
69
<P>A good introduction into VHDL design with open source tools can
70
be found here:
71
 
72
<P><A HREF="http://www.armadeus.com/wiki/index.php?title=How_to_make_a_VHDL_design_in_Ubuntu/Debian">http://www.armadeus.com/wiki/index.php?title=How_to_make_a_VHDL_design_in_Ubuntu/Debian</A>
73
 
74
<H2><A NAME="section_1_3">1.3 Structure of this Lecture</A></H2>
75
 
76
<P>This lecture is organized as a sequence of lessons. The first lessons will
77
describe the VHDL files of the CPU design in a top-down fashion.
78
 
79
<P>Then follows a lesson on how to compile, simulate and build the design.
80
 
81
<P>Finally there is a listing of all design files with line numbers.
82
Pieces of these design files will be spread over
83
the different lessons and explained there in detail. In the end, all code
84
lines in the appendix should have been explained, with the exception of
85
comments, empty lines and the like. Repetitions such as the structure
86
of VHDL files or different opcodes that are implemented in the same way,
87
will only be described once.
88
 
89
<P>All source files are provided (without line numbers) in a tar file
90
that is stored next to this lecture.
91
 
92
<H2><A NAME="section_1_4">1.4 Naming Conventions</A></H2>
93
 
94
<P>In all lessons and in the VHDL source files, the following conventions
95
are used:
96
 
97
<P>VHDL entities and components and VHDL keywords are written in <STRONG>lowercase</STRONG>.
98
Signal names and variables are written in <STRONG>UPPERCASE</STRONG>.
99
Each signal has a prefix according to the following rules:
100
 
101
<TABLE>
102
<TR><TD>I_</TD><TD>for inputs of a VHDL entity.
103
</TD></TR><TR><TD>Q_</TD><TD>for outputs of a VHDL entity.
104
</TD></TR><TR><TD>L_</TD><TD>for local signals that are generated by a VHDL construct (e.g. by a signal assignment).
105
</TD></TR><TR><TD>x_</TD><TD>with an uppercase x for signals <STRONG>generated</STRONG> by an instantiated entity.
106
</TD></TR>
107
</TABLE>
108
<P>For every instantiated component we choose an uppercase letter x (other than
109
I, L, or Q). All signals driven by the component then get the prefix <STRONG>Q_</STRONG>
110
(if the instantiated component drives an output of the entity being defined)
111
or the prefix <STRONG>x_</STRONG> (if the component drives an internal signal).
112
 
113
<P>Apart from the prefix, we try to keep the name of a signal the
114
same across different VHDL files. Unless the prefix matters, we will
115
use the signal name <STRONG>without its prefix</STRONG> in our descriptions.
116
 
117
<P>Another convention is that we use one VHLD source file for every
118
entity that we define and that the name of the file (less the
119
.vhd extension) matches the entity name.
120
 
121
<H2><A NAME="section_1_5">1.5 Directory Structure</A></H2>
122
 
123
<P>Create a directory of your choice. In that directory, <STRONG>mkdir</STRONG> the following
124
sub-directories:
125
 
126
<TABLE>
127
<TR><TD>app</TD><TD>for building the program that will run on the CPU (i.e. <STRONG>hello.c</STRONG>)
128
</TD></TR><TR><TD>simu</TD><TD>for object files generated by <STRONG>ghdl</STRONG>
129
</TD></TR><TR><TD>src</TD><TD>for VHDL source files of the CPU and <STRONG>avr_fpga.ucf</STRONG>
130
</TD></TR><TR><TD>test</TD><TD>for a VHDL testbench
131
</TD></TR><TR><TD>tools</TD><TD>for tools <STRONG>end_conv</STRONG> and <STRONG>make_mem</STRONG>
132
</TD></TR><TR><TD>work</TD><TD>working directory for <STRONG>ghdl</STRONG>
133
</TD></TR>
134
</TABLE>
135
<P>Initially the directory should look like this:
136
 
137
<pre class="cmd">
138
 
139
# ls -R .
140
./app:
141
hello.c
142
 
143
./simu:
144
 
145
./src:
146
alu.vhd
147
avr_fpga.ucf
148
avr_fpga.vhd
149
baudgen.vhd
150
common.vhd
151
COPYING
152
cpu_core.vhd
153
data_mem.vhd
154
data_path.vhd
155
io.vhd
156
opc_deco.vhd
157
opc_fetch.vhd
158
prog_mem_content.vhd
159
prog_mem.vhd
160
reg_16.vhd
161
register_file.vhd
162
segment7.vhd
163
status_reg.vhd
164
uart_rx.vhd
165
uart_tx.vhd
166
uart.vhd
167
 
168
./test:
169
RAMB4_S4_S4.vhd
170
test_tb.vhd
171
 
172
./tools:
173
end_conv.cc
174
make_mem.cc
175
 
176
./work:
177
 
178
</pre>
179
<P>
180
 
181
<H2><A NAME="section_1_6">1.6 Other Useful Tools</A></H2>
182
 
183
<P>This lecture was prepared with 3 excellent tools:
184
 
185
<UL>
186
  <LI><STRONG>vim</STRONG> 7.1.38 for preparing the text of the lecture,
187
  <LI><STRONG>txt2html</STRONG> 2.46 for converting the text into html, and
188
  <LI><STRONG>dia</STRONG> 0.5 for drawing the figures.
189
</UL>
190
<P><hr><BR>
191
<table class="ttop"><th class="ttop"></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="02_Top_Level.html">Next Lesson</a></th></table>
192
</BODY>
193
</HTML>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.