Electronics For You 08 2014.pdf

(33223 KB) Pobierz
Self Healing
Computers
Manufacturing
Flexible Electronics
Wireless
Charging
`
100
AUGUST 2014
For You
Security
Technologies & Solutions
DO-IT YOURSELF
>
Sequential Tilt-Motion Lock
>
Oscilloscope as Image Viewer
>
Mini Rechargeable Power Supply
>
Building Image Processing
Embedded Systems Using Python
>
Understanding Digital Camera
Histograms Using MATLAB
The Latest
Top 5
Vol. 3 No. 4
ISSN 0013-516X
TM
Pages: 150+8
UK £5; US $10
TM
TM
TM
+
Get
in.element14.com/raspberrypi
in.element14.com/raspberrypi
in.element14.com/raspberrypi
in.element14.com/raspberrypi
Get yours today at element14:
Raspberry
for your money
Get yours today at element14:
Raspberry
for your money
element14:
Raspberry
for your
at
in.element14.com/raspberrypi
yours today
money
Get yours today at element14:
Get yours today at element14:
Juicy fruit... get more
Raspberry
get more
Juicy fruit... get more
Juicy fruit... get more
money
Juicy fruit...
for your
® Raspberry Pi is a trademark of the Raspberry Pi Foundation
Plus, many more make your own projects inside
in-sales@element14.com | 1800 3000 3888 (Toll free)
® Raspberry Pi
a trademark of the Raspberry Pi Foundation
@element14.com
is a trademark of the Raspberry Pi Foundation
|
1800 3000 3888 | (Toll free)free)
in-sales@element14.com | 1800 3000 3888 (Toll free)
in-sales@element14.com | 1800 3000 3888 (Toll free)
®® Raspberry Pi is a trademark of the Raspberry Pi Foundation
Raspberry Pi is
in-sales@element14.com
1800 3000 3888 (Toll
with the
NEW
Model B+
with the
NEW
Model B+
with the
NEW
Model B+
with the
NEW
Model B+
EFY Plus
DVD
Create Virtual CPUs
Using
CPU Sim
CPU Sim is a software that lets you create CPU architectures of your choice,
create and edit assembly languages, and run them on the simulated CPU using
machine language
U
AnAghA P.
nderstanding the concepts of
computer organisation and
architecture is difficult by just
reading about it. Hands-on experience
is required to fully grasp the subject.
Unfortunately, providing this experi-
ence can be difficult due to the lack of
availability and high cost in setting up
labs with necessary hardware. Moreo-
ver, the time required by the users to
familiarise with the tools for working
with hardware is also significant. In
order to solve this problem, some cen-
tral processing unit (CPU) simulator
programs were developed. But most
of these software packages could simu-
late only fixed architectures.
Why you should learn
to use CPU Sim
The idea that you should have ex-
posure to as many different archi-
tectures as possible and hands-on
experience to design your very own
simple architectures is what led to
the development of CPU Sim. It is an
interactive simulator that allows you
to understand computer architectures
and organisations, design your own
architectures from scratch, or mod-
ify the given architectures. You can
write the programs using machine
language or Assembly language and
run them on the virtual CPU. You can
also specify details of the CPU to be
simulated, such as register set, micro-
instruction set, machine instruction
set, memory and Assembly language
instructions. The software was based
www.efymag.com
Main window
on STARTLE simulator developed
by JM Kerridge of the University of
Sheffield.
struction fetch, decode
and execution
5. Instruction types
(data manipulation,
memory architecture, reg-
isters, interrupt, control,
external I/O)
6. Instruction formats
7. Assembly language
programming and ma-
chine language program-
ming
8. Addressing modes
of CPU
9. Main memory or-
ganisation and operations
Understanding and
using CPU Sim does not
require in-depth knowl-
edge of a high-level lan-
guage, but an apprecia-
tion of concepts involved
in high-level language
programming is an advantage.
What you can do with it
CPU Sim is a complete development
environment. This software allows
creating or modifying a simulated
CPU including units such as registers,
microinstructions, machine instruc-
tions and RAM, and specifying its
features.
You can create, edit and execute
Assembly language programs for this
virtually created CPU. It has built-
in features and dialogue boxes that
help you design CPU architecture,
text editor where you can write and
edit the Assembly language program,
assembler and separate displays for
electronics for you Plus | august 2014
What the user gets
By using CPU Sim, you can get hands-
on experience on the following subjects
of computer organisation and archi-
tecture:
1. Representation of numeric data
and their number bases
2. Non-numeric data representation
3. Microprogrammed realisation
of the CPU (where control signals are
generated by a microcode/micropro-
gram stored in the control read-only
memory)
4. Operation of control unit: in-
i
EFY Plus
DVD
CPU Sim Facts
License type
Author
Freeware
Dale Skrien, Department of
Computer Science, Colby
College
Windows, Linux, OSX
CPU Sim 3.9.0
7.9 MB
Java runtime environment
(JRE) 1.5 or later
Installation
1. Confirm that Java runtime environment (JRE) 1.5 is installed in the computer. If not,
download it (free) from http://java.sun.com/ (Java comes installed with OSX)
2. If necessary, fix your Path system variable so that it includes the directory installed
with Java, in which the Java interpreter application is located. (Not required for OSX)
3. Unzip CPUSim3.9.0.zip file, which produces two folders, CPUSim3.9.0 and
MACOSX
4. Start CPU Sim
Windows:
In the folder CPUSim3.9.0, double click on the batch file CPUSim.bat and
the program opens automatically. If a window Wombat1 does not open, check again if you
have the suitable version of JRE installed in your computer.
OSX:
To install the English language version of CPU Sim, double-click on
CPUSim3.9.0.app. For Chinese version, double-click on CPUSim3.9.0.Chinese.app file.
Linux (or for those who prefer using Command Prompt/Terminal Window):
1. Open the command prompt or terminal window and navigate to the folder
CPUSim3.9.0.
2. Type the following commands for their respective operating system, in a single line:
For Windows:
java -cp CPUSim3.9.jar;jhall.jar;CPUSimHelp3.9.jar cpusim.Main
For OSX and Linux:
java -cp CPUSim3.9.jar:jhall.jar:CPUSimHelp3.9.jar cpusim.Main
3. The following four additional optional arguments can be added to the command
line, in any order:
-m <machine file name>
-t <text (assembly program) file name>
-l <language>
-c
The -m flag is used to indicate the machine file to be loaded into CPU Sim during start
up. If a text file is specified using -t flag, that file is opened during start up. The language
for display menus and dialogues can be indicated by the -l file (-l English or -l Chinese).
If -l file is not specified, it opens in the default English language. The -c flag (which can
be used only together with -t and -m flags) indicates that the Java Swing GUI should not
be used, and the corresponding text file and machine file will be loaded and run from the
command line. The -p flag is used to specify property files (files that contain information
like the preferred fonts, register, RAM windows, and recently opened machine and text
files) and is used to load them into CPU Sim during start up.
easy user interface and appealing
view are additional advantages.
Operating system
Latest version
Disk space
Other
requirement(s)
viewing RAM and registers during
execution.
It has several features that make
debugging easier. For instance, you
can execute the assembled programs
either continuously or step-by-step.
It allows inspecting or changing any
of the values in the register or RAM
windows and resuming execution or
stepping forward or backward during
the execution. If an error is detected
during assembling in the program
to be run, it is highlighted in the text
editor.
What makes it special
The architecture of CPU Sim is de-
signed at register-transfer level. This
means the basic units of the hypotheti-
cal CPU are registers, condition bits
and memory (RAM). The user does
not have to deal with logic gates or
transistors on the digital logic level of
the machine.
CPU Sim is developed purely us-
ing Java Swing package. This makes
the program run on any computer
with Java runtime environment (JRE)
installed in it, irrespective of the plat-
form (Windows, Linux or OSX) it runs
on.
When you start CPU Sim, the win-
dow comes with a loaded hypothetical
CPU known as Wombat1. Here you
can assemble and run a program for
that architecture. You can also create a
new virtual CPU from scratch by going
to File > New Machine.
Support
CPU Sim has a very comprehen-
sive help guide provided in the
menu bar (Help > General CPU
Sim Help). The installation pack-
age also contains a PDF document
(CPUSim3.4UserManual.pdf) that
explains how various functions are
performed using this software. It
also includes tutorials with sample
assignments that can be run on CPU
Sim. Questions and comments can be
directly sent to the author Dale Skrien
by e-mail. Visit CPU Sim home page
www.cs.colby.edu/djskrien/CPUSim
for details.
The author is a technical correspondent at EFY
www.efymag.com
Sample assembly language
Why CPU Sim
XSIM Computer Simulator, DLX Simu-
lator, HiRISC Simulator, Simple Com-
puter Emulator and TOM (Thoroughly
ii
august 2014 | electronics for you Plus
Obedient Moron) Computer Simulator
are some of the CPU simulator tools
we found online that have features
similar to CPU Sim. Though most of
these are available for free, they lack
many of the features available in CPU
Sim. This software is simple enough
for self-learning and to work with, yet
rich enough to thoroughly understand
the concepts and build on them. An
EFY Plus
DVD
Simulate Your PIC
Microcontroller Using
gpsim
In this article, we explore the features and advantages of gpsim by analysing
the step-by-step procedure to simulate PIC microcontroller using this tool.
gpsim is available for Linux operating system on the DVD accompanying this
month’s issue of EFY Plus
g
Sneha aMbaStha
psim is a free software simula-
tion tool for PIC microcontrollers
from Microchip, which has been
designed to be fast enough to simulate
PICs at a speed of about 20MHz. Its
accurate design makes it comparable to
using a real PIC microcontroller from
the core to the I/O pins and even all
the internal peripherals.
of PIC to share a relationship. By be-
ing designed to support all the three
families of PIC (12-bit core, 14-bit core
and 16-bit core), this tool eliminates
the need of a different simulator for a
different core. gpsim’s accuracy allows
it to test the PIC in the same way as it
would be in a real world.
Why use this tool
Currently, there are so many software
simulators available for PIC that it
Why it is noteworthy
It is mostly written in C++, which ena-
bles it to easily implement a hierarchi-
cal model of a PIC. This in turn enables
it to use the inheritance property of
C++, which allows the various models
Three important functions
1. Complex debugging with in-circuit
emulators
2. Provides a means to access virtual
functions like execute and name
3. Sets read and write break points on
values
Fig. 1: Register reviewer
Competitors to gpsim
Real PIC Simulator
PICsim
Oshon Simulator
PIC Development Studio
System requirements
1. No minimum hardware requirement
2. Two packages, readline and gtk (the
gimp tool kit), are pre-installed in a
Linux distribution like Ubuntu
3. Utility package, gputils
Fig. 2: Source browser
becomes obvious for engineers to ask:
Why use gpsim? A simple answer
to this is that, being a free and open
source software, unlike most of its
serious competition, gpsim enjoys the
FOSS community support.
gpsim has the following benefits
that make it superior to all the other
simulators available in the market:
Easy debugging with three-control
option.
gpsim is capable of being con-
trolled from either a graphical user
interface (GUI) by a remote process
or by a command line interface (CLI).
Although the tool is by default config-
ured for GUI, it can also be configured
for CLI and remote process later.
No hardware requirements.
gpsim
does not require any minimum hard-
ware specification and so can be built
and run on any popular Linux distri-
bution. Moreover, it is not limited to
Linux and has also been
ported to other operating
systems like Microsoft
Windows, BSD, MAC
and Solaris.
Supports loadable
modules.
This feature
enables gpsim to add all
other devices that are
totally separate from this
tool. It allows users to
customise a simulation
environment.
Allows easy inspec-
tion.
At times, a his-
tory or a trace of the work
helps inspect its current
status and to analyse the
electronics for you Plus | august 2014
www.efymag.com
iii
EFY Plus
DVD
How to compile and install
Since we have seen that some users find the installation to be a challenge, here are the steps to
extract and convert this tool into an executable file:
As discussed before, gpsim can be easily installed in Linux/Unix environment. However,
gpsim is available in compressed format and should be converted to an executable format for
installation:
1. Create a parent subdirectory for gpsim (example, gnupic)
$ mkdir ~/gnupic
(you can choose whatever directory name you like)
2. Copy the tar ball to this directory and expand it:
$ cd ~/gnupic
$ mv the_path_of_where_ever_the_tarball_is/gpsim-0.x.y.tar.gz .
$ tar -xvzf gpsim-0.x.y.tar.gz
(Where ‘x.y’ is the release number. As per the software in the DVD ‘x.y’ is ‘27.0’)
These commands will create a subdirectory called gpsim-0.x.y. All of gpsim’s source code
will be untarred here.
3. cd gpsim-0.x.y
4. ./configure
This will check your system for the proper tools necessary to build gpsim and then it will
create Makefiles.
5. make all
This will create the executable.
6. su root
Su or root privileges are required to complete the installation. If you don’t have root privileges
or don’t wish to install gpsim in the /usr/local/bin directory, check the steps on building without
root privileges.
7. make install
This copies the executable file into the /usr/local/bin subdirectory.
The last and final step is to install gpsim:
1. Use the following codes:
cd $HOME/compiling
tar xzvf gpsim-VERSION-tar.gz
cd gpsim-VERSION-
./configure --with-exdbm=$HOME/localinst/eXdbm --prefix=$HOME/localinst/gpsim
make install
cd $HOME
2. Edit your shell configuration and add something like:
export PATH=”$PATH”:$HOME/localinst/gpsim/bin
3. Re-login to let changes take effect.
As these files were only needed for compiling and installation, they can be removed. To
remove these files you can use the commands:
rm -rf $HOME/compiling/eXdbm
rm -rf $HOME/compiling/gpsim
rm -rf $HOME/compiling/gtk+extra
Use the following link to build and install gpsim on Windows: http://gpsim.sourceforge.net/
gpsimWin32/gpsimWin32.html
cause of the bugs. gpsim helps diag-
nose the bugs providing that history.
Additional benefits
through supportive tools
gpsim has the following supportive
tools that help it in simulation:
Register reviewer.
gpsim has two
similar register windows that provide
data for RAM and EEPROM. It allows
you to see all registers in the current
processor, with their display names
and values. The register viewer pro-
vides the following functions:
1. One can not only set read, write
and break point values but also clear
each break point on the registers
2. Writes and reads of specific data
can be logged in
3. Cells can be copied just by drag-
ging the borders of the selected cells
4. The content of one cell can be
copied to another cell
5. ‘Add watch’ allows one to watch
the register values
Source browser.
gpsim has two
source browsers: .asm and .obj. The
.asm is a colour-coded display of the
PIC source whereas the .obj provides
an opcode view. The opcode view has
memory cell on one line and informa-
tion related to disassembly, address
and hexadecimal value on the other.
Breadboard.
It not only allows one
to create/modify and examine the
PIC environment but also helps to in-
stantiate PIC processor from the com-
mand line or from .stc file. In simple
language, it helps in creating a correct
configuration to test the source code.
You can create code just by a click and
also connect to those nodes for a bet-
THE COMPLETE MAGAZINE ON OPEN SOURCE
Your favourite Magazine on Open
Source is now on the Web, too.
OpenSourceForU.com
Follow us on Twitter@LinuxForYou
iV
august 2014 | electronics for you Plus
www.efymag.com
Zgłoś jeśli naruszono regulamin