现代刑侦技术:Proteus仿真速度很慢的分析

来源:百度文库 编辑:偶看新闻 时间:2024/05/08 00:10:52
很多朋友在做Proteus硬件仿真的时候可能都碰上了仿真速度慢的问题,在点击了开始仿真之后,CPU过载,速度极慢,无法正常进行仿真;Proteus在信息栏提示CPU被使用情况,可能高达90%到100%,并没有按照真实速度仿真,点击信息栏中的提示信息就弹出一个对话框,说是 Simulation is not running in real time due to excessive CPUload,鼠标点击提示,会展开一个消息框,下面就是消息框内的内容:
This message has been generated because the simulation has been unable to keep up with real time for more than 20 consecutive simulation frames. This does not affect the accuracy of the simulation in any way, but it will mean that the simulated system may respond much more slowly to interactive events(e.g. push buttons).See Also:How to make simulations run faster?这里的说明中可以看到至少两个信息:第一,速度慢并不影响仿真精度;第二,我们可以点击最下方那句话打开另一个链接来加速仿真;那么,我们就继续按照提示来寻找答案。(也许我们的Proteus版本不同,这些链接打开顺序和方法可能不一样,我是用的是7.1的版本)点击 How to make simulations run faster?打开Proteus的帮助,进入一个英文界面,我把原文全部贴在这里,之后和你一起解读。ADVANCED TOPICS
HOW TO MAKE INTERACTIVE SIMULATIONS RUN FASTER
Introduction
Although Proteus VSM is able to run many interactive simulations in realtime, it should be fairly obvious that this cannot be the case for allcircuits. For example, it is perfectly possible to draw a circuit that willoscillate at 1GHz, but there is no way that this can be simulated in realtime on a computer that may not even execute one machine instruction in 1ns.In this section, we will explain in a little more detail what determines thecomplexity of a simulation and how you can optimize a circuit to maximize thesimulation speed.Using Digital Resistor and Diode ModelsFirst and foremost in this context, it is vital to understand the differencebetween analogue and digital simulation within ProSPICE. This is because thesimulation of digital circuitry is two or three orders of magnitude (i.e. upto 1000 times) faster than the simulation of analogue circuitry. It is forthis reason that ProSPICE contains a digital simulator at all - that byrepresenting the operation of digital components as an event driven process,a great deal of unnecessary computation can be avoided.For example, whilst a PC with 600MHz P3 processor can simulate around 2million digital events per second, the same computer will only be able tosimulate a sine wave generator running up to about 2kHz before the CPU loadreaches 100%. Such a waveform will require about 60,000 analogue timepointsto be computed per second, and each timepoint will require a convergentsolution of the circuit nodal equations to be established - a process vastlymore complex than processing a simple digital event.
For many components, it should be fairly intuitive as to whether analogue ordigital simulation will be required. For example, nearly all TTL and CMOSparts are represented by digital models, whereas analogue ICs such as op-amps, comparators and so forth are represented by analogue models. Allcomponents which are represented by standard SPICE models require analoguesimulation.However, a grey area arises for components which - though strictly analoguein nature - can be represented by a digital model for some purposes. Inparticular, diodes - and perhaps more surprisingly - resistors fall into this
category. This becomes highly relevant in the context of wire-or logic, pull
-up resistors, devices with open-collector outputs, and in diode-resistor
logic networks.
Example 1 - Wire-Or Logic
The following circuit section shows a typical wire-or logic network:

U1:A and U1:B have open-collector outputs and can only sink current. A logic
1 output level results in a high impedance condition. In terms of DSIM, this
means that the gate outputs drive either an SLO (strong low) or a FLT
(floating) logic state. Now if resistor R1 is modelled in the analogue
domain, PROSPICE must insert a digital to analogue interface object between
the logic gates and the resistor, and then an analogue to digital interface
object between the resistor and the input to U2:A. This will result in
wonderfully detailed simulation of the rise-fall waveforms at this node, and
the current flow through R1, but will also result in a great deal of
computation every time the output of U1:A or U1:B changes state.
All this can be avoided if R1 is modelled digitally. In this case, its
behaviour is to convert the SHI logic state of VCC to a WHI (weak high) logic
level. When either NAND gate pulls low, the SLO state overrides the WHI state
from the resistor and the net state is resolved to be logic low. But when
neither gate sinks current, the WHI state beats the FLT state and the net
rises to logic high. All this can be managed within the digital simulation
paradigm and no analogue simulation is required.
Therefore, pull up resistors of any kind should almost always be modelled
digitally.
Example 2 - Diode-Resistor Logic
Another case where seemingly analogue circuitry can be modelled in the
digital domain is diode-resistor networks of the sort shown below. These are
often found around keypad scanning circuitry where the diodes serve to
prevent short circuits between the row driving lines if more than more than
one key is depressed simultaneously.
As with the wire-or logic example, ProSPICE will quite happily model this in
the analogue domain but it will be computationally expensive. If a digital
resistor model is used as above, and a diode is seen as a device which will
pass only low logic level from cathode to anode and only a high logic level
from anode to cathode, then the whole network can once again be modelled
digitally.
Since keypad scanning routines tend to operate at some speed, and there are
often numerous diodes and resistors, this is a very important optimization to
be aware of.
How to Select the Digital Resistor Model
1.    Point at the resistor you wish to change and press CTRL-E.
2.    Click the Edit All Properties as Text checkbox.
3.    Change the PRIMITIVE property to read
       PRIMITIVE=DIGITAL,RESISTOR
