Altera Corporation 155
Section
3
MAX+PLUS II
Tutorial
This tutorial demonstrates the basic features of MAX+PLUS II.
Introduction............................................................................................. 156
Project Description....................................................................... 157
Tutorial Overview........................................................................ 160
Getting Help .................................................................................162
Design Entry
Session 1: Start a MAX+PLUS II Session .................................. 165
Session 2: Create a Graphic Design File.................................... 168
Session 3: Create Two Text Design Files................................... 185
Session 4: Create a Waveform Design File ............................... 196
Session 5: Create the Top-Level Graphic Design File ............. 210
Project Processing
Session 6: Compile the Project.................................................... 216
Session 7: View the Project in the Hierarchy Display............. 229
Session 8: View the Fit in the Floorplan Editor........................ 231
Project Verification
Simulation Overview................................................................... 242
Session 9: Create a Simulator Channel File .............................. 245
Session 10: Simulate the Project ................................................. 255
Session 11: Analyze Simulation Outputs.................................. 261
Session 12: Analyze Timing........................................................ 266
Device Programming
Session 13: Program an Altera Device ...................................... 273
Are We There Yet?.................................................................................. 276
81_GSBOOK.fm5 Page 155 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
156 Altera Corporation
Introduction
MAX+PLUS II is easyÑeasy to learn, easy to use, and very easy to like. This
tutorial introduces you to the basic features of the fully integrated
MAX+PLUS II design environment, so youÕll be able to create your own
logic designs in record time. Once you start using MAX+PLUS II, the on-line
help (always just a mouse-click away) can fill in all the details.
In this tutorial, you will create a design (called a ÒprojectÓ in MAX+PLUS II)
named chiptrip, a simple driving simulator. After you enter and compile the
chiptrip project, you will simulate it. In the simulation sessions, you will
guide your ÒvehicleÓ through an imaginary street map. Your challenge will
be to drive from your company to Altera using the most direct route without
getting tickets from the police. Once you finish the simulation task, your
final step will be to program your completed project into an Altera device.
81_GSBOOK.fm5 Page 156 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 157
The tutorial is divided into four sections: creating the actual logic circuit,
compiling it, simulating it with multiple sets of inputs, and then
programming an Altera device. To accommodate your level of expertise and
to make sure that you experience some driving pleasure on the way
(remember FahrvergnŸgen?), all files for this project are provided in the
\max2work\chiptrip directory. Thus, you can choose to go through every
single step of the tutorial or take one or more shortcuts by copying the ready-
made files to your working directory. Since the tutorial is divided into
logical chunks, you can stop at any time and continue later. Have a good
trip!
Project Description
The chiptrip tutorial takes you through all major steps of design entry,
compilation, simulation, and programming for a hierarchical project.
Design Entry & Project Processing
You will create five design files using text, graphic, and waveform design
entry. This tutorial describes a Òbottom-upÓ hierarchical design entry
method, in which you create the lower-level designs first and then combine
them in a single top-level design file to create the chiptrip project. A project
consists of all files associated with a particular design, including all
subdesign files and ancillary files; the project name is always the same as the
name of the top-level design file, without the filename extension. In the
chiptrip project, the top-level Graphic Design File (.gdf), chiptrip.gdf,
incorporates four lower-level design filesÑa GDF, two Text Design
Files (.tdf), and a Waveform Design File (.wdf). Each lower-level file
performs a specific function in the driving simulation game:
The tick_cnt.gdf file, your Òdriving record,Ó counts the number of
police citations you collect as you drive. This counter adds up the
number of tickets issued for ÒillegalÓ speeds in auto_max.tdf and
speed_ch.wdf.
The time_cnt.tdf file, the ÒclockÓ in your car, counts the number of
clock pulses required for the vehicle to reach Altera.
The auto_max.tdf file, your Òautomobile,Ó contains a state machine
that monitors the direction and acceleration inputs to the project and
determines the next location (i.e., state) of the vehicle.
81_GSBOOK.fm5 Page 157 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
158 Altera Corporation
The speed_ch.wdf file, your Òspeedometer,Ó is a state machine that
checks the acceleration of the vehicle. Illegal speeds result in a
speeding ticket.
1If you have not purchased the waveform design entry feature for
MAX+PLUS II, you can use a TDF version of the speed_ch.wdf
file, called speed_ch.tdf. This file is available in the
\max2work\chiptrip subdirectory.
Figure 3-1 shows a block diagram of the chiptrip project:
Figure 3-1. Block Diagram of chiptrip
After you have created the design files, you must successfully compile your
project to generate the files you need to simulate chiptrip and program a
device.
chiptrip.gdf
tick_cnt.gdf time_cnt.tdf auto_max.tdf
8count.gdf
speed_ch.wdf
81_GSBOOK.fm5 Page 158 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 159
Project Verification & Device Programming
The simulation portion of the tutorial is a driving game. The game tests your
ability to plan and modify your simulation inputs to complete a specific task.
Your goal is to navigate your vehicle through different intersections on a
map (shown in Figure 3-2) to arrive at Altera as fast as you can and with as
few speeding tickets as possible. Depending on how you edit your
simulation inputs, you can maneuver your car along expressways,
commercial roads, or residential streets.
Figure 3-2. Map to Altera
On expressways, you can go as fast as you like without worrying about any
police officers stopping you. On commercial roads, you can accelerate once
without getting a speeding ticket, but you will definitely get caught the
second time. If you accelerate at all on residential streets, however, you will
get a ticket right away. Just remember, in this design logic universe, police
officers are everywhere, they always know when you are speeding, and you
canÕt talk them out of giving you a ticket.
After you practice simulating your project with multiple sets of input
vectors and analyzing its timing to your satisfaction, you can then program
the chiptrip project into an Altera device.
YC
RPT
MPLD
EPLD
GDF CNF
EPM
Your Company
Residential Street:
Normal speed
only; any acceleration results in a
speeding ticket.
Commercial Road:
Accelerating
for two Clock cycles results in a
ticket. Clock cycles can be non-
consecutive.
Expressway:
Any number of
accelerations is allowed.
81_GSBOOK.fm5 Page 159 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
160 Altera Corporation
Tutorial Overview
The chiptrip tutorial is designed to help you become an expert
MAX+PLUS II user quickly and easily. The tutorial is modular, so you can
complete the sessions at your own pace; work through one session at a time,
or the whole tutorial in one sitting. You can also adapt the tutorial to your
level of expertise. For example, if you feel comfortable with the various
design entry methods, you can skip one or more of the sessions and move
straight on to compiling and simulating your project. In addition, Sessions 5
and 9 introduce you to command shortcuts that can help you develop more
efficient design entry skills.
Tutorial Files
All tutorial files are copied to your hard disk during MAX+PLUS II
installation. The MAX+PLUS II working directory, which has the default
name \max2work, contains the chiptrip and tutorial subdirectories. The
\max2work\chiptrip subdirectory contains all design files, as well as user-
and MAX+PLUS II-generated files for this tutorial. To prevent changes to
the original files, you should create your project in the \max2work\tutorial
subdirectory. If you do not wish to create an entire design file from scratch,
you can simply copy the desired file from the \max2work\chiptrip
subdirectory into the \max2work\tutorial subdirectory without running
the risk of accidentally overwriting the original tutorial files installed on
your hard disk. You can copy files with the appropriate copying command
for your operating system, or open a file in MAX+PLUS II and choose Save
As (File menu) to save a copy of the file in a different directory.
11. Be sure to refer to the read.me file in the
\max2work\tutorial directory for information on changes
to the chiptrip tutorial since this manual was printed.
2. On a UNIX workstation, the max2work directory is a
subdirectory of the /usr directory.
Command Shortcuts
Many MAX+PLUS II commands have a variety of shortcuts. These shortcuts
are often context-sensitive, that is, the options available depend on the
position of the mouse pointer or on the item(s) selected on screen. Although
you can use shortcuts at any stage of the tutorial process, Sessions 5 and 9
provide you with specific alternative steps to help speed up design entry.
81_GSBOOK.fm5 Page 160 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 161
You can experiment with these shortcuts and determine which one(s) you
prefer. The shortcuts will help you develop an efficient and personalized
method for working with the MAX+PLUS II software.
1The ÒShortcutsÓ section of MAX+PLUS II Help for each
application lists all Button 1, keyboard, and toolbar/tool palette
shortcuts.
Shortcut Method: Description:
Button 1 shortcuts, which are executed by double-
clicking, are context-sensitive. For example, in the
Graphic Editor, you can open the Enter Symbol
dialog box by simply double-clicking Button 1 in a
blank space in the window. In contrast, double-
clicking Button 1 on a macrofunction symbol opens
the macrofunction that the symbol represents.
Button 1 corresponds to the left button on a two- or
three-button mouse.
Button 2 shortcuts, which are executed by clicking to
display a pop-up menu, are also context-sensitive.
These shortcuts allow you to execute a task by
pointing to a selection, pressing Button 2, and
choosing a command as you work. For instance, you
can cut a selected object or a section of text out of a file
by clicking Button 2 on the selected item and choosing
Cut from the pop-up menu. Button 2 corresponds to
the right button on a two-button mouse or the middle
and right buttons on a three-button mouse.
Keyboard shortcuts allow you to perform a task
instantly. For example, typing Ctrl+P is a keyboard
shortcut for the Print command. Keyboard shortcuts
are listed in the pull-down menus and in
MAX+PLUS II Help.
Toolbar and tool palette shortcut buttons are available
on the top and left sides of the window. For example,
choosing the Zoom In button on the tool palette is a
shortcut for the Zoom In command.
Mouse Button 1
1
Mouse Button 2
2
Keyboard
A
Toolbar/Palette
81_GSBOOK.fm5 Page 161 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
162 Altera Corporation
Getting Help
Throughout the tutorial, you can follow the footprints ( f ) for useful
references to MAX+PLUS II Help. On-line help provides the most up-to-
date and complete information on all MAX+PLUS II features. Two of the
easiest ways to get on-line help are by using the context-sensitive help
feature and the search index.
Context-Sensitive Help
Context-sensitive help gives you instant help when you need it. You can
access context-sensitive help in three ways:
Method: Description:
Shift+F1 or the context-sensitive
help toolbar button h
Position the question-mark pointer
over an item on the screen, a text file
keyword, or a menu command, then
click Button 1 on it to obtain help.
F1 key When a menu command is
highlighted, a dialog box is open, or
a pop-up message box is displayed,
press F1 to obtain help. You can also
press F1 when any MAX+PLUS II
application window is displayed to
obtain general information about
the context-sensitive help available
for that application.
Help on Message button In the Message Processor window,
you can select a message with
Button 1 and choose the Help on
Message button to display help on
that message.
81_GSBOOK.fm5 Page 162 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 163
Search Index
MAX+PLUS II Help includes an extensive on-line index to help you find
information fast. To search for a Help topic:
1. If you are in MAX+PLUS II, choose Search for Help on (Help menu).
or:
If you are already in Help, choose the Index button at the top of the
Help window (called Search in Windows NT 3.51).
The Help Topics dialog box is displayed. (In Windows NT 3.51, the
Search dialog box, which functions in a similar manner, appears
instead of the Help Topics dialog box.)
2. Type a keyword or phrase. The keyword list scrolls to display the
keywords that match the text you type, as shown in the following
illustration:
81_GSBOOK.fm5 Page 163 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
164 Altera Corporation
3. Click Button 1 on a keyword to select it and choose the Display button
or double-click Button 1 on the keyword to go to the topic associated
with the keyword. If multiple topics exist, they are displayed in the
Topics Found dialog box, as shown in the following illustration:
4. Select a topic name from the list and choose the Display button or
double-click Button 1 on a topic name to display the topic.
81_GSBOOK.fm5 Page 164 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 165
Session 1: Start a MAX+PLUS II Session
In this session, you will start MAX+PLUS II to begin creating your project.
1This tutorial assumes that the MAX+PLUS II working directory,
which has the default name \max2work, appears on the d: drive
on your computer. If you installed the MAX+PLUS II working
directory in a different drive and/or directory, substitute the
appropriate drive and/or directory name.
To start MAX+PLUS II:
1. Double-click Button 1 on the MAX+PLUS II icon. On a PC running
Windows, this icon appears in the MAX+PLUS II program group in
the Program Manager window.
or:
Type maxplus2 9 at the command line.
The MAX+PLUS II Manager window opens. The title bar displays the
name of the program (MAX+PLUS II), and a drive and directory name
(d:\max2work\tutorial). The current project name, chiptrip, is
appended to the drive and directory names.
81_GSBOOK.fm5 Page 165 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
166 Altera Corporation
See the following illustration:
All MAX+PLUS II applications contain a toolbar and status bar which
you can turn on and off using the Preferences command (Options
menu).
2. To turn the toolbar and status bar on and off:
a. Choose Preferences from the Options menu. The Preferences
dialog box is displayed.
b. Turn the Show Toolbar and/or Show Status Bar options on or off
by clicking Button 1 on their checkboxes.
c. Choose OK.
Toolbar
Status bar
Application box (shown as an
icon in some operating systems) Title bar displays program name,
drive, directory, and project name. Maximize
button
Tool palette
(not used in all
applications)
81_GSBOOK.fm5 Page 166 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 167
The toolbar displays buttons and drop-down list boxes that provide
quick access to frequently used commands. (Additional buttons are
available on the tool palette in some applications.) The status bar
provides a brief description of a highlighted menu command or an
item in the toolbar or tool palette when you move the mouse pointer
over it.
1In some MAX+PLUS II applications, items on the far right
of the toolbar are unavailable if your monitor is set to VGA
display mode. All toolbar buttons and drop-down lists are
available in larger screen displays.
If you wish, you can switch to an alternate combination of
toolbar buttons for VGA displays. Go to ÒSetting
MAX+PLUS II PreferencesÓ using Search for Help on (Help
menu) for instructions.
3. Maximize the MAX+PLUS II window by clicking Button 1 on the
Maximize button, as shown in the illustration on page 166.
1If you wish to exit MAX+PLUS II, choose Exit
MAX+PLUS II (File menu) or double-click Button 1 on the
application icon (or box) in the top left corner of the
MAX+PLUS II window, as shown in the illustration on
page 166.
81_GSBOOK.fm5 Page 167 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
168 Altera Corporation
Session 2: Create a Graphic Design File
In this session, you will specify the project name and use the MAX+PLUS II
Graphic Editor to enter and save tick_cnt.gdf, which counts the number of
speeding tickets you collect during your trip. This session includes the
following steps:
1. Create a new file.
2. Specify the project name.
3. Select a palette tool.
4. Enter logic function symbols.
5. Set and show guidelines.
6. Move a symbol.
7. Enter input and output pins.
8. Name the pins.
9. Connect the symbols.
10. Connect nodes and buses by name.
11. Save the file and check for basic errors.
12. Create a default symbol.
13. Close the file.
1Remember, all files for the chiptrip tutorial are available in the
\max2work\chiptrip subdirectory.
1. Create a New File
In this step, you will create a new GDF called tick_cnt.gdf.
To create the file:
1. Choose New (File menu). The New dialog box is displayed.
2. Select Graphic Editor file.
3. Select the .gdf filename extension in the drop-down list box.
4. Choose OK.
An untitled Graphic Editor window opens, as shown in the following
illustration:
81_GSBOOK.fm5 Page 168 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 169
5. If necessary, maximize the Graphic Editor window by clicking
Button 1 on the Maximize button in the Graphic Editor title bar.
6. To save the file, choose Save As (File menu). The Save As dialog box
is displayed, as shown in the following illustration:
Workspace Maximize button
Selection tool
Circle tool
Toggle Connection
Dot button
Diagonal Line tool
Rubberbanding On
button Rubberbanding Off
button
Arc tool
Zoom In button Zoom Out button
Fit in Window
button
Orthogonal Line
tool
Text tool
Specifies the name
of the file.
Displays the default
extension for the
current file type. You
can select a different
extension from the
drop-down list.
81_GSBOOK.fm5 Page 169 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
170 Altera Corporation
7. Type tick_cnt.gdf in the File Name box.
8. If \max2work\tutorial does not appear in the Directory is field as the
current directory, select it in the Directories box.
9. Choose OK to save the tick_cnt.gdf file.
2. Specify the Project Name
In MAX+PLUS II, you must specify a design file as your current project
before you can compile it or perform any other batch processing such as
simulation. MAX+PLUS II processes one project at a time, and you must
ensure that all design files in a project appear in that projectÕs hierarchy. You
should always create a separate subdirectory for each new project. When
you enter the project name, you also specify the name of the subdirectory
where the project will be stored. If the subdirectory does not exist,
MAX+PLUS II can create it for you.
To specify the project name:
1. Choose Project Name (File menu). The Project Name dialog box is
displayed:
2. If necessary, turn off the Show Only Tops of Hierarchies option.
Lists all design
files and
programming
files in the
current
directory.
Shows current
project name.
Shows current
directory path.
Lists all
subdirectories.
Lists all local and
network drives.
81_GSBOOK.fm5 Page 170 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 171
3. Select tick_cnt.gdf in the Files box.
4. Choose OK.
The MAX+PLUS II title bar changes to display the new project name:
MAX+plus II Manager - d:\max2work\tutorial\tick_cnt
1As an alternative to using the Project Name command, you can
simply choose the Project Set Project to Current File command
(File menu) when tick_cnt.gdf is open in the active Graphic Editor
window.
3. Select a Palette Tool
In this step, you will select from the various palette tools available for the
Graphic Editor. In the Graphic, Symbol, and Waveform Editors, the pointer
changes shape, depending upon the current selected palette tool and the
object under the mouse pointer. The Selection tool, which has an arrow-
shaped pointer, is the default palette tool when you first open a Graphic
Editor window. As an exercise, you will select the Orthogonal Line tool from
the tool palette.
To select the Orthogonal Line tool from the palette:
vClick Button 1 on the Orthogonal Line tool, as shown in the
illustration on page 169.
The pointer changes into a +-shaped pointer if you select the Orthogonal,
Diagonal, Arc, or Circle tool. If you select the Text tool, the pointer is an
inverted ÒtÓ that changes into an I-shaped pointer when it passes over
editable text.
81_GSBOOK.fm5 Page 171 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
172 Altera Corporation
The Selection tool is a ÒsmartÓ tool. When this tool is selected, the arrow-
shaped Selection pointer automatically changes into the Orthogonal Line
drawing or Text Editing pointer when it passes over different objects in the
Graphic Editor window:
When the Selection pointer passes over the end of a line, a connection
dot, or a symbol pinstub, it changes into the +-shaped Orthogonal
Line drawing pointer, which allows you to draw lines and enter or
delete connection dots. This ÒsmartÓ behavior means that you need to
select a line drawing tool from the tool palette only if you wish to draw
lines in empty space.
When you double-click Button 1 on editable text, the Selection pointer
changes into the I-shaped Text Editing pointer, which allows you to
edit pin and node names, pin default values, and comments. This
ÒsmartÓ behavior means that you need to select the Text tool from the
tool palette only if you wish to enter text in empty space.
When the pointer passes over empty space, over the middle of a line
or symbol, or over text, the Selection pointer has normal selection
behavior, which allows you to select, move, and copy objects in the
window.
4. Enter Logic Function Symbols
MAX+PLUS II provides symbols for a variety of logic functionsÑincluding
primitive, megafunction, and macrofunction symbolsÑthat you can use in
your Graphic Editor files.
To enter a symbol:
1. With the Selection pointer, click Button 1 in empty space in the
Graphic Editor window to define an insertion point and choose Enter
Symbol (Symbol menu).
81_GSBOOK.fm5 Page 172 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 173
The Enter Symbol dialog box is displayed:
SHORTCUTS Double-clicking Button 1 in a blank space in the Graphic Editor
window is a shortcut for this step. This action both defines an insertion
point and opens the Enter Symbol dialog box.
1Command shortcuts are described in more detail in
Sessions 5 and 9 of this tutorial.
2. Type 8count in the Symbol Name box.
3. Choose OK. The 8count symbol is entered with its top left corner at
the insertion point. The 8count macrofunction is an 8-bit up/down
binary counter. In tick_cnt.gdf, four bits of the 8count macrofunction
will be used to count the number of tickets received by the driver.
4. Repeat steps 1 through 3 to enter the NOR2 and GND primitives to the
left of the 8count symbol.
1MAX+PLUS II documentation conventions use all capital
letters for primitive names. However, you should type all
primitive, megafunction, and macrofunction names with
lowercase letters in the Enter Symbol dialog box.
Specifies the name of a
symbol to be entered in
your file.
Double-clicking Button 1
on a symbol library
directory lists its
contents in the Symbol
Files box. MAX+PLUS II
automatically searches
each listed directory for
a symbol when you type
a symbol name in the
Symbol Name box and
choose OK.
Lists all
symbols in
the current
directory.
81_GSBOOK.fm5 Page 173 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
174 Altera Corporation
See the following illustration:
1If you enter or move two symbols so that their borders and
pinstubs touch, the symbols become logically connected. If you
then move one of the symbols when Rubberbanding (Options
menu) is turned on, a new node or bus line forms automatically
between the connected pinstubs of the two symbols.
fChoose h from the toolbar and click Button 1 on the 8count, NOR2, or GND
symbols for information on each. On-line help provides complete
information on all Altera-provided primitives, megafunctions, and
macrofunctions.
You can also get help on megafunctions, primitives, and macrofunctions by
choosing Megafunctions/LPM, Primitives, or Old-Style Macrofunctions,
respectively, from the Help menu.
5. Set & Show Guidelines
To increase the readability of your schematic, you can align symbols to
horizontal and vertical guidelines. You can specify the guideline spacing
and display or hide the guidelines.
Rubberbanding
On button Rubberbanding
Off button
81_GSBOOK.fm5 Page 174 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 175
To set the spacing and show the guidelines:
1. Choose Guideline Spacing from the Options menu. The Guideline
Spacing dialog box is displayed.
2. Type 15 in both the X (Horizontal) Spacing and Y (Vertical) Spacing
boxes to specify 15 grid-unit spacing between guidelines.
3. Choose OK.
4. Turn on Show Guidelines (Options menu). When the command is
turned on, a checkmark appears next to the command name in the
menu. The guidelines appear as shown in the following illustration:
1As you edit your schematic, you can change the window display
to view larger or smaller portions of the file by choosing the
Zoom In, Zoom Out, and Fit in Window buttons on the tool
palette, as shown in the previous illustration.
Guidelines spaced
15 grid units apart.
Zoom In button
Fit in Window
button
Zoom Out Button
81_GSBOOK.fm5 Page 175 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
176 Altera Corporation
6. Move a Symbol
To move and align the 8count symbol:
1. With the Selection pointer, press or click Button 1 on 8count to select
the symbol.
2. While pressing Button 1, drag the symbol and position the top left
corner of 8count at the closest guideline intersection. An outline of
the symbol moves with the pointer so that you can position it
accurately.
3. Once the symbol is in position, release Button 1.
1You can move any symbol, graphic, or block of text that can be
selected with Button 1 in the MAX+PLUS II Graphic or Symbol
Editor by dragging it with the Selection pointer.
fGo to ÒMoving an ObjectÓ and ÒSelecting an ObjectÓ using Search for Help
on (Help menu).
7. Enter Input & Output Pins
To enter the INPUT and OUTPUT pins:
1. With the Selection pointer, double-click Button 1 in an empty space to
the left of the 8count symbol to open the Enter Symbol dialog box,
type input in the Symbol Name box, and choose OK. The INPUT pin
symbol is displayed.
2. Press Ctrl and then press Button 1 on the INPUT symbol. While
holding Ctrl and Button 1 down, drag the mouse down to create a
copy of the symbol and place it below the original. (The symbol is
copied but not placed on the Clipboard.)
3. Repeat step 2 to create the third INPUT symbol.
4. Repeat step 1 to enter the OUTPUT symbol below the 8count symbol.
81_GSBOOK.fm5 Page 176 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 177
See the following illustration:
A symbol identification number is located at the bottom left corner of each
symbol. It is automatically assigned based on the order in which you enter
the symbols (i.e., the first symbol entered is assigned the ID number 1). It
uniquely identifies each instance of a symbol within the GDF. The symbol
ID numbers in your file may differ from those in the illustrations, depending
on the order in which you enter the symbols. However, these differences will
not cause any errors.
8. Name the Pins
You will now name the input and output pins. Symbols in this procedure are
identified as <symbol name>:<symbol ID>, e.g., INPUT:4 is the INPUT
symbol with the symbol ID number 4, as entered in the previous step.
1If you did not enter the symbols in the described sequence, your
symbol ID numbers will differ from those in the illustration. These
differences will not cause any errors.
Each symbol has
an ID number
that uniquely
identifies it.
These ID
numbers are
based on the
order in which
symbols are
entered.
4
5
6
7 12 3
81_GSBOOK.fm5 Page 177 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
178 Altera Corporation
To assign a pin name:
1. With the Selection pointer, double-click Button 1 on the default pin
name ÒPIN_NAMEÓ of INPUT:4 to select the entire name.
2. Type get_ticket1. The new name replaces the default pin name.
The get_ticket1 signal will be used to enable the counter. When it
goes high, the count value will increment by one.
1You can also use the Text tool to edit and enter text. Double-
click Button 1 to select the entire name, or drag Button 1 to
select a portion of the name you wish to edit.
3. Rename the remaining INPUT and OUTPUT pins as shown in the
following list. If you press 9 after you edit a pin name, the next pin
name below it is automatically selected for editing.
Primitive: Name: Description:
INPUT:5 get_ticket2 Same as get_ticket1.
INPUT:6 clk This signal is the Clock for the
tick_cnt.gdf counter.
OUTPUT:7 ticket[3..0] These signals represent the counter
bit outputs. The name is given in
single-range bus name format,
which is used to create an array of
four output pins. In this case,
ticket[3..0] is the bus that
represents the pins ticket3,
ticket2, ticket1, and ticket0.
81_GSBOOK.fm5 Page 178 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 179
See the following illustration:
fGo to ÒPin & Node NamesÓ and ÒBus NamesÓ using Search for Help on
(Help menu).
9. Connect the Symbols
You can use the ÒsmartÓ Selection tool to draw most of the lines you need to
connect symbols in a Graphic Editor fileÑthe Selection pointer
automatically turns into the Orthogonal Line drawing pointer when it is
over a pinstub or connection dot, or at the end of a line. You can also use the
Orthogonal and Diagonal Line tools to connect symbols.
To draw a line:
1. With the Selection pointer, move symbols so they line up with the
appropriate pinstubs or other symbols, as shown in the preceding
illustration.
2. Choose the solid line style from the top of the Line Style submenu
(Options menu). This line style is the recommended line style for
nodes.
81_GSBOOK.fm5 Page 179 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
180 Altera Corporation
3. Point to the output pinstub of the get_ticket1 input pin. The
Selection pointer turns into the +-shaped Orthogonal Line drawing
pointer when it is close to the pinstub.
4. Press Button 1 to define the start of a line.
5. While pressing Button 1, drag the mouse to draw a line that connects
to the uppermost input pinstub on the NOR2 gate.
6. Release Button 1.
1With the Orthogonal Line drawing pointer, you can draw
straight lines or lines with a single bend. If you cannot draw
a straight line or a line with a single bend to connect two
symbols, you must draw two lines to create the two bends
needed to make the connection. After you draw the first
line, draw a second line that connects to the end of the first.
Lines merge automatically if they have the same line style.
If you need to delete a line, click Button 1 on the line to select it and
press the Del or Backspace key.
7. Repeat steps 3 through 7 to connect the remaining symbols as shown
in the following table and in the illustration on page 181:
Draw Line From: To:
INPUT pin get_ticket2 NOR2 input
Output pinstub of NOR2 GN input of 8count
DNUP input of 8count GND
INPUT pin clk CLK input of 8count
QA output of 8count Next vertical guideline on the
right (i.e., draw line but do not
physically connect it to another
symbol)
QB output of 8count Same as QA
QC output of 8count Same as QA
QD output of 8count Same as QA
OUTPUT pin ticket[3..0] Next vertical guideline on the left,
as with QA
81_GSBOOK.fm5 Page 180 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 181
The line that extends from the ticket[3..0] output pin should be a bus
line. To change the line into a bus line:
1. Point to the line that extends from the output pin named
ticket[3..0] and click Button 1 to select the line.
2. Choose the bus line style, i.e., the thick line style, from the Line Style
submenu (Options menu).
See the following illustration:
fChoose h from the toolbar and click Button 1 on the bus line to go to
ÒBusesÓ in MAX+PLUS II Help.
Bus line Single-range bus
pin name creates
an array of 4 pins.
81_GSBOOK.fm5 Page 181 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
182 Altera Corporation
10. Connect Nodes & Buses by Name
You can connect the nodes (i.e., lines) that are attached to the output
pinstubs QA, QB, QC, and QD on the 8count symbol by name to the bus line
that is attached to the input of ticket[3..0]. Nodes and buses are
connected by assigning appropriate names to them; they need not be
physically connected. A logical connection exists only if each member of a
bus has the same name as one of the nodes. For example, to connect bus
b[1..0] (with members b1 and b0) to two nodes that are not physically
connected to the bus, you must name the nodes b1 and b0.
To assign names to the nodes and bus:
1. Change the text size and font to 10-point Arial font:
a. Choose Text Size (Options menu). If 10 is not checked on the
submenu, select it from the list of available text sizes.
b. Choose Font (Options menu). If Arial is not checked on the
submenu, select it from the list of available fonts.
2. With the Selection pointer, select the node that extends from the QA
pinstub of the 8count symbol by clicking Button 1 on the line. A small
square insertion point appears below the line to show the insertion
point for the name.
3. Type ticket0. The name appears above the line.
1If a name overlaps a symbol, you can move it to another
location on the node or bus line by simply dragging it to a
new position with Button 1 in the same way that you would
move a symbol. See Ò6. Move a SymbolÓ on page 176 for
more information.
4. Repeat steps 1 through 3 for the remaining nodes and the bus:
Pinstub/Pin Name: Node/Bus Name:
QB ticket1
QC ticket2
QD ticket3
ticket[3..0] ticket[3..0]
81_GSBOOK.fm5 Page 182 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 183
See the following illustration:
Once you have assigned these names, the nodes ticket3, ticket2,
ticket1, and ticket0 are automatically connected to the bus
ticket[3..0] by name, even though they are not physically connected.
11. Save the File & Check for Basic Errors
To ensure that you have entered the logic correctly, you can save the file and
check for simple errors.
To save the file and check for errors:
1. Choose Project Save & Check from the File menu. The file is saved
and the MAX+PLUS II Compiler window opens; the Compiler Netlist
Extractor module checks the file for errors, updates the Hierarchy
Display, and displays a message indicating the number of errors and
warnings.
2. If Project Save & Check is successful and there are no errors or
warnings, choose OK to close the message box.
Document
box
(shown as
an icon in
some
operating
systems)
81_GSBOOK.fm5 Page 183 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
184 Altera Corporation
1If the Compiler issues any error or warning messages and
the Message Processor window is not automatically
displayed, you can open it by choosing Message Processor
(MAX+PLUS II menu). Select a message in the Message
Processor window and choose Locate to find its source(s) or
choose Help on Message to get an explanation. See Ò10.
Locate the Source of a MessageÓ on page 226 for more
information. You should correct any errors in your design
file, and save and check it until it is error-free.
3. Double-click Button 1 on the document icon (or box), as shown in the
illustration on page 183, to close the Compiler window and return to
the Graphic Editor.
12. Create a Default Symbol
You will now create a Symbol File (.sym) that represents the current file. The
symbol in this file can be used in any other Graphic Design File (.gdf).
To create a default symbol:
vChoose Create Default Symbol (File menu). If a symbol for a Þle
already exists, MAX+PLUS II asks you whether it is OK to overwrite
the existing symbol. Choose OK to ensure that you have the most up-
to-date information in your Symbol File.
13. Close the File
To close the tick_cnt.gdf file:
vChoose Close from the File menu or double-click Button 1 on the
document icon (or box), as shown in the illustration on page 183. The
Graphic Editor window displaying the tick_cnt.gdf Þle closes
automatically.
81_GSBOOK.fm5 Page 184 Tuesday, October 14, 1997 4:04 PM
Section 3: MAX+PLUS II Tutorial
Altera Corporation 185
Session 3: Create Two Text Design Files
In this session, you will use the MAX+PLUS II Text Editor to enter and save
two Text Design Files (.tdf) written in the Altera Hardware Description
Language (AHDL). The first TDF, time_cnt.tdf, measures the time it takes
for your vehicle to reach Altera by counting Clock pulses. The auto_max.tdf
file describes the functions of the street_map state machine, and
determines the direction and acceleration of your automobile. This session
includes the following steps:
1. Create a new file and specify the project name.
2. Turn on syntax coloring.
3. Enter the design name, inputs, and outputs.
4. Declare a register.
5. Enter Boolean equations.
6. Enter an If Then Statement.
7. Check for syntax errors and create a default symbol.
8. Copy auto_max.tdf and create a default symbol.
fGo to MAX+PLUS II AHDL Help or the MAX+PLUS II AHDL manual for
more detailed information on AHDL. The on-line help and manual contain
the same information at the time of printing, but the on-line information is
always the most up-to-date. On-line help also has links to related help
topics, and pop-up examples and glossary definitions to help you find the
information you need as quickly as possible. You should use the manual as
a take-home reference and use on-line help when you are at your computer.
81_GSBOOK.fm5 Page 185 Tuesday, October 14, 1997 4:04 PM
MAX+PLUS II Getting Started
186 Altera Corporation
1. Create a New File & Specify the Project Name
In this step, you will create a new TDF called time_cnt.tdf in AHDL, and
name the project.
To specify the project name and create a new file:
1. Choose New (File menu), select Text Editor file, and choose OK to open
an untitled Text Editor window (see Ò1. Create a New FileÓ on
page 168).
2. If necessary, maximize the Text Editor window by clicking Button 1 on
the Maximize button in the top right corner of the Text Editor title bar.
3. Choose Save As (File menu). Type time_cnt.tdf in the File Name
box.
4. Make sure that \max2work\tutorial appears as the current directory
in the Directory is field. Choose OK to save the time_cnt.tdf file.
5. Choose Project Set Project to Current File or Project Name (File
menu) and change the project name to time_cnt (see Ò2. Specify the
Project NameÓ on page 170).
2. Turn on Syntax Coloring
To make sections of your TDF more visible, you can use the Text EditorÕs
Syntax Coloring command. Syntax coloring allows you to see the different
parts of a TDF in different colors. For example, keywords are displayed in
one color and comments are displayed in another, making them easier to
distinguish on screen.
To turn on syntax coloring:
vChoose Syntax Coloring (Options menu). When the command is
turned on, a checkmark appears next to the command name in the
menu.
81_GSBOOK.fm5 Page 186 Tuesday, October 14, 1997 4:04 PM