AVR MCU Hardware/Software Co-simulation Using VMLAB

Publisher:素心悠远Latest update time:2012-04-22 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Preface

In the process of single-chip microcomputer application development, after the source file is compiled successfully, simulation debugging work must be carried out. Simulation debugging can be divided into two categories-chip-level simulation and code-level simulation. Chip-level simulation refers to the use of simulation software and ICE hardware tools to perform simulation debugging work on actual hardware; while code-level simulation is completed entirely on the computer without the participation of hardware. The two types of simulation have their own characteristics and are used in different occasions. Based on VMLAB, this article describes the method of hardware/software co-simulation of AVR single-chip microcomputers.

The full name of VMLAB is VisualMicroLab. It is designed for AVR and ST62 series microcontrollers. It is a virtual prototype framework for microcontrollers. It can provide users with a real virtual microcontroller (MCU) design laboratory. It has a powerful multi-window, multi-file editor, an integrated development environment for microcontrollers, a series of integrated development tools, a graphical interface debugger, a mixed-mode analog-digital circuit simulator, a code quality checker, and so on. Hardware and application software can be simulated concurrently, compared with which, the online hardware emulator (ICE) seems to lose its meaning. VMLAB can simulate more peripherals including analog components based on MCU, and it has interactive device (buttons, potentiometers, LCD display) simulation functions.

Co-simulation in VMLAB

First, let me introduce two concepts:

1) Virtual prototype

A virtual prototype is a concentrated embodiment of a specific application, which is a collection of software and hardware. The role of a virtual prototype is to simulate the behavior of the application before implementing it.

2) Hardware/software co-simulation (hw/swco-simulation)

Hardware/software co-simulation means that for a specific application, all features, including hardware and software, are simulated and implemented using a virtual prototype. VMLAB implements co-simulation based on a co-simulation engine called CCCP (Concurrent Co-simulator of Circuits and Processors).

One of the great benefits of using a virtual prototype based on a specific application is that the hardware part can be simulated through the virtual prototype, which will undoubtedly increase the development speed and no longer require an in-circuit emulator (ICE) tool, and the cost will undoubtedly be greatly reduced.

In VMLAB, simulation is managed through the project file *.prj. Some syntax keywords of the project file are shown in Table 1.

Table 1: VMLAB project file syntax keywords

The simulation experiment needs to be carried out according to the following steps:

1) Generate a project file, select the microcontroller type, and specify the source file.

2) Add or modify the hardware connection relationship of the microcontroller periphery in the project file.

3) In the "view'CodeNotebook" window on the menu bar, create or modify the source file code.

4) Use the "project'build" command on the menu bar (or press F9) to compile and generate the hardware/software database. You can observe error or warning messages through the "CodeMaker" item in the "view'Messages" window on the menu bar.

5) When there are no errors in the compilation, the green light in the VMLAB toolbar will light up. Click this green light and the simulation will continue to run. You can use the toolbar to control the simulation process, or you can use the menu bar "Run'..." to control the simulation process.

6) After all application characteristics are simulated, download the *.hex file to the microcontroller.

Introduction to Basic Hardware Libraries in VMLAB

The basic hardware library in VMLAB is divided into four parts, each part contains different basic hardware.

1) Basic analog devices

It includes resistors, grounding capacitors, grounding buttons, and LEDs. The buttons and LEDs are all connected to the control panel, as shown in Figure 1.

2) Voltage generator

Including pulse voltage source, sinusoidal wave voltage source and potentiometer (sliding resistor).

3) Interactive non-return-to-zero code generator (NRZ-generator)

4) Other macro-models

Includes: Operational Amplifier (OPAMP), Comparator (COMP), Two-input NOR Gate (ND2), 8-bit DA Converter (D2A8), RS232, LCD Model, I2C Monitor, 44 Matrix Keyboard.

Co-simulation Example

As shown in Figure 2, a small AC signal is amplified by the operational amplifier and added to the AD input terminal of the microcontroller Atmega16.

The connection of the peripheral circuit can be achieved by adding the following line information to the project file:

;------------------------------------------------- ----------

XopOPAMPampposampnegPA7; add an operational amplifier

R1GNDampneg100K; add R1

R2PA7ampneg300K; add R2

VsinampposVSSSIN(0.40.220); add a signal source,

PLOTV(PA7)V(amppos); Observe the voltage of PA7 and amppos nodes in the scope window

state

;------------------------------------------------- ----------

In VMLAB, users can define simulation node names themselves. For example, amppos and ampneg above are two user-defined nodes. Letters, underscores, and numbers can be used in node names, and pins of various types of microcontrollers pre-defined in VMLAB can also be used.

Conclusion

Compared with other similar code-level simulation tools, VMLAB has the advantage that hardware simulation is completely computer-based and does not require the addition of actual hardware. As a simulation platform, VMLAB can not only simulate most of the characteristics of MCU and other peripherals, but also perform co-simulation on applications involving analog quantities. The simulation function of VMLAB is even comparable to that of ICE hardware tools, and the use of VMLAB will undoubtedly greatly reduce development costs.

Reference address:AVR MCU Hardware/Software Co-simulation Using VMLAB

Previous article:Design of BDM Debugging System for Motorola Microprocessor
Next article:Temperature acquisition instrument made of CD4051 and AD595

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号