Warriors:
Contents
1 Overview 3
2 System Design 3
2.1 General design and layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Audio Codec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2.1 Audio Control Peripheral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.2 Audio Sample Peripheral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Ethernet Codec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 Microblaze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 RTP Packet Structure and Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6 RTP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Process 11
5 Acknowledgements 12
A Code listing 13
A.1 C Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
A.1.1 ether.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
A.1.2 ether.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
A.1.3 main.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
A.2 clkgen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
A.2.1 data/clkgen v2 1 0.pao . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
A.2.2 data/clkgen v2 1 0.mpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
A.2.3 hdl/verilog/clkgen.v . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
A.3 Audio Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
A.3.1 data/opb audio cntlr v2 1 0.pao . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
A.3.2 data/opb audio cntlr v2 1 0.mpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
A.3.3 data/opb audio cntlr.vhd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
A.4 Audio Sampler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
A.4.1 data/opb audio sampler v2 1 0.pao . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
A.4.2 data/opb audio sampler v2 1 0.mpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
A.4.3 hdl/vhdl/opb audio sampler v2 1 0.vhd . . . . . . . . . . . . . . . . . . . . . . . . . . 37
A.5 opb ethernet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
A.5.1 data/opb ethernet v2 1 0.pao . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
A.5.2 data/opb ethernet v2 1 0.mpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
A.5.3 hdl/vhdl/memoryctrl.vhd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
A.5.4 hdl/vhdl/opb ethernet.vhd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
A.5.5 hdl/vhdl/pad io.vhd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
A.5.6 hdl/vhdl/opb ethernet.vhd.old . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
A.6 misc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
A.6.1 Makefile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
A.6.2 system.mhs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
A.6.3 system.mss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
A.6.4 data/system.ucf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
2
2 SYSTEM DESIGN LIST OF FIGURES
List of Figures
1 System Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Audio Controller Timing Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Audio Controller Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 Audio Sampler Timing Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
5 Audio Sampler Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
6 Ethernet Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
7 Ethernet Timing Diagram (for Read Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1 Overview
This document describes the design of our system, development process, and advice for future project groups
that want to develop similar systems. A full listing of our source code is included as Appendix A
The SOBA server is a streaming audio server based on the XESS XSB-300E FPGA board. We imple-
mented it using IP’s included in the Xilinx EDK 6.1 in addition to our own IP’s, and some C code. The
system encodes analog audio input into 16-bit samples and streams the digitized audio out the ethernet port
in RTP packets, ready to be played in real time by an RTP client.
The system is comprised of three primary subsystems: the audio codec, the microblaze, and the ethernet
controller. Each is described in further detail in the following sections.
2 System Design
2.1 General design and layout
Figure 1 shows a general block diagram for our system.
The system accepts line level audio via the AKM AK4565 audio codec where the signal is converted
from analog to 16-bit signed digital samples. The samples are fetched from the audio codec by our audio
sampler peripheral which generates an interrupt each time a complete sample arrives. The 32-bit Microblaze
soft processor then transmits the sample from the audio sampler to the ethernet peripheral via the on-
board peripheral bus (OPB). The ethernet peripheral places the samples in the ASIX AX88796L Ethernet
controller’s onboard RAM as the payload of a preloaded real-time transport protocol (RTP) packet. As each
packet’s payload is filled, it is transmitted onto the IP network as a UDP packet. An RTP client on the
machine at the destination IP address receives the packets and plays the streaming audio in real time.
In addition the components mentioned above, we also designed, implemented and tested an audio control
peripheral discussed below which is not included in our final design.
Address Space on the OPB Bus
Ethernet Controller: 0x00800000 – 0x00FFFFFF
Audio Sampler: 0x10000100 – 0x100001FF
UART: 0xFEFF0100 – 0xFEFF01FF
Interrupt Controller: 0xFFFF0000 – 0xFFFF00FF
3
2.2 Audio Codec 2 SYSTEM DESIGN
Clock Signal
FPGA
Clock
Generator
ASIX
Ethernet AX88796L
Peripheral Ethernet
Controller
Microblaze
Audio
Controller
Interrupt
Interrupt
Controller UART
Controller
Audio
Sampler
OPB
Controller
UART
AKM AK4565
Audio Codec
The timing diagram for the audio control signals is shown Figure 2. Our audio control peripheral,
shown in Figure 3, takes read/write requests from the Microblaze on the OPB bus and translates them into
read/write requests to specific registers in the audio codec. The audio control peripheral is allocated a byte’s
worth of address space on the OPB bus. The lowest address byte designates the addressed register on the
audio codec.
5
2.3 Ethernet Codec 2 SYSTEM DESIGN
OPB_CLK
OPB_DBus(25)
OPB_DBus(27)
OPB_DBus(29)
OPB_DBus(31)
OPB_ABus(29)
OPB_ABus(31)
AU_CDTO
OPB_DBus(24)
OPB_DBus(26)
OPB_DBus(28)
OPB_DBus(30)
OPB_ABus(28)
OPB_ABus(30)
OPB_RNW
'1'
'0'
'1'
Clock Divider 15 14 . . . (int_au_cdti_buff) ... 3 2 1 0
(Clock / 12)
int_au_cclk
shift_in reg
shift_out
cdto_buff
reg
cdti_buff
count_rst
Clock
Counter
cdti_load
int_au_cdti
int_au_cclk_count
MUX '0'
output enable
FSM
int_au_csn
OPB_CLK
AU_SDTO0 OPB_RST
au_sdto0_ OPB_cloc
IObuff k_counter
OPB_clk_count
0 1 2 3 4 5 6 7 8 9 ...
au_sdti_ shift_rcv
obuff (32 bit shift reg)
OPB_clk_count(9) lrck
OPB_clk_count(4) bclk
mclk
[0:31]
OPB_SELECT
OPB_clk_count(1)
OPB_RST
OPB_ABUS Compar
ator
C_BASEADDR
int_selected
latch_sample
send_
interrupt au_mcl au_bclk au_lrck
k_obuff
[0:31]
_obuff _obuff
enable
enable
OPB_RST
FSM
gate_aus_
dbus_output
[0:31]
AU_BCLK
Interrupt
AU_SDTI AUS_DATA AU_MCLK AU_LRCK
7
2.3 Ethernet Codec 2 SYSTEM DESIGN
PAD I/O while maintaining the logic for managing the OPB peripheral selection and setting address line
activity as well as data line direction based on OPB signals.
The timing diagram (Figure 7)and block diagram (Figure 6) for the Ethernet component are shown
below. Our timing follows the timing diagram except we add an extra cycle between taking the chip select
active and taking the IOWR active.
OPB_RST
SIn_xferAck
OPB_RNW
OPB_RNW
FSM
OPB_Select
CS
Comparator
[31:21]
OPB_ABUS
IORW
IORD
[9:0]
Ether_CS
BHE
AEN
As described in the design document, we implemented diagnostic functionality so we could verify our
ability to read and write registers on the Ethernet Chip and generally check the health of the chip. In
particular, there are certain registers that have default values that can be checked to verify accurate reading
of registers. See the diagnostics function in ether.c (Section A.1.2)
Our initialization process also closely followed our design document. The following steps were taken:
Writing to registers involved writing directly to the memory location of the register based on OPB
mapping. Writing data to the on-chip RAM required a remote DMA write which involved first setting the
target address and then the target byte count in appropriate registers. Once this was done, the data was
placed on the dataport a word at a time.
8
2 SYSTEM DESIGN 2.3 Ethernet Codec
OPB_CLK
OPB_Select
OPB_ABUS
OPB_RNW
PB_LB
PB_UB
PB_A
CS_N
OE
WE
9
2.4 Microblaze 2 SYSTEM DESIGN
2.4 Microblaze
Our Microblaze code is used to initialize chips, interrupts, and stuff the default data into packet headers.
Our code size was shrunk below the Microblaze 4K limit so we were able to keep all of our code on BRAM.
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
Table 1: Header Structure for packets. Includes actual bit/byte values in many cases.
To view packets that we sent over Ethernet, we used Ethereal, an excellent network packet sniffing tool
which can be found at http://www.ethereal.com/. To test reception of UDP packets, we used netcat
on Linux. To test reception of RTP packets, we used rtpdump which can be found at http://www.cs.
columbia.edu/IRT/software/rtptools/
10
4 LESSONS LEARNED AND ADVICE FOR FUTURE PROJECTS
3 Process
We started off by splitting up the work into two main components. Avi and Sean worked on the Ethernet
peripheral and BJ and Oliver worked on the audio peripheral. We experienced significant difficulties devel-
oping our Ethernet peripheral from scratch and ended up basing our vhdl off the JAYCam project’s Ethernet
peripheral. Once the Ethernet peripheral was sending packets and the audio peripheral was digitizing audio,
the two components were combined into a single system that utilized the Microblaze for control. Avi and
Sean did the initial integration and then the team as a whole worked in shifts to get the client receiving
audio and to verify proper packet construction.
11
5 ACKNOWLEDGEMENTS
Oliver The greatest thing I learned in embedded system was grand scheme of organization and implementation
of an embedded system. VHDL was new to me before this class and now I feel I have a good handle on
how a project needs to be coded, debugged, re-coded, debugged, again and again. I found it interesting
to think about how fsm design allows settings to happen concurrently in the same clock signal. VHDL
is a marriage between code and clock that exists on a level that I can only compare to gate level
layout in VLSI. My work this semester was mostly accomplished by understanding the operation audio
codec and proofreading VHDL code. I also tested pins of the board with the oscilloscope to debug and
test codec output. This was the best way to initially see if our codec was operating reasonably. My
understanding of UDP and TCP has also been born from this class, and I now understand the basic
handling of headers and checksums.
5 Acknowledgements
Many thanks to Marcio Buss, Stephen Edwards, Josh Weinberg and JAYCam, Raj, and Christian for their
advice.
12
A CODE LISTING
A Code listing
A.1 C Source
A.1.1 ether.h
/∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# CSEE 4 8 4 0 Embedded System Design
#
# SOBA S e r v e r
#
# Team W a r r i o r s : Avraham Sh in n a r as1619@columbia . edu
# Benjamin Dweck bjd2102@columbia . edu
# Oliver Irwin omi3@columbia . edu
# Sean White sw2061@columbia . edu
#
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/
#include ” x i o . h”
#include ” x b a s i c t y p e s . h”
#define d p r i n t p r i n t
#i f n d e f BYTE
#define BYTE unsigned char
#endif
#i f n d e f WORD
#define WORD unsigned short
#endif
// d e f i n e the s i z e of a packet
#define HEADER SIZE ( MAC HEADER SIZE+IP HEADER SIZE+UDP HEADER SIZE+RTP HEADER SIZE)
13
A.1 C Source A CODE LISTING
/ / NE2000 d e f i n i t i o n s
#define NIC BASE ( 0 x00A00400 ) / / Base I /O a d d r e s s o f t h e NIC c a r d
#define DATAPORT ( 0 x10 ∗ 2 )
#define NE RESET ( 0 x 1 f ∗ 2 )
/ / NIC page0 r e g i s t e r o f f s e t s
#define CMDR ( 0 x00 ∗ 2 ) / / command r e g i s t e r f o r r e a d & w r i t e
#define PSTART ( 0 x01 ∗ 2 ) / / page s t a r t r e g i s t e r f or w r i t e
#define PSTOP ( 0 x02 ∗ 2 ) / / page s t o p r e g i s t e r f o r w r i t e
#define BNRY ( 0 x03 ∗ 2 ) / / boundary r e g f or rd and wr
#define TPSR ( 0 x04 ∗ 2 ) / / tx s t a r t page s t a r t r e g f o r wr
#define TBCR0 ( 0 x05 ∗ 2 ) / / tx byte count 0 r e g f or wr
#define TBCR1 ( 0 x06 ∗ 2 ) / / tx byte count 1 r e g fo r wr
#define ISR ( 0 x07 ∗ 2 ) / / i n t e r r u p t s t a t u s r e g f or rd and wr
#define RSAR0 ( 0 x08 ∗ 2 ) / / low byte o f remote s t a r t addr
#define RSAR1 ( 0 x09 ∗ 2 ) / / h i byte o f remote s t a r t addr
#define RBCR0 ( 0 x0A ∗ 2 ) / / remote byte count r e g 0 fo r wr
#define RBCR1 ( 0 x0B ∗ 2 ) / / remote byte count r e g 1 fo r wr
#define RCR ( 0 x0C ∗ 2 ) / / rx c o n f i g u r a t i o n r e g f or wr
#define TCR ( 0 x0D ∗ 2 ) / / tx c o n f i g u r a t i o n r e g f or wr
#define DCR ( 0 x0E ∗ 2 ) / / data c o n f i g u r a t i o n r e g f o r wr
#define IMR ( 0 x0F ∗ 2 ) / / i n t e r r u p t mask r e g f or wr
/ / NIC page 1 r e g i s t e r o f f s e t s
#define PAR0 ( 0 x01 ∗ 2 ) / / p h y s i c a l addr r e g 0 f or rd and wr
#define CURR ( 0 x07 ∗ 2 ) / / c u r r e n t page r e g fo r rd and wr
#define MAR0 ( 0 x08 ∗ 2 ) / / m u l t i c a s t addr r e g 0 f or rd and WR
14
A CODE LISTING A.1 C Source
/ ∗ s y m b o l i c names f o r v a r i o u s r e g i s t e r b i t s ∗ /
#include ” e t h e r . h”
#include ” x p a r a m e t e r s . h”
#include ” x b a s i c t y p e s . h”
#include ” x i o . h”
#include ” x i n t c l . h”
/ ∗ s t a t i c data ∗ /
/ ∗ s t o r e d w i t h o ut t h e one ’ s complement ∗ /
/ ∗ n o t e : i p checksum can a c t u a l l y be c o n s t a n t ! ! ∗ /
/ ∗ a l l t h e pseudo h e a d e r s and most o f t h e h e a d e r s on t h e udp checksum
can be c a l c u l a t e d i n advance . we j u s t need t o ask e t h e r e a l what i t
15
A.1 C Source A CODE LISTING
struct {
WORD padding ;
WORD sequence number ;
unsigned long time stamp ;
} dynamic data ;
16
A CODE LISTING A.1 C Source
/ ∗ 1 8 ∗ / 0 x00 ,
/ ∗ 1 9 ∗ / 0 x00 ,
/∗ Flags ( 3 b i t s ) : f i x e d ∗/
/∗ Fragment O f f s e t ( 1 3 b i t s ) : f i x e d ∗ /
/ ∗ 2 0 ∗ / 0 x00 ,
/ ∗ 2 1 ∗ / 0 x00 ,
/∗ TTL ( 1 byte ) : f i x e d ∗ /
/ ∗ f o r now , t h i s s h o u l d d i e on c o n t a c t ∗/
/ ∗ 2 2 ∗ / 0 x04 ,
/∗ P r o t o c o l ( 1 byte ) : f i x e d ∗ /
/ ∗ UDP=17 ∗/
/ ∗ 2 3 ∗ / 0 x11 ,
/∗ Header Checksum ( 2 b y t e s ) : updated . s e e u p d a t e i p c h e c k s u m ∗ /
/ / Micro4
0x8A , 0 x63 ,
/∗ S o u r c e IP ( 4 b y t e s ) : f i x e d ∗ /
/ ∗ 2 6 ∗ / 0 x80 ,
/ ∗ 2 7 ∗ / 0 x3B ,
/ ∗ 2 8 ∗ / 0 x95 ,
/ ∗ 2 9 ∗ / 0 xA2 ,
/∗ D e s t i n a t i o n IP ( 4 b y t e s ) : f i x e d ∗ /
/ / Micro4
128,59,144,169,
// / ∗ 3 0 ∗ / 1 2 8 ,
// / ∗ 3 1 ∗ / 5 9 ,
// / ∗ 3 2 ∗ / 1 4 4 ,
// / ∗ 3 3 ∗ / 1 6 8 ,
/ ∗ UDP h e a d e r ( 6 Bytes ) ∗ /
/∗ S o u r c e Port ( 2 b y t e s ) : f i x e d ∗ /
/ ∗ 3 4 ∗ / 0 x0B ,
/ ∗ 3 5 ∗ / 0 xE2 ,
/∗ D e s t i n a t i o n Port ( 2 b y t e s ) : f i x e d ∗ /
/∗ in decimal : 3 0 4 2 ∗ /
/ ∗ 3 6 ∗ / 0 x0B ,
/ ∗ 3 7 ∗ / 0 xE2 ,
/∗ Length ( 2 b y t e s ) : f i x e d ∗ /
/ ∗ 3 8 ∗ / UDP LENGTH>>8,
/ ∗ 3 9 ∗ / UDP LENGTH & 0 x f f ,
/∗ Checksum ( 2 b y t e s ) : updated ∗ /
/∗ 40 ∗/ 0 ,
/∗ 41 ∗/ 0 ,
/ ∗ RTP h e a d e r ( 1 2 b y t e s ) ∗ /
/∗ Version ( 2 b i t s ) : f i x e d ∗/
/∗ 10 ∗/
/∗ Padding ( 1 b i t ) : f i x e d ∗ /
/∗ 0 ∗/
/∗ Extension ( 1 b i t ) : f i x e d ∗/
/∗ 0 ∗/
/∗ CSRC count ( 4 b i t s ) : f i x e d ∗ /
/∗ 0 ∗/
/ ∗ 4 2 ∗ / 0 x80 ,
/∗ Marker b i t ( 1 b i t ) : f i x e d ∗ /
/∗ 0 ∗/
17
A.1 C Source A CODE LISTING
/∗ Payload type ( 7 b i t s ) : f i x e d ∗ /
/ ∗ L16 = 1 0 ( 2 c h a n n e l ( ( s e e
h t t p : / /www. n e t w o r k s o r c e r y . com/ enp / p r o t o c o l / r t p . htm ) ∗ /
/ ∗ 4 3 ∗ / 0 x0a ,
/∗ Sequence number ( 1 6 b i t s ) : updated ∗ /
/ ∗ 4 4 ∗ / 0 x00 ,
/ ∗ 4 5 ∗ / 0 x00 ,
/∗ Time stamp ( 3 2 b i t s ) : updated ∗ /
/ ∗ 4 6 ∗ / 0 x00 ,
/ ∗ 4 7 ∗ / 0 x00 ,
/ ∗ 4 8 ∗ / 0 x00 ,
/ ∗ 4 9 ∗ / 0 x00 ,
/∗ SSRC ( 3 2 b i t s ) : f i x e d ∗ /
/ ∗ s h o u l d be a random v a l u e : I don ’ t t h i n k t h i s i s what i s meant : )
−− s i n c e we don ’ t change our s o u r c e t r a n s p o r t a d d r e s s and don ’ t
h a n d l e m u l t i p l e s y n c h r o n i z a t i o n s o u r c e w i t h i n t h e same RTP
c h a n n e l , t h i s s h o u l d not be a problem . ∗ /
/ ∗ 5 0 ∗ / 0 x42 ,
/ ∗ 5 1 ∗ / 0 x42 ,
/ ∗ 5 2 ∗ / 0 x42 ,
/ ∗ 5 3 ∗ / 0 x42
/∗ CSRC l i s t ( 0 b i t s ) : f i x e d ∗ /
/ ∗ we a r e e v i l and don ’ t g i v e p r o p e r a t t r i b u t i o n t o s o u r c e s . ∗ /
};
/ ∗ a s i m p l e w a i t f u n c t i o n t h a t burns c l o c k c y c l e s . ∗ /
void w a i t ( int mult ) {
v o l a t i l e int j = 0 , i =1000000;
f o r ( ; i > 0; −− i ) {
f o r ( ; mult > 0; −− mult ) {
/ / a smart c o m p i l e r with a g g r e s i v e i n l i n e r s h o u l d u n r o l l t h i s
++j ;
}
}
}
/∗
INITIALIZATION
∗/
int d i a g n o s t i c s ( ) {
/ / o u t n i c (CMDR, 0 x21 ) ; / / s t o p AX88796
wait ( 1 0 ) ;
o u t n i c (CMDR, 0 x61 ) ;
o u t n i c (PSTART, 0 x4E ) ;
18
A CODE LISTING A.1 C Source
o u t n i c (CMDR, 0 x21 ) ;
o u t n i c (PSTOP , 0 x3E ) ;
o u t n i c (CMDR, 0 x61 ) ;
i f ( i n n i c (PSTART) ! = 0 x4e )
return 1 ;
i f ( i n n i c ( 0 x16 ∗ 2 ) ! = 0 x15 )
return 3 ;
i f ( i n n i c ( 0 x12 ∗ 2 ) ! = 0 x0c )
return 4 ;
i f ( i n n i c ( 0 x13 ∗ 2 ) ! = 0 x12 )
return 5 ;
return 0 ;
}
19
A.1 C Source A CODE LISTING
o u t n i c ( ISR , 0 x f f ) ;
/ ∗ Write 2 0 h t o R e c e i v e C o n f i g u r a t i o n R e g i s t e r t o put NIC i n monitor mode ∗ /
o u t n i c (RCR, 0 x20 ) ;
/ ∗ Write 0 2 h t o Transmit C o n f i g u r a t i o n R e g i s t e r t o put NIC i n l o o p−back mode ∗ /
o u t n i c (TCR, 0 x02 ) ;
/ ∗ S e t RX S t a r t and Stop , Boundary , and TX s t a r t page . ∗ /
o u t n i c (PSTART , RXSTART) ;
o u t n i c (PSTOP , RXSTOP) ;
o u t n i c (BNRY, ( BYTE) (RXSTOP− 1 ) ) ;
o u t n i c (TPSR , TXSTART) ;
/ ∗ Reset i n t e r r u p t mask and f l a g s . ∗ /
o u t n i c ( ISR , 0 xFF ) ; // c l e a r i nt e rr u pt status register
o u t n i c (IMR , 0 x00 ) ; / / Mask c o m p l e t i o n i r q
/ ∗ Write 2 2 h t o Command R e g i s t e r t o s t a r t NIC ∗ /
o u t n i c (CMDR, 0 x22 ) ;
/ ∗ Write 0 0 h t o Transmit C o n f i g u r a t i o n R e g i s t e r t o s e t normal t r a n s m i t o p e r a t i o n ∗ /
o u t n i c (TCR, 0 x00 ) ;
d p r i n t ( ” E t h e r n e t c a r d i n t i a l i z a t i o n c o m p l e t e ! \ r \n” ) ;
}
/∗ i n i t p a c k e t s e t u p ( ) ; ∗ /
dynamic data . sequence number = 0 ;
dynamic data . time stamp = 0 ;
/ ∗ now l e t s i n i t i a l i z e t h e b u f f e r s . ∗ /
return send ( (WORD ∗ ) h e a d e r , PACKET START ADDRESS , 5 4 ) ; / / HEADER SIZE ) ;
}
/∗ a c t u a l l y transmits a ( f i l l e d in ) packet . ∗ /
s t a t i c BYTE t r a n s m i t (WORD s e n d l e n )
{
int j ;
o u t n i c (TPSR , TXSTART) ; / / s e t Transmit Page S t a r t R e g i s t e r
o u t n i c (TBCR0 , ( s e n d l e n&0 x f f ) ) ; / / s e t Transmit Byte Count
o u t n i c (TBCR1 , ( s e n d l e n >>8));
o u t n i c ( ISR , 0 xFF ) ;
return 0 ;
}
20
A CODE LISTING A.1 C Source
c o u n t e r = dmalen>>1;
o u t n i c (CMDR,CR COMPLETE) ;
return 0 ;
}
/∗ external i n t e r f a c e ∗/
/ ∗ t a k e s a 2 word sample , and s e n d s i t out . s e n d s p a c k e t i f needed ∗ /
/∗ 0 return i s success ∗/
BYTE o u t p u t s a m p l e (WORD ∗ sample ) {
BYTE r e t = 0 ;
/∗ WORD check ; ∗ /
/∗ r e t = append ( sample ) ; ∗ /
r e t = send ( sample , c u r p a y l o a d a d d r , 4 ) ;
/∗ i f ( ret )
return ret ; ∗/
c u r p a y l o a d a d d r +=4;
/ ∗ update checksums ∗ /
21
A.1 C Source A CODE LISTING
if ( ret ) {
p r i n t ( ” E r r o r w r i t i n g r t p h e a d e r data \ r \n” ) ;
}
if ( ret ) {
p r i n t ( ” E r r o r f i n a l i z i n g p a c k e t . d r o p p i n g . \ r \n” ) ;
} else {
r e t = t r a n s m i t (PACKET SIZE ) ;
// p r i n t ( ” p r o b a b l e s u c c e s s t r a n s m i t t i n g p a c k e t . happy ! happy ! \ r \n” ) ;
}
return r e t ;
}
A.1.3 main.c
/∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# CSEE 4 8 4 0 Embedded System Design
#
# SOBA S e r v e r
#
# Team W a r r i o r s : Avraham Sh i nn a r as1619@columbia . edu
# Benjamin Dweck bjd2102@columbia . edu
# Oliver Irwin omi3@columbia . edu
# Sean White sw2061@columbia . edu
22
A CODE LISTING A.1 C Source
#
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/
#include ” x p a r a m e t e r s . h”
#include ” x b a s i c t y p e s . h”
#include ” x i o . h”
#include ” e t h e r . h”
#include ” x i n t c l . h”
unsigned long u a r t o u t = 0 ;
BYTE new data =0;
void a u d i o s a m p l e r h a n d l e r ( void ∗ c a l l b a c k )
{
// m i c r o b l a z e d i s a b l e i n t e r r u p t s ( ) ;
new data =1;
// m i c r o b l a z e e n a b l e i n t e r r u p t s ( ) ;
}
int main ( )
{
int r e t ;
p r i n t ( ”\ r \n” ) ;
p r i n t ( ” H e l l o World ! \ r \n” ) ;
p r i n t ( ” Running d i a g n o s t i c s \ r \n” ) ;
i f ( r e t=d i a g n o s t i c s ( ) ) {
p r i n t ( ” D i a g n o s t i c s f a i l e d . i n t e r n a l e r r o r number ” ) ;
putnum ( r e t ) ;
p r i n t ( ”\ r \n” ) ;
} else {
p r i n t ( ” D i a g n o s t i c s s u c c e s s f u l . \ r \n” ) ;
}
if ( init ()) {
p r i n t ( ” E t h e r n e t NIC not p r e s e n t o r not i n i t i a l i z i n g c o r r e c t l y \ r \n” ) ;
return 1 ;
}
/∗ i n i t i a l i z i n g interrupts ∗/
XI ntc mEnableIntr (XPAR INTC SINGLE BASEADDR , XPAR AUDIO SAMPLER INTERRUPT MASK ) ;
XIntc mMasterEnable (XPAR INTC SINGLE BASEADDR ) ;
X I n t c R e g i s t e r H a n d l e r (XPAR INTC SINGLE BASEADDR , XPAR INTC AUDIO SAMPLER INTERRUPT INTR ,
a u d i o s a m p l e r h a n d l e r , ( void ∗ ) 0 ) ;
for ( ; ; ) {
/ ∗ new data i s s e t i n t h e i n t e r r u p t h a n d l e r when new data i s ready . ∗ /
i f ( new data == 1) {
23
A.2 clkgen A CODE LISTING
new data = 0 ;
}
return 0 ;
}
A.2 clkgen
A.2.1 data/clkgen v2 1 0.pao
################################################################################
##
## Copyright ( c ) 1 9 9 5 − 2 0 0 2 X i l i n x , I n c . A l l r i g h t s r e s e r v e d . X i l i n x , I n c .
##
## MicroBlaze Brd ZBT ClkGen v2 0 0 a . pao
##
## P e r i p h e r a l Analyze Order
##
################################################################################
l i b clkgen v1 00 a clkgen
A.2.2 data/clkgen v2 1 0.mpd
###################################################################
##
## M i c r o p r o c e s s o r P e r i p h e r a l D e f i n i t i o n : g e n e r a t e d by p s f u t i l
##
## Template MPD fo r P e r i p h e r a l : MicroBlaze Brd ZBT ClkGen
##
###################################################################
BEGIN c l k g e n , IPTYPE = IP
## P e r i p h e r a l Options
#OPTION IPTYPE = IP
OPTION HDL = VERILOG
## P o r t s
24
A CODE LISTING A.2 clkgen
END
A.2.3 hdl/verilog/clkgen.v
module c l k g e n (
FPGA CLK1 ,
sys clk ,
pixel clock ,
io clock ,
fpga reset
);
i n p u t FPGA CLK1 ;
output s y s c l k , p i x e l c l o c k , i o c l o c k , f p g a r e s e t ;
wire c l k i b u f , c l k 1 x i , c l k 2 x i ;
// w i r e c l k 1 x , c l k 0 5 x ;
// w i r e c l k i b u f , c l k 1 x i , c l k 0 5 x i , c l k 2 x i ;
wire locked ;
a s s i g n p i x e l c l o c k = 0 ; / / new
// synopsys t r a n s l a t e o f f
/ / defparam v d l l . CLKDV DIVIDE = 2 . 0 ;
// synopsys t r a n s l a t e o n
/ / s y n t h e s i s a t t r i b u t e CLKDV DIVIDE o f v d l l i s 2
//CLKDLL v d l l ( . CLKIN( c l k i b u f ) , . CLKFB( s y s c l k ) , . CLK0( c l k 1 x i ) ,
// .CLKDV( c l k 0 5 x i ) , . CLK2X( c l k 2 x i ) , . RST ( 1 ’ b0 ) , . LOCKED( l o c k e d ) ) ;
CLKDLL v d l l ( . CLKIN( c l k i b u f ) , . CLKFB( s y s c l k ) , . CLK0( c l k 1 x i ) ,
.CLK2X( c l k 2 x i ) , . RST ( 1 ’ b0 ) , . LOCKED( l o c k e d ) ) ;
endmodule
25
A.3 Audio Controller A CODE LISTING
BUS INTERFACE BUS = SOPB , BUS STD = OPB , BUS TYPE = SLAVE
## G e n e r i c s for VHDL
PARAMETER c baseaddr = 0xFFFFFFFF , DT = s t d l o g i c v e c t o r , MIN SIZE = 0xFF
PARAMETER c highaddr = 0 x00000000 , DT = std logic vector
PARAMETER c opb awidth = 32, DT = integer
PARAMETER c opb dwidth = 32, DT = integer
## P o r t s
PORT opb abus = OPB ABus , DIR = IN , VEC = [ 0 : ( c o p b a w i d t h − 1 ) ] , BUS = SOPB
PORT opb be = OPB BE , DIR = IN , VEC = [ 0 : ( ( c o p b d w i d t h / 8 ) − 1 ) ] ,BUS = SOPB
PORT o p b c l k = ”” , DIR = IN , SIGIS=CLK, BUS = SOPB
PORT opb dbus = OPB DBus , DIR = IN , VEC = [ 0 : ( c o p b d w i d t h − 1 ) ] , BUS = SOPB
PORT opb rnw = OPB RNW, DIR = IN , BUS = SOPB
PORT o p b r s t = OPB Rst , DIR = IN , BUS = SOPB
PORT o p b s e l e c t = OPB select , DIR = IN , BUS = SOPB
PORT o p b s e q a d d r = OPB seqAddr , DIR = IN , BUS = SOPB
PORT s l n d b u s = Sl DBus , DIR = OUT, VEC = [ 0 : ( c o p b d w i d t h − 1 ) ] , BUS = SOPB
PORT s l n e r r a c k = S l e r r A c k , DIR = OUT, BUS = SOPB
PORT s l n r e t r y = Sl retry , DIR = OUT, BUS = SOPB
PORT s l n t o u t s u p = S l t o u t S u p , DIR = OUT, BUS = SOPB
PORT s l n x f e r a c k = S l x f e r A c k , DIR = OUT, BUS = SOPB
END
A.3.3 data/opb audio cntlr.vhd
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
26
A CODE LISTING A.3 Audio Controller
−− Audio C o n t r o l l e r OPB P e r i p h e r a l
−−
−− Benjamin Dweck
−− bjd2102@columbia . edu
−−
−− O l i v e r I r w i n
−− omi3@columbia . edu
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− Clock D i v i d e r
−−
−− Notes : Clock output s t a r t s out low a f t e r r e s e t
−−
−− Used t o d i v i d e OPB Clk t o g e n e r a t e AU CCLK
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
generic (
FACTOR : i n t e g e r : = 1 0 ) ; −− Clock d i v i d e−by f a c t o r
port (
c l k i n : in s t d l o g i c ; −− Input c l o c k
rst : in s t d l o g i c ; −− Reset s i g n a l
c l k o u t : out s t d l o g i c ) ; −− Output c l o c k
end c l o c k d i v i d e r ;
a r c h i t e c t u r e arch of c l o c k d i v i d e r i s
s i g n a l count : i n t e g e r : = 0 ;
s i g n a l output : s t d l o g i c : = ’ 0 ’ ;
begin
c l k o u t <= output ;
27
A.3 Audio Controller A CODE LISTING
end i f ;
end p r o c e s s d i v i d e ;
end a r c h ;
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− 5− b i t Unsigned N e g a t i v e Edge T r i g g e r e d Up Counter
−− with Asynchronous Reset
−−
−− Used t o keep t r a c k o f number o f AU CCLK c y c l e s
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
use i e e e . s t d l o g i c u n s i g n e d . a l l ;
entity counter i s
port (
clk , reset : in s t d l o g i c ;
count : out s t d l o g i c v e c t o r ( 4 downto 0 )
);
end c o u n t e r ;
a r c h i t e c t u r e arch of counter i s
s i g n a l tmp : s t d l o g i c v e c t o r ( 4 downto 0 ) ;
begin
end a r c h ;
28
A CODE LISTING A.3 Audio Controller
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− 16− b i t N e g a t i v e Edge T r i g g e r e d Right S h i f t R e g i s t e r
−− with A c t i v e High Load and S e r i a l Out
−−
−− Used t o l a t c h onto data t o be output t o t h e a u d i o c o d e c and
−− s h i f t i t out s e r i a l l y .
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
a r c h i t e c t u r e arch of s h i f t o u t i s
s i g n a l tmp : s t d l o g i c v e c t o r ( 1 5 downto 0 ) ;
begin
p r o c e s s (C , ALOAD, D)
begin
i f (ALOAD= ’ 1 ’ ) then
tmp <= D;
e l s i f (C ’ e v e n t and C= ’ 0 ’ ) then
tmp < = ’ 0 ’ & tmp ( 1 5 downto 1 ) ;
end i f ;
end p r o c e s s ;
SO <= tmp ( 0 ) ;
end a r c h ;
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− 8− b i t P o s i t i v e Edge T r i g g e r e d Right S h i f t R e g i s t e r
−− with S e r i a l In and P a r a l l e l Out
−−
−− Used t o r e c e i v e data s e r i a l l y from t h e a u d i o c o d e c
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
29
A.3 Audio Controller A CODE LISTING
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
entity shift in is
port (
SI : i n s t d l o g i c ;
C : in s t d l o g i c ;
D : out s t d l o g i c v e c t o r ( 7 downto 0 )
);
end s h i f t i n ;
a r c h i t e c t u r e arch of s h i f t i n i s
s i g n a l tmp : s t d l o g i c v e c t o r ( 7 downto 0 ) ;
begin
p r o c e s s (C)
begin
i f (C ’ e v e n t and C= ’ 1 ’ ) then
tmp <= SI & tmp ( 7 downto 1 ) ;
end i f ;
end p r o c e s s ;
D <= tmp ;
end a r c h ;
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− Audio P e r i p h e r a l
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
generic (
C OPB AWIDTH : integer := 32;
C OPB DWIDTH : integer := 32;
C BASEADDR : s t d l o g i c v e c t o r ( 0 to 3 1 ) := X”00000000” ;
C HIGHADDR : s t d l o g i c v e c t o r ( 0 to 3 1 ) := X”FFFFFFFF” ) ;
port (
−− OPB Input S i g n a l s
OPB Clk : in s t d logic ;
OPB Rst : in s t d logic ;
OPB ABus : in s t d logic v e c t o r ( 0 t o C OPB AWIDTH−1);
OPB BE : in s t d logic v e c t o r ( 0 t o C OPB DWIDTH/8−1);
30
A CODE LISTING A.3 Audio Controller
−− Audio IO S i g n a l s
AU CSN : out std logic ; −− Audio Chip S e l e c t ( A c t i v e LOW)
PB D : i n o u t s t d l o g i c v e c t o r ( 1 5 downto 0 ) ; −− O f f−FPGA P e r i p h e r a l
−− Data Bus
end o p b a u d i o c n t l r ;
−− I n t e r n a l b u f f e r / u t i l l i t y signals
signal int au csn : std logic := ’1’; −− Used a s a u d i o c o d e c c h i p s e l e c t ( a
signal int au cclk : std logic ; −− Used a s s e r i a l c l o c k s i g n a l t o a u d
signal int au cclk count : std logic v e c t o r ( 4 downto 0 ) ; −− Used t o keep t r a c k o
signal int au cclk count rst : std logic ; −− To r e s e t c c l k c o u n t e r
signal int au cdti : std logic ; −− AU CDT
signal int au cdti buff : std logic v e c t o r ( 1 5 downto 0 ) ; −− Input t o CDTI s h i f t r e g
signal int au cdti load : std logic ; −− CDTI s
signal int au cdto buff : std logic v e c t o r (AU DWIDTH−1 downto 0 ) ; −− Data t o be s
−− I n t e r n a l u t i l l i t y s i g n a l s
signal int selected : std logic ; −− I n t e r n a l c h i p s e l e c t s i g n a l
signal int output enable : std logic ; −− Enable output from p e r i p h e r a l t o OPB bus
−− S t a t e c o n s t a n t s
−− C r i t i c a l : S l n x f e r A c k i s g e n e r a t e d d i r e c t l y from s t a t e b i t 0 !
c o n s t a n t STATE BITS : i n t e g e r : = 2 ;
constant Idle : std logic vector ( 0 t o STATE BITS− 1 ) : = ”00” ;
constant Transfer : std logic vector ( 0 t o STATE BITS− 1 ) : = ”01” ;
c o n s t a n t Ack : std logic vector ( 0 t o STATE BITS− 1 ) : = ”11” ;
s i g n a l p r e s e n t s t a t e , n e x t s t a t e : s t d l o g i c v e c t o r ( 0 t o STATE BITS−1);
31
A.3 Audio Controller A CODE LISTING
−− CCLK Counter
component c o u n t e r i s
port (
clk : in s t d l o g i c ;
reset : in s t d l o g i c ;
count : out s t d l o g i c v e c t o r ( 4 downto 0 ) ) ;
end component ;
−− Transmit R e g i s t e r ( AU CDTI)
component s h i f t o u t i s
port (
C , ALOAD : i n s t d l o g i c ;
D : i n s t d l o g i c v e c t o r ( 1 5 downto 0 ) ;
SO : out s t d l o g i c ) ;
end component ;
−− R e c e i v e R e g i s t e r (AU CDTO)
component s h i f t i n i s
port (
SI : i n s t d l o g i c ;
C : in s t d l o g i c ;
D : out s t d l o g i c v e c t o r ( 7 downto 0 ) ) ;
end component ;
begin −− b e h a v i o r a l
−− A / 6 Clock D i v i d e r t o g e n e r a t e CCLK
clkdiv : clock divider
32
A CODE LISTING A.3 Audio Controller
−− CCLK Counter
ccounter : counter
p o r t map ( i n t a u c c l k , i n t a u c c l k c o u n t r s t , i n t a u c c l k c o u n t ) ;
−− Transmit R e g i s t e r
cdti buff : shift out
p o r t map ( i n t a u c c l k , i n t a u c d t i l o a d , i n t a u c d t i b u f f , i n t a u c d t i ) ;
−− R e c e i v e R e g i s t e r
cdto buff : s h i f t i n
p o r t map ( PB D ( 2 ) , i n t a u c c l k , i n t a u c d t o b u f f ) ;
a u c c l k i o b u f f : IOBUF F 8
p o r t map (
O => n u l l ,
I => i n t a u c c l k ,
IO => PB D ( 0 ) ,
T => i n t a u c s n ) ;
a u c d t i i o b u f f : IOBUF F 8
p o r t map (
O => n u l l ,
I => i n t a u c d t i ,
IO => PB D ( 1 ) ,
T => i n t a u c s n ) ;
d b u s i o b u f f g e n : for i i n 3 t o 1 5 g e n e r a t e
d b u s i o b u f f : IOBUF F 8
p o r t map (
O => n u l l ,
I => ’0’,
IO => PB D( i ) ,
T => i n t a u c s n ) ;
end g e n e r a t e ;
end g e n e r a t e d b u s i o b u f f g e n ;
−− Produce c h i p s e l e c t s i g n a l by d e c o d i n g OPB a d d r e s s and c h e c k i n g OPB select
i n t s e l e c t e d <=
’ 1 ’ when OPB select = ’ 1 ’ and
OPB ABus ( 0 t o C OPB AWIDTH−AU AWIDTH−1) =
C BASEADDR( 0 t o C OPB AWIDTH−AU AWIDTH−1)
else ’ 0 ’ ;
−− Unused o u t p u t s
33
A.3 Audio Controller A CODE LISTING
−− Tie t h e 0 ’ th s t a t e b i t t o S l n x f e r A c k
S l n x f e r A c k <= p r e s e n t s t a t e ( 0 ) ;
−− P r o c e s s t o q u a l i f y OPB output u s i n g i n t o u t p u t e n a b l e
r e g i s t e r o p b o u t p u t s : p r o c e s s ( OPB Rst , OPB RNW, i n t o u t p u t e n a b l e )
begin
i f OPB Rst = ’ 1 ’ then
Sln DBus (C OPB DWIDTH−AU DWIDTH t o C OPB DWIDTH−1) <= ( o t h e r s = > ’ 0 ’ ) ;
else
i f i n t o u t p u t e n a b l e = ’ 1 ’ and OPB RNW = ’ 1 ’ then
Sln DBus (C OPB DWIDTH−AU DWIDTH t o C OPB DWIDTH−1) <= i n t a u c d t o b u f f ;
else
Sln DBus (C OPB DWIDTH−AU DWIDTH t o C OPB DWIDTH−1) <= ( o t h e r s = > ’ 0 ’ ) ;
end i f ;
end i f ;
end p r o c e s s r e g i s t e r o p b o u t p u t s ;
−− S e q u e n t i a l p a r t o f t h e FSM
f s m s e q : p r o c e s s ( OPB Clk , OPB Rst )
begin
i f OPB Rst = ’ 1 ’ then −− Asynchronous r e s e t t o I d l e s t a t e
p r e s e n t s t a t e <= I d l e ;
e l s i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then −− P o s i t i v e edge OPB Clk
p r e s e n t s t a t e <= n e x t s t a t e ; −− advance t o next s t a t e
end i f ;
end p r o c e s s f s m s e q ;
−− Combinational p a r t o f t h e FSM
fsm comb : p r o c e s s ( OPB Clk , p r e s e n t s t a t e , i n t s e l e c t e d , i n t a u c c l k c o u n t )
begin
34
A CODE LISTING A.3 Audio Controller
case p r e s e n t s t a t e i s
when I d l e =>
Sln toutSup < = ’ 0 ’ ; −− D i s a b l e S u p r e s s−Timeout
int au csn <= ’1’; −− D e s e l e c t Audio Codec
int au cdti load <= ’1’; −− Open i n p u t t o CDTI s h i f t r e g
int output enable <= ’0’; −− D i s a b l e output t o Sln DBus
int au cclk count rst <= ’1’; −− Reset AU CCLK c o u n t e r
i f i n t s e l e c t e d = ’ 1 ’ then
n e x t s t a t e <= T r a n s f e r ;
else
n e x t s t a t e <= I d l e ;
end i f ;
when T r a n s f e r =>
i f i n t s e l e c t e d = ’ 1 ’ then
Sln toutSup < = ’ 1 ’ ; −− S u p r e s s OPB Timeout
int au cdti load <= ’0’; −− Latch a u d i o c o d e c a d d r e s s / data from OPB
int au cclk count rst <= ’0’; −− S t a r t c o u n t e r
35
A.4 Audio Sampler A CODE LISTING
n e x t s t a t e <= I d l e ;
end case ;
end b e h a v i o r a l ;
A.4 Audio Sampler
A.4.1 data/opb audio sampler v2 1 0.pao
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
#− CSEE 4 8 4 0 Embedded System Design − Audio Sampling OPB P e r i p h e r a l ( pao )
#−
#− SOBA S e r v e r
#−
#− Team W a r r i o r s : Avraham Sh i nn a r as1619@columbia . edu
#− Benjamin Dweck bjd2102@columbia . edu
#− Oliver Irwin omi3@columbia . edu
#− Sean White sw2061@columbia . edu
#−
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
###############################################################
#
# o p b a u d i o s a m p l e r pao f i l e
#
###############################################################
###################################################################
##
## M i c r o p r o c e s s o r P e r i p h e r a l D e f i n i t i o n
##
## P e r i p h e r a l : Audio Sampler
##
###################################################################
36
A CODE LISTING A.4 Audio Sampler
# Bus I n t e r f a c e
BUS INTERFACE BUS = SOPB , BUS STD = OPB , BUS TYPE = SLAVE
## G e n e r i c s for VHDL
PARAMETER c baseaddr = 0xFFFFFFFF , DT = s t d l o g i c v e c t o r , MIN SIZE = 0xFF
PARAMETER c highaddr = 0 x00000000 , DT = std logic vector
PARAMETER c opb awidth = 32, DT = integer
PARAMETER c opb dwidth = 32, DT = integer
## P o r t s
PORT opb abus = OPB ABus , DIR = IN , VEC = [ 0 : ( c o p b a w i d t h − 1 ) ] , BUS = SOPB
PORT opb be = OPB BE , DIR = IN , VEC = [ 0 : ( ( c o p b d w i d t h / 8 ) − 1 ) ] , BUS = SOPB
PORT o p b c l k = ”” , DIR = IN , SIGIS=CLK, BUS = SOPB
PORT opb dbus = OPB DBus , DIR = IN , VEC = [ 0 : ( c o p b d w i d t h − 1 ) ] , BUS = SOPB
PORT opb rnw = OPB RNW, DIR = IN , BUS = SOPB
PORT o p b r s t = OPB Rst , DIR = IN , BUS = SOPB
PORT o p b s e l e c t = OPB select , DIR = IN , BUS = SOPB
PORT o p b s e q a d d r = OPB seqAddr , DIR = IN , BUS = SOPB
PORT a u s d b u s = Sl DBus , DIR = OUT, VEC = [ 0 : ( c o p b d w i d t h − 1 ) ] , BUS = SOPB
PORT a u s e r r a c k = Sl errAck , DIR = OUT, BUS = SOPB
PORT a u s r e t r y = Sl retry , DIR = OUT, BUS = SOPB
PORT a u s t o u t s u p = Sl toutSup , DIR = OUT, BUS = SOPB
PORT a u s x f e r a c k = Sl xferAck , DIR = OUT, BUS = SOPB
PORT I n t e r r u p t = ”” , DIR = OUT, SENSITIVITY = LEVEL HIGH , SIGIS = INTERRUPT , INTERRUPT PRIO
END
A.4.3 hdl/vhdl/opb audio sampler v2 1 0.vhd
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− CSEE 4 8 4 0 Embedded System Design − Audio Sampling OPB P e r i p h e r a l
−−
−− SOBA S e r v e r
−−
−− Team W a r r i o r s : Avraham Sh i n n a r as1619@columbia . edu
−− Benjamin Dweck bjd2102@columbia . edu
−− Oliver Irwin omi3@columbia . edu
−− Sean White sw2061@columbia . edu
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− 32− b i t P o s i t i v e Edge T r i g g e r e d L e f t S h i f t R e g i s t e r
37
A.4 Audio Sampler A CODE LISTING
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
entity shift 32 is
port (
SI : i n s t d l o g i c ;
C : in s t d l o g i c ;
D : out s t d l o g i c v e c t o r ( 3 1 downto 0 )
);
end s h i f t 3 2 ;
a r c h i t e c t u r e arch of s h i f t 3 2 i s
s i g n a l tmp : s t d l o g i c v e c t o r ( 3 1 downto 0 ) ;
begin
p r o c e s s (C)
begin
i f C ’ e v e n t and C= ’ 1 ’ then
tmp <= tmp ( 3 0 downto 0 ) & SI ;
end i f ;
end p r o c e s s ;
D <= tmp ;
end a r c h ;
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− 32− b i t P o s i t i v e Edge T r i g g e r e d Latch
−− with Asynchronous Reset
−−
−− Used t o r e c e i v e s amples s e r i a l l y from t h e a u d i o c o d e c
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
entity latch 32 is
port (
R : in s t d logic ;
C : in s t d logic ;
D : in s t d l o g i c v e c t o r ( 3 1 downto 0 ) ;
38
A CODE LISTING A.4 Audio Sampler
Q : out s t d l o g i c v e c t o r ( 3 1 downto 0 )
);
end l a t c h 3 2 ;
a r c h i t e c t u r e arch of l a t c h 3 2 i s
s i g n a l tmp : s t d l o g i c v e c t o r ( 3 1 downto 0 ) ;
begin
p r o c e s s (C , R)
begin
i f R= ’ 1 ’ then
tmp <= X”00000000” ;
e l s i f C’ e v e n t and C= ’ 1 ’ then
tmp <= D;
end i f ;
end p r o c e s s ;
Q <= tmp ;
end a r c h ;
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−
−− Audio Sampler P e r i p h e r a l
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
use i e e e . s t d l o g i c u n s i g n e d . a l l ;
generic (
C OPB AWIDTH : integer := 32;
C OPB DWIDTH : integer := 32;
C BASEADDR : s t d l o g i c v e c t o r ( 0 to 3 1 ) := X”00000000” ;
C HIGHADDR : s t d l o g i c v e c t o r ( 0 to 3 1 ) := X”FFFFFFFF” ) ;
port (
−− OPB Input S i g n a l s
OPB Clk : in s t d logic ;
OPB Rst : in s t d logic ;
OPB ABus : in s t d logic v e c t o r ( 0 t o C OPB AWIDTH−1);
OPB BE : in s t d logic v e c t o r ( 0 t o C OPB DWIDTH/8−1);
OPB DBus : in s t d logic v e c t o r ( 0 t o C OPB DWIDTH−1);
OPB RNW : in s t d logic ;
OPB select : i n s t d logic ;
OPB seqAddr : i n s t d logic ; −− S e q u e n t i a l Address
39
A.4 Audio Sampler A CODE LISTING
−− I n t e r r u p t
Interrupt : out s t d l o g i c ; −− I n t e r r u p t S i g n a l
−− Audio IO S i g n a l s
AU MCLK : out s t d logic ; −− Audio Chip Master Clock
AU LRCK : out s t d logic ; −− Audio L e f t / Right Channel Clock
AU BCLK : out s t d logic ; −− Audio B i t Clock
AU SDTI : out s t d logic ; −− Audio Data In (TO Codec )
AU SDTO0 : in s t d logic ); −− Audio Data Out 0 (FROM Codec )
end o p b a u d i o s a m p l e r ;
−− Clock c o u n t e r used t o g e n e r a t e a u d i o t r a n s m i s s i o n c l o c k s
s i g n a l o p b c l k c o u n t : s t d l o g i c v e c t o r ( 1 0 downto 0 ) ;
−− I n t e r n a l U t i l i t y S i g n a l s
signal int selected : std logic ; −− Decoded c h i p s e l e c t s i g n a l
signal int aus dbus en : std logic ; −− Enable s output t o AUS DBus
signal int shift out : std logic v e c t o r ( 3 1 downto 0 ) ; −− Output o f s h i f t−i n r e g i s t
signal int sample : std logic v e c t o r ( 3 1 downto 0 ) ; −− Last r e c e i v e d sample
−− I n t e r n a l B u f f e r S i g n a l s
signal int interrupt : std logic ;
signal int au mclk : std logic ;
signal int au bclk : std logic ;
signal int au lrck : std logic ;
signal int au sdto0 : std logic ;
−− S t a t e c o n s t a n t s
constant Idle : s t d l o g i c : = ’ 0 ’ ;
constant Xfer : s t d l o g i c : = ’ 1 ’ ;
40
A CODE LISTING A.4 Audio Sampler
component l a t c h 32 is
port (
R : in std logic ;
C : in std logic ;
D : in std logic v e c t o r ( 3 1 downto 0 ) ;
Q : out std logic v e c t o r ( 3 1 downto 0 ) ) ;
end component ;
component IBUF i s
port (
I : in s t d l o g i c ;
O : out s t d l o g i c ) ;
end component ;
begin
−− R e c e i v i n g S h i f t R e g i s t e r
shift rcv : shift 32
p o r t map ( SI => i n t a u s d t o 0 ,
C => i n t a u b c l k ,
D => i n t s h i f t o u t ) ;
−− Sample Latch
latch sample : latch 32
p o r t map (R => OPB Rst ,
C => i n t a u l r c k ,
D => i n t s h i f t o u t ,
Q => i n t s a m p l e ) ;
−− AU MCLK B u f f e r
a u m c l k b u f f : OBUF F 8
p o r t map (
O => AU MCLK,
I => i n t a u m c l k ) ;
−− AU BCLK B u f f e r
a u b c l k b u f f : OBUF F 8
p o r t map (
O => AU BCLK,
I => i n t a u b c l k ) ;
−− AU LRCK B u f f e r
a u l r c k b u f f : OBUF F 8
p o r t map (
O => AU LRCK,
I => i n t a u l r c k ) ;
41
A.4 Audio Sampler A CODE LISTING
−− AU SDTI B u f f e r
a u s d t i b u f f : OBUF F 8
p o r t map (
O => AU SDTI ,
I => i n t a u s d t o 0 ) ;
−− AU MCLK B u f f e r
a u s d t o 0 b u f f : IBUF
p o r t map (
O => i n t a u s d t o 0 ,
I => AU SDTO0 ) ;
−− Tie o f f−FPGA s i g n a l s t o i n t e r n a l b u f f e r s i g n a l s
INTERRUPT <= i n t i n t e r r u p t ;
−− Generate Audio T r a n s m i s s i o n C l o c k s
int au mclk <= o p b c l k c o u n t ( 1 ) ;
int au bclk <= o p b c l k c o u n t ( 4 ) ;
int au lrck <= NOT o p b c l k c o u n t ( 9 ) ;
42
A CODE LISTING A.4 Audio Sampler
−− S e q u e n t i a l p a r t o f t h e FSM
f s m s e q : p r o c e s s ( OPB Clk , OPB Rst )
begin
i f OPB Rst = ’ 1 ’ then −− Asynchronous r e s e t t o I d l e s t a t e
p r e s e n t s t a t e <= I d l e ;
e l s i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then −− P o s i t i v e edge OPB Clk
p r e s e n t s t a t e <= n e x t s t a t e ; −− advance t o next s t a t e
end i f ;
end p r o c e s s f s m s e q ;
−− Combinational p a r t o f t h e FSM
fsm comb : p r o c e s s ( p r e s e n t s t a t e , i n t s e l e c t e d )
begin
int aus dbus en <= ’0’;
case p r e s e n t s t a t e i s
when I d l e =>
int aus dbus en <= ’0’;
i f i n t s e l e c t e d = ’ 1 ’ then
n e x t s t a t e <= X f e r ;
else
n e x t s t a t e <= I d l e ;
end i f ;
when X f e r =>
int aus dbus en <= ’1’;
n e x t s t a t e <= I d l e ;
when o t h e r s =>
int aus dbus en <= ’0’;
43
A.5 opb ethernet A CODE LISTING
n e x t s t a t e <= I d l e ;
end case ;
end p r o c e s s fsm comb ;
end b e h a v i o r a l ;
A.5 opb ethernet
A.5.1 data/opb ethernet v2 1 0.pao
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# CSEE 4 8 4 0 Embedded System Design
#
# SOBA S e r v e r
#
# Team W a r r i o r s : Avraham S h i nn a r as1619@columbia . edu
# Benjamin Dweck bjd2102@columbia . edu
# Oliver Irwin omi3@columbia . edu
# Sean White sw2061@columbia . edu
#
#
# o p b e t h e r n e t pao f i l e
#
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
BUS INTERFACE BUS = SOPB , BUS STD = OPB , BUS TYPE = SLAVE
## G e n e r i c s for VHDL
PARAMETER c b a s e a d d r = 0xFFFFFFFF ,DT = s t d l o g i c v e c t o r , MIN SIZE=0x100 , BUS=SOPB
PARAMETER c h i g h a d d r = 0 x00000000 , DT = s t d l o g i c v e c t o r , BUS=SOPB
44
A CODE LISTING A.5 opb ethernet
## P o r t s
PORT opb abus = OPB ABus , DIR = IN , VEC = [ 0 : ( c o p b a w i d t h − 1 ) ] , BUS = SOPB
PORT opb be = OPB BE , DIR = IN , VEC = [ 0 : ( ( c o p b d w i d t h / 8 ) − 1 ) ] , BUS = SOPB
PORT o p b c l k = ”” , DIR = IN , SIGIS=CLK, BUS = SOPB
PORT opb dbus = OPB DBus , DIR = IN , VEC = [ 0 : ( c o p b d w i d t h − 1 ) ] , BUS = SOPB
PORT opb rnw = OPB RNW, DIR = IN , BUS = SOPB
PORT o p b r s t = OPB Rst , DIR = IN , BUS = SOPB
PORT o p b s e l e c t = OPB select , DIR = IN , BUS = SOPB
PORT o p b s e q a d d r = OPB seqAddr , DIR = IN , BUS = SOPB
PORT s l n d b u s = Sl DBus , DIR = OUT, VEC = [ 0 : ( c o p b d w i d t h − 1 ) ] , BUS = SOPB
PORT s l n e r r a c k = Sl errAck , DIR = OUT, BUS = SOPB
PORT s l n r e t r y = Sl retry , DIR = OUT, BUS = SOPB
PORT s l n t o u t s u p = Sl toutSup , DIR = OUT, BUS = SOPB
PORT s l n x f e r a c k = Sl xferAck , DIR = OUT, BUS = SOPB
PORT i o c l o c k = ”” , DIR=IN
END
A.5.3 hdl/vhdl/memoryctrl.vhd
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− CSEE 4 8 4 0 Embedded System Design
−−
−− SOBA S e r v e r
−−
−− Team W a r r i o r s : Avraham Sh i nn a r as1619@columbia . edu
−− Benjamin Dweck bjd2102@columbia . edu
−− Oliver Irwin omi3@columbia . edu
−− Sean White sw2061@columbia . edu
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
l i b r a r y IEEE ;
45
A.5 opb ethernet A CODE LISTING
−− Uncomment t h e f o l l o w i n g l i n e s t o u s e t h e d e c l a r a t i o n s t h a t a r e
−− p r o v i d e d f or i n s t a n t i a t i n g X i l i n x p r i m i t i v e components .
−−l i b r a r y UNISIM ;
−−u s e UNISIM . VComponents . a l l ;
e n t i t y memoryctrl i s
Port ( r s t : i n s t d l o g i c ;
clk : in s t d l o g i c ;
c s : i n s t d l o g i c ; −− any o f my d e v i c e s s e l e c t e d
o p b s e l e c t : i n s t d l o g i c ; −− o r i g i n a l s e l e c t
rnw : i n s t d l o g i c ;
eth io : in s t d l o g i c ;
fullword : in s t d l o g i c ;
r e a d e a r l y : out s t d l o g i c ;
w r i t e e a r l y : out s t d l o g i c ;
b u s r e q : out s t d l o g i c ;
v i d e o c y c l e : out s t d l o g i c ;
h i h a l f : out s t d l o g i c ;
w r r e q : out s t d l o g i c ;
r d r e q : out s t d l o g i c ;
x f e r : out s t d l o g i c ;
c e 0 : out s t d l o g i c ;
c e 1 : out s t d l o g i c ;
r r e s : out s t d l o g i c ;
vreq : in s t d l o g i c ;
v i d e o c e : out s t d l o g i c
);
end memoryctrl ;
a r c h i t e c t u r e B e h a v i o r a l o f memoryctrl i s
begin
46
A CODE LISTING A.5 opb ethernet
e l s i f c l k ’ e v e n t and c l k = ’ 1 ’ then
r x f e r <= o p b s e l e c t and ( ( r common and not rnw and not f u l l w o r d and not e t h i o )
end i f ;
end p r o c e s s ;
r e a d e a r l y <= r r a and e t h i o ;
w r i t e e a r l y <= not ( ( r common and not rnw and e t h i o ) o r ( r w e t h 1 ) o r r w e t h 2 ) ;
h i h a l f <= r w32 o r ( r r a and f u l l w o r d ) ;
x f e r <= r x f e r ;
r r e s <= r x f e r ;
c e 0 <= r r b o r ( r r c and e t h i o ) ;
c e 1 <= r r b o r r r c ;
−− t h e v i d e o s t a t e machine
47
A.5 opb ethernet A CODE LISTING
r v0 <=’0’;
r v1 <=’0’;
r v2 <=’0’;
end B e h a v i o r a l ;
A.5.4 hdl/vhdl/opb ethernet.vhd
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− CSEE 4 8 4 0 Embedded System Design
−−
−− SOBA S e r v e r
−−
−− Team W a r r i o r s : Avraham Sh i n n a r as1619@columbia . edu
−− Benjamin Dweck bjd2102@columbia . edu
−− Oliver Irwin omi3@columbia . edu
−− Sean White sw2061@columbia . edu
−−
−− based on Jaycam e t h e r n e t vhdl
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
l i b r a r y IEEE ;
u s e IEEE . STD LOGIC 1164 . ALL ;
u s e IEEE . STD LOGIC ARITH . ALL ;
u s e IEEE . STD LOGIC UNSIGNED . ALL ;
−− Uncomment t h e f o l l o w i n g l i n e s t o u s e t h e d e c l a r a t i o n s t h a t a r e
−− p r o v i d e d f or i n s t a n t i a t i n g X i l i n x p r i m i t i v e components .
l i b r a r y UNISIM ;
u s e UNISIM . VComponents . a l l ;
48
A CODE LISTING A.5 opb ethernet
S l n x f e r A c k : out s t d l o g i c ;
PB A : out s t d l o g i c v e c t o r ( 1 9 downto 0 ) ;
PB UB N : out s t d l o g i c ;
PB LB N : out s t d l o g i c ;
PB WE N : out s t d l o g i c ;
PB OE N : out s t d l o g i c ;
RAM CE N : out s t d l o g i c ;
ETHERNET CS N : out s t d l o g i c ;
ETHERNET RDY : i n s t d l o g i c ;
ETHERNET IREQ : i n s t d l o g i c ;
ETHERNET IOCS16 N : i n s t d l o g i c ;
PB D : i n o u t s t d l o g i c v e c t o r ( 1 5 downto 0 )
);
end o p b e t h e r n e t ;
s i g n a l sram ce : s t d l o g i c ;
signal ethernet ce : std logic ;
s i g n a l rnw : s t d l o g i c ;
s i g n a l addr : s t d l o g i c v e c t o r ( 2 3 downto 0 ) ;
s i g n a l be : s t d l o g i c v e c t o r ( 3 downto 0 ) ;
s i g n a l p b b y t e s e l : s t d l o g i c v e c t o r ( 1 downto 0 ) ;
s i g n a l wdata : s t d l o g i c v e c t o r ( 3 1 downto 0 ) ;
s i g n a l wdata mux : s t d l o g i c v e c t o r ( 1 5 downto 0 ) ;
component memoryctrl
Port ( rst : in s t d l o g i c ;
49
A.5 opb ethernet A CODE LISTING
clk : in s t d l o g i c ;
c s : i n s t d l o g i c ; −− any o f my d e v i c e s s e l e c t e d
o p b s e l e c t : i n s t d l o g i c ; −− o r i g i n a l s e l e c t
rnw : i n s t d l o g i c ;
eth io : in s t d l o g i c ;
fullword : in s t d l o g i c ;
r e a d e a r l y : out s t d l o g i c ;
w r i t e e a r l y : out s t d l o g i c ;
v i d e o c y c l e : out s t d l o g i c ;
h i h a l f : out s t d l o g i c ;
w r r e q : out s t d l o g i c ;
r d r e q : out s t d l o g i c ;
b u s r e q : out s t d l o g i c ;
x f e r : out s t d l o g i c ;
c e 0 : out s t d l o g i c ;
c e 1 : out s t d l o g i c ;
r r e s : out s t d l o g i c ;
vreq : in s t d l o g i c ;
v i d e o c e : out s t d l o g i c ) ;
end component ;
component p a d i o
Port ( s y s c l k : i n s t d l o g i c ;
i o c l o c k : in s t d l o g i c ;
read early : in s t d l o g i c ;
write early : in s t d l o g i c ;
rst : in s t d l o g i c ;
PB A : out s t d l o g i c v e c t o r ( 1 9 downto 0 ) ;
PB UB N : out s t d l o g i c ;
PB LB N : out s t d l o g i c ;
PB WE N : out s t d l o g i c ;
PB OE N : out s t d l o g i c ;
RAM CE N : out s t d l o g i c ;
ETHERNET CS N : out s t d l o g i c ;
ETHERNET RDY : i n s t d l o g i c ;
ETHERNET IREQ : i n s t d l o g i c ;
ETHERNET IOCS16 N : i n s t d l o g i c ;
PB D : i n o u t s t d l o g i c v e c t o r ( 1 5 downto 0 ) ;
pb addr : i n s t d l o g i c v e c t o r ( 1 9 downto 0 ) ;
pb ub : i n s t d l o g i c ;
pb lb : in s t d l o g i c ;
pb wr : i n s t d l o g i c ;
pb rd : i n s t d l o g i c ;
ram ce : i n s t d l o g i c ;
ethernet ce : in s t d l o g i c ;
pb dread : out s t d l o g i c v e c t o r ( 1 5 downto 0 ) ;
p b d w r i t e : i n s t d l o g i c v e c t o r ( 1 5 downto 0 ) ) ;
end component ;
begin
50
A CODE LISTING A.5 opb ethernet
−− t h e c o n t r o l l e r s t a t e machine
memoryctrl1 : memoryctrl
p o r t map ( r s t => OPB Rst ,
c l k => OPB Clk ,
c s => c s ,
o p b s e l e c t => OPB select ,
rnw => rnw ,
f u l l w o r d => f u l l w o r d ,
e t h i o => e t h i o ,
r e a d e a r l y => r e a d e a r l y ,
w r i t e e a r l y => w r i t e e a r l y ,
v i d e o c y c l e => v i d e o c y c l e ,
h i h a l f => h i h a l f ,
w r r e q => w r r e q ,
r d r e q => r d r e q ,
b u s r e q => b u s r e q ,
x f e r => x f e r ,
c e 0 => r c e 0 ,
c e 1 => r c e 1 ,
r r e s => r r e s e t ,
v r e q => v i d e o r e q ,
v i d e o c e => v i d e o c e ) ;
−− PADS
51
A.5 opb ethernet A CODE LISTING
e t h e r n e t c e => e t h e r n e t c e ,
pb dread => r d a t a ,
p b d w r i t e => wdata mux ) ;
amuxsel <= v i d e o c y c l e ;
f u l l w o r d <= be ( 2 ) and be ( 0 ) ;
−− p r e p a r e c o n t r o l s i g n a l s
p r o c e s s ( v i d e o c y c l e , be , addr ( 1 ) , h i h a l f , r d r e q , w r r e q )
begin
end p r o c e s s ;
pb rd <= r d r e q o r v i d e o c y c l e ;
pb wr <= w r r e q ;
−−pb wr <= OPB Clk ;
−− r e g i s t e r rw
i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then
52
A CODE LISTING A.5 opb ethernet
end i f ;
−− r e g i s t e r a d r e s s e s A23 . . A0
i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then
for i i n 0 t o 2 3 l o o p
i f OPB Rst = ’ 1 ’ then
addr ( i ) < = ’ 0 ’ ;
else
addr ( i ) <= OPB ABus( i ) ;
end i f ;
end l o o p ;
end i f ;
−− r e g i s t e r BE
i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then
i f OPB Rst = ’ 1 ’ then
be <= ”0000” ;
else
be <= OPB BE ;
end i f ;
end i f ;
−− r e g i s t e r data w r i t e
i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then
for i i n 0 t o 3 1 l o o p
i f OPB Rst = ’ 1 ’ then
wdata ( i ) < = ’ 0 ’ ;
else
wdata ( i ) <= OPB DBus( i ) ;
end i f ;
end l o o p ;
end i f ;
−− t h e fun b e g i n s
−− c e 0 / c e 1 e n a b l e s w r i t i n g MSB ( low ) / LSB ( h i g h ) h a l v e s
for i i n 0 t o 1 5 l o o p
i f OPB Rst = ’ 1 ’ then
Sln DBus ( i ) < = ’ 0 ’ ;
53
A.5 opb ethernet A CODE LISTING
for i i n 1 6 t o 3 1 l o o p
i f OPB Rst = ’ 1 ’ then
Sln DBus ( i ) < = ’ 0 ’ ;
e l s i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then
i f r r e s e t = ’ 1 ’ then
Sln DBus ( i ) < = ’ 0 ’ ;
e l s i f r c e 0 = ’ 1 ’ then
Sln DBus ( i ) <= r d a t a ( i −16);
end i f ;
end i f ;
end l o o p ;
end p r o c e s s ;
−− t i e unused t o ground
Sln errAck <= ’0’;
Sln retry <= ’0’;
Sln toutSup <= ’0’;
S l n x f e r A c k <= x f e r ;
end B e h a v i o r a l ;
A.5.5 hdl/vhdl/pad io.vhd
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− CSEE 4 8 4 0 Embedded System Design
−−
−− SOBA S e r v e r
−−
−− Team W a r r i o r s : Avraham Sh i n n a r as1619@columbia . edu
−− Benjamin Dweck bjd2102@columbia . edu
−− Oliver Irwin omi3@columbia . edu
−− Sean White sw2061@columbia . edu
−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
l i b r a r y IEEE ;
u s e IEEE . STD LOGIC 1164 . ALL ;
u s e IEEE . STD LOGIC ARITH . ALL ;
u s e IEEE . STD LOGIC UNSIGNED . ALL ;
l i b r a r y UNISIM ;
u s e UNISIM .VCOMPONENTS. ALL ;
54
A CODE LISTING A.5 opb ethernet
entity pad io i s
Port ( s y s c l k : i n s t d l o g i c ;
i o c l o c k : in s t d l o g i c ;
read early : in s t d l o g i c ;
write early : in s t d l o g i c ;
rst : in s t d l o g i c ;
PB A : out s t d l o g i c v e c t o r ( 1 9 downto 0 ) ;
PB UB N : out s t d l o g i c ;
PB LB N : out s t d l o g i c ;
PB WE N : out s t d l o g i c ;
PB OE N : out s t d l o g i c ;
RAM CE N : out s t d l o g i c ;
ETHERNET CS N : out s t d l o g i c ;
ETHERNET RDY : i n s t d l o g i c ;
ETHERNET IREQ : i n s t d l o g i c ;
ETHERNET IOCS16 N : i n s t d l o g i c ;
PB D : i n o u t s t d l o g i c v e c t o r ( 1 5 downto 0 ) ;
pb addr : i n s t d l o g i c v e c t o r ( 1 9 downto 0 ) ;
pb ub : i n s t d l o g i c ;
pb lb : in s t d l o g i c ;
pb wr : i n s t d l o g i c ;
pb rd : i n s t d l o g i c ;
ram ce : i n s t d l o g i c ;
ethernet ce : in s t d l o g i c ;
pb dread : out s t d l o g i c v e c t o r ( 1 5 downto 0 ) ;
p b d w r i t e : i n s t d l o g i c v e c t o r ( 1 5 downto 0 ) ) ;
end p a d i o ;
component FDCE
p o r t (C : i n s t d l o g i c ;
CLR : i n s t d l o g i c ;
CE : i n s t d l o g i c ;
D : in s t d l o g i c ;
Q : out s t d l o g i c ) ;
end component ;
component FDPE
p o r t (C : i n s t d l o g i c ;
PRE : i n s t d l o g i c ;
CE : i n s t d l o g i c ;
D : in s t d l o g i c ;
Q : out s t d l o g i c ) ;
end component ;
a t tr ib ut e iob : s t r i n g ;
a t t r i b u t e i o b o f FDCE : component i s ” t r u e ” ;
a t t r i b u t e i o b o f FDPE : component i s ” t r u e ” ;
55
A.5 opb ethernet A CODE LISTING
component OBUF F 24
p o r t (O : out STD ULOGIC ;
I : i n STD ULOGIC ) ;
end component ;
component IOBUF F 24
p o r t (O : out STD ULOGIC ;
IO : i n o u t STD ULOGIC ;
I : i n STD ULOGIC ;
T : i n STD ULOGIC ) ;
end component ;
s i g n a l rd ce , wr ce , din c e , r d e a r l y , wr early : s t d l o g i c ;
−−a t t r i b u t e e q u i v a l e n t r e g i s t e r r e m o v a l : s t r i n g ;
−−a t t r i b u t e e q u i v a l e n t r e g i s t e r r e m o v a l o f p b t r i s t a t e 1 : s i g n a l i s ”no” ;
−−a t t r i b u t e e q u i v a l e n t r e g i s t e r r e m o v a l o f p b d w r i t e 1 : s i g n a l i s ”no” ;
begin
56
A CODE LISTING A.5 opb ethernet
end i f ;
end p r o c e s s ;
d a t a z <= ( not pb wr ) o r pb rd ;
p b t r i s t a t e <= ”1111111111111111” when d a t a z = ’ 1 ’ e l s e ”0000000000000000” ;
−− a d d r e s s
a f f : for i in 0 to 1 9 generate
a f f : FDCE p o r t map (
C => i o c l o c k , CLR => r s t ,
CE => i o h a l f ,
D => pb addr ( i ) ,
Q => p b a d d r 1 ( i ) ) ;
end g e n e r a t e ;
−− data
d i n c e <= i o h a l f xor r d e a r l y ;
d f f : for i in 0 to 1 5 generate
d r f f : FDPE p o r t map (
C => i o c l o c k , PRE => r s t ,
CE => d i n c e ,
D => p b d r e a d a ( i ) ,
Q => pb dread ( i ) ) ;
d w f f : FDPE p o r t map (
C => i o c l o c k , PRE => r s t ,
CE => i o h a l f ,
D => p b d w r i t e ( i ) ,
Q => p b d w r i t e 1 ( i ) ) ;
d t f f : FDPE p o r t map (
C => i o c l o c k , PRE => r s t ,
CE => i o h a l f ,
D => p b t r i s t a t e ( i ) ,
Q => p b t r i s t a t e 1 ( i ) ) ;
end g e n e r a t e ;
−− c o n t r o l
we n <= not pb wr o r ( not i o h a l f and w r e a r l y ) ;
w r c e <= i o h a l f o r w r e a r l y ;
w e f f : FDPE p o r t map (
C => i o c l o c k , PRE => r s t ,
CE => w r c e ,
D => we n ,
Q => pb we n1 ) ;
57
A.5 opb ethernet A CODE LISTING
CE => r d c e ,
D => o e n ,
Q => p b o e n 1 ) ;
l b n <= not p b l b ;
l b f f : FDPE p o r t map (
C => i o c l o c k , PRE => r s t ,
CE => i o h a l f ,
D => l b n ,
Q => p b l b n 1 ) ;
ub n <= not pb ub ;
u b f f : FDPE p o r t map (
C => i o c l o c k , PRE => r s t ,
CE => i o h a l f ,
D => ub n ,
Q => pb ub n1 ) ;
e t h c e n <= not e t h e r n e t c e ;
e t h c e f f : FDPE p o r t map (
C => i o c l o c k ,
PRE => r s t ,
CE => i o h a l f ,
D => e t h c e n ,
Q => e t h c e n 1 ) ;
−− I /O BUFFERS
webuf : OBUF F 24
p o r t map (O => PB WE N ,
I => pb we n1 ) ;
o e b u f : OBUF F 24
p o r t map (O => PB OE N ,
I => p b o e n 1 ) ;
ramcebuf : OBUF F 24
p o r t map (O => RAM CE N ,
I => r a m c e n 1 ) ;
e t h c e b u f : OBUF F 24
p o r t map (O => ETHERNET CS N ,
I => e t h c e n 1 ) ;
58
A CODE LISTING A.5 opb ethernet
−− ETHERNET RDY : i n s t d l o g i c ;
−− ETHERNET IREQ : i n s t d l o g i c ;
−− ETHERNET IOCS16 N : i n s t d l o g i c ;
ubbuf : OBUF F 24
p o r t map (O => PB UB N ,
I => pb ub n1 ) ;
l b b u f : OBUF F 24
p o r t map (O => PB LB N ,
I => p b l b n 1 ) ;
abuf : f or i i n 0 t o 1 9 g e n e r a t e
abuf : OBUF F 24 p o r t map (
O => PB A( i ) ,
I => p b a d d r 1 ( i ) ) ;
end g e n e r a t e ;
dbuf : f o r i i n 0 t o 1 5 g e n e r a t e
dbuf : IOBUF F 24 p o r t map (
O => p b d r e a d a ( i ) ,
IO => PB D( i ) ,
I => p b d w r i t e 1 ( i ) ,
T => p b t r i s t a t e 1 ( i ) ) ;
end g e n e r a t e ;
end B e h a v i o r a l ;
A.5.6 hdl/vhdl/opb ethernet.vhd.old
Note that this file represents our original attempt to get ethernet working without using JAYcam’s code.
We did not get it working, but felt that it might be useful to future groups (we did get parts of it functioning
correctly). This code is not, however actually used in our project.
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− CSEE 4 8 4 0 Embedded System Design
−−
−− SOBA S e r v e r
−−
−− Team W a r r i o r s : Avraham Sh i n n a r as1619@columbia . edu
−− Benjamin Dweck bjd2102@columbia . edu
−− Oliver Irwin omi3@columbia . edu
−− Sean White sw2061@columbia . edu
−−
−− our o r i g i n a l attempt g e t t i n g e t h e r n e t working . not used .
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
59
A.5 opb ethernet A CODE LISTING
generic (
C OPB AWIDTH : i n t e g e r := 32;
C OPB DWIDTH : i n t e g e r := 32;
C BASEADDR : s t d l o g i c v e c t o r ( 0 to 3 1 ) := X”00000000” ;
C HIGHADDR : s t d l o g i c v e c t o r ( 0 to 3 1 ) := X”FFFFFFFF” ;
C ETHERNET DWIDTH : i n t e g e r : = 1 6 ; −− Number o f a d d r e s s l i n e s on t h e
C ETHERNET AWIDTH : i n t e g e r : = 1 0 ) ; − − Number o f data l i n e s on t h e RAM
port (
OPB Clk : in std logic ;
OPB Rst : in std logic ;
OPB ABus : in std logic v e c t o r ( 0 t o C OPB AWIDTH−1);
OPB BE : in std logic v e c t o r ( 0 t o C OPB DWIDTH/8−1);
OPB DBus : in std logic v e c t o r ( 0 t o C OPB DWIDTH−1);
OPB RNW : in std logic ;
OPB select : in std logic ;
OPB seqAddr : in std logic ; −− S e q u e n t i a l Address
Sln DBus : out std logic v e c t o r ( 0 t o C OPB DWIDTH−1);
Sln errAck : out std logic ; −− ( unused )
Sln retry : out std logic ; −− ( unused )
Sln toutSup : out std logic ; −− Timeout s u p p r e s s
Sln xferAck : out std logic ; −− T r a n s f e r acknowledge
component OBUF F 24
port (
O : out s t d l o g i c ; −− t h e p i n
I : in s t d l o g i c ) ; −− s i g n a l t o p i n
end component ;
component IOBUF F 24
port (
O : out s t d l o g i c ; −− s i g n a l from p i n
I : in s t d l o g i c ; −− s i g n a l t o p i n
IO : i n o u t s t d l o g i c ; −− t h e p i n
T : in s t d l o g i c ) ; −− 1 = d r i v e IO with O
end component ;
s i g n a l a b u f i n p u t : s t d l o g i c v e c t o r ( 0 t o C ETHERNET AWIDTH−1);
60
A CODE LISTING A.5 opb ethernet
s i g n a l d b u f o u t p u t , d b u f i n p u t : s t d l o g i c v e c t o r ( 0 t o C ETHERNET DWIDTH−1);
signal tristate control : std logic ;
s i g n a l RNW : s t d l o g i c ;
signal chip select : std logic ;
signal output enable : s t d l o g i c ;
signal ETHERNET CS N i : s t d l o g i c ;
signal PB OE i : s t d l o g i c ;
signal PB WE i : s t d l o g i c ;
signal ae n i : std logic ;
signal bhe n i : std logic ;
signal be : s t d l o g i c v e c t o r ( 0 t o C OPB DWIDTH/8−1);
signal fullword : std logic ;
signal s t a t e v a l u e : s t d l o g i c v e c t o r ( 0 to 7 ) ;
s i g n a l pb read : s t d l o g i c ;
signal pb write : s t d l o g i c ;
begin
e t h e r n e t c s n p a d : OBUF F 24 p o r t map (
O => ETHERNET CS N ,
I => ETHERNET CS N i ) ;
61
A.5 opb ethernet A CODE LISTING
p b o e p a d : OBUF F 24 p o r t map (
O => PB OE ,
I => PB OE i ) ;
p b l b p a d : OBUF F 24 p o r t map ( −− AE N
O => PB LB ,
I => a e n i ) ;
f u l l w o r d <= be ( 2 ) and be ( 0 ) ;
62
A CODE LISTING A.5 opb ethernet
end i f ;
end p r o c e s s r e g i s t e r o p b i n p u t s ;
i f p b r e a d = ’ 0 ’ then
PB OE i < = ’ 0 ’ ;
else
PB OE i < = ’ 1 ’ ;
end i f ;
i f p b w r i t e = ’ 0 ’ then
PB WE i < = ’ 0 ’ ;
else
PB WE i < = ’ 1 ’ ;
end i f ;
end i f ;
end p r o c e s s ;
63
A.5 opb ethernet A CODE LISTING
−− Unused o u t p u t s
Sln errAck <= ’0’;
Sln retry <= ’0’;
−− S e q u e n t i a l p a r t o f t h e FSM
f s m s e q : p r o c e s s ( OPB Clk , OPB Rst )
begin
i f OPB Rst = ’ 1 ’ then
p r e s e n t s t a t e <= I d l e ;
e l s i f OPB Clk ’ e v e n t and OPB Clk = ’ 1 ’ then
p r e s e n t s t a t e <= n e x t s t a t e ;
end i f ;
end p r o c e s s f s m s e q ;
−− Combinational p a r t o f t h e FSM
fsm comb : p r o c e s s ( OPB Rst , p r e s e n t s t a t e , c h i p s e l e c t , OPB Select , RNW)
begin
64
A CODE LISTING A.5 opb ethernet
when S e l e c t e d =>
t r i s t a t e c o n t r o l <= RNW;
output enable <= ’0’;
p b r e a d <= not RNW; −− a c t i v e low
p b w r i t e <= RNW; −− a c t i v e low
i f OPB Select = ’ 1 ’ then
i f RNW = ’ 1 ’ then
n e x t s t a t e <= Read0 ;
else
n e x t s t a t e <= Write1 ;
end i f ;
else
n e x t s t a t e <= I d l e ;
end i f ;
65
A.5 opb ethernet A CODE LISTING
when T r a n s f e r d o n e =>
t r i s t a t e c o n t r o l <= RNW; −− 0
n e x t s t a t e <= I d l e ;
output enable <= ’0’;
pb read < = ’ 1 ’ ; −− a c t i v e low
pb write <= ’1’; −− a c t i v e low
when o t h e r s =>
t r i s t a t e c o n t r o l <= RNW;
n e x t s t a t e <= I d l e ;
output enable <= ’0’;
pb read < = ’ 1 ’ ; −− a c t i v e low
66
A CODE LISTING A.6 misc
end case ;
end i f ;
end p r o c e s s fsm comb ;
−− b h e n i <= ’0’; −− UB
end B e h a v i o r a l ;
−− L o c a l V a r i a b l e s :
−− c o m p i l e−command : ” g h d l −a o p b e t h e r n e t . vhd”
−− End :
A.6 misc
A.6.1 Makefile
# M a k e f i l e fo r CSEE 4 8 4 0
SYSTEM = system
MICROBLAZE OBJS = \
c s o u r c e f i l e s /main . o c s o u r c e f i l e s / ether . o
LIBRARIES = mymicroblaze / l i b / l i b x i l . a
# B i t s t r e a m s fo r t h e FPGA
# F i l e s t o be downloaded t o t h e SRAM
FPGA ARCH = s p a r t a n 2 e
DEVICE = x c2 s 300 e p q208−6
LANGUAGE = vhdl
PLATGEN OPTIONS = −p $ (FPGA ARCH) − l a n g $ (LANGUAGE)
67
A.6 misc A CODE LISTING
# Paths f or programs
XILINX = / u s r / cad / x i l i n x / i s e 6 . 2 i
ISEBINDIR = $ ( XILINX ) / b i n / l i n
ISEENVCMDS = LD LIBRARY PATH=$ ( ISEBINDIR ) XILINX=$ ( XILINX ) PATH=$ ( ISEBINDIR ) : $ (PATH)
# Executables
# External Targets
all :
@echo ” M a k e f i l e t o b u i l d a M i c r o p r o c e s s o r system : ”
@echo ”Run make with any o f t h e f o l l o w i n g t a r g e t s ”
@echo ” make l i b s : C o n f i g u r e s t h e sw l i b r a r i e s f o r t h i s system ”
@echo ” make program : Compiles t h e program s o u r c e s f o r a l l t h e p r o c e s s o r i n s t a n c
@echo ” make n e t l i s t : G e n e r a t e s t h e n e t l i s t f o r t h i s system ( $ (SYSTEM) ) ”
@echo ” make b i t s : Runs Imple mentation t o o l s t o g e n e r a t e t h e b i t s t r e a m ”
@echo ” make i n i t b r a m : I n i t i a l i z e s b i t s t r e a m with BRAM data ”
@echo ” make download : Downloads t h e b i t s t r e a m onto t h e board ”
@echo ” make n e t l i s t c l e a n : D e l e t e s n e t l i s t ”
@echo ” make hwclean : D e l e t e s i m p l e m e n t a t i o n d i r ”
@echo ” make l i b s c l e a n : D e l e t e s sw l i b r a r i e s ”
@echo ” make prog ram c le a n : D e l e t e s c o m p i l e d ELF f i l e s ”
@echo ” make c l e a n : Deletes a l l generated f i l e s / d i r e c t o r i e s ”
@echo ” make cd : D e l e t e s some s t u f f and downloads ”
@echo ” ”
@echo ” make < t a r g e t > : ( D e f a u l t ) ”
@echo ” C r e a t e s a M i c r o p r o c e s s o r system u s i n g d e f a u l t i n i t i a l i z a t i o n s ”
@echo ” s p e c i f i e d f o r each p r o c e s s o r i n MSS f i l e ”
68
A CODE LISTING A.6 misc
b i t s : $ (FPGA BITFILE)
n e t l i s t : $ (NETLIST)
l i b s : $ (LIBRARIES)
i n i t b r a m : $ (MERGED BITFILE)
cd : c l p a r t download
clpart :
rm − f i m p l e m e n t a t i o n / system . ngc i m p l e m e n t a t i o n / e t h e r n e t p e r i p h e r a l w r a p p e r . ngc i m p
c l e a n : hwclean l i b s c l e a n p ro gra m c l e a n
rm − f b r a m i n i t . sh p l a t g e n . l o g p l a t g e n . opt l i b g e n . l o g
rm − f i m p a c t . cmd x f l o w . h i s
hwclean : n e t l i s t c l e a n
rm − r f i m p l e m e n t a t i o n s y n t h e s i s x s t h d l
rm − r f x s t . s r p $ (SYSTEM) x s t . s r p
netlistclean :
rm − f $ (FPGA BITFILE ) $ (MERGED BITFILE ) \
$ (NETLIST ) i m p l e m e n t a t i o n / $ (SYSTEM) bd .bmm
libsclean :
rm − r f mymicroblaze / l i b
p r og ra m c le an :
rm − f $ ( ELF FILE ) $ (SRAM BITFILE ) $ (SRAM HEXFILE)
#
# Software r u l e s
#
MICROBLAZE MODE = e x e c u t a b l e
# C o m p i l a t i on
MICROBLAZE CC CFLAGS =
#MICROBLAZE CC OPT = −O3 #−mxl−gp−opt
MICROBLAZE CC OPT = −Os #−mxl−gp−opt
MICROBLAZE CC DEBUG FLAG =# −g s t a b s
MICROBLAZE INCLUDES = − I . / mymicroblaze / i n c l u d e / # − I
69
A.6 misc A CODE LISTING
MICROBLAZE CFLAGS = \
$ (MICROBLAZE CC CFLAGS) \
−mxl−b a r r e l−s h i f t \
$ (MICROBLAZE CC OPT) \
$ (MICROBLAZE CC DEBUG FLAG) \
$ (MICROBLAZE INCLUDES)
$ (MICROBLAZE OBJS ) : % . o : % . c
PATH=$ (MBBINDIR ) $ (MICROBLAZE CC) $ (MICROBLAZE CFLAGS) − c $< −o $@
# Linking
# Uncomment t h e f o l l o w i n g t o make l i n k e r p r i n t l o c a t i o n s f o r e v e r y t h i n g
MICROBLAZE LD FLAGS = −Wl,−M
#MICROBLAZE LINKER SCRIPT = −Wl,−T −Wl , m y l i n k s c r i p t
MICROBLAZE LIBPATH = −L . / mymicroblaze / l i b /
MICROBLAZE CC START ADDR FLAG= −Wl,− defsym −Wl , TEXT START ADDR=0x00000000
MICROBLAZE CC STACK SIZE FLAG= −Wl,− defsym −Wl , STACK SIZE=0x200
MICROBLAZE LFLAGS = \
−x l−mode−$ (MICROBLAZE MODE) \
$ (MICROBLAZE LD FLAGS) \
$ (MICROBLAZE LINKER SCRIPT ) \
$ (MICROBLAZE LIBPATH) \
$ (MICROBLAZE CC START ADDR FLAG) \
$ (MICROBLAZE CC STACK SIZE FLAG)
#
# Hardware r u l e s
#
# Hardware c o m p i l a t i o n : o p t i m i z e t h e n e t l i s t , p l a c e and r o u t e
$ (NETLIST ) : $ (MHSFILE)
$ (PLATGEN) $ (PLATGEN OPTIONS) − s t x s t $ (MHSFILE)
$ (XST) − i f n s y n t h e s i s /$ (SYSTEM) x s t . s c r
# p e r l synth modules . pl < s y n t h e s i s / xst . s c r > xst . s c r
# $ (XST) − i f n x s t . s c r
70
A CODE LISTING A.6 misc
# rm − r x s t x s t . s c r
# $ (XST) − i f n s y n t h e s i s /$ (SYSTEM) . s c r
#
# Downloading
#
# Download t h e f i l e s t o t h e t a r g e t board
# Parameters
PARAMETER VERSION = 2 . 1 . 0
####PORTS
# Clock Port
PORT FPGA CLK1 = FPGA CLK1 , DIR = IN
# UART P o r t s
71
A.6 misc A CODE LISTING
# Ethernet Ports
PORT PB D = PB D , DIR = INOUT , VEC= [ 1 5 : 0 ]
PORT PB A = PB A , DIR = OUT, VEC= [ 1 9 : 0 ]
PORT PB OE N = PB OE N , DIR = OUT
PORT PB WE N = PB WE N , DIR = OUT
PORT PB UB N = PB UB N , DIR = OUT
PORT PB LB N = PB LB N , DIR = OUT
PORT RAM CE N = RAM CE N , DIR = OUT
# Audio Codec P o r t s
#### PERIPHERALS
# Ethernet p e r i p h e r a l
BEGIN o p b e t h e r n e t
PARAMETER INSTANCE = e t h e r n e t p e r i p h e r a l
PARAMETER HW VER = 1 . 0 0 . a
PARAMETER C BASEADDR = 0 x00800000
PARAMETER C HIGHADDR = 0x00FFFFFF
# PARAMETER C BASEADDR = 0 xFF100000
# PARAMETER C HIGHADDR = 0xFF1FFFFF
PORT PB D = PB D
PORT PB A = PB A
PORT PB OE N = PB OE N
72
A CODE LISTING A.6 misc
PORT PB WE N = PB WE N
PORT PB UB N = PB UB N
PORT PB LB N = PB LB N
PORT RAM CE N = RAM CE N
PORT i o c l o c k = i o c l o c k
END
# Audio Sampler P e r i p h e r a l
BEGIN o p b a u d i o s a m p l e r
PARAMETER INSTANCE = a u d i o s a m p l e r
PARAMETER HW VER = 1 . 0 0 . a
PARAMETER C BASEADDR = 0 x10000100
PARAMETER C HIGHADDR = 0 x100001FF
BUS INTERFACE SOPB = myopb bus
# PORT AU CLK = a u d i o c l k
PORT OPB Clk = s y s c l k
PORT AU MCLK = AU MCLK
PORT AU LRCK = AU LRCK
PORT AU BCLK = AU BCLK
PORT AU SDTI = AU SDTI
PORT AU SDTO0 = AU SDTO0
PORT INTERRUPT = s a m p l e r i n t r
END
# The MICROBLAZE
BEGIN m i c r o b l a z e
PARAMETER INSTANCE = mymicroblaze
PARAMETER HW VER = 2 . 0 0 . a
PARAMETER C USE BARREL = 1
PARAMETER C USE ICACHE = 0
PORT Clk = s y s c l k
PORT Reset = f p g a r e s e t
PORT I n t e r r u p t = i n t r
BUS INTERFACE DLMB = d lmb
BUS INTERFACE ILMB = i l m b
BUS INTERFACE DOPB = myopb bus
BUS INTERFACE IOPB = myopb bus
END
# Interrupt Controller
BEGIN o p b i n t c
PARAMETER INSTANCE = i n t c
PARAMETER HW VER = 1 . 0 0 . c
PARAMETER C BASEADDR = 0 xFFFF0000
PARAMETER C HIGHADDR = 0xFFFF00FF
PORT OPB Clk = s y s c l k
PORT I n t r = u a r t i n t r & s a m p l e r i n t r
PORT I r q = intr
BUS INTERFACE SOPB = myopb bus
73
A.6 misc A CODE LISTING
END
BEGIN l m b b r a m i f c n t l r
PARAMETER INSTANCE = l m b d a t a c o n t r o l l e r
PARAMETER HW VER = 1 . 0 0 . b
PARAMETER C BASEADDR = 0 x00000000
PARAMETER C HIGHADDR = 0 x00000FFF
BUS INTERFACE SLMB = d lmb
BUS INTERFACE BRAM PORT = conn 0
END
# I n s t r u c t i o n LMB bus
BEGIN l m b b r a m i f c n t l r
PARAMETER INSTANCE = l m b i n s t r u c t i o n c o n t r o l l e r
PARAMETER HW VER = 1 . 0 0 . b
PARAMETER C BASEADDR = 0 x00000000
PARAMETER C HIGHADDR = 0 x00000FFF
BUS INTERFACE SLMB = i l m b
BUS INTERFACE BRAM PORT = conn 1
END
# The a c t u a l b l o c k memory
BEGIN c l k g e n
74
A CODE LISTING A.6 misc
PARAMETER INSTANCE = c l k g e n 0
PARAMETER HW VER = 1 . 0 0 . a
PORT FPGA CLK1 = FPGA CLK1
PORT i o c l o c k = i o c l o c k
PORT s y s c l k = s y s c l k
PORT f p g a r e s e t = f p g a r e s e t
END
# UART: S e r i a l p o r t hardware
BEGIN o p b u a r t l i t e
PARAMETER INSTANCE = myuart
PARAMETER HW VER = 1 . 0 0 . b
PARAMETER C CLK FREQ = 50 0 0 0 0 0 0
PARAMETER C USE PARITY = 0
PARAMETER C BASEADDR = 0 xFEFF0100
PARAMETER C HIGHADDR = 0xFEFF01FF
BUS INTERFACE SOPB = myopb bus
PORT OPB Clk = s y s c l k
PORT RX=RS232 RD
PORT TX=RS232 TD
PORT INTERRUPT = u a r t i n t r
END
A.6.3 system.mss
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# CSEE 4 8 4 0 Embedded System Design − System C o n s t r a i n t s F i l e
#
# SOBA S e r v e r
#
# Team W a r r i o r s : Avraham S h i n n a r as1619@columbia . edu
# Benjamin Dweck bjd2102@columbia . edu
# Oliver Irwin omi3@columbia . edu
# Sean White sw2061@columbia . edu
#
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
75
A.6 misc A CODE LISTING
PARAMETER VERSION = 2 . 2 . 0
PARAMETER HW SPEC FILE = system . mhs
BEGIN PROCESSOR
PARAMETER HW INSTANCE = mymicroblaze
PARAMETER DRIVER NAME = cpu
PARAMETER DRIVER VER = 1 . 0 0 . a
END
BEGIN OS
PARAMETER PROC INSTANCE = mymicroblaze
PARAMETER OS NAME = s t a n d a l o n e
PARAMETER OS VER = 1 . 0 0 . a
PARAMETER STDIN = myuart
PARAMETER STDOUT = myuart
END
BEGIN DRIVER
PARAMETER HW INSTANCE = myuart
PARAMETER DRIVER NAME = u a r t l i t e
PARAMETER DRIVER VER = 1 . 0 0 . b
END
BEGIN DRIVER
PARAMETER HW INSTANCE = i n t c
PARAMETER DRIVER NAME = i n t c
PARAMETER DRIVER VER = 1 . 0 0 . c
END
BEGIN DRIVER
PARAMETER HW INSTANCE = l m b d a t a c o n t r o l l e r
PARAMETER DRIVER NAME = g e n e r i c
PARAMETER DRIVER VER = 1 . 0 0 . a
END
BEGIN DRIVER
PARAMETER HW INSTANCE = l m b i n s t r u c t i o n c o n t r o l l e r
PARAMETER DRIVER NAME = g e n e r i c
PARAMETER DRIVER VER = 1 . 0 0 . a
END
BEGIN DRIVER
PARAMETER HW INSTANCE = e t h e r n e t p e r i p h e r a l
PARAMETER DRIVER NAME = g e n e r i c
PARAMETER DRIVER VER = 1 . 0 0 . a
END
BEGIN DRIVER
PARAMETER HW INSTANCE = a u d i o s a m p l e r
76
A CODE LISTING A.6 misc
net s y s c l k period = 2 0 . 0 0 0 ;
#n e t p i x e l c l o c k p e r i o d = 3 6 . 0 0 0 ;
net i o c l o c k period = 9 . 0 0 0 ;
#n e t ICLK p e r i o d = 3 0 . 0 0 0 ;
# Ethernet
n e t ETHERNET CS N l o c=” p82 ” ;
n e t ETHERNET RDY l o c=” p81 ” ;
n e t ETHERNET IREQ l o c=” p75 ” ;
n e t ETHERNET IOCS16 N l o c=” p74 ” ;
# OPB ETHERNET
n e t PB OE N l o c=” p125 ” ;
n e t PB WE N l o c=” p123 ” ;
n e t PB UB N l o c=” p146 ” ;
n e t PB LB N l o c=” p140 ” ;
# OPB Data
n e t PB D<0> l o c=” p153 ” ;
n e t PB D<1> l o c=” p145 ” ;
n e t PB D<2> l o c=” p141 ” ;
n e t PB D<3> l o c=” p135 ” ;
77
A.6 misc A CODE LISTING
#OPB Address
n e t PB A<0> l o c=” p83 ” ;
n e t PB A<1> l o c=” p84 ” ;
n e t PB A<2> l o c=” p86 ” ;
n e t PB A<3> l o c=” p87 ” ;
n e t PB A<4> l o c=” p88 ” ;
n e t PB A<5> l o c=” p89 ” ;
n e t PB A<6> l o c=” p93 ” ;
n e t PB A<7> l o c=” p94 ” ;
n e t PB A<8> l o c=” p100 ” ;
n e t PB A<9> l o c=” p101 ” ;
n e t PB A<10> l o c=” p102 ” ;
n e t PB A<11> l o c=” p109 ” ;
n e t PB A<12> l o c=” p110 ” ;
n e t PB A<13> l o c=” p111 ” ;
n e t PB A<14> l o c=” p112 ” ;
n e t PB A<15> l o c=” p113 ” ;
n e t PB A<16> l o c=” p114 ” ;
n e t PB A<17> l o c=” p115 ” ;
n e t PB A<17> l o c=” p115 ” ;
n e t PB A<18> l o c=” p121 ” ;
n e t PB A<19> l o c=” p122 ” ;
# Audio Codec
n e t AU CSN l o c=” p165 ” ;
n e t AU MCLK l o c=” p167 ” ;
n e t AU LRCK l o c=” p168 ” ;
n e t AU BCLK l o c=” p166 ” ;
n e t AU SDTI l o c=” p169 ” ;
n e t AU SDTO0 l o c=” p173 ” ;
78