If you are building a circuit from scratch, and know that you will want a
particular resistor to be modelled digitally, you can also achieve this by
picking the PULLUP or PULLDOWN models from the component library. This
devices already contains the PRIMITIVE property as above.
How to Select the Digital Diode Model
1.    Point at the diode you wish to change and press CTRL-E.
2.    Click the Edit All Properties as Text checkbox.
3.    Change the PRIMITIVE property to read
       PRIMITIVE=DIGITAL,DIODE
4.    Delete any MODEL property, as SPICE parameters have no meaning for the
digital diode model.
If you are building a circuit from scratch, and know that you will want a
particular diode to be modelled digitally, you can also achieve this by
picking the DIODE-DIGITAL device the component library. This device already
contains the PRIMITIVE property as above.
Optimizing Memory Accesses to External RAM and ROM
Many larger microprocessor designs make use of ROM, RAM or EEPROM memory
devices external to the microcontroller itself. These may store the program
code, or be used to supplement internal SRAM present within the CPU chip
itself. Given a correct address decoding circuit, and assuming that the
memory device is modelled, Proteus VSM will correctly simulate such designs
as drawn. When the CPU accesses external memory, the model will drive the
address, data and control lines appropriately, and external decode logic and
memory model will respond by reading or writing the appropriate locations.
This is quite useful if you wish to verify that your memory decoding
circuitry works as designed, but is also extremely expensive in terms of
computation. Setting up a 16 bit address will create a minimum of 16 digital
events and reading or writing a byte of data to/from data bus will generate
another 8. Removing the data from the bus afterwards will create another 8
events. Where address and data lines are multiplexed, as in the above HC11
design, even more events will be generated. All this compares very
unfavourably with the ability of a VSM CPU model to execute an instruction
using just one event per machine cycle.
Therefore, we have provided the CPU models with the ability to simulate
accesses to external memory internally to the model. At the time of writing
this applies to the 8051,
HC11 and the larger AVR CPU models. External memory may be declared using
EXTRAM, or EXTROM properties which specify the memory range for each block of
external memory. Full details are provided in the model specific help for
these processors, which you can access from the Edit Component dialogue form,
or from the Start Menu.
Once the external memory map has been defined in this way, instructions which
access external memory within the specified ranges can be simulated without
generating large numbers of digital events. Accesses to memory mapped
peripherals can still be fully simulated, since these will lie at locations
outside the memory ranges specified in the EXTRAM and EXTROM properties.
这里就列出了所有问题的根源了;各位朋友不妨多看看这里的英文帮助,磨刀不误砍柴工,这里的帮助内容比任何人的经验之谈要高明得多;
好了,让我来读读这里的帮助,下面是我读出的基本内容之一:
第一:使用数字式的电阻和二极管(Using Digital Resistor and Diode Models)
这句话是我的翻译,原文的意思是如果把所有的二极管和电阻都看成是模拟量那样仿真的话,Proteus的速度会大大下降;所以所有的上拉电阻都可以看成是数字量的模拟(原文是:Therefore, pull up resistors of any kind should almost always bemodelled digitally.);而一些作为逻辑门电路用的二极管也可以看成数字式的;因此,需要对仿真的元件进行设置。
1)对电阻的设置(How to Select the Digital Resistor Model) How to Select the Digital Resistor Model1.    Point at the resistor you wish to change and press CTRL-E.
2.    Click the Edit All Properties as Text checkbox.
3.    Change the PRIMITIVE property to read      
PRIMITIVE=DIGITAL,RESISTOR
2)对二极管的设置(How to Select the Digital Diode Model)
1.    Point at the diode you wish to change and press CTRL-E.
2.    Click the Edit All Properties as Text checkbox.
3.    Change the PRIMITIVE property to read
       PRIMITIVE=DIGITAL,DIODE
4.    Delete any MODEL property, as SPICE parameters have no meaning for thedigital diode model       另外说明,在编辑Properties时,在文本框里键入的内容若用中括号{}括起来,那么在仿真界面就不会显示出来,比如
{MODFILE=74AND2.MDF}
{PACKAGE=DIL14}
{ITFMOD=TTL}
第二:Optimizing Memory Accesses to External RAM and ROM
这个问题我还没有遇到过,也不太明白其中的内容,希望比较熟悉单片机方面有的朋友做补充了!!